@introspection-ai/recipes 0.65.0 → 0.66.0
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/dist/agent-tool/arguments.d.ts +4 -2
- package/dist/agent-tool/arguments.d.ts.map +1 -1
- package/dist/agent-tool/arguments.generated.d.ts.map +1 -1
- package/dist/agent-tool/arguments.generated.js +6 -2
- package/dist/agent-tool/arguments.generated.js.map +1 -1
- package/dist/agent-tool/run-cwd.d.ts +18 -0
- package/dist/agent-tool/run-cwd.d.ts.map +1 -0
- package/dist/agent-tool/run-cwd.js +49 -0
- package/dist/agent-tool/run-cwd.js.map +1 -0
- package/dist/agents.d.ts +25 -2
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +112 -64
- package/dist/agents.js.map +1 -1
- package/dist/batch/agent-batches.d.ts +10 -0
- package/dist/batch/agent-batches.d.ts.map +1 -1
- package/dist/batch/agent-batches.js +68 -12
- package/dist/batch/agent-batches.js.map +1 -1
- package/dist/batch/index.d.ts +2 -0
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +2 -1
- package/dist/batch/index.js.map +1 -1
- package/dist/batch/lines.d.ts +2 -2
- package/dist/batch/lines.d.ts.map +1 -1
- package/dist/batch/lines.js +4 -2
- package/dist/batch/lines.js.map +1 -1
- package/dist/batch/runner.d.ts +2 -0
- package/dist/batch/runner.d.ts.map +1 -1
- package/dist/batch/runner.js +1 -1
- package/dist/batch/runner.js.map +1 -1
- package/dist/child/agent-completions.d.ts +25 -8
- package/dist/child/agent-completions.d.ts.map +1 -1
- package/dist/child/agent-completions.js +68 -16
- package/dist/child/agent-completions.js.map +1 -1
- package/dist/child/agent-store.d.ts +4 -0
- package/dist/child/agent-store.d.ts.map +1 -1
- package/dist/child/agent-store.js +18 -0
- package/dist/child/agent-store.js.map +1 -1
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +44 -47
- package/dist/pi-extension.js.map +1 -1
- package/dist/recipe/manifest.generated.d.ts +1 -1
- package/dist/recipe/manifest.generated.js +1 -1
- package/dist/run-controller.d.ts.map +1 -1
- package/dist/run-controller.js +13 -2
- package/dist/run-controller.js.map +1 -1
- package/docs/agent-batch.md +14 -4
- package/docs/agent-composition.md +20 -7
- package/package.json +5 -5
|
@@ -33,25 +33,85 @@ function compactTokens(count) {
|
|
|
33
33
|
return `${Math.round(count / 1_000_000)}M`;
|
|
34
34
|
}
|
|
35
35
|
/** `↑212 ↓53k`, input and output tokens as Pi's footer writes them, each left out at 0. */
|
|
36
|
-
|
|
36
|
+
function tokenText(input, output) {
|
|
37
37
|
return [
|
|
38
38
|
...(input > 0 ? [`↑${compactTokens(input)}`] : []),
|
|
39
39
|
...(output > 0 ? [`↓${compactTokens(output)}`] : []),
|
|
40
40
|
].join(" ");
|
|
41
41
|
}
|
|
42
42
|
/** `$0.004 (sub)`, to three places as Pi's footer shows cost; none for a run whose models have no price. */
|
|
43
|
-
|
|
43
|
+
function costText(cost, pricing) {
|
|
44
44
|
if (pricing?.priced === false)
|
|
45
45
|
return undefined;
|
|
46
46
|
return `$${cost.toFixed(3)}${pricing?.subscription ? " (sub)" : ""}`;
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
49
|
-
export function
|
|
48
|
+
/** A run's usage as its snapshot counts it, in the shape its lines take. */
|
|
49
|
+
export function runUsage(usage, pricing) {
|
|
50
|
+
if (!usage)
|
|
51
|
+
return undefined;
|
|
52
|
+
return {
|
|
53
|
+
input_tokens: usage.input,
|
|
54
|
+
output_tokens: usage.output,
|
|
55
|
+
cost_usd: usage.cost,
|
|
56
|
+
...(pricing ? { pricing } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A run's own usage plus what it reported for work it ran elsewhere, as one
|
|
61
|
+
* figure. A reported cost is not on the run's subscription, so it drops `(sub)`.
|
|
62
|
+
*/
|
|
63
|
+
export function combinedUsage(own, reported) {
|
|
64
|
+
if (!reported ||
|
|
65
|
+
reported.input_tokens + reported.output_tokens + reported.cost_usd === 0)
|
|
66
|
+
return own;
|
|
67
|
+
const pricing = reported.cost_usd > 0
|
|
68
|
+
? { subscription: false, priced: true }
|
|
69
|
+
: own?.pricing;
|
|
70
|
+
return {
|
|
71
|
+
input_tokens: (own?.input_tokens ?? 0) + reported.input_tokens,
|
|
72
|
+
output_tokens: (own?.output_tokens ?? 0) + reported.output_tokens,
|
|
73
|
+
cost_usd: (own?.cost_usd ?? 0) + reported.cost_usd,
|
|
74
|
+
...(pricing ? { pricing } : {}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Several runs' pricing: a subscription only if every one is, priced if any one is. */
|
|
78
|
+
export function mergePricing(a, b) {
|
|
79
|
+
if (!a || !b)
|
|
80
|
+
return a ?? b;
|
|
81
|
+
return {
|
|
82
|
+
subscription: a.subscription && b.subscription,
|
|
83
|
+
priced: a.priced || b.priced,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** Several runs' usage as one. */
|
|
87
|
+
export function sumUsage(usages) {
|
|
88
|
+
const total = { input_tokens: 0, output_tokens: 0, cost_usd: 0 };
|
|
89
|
+
for (const usage of usages) {
|
|
90
|
+
if (!usage)
|
|
91
|
+
continue;
|
|
92
|
+
total.input_tokens += usage.input_tokens ?? 0;
|
|
93
|
+
total.output_tokens += usage.output_tokens;
|
|
94
|
+
total.cost_usd += usage.cost_usd;
|
|
95
|
+
const pricing = mergePricing(total.pricing, usage.pricing);
|
|
96
|
+
if (pricing)
|
|
97
|
+
total.pricing = pricing;
|
|
98
|
+
}
|
|
99
|
+
return total;
|
|
100
|
+
}
|
|
101
|
+
/** `["↑212 ↓53k", "$0.600 (sub)"]`: a run's tokens and cost, each left out when there is none. */
|
|
102
|
+
export function usageParts(usage) {
|
|
103
|
+
if (!usage)
|
|
104
|
+
return [];
|
|
50
105
|
const tokens = tokenText(usage.input_tokens ?? 0, usage.output_tokens);
|
|
51
106
|
const cost = costText(usage.cost_usd, usage.pricing);
|
|
52
|
-
return
|
|
107
|
+
return [...(tokens ? [tokens] : []), ...(cost ? [cost] : [])];
|
|
108
|
+
}
|
|
109
|
+
/** `↑212 ↓53k · $0.600 (sub)`: a run's tokens and cost, as Pi's footer writes them. */
|
|
110
|
+
export function usageText(usage) {
|
|
111
|
+
return usageParts(usage).join(" · ");
|
|
53
112
|
}
|
|
54
|
-
|
|
113
|
+
/** `reported`: what the run reported for work it ran elsewhere, counted in its usage. */
|
|
114
|
+
export function envelopeFromRun(run, reported) {
|
|
55
115
|
if (run.status !== "completed" && run.status !== "failed")
|
|
56
116
|
return null;
|
|
57
117
|
const started = Date.parse(run.startedAt);
|
|
@@ -61,6 +121,7 @@ export function envelopeFromRun(run) {
|
|
|
61
121
|
completed >= started
|
|
62
122
|
? completed - started
|
|
63
123
|
: undefined;
|
|
124
|
+
const usage = combinedUsage(runUsage(run.usage, run.pricing), reported);
|
|
64
125
|
return {
|
|
65
126
|
id: run.id,
|
|
66
127
|
agent: run.agent,
|
|
@@ -69,16 +130,7 @@ export function envelopeFromRun(run) {
|
|
|
69
130
|
output_preview: run.output?.slice(0, OUTPUT_PREVIEW_CHARS),
|
|
70
131
|
error: run.error,
|
|
71
132
|
duration_ms: duration,
|
|
72
|
-
...(
|
|
73
|
-
? {
|
|
74
|
-
usage: {
|
|
75
|
-
input_tokens: run.usage.input,
|
|
76
|
-
output_tokens: run.usage.output,
|
|
77
|
-
cost_usd: run.usage.cost,
|
|
78
|
-
...(run.pricing ? { pricing: run.pricing } : {}),
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
: {}),
|
|
133
|
+
...(usage ? { usage } : {}),
|
|
82
134
|
};
|
|
83
135
|
}
|
|
84
136
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-completions.js","sourceRoot":"","sources":["../../src/child/agent-completions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"agent-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
45
|
pricing?: UsagePricing;
|
|
46
|
+
/** The folder the run works in, when it is not its parent's working directory. */
|
|
47
|
+
cwd?: string;
|
|
46
48
|
}
|
|
49
|
+
/** A copy of a run's persisted fields, without the live ones a run carries. */
|
|
50
|
+
export declare function snapshotOf(run: ChildRunSnapshot): ChildRunSnapshot;
|
|
47
51
|
export declare class ChildAgentRunStore {
|
|
48
52
|
private readonly root;
|
|
49
53
|
private readonly pendingWrites;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-store.d.ts","sourceRoot":"","sources":["../../src/child/agent-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,KAAK,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;AACzE,KAAK,eAAe,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,2EAA2E;AAC3E,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,E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AE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,GAAG,EAAE,gBAAgB,GAAG,gBAAgB,CAgBlE;AAkCD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAG9B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoC;IAElE,YAAY,YAAY,EAAE,MAAM,EAE/B;IAEK,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB3D;IAED;;;;OAIG;IACG,sBAAsB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAuB1D;CACF"}
|
|
@@ -11,6 +11,24 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
13
13
|
import { join } from "node:path";
|
|
14
|
+
/** A copy of a run's persisted fields, without the live ones a run carries. */
|
|
15
|
+
export function snapshotOf(run) {
|
|
16
|
+
return {
|
|
17
|
+
id: run.id,
|
|
18
|
+
agent: run.agent,
|
|
19
|
+
label: run.label,
|
|
20
|
+
prompt: run.prompt,
|
|
21
|
+
status: run.status,
|
|
22
|
+
startedAt: run.startedAt,
|
|
23
|
+
completedAt: run.completedAt,
|
|
24
|
+
output: run.output,
|
|
25
|
+
error: run.error,
|
|
26
|
+
toolCalls: run.toolCalls.map((call) => ({ ...call })),
|
|
27
|
+
...(run.usage ? { usage: { ...run.usage } } : {}),
|
|
28
|
+
...(run.pricing ? { pricing: { ...run.pricing } } : {}),
|
|
29
|
+
...(run.cwd ? { cwd: run.cwd } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
14
32
|
const RUN_STATUSES = [
|
|
15
33
|
"running",
|
|
16
34
|
"completed",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-store.js","sourceRoot":"","sources":["../../src/child/agent-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-store.js","sourceRoot":"","sources":["../../src/child/agent-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA2CjC,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,GAAqB;IAC9C,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;QACrD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,GAA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CAAC,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC;gBAClD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,sBAAsB;QAC1B,IAAI,MAAgB,CAAC;QACrB,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,SAAS,GAAuB,EAAE,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CACxB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,EACrC,MAAM,CACP,CAAC;gBACF,MAAM,MAAM,GAAG,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC1D,IAAI,MAAM,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;oBACzB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,uBAAuB;YACzB,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-extension.d.ts","sourceRoot":"","sources":["../src/pi-extension.ts"],"names":[],"mappings":"AAqBA,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAGL,KAAK,4BAA4B,EAGlC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"pi-extension.d.ts","sourceRoot":"","sources":["../src/pi-extension.ts"],"names":[],"mappings":"AAqBA,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAGL,KAAK,4BAA4B,EAGlC,MAAM,kBAAkB,CAAC;AAqC1B,OAAO,EAGL,KAAK,qBAAqB,EAS3B,MAAM,aAAa,CAAC;AAkFrB,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,YAAY,CAAC;AAiBpB,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,sBAAsB,CAAC,EAAE,4BAA4B,CAAC;IACtD,wDAAwD;IACxD,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,yFAAyF;IACzF,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,6EAA6E;IAC7E,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AA8jBD,wBAAgB,sBAAsB,CACpC,IAAI,GAAE,uBAA4B,GACjC,gBAAgB,CA+tDlB"}
|
package/dist/pi-extension.js
CHANGED
|
@@ -15,10 +15,11 @@ import { createRecipeChildAgentRunner, promptResultText, } from "./child/agent.j
|
|
|
15
15
|
import { registerGenAiSpansFile } from "./genai-spans-file.js";
|
|
16
16
|
import { loadRecipeExtensionFactory } from "./recipe/extensions.js";
|
|
17
17
|
import { bindRecipeExtensionFactory, createRecipeExtensionSessionContext, createRecipeExtensionRegistrationRegistry, } from "./extensions.js";
|
|
18
|
-
import { ChildAgentRunStore, } from "./child/agent-store.js";
|
|
19
|
-
import { ChildCompletionQueue,
|
|
18
|
+
import { ChildAgentRunStore, snapshotOf, } from "./child/agent-store.js";
|
|
19
|
+
import { ChildCompletionQueue, combinedUsage, envelopeFromRun, mergePricing, runUsage, sumUsage, usageParts, renderCompletionNotice, usageText, } from "./child/agent-completions.js";
|
|
20
20
|
import { AGENT_RUN_MESSAGE_TYPE, AgentMessageBus, renderAgentMessages, ROOT_AGENT, } from "./child/messages.js";
|
|
21
|
-
import { AGENT_RUN_EVENT_ENTRY_TYPE, notifyAgentRunEvent, persistsAgentRunEvent, agentLine, runProgress, toolActivity, } from "./agents.js";
|
|
21
|
+
import { AGENT_RUN_EVENT_ENTRY_TYPE, notifyAgentRunEvent, persistsAgentRunEvent, agentLine, runProgress, runTotals, waitedTotals, toolActivity, expandHint, } from "./agents.js";
|
|
22
|
+
import { runCwd } from "./agent-tool/run-cwd.js";
|
|
22
23
|
import { applyStreamingEvent, liveUsage, } from "./child/streaming-usage.js";
|
|
23
24
|
import { clearMcpSession, clearSessionMcpCli, configureMcpLocalConfigPath, createIsolatedMcpEnvironment, endpointBindings, formatMcpConfigurationDiagnostics, materializeMcpSession, materializeSessionMcpCli, resolveAgentMcpSelections, resolveMcpSessionServers, stopMcpDaemon, } from "./mcp/index.js";
|
|
24
25
|
import { mcpServersBehindTools } from "./mcp/policy.js";
|
|
@@ -242,22 +243,6 @@ function formatCompletionMessage(batch, options, theme) {
|
|
|
242
243
|
});
|
|
243
244
|
return blocks.join("\n");
|
|
244
245
|
}
|
|
245
|
-
function snapshotOf(run) {
|
|
246
|
-
return {
|
|
247
|
-
id: run.id,
|
|
248
|
-
agent: run.agent,
|
|
249
|
-
label: run.label,
|
|
250
|
-
prompt: run.prompt,
|
|
251
|
-
status: run.status,
|
|
252
|
-
startedAt: run.startedAt,
|
|
253
|
-
completedAt: run.completedAt,
|
|
254
|
-
output: run.output,
|
|
255
|
-
error: run.error,
|
|
256
|
-
toolCalls: run.toolCalls.map((call) => ({ ...call })),
|
|
257
|
-
...(run.usage ? { usage: { ...run.usage } } : {}),
|
|
258
|
-
...(run.pricing ? { pricing: { ...run.pricing } } : {}),
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
246
|
/** Folds how one assistant message's model is paid for into its run's pricing. */
|
|
262
247
|
function notePricing(run, event, registry) {
|
|
263
248
|
const record = asRecord(event);
|
|
@@ -277,15 +262,6 @@ function notePricing(run, event, registry) {
|
|
|
277
262
|
};
|
|
278
263
|
run.pricing = mergePricing(run.pricing, pricing);
|
|
279
264
|
}
|
|
280
|
-
/** Several runs' pricing: a subscription only if every one is, priced if any one is. */
|
|
281
|
-
function mergePricing(a, b) {
|
|
282
|
-
if (!a || !b)
|
|
283
|
-
return a ?? b;
|
|
284
|
-
return {
|
|
285
|
-
subscription: a.subscription && b.subscription,
|
|
286
|
-
priced: a.priced || b.priced,
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
265
|
/** Adds an assistant message's usage, from a child's `message_end` event, to its run's. */
|
|
290
266
|
function addMessageUsage(run, event) {
|
|
291
267
|
const record = asRecord(event);
|
|
@@ -328,7 +304,9 @@ function controllerSummary(run, status = run.status) {
|
|
|
328
304
|
const running = [...run.toolCalls]
|
|
329
305
|
.reverse()
|
|
330
306
|
.find((call) => call.status === "running");
|
|
331
|
-
|
|
307
|
+
// The last call stays on the line while the model thinks, so it doesn't flash between tools.
|
|
308
|
+
const latest = running ?? run.toolCalls.at(-1);
|
|
309
|
+
const currentActivity = latest && toolActivity(latest.name, latest.args);
|
|
332
310
|
const usage = liveUsage(run.usage, streaming?.values() ?? []);
|
|
333
311
|
return {
|
|
334
312
|
agent_run_id: run.id,
|
|
@@ -347,10 +325,15 @@ function controllerSummary(run, status = run.status) {
|
|
|
347
325
|
: Number.isFinite(startedAt)
|
|
348
326
|
? startedAt
|
|
349
327
|
: Date.now(),
|
|
350
|
-
...(running
|
|
351
|
-
|
|
328
|
+
...(running ? { current_tool: running.name } : {}),
|
|
329
|
+
...(currentActivity ? { current_activity: currentActivity } : {}),
|
|
330
|
+
...(latest && Number.isFinite(Date.parse(latest.startedAt))
|
|
331
|
+
? { activity_at: Date.parse(latest.startedAt) }
|
|
352
332
|
: {}),
|
|
353
333
|
...(run.statusNote ? { status_text: run.statusNote.text } : {}),
|
|
334
|
+
...(run.statusNote?.at !== undefined
|
|
335
|
+
? { status_at: run.statusNote.at }
|
|
336
|
+
: {}),
|
|
354
337
|
...(run.statusNote?.usage ? { reported_usage: run.statusNote.usage } : {}),
|
|
355
338
|
nested_tools: run.toolCalls.map((call) => ({
|
|
356
339
|
toolName: call.name,
|
|
@@ -373,6 +356,7 @@ function controllerSummary(run, status = run.status) {
|
|
|
373
356
|
},
|
|
374
357
|
}
|
|
375
358
|
: {}),
|
|
359
|
+
...(run.cwd ? { cwd: run.cwd } : {}),
|
|
376
360
|
};
|
|
377
361
|
}
|
|
378
362
|
function nameList(names) {
|
|
@@ -559,17 +543,15 @@ export function createRecipesExtension(opts = {}) {
|
|
|
559
543
|
const runs = [...childRuns.values()].filter((run) => run.status === "running");
|
|
560
544
|
if (runs.length === 0)
|
|
561
545
|
return undefined;
|
|
562
|
-
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
const
|
|
546
|
+
// Each run counts what it reported for work it ran elsewhere, as its own line does.
|
|
547
|
+
const usages = runs.map((run) => {
|
|
548
|
+
const own = liveUsage(run.usage, run.streaming.values());
|
|
549
|
+
return combinedUsage(runUsage(own, run.pricing), run.statusNote?.usage);
|
|
550
|
+
});
|
|
551
|
+
const total = sumUsage(usages);
|
|
568
552
|
return [
|
|
569
553
|
`${runs.length} agent${runs.length === 1 ? "" : "s"}`,
|
|
570
|
-
...(
|
|
571
|
-
? [tokenText(input, output), ...(costPart ? [costPart] : [])]
|
|
572
|
-
: []),
|
|
554
|
+
...(total.output_tokens > 0 ? usageParts(total) : []),
|
|
573
555
|
].join(" · ");
|
|
574
556
|
};
|
|
575
557
|
const watchAgents = () => {
|
|
@@ -646,7 +628,7 @@ export function createRecipesExtension(opts = {}) {
|
|
|
646
628
|
if (!state || !localAgentContext) {
|
|
647
629
|
throw new Error("No recipe session is active");
|
|
648
630
|
}
|
|
649
|
-
const run = await runChildAgent(state, input.name, input.prompt, input.label, localAgentContext, input.onUpdate);
|
|
631
|
+
const run = await runChildAgent(state, input.name, input.prompt, input.label, localAgentContext, input.onUpdate, input.cwd);
|
|
650
632
|
return controllerSummary(run);
|
|
651
633
|
},
|
|
652
634
|
async wait(id, signal) {
|
|
@@ -1323,10 +1305,11 @@ export function createRecipesExtension(opts = {}) {
|
|
|
1323
1305
|
throw error;
|
|
1324
1306
|
}
|
|
1325
1307
|
}
|
|
1326
|
-
async function runChildAgent(launchState, agentName, prompt, label, ctx, onUpdate) {
|
|
1308
|
+
async function runChildAgent(launchState, agentName, prompt, label, ctx, onUpdate, requestedCwd) {
|
|
1327
1309
|
if (label !== undefined && messages.hasName(label)) {
|
|
1328
1310
|
throw new Error(`An agent named "${label}" is already running in this session; pick another label.`);
|
|
1329
1311
|
}
|
|
1312
|
+
const where = runCwd(launchState.cwd, requestedCwd);
|
|
1330
1313
|
const id = nextChildRunId();
|
|
1331
1314
|
const inbox = createRunnerInbox(() => run.runner);
|
|
1332
1315
|
// `notifyUpdate` reads it and can run before the run record exists.
|
|
@@ -1364,7 +1347,7 @@ export function createRecipesExtension(opts = {}) {
|
|
|
1364
1347
|
const runner = createChildAgentRunner({
|
|
1365
1348
|
messages: { bus: messages, id, inbox },
|
|
1366
1349
|
recipe: launchState.resolvedRecipe,
|
|
1367
|
-
workspaceDir:
|
|
1350
|
+
workspaceDir: where.cwd,
|
|
1368
1351
|
env,
|
|
1369
1352
|
agentName,
|
|
1370
1353
|
modelRegistry: ctx.modelRegistry,
|
|
@@ -1423,6 +1406,7 @@ export function createRecipesExtension(opts = {}) {
|
|
|
1423
1406
|
startedAt: new Date().toISOString(),
|
|
1424
1407
|
toolCalls: [],
|
|
1425
1408
|
streaming: new Map(),
|
|
1409
|
+
...(where.shown ? { cwd: where.shown } : {}),
|
|
1426
1410
|
runner,
|
|
1427
1411
|
promise: Promise.resolve(undefined),
|
|
1428
1412
|
notifyUpdate,
|
|
@@ -1440,7 +1424,11 @@ export function createRecipesExtension(opts = {}) {
|
|
|
1440
1424
|
const current = run;
|
|
1441
1425
|
// A note without usage keeps the last reported total.
|
|
1442
1426
|
const usage = note.usage ?? current.statusNote?.usage;
|
|
1443
|
-
current.statusNote = {
|
|
1427
|
+
current.statusNote = {
|
|
1428
|
+
text: note.text,
|
|
1429
|
+
at: Date.now(),
|
|
1430
|
+
...(usage ? { usage } : {}),
|
|
1431
|
+
};
|
|
1444
1432
|
current.notifyUpdate();
|
|
1445
1433
|
},
|
|
1446
1434
|
}),
|
|
@@ -1498,7 +1486,7 @@ export function createRecipesExtension(opts = {}) {
|
|
|
1498
1486
|
// an empty queue, deferring delivery to the full batch window. It also
|
|
1499
1487
|
// still notifies if the disk write fails. Wait and terminal status
|
|
1500
1488
|
// reads acknowledge it back out.
|
|
1501
|
-
const envelope = envelopeFromRun(run);
|
|
1489
|
+
const envelope = envelopeFromRun(run, run.statusNote?.usage);
|
|
1502
1490
|
// A batch row is reported in its batch's results, not on its own.
|
|
1503
1491
|
if (envelope && !run.batchRow)
|
|
1504
1492
|
completions.enqueue(envelope);
|
|
@@ -1713,13 +1701,22 @@ export function createRecipesExtension(opts = {}) {
|
|
|
1713
1701
|
liveTicker = undefined;
|
|
1714
1702
|
}
|
|
1715
1703
|
};
|
|
1716
|
-
agentTool.renderResult = (result,
|
|
1704
|
+
agentTool.renderResult = (result, options, theme, context) => {
|
|
1717
1705
|
const text = context.lastComponent ?? new Text("", 0, 0);
|
|
1718
1706
|
const content = result.content
|
|
1719
1707
|
.map((part) => (part.type === "text" ? part.text : ""))
|
|
1720
1708
|
.join("\n");
|
|
1721
1709
|
const summary = asRecord(result.details)?.agent;
|
|
1722
1710
|
const live = summary ? childRuns.get(summary.agent_run_id) : undefined;
|
|
1711
|
+
const totals = !options.expanded && !options.isPartial
|
|
1712
|
+
? waitedTotals(context.args, result.details, live && controllerSummary(live))
|
|
1713
|
+
: undefined;
|
|
1714
|
+
if (totals) {
|
|
1715
|
+
const hint = expandHint(context);
|
|
1716
|
+
const suffix = hint ? ` ${themeFg(theme, "muted", `(${hint})`)}` : "";
|
|
1717
|
+
text.setText(`${totals}${suffix}`);
|
|
1718
|
+
return text;
|
|
1719
|
+
}
|
|
1723
1720
|
if (!summary || !live) {
|
|
1724
1721
|
text.setText(content);
|
|
1725
1722
|
return text;
|
|
@@ -1727,7 +1724,7 @@ export function createRecipesExtension(opts = {}) {
|
|
|
1727
1724
|
const current = controllerSummary(live);
|
|
1728
1725
|
const progress = current.status === "running"
|
|
1729
1726
|
? runProgress(current)
|
|
1730
|
-
:
|
|
1727
|
+
: runTotals(current);
|
|
1731
1728
|
const lead = `run ${summary.agent_run_id} (`;
|
|
1732
1729
|
text.setText(content
|
|
1733
1730
|
.split("\n")
|