@cursor/july 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +16 -5
- package/README.md +8 -9
- package/dist/bin/agent-serve.d.ts +3 -1
- package/dist/bin/agent-serve.d.ts.map +1 -1
- package/dist/bin/agent-serve.js +416 -155
- package/dist/channels/slack/log.d.ts +1 -1
- package/dist/channels/slack/log.d.ts.map +1 -1
- package/dist/channels/slack/log.js +4 -5
- package/dist/channels/slack/setup.js +1 -1
- package/dist/channels/slack/socket-mode.d.ts.map +1 -1
- package/dist/channels/slack/socket-mode.js +10 -9
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.Oje4vhlk.js → app.DF-Yx4OP.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.0XrheBv2.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.H5XZ2zCB.js → VPLocalSearchBox.DSeJSudL.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CTR_TuaE.js → theme.DZVLTXOC.js} +2 -2
- package/dist/docs/assets/{index.md.m81y7TY7.js → index.md.Cylk70gg.js} +1 -1
- package/dist/docs/assets/{quickstart.md.CfU8_uTC.js → quickstart.md.BU6Iwi_9.js} +18 -6
- package/dist/docs/assets/{reference_cli.md.DA730zCu.js → reference_cli.md.Bv6pOxcF.js} +11 -6
- package/dist/docs/assets/{reference_cli.md.DA730zCu.lean.js → reference_cli.md.Bv6pOxcF.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +3 -3
- package/dist/docs/concepts.html +3 -3
- package/dist/docs/deployment.html +3 -3
- package/dist/docs/evals.html +3 -3
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +3 -3
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/slack.html +3 -3
- package/dist/docs/guides/webhooks.html +3 -3
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +5 -5
- package/dist/docs/quickstart.html +22 -10
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/channels.html +3 -3
- package/dist/docs/reference/cli.html +14 -9
- package/dist/docs/reference/connections.html +3 -3
- package/dist/docs/reference/hooks.html +3 -3
- package/dist/docs/reference/http-api.html +3 -3
- package/dist/docs/reference/instructions.html +3 -3
- package/dist/docs/reference/playground.html +3 -3
- package/dist/docs/reference/project-layout.html +3 -3
- package/dist/docs/reference/schedules.html +3 -3
- package/dist/docs/reference/sessions.html +3 -3
- package/dist/docs/reference/skills.html +3 -3
- package/dist/docs/reference/subagents.html +3 -3
- package/dist/docs/reference/tools.html +3 -3
- package/dist/docs/scaffolding-agents.html +3 -3
- package/dist/docs/storage.html +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/internal/ab-collector.js +3 -3
- package/dist/internal/ab-fold.js +1 -1
- package/dist/internal/chat-client.d.ts +29 -3
- package/dist/internal/chat-client.d.ts.map +1 -1
- package/dist/internal/chat-client.js +180 -27
- package/dist/internal/cli-ax.d.ts +83 -2
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +626 -52
- package/dist/internal/cli-cursor.d.ts.map +1 -1
- package/dist/internal/cli-cursor.js +8 -36
- package/dist/internal/cli-deploy.d.ts +59 -3
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +316 -38
- package/dist/internal/cli-github.js +13 -13
- package/dist/internal/cursor/account-mcp.js +3 -3
- package/dist/internal/cursor/backend-client.js +1 -1
- package/dist/internal/cursor/credentials.d.ts +14 -3
- package/dist/internal/cursor/credentials.d.ts.map +1 -1
- package/dist/internal/cursor/credentials.js +21 -6
- package/dist/internal/cursor/github-credentials.js +3 -3
- package/dist/internal/cursor-event-relay.js +1 -1
- package/dist/internal/cursor-relay-core.d.ts +1 -1
- package/dist/internal/cursor-relay-core.d.ts.map +1 -1
- package/dist/internal/cursor-relay-core.js +2 -1
- package/dist/internal/cursor-slack-relay.js +1 -1
- package/dist/internal/deploy-client.d.ts +9 -1
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +23 -3
- package/dist/internal/deploy-source.d.ts +35 -0
- package/dist/internal/deploy-source.d.ts.map +1 -0
- package/dist/internal/deploy-source.js +118 -0
- package/dist/internal/discovery.d.ts +11 -0
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +43 -14
- package/dist/internal/distribution.d.ts +7 -0
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +7 -0
- package/dist/internal/docs-site.js +3 -3
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +10 -9
- package/dist/internal/eval-runner.d.ts +2 -0
- package/dist/internal/eval-runner.d.ts.map +1 -1
- package/dist/internal/eval-runner.js +2 -0
- package/dist/internal/event-mapper.d.ts +54 -1
- package/dist/internal/event-mapper.d.ts.map +1 -1
- package/dist/internal/event-mapper.js +151 -41
- package/dist/internal/github-fanout.js +2 -2
- package/dist/internal/host-platforms.js +5 -5
- package/dist/internal/init-project.d.ts +88 -1
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +221 -31
- package/dist/internal/install-cursor-skills.d.ts +64 -0
- package/dist/internal/install-cursor-skills.d.ts.map +1 -0
- package/dist/internal/install-cursor-skills.js +274 -0
- package/dist/internal/logs-client.d.ts +60 -0
- package/dist/internal/logs-client.d.ts.map +1 -0
- package/dist/internal/logs-client.js +311 -0
- package/dist/internal/mcp-endpoint.d.ts.map +1 -1
- package/dist/internal/mcp-endpoint.js +1 -1
- package/dist/internal/open-browser.d.ts +5 -0
- package/dist/internal/open-browser.d.ts.map +1 -0
- package/dist/internal/open-browser.js +34 -0
- package/dist/internal/playground/toolchain.d.ts.map +1 -1
- package/dist/internal/playground/toolchain.js +19 -14
- package/dist/internal/playground-proxy.d.ts +69 -0
- package/dist/internal/playground-proxy.d.ts.map +1 -0
- package/dist/internal/playground-proxy.js +468 -0
- package/dist/internal/prompt-context.d.ts +35 -0
- package/dist/internal/prompt-context.d.ts.map +1 -0
- package/dist/internal/prompt-context.js +71 -0
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +11 -11
- package/dist/internal/request-headers.d.ts +11 -0
- package/dist/internal/request-headers.d.ts.map +1 -0
- package/dist/internal/request-headers.js +14 -0
- package/dist/internal/resolve-prod-target.d.ts +44 -0
- package/dist/internal/resolve-prod-target.d.ts.map +1 -0
- package/dist/internal/resolve-prod-target.js +134 -0
- package/dist/internal/resolved-connections.js +5 -5
- package/dist/internal/run-client.d.ts +2 -2
- package/dist/internal/run-client.d.ts.map +1 -1
- package/dist/internal/run-client.js +38 -23
- package/dist/internal/schedule-runner.js +1 -1
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +23 -17
- package/dist/internal/session-engine.d.ts +1 -1
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +34 -19
- package/dist/internal/sessions-client.d.ts +34 -0
- package/dist/internal/sessions-client.d.ts.map +1 -0
- package/dist/internal/sessions-client.js +193 -0
- package/dist/internal/storage-coordinator.js +6 -6
- package/dist/internal/stream-progress.d.ts.map +1 -1
- package/dist/internal/stream-progress.js +31 -3
- package/dist/internal/terminal-style.d.ts +22 -0
- package/dist/internal/terminal-style.d.ts.map +1 -0
- package/dist/internal/terminal-style.js +49 -0
- package/dist/internal/trajectory.d.ts +10 -5
- package/dist/internal/trajectory.d.ts.map +1 -1
- package/dist/internal/trajectory.js +82 -10
- package/dist/internal/update-check.d.ts +93 -0
- package/dist/internal/update-check.d.ts.map +1 -0
- package/dist/internal/update-check.js +431 -0
- package/dist/internal/workspace.d.ts +11 -0
- package/dist/internal/workspace.d.ts.map +1 -1
- package/dist/internal/workspace.js +38 -4
- package/dist/playground/assets/index-Ct_Usdm8.css +1 -0
- package/dist/playground/assets/index-Dsyb-Vaj.js +319 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +29 -2
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +0 -1
- package/docs/quickstart.md +22 -7
- package/docs/reference/cli.md +51 -3
- package/package.json +4 -1
- package/skills/ab/SKILL.md +8 -8
- package/skills/create-agent/SKILL.md +28 -22
- package/skills/debug/SKILL.md +11 -11
- package/skills/evals/SKILL.md +16 -16
- package/skills/framework-map/SKILL.md +6 -6
- package/skills/github/SKILL.md +13 -13
- package/skills/hillclimb/SKILL.md +10 -10
- package/skills/setup-slack/SKILL.md +14 -14
- package/src/bin/agent-serve.ts +451 -191
- package/src/channels/slack/log.ts +5 -5
- package/src/channels/slack/setup.ts +1 -1
- package/src/channels/slack/socket-mode.ts +11 -9
- package/src/internal/ab-collector.ts +3 -3
- package/src/internal/ab-fold.ts +1 -1
- package/src/internal/chat-client.ts +252 -37
- package/src/internal/cli-ax.ts +761 -72
- package/src/internal/cli-cursor.ts +14 -42
- package/src/internal/cli-deploy.ts +428 -49
- package/src/internal/cli-github.ts +13 -15
- package/src/internal/cursor/account-mcp.ts +3 -3
- package/src/internal/cursor/backend-client.ts +1 -1
- package/src/internal/cursor/credentials.ts +26 -7
- package/src/internal/cursor/github-credentials.ts +3 -3
- package/src/internal/cursor-event-relay.ts +1 -1
- package/src/internal/cursor-relay-core.ts +4 -2
- package/src/internal/cursor-slack-relay.ts +1 -1
- package/src/internal/deploy-client.ts +45 -4
- package/src/internal/deploy-source.ts +133 -0
- package/src/internal/discovery.ts +53 -16
- package/src/internal/distribution.ts +8 -0
- package/src/internal/docs-site.ts +3 -3
- package/src/internal/eval-run-store.ts +10 -11
- package/src/internal/eval-runner.ts +5 -0
- package/src/internal/event-mapper.ts +222 -42
- package/src/internal/github-fanout.ts +2 -2
- package/src/internal/host-platforms.ts +5 -5
- package/src/internal/init-project.ts +333 -51
- package/src/internal/install-cursor-skills.ts +327 -0
- package/src/internal/logs-client.ts +442 -0
- package/src/internal/mcp-endpoint.ts +1 -3
- package/src/internal/open-browser.ts +41 -0
- package/src/internal/playground/toolchain.ts +18 -16
- package/src/internal/playground-proxy.ts +576 -0
- package/src/internal/prompt-context.ts +95 -0
- package/src/internal/reminder-runner.ts +11 -17
- package/src/internal/request-headers.ts +23 -0
- package/src/internal/resolve-prod-target.ts +182 -0
- package/src/internal/resolved-connections.ts +5 -5
- package/src/internal/run-client.ts +39 -36
- package/src/internal/schedule-runner.ts +1 -1
- package/src/internal/server.ts +25 -16
- package/src/internal/session-engine.ts +35 -18
- package/src/internal/sessions-client.ts +216 -0
- package/src/internal/storage-coordinator.ts +6 -6
- package/src/internal/stream-progress.ts +36 -2
- package/src/internal/terminal-style.ts +74 -0
- package/src/internal/trajectory.ts +91 -13
- package/src/internal/update-check.ts +552 -0
- package/src/internal/workspace.ts +42 -4
- package/src/types.ts +45 -7
- package/dist/docs/assets/chunks/@localSearchIndexroot.zwQ9RCQ7.js +0 -1
- package/dist/playground/assets/index-B1Qc9h2u.css +0 -1
- package/dist/playground/assets/index-CpDYCj8W.js +0 -79
- /package/dist/docs/assets/{index.md.m81y7TY7.lean.js → index.md.Cylk70gg.lean.js} +0 -0
- /package/dist/docs/assets/{quickstart.md.CfU8_uTC.lean.js → quickstart.md.BU6Iwi_9.lean.js} +0 -0
|
@@ -185,7 +185,7 @@ export class EvalRunStore {
|
|
|
185
185
|
await this.pruneOldRuns(config);
|
|
186
186
|
await this.enqueuePersist(snapshot, this.resolvePersist(config));
|
|
187
187
|
this.logger(
|
|
188
|
-
`[
|
|
188
|
+
`[agentkit] eval run ${runId}: starting ${cases.length} case(s)`
|
|
189
189
|
);
|
|
190
190
|
|
|
191
191
|
void this.execute(runId, {
|
|
@@ -235,7 +235,7 @@ export class EvalRunStore {
|
|
|
235
235
|
const loaded = await persist.load({ projectRoot: this.projectRoot });
|
|
236
236
|
if (!Array.isArray(loaded)) {
|
|
237
237
|
this.logger(
|
|
238
|
-
"[
|
|
238
|
+
"[agentkit] eval persistRuns.load() did not return an array; ignoring"
|
|
239
239
|
);
|
|
240
240
|
this.hydrated = true;
|
|
241
241
|
return;
|
|
@@ -262,12 +262,12 @@ export class EvalRunStore {
|
|
|
262
262
|
}
|
|
263
263
|
await this.pruneOldRuns(config);
|
|
264
264
|
this.logger(
|
|
265
|
-
`[
|
|
265
|
+
`[agentkit] hydrated ${this.runs.size} playground eval run(s) from persistRuns`
|
|
266
266
|
);
|
|
267
267
|
} catch (error) {
|
|
268
268
|
const message = error instanceof Error ? error.message : String(error);
|
|
269
269
|
this.logger(
|
|
270
|
-
`[
|
|
270
|
+
`[agentkit] failed to hydrate playground eval runs: ${message}`
|
|
271
271
|
);
|
|
272
272
|
} finally {
|
|
273
273
|
this.hydrated = true;
|
|
@@ -319,7 +319,7 @@ export class EvalRunStore {
|
|
|
319
319
|
} catch (error) {
|
|
320
320
|
const message = error instanceof Error ? error.message : String(error);
|
|
321
321
|
this.logger(
|
|
322
|
-
`[
|
|
322
|
+
`[agentkit] persistRuns.save(${run.runId}) failed: ${message}`
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
325
|
}
|
|
@@ -335,9 +335,7 @@ export class EvalRunStore {
|
|
|
335
335
|
await persist.delete(runId, { projectRoot: this.projectRoot });
|
|
336
336
|
} catch (error) {
|
|
337
337
|
const message = error instanceof Error ? error.message : String(error);
|
|
338
|
-
this.logger(
|
|
339
|
-
`[agent-serve] persistRuns.delete(${runId}) failed: ${message}`
|
|
340
|
-
);
|
|
338
|
+
this.logger(`[agentkit] persistRuns.delete(${runId}) failed: ${message}`);
|
|
341
339
|
}
|
|
342
340
|
}
|
|
343
341
|
|
|
@@ -400,7 +398,8 @@ export class EvalRunStore {
|
|
|
400
398
|
}
|
|
401
399
|
if (
|
|
402
400
|
event.type === "message.completed" &&
|
|
403
|
-
typeof event.data?.text === "string"
|
|
401
|
+
typeof event.data?.text === "string" &&
|
|
402
|
+
event.data.parentCallId === undefined
|
|
404
403
|
) {
|
|
405
404
|
c.finalText = event.data.text;
|
|
406
405
|
}
|
|
@@ -421,7 +420,7 @@ export class EvalRunStore {
|
|
|
421
420
|
run.finishedAt = new Date().toISOString();
|
|
422
421
|
await this.enqueuePersist(run, this.resolvePersist(opts.config));
|
|
423
422
|
this.logger(
|
|
424
|
-
`[
|
|
423
|
+
`[agentkit] eval run ${runId}: done — ${run.summary.passed} passed, ${run.summary.failed} failed`
|
|
425
424
|
);
|
|
426
425
|
} catch (error) {
|
|
427
426
|
const run = this.runs.get(runId);
|
|
@@ -432,7 +431,7 @@ export class EvalRunStore {
|
|
|
432
431
|
run.finishedAt = new Date().toISOString();
|
|
433
432
|
run.error = error instanceof Error ? error.message : String(error);
|
|
434
433
|
await this.enqueuePersist(run, this.resolvePersist(opts.config));
|
|
435
|
-
this.logger(`[
|
|
434
|
+
this.logger(`[agentkit] eval run ${runId}: failed — ${run.error}`);
|
|
436
435
|
} finally {
|
|
437
436
|
if (this.activeRunId === runId) {
|
|
438
437
|
this.activeRunId = undefined;
|
|
@@ -76,6 +76,8 @@ export interface RunEvalsOptions extends EvalSelectionOptions {
|
|
|
76
76
|
baseUrl: string;
|
|
77
77
|
timeoutMs?: number;
|
|
78
78
|
bearerToken?: string;
|
|
79
|
+
/** Extra request headers (e.g. hosted engineAccess). */
|
|
80
|
+
headers?: Record<string, string>;
|
|
79
81
|
verbose?: boolean;
|
|
80
82
|
onEvent?: (event: SessionEvent) => void;
|
|
81
83
|
/** Fired when a case begins executing (after concurrency slot acquired). */
|
|
@@ -240,6 +242,7 @@ export async function runDiscoveredEvals(
|
|
|
240
242
|
baseUrl: options.baseUrl,
|
|
241
243
|
defaultTimeoutMs,
|
|
242
244
|
bearerToken: options.bearerToken,
|
|
245
|
+
headers: options.headers,
|
|
243
246
|
verbose: Boolean(options.verbose),
|
|
244
247
|
onEvent: (event) => {
|
|
245
248
|
options.onCaseEvent?.(discovered.id, event);
|
|
@@ -268,6 +271,7 @@ async function runOneEval(
|
|
|
268
271
|
baseUrl: string;
|
|
269
272
|
defaultTimeoutMs: number;
|
|
270
273
|
bearerToken?: string;
|
|
274
|
+
headers?: Record<string, string>;
|
|
271
275
|
verbose: boolean;
|
|
272
276
|
onEvent?: (event: SessionEvent) => void;
|
|
273
277
|
}
|
|
@@ -330,6 +334,7 @@ async function runOneEval(
|
|
|
330
334
|
// Keep defineEval traffic out of live defineAB enrollment/metrics.
|
|
331
335
|
purpose: "eval",
|
|
332
336
|
bearerToken: opts.bearerToken,
|
|
337
|
+
headers: opts.headers,
|
|
333
338
|
workspaceDir: options.workspaceDir,
|
|
334
339
|
workspaceFiles: options.workspaceFiles,
|
|
335
340
|
timeoutMs,
|
|
@@ -4,11 +4,63 @@
|
|
|
4
4
|
* (`SessionEvent` payloads). One mapper instance covers one turn.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
InteractionUpdate as SdkInteractionUpdate,
|
|
9
|
+
ToolCall,
|
|
10
|
+
} from "@cursor/sdk";
|
|
8
11
|
import type { SessionEventPayload, TurnUsage } from "../types.js";
|
|
9
12
|
|
|
10
13
|
const CUSTOM_TOOLS_PROVIDER = "custom-user-tools";
|
|
11
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Nested interaction updates from a task/subagent tool-call-delta.
|
|
17
|
+
* Mirrored locally so agent-serve typechecks against published `@cursor/sdk`
|
|
18
|
+
* versions that do not yet export `NestedTaskUpdate` / `tool-call-delta`.
|
|
19
|
+
*/
|
|
20
|
+
type NestedTaskUpdate =
|
|
21
|
+
| { type: "text-delta"; text: string }
|
|
22
|
+
| { type: "thinking-delta"; text: string }
|
|
23
|
+
| { type: "thinking-completed"; thinkingDurationMs: number }
|
|
24
|
+
| {
|
|
25
|
+
type: "tool-call-started";
|
|
26
|
+
callId: string;
|
|
27
|
+
toolCall: ToolCall;
|
|
28
|
+
modelCallId: string;
|
|
29
|
+
}
|
|
30
|
+
| {
|
|
31
|
+
type: "tool-call-completed";
|
|
32
|
+
callId: string;
|
|
33
|
+
toolCall: ToolCall;
|
|
34
|
+
modelCallId: string;
|
|
35
|
+
}
|
|
36
|
+
| {
|
|
37
|
+
type: "partial-tool-call";
|
|
38
|
+
callId: string;
|
|
39
|
+
toolCall: ToolCall;
|
|
40
|
+
modelCallId: string;
|
|
41
|
+
}
|
|
42
|
+
| { type: "step-started"; stepId: number }
|
|
43
|
+
| { type: "step-completed"; stepId: number; stepDurationMs: number };
|
|
44
|
+
|
|
45
|
+
type ToolCallDeltaUpdate = {
|
|
46
|
+
type: "tool-call-delta";
|
|
47
|
+
callId: string;
|
|
48
|
+
modelCallId: string;
|
|
49
|
+
taskUpdate: NestedTaskUpdate;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** SDK updates plus nested task deltas once the SDK exposes them. */
|
|
53
|
+
type InteractionUpdate = SdkInteractionUpdate | ToolCallDeltaUpdate;
|
|
54
|
+
|
|
55
|
+
function asToolCallDelta(
|
|
56
|
+
update: InteractionUpdate
|
|
57
|
+
): ToolCallDeltaUpdate | undefined {
|
|
58
|
+
if ((update as { type: string }).type !== "tool-call-delta") {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
return update as ToolCallDeltaUpdate;
|
|
62
|
+
}
|
|
63
|
+
|
|
12
64
|
export interface ToolCallDescription {
|
|
13
65
|
toolName: string;
|
|
14
66
|
args?: unknown;
|
|
@@ -20,12 +72,19 @@ export interface ToolResultDescription {
|
|
|
20
72
|
isError: boolean;
|
|
21
73
|
}
|
|
22
74
|
|
|
75
|
+
interface NestedAccumulators {
|
|
76
|
+
text: string;
|
|
77
|
+
reasoning: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
23
80
|
export class TurnEventMapper {
|
|
24
81
|
private textAccumulator = "";
|
|
25
82
|
private reasoningAccumulator = "";
|
|
26
83
|
private usageTotal: TurnUsage | undefined;
|
|
27
84
|
private lastAssistantText: string | undefined;
|
|
28
85
|
private summaryTitle: string | undefined;
|
|
86
|
+
/** Per-parent-call accumulators for nested subagent streams. */
|
|
87
|
+
private readonly nested = new Map<string, NestedAccumulators>();
|
|
29
88
|
|
|
30
89
|
constructor(private readonly emit: (payload: SessionEventPayload) => void) {}
|
|
31
90
|
|
|
@@ -74,49 +133,11 @@ export class TurnEventMapper {
|
|
|
74
133
|
}
|
|
75
134
|
case "tool-call-started": {
|
|
76
135
|
this.flushAssistantText("tool_call");
|
|
77
|
-
|
|
78
|
-
this.emit({
|
|
79
|
-
type: "actions.requested",
|
|
80
|
-
data: {
|
|
81
|
-
calls: [
|
|
82
|
-
{
|
|
83
|
-
callId: update.callId,
|
|
84
|
-
toolName: description.toolName,
|
|
85
|
-
args: description.args,
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
if (description.subagent !== undefined) {
|
|
91
|
-
this.emit({
|
|
92
|
-
type: "subagent.called",
|
|
93
|
-
data: {
|
|
94
|
-
callId: update.callId,
|
|
95
|
-
name: description.subagent.name,
|
|
96
|
-
description: description.subagent.description,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
}
|
|
136
|
+
this.emitToolStarted(update.callId, update.toolCall);
|
|
100
137
|
return;
|
|
101
138
|
}
|
|
102
139
|
case "tool-call-completed": {
|
|
103
|
-
|
|
104
|
-
const result = describeToolResult(update.toolCall);
|
|
105
|
-
this.emit({
|
|
106
|
-
type: "action.result",
|
|
107
|
-
data: {
|
|
108
|
-
callId: update.callId,
|
|
109
|
-
toolName: description.toolName,
|
|
110
|
-
output: result.output,
|
|
111
|
-
isError: result.isError,
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
if (description.subagent !== undefined) {
|
|
115
|
-
this.emit({
|
|
116
|
-
type: "subagent.completed",
|
|
117
|
-
data: { callId: update.callId, name: description.subagent.name },
|
|
118
|
-
});
|
|
119
|
-
}
|
|
140
|
+
this.emitToolCompleted(update.callId, update.toolCall);
|
|
120
141
|
return;
|
|
121
142
|
}
|
|
122
143
|
case "step-started": {
|
|
@@ -148,7 +169,13 @@ export class TurnEventMapper {
|
|
|
148
169
|
case "shell-output-delta":
|
|
149
170
|
return;
|
|
150
171
|
default: {
|
|
151
|
-
//
|
|
172
|
+
// Nested task/subagent progress (tool-call-delta) — accepted via
|
|
173
|
+
// structural check so we typecheck against older published SDKs.
|
|
174
|
+
const delta = asToolCallDelta(update);
|
|
175
|
+
if (delta !== undefined) {
|
|
176
|
+
this.handleNestedTaskUpdate(delta.callId, delta.taskUpdate);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
152
179
|
return;
|
|
153
180
|
}
|
|
154
181
|
}
|
|
@@ -157,6 +184,143 @@ export class TurnEventMapper {
|
|
|
157
184
|
/** Close out the turn: finalize any open assistant text block. */
|
|
158
185
|
finish(): void {
|
|
159
186
|
this.flushAssistantText("stop");
|
|
187
|
+
for (const parentCallId of this.nested.keys()) {
|
|
188
|
+
this.flushNestedAssistantText(parentCallId, "stop");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private handleNestedTaskUpdate(
|
|
193
|
+
parentCallId: string,
|
|
194
|
+
update: NestedTaskUpdate
|
|
195
|
+
): void {
|
|
196
|
+
switch (update.type) {
|
|
197
|
+
case "text-delta": {
|
|
198
|
+
const acc = this.ensureNested(parentCallId);
|
|
199
|
+
acc.text += update.text;
|
|
200
|
+
this.emit({
|
|
201
|
+
type: "message.appended",
|
|
202
|
+
data: {
|
|
203
|
+
delta: update.text,
|
|
204
|
+
text: acc.text,
|
|
205
|
+
parentCallId,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
case "thinking-delta": {
|
|
211
|
+
const acc = this.ensureNested(parentCallId);
|
|
212
|
+
acc.reasoning += update.text;
|
|
213
|
+
this.emit({
|
|
214
|
+
type: "reasoning.appended",
|
|
215
|
+
data: {
|
|
216
|
+
delta: update.text,
|
|
217
|
+
text: acc.reasoning,
|
|
218
|
+
parentCallId,
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
case "thinking-completed": {
|
|
224
|
+
const acc = this.nested.get(parentCallId);
|
|
225
|
+
if (acc !== undefined && acc.reasoning !== "") {
|
|
226
|
+
acc.reasoning = "";
|
|
227
|
+
}
|
|
228
|
+
this.emit({
|
|
229
|
+
type: "reasoning.completed",
|
|
230
|
+
data: {
|
|
231
|
+
durationMs: update.thinkingDurationMs,
|
|
232
|
+
parentCallId,
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
case "tool-call-started": {
|
|
238
|
+
this.flushNestedAssistantText(parentCallId, "tool_call");
|
|
239
|
+
this.emitToolStarted(update.callId, update.toolCall, parentCallId);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
case "tool-call-completed": {
|
|
243
|
+
this.emitToolCompleted(update.callId, update.toolCall, parentCallId);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
case "partial-tool-call":
|
|
247
|
+
case "step-started":
|
|
248
|
+
case "step-completed":
|
|
249
|
+
return;
|
|
250
|
+
default: {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private emitToolStarted(
|
|
257
|
+
callId: string,
|
|
258
|
+
toolCall: ToolCall,
|
|
259
|
+
parentCallId?: string
|
|
260
|
+
): void {
|
|
261
|
+
const description = describeToolCall(toolCall);
|
|
262
|
+
this.emit({
|
|
263
|
+
type: "actions.requested",
|
|
264
|
+
data: {
|
|
265
|
+
calls: [
|
|
266
|
+
{
|
|
267
|
+
callId,
|
|
268
|
+
toolName: description.toolName,
|
|
269
|
+
args: description.args,
|
|
270
|
+
parentCallId,
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
parentCallId,
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
// Subagent bookends only fire for the top-level task tool, not nested
|
|
277
|
+
// tools inside a subagent (nested subagents aren't supported).
|
|
278
|
+
if (description.subagent !== undefined && parentCallId === undefined) {
|
|
279
|
+
this.emit({
|
|
280
|
+
type: "subagent.called",
|
|
281
|
+
data: {
|
|
282
|
+
callId,
|
|
283
|
+
name: description.subagent.name,
|
|
284
|
+
description: description.subagent.description,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private emitToolCompleted(
|
|
291
|
+
callId: string,
|
|
292
|
+
toolCall: ToolCall,
|
|
293
|
+
parentCallId?: string
|
|
294
|
+
): void {
|
|
295
|
+
const description = describeToolCall(toolCall);
|
|
296
|
+
const result = describeToolResult(toolCall);
|
|
297
|
+
this.emit({
|
|
298
|
+
type: "action.result",
|
|
299
|
+
data: {
|
|
300
|
+
callId,
|
|
301
|
+
toolName: description.toolName,
|
|
302
|
+
output: result.output,
|
|
303
|
+
isError: result.isError,
|
|
304
|
+
parentCallId,
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
if (description.subagent !== undefined && parentCallId === undefined) {
|
|
308
|
+
this.flushNestedAssistantText(callId, "stop");
|
|
309
|
+
this.nested.delete(callId);
|
|
310
|
+
this.emit({
|
|
311
|
+
type: "subagent.completed",
|
|
312
|
+
data: { callId, name: description.subagent.name },
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
private ensureNested(parentCallId: string): NestedAccumulators {
|
|
318
|
+
let acc = this.nested.get(parentCallId);
|
|
319
|
+
if (acc === undefined) {
|
|
320
|
+
acc = { text: "", reasoning: "" };
|
|
321
|
+
this.nested.set(parentCallId, acc);
|
|
322
|
+
}
|
|
323
|
+
return acc;
|
|
160
324
|
}
|
|
161
325
|
|
|
162
326
|
private flushAssistantText(finishReason: "stop" | "tool_call"): void {
|
|
@@ -171,6 +335,22 @@ export class TurnEventMapper {
|
|
|
171
335
|
data: { text, finishReason },
|
|
172
336
|
});
|
|
173
337
|
}
|
|
338
|
+
|
|
339
|
+
private flushNestedAssistantText(
|
|
340
|
+
parentCallId: string,
|
|
341
|
+
finishReason: "stop" | "tool_call"
|
|
342
|
+
): void {
|
|
343
|
+
const acc = this.nested.get(parentCallId);
|
|
344
|
+
if (acc === undefined || acc.text === "") {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const text = acc.text;
|
|
348
|
+
acc.text = "";
|
|
349
|
+
this.emit({
|
|
350
|
+
type: "message.completed",
|
|
351
|
+
data: { text, finishReason, parentCallId },
|
|
352
|
+
});
|
|
353
|
+
}
|
|
174
354
|
}
|
|
175
355
|
|
|
176
356
|
/**
|
|
@@ -136,14 +136,14 @@ export async function fanoutDelivery(
|
|
|
136
136
|
});
|
|
137
137
|
if (!response.ok) {
|
|
138
138
|
log(
|
|
139
|
-
`[
|
|
139
|
+
`[agentkit] delivery to ${label} failed: HTTP ${response.status}\n`
|
|
140
140
|
);
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
delivered.push(label);
|
|
144
144
|
} catch (error) {
|
|
145
145
|
log(
|
|
146
|
-
`[
|
|
146
|
+
`[agentkit] delivery to ${label} failed: ${
|
|
147
147
|
error instanceof Error ? error.message : String(error)
|
|
148
148
|
}\n`
|
|
149
149
|
);
|
|
@@ -114,7 +114,7 @@ export async function warmupHostGitHubAuth(options: {
|
|
|
114
114
|
const source = options.authSource ?? (await resolveHostGitHubAuthSource());
|
|
115
115
|
if (source === "unavailable") {
|
|
116
116
|
options.logger(
|
|
117
|
-
"[
|
|
117
|
+
"[agentkit] GitHub auth: unavailable (set GITHUB_APP_ID + GITHUB_APP_PRIVATE_KEY + GITHUB_APP_INSTALLATION_ID, or GITHUB_TOKEN / GH_TOKEN, or run `gh auth login`)"
|
|
118
118
|
);
|
|
119
119
|
return source;
|
|
120
120
|
}
|
|
@@ -125,7 +125,7 @@ export async function warmupHostGitHubAuth(options: {
|
|
|
125
125
|
exportedGhToken = await ensureGhCliTokenEnv();
|
|
126
126
|
} catch (error) {
|
|
127
127
|
options.logger(
|
|
128
|
-
`[
|
|
128
|
+
`[agentkit] GitHub auth: failed to export GH_TOKEN for gh CLI: ${
|
|
129
129
|
error instanceof Error ? error.message : String(error)
|
|
130
130
|
}`
|
|
131
131
|
);
|
|
@@ -143,16 +143,16 @@ export async function warmupHostGitHubAuth(options: {
|
|
|
143
143
|
? "GITHUB_TOKEN/GH_TOKEN"
|
|
144
144
|
: "gh auth token";
|
|
145
145
|
if (options.github === undefined) {
|
|
146
|
-
options.logger(`[
|
|
146
|
+
options.logger(`[agentkit] GitHub auth: ${label}`);
|
|
147
147
|
return source;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
try {
|
|
151
151
|
await options.github.getOctokit();
|
|
152
|
-
options.logger(`[
|
|
152
|
+
options.logger(`[agentkit] GitHub auth: ${label}`);
|
|
153
153
|
} catch (error) {
|
|
154
154
|
options.logger(
|
|
155
|
-
`[
|
|
155
|
+
`[agentkit] GitHub auth: ${label} resolved but Octokit warmup failed: ${
|
|
156
156
|
error instanceof Error ? error.message : String(error)
|
|
157
157
|
}`
|
|
158
158
|
);
|