@sema-agent/server 7.125.1 → 7.127.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/MIGRATION.md +229 -2
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/USAGE.md +346 -145
- package/deploy/sema-up/README.md +1 -1
- package/deploy/sema-up/chart/templates/networkpolicy-sandbox.yaml +57 -0
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +32 -1
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +3 -2
- package/deploy/sema-up/chart/templates/server.yaml +2 -1
- package/deploy/sema-up/chart/values.yaml +22 -0
- package/deploy/sema-up/cluster-up.sh +10 -10
- package/deploy/sema-up/kube-up.sh +20 -13
- package/deploy/sema-up/lib/dataroot.sh +1 -1
- package/deploy/sema-up/lib/envf.sh +5 -5
- package/deploy/sema-up/lib/flagshape.sh +5 -5
- package/deploy/sema-up/lib/lanes.py +1 -1
- package/deploy/sema-up/lib/node-addrs.sh +42 -0
- package/deploy/sema-up/lib/parse-machines.py +2 -2
- package/deploy/sema-up/lib/shell-access.sh +1 -1
- package/deploy/sema-up/preflight.sh +4 -4
- package/deploy/sema-up/sema-up.sh +33 -33
- package/deploy/sema-up/smoke.sh +3 -3
- package/deploy/sema-up/stack/compose.yaml +1 -1
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +26 -3
- package/dist/approval-card.d.ts +20 -4
- package/dist/approval-content-kind.d.ts +38 -22
- package/dist/approval-content-kind.js +20 -4
- package/dist/audit.js +3 -0
- package/dist/bench/s1/arms.d.ts +9 -37
- package/dist/bench/s1/arms.js +4 -61
- package/dist/bench/s1/live-deps.d.ts +4 -10
- package/dist/bench/s1/live-deps.js +1 -222
- package/dist/bench/s1/oracle.d.ts +1 -1
- package/dist/bench/s1/reviewer.d.ts +1 -1
- package/dist/bench/s1/row.d.ts +5 -7
- package/dist/bench/s1/row.js +0 -2
- package/dist/bench/s1/run-firm.d.ts +2 -2
- package/dist/bench/s1/run-firm.js +1 -4
- package/dist/bench/s1/runner-ctx.d.ts +17 -29
- package/dist/bench/s1/runner-ctx.js +3 -7
- package/dist/bench/s1/tasks.d.ts +9 -46
- package/dist/bench/s1/tasks.js +4 -63
- package/dist/boot/execution-env.d.ts +38 -26
- package/dist/boot/execution-env.js +87 -41
- package/dist/boot/leader.d.ts +2 -1
- package/dist/boot/memory-boundary.d.ts +1 -1
- package/dist/boot/memory-consolidation.d.ts +37 -3
- package/dist/boot/memory-consolidation.js +18 -2
- package/dist/boot/parked-revive-gate.d.ts +0 -3
- package/dist/boot/parked-revive-gate.js +2 -2
- package/dist/boot/resolve-spec.d.ts +0 -2
- package/dist/boot/resolve-spec.js +12 -17
- package/dist/boot/retention-lane.d.ts +12 -1
- package/dist/boot/retention-lane.js +2 -0
- package/dist/boot/runner-deps.d.ts +7 -6
- package/dist/boot/runner-deps.js +5 -16
- package/dist/boot/session-faces.d.ts +7 -2
- package/dist/boot/session-faces.js +37 -1
- package/dist/boot/stage-03-store-backend.d.ts +1 -0
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -0
- package/dist/boot/stage-05-execution-env.d.ts +2 -2
- package/dist/boot/stage-05-execution-env.js +7 -4
- package/dist/boot/stage-06-runners.d.ts +2 -3
- package/dist/boot/stage-06-runners.js +13 -9
- package/dist/boot/stage-07-capability-layer.d.ts +2 -3
- package/dist/boot/stage-07-capability-layer.js +3 -4
- package/dist/boot/stage-08-reapers.d.ts +2 -3
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +2 -3
- package/dist/boot/stage-09-leader.js +2 -1
- package/dist/boot/stage-10-http-server.d.ts +2 -3
- package/dist/boot/stage-10-http-server.js +2 -2
- package/dist/boot/stores.d.ts +1 -0
- package/dist/boot/stores.js +4 -3
- package/dist/boot/web-admin.d.ts +5 -0
- package/dist/boot/web-admin.js +28 -14
- package/dist/brain.d.ts +2 -2
- package/dist/brain.js +1 -1
- package/dist/capabilities/builtin-tools.d.ts +2 -1
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/hands-lane.d.ts +9 -6
- package/dist/capabilities/hands-lane.js +2 -2
- package/dist/capabilities/memory-notice.d.ts +27 -22
- package/dist/capabilities/memory-notice.js +15 -17
- package/dist/capabilities/scenarios.d.ts +9 -14
- package/dist/capabilities/scenarios.js +5 -50
- package/dist/capability-facts.d.ts +22 -11
- package/dist/capability-facts.js +13 -6
- package/dist/config-catalog.js +14 -5
- package/dist/config-provider.d.ts +5 -1
- package/dist/config-provider.js +23 -4
- package/dist/config-types.d.ts +19 -2
- package/dist/config.js +41 -6
- package/dist/deployment-governance.d.ts +19 -21
- package/dist/deployment-governance.js +7 -8
- package/dist/env-name-allowlist-knobs.d.ts +5 -5
- package/dist/env-name-allowlist-knobs.js +1 -0
- package/dist/execution-lane-caps.d.ts +12 -0
- package/dist/execution-lane-caps.js +18 -4
- package/dist/fleet/subagent-tail-bus.js +15 -5
- package/dist/hooks/hook-runner.d.ts +84 -30
- package/dist/hooks/hook-runner.js +74 -41
- package/dist/http/admission.js +17 -10
- package/dist/http/durable-run-leg.d.ts +5 -4
- package/dist/http/durable-run-leg.js +2 -4
- package/dist/http/idempotency.d.ts +28 -6
- package/dist/http/idempotency.js +10 -2
- package/dist/http/principal-gate.d.ts +14 -0
- package/dist/http/principal-gate.js +7 -0
- package/dist/http/request-guards.d.ts +2 -1
- package/dist/http/request-guards.js +14 -14
- package/dist/http/resume-legs.d.ts +2 -2
- package/dist/http/resume-legs.js +20 -10
- package/dist/http/route-ctx.d.ts +15 -7
- package/dist/http/routes/a2a-serve.js +11 -7
- package/dist/http/routes/approvals-assistant.js +18 -3
- package/dist/http/routes/background.d.ts +1 -1
- package/dist/http/routes/background.js +1 -1
- package/dist/http/routes/capabilities.js +10 -2
- package/dist/http/routes/mcp-reconnect.js +1 -1
- package/dist/http/routes/runs.d.ts +4 -3
- package/dist/http/routes/runs.js +35 -14
- package/dist/http/routes/session-sync.js +14 -11
- package/dist/http/routes/sessions.js +9 -9
- package/dist/http/routes/side-query.js +6 -19
- package/dist/http/routes/tasks.js +29 -19
- package/dist/http/routes/workflows.js +8 -0
- package/dist/http/server.d.ts +4 -0
- package/dist/http/server.js +3 -5
- package/dist/http/submit-replay.d.ts +15 -8
- package/dist/http/submit-replay.js +6 -0
- package/dist/http/wire-types.d.ts +7 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal-run-env.d.ts +30 -0
- package/dist/internal-run-env.js +11 -0
- package/dist/leader/wire.js +3 -2
- package/dist/lsp/manager.js +1 -1
- package/dist/memory-scope.d.ts +19 -7
- package/dist/memory-scope.js +25 -8
- package/dist/observability/fail-open.d.ts +31 -3
- package/dist/observability/fail-open.js +31 -3
- package/dist/observability/metrics.d.ts +0 -1
- package/dist/observability/metrics.js +1 -4
- package/dist/observability/run-terminal.js +72 -4
- package/dist/permission-rule-vocab.d.ts +3 -2
- package/dist/permission-rule-vocab.js +1 -1
- package/dist/plan-cache-probe.d.ts +3 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +1 -1
- package/dist/plugins/caching-session-store.d.ts +42 -22
- package/dist/plugins/caching-session-store.js +19 -9
- package/dist/plugins/checkpoint-store-sql.d.ts +42 -28
- package/dist/plugins/checkpoint-store-sql.js +57 -11
- package/dist/plugins/file-run-store.d.ts +25 -21
- package/dist/plugins/file-run-store.js +70 -34
- package/dist/plugins/k8s-exec-protocol.js +3 -0
- package/dist/plugins/local-checkpoint-store.d.ts +8 -5
- package/dist/plugins/local-checkpoint-store.js +5 -15
- package/dist/plugins/local-session-store.d.ts +66 -7
- package/dist/plugins/local-session-store.js +168 -101
- package/dist/plugins/mailbox-recipient-lifecycle.d.ts +1 -1
- package/dist/plugins/memory-run-store.d.ts +19 -3
- package/dist/plugins/memory-run-store.js +38 -3
- package/dist/plugins/one-time-migrations.d.ts +165 -39
- package/dist/plugins/one-time-migrations.js +51 -144
- package/dist/plugins/pg-pool.js +11 -1
- package/dist/plugins/pg-session-storage.d.ts +2 -0
- package/dist/plugins/pg-session-storage.js +9 -5
- package/dist/plugins/remote-env-adb.d.ts +3 -0
- package/dist/plugins/remote-env-adb.js +1 -0
- package/dist/plugins/remote-env-device.d.ts +3 -0
- package/dist/plugins/remote-env-device.js +1 -0
- package/dist/plugins/remote-env-e2b.d.ts +4 -0
- package/dist/plugins/remote-env-e2b.js +2 -1
- package/dist/plugins/remote-env-host.d.ts +23 -1
- package/dist/plugins/remote-env-host.js +20 -2
- package/dist/plugins/remote-env-k8s.d.ts +264 -41
- package/dist/plugins/remote-env-k8s.js +551 -82
- package/dist/plugins/remote-env-local-docker.d.ts +4 -0
- package/dist/plugins/remote-env-local-docker.js +2 -1
- package/dist/plugins/remote-env-ssh.d.ts +3 -0
- package/dist/plugins/remote-env-ssh.js +1 -0
- package/dist/plugins/retention-store-sql.d.ts +4 -1
- package/dist/plugins/retention-store-sql.js +11 -9
- package/dist/plugins/run-store-sql.d.ts +44 -6
- package/dist/plugins/run-store-sql.js +92 -27
- package/dist/plugins/session-capture-record-store-sql.d.ts +2 -3
- package/dist/plugins/session-store.d.ts +4 -3
- package/dist/plugins/session-store.js +1 -1
- package/dist/plugins/sql-driver.d.ts +2 -1
- package/dist/plugins/store-backend.d.ts +12 -5
- package/dist/plugins/store-backend.js +13 -4
- package/dist/plugins/store-contracts.d.ts +20 -3
- package/dist/plugins/store-open-wait.js +3 -0
- package/dist/plugins/tidb-pool.js +15 -3
- package/dist/plugins/tidb-session-storage.js +3 -2
- package/dist/plugins/tidb-session-store.d.ts +2 -0
- package/dist/plugins/tidb-session-store.js +6 -2
- package/dist/request-key-closure.d.ts +32 -7
- package/dist/request-key-closure.js +25 -9
- package/dist/router/route-orchestration.d.ts +3 -11
- package/dist/router/route-orchestration.js +0 -4
- package/dist/rule-entry-list.js +0 -4
- package/dist/rules-consent.js +3 -0
- package/dist/run-acceptance.d.ts +51 -0
- package/dist/run-acceptance.js +27 -0
- package/dist/run-local.d.ts +5 -4
- package/dist/run-local.js +23 -17
- package/dist/runs.d.ts +7 -11
- package/dist/runs.js +6 -16
- package/dist/sandbox-egress-policy.d.ts +61 -0
- package/dist/sandbox-egress-policy.js +235 -0
- package/dist/security.d.ts +7 -0
- package/dist/security.js +5 -0
- package/dist/server-secret-env.d.ts +10 -4
- package/dist/server-secret-env.js +4 -1
- package/dist/session-error-wire.d.ts +2 -2
- package/dist/session-incarnation.d.ts +46 -2
- package/dist/session-incarnation.js +14 -3
- package/dist/session-sync-kernel.d.ts +10 -3
- package/dist/session-titler.d.ts +5 -3
- package/dist/spec-fields.d.ts +24 -8
- package/dist/spec-fields.js +21 -2
- package/dist/task-workflow.d.ts +6 -4
- package/dist/task-workflow.js +3 -2
- package/dist/tool-approval.d.ts +78 -6
- package/dist/tool-approval.js +7 -3
- package/dist/trace/core-keyset-guard.d.ts +6 -5
- package/dist/trace/engine-notice-wire.d.ts +26 -1
- package/dist/trace/engine-notice-wire.js +7 -2
- package/dist/trace/ledger-events.d.ts +9 -3
- package/dist/trace/ledger-sink.d.ts +7 -0
- package/dist/trace/ledger-sink.js +14 -4
- package/dist/trace/project.d.ts +57 -11
- package/dist/trace/project.js +54 -8
- package/dist/trace/self-minted-wire.d.ts +94 -2
- package/dist/trace/self-minted-wire.js +28 -0
- package/dist/trace/tool-output-media.d.ts +26 -0
- package/dist/trace/tool-output-media.js +57 -0
- package/dist/trace/wire-projection-faces.d.ts +7 -1
- package/dist/trace/wire-projection-faces.js +2 -1
- package/dist/web-admin-client/apply-effective.d.ts +13 -7
- package/dist/web-admin-client/apply-effective.js +11 -26
- package/dist/web-admin-client/apply-ledger.d.ts +2 -2
- package/dist/web-admin-client/candidate-gate.d.ts +39 -4
- package/dist/web-admin-client/candidate-gate.js +9 -2
- package/dist/web-admin-client/facade.d.ts +2 -2
- package/dist/web-admin-client/http-client.d.ts +3 -1
- package/dist/web-admin-client/http-client.js +4 -3
- package/dist/web-admin-client/read-warnings.d.ts +33 -5
- package/dist/web-admin-client/read-warnings.js +41 -6
- package/dist/web-admin-client/types.d.ts +11 -5
- package/dist/workspace-cache.d.ts +45 -0
- package/dist/workspace-cache.js +30 -0
- package/dist/workspace-space-commit.d.ts +116 -0
- package/dist/workspace-space-commit.js +117 -0
- package/dist/workspace-space.d.ts +75 -9
- package/dist/workspace-space.js +52 -1
- package/package.json +4 -4
- package/dist/boot/session-incarnation-seat.d.ts +0 -41
- package/dist/boot/session-incarnation-seat.js +0 -69
- package/dist/capabilities/code-review-council.d.ts +0 -49
- package/dist/capabilities/code-review-council.js +0 -111
- package/dist/capabilities/collab-wire.d.ts +0 -36
- package/dist/capabilities/collab-wire.js +0 -2
- package/dist/capabilities/collab-workflows.d.ts +0 -47
- package/dist/capabilities/collab-workflows.js +0 -90
- package/dist/capabilities/prompts/code-review.d.ts +0 -25
- package/dist/capabilities/prompts/code-review.js +0 -39
- package/dist/capabilities/prompts/team.d.ts +0 -10
- package/dist/capabilities/prompts/team.js +0 -6
- package/dist/capabilities/team.d.ts +0 -113
- package/dist/capabilities/team.js +0 -70
package/dist/trace/project.d.ts
CHANGED
|
@@ -150,6 +150,7 @@ export declare function toolStartEventData(ev: {
|
|
|
150
150
|
toolName: string;
|
|
151
151
|
label?: string;
|
|
152
152
|
args: unknown;
|
|
153
|
+
recovered?: true;
|
|
153
154
|
eventId?: string;
|
|
154
155
|
parentToolCallId?: string;
|
|
155
156
|
}): Record<string, unknown>;
|
|
@@ -190,8 +191,8 @@ export declare function screenedGate(v: unknown): GateOutcome | undefined;
|
|
|
190
191
|
* ## 读腿与写腿现在是**同一只**筛(7.74.0 起,零双读)
|
|
191
192
|
* 7.72.0–7.73.0 期间读腿多一步「认本服务上一版写下的退役词旧拼法」(`unresolvable` → `ancestor_marked`),
|
|
192
193
|
* 那是一条**长期双读臂**:同一份字节在写腿与读腿上有两种理解,而且没有到期日。7.74.0 把它换成**一次性
|
|
193
|
-
* 迁移**(
|
|
194
|
-
*
|
|
194
|
+
* 迁移**(启动期把存量字节原地改名;窗关后已删码)⇒ 读腿退回写腿那只严格筛子,集外词一律整条 withhold + 计数,
|
|
195
|
+
* 不再有第二种读法 —— 残留旧拼法的字节(local 车道引擎 File 店里不可改写的已决行)同走这一只筛,响亮不静默。
|
|
195
196
|
*
|
|
196
197
|
* ## 与写腿脱敏汇点的关系(别再走回头路)
|
|
197
198
|
* 写腿的对偶是 `redactLedgerEventData`(三孪生 store 的 `appendEvent` 落库前),它管的是脱敏、不是判形;
|
|
@@ -281,20 +282,21 @@ export declare function toolEndEventData(ev: {
|
|
|
281
282
|
delivered?: McpDelivered;
|
|
282
283
|
gate?: GateOutcome;
|
|
283
284
|
gatedCallId?: string;
|
|
285
|
+
wireName?: string;
|
|
286
|
+
notExecuted?: true;
|
|
284
287
|
eventId?: string;
|
|
285
288
|
parentToolCallId?: string;
|
|
286
289
|
}): Record<string, unknown>;
|
|
287
290
|
/**
|
|
288
291
|
* `tool_progress` 的白名单投影(core 7.18.0 [ref])—— 一只**仍在跑**的工具调用的存活 tick。
|
|
289
292
|
*
|
|
290
|
-
* ## 这一帧只上 live,不落账(
|
|
293
|
+
* ## 这一帧只上 live,不落账(判据是回放面有没有第二来源,不是「core 标了 LIVE ONLY」)
|
|
291
294
|
* core `@contract tool_progress.ephemeral` 逐字:「LIVE ONLY, like `task_progress`/`status`: core never
|
|
292
|
-
* persists this frame (no session-tree entry, no checkpoint state, no resume replay)
|
|
293
|
-
* `
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* **不等于** `tool_end` 的 duration)。
|
|
295
|
+
* persists this frame (no session-tree entry, no checkpoint state, no resume replay)」—— 那是**引擎**的义务;
|
|
296
|
+
* 本仓的律是「EPHEMERAL 帧带着回放面没有第二来源的事实 ⇒ 落账」(`status` / `task_progress` / `task_started` 都落)。
|
|
297
|
+
* 本帧的事实**有**第二来源:`@contract tool_progress.cadence` 逐字「A call that finishes inside one interval emits
|
|
298
|
+
* NO frame at all」⇒ **帧的缺席从来不是证据**;落账会让回放面凭空多出一份「这只调用跑了多久」的账,而那件事的
|
|
299
|
+
* 真源是 `tool_end`(core 明写 `elapsedTimeSeconds` **不等于** `tool_end` 的 duration)。
|
|
298
300
|
*
|
|
299
301
|
* ## 信任划线
|
|
300
302
|
* · `toolCallId` / `toolName` —— 调用 id(🔴 S-283 订正:出身是**服务商**在 tool_use / tool_calls 里给的,引擎缺席时自铸兜底、越界时折叠 ——
|
|
@@ -306,7 +308,8 @@ export declare function toolEndEventData(ev: {
|
|
|
306
308
|
* · `elapsedTimeSeconds` —— 引擎铸的整秒,单调、一 call 一个原点 ⇒ 有限数才铸键。
|
|
307
309
|
* · `output` —— 🔴 **UNTRUSTED RAW**,core 逐字「exactly as `tool_end.output`: process output that may
|
|
308
310
|
* carry secrets, paths or PII; core bounds only its SIZE, and a consumer MUST redact before persisting
|
|
309
|
-
* or displaying it」⇒ 与 `tool_end.output`
|
|
311
|
+
* or displaying it」⇒ 与 `tool_end.output` **同一只**投影 `projectToolOutput`(串形与文本块整只过 `redactDeep`;本帧只有串形,
|
|
312
|
+
* 媒体块那一臂在这里够不着),一个字节的例外都不开。
|
|
310
313
|
* · `totalLines` / `totalBytes` —— 引擎计数;core 的缺席律逐字:三者**同进同退**(在场=「观察到了输出」,
|
|
311
314
|
* 缺席=「一个字节都没观察到」,**从不是**「与上一帧相比没变」)。所以本投影按 `output` 的在场判三者:
|
|
312
315
|
* `output` 读不出 ⇒ 三键一起缺席,不单独留下两个计数(那会把「没输出」谎报成「有输出但读不出」)。
|
|
@@ -370,6 +373,47 @@ export declare function taskProgressEventData(ev: {
|
|
|
370
373
|
seq?: number;
|
|
371
374
|
model?: string;
|
|
372
375
|
}): Record<string, unknown>;
|
|
376
|
+
/**
|
|
377
|
+
* The `task_started` payload(core 7.50.0):一只委派子代**起跑**的那一帧 —— 每周期一只(首派 / 复活;耐久续跑腿不铸),
|
|
378
|
+
* 序在子代的 `wiring_manifest` 之后、它的首个 `task_progress` 与首次模型请求之前。
|
|
379
|
+
*
|
|
380
|
+
* **活面投、账本落**(与 `task_progress` / `status` 同一条律)。core 契约逐字「Live and ephemeral like `task_progress`:
|
|
381
|
+
* never persisted, never replayed on resume, absent from checkpoints」—— 那是**引擎**的义务(不进会话树、检查点、续跑重放)。
|
|
382
|
+
* 本服务的账本是异步车道的活流(`POST /v1/runs` 的观看者读的就是 `GET /v1/runs/:id/events` 的账本 tail)与断线重连面,
|
|
383
|
+
* 律是「**EPHEMERAL 帧带着回放面没有第二来源的事实 ⇒ 落账**」:`agentType` / `rootSessionId` / `parentSessionId` / `startedAt`
|
|
384
|
+
* 只骑这一帧,`task_progress` 上没有。(`tool_progress` 不落是同一条律的反面:它的事实由同一只调用的 `tool_end` 推出。)
|
|
385
|
+
* 调用点:三条 live 腿(sync 主流、sync forward 道、子代 tail 总线)+ 两条 durable 腿(账本汇、resume 腿)各自的主流臂与
|
|
386
|
+
* forward 道 —— 即 `task_progress` 的全部投影点,同一只构造器。
|
|
387
|
+
*
|
|
388
|
+
* 键的信任判与 `task_progress` 孪生**逐键同**(core 原话「every member is a value the run already speaks
|
|
389
|
+
* elsewhere — this frame introduces no new reading of any of them」⇒ 本仓也不铸第二种读法):
|
|
390
|
+
* · run / 会话 id、`seq`、`taskType`、`model`、`workflowRunId`、`agentType` —— 引擎值 verbatim(`agentType` 是解析过的子代类型名,
|
|
391
|
+
* 不是模型自由文本);`startedAt` 是有限数才上 wire;
|
|
392
|
+
* · `name` / `workflowAgentLabel` —— UNTRUSTED 展示文本 ⇒ `redactSecrets`(同 `task_progress.name` / `.workflowAgentLabel`);
|
|
393
|
+
* · `spawnName` —— 出生点校验过的队友**身份键** ⇒ verbatim(理由全文在 {@link taskProgressEventData} 的同名键注);
|
|
394
|
+
* · 身份两键经 `identityFields`(信封上的 `sourceTaskId` / `bgAgentId` 不由本族构造器投,见 `FRAME_ENVELOPE_KEYS`)。
|
|
395
|
+
* 缺席即缺席:可选键缺席不铸键(`taskType` 缺席 = 前台子代,禁读作某个默认种类;`seq` 缺席 = 无 `a*` 行,禁读作 cycle 1)。
|
|
396
|
+
*/
|
|
397
|
+
export declare function taskStartedEventData(ev: {
|
|
398
|
+
/** 判别位(入参就是那一帧;本构造器不投它 —— 帧名由调用点的 `type` 键 / 账本行名给)。 */
|
|
399
|
+
type?: "task_started";
|
|
400
|
+
taskId: string;
|
|
401
|
+
sessionId: string;
|
|
402
|
+
taskType?: string;
|
|
403
|
+
seq?: number;
|
|
404
|
+
workflowRunId?: string;
|
|
405
|
+
workflowAgentLabel?: string;
|
|
406
|
+
parentTaskId?: string;
|
|
407
|
+
parentSessionId?: string;
|
|
408
|
+
rootSessionId?: string;
|
|
409
|
+
name?: string;
|
|
410
|
+
spawnName?: string;
|
|
411
|
+
agentType?: string;
|
|
412
|
+
model: string;
|
|
413
|
+
startedAt: number;
|
|
414
|
+
eventId?: string;
|
|
415
|
+
parentToolCallId?: string;
|
|
416
|
+
}): Record<string, unknown>;
|
|
373
417
|
/** The `task_notification` payload (core 1.202 [ref] P2: a background task finished — this event is the
|
|
374
418
|
* LEDGER/display projection of the OBSERVED terminal state, emitted the moment core observes it. It does NOT
|
|
375
419
|
* attest that the `<task-notification>` XML has entered the model context: core's steer targets the NEXT TURN
|
|
@@ -837,6 +881,8 @@ export declare function brainStatusEventData(ev: {
|
|
|
837
881
|
errorStatus?: number;
|
|
838
882
|
elapsedMs?: number;
|
|
839
883
|
timeoutMs?: number;
|
|
884
|
+
providerCondition?: string;
|
|
885
|
+
providerConditionSource?: string;
|
|
840
886
|
eventId?: string;
|
|
841
887
|
parentToolCallId?: string;
|
|
842
888
|
}): Record<string, unknown>;
|
|
@@ -891,7 +937,7 @@ export interface TraceTurn {
|
|
|
891
937
|
* 🔴 **S-213⑥:五个子键**全部按同族 OMIT 契约走 —— 引擎那一侧报了才铸,没报就**缺席**,恒不折 `0`。
|
|
892
938
|
* `in`/`out` 此前是必填座、缺一键时写 `?? 0`:读端拿到的 `in:0` 与「这一轮真的零输入」逐字节同形,
|
|
893
939
|
* 于是一次 usage 半缺(某些 provider 只回 output 侧)在面板上显示成一个可核对的真数字。
|
|
894
|
-
* 0 是一个数,未知不是 —— 两者同形正是本仓 `boundCallId`/`gateKind`/`
|
|
940
|
+
* 0 是一个数,未知不是 —— 两者同形正是本仓 `boundCallId`/`gateKind`/`approvalCard` 一族一直在防的事。
|
|
895
941
|
* ⚠️ wire 面(`GET /v1/tasks/:id/turns` 与 trace SSE 的 `turn` 事件)因此可能给出**只有一侧**的
|
|
896
942
|
* `tokens`;做算术的消费端要按「键可能缺席」读(`tokens` 整只可缺席早就是契约的一部分)。
|
|
897
943
|
* 🔴 **7.74.0 / core 7.17.0([ref])**:引擎自陈 `usageMissing` 的一轮(usage 是六个 0 的占位)⇒ 整只缺席 ——
|
package/dist/trace/project.js
CHANGED
|
@@ -3,6 +3,7 @@ import { isAskClass, isAskOrigin, isModeReleaseReason, isPermissionMode, isPersi
|
|
|
3
3
|
import { Value } from "typebox/value";
|
|
4
4
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
5
5
|
import { redactSecrets, redactDeep } from "./redact.js";
|
|
6
|
+
import { projectToolOutput } from "./tool-output-media.js";
|
|
6
7
|
import { injectionTierOrAbsent } from "./injection-tier.js";
|
|
7
8
|
import { semaProvenanceOrAbsent } from "./sema-provenance.js";
|
|
8
9
|
import { resupplyFields, terminalFrameFacetFields } from "./task-notification-facets.js";
|
|
@@ -91,7 +92,14 @@ export function modelTextEventData(ev) {
|
|
|
91
92
|
return { text: ev.text, ...(ev.eventId ? { eventId: ev.eventId } : {}) };
|
|
92
93
|
}
|
|
93
94
|
export function toolStartEventData(ev) {
|
|
94
|
-
return {
|
|
95
|
+
return {
|
|
96
|
+
toolCallId: ev.toolCallId,
|
|
97
|
+
toolName: ev.toolName,
|
|
98
|
+
...(ev.label !== undefined ? { label: ev.label } : {}),
|
|
99
|
+
args: redactDeep(ev.args),
|
|
100
|
+
...(ev.recovered === true ? { recovered: true } : {}),
|
|
101
|
+
...identityFields(ev),
|
|
102
|
+
};
|
|
95
103
|
}
|
|
96
104
|
const SETTLEMENT_NOTE_MAX = 500;
|
|
97
105
|
export function screenedGate(v) {
|
|
@@ -126,22 +134,34 @@ function modeLedgerDefect(d) {
|
|
|
126
134
|
return "disposition.released.origin is outside the closed set";
|
|
127
135
|
if (o.mandate !== undefined && !isPersistedRuleMandate(o.mandate))
|
|
128
136
|
return "disposition.released.mandate is outside the closed set";
|
|
129
|
-
if (o.reason !== undefined && !isModeReleaseReason(o.reason))
|
|
130
|
-
return "disposition.released.reason is outside the closed set";
|
|
131
137
|
return false;
|
|
132
138
|
}
|
|
139
|
+
function withReleaseReasonTheEngineReads(g) {
|
|
140
|
+
const d = g.disposition;
|
|
141
|
+
if (d.kind !== "allowed" || d.released === undefined)
|
|
142
|
+
return g;
|
|
143
|
+
const r = d.released;
|
|
144
|
+
if (r === null || typeof r !== "object")
|
|
145
|
+
return g;
|
|
146
|
+
const reason = d.released.reason;
|
|
147
|
+
if (typeof reason !== "string" || isModeReleaseReason(reason))
|
|
148
|
+
return g;
|
|
149
|
+
const { reason: _unread, ...kept } = d.released;
|
|
150
|
+
return { ...g, disposition: { ...d, released: kept } };
|
|
151
|
+
}
|
|
133
152
|
function screenedGateOrThrow(v) {
|
|
134
153
|
if (v === null || typeof v !== "object") {
|
|
135
154
|
if (v !== undefined)
|
|
136
155
|
recordFailOpen("server.trace.gate-outcome-defective", "gate is not an object");
|
|
137
156
|
return undefined;
|
|
138
157
|
}
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
if (d === null || typeof d !== "object" || (d.kind !== "allowed" && d.kind !== "denied")) {
|
|
158
|
+
const stored = v;
|
|
159
|
+
if (stored.disposition === null || typeof stored.disposition !== "object" || (stored.disposition.kind !== "allowed" && stored.disposition.kind !== "denied")) {
|
|
142
160
|
recordFailOpen("server.trace.gate-outcome-defective", "disposition is not one of the two arms");
|
|
143
161
|
return undefined;
|
|
144
162
|
}
|
|
163
|
+
const g = withReleaseReasonTheEngineReads(stored);
|
|
164
|
+
const d = g.disposition;
|
|
145
165
|
const classifierFallbackRaw = d.classifier !== null && typeof d.classifier === "object" ? d.classifier.fallback : undefined;
|
|
146
166
|
const shapeDefect = (d.kind === "denied" && typeof d.deniedBy !== "string" && "disposition.deniedBy is not a string") ||
|
|
147
167
|
(d.kind === "denied" && d.cause !== undefined && typeof d.cause !== "string" && "disposition.cause is not a string") ||
|
|
@@ -266,7 +286,7 @@ export function toolEndEventData(ev) {
|
|
|
266
286
|
toolName: ev.toolName,
|
|
267
287
|
...(ev.label !== undefined ? { label: ev.label } : {}),
|
|
268
288
|
isError: ev.isError,
|
|
269
|
-
...(ev.output !== undefined ? { output:
|
|
289
|
+
...(ev.output !== undefined ? { output: projectToolOutput(ev.output) } : {}),
|
|
270
290
|
...(ev.truncated ? { truncated: true } : {}),
|
|
271
291
|
...(Number.isFinite(ev.totalChars) ? { totalChars: ev.totalChars } : {}),
|
|
272
292
|
...(ev.structured !== undefined ? { structured: redactDeep(ev.structured) } : {}),
|
|
@@ -274,6 +294,8 @@ export function toolEndEventData(ev) {
|
|
|
274
294
|
...(typeof ev.delivered === "string" && MCP_DELIVERY_VERDICTS.includes(ev.delivered) ? { delivered: ev.delivered } : {}),
|
|
275
295
|
...(gate !== undefined ? { gate } : {}),
|
|
276
296
|
...(typeof ev.gatedCallId === "string" && ev.gatedCallId !== "" ? { gatedCallId: ev.gatedCallId } : {}),
|
|
297
|
+
...(typeof ev.wireName === "string" && ev.wireName !== "" ? { wireName: ev.wireName } : {}),
|
|
298
|
+
...(ev.notExecuted === true ? { notExecuted: true } : {}),
|
|
277
299
|
...identityFields(ev),
|
|
278
300
|
};
|
|
279
301
|
}
|
|
@@ -288,7 +310,7 @@ export function toolProgressEventData(ev) {
|
|
|
288
310
|
toolCallId: id,
|
|
289
311
|
toolName: name,
|
|
290
312
|
...(n(ev.elapsedTimeSeconds) !== undefined ? { elapsedTimeSeconds: n(ev.elapsedTimeSeconds) } : {}),
|
|
291
|
-
...(hasOutput ? { output:
|
|
313
|
+
...(hasOutput ? { output: projectToolOutput(ev.output) } : {}),
|
|
292
314
|
...(hasOutput && n(ev.totalLines) !== undefined ? { totalLines: n(ev.totalLines) } : {}),
|
|
293
315
|
...(hasOutput && n(ev.totalBytes) !== undefined ? { totalBytes: n(ev.totalBytes) } : {}),
|
|
294
316
|
...identityFields(ev),
|
|
@@ -327,6 +349,25 @@ export function taskProgressEventData(ev) {
|
|
|
327
349
|
...identityFields(ev),
|
|
328
350
|
};
|
|
329
351
|
}
|
|
352
|
+
export function taskStartedEventData(ev) {
|
|
353
|
+
return {
|
|
354
|
+
taskId: ev.taskId,
|
|
355
|
+
sessionId: ev.sessionId,
|
|
356
|
+
...(typeof ev.taskType === "string" && ev.taskType.length > 0 ? { taskType: ev.taskType } : {}),
|
|
357
|
+
...(typeof ev.seq === "number" ? { seq: ev.seq } : {}),
|
|
358
|
+
...(ev.workflowRunId ? { workflowRunId: ev.workflowRunId } : {}),
|
|
359
|
+
...(ev.workflowAgentLabel ? { workflowAgentLabel: redactSecrets(ev.workflowAgentLabel) } : {}),
|
|
360
|
+
...(ev.parentTaskId ? { parentTaskId: ev.parentTaskId } : {}),
|
|
361
|
+
...(ev.parentSessionId ? { parentSessionId: ev.parentSessionId } : {}),
|
|
362
|
+
...(ev.rootSessionId ? { rootSessionId: ev.rootSessionId } : {}),
|
|
363
|
+
...(ev.name ? { name: redactSecrets(ev.name) } : {}),
|
|
364
|
+
...(ev.spawnName ? { spawnName: ev.spawnName } : {}),
|
|
365
|
+
...(ev.agentType ? { agentType: ev.agentType } : {}),
|
|
366
|
+
model: ev.model,
|
|
367
|
+
...(typeof ev.startedAt === "number" && Number.isFinite(ev.startedAt) ? { startedAt: ev.startedAt } : {}),
|
|
368
|
+
...identityFields(ev),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
330
371
|
export function taskNotificationEventData(ev) {
|
|
331
372
|
const n = ev.notification;
|
|
332
373
|
return {
|
|
@@ -724,6 +765,8 @@ export function brainStatusEventData(ev) {
|
|
|
724
765
|
...(num(ev.timeoutMs) ? { timeoutMs: ev.timeoutMs } : {}),
|
|
725
766
|
...(num(ev.errorStatus) ? { errorStatus: ev.errorStatus } : {}),
|
|
726
767
|
...(typeof ev.errClass === "string" && ev.errClass.length > 0 ? { errClass: ev.errClass } : {}),
|
|
768
|
+
...(typeof ev.providerCondition === "string" && ev.providerCondition.length > 0 ? { providerCondition: ev.providerCondition } : {}),
|
|
769
|
+
...(typeof ev.providerConditionSource === "string" && ev.providerConditionSource.length > 0 ? { providerConditionSource: ev.providerConditionSource } : {}),
|
|
727
770
|
...identityFields(ev),
|
|
728
771
|
};
|
|
729
772
|
}
|
|
@@ -839,6 +882,7 @@ export function toolCallFieldsOf(d) {
|
|
|
839
882
|
name: String(d.toolName ?? ""),
|
|
840
883
|
...(typeof d.label === "string" ? { label: d.label } : {}),
|
|
841
884
|
input: d.args,
|
|
885
|
+
...(d.recovered === true ? { recovered: true } : {}),
|
|
842
886
|
...identityFields(d),
|
|
843
887
|
};
|
|
844
888
|
}
|
|
@@ -854,6 +898,8 @@ export function toolResultFieldsOf(d) {
|
|
|
854
898
|
...(typeof d.delivered === "string" && MCP_DELIVERY_VERDICTS.includes(d.delivered) ? { delivered: d.delivered } : {}),
|
|
855
899
|
...(gate !== undefined ? { gate } : {}),
|
|
856
900
|
...(typeof d.gatedCallId === "string" && d.gatedCallId !== "" ? { gatedCallId: d.gatedCallId } : {}),
|
|
901
|
+
...(typeof d.wireName === "string" && d.wireName !== "" ? { wireName: d.wireName } : {}),
|
|
902
|
+
...(d.notExecuted === true ? { notExecuted: true } : {}),
|
|
857
903
|
...identityFields(d),
|
|
858
904
|
};
|
|
859
905
|
}
|
|
@@ -365,8 +365,9 @@ export declare const SELF_MINTED_WIRE: {
|
|
|
365
365
|
};
|
|
366
366
|
};
|
|
367
367
|
/**
|
|
368
|
-
* 提交幂等(契约 §0.7:幂等 = 资源行上的唯一键)
|
|
369
|
-
* `Idempotency-Key` 命中一条读不到 / 不是这次 taskId 所指的行时的 409
|
|
368
|
+
* 提交幂等(契约 §0.7:幂等 = 资源行上的唯一键)上 wire 的面:同步腿读行重放体的 `replay` 键、两只按键读的读口、
|
|
369
|
+
* `Idempotency-Key` 命中一条读不到 / 不是这次 taskId 所指的行时的 409(7.125.0);同键异体(绑定那一行的请求体与这次不同)的 409(7.126.0)。
|
|
370
|
+
* 行为由 `test/submit-idempotency-one-ledger.test.ts` 钉。
|
|
370
371
|
*/
|
|
371
372
|
readonly submitIdempotency: {
|
|
372
373
|
readonly at: "提交幂等(<端点>#<面> → 应答状态)";
|
|
@@ -387,6 +388,78 @@ export declare const SELF_MINTED_WIRE: {
|
|
|
387
388
|
readonly attr: 409;
|
|
388
389
|
readonly since: "7.125.0";
|
|
389
390
|
};
|
|
391
|
+
readonly "POST /v1/runs|/v1/tasks Idempotency-Key#conflict.idempotency_payload_mismatch": {
|
|
392
|
+
readonly attr: 409;
|
|
393
|
+
readonly since: "7.126.0";
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* 内建场景名(`GET /v1/capabilities.scenarios` 的内建成员,`GET /v1/capabilities/scenarios/:name` 的内建详情)。7.126.0 `discuss` 退出 wire
|
|
399
|
+
* (core 7.49.0 删团队讨论运行时;请求体再传它 = 400 `scenario_unknown`)。钉 test/team-orchestration-retired.test.ts。
|
|
400
|
+
*/
|
|
401
|
+
readonly builtinScenario: {
|
|
402
|
+
readonly at: "GET /v1/capabilities#scenarios[] 内建成员";
|
|
403
|
+
readonly members: {
|
|
404
|
+
code: {
|
|
405
|
+
attr: string;
|
|
406
|
+
since: string;
|
|
407
|
+
};
|
|
408
|
+
default: {
|
|
409
|
+
attr: string;
|
|
410
|
+
since: string;
|
|
411
|
+
};
|
|
412
|
+
"code-review": {
|
|
413
|
+
attr: string;
|
|
414
|
+
since: string;
|
|
415
|
+
};
|
|
416
|
+
scan: {
|
|
417
|
+
attr: string;
|
|
418
|
+
since: string;
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* 提交体的场景透传键(受理门放行;`ScenarioRequest` 索引签名读)。7.126.0 只喂 discuss 场景与 code-review council 腿的四键退出 wire
|
|
424
|
+
* (受理门对它们答未知键 400;同批退出的具名键 `council` / `debate` 住在 `TaskRequestBody` 上,不在本集 —— 具名提交面键本清单今天看不见)。
|
|
425
|
+
*/
|
|
426
|
+
readonly scenarioBodyKey: {
|
|
427
|
+
readonly at: "POST /v1/tasks|/v1/tasks/stream|/v1/runs 体的场景透传键";
|
|
428
|
+
readonly members: {
|
|
429
|
+
repo: {
|
|
430
|
+
attr: string;
|
|
431
|
+
since: string;
|
|
432
|
+
};
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
/**
|
|
436
|
+
* `GET /v1/models` 应答体的顶层键(闭集;`src/http/routes/capabilities.ts` 的 `sendJson(res, 200, {…})` 字面量)。属性 = 在场律:`always` 恒在场(零条也出键),`present-iff` 条件成立才出键
|
|
437
|
+
* (缺席不下「无」的结论——也可能是更早的 server)。`since` = 该键上 wire 的起始版本(`models` / `default` / `defaultModel` 在本仓首个 tag 就有)。
|
|
438
|
+
* 7.126.0:`candidateRejected`(S-1457,present-iff:当前生效的配置是因判官整拒了最近一份候选而回落的那一份;契约 §A.1d)。
|
|
439
|
+
*/
|
|
440
|
+
readonly modelsResponseKey: {
|
|
441
|
+
readonly at: "GET /v1/models 应答体顶层键(<键> → 在场律)";
|
|
442
|
+
readonly members: {
|
|
443
|
+
readonly models: {
|
|
444
|
+
readonly attr: "always";
|
|
445
|
+
readonly since: "1.214.2";
|
|
446
|
+
};
|
|
447
|
+
readonly default: {
|
|
448
|
+
readonly attr: "always";
|
|
449
|
+
readonly since: "1.214.2";
|
|
450
|
+
};
|
|
451
|
+
readonly defaultModel: {
|
|
452
|
+
readonly attr: "always";
|
|
453
|
+
readonly since: "1.214.2";
|
|
454
|
+
};
|
|
455
|
+
readonly droppedEntries: {
|
|
456
|
+
readonly attr: "always";
|
|
457
|
+
readonly since: "7.123.0";
|
|
458
|
+
};
|
|
459
|
+
readonly candidateRejected: {
|
|
460
|
+
readonly attr: "present-iff";
|
|
461
|
+
readonly since: "7.126.0";
|
|
462
|
+
};
|
|
390
463
|
};
|
|
391
464
|
};
|
|
392
465
|
/** 本仓在出口对 core 值做的变换(值变、键不变)。 */
|
|
@@ -417,6 +490,25 @@ export declare const SELF_MINTED_WIRE: {
|
|
|
417
490
|
readonly attr: "redactListEntry";
|
|
418
491
|
readonly since: "7.120.0";
|
|
419
492
|
};
|
|
493
|
+
/**
|
|
494
|
+
* 7.127.0(引擎 7.50.0:`tool_end.output` 按块带已准入的图像 / 文档):媒体块(image / document 且 `data` 是串)的 `data` 是字节编码 ——
|
|
495
|
+
* 活面 SSE 逐字过境,不跑文本脱敏(`trace/tool-output-media.ts` `projectToolOutput`;钉 test/tool-end-media-durable.test.ts);
|
|
496
|
+
* 唯一例外 = 连接积压:本帧媒体 + 这条连接 / 订阅者未送出的字节 > 64 MiB ⇒ 本帧媒体降描述符(`liveToolEndForBacklog`;钉 test/live-media-backlog.test.ts)。
|
|
497
|
+
*/
|
|
498
|
+
readonly "SSE tool_end#output[].data(\u5A92\u4F53\u5757)": {
|
|
499
|
+
readonly attr: "verbatim-bytes;backlog>64MiB⇒descriptor+totalChars";
|
|
500
|
+
readonly since: "7.127.0";
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* 7.127.0:同一媒体块在**持久面**(账本行与 `GET /v1/runs/:id/events` 回放)只存描述符 `{ type, mimeType?, bytes, truncated: true }`,
|
|
504
|
+
* 帧级 `truncated` 随之为真、帧级 `totalChars` 随之在场(core 不变量「Present iff truncated」:帧上已有 core 的值 ⇒ 原样保留,
|
|
505
|
+
* 没有 ⇒ 逐块真实大小求和;活面积压降级同一只函数)(账本汇点一处剥:`observability/run-terminal.ts` `redactLedgerEventData` →
|
|
506
|
+
* `toolEndMediaAsDescriptors`;钉同上)。
|
|
507
|
+
*/
|
|
508
|
+
readonly "GET /v1/runs/:id/events#tool_end.output[](\u5A92\u4F53\u5757)": {
|
|
509
|
+
readonly attr: "durableMediaDescriptor+totalChars";
|
|
510
|
+
readonly since: "7.127.0";
|
|
511
|
+
};
|
|
420
512
|
};
|
|
421
513
|
};
|
|
422
514
|
};
|
|
@@ -134,6 +134,32 @@ export const SELF_MINTED_WIRE = {
|
|
|
134
134
|
"GET /v1/runs?idempotencyKey": { attr: 200, since: "7.125.0" },
|
|
135
135
|
"GET /v1/leader?idempotencyKey": { attr: 200, since: "7.125.0" },
|
|
136
136
|
"POST /v1/runs|/v1/tasks Idempotency-Key#conflict.run_exists": { attr: 409, since: "7.125.0" },
|
|
137
|
+
"POST /v1/runs|/v1/tasks Idempotency-Key#conflict.idempotency_payload_mismatch": { attr: 409, since: "7.126.0" },
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
builtinScenario: {
|
|
141
|
+
at: "GET /v1/capabilities#scenarios[] 内建成员",
|
|
142
|
+
members: {
|
|
143
|
+
code: { attr: "-", since: "1.214.2" },
|
|
144
|
+
default: { attr: "-", since: "1.214.2" },
|
|
145
|
+
"code-review": { attr: "-", since: "1.214.2" },
|
|
146
|
+
scan: { attr: "-", since: "1.214.2" },
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
scenarioBodyKey: {
|
|
150
|
+
at: "POST /v1/tasks|/v1/tasks/stream|/v1/runs 体的场景透传键",
|
|
151
|
+
members: {
|
|
152
|
+
repo: { attr: "-", since: "1.214.2" },
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
modelsResponseKey: {
|
|
156
|
+
at: "GET /v1/models 应答体顶层键(<键> → 在场律)",
|
|
157
|
+
members: {
|
|
158
|
+
models: { attr: "always", since: "1.214.2" },
|
|
159
|
+
default: { attr: "always", since: "1.214.2" },
|
|
160
|
+
defaultModel: { attr: "always", since: "1.214.2" },
|
|
161
|
+
droppedEntries: { attr: "always", since: "7.123.0" },
|
|
162
|
+
candidateRejected: { attr: "present-iff", since: "7.126.0" },
|
|
137
163
|
},
|
|
138
164
|
},
|
|
139
165
|
wireValueRule: {
|
|
@@ -143,6 +169,8 @@ export const SELF_MINTED_WIRE = {
|
|
|
143
169
|
"POST /v1/side-query#errorMessage": { attr: "redactErrorMessage", since: "7.108.0" },
|
|
144
170
|
"engine_notice permission.allowed_tool_not_granted#detail.entries[].entry": { attr: "redactListEntry", since: "7.120.0" },
|
|
145
171
|
"engine_notice permission.rule_row_dropped#detail.rows[].rule": { attr: "redactListEntry", since: "7.120.0" },
|
|
172
|
+
"SSE tool_end#output[].data(媒体块)": { attr: "verbatim-bytes;backlog>64MiB⇒descriptor+totalChars", since: "7.127.0" },
|
|
173
|
+
"GET /v1/runs/:id/events#tool_end.output[](媒体块)": { attr: "durableMediaDescriptor+totalChars", since: "7.127.0" },
|
|
146
174
|
},
|
|
147
175
|
},
|
|
148
176
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 两面共用的 `output` 投影:串 / 文本块 / 其它块整只过 `redactDeep`;媒体块逐成员过,`data` 逐字。
|
|
3
|
+
* 保键序(逐键映射),不改入参。
|
|
4
|
+
*/
|
|
5
|
+
export declare function projectToolOutput(output: unknown): unknown;
|
|
6
|
+
/**
|
|
7
|
+
* `tool_end` 载荷的媒体降级(持久面恒用;活面只在连接积压时用):带 `data` 的媒体块换成描述符,有任何一块被换 ⇒ 帧级 `truncated: true`
|
|
8
|
+
* 且帧级 `totalChars` 在场 —— core 不变量「Present iff truncated」:被界之前那个值的真实大小。帧上已有 `totalChars`(core 已截断:
|
|
9
|
+
* 文本被切而媒体留着)⇒ **原样保留**(它说的是更早的原值,本仓手里的已是切过的值,重算只会低报);没有 ⇒ 按 {@link trueSizeOf}
|
|
10
|
+
* 逐块求和(core 没截,`output` 就是原值 —— 文本块是本服务脱敏后的字节,即本服务交付的内容)。
|
|
11
|
+
* 没有媒体块 ⇒ 原样返回同一引用(纯文本 / 串形 output 一个字节不变);已是描述符的块(无 `data`)原样 ⇒ 幂等。
|
|
12
|
+
*/
|
|
13
|
+
export declare function toolEndMediaAsDescriptors(data: Record<string, unknown>): Record<string, unknown>;
|
|
14
|
+
/** 活面一条连接允许压住的待发字节上界(含本帧媒体)。一帧媒体最大约为部署媒体预算的 4/3(缺省约 40 MiB),
|
|
15
|
+
* 上界取它之上一点:空闲连接上一整帧最大的图照样整块过,第二帧起只在读者跟上之后才整块。 */
|
|
16
|
+
export declare const LIVE_MEDIA_BACKLOG_BYTES: number;
|
|
17
|
+
/** 一帧 `tool_end` 载荷里媒体块 `data` 的字节数(base64 串长;没有媒体 = 0)。 */
|
|
18
|
+
export declare function liveMediaBytesOf(frame: Record<string, unknown>): number;
|
|
19
|
+
/**
|
|
20
|
+
* 活面的积压判据(一只):`backlogBytes` = 这条连接 / 这个订阅者此刻还没送出去的字节。本帧媒体 + 积压 > 上界 ⇒ 媒体降描述符,
|
|
21
|
+
* 否则原样(同一引用)。非 `tool_end` 载荷由调用方不送进来;没有媒体的 `tool_end` 恒原样。
|
|
22
|
+
* 降级是 F 类兜底(观众少见一张图),每降一帧在**这里**记一次 `server.tool-end-media.live-backlog-degraded` —— 三处写口都经这一只函数,
|
|
23
|
+
* 留痕因此只有一处;帧上它与引擎的媒体预算降级同形,计数是运维看出「多少观众丢了图」的唯一位。
|
|
24
|
+
*/
|
|
25
|
+
export declare function liveToolEndForBacklog(frame: Record<string, unknown>, backlogBytes: number): Record<string, unknown>;
|
|
26
|
+
//# sourceMappingURL=tool-output-media.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { redactDeep } from "./redact.js";
|
|
2
|
+
import { recordFailOpen } from "../observability/fail-open.js";
|
|
3
|
+
function isMediaBlock(b) {
|
|
4
|
+
if (b === null || typeof b !== "object" || Array.isArray(b))
|
|
5
|
+
return false;
|
|
6
|
+
const block = b;
|
|
7
|
+
return (block.type === "image" || block.type === "document") && typeof block.data === "string";
|
|
8
|
+
}
|
|
9
|
+
const MIME_ECHO_MAX = 255;
|
|
10
|
+
export function projectToolOutput(output) {
|
|
11
|
+
if (!Array.isArray(output))
|
|
12
|
+
return redactDeep(output);
|
|
13
|
+
return output.map((b) => (isMediaBlock(b) ? Object.fromEntries(Object.entries(b).map(([k, v]) => [k, k === "data" ? v : redactDeep(v)])) : redactDeep(b)));
|
|
14
|
+
}
|
|
15
|
+
function trueSizeOf(b) {
|
|
16
|
+
if (isMediaBlock(b))
|
|
17
|
+
return b.data.length;
|
|
18
|
+
if (b !== null && typeof b === "object" && !Array.isArray(b) && b.type === "text" && typeof b.text === "string") {
|
|
19
|
+
const { type: _type, text, ...rest } = b;
|
|
20
|
+
return text.length + Math.max(0, (JSON.stringify(rest)?.length ?? 2) - 2);
|
|
21
|
+
}
|
|
22
|
+
return JSON.stringify(b)?.length ?? 0;
|
|
23
|
+
}
|
|
24
|
+
export function toolEndMediaAsDescriptors(data) {
|
|
25
|
+
const output = data.output;
|
|
26
|
+
if (!Array.isArray(output) || !output.some(isMediaBlock))
|
|
27
|
+
return data;
|
|
28
|
+
const totalChars = typeof data.totalChars === "number" && Number.isFinite(data.totalChars) ? data.totalChars : output.reduce((n, b) => n + trueSizeOf(b), 0);
|
|
29
|
+
const stripped = output.map((b) => isMediaBlock(b)
|
|
30
|
+
? {
|
|
31
|
+
type: b.type,
|
|
32
|
+
...(typeof b.mimeType === "string" && b.mimeType.length <= MIME_ECHO_MAX ? { mimeType: b.mimeType } : {}),
|
|
33
|
+
bytes: Math.floor((b.data.length * 3) / 4),
|
|
34
|
+
truncated: true,
|
|
35
|
+
}
|
|
36
|
+
: b);
|
|
37
|
+
return { ...data, output: stripped, truncated: true, totalChars };
|
|
38
|
+
}
|
|
39
|
+
export const LIVE_MEDIA_BACKLOG_BYTES = 64 * 1024 * 1024;
|
|
40
|
+
export function liveMediaBytesOf(frame) {
|
|
41
|
+
const output = frame.output;
|
|
42
|
+
if (!Array.isArray(output))
|
|
43
|
+
return 0;
|
|
44
|
+
let n = 0;
|
|
45
|
+
for (const b of output)
|
|
46
|
+
if (isMediaBlock(b))
|
|
47
|
+
n += b.data.length;
|
|
48
|
+
return n;
|
|
49
|
+
}
|
|
50
|
+
export function liveToolEndForBacklog(frame, backlogBytes) {
|
|
51
|
+
const media = liveMediaBytesOf(frame);
|
|
52
|
+
if (media === 0 || backlogBytes + media <= LIVE_MEDIA_BACKLOG_BYTES)
|
|
53
|
+
return frame;
|
|
54
|
+
recordFailOpen("server.tool-end-media.live-backlog-degraded", `backlog=${backlogBytes} media=${media}`);
|
|
55
|
+
return toolEndMediaAsDescriptors(frame);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=tool-output-media.js.map
|
|
@@ -74,6 +74,12 @@ export declare const WIRE_PROJECTION_FACES: {
|
|
|
74
74
|
readonly excluded: readonly [];
|
|
75
75
|
readonly minted: readonly [];
|
|
76
76
|
};
|
|
77
|
+
readonly task_started: {
|
|
78
|
+
readonly projector: "taskStartedEventData";
|
|
79
|
+
readonly coreType: string;
|
|
80
|
+
readonly excluded: readonly [];
|
|
81
|
+
readonly minted: readonly [];
|
|
82
|
+
};
|
|
77
83
|
readonly tool_start: {
|
|
78
84
|
readonly projector: "toolStartEventData";
|
|
79
85
|
readonly coreType: string;
|
|
@@ -155,7 +161,7 @@ export declare const WIRE_PROJECTION_FACES: {
|
|
|
155
161
|
readonly human_input: {
|
|
156
162
|
readonly projector: "humanInputEventData";
|
|
157
163
|
readonly coreType: string;
|
|
158
|
-
readonly excluded: readonly ["principal"];
|
|
164
|
+
readonly excluded: readonly ["principal", "attachments"];
|
|
159
165
|
readonly minted: readonly [];
|
|
160
166
|
};
|
|
161
167
|
readonly task_notification: {
|
|
@@ -16,6 +16,7 @@ function withoutSections(all, drop) {
|
|
|
16
16
|
}
|
|
17
17
|
export const WIRE_PROJECTION_FACES = {
|
|
18
18
|
task_progress: { projector: "taskProgressEventData", coreType: arm("task_progress"), excluded: [], minted: [] },
|
|
19
|
+
task_started: { projector: "taskStartedEventData", coreType: arm("task_started"), excluded: [], minted: [] },
|
|
19
20
|
tool_start: { projector: "toolStartEventData", coreType: arm("tool_start"), excluded: [], minted: [] },
|
|
20
21
|
tool_end: { projector: "toolEndEventData", coreType: arm("tool_end"), excluded: [], minted: [] },
|
|
21
22
|
tool_progress: { projector: "toolProgressEventData", coreType: arm("tool_progress"), excluded: [], minted: [] },
|
|
@@ -29,7 +30,7 @@ export const WIRE_PROJECTION_FACES = {
|
|
|
29
30
|
context_usage: { projector: "contextUsageEventData", coreType: arm("context_usage"), excluded: [], minted: [] },
|
|
30
31
|
turn_end: { projector: "turnEndEventData", coreType: arm("turn_end"), excluded: [], minted: [] },
|
|
31
32
|
compaction_outcome: { projector: "compactionOutcomeEventData", coreType: arm("compaction_outcome"), excluded: [], minted: [] },
|
|
32
|
-
human_input: { projector: "humanInputEventData", coreType: arm("human_input"), excluded: ["principal"], minted: [] },
|
|
33
|
+
human_input: { projector: "humanInputEventData", coreType: arm("human_input"), excluded: ["principal", "attachments"], minted: [] },
|
|
33
34
|
task_notification: {
|
|
34
35
|
projector: "taskNotificationEventData",
|
|
35
36
|
coreType: `TaskNotificationPayload & ${arm("task_notification")}`,
|
|
@@ -62,9 +62,9 @@ export declare function applyEffective(config: ServiceConfig, eff: EffectiveConf
|
|
|
62
62
|
/**
|
|
63
63
|
* 🔴 **模型面组由哪些 effective 域组成 —— 唯一定义**(7.101.0 验修轮 V1 / codex V-1;OA 验修轮 V2 的以点改面)。
|
|
64
64
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
65
|
+
* 组里今天只有 `models` 一个域(collab 域曾因模板带模型引用而同组;7.49.0 起本仓不执行 collab 模板,它出组 —— 见
|
|
66
|
+
* {@link collabTemplatesNotExecuted})。此前「模型面」散在三处各写一份(世代账键表 / stage 闸 / boot 按组回落 LKG 的合成),
|
|
67
|
+
* 收成本表一处定义;再有域入组只改这一行,下面的映射型逼着补落点。
|
|
68
68
|
* 读者一律从这里派生,禁手抄:
|
|
69
69
|
* · stage:{@link stageModelPlane} 产出组内**每个**域的产物({@link ModelPlaneStages} 按本表映射),组被拒 ⇒ 一个域都没有;
|
|
70
70
|
* · 世代账:整组拒的 `keys` 与落地的 `applied` 都由 {@link MODEL_PLANE_SURFACES} 按本表派生({@link modelPlaneGroupReport});
|
|
@@ -72,14 +72,14 @@ export declare function applyEffective(config: ServiceConfig, eff: EffectiveConf
|
|
|
72
72
|
* (与 `config.ts` 的配置组视图 `MODEL_PLANE_GROUP_KEYS` 不是一回事:那是 `ServiceConfig` 的分节视图;这里是「中心热应用的
|
|
73
73
|
* 模型面这一组包含哪些 effective 域」。)
|
|
74
74
|
*/
|
|
75
|
-
export declare const MODEL_PLANE_DOMAINS: readonly ["models"
|
|
75
|
+
export declare const MODEL_PLANE_DOMAINS: readonly ["models"];
|
|
76
76
|
export type ModelPlaneDomain = (typeof MODEL_PLANE_DOMAINS)[number];
|
|
77
|
-
/** 模型面组在 effective 上的那一切片(
|
|
77
|
+
/** 模型面组在 effective 上的那一切片(组内各域,与 `EffectiveConfig` 同形)。 */
|
|
78
78
|
export type ModelPlaneOf = Pick<EffectiveConfig, ModelPlaneDomain>;
|
|
79
79
|
/**
|
|
80
80
|
* `target` 换上 `source` 的**整个模型面**(组内每个域都取 `source` 的;`source` 缺席的域在结果里同样缺席,不留 `target` 的),
|
|
81
81
|
* 其余域原样是 `target` 的。boot 按组回落 LKG 的合成文档(回落 apply 的入参)走这一只 —— 禁在调用点
|
|
82
|
-
* 手写 `{ ...x, models
|
|
82
|
+
* 手写 `{ ...x, models }`(组再加域时漏一个正是 V1 的病形)。纯数据:不改两个入参。
|
|
83
83
|
*/
|
|
84
84
|
export declare function withModelPlaneOf<E extends EffectiveConfig>(target: E, source: ModelPlaneOf): E;
|
|
85
85
|
/**
|
|
@@ -104,6 +104,12 @@ export declare const PLANE_REFUSAL_INVARIANT_OF: {
|
|
|
104
104
|
readonly "config.model_route_endpoint_missing": "model-route-endpoint";
|
|
105
105
|
readonly "config.gateway_fallback_without_primary": "model-route-endpoint";
|
|
106
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* collab 域 = 中心的多成员讨论模板。**本仓不执行它们**:唯一的执行体是引擎的团队讨论脚本,core 7.49.0 已删(本仓不留第二份
|
|
109
|
+
* 团队编排)。这一只是本仓对该域的**唯一读法**:已发布且启用的模板 id(`enabled === false` 是运营态关闭,不算发布)——
|
|
110
|
+
* 真 apply 的 `web_admin_collab_not_executed` warn 与 dry-run 行的 `collab.notExecuted` 都读它。
|
|
111
|
+
*/
|
|
112
|
+
export declare function collabTemplatesNotExecuted(eff: Pick<EffectiveConfig, "collab">): string[];
|
|
107
113
|
/**
|
|
108
114
|
* DESIGN-278 §5 S2([ref])—— center 这份 effective **当前在管**哪些 `ServiceConfig` 键(配置目录端点
|
|
109
115
|
* `GET /v1/config/catalog` 判 `effectiveLane` 的 center 半场)。
|
|
@@ -127,7 +133,7 @@ export declare function applyRuntimeHot(config: ServiceConfig, gov: EffectiveCon
|
|
|
127
133
|
/**
|
|
128
134
|
* Read-only comparison (`WEB_ADMIN_ENV.dryRun`): log what the web-admin config WOULD change vs the current
|
|
129
135
|
* (env-derived) config, WITHOUT applying it. The safe-rollout step the web-admin recommends — verify
|
|
130
|
-
* the center's models/roles
|
|
136
|
+
* the center's models/roles match (or intentionally differ from) the env baseline before going live.
|
|
131
137
|
*/
|
|
132
138
|
export declare function logEffectiveDiff(config: ServiceConfig, eff: EffectiveConfig, logger?: Logger): void;
|
|
133
139
|
//# sourceMappingURL=apply-effective.d.ts.map
|