@steerable/agent-shell 0.11.0 → 0.12.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.
|
@@ -128,6 +128,9 @@ export declare class LocalBackendRouter {
|
|
|
128
128
|
* - 同步真实 messageId:`data: {"type":"message_id","messageId":"..."}`
|
|
129
129
|
* - 工具执行结果(无需用户确认):`data: {"type":"executed_actions","actions":[...]}`
|
|
130
130
|
* - 回合产物文件列表(仅非空时发,在 message_id 之前):`data: {"type":"turn_files","files":[...]}`
|
|
131
|
+
* - 回合账单(仅有时发,在 message_id 之前):`data: {"type":"turn_usage","usage":{...}}`
|
|
132
|
+
* 与 `turn_files` 同批归档:前端按 message_id 把它挂到落库消息上,刷新后
|
|
133
|
+
* 从 `messageMetadata.usage` 水合。整轮总计与子代理分项只在这一次出现。
|
|
131
134
|
* - 错误:保留 `event:error` + `data: {"message":"..."}`(前端会忽略,但日志/未来 UI 用)
|
|
132
135
|
* - 结束:标准 SSE `[DONE]` 串。
|
|
133
136
|
*/
|
|
@@ -2450,6 +2450,9 @@ export class LocalBackendRouter {
|
|
|
2450
2450
|
* - 同步真实 messageId:`data: {"type":"message_id","messageId":"..."}`
|
|
2451
2451
|
* - 工具执行结果(无需用户确认):`data: {"type":"executed_actions","actions":[...]}`
|
|
2452
2452
|
* - 回合产物文件列表(仅非空时发,在 message_id 之前):`data: {"type":"turn_files","files":[...]}`
|
|
2453
|
+
* - 回合账单(仅有时发,在 message_id 之前):`data: {"type":"turn_usage","usage":{...}}`
|
|
2454
|
+
* 与 `turn_files` 同批归档:前端按 message_id 把它挂到落库消息上,刷新后
|
|
2455
|
+
* 从 `messageMetadata.usage` 水合。整轮总计与子代理分项只在这一次出现。
|
|
2453
2456
|
* - 错误:保留 `event:error` + `data: {"message":"..."}`(前端会忽略,但日志/未来 UI 用)
|
|
2454
2457
|
* - 结束:标准 SSE `[DONE]` 串。
|
|
2455
2458
|
*/
|
|
@@ -3913,6 +3916,13 @@ export class LocalBackendRouter {
|
|
|
3913
3916
|
// `turn_active` marker survives — that marker is exactly what
|
|
3914
3917
|
// `detectInterruptedTurn` reads to offer "continue" on the next open.
|
|
3915
3918
|
let sidecarLost = false;
|
|
3919
|
+
// R6: the turn's bill, lifted out of `driveWithAutoContinue` so the
|
|
3920
|
+
// assistant row and the `turn_usage` event can carry it. It holds the
|
|
3921
|
+
// LAST pass's figures: the turn total already lives in `usage_events`
|
|
3922
|
+
// (the router writes one row per pass) and this is the per-turn view the
|
|
3923
|
+
// message shows — a resumed pass re-reads what the previous one left, so
|
|
3924
|
+
// summing passes here would double-count.
|
|
3925
|
+
let turnUsage;
|
|
3916
3926
|
// Every pass records its own sidecar trace; all of them are persisted
|
|
3917
3927
|
// against the one assistant message this turn produces.
|
|
3918
3928
|
const passTraceIds = [];
|
|
@@ -4216,9 +4226,10 @@ export class LocalBackendRouter {
|
|
|
4216
4226
|
turnPasses += 1;
|
|
4217
4227
|
// W6-9 用量归因:落一条 chat 用量事件(含成本估算,无单价模型 costUsd=null)。
|
|
4218
4228
|
// 每趟各落一条——续跑的花费是真实发生的,不该被合并掉。
|
|
4219
|
-
// R5
|
|
4220
|
-
//
|
|
4221
|
-
//
|
|
4229
|
+
// R5: 子代理的花费进同一条记录。注意 `usage.totalTokens` 与
|
|
4230
|
+
// `childTotalTokens` 是**两份并列**的账单(父级 / 子代理),不是
|
|
4231
|
+
// 「总计与其中一部分」,所以相加才是整轮成本。外部引擎子代理报
|
|
4232
|
+
// 不出 token,此时 usage_note='partial',不把缺失当零。
|
|
4222
4233
|
if (outcome.usage) {
|
|
4223
4234
|
try {
|
|
4224
4235
|
await this.store.recordUsageEvent({
|
|
@@ -4254,6 +4265,7 @@ export class LocalBackendRouter {
|
|
|
4254
4265
|
outcomeTraceId = finalOutcome.traceId;
|
|
4255
4266
|
autoContinuations = finalContinuations;
|
|
4256
4267
|
sidecarLost = finalOutcome.sidecarLost === true;
|
|
4268
|
+
turnUsage = finalOutcome.usage;
|
|
4257
4269
|
// 干净失败的趟(sidecar 正常收流但 status=failed,如 LLM 401/超时)
|
|
4258
4270
|
// 不走下面的 catch——这里补发 error 事件,否则前端只渲染一条空消息,
|
|
4259
4271
|
// 用户完全看不到失败原因。
|
|
@@ -4391,6 +4403,11 @@ export class LocalBackendRouter {
|
|
|
4391
4403
|
...(durationMs != null ? { durationMs } : {}),
|
|
4392
4404
|
...(autoContinuations > 0 ? { autoContinuations } : {}),
|
|
4393
4405
|
...(turnFiles.length > 0 ? { turnFiles } : {}),
|
|
4406
|
+
// R6: the turn's bill, kept on the row so a replayed message shows
|
|
4407
|
+
// the same figures the live turn did — the child rows only carry
|
|
4408
|
+
// their own slice, and the per-turn total is not derivable from
|
|
4409
|
+
// them (the parent's own spend is not in any child).
|
|
4410
|
+
...(turnUsage ? { usage: turnUsage } : {}),
|
|
4394
4411
|
...(failureInfo ? { failure: failureInfo } : {}),
|
|
4395
4412
|
}));
|
|
4396
4413
|
if (!sidecarLost) {
|
|
@@ -4503,6 +4520,14 @@ export class LocalBackendRouter {
|
|
|
4503
4520
|
if (turnFiles.length > 0) {
|
|
4504
4521
|
emit(this.sseData({ type: 'turn_files', files: turnFiles }));
|
|
4505
4522
|
}
|
|
4523
|
+
// R6: the turn's bill, emitted just before `message_id` so it archives
|
|
4524
|
+
// with the rest of the turn's queues. This is the only place the parent's
|
|
4525
|
+
// own spend and the children's share appear together — the child rows
|
|
4526
|
+
// carry only their own slice, so a host that wants "what did this turn
|
|
4527
|
+
// cost, and how much of it was sub-agents" cannot add them up itself.
|
|
4528
|
+
if (turnUsage) {
|
|
4529
|
+
emit(this.sseData({ type: 'turn_usage', usage: turnUsage }));
|
|
4530
|
+
}
|
|
4506
4531
|
if (assistant) {
|
|
4507
4532
|
emit(this.sseData({ type: 'message_id', messageId: assistant.id }));
|
|
4508
4533
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steerable/agent-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Steerable framework — product-neutral Node HostRuntime and headless HTTP server shared by Tauri desktop and browser deployments; scenario packs extend it through @steerable/pack-sdk.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://steerableframework.com/",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"jpeg-js": "^0.4.4",
|
|
54
54
|
"node-pty": "^1.1.0",
|
|
55
55
|
"pngjs": "^7.0.0",
|
|
56
|
-
"@steerable/agent-
|
|
57
|
-
"@steerable/agent-
|
|
58
|
-
"@steerable/
|
|
59
|
-
"@steerable/
|
|
56
|
+
"@steerable/agent-protocol": "0.12.0",
|
|
57
|
+
"@steerable/agent-runtime": "0.12.0",
|
|
58
|
+
"@steerable/pack-sdk": "0.12.0",
|
|
59
|
+
"@steerable/agent-harness": "0.12.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/better-sqlite3": "^7.6.13",
|