Skip to content

feat: Stream Events v2, tool builders, run/runAndWait split (0.1.10)#10

Open
AjayaRamachandran wants to merge 3 commits into
mainfrom
coop-sdk-fixes
Open

feat: Stream Events v2, tool builders, run/runAndWait split (0.1.10)#10
AjayaRamachandran wants to merge 3 commits into
mainfrom
coop-sdk-fixes

Conversation

@AjayaRamachandran
Copy link
Copy Markdown

  • Split client.run (fire-and-forget) from client.runAndWait (polling) (R18)
  • Generic RunResult for type-narrowed answers via Zod (R10, R13)
  • Default headers / defaults options for FunctionTools at the client level (R9)
  • ResourceTool, MCPTool.headers + auth, expanded Engine union (R7, R17, R4)
  • ReasoningNode.subtasks (plural), ToolUse, RunInput.images/resources/skills/agentId (R1, R2, R3)
  • Stream parser emits StartedEvent first, parses reasoning_node/tool_call/result/error frames (R8, R15, R5)
  • New tools.{platform,function,mcp,resource} builders (R11)
  • normalizeTools auto-promotes function-tool defaults into JSON Schema parameters (R12)
  • client.observe(runId) for re-attaching to in-flight runs (R16)

27 tests pass. Requires API with Stream Events v2 support.

AjayaRamachandran and others added 3 commits May 1, 2026 14:58
- Split client.run (fire-and-forget) from client.runAndWait (polling) (R18)
- Generic RunResult<T> for type-narrowed answers via Zod (R10, R13)
- Default headers / defaults options for FunctionTools at the client level (R9)
- ResourceTool, MCPTool.headers + auth, expanded Engine union (R7, R17, R4)
- ReasoningNode.subtasks (plural), ToolUse, RunInput.images/resources/skills/agentId (R1, R2, R3)
- Stream parser emits StartedEvent first, parses reasoning_node/tool_call/result/error frames (R8, R15, R5)
- New tools.{platform,function,mcp,resource} builders (R11)
- normalizeTools auto-promotes function-tool defaults into JSON Schema parameters (R12)
- client.observe(runId) for re-attaching to in-flight runs (R16)

27 tests pass. Requires API with Stream Events v2 support.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restores options.awaitCompletion as a deprecated alias so existing
docs snippets (apps/web quickstart, playground, llms.txt, etc.) keep
working without changes:

  - RunOptions { awaitCompletion?: boolean } and RunParams.options come
    back, both marked @deprecated
  - client.run({ ..., options: { awaitCompletion: true } }) routes
    through runAndWait() and emits a one-shot console.warn
  - Refactored to a private createRunOnly() helper to break recursion
    (run -> runAndWait -> run -> ... loop)

Wire format: stream parser now reads payload.runId ?? payload.run_id
so the canonical camelCase shape is preferred but legacy snake_case
keys still parse.

ErrorCode spelling: cancelled -> canceled (one l, matches RunStatus).
README ErrorCode block updated.

README: new "Back-compat and deprecations" section documenting the
options.awaitCompletion deprecation, runId canonical/legacy policy, and
canceled spelling.

Tests: 31 pass (was 27). New tests cover the deprecation routing, no-op
options object still fire-and-forgets, legacy run_id snake_case still
parses, and canceled error code on the wire.

Co-authored-by: Cursor <cursoragent@cursor.com>
Return the terminal run status and result metadata from stream generators so consumers do not see failed SSE streams as succeeded.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant