feat(node-sdk): expose subagent task query API#37
Merged
Conversation
This was referenced May 23, 2026
The `SubagentProgress` event variant exists but until now was never sent —
the subagent task tracker introduced in the previous commit observed
Start and End but had no mid-task signal to update from.
Adds a `synthesize_subagent_progress()` helper called by the mpsc → broadcast
forwarder inside `TaskExecutor::execute_with_task_id`. It translates two
child-loop events into compact progress milestones on the parent broadcast:
- `ToolEnd` → `status = "tool_completed"`, metadata `{ tool, exit_code,
output_bytes, error_kind? }`
- `TurnEnd` → `status = "turn_completed"`, metadata `{ turn, total_tokens,
prompt_tokens, completion_tokens }`
Noisy events (TextDelta / ToolStart / ToolOutputDelta / nested Subagent*)
are intentionally not translated — consumers needing token-level detail
should subscribe to the raw event stream directly.
The original child events are still forwarded unchanged; progress is
additive, so downstream consumers see both the synthesized milestone
and the underlying event.
Mirrors the new Session APIs from the core crate so JS/TS callers can introspect delegated subagent tasks without parsing run_events. - `Session.subagentTask(taskId)` → snapshot or null - `Session.subagentTasks()` → snapshots from this session - `Session.pendingSubagentTasks()` → only `running` entries Regenerated index.d.ts also picks up doc-comment drift and napi-rs ordering churn that had accumulated since the last build. The hand-added type aliases (ToolErrorKind union, VerificationStatus / VerificationCheck / VerificationReport / ToolArtifact) are preserved — they aren't generatable from Rust and have to be reinserted around each rebuild. test.mjs gains a small smoke block confirming the three methods exist and return the expected empty-state shapes (array, array, null).
d5b3b1d to
8f0fd3a
Compare
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mirrors the core-side subagent query API (#35) onto the Node SDK so JS/TS callers don't have to parse the raw event stream.
```ts
const snap = await session.subagentTask('task-abc')
// { taskId, parentSessionId, childSessionId, agent, description,
// status: 'running' | 'completed' | 'failed',
// startedMs, updatedMs, finishedMs?, output?, success?, progress: [...] }
const all = await session.subagentTasks()
const pending = await session.pendingSubagentTasks()
```
Notes on the regenerated `index.d.ts`
The file is `auto-generated by NAPI-RS` per its header. Building picked up:
The hand-added type aliases that aren't generated from Rust — `ToolErrorKind`, `VerificationStatus`, `VerificationCheck`, `VerificationReport`, `ToolArtifact` — were lost by the regeneration and restored as part of this commit. They probably belong in a separate non-generated `index.types.ts` long-term, but that's out of scope here.
Test plan
Follow-ups