@sema-agent/server 7.135.0 → 7.137.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 +237 -2
- package/USAGE.md +146 -41
- package/deploy/sema-up/README.md +15 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +7 -1
- package/deploy/sema-up/chart/values.yaml +1 -1
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +7 -1
- package/dist/approval-card.d.ts +60 -4
- package/dist/approval-card.js +18 -1
- package/dist/approval-content-kind.d.ts +7 -0
- package/dist/approval-content-kind.js +8 -1
- package/dist/approval-gate-currency.d.ts +48 -6
- package/dist/approval-gate-currency.js +16 -9
- package/dist/approval-hmac.d.ts +13 -1
- package/dist/approval-hmac.js +1 -1
- package/dist/approval.js +3 -3
- package/dist/auth-bridge.d.ts +34 -5
- package/dist/auth-bridge.js +22 -5
- package/dist/boot/budget-tracing.d.ts +1 -2
- package/dist/boot/budget-tracing.js +2 -2
- package/dist/boot/execution-env.d.ts +24 -1
- package/dist/boot/execution-env.js +69 -6
- package/dist/boot/org-memory.js +1 -1
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +15 -1
- package/dist/boot/resolve-spec.d.ts +4 -0
- package/dist/boot/resolve-spec.js +24 -22
- package/dist/boot/runner-deps.js +4 -2
- package/dist/boot/stage-03-store-backend.d.ts +1 -1
- package/dist/boot/stage-04-stores.d.ts +2 -2
- package/dist/boot/stage-05-execution-env.d.ts +4 -2
- package/dist/boot/stage-05-execution-env.js +11 -2
- package/dist/boot/stage-06-runners.d.ts +4 -2
- package/dist/boot/stage-06-runners.js +5 -1
- package/dist/boot/stage-07-capability-layer.d.ts +5 -2
- package/dist/boot/stage-07-capability-layer.js +1 -1
- package/dist/boot/stage-08-reapers.d.ts +5 -2
- package/dist/boot/stage-08-reapers.js +2 -1
- package/dist/boot/stage-09-leader.d.ts +5 -2
- package/dist/boot/stage-10-http-server.d.ts +5 -2
- package/dist/boot/stage-10-http-server.js +3 -2
- package/dist/boot/stores.d.ts +1 -1
- package/dist/boot/stores.js +2 -3
- package/dist/boot/web-admin.js +10 -17
- package/dist/brain.js +12 -3
- package/dist/broker/broker.d.ts +89 -0
- package/dist/broker/broker.js +287 -0
- package/dist/broker/constants.d.ts +39 -0
- package/dist/broker/constants.js +15 -0
- package/dist/broker/http1.d.ts +111 -0
- package/dist/broker/http1.js +256 -0
- package/dist/broker/lease-book.d.ts +87 -0
- package/dist/broker/lease-book.js +142 -0
- package/dist/broker/lease-file.d.ts +60 -0
- package/dist/broker/lease-file.js +127 -0
- package/dist/broker/main.d.ts +2 -0
- package/dist/broker/main.js +20 -0
- package/dist/budget.d.ts +3 -3
- package/dist/budget.js +4 -0
- package/dist/capabilities/composite-members.d.ts +2 -1
- package/dist/capabilities/composite-members.js +2 -1
- package/dist/capabilities/engine-capabilities.js +1 -0
- package/dist/capabilities/mcp-probe.d.ts +5 -4
- package/dist/capabilities/scenarios.d.ts +23 -8
- package/dist/capabilities/scenarios.js +13 -8
- package/dist/capabilities/skills.d.ts +28 -5
- package/dist/capabilities/skills.js +8 -0
- package/dist/capability-facts.d.ts +3 -7
- package/dist/capability-facts.js +3 -5
- package/dist/center-credential-renewer.js +5 -1
- package/dist/center-credential.d.ts +18 -4
- package/dist/center-credential.js +18 -3
- package/dist/checkpoint-ctx-seal-m28.d.ts +3 -10
- package/dist/checkpoint-ctx-seal-m28.js +1 -1
- package/dist/checkpoint-identity.d.ts +3 -3
- package/dist/config-catalog.js +21 -16
- package/dist/config-d-migration.js +1 -1
- package/dist/config-invariants.d.ts +1 -1
- package/dist/config-invariants.js +8 -0
- package/dist/config-lkg.d.ts +0 -38
- package/dist/config-lkg.js +1 -83
- package/dist/config-types.d.ts +21 -4
- package/dist/config.d.ts +1 -1
- package/dist/config.js +60 -16
- package/dist/deployment-governance.d.ts +2 -2
- package/dist/deployment-governance.js +7 -9
- package/dist/deployment-shape.d.ts +1 -1
- package/dist/device-ws-protocol.d.ts +1 -0
- package/dist/device-ws-protocol.js +2 -1
- package/dist/elicitation.d.ts +8 -7
- package/dist/elicitation.js +9 -8
- package/dist/file-history-disclosure.d.ts +8 -4
- package/dist/file-history-disclosure.js +24 -6
- package/dist/fleet-client.d.ts +32 -1
- package/dist/fleet-client.js +24 -4
- package/dist/fleet-lease.d.ts +7 -3
- package/dist/fleet-lease.js +31 -23
- package/dist/hooks/classic-stations.d.ts +11 -54
- package/dist/hooks/hook-llm.js +14 -8
- package/dist/hooks/hook-runner.d.ts +4 -4
- package/dist/hooks/hook-runner.js +2 -2
- package/dist/http/admission.js +10 -7
- package/dist/http/approval-sweeps.js +4 -3
- package/dist/http/caller-trust.d.ts +2 -1
- package/dist/http/caller-trust.js +1 -3
- package/dist/http/checkpoint-ctx.d.ts +76 -16
- package/dist/http/checkpoint-ctx.js +45 -1
- package/dist/http/dispatch.js +24 -19
- package/dist/http/durable-run-leg.d.ts +5 -1
- package/dist/http/durable-run-leg.js +1 -1
- package/dist/http/health-self-report.d.ts +2 -2
- package/dist/http/mcp-remote-text.d.ts +5 -0
- package/dist/http/mcp-remote-text.js +7 -0
- package/dist/http/principal-gate.d.ts +15 -10
- package/dist/http/principal-gate.js +48 -9
- package/dist/http/resume-ctx-read.d.ts +2 -16
- package/dist/http/resume-ctx-read.js +2 -3
- package/dist/http/resume-legs.d.ts +2 -20
- package/dist/http/resume-legs.js +52 -38
- package/dist/http/route-ctx.d.ts +8 -2
- package/dist/http/routes/approvals-assistant.d.ts +0 -2
- package/dist/http/routes/approvals-assistant.js +65 -16
- package/dist/http/routes/capabilities.js +11 -1
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +5 -7
- package/dist/http/routes/runs.js +4 -3
- package/dist/http/routes/session-sync.js +70 -12
- package/dist/http/routes/sessions.js +20 -15
- package/dist/http/routes/tasks.js +8 -6
- package/dist/http/server.d.ts +4 -0
- package/dist/http/stored-body-replay.d.ts +3 -3
- package/dist/http/stored-body-replay.js +6 -1
- package/dist/http/submit-ctx.js +1 -1
- package/dist/http/wire-types.d.ts +57 -30
- package/dist/identity-source.d.ts +65 -0
- package/dist/identity-source.js +45 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/memory-store-refusal.d.ts +3 -3
- package/dist/model-entry-refusal.d.ts +2 -0
- package/dist/model-entry-refusal.js +11 -0
- package/dist/model-route-gap.d.ts +49 -4
- package/dist/model-route-gap.js +34 -1
- package/dist/model-select.d.ts +6 -17
- package/dist/model-select.js +0 -3
- package/dist/namespaced-rule-name.d.ts +1 -1
- package/dist/object-store-buckets.d.ts +13 -0
- package/dist/object-store-buckets.js +3 -0
- package/dist/observability/fail-open.d.ts +19 -7
- package/dist/observability/fail-open.js +19 -7
- package/dist/observability/metrics.js +2 -2
- package/dist/observability/principal-context.d.ts +4 -1
- package/dist/observability/principal-context.js +6 -1
- package/dist/observability/run-terminal.js +1 -0
- package/dist/operator-ask.d.ts +2 -2
- package/dist/org-delivery-gate.js +1 -1
- package/dist/org-memory-admission.d.ts +2 -2
- package/dist/org-memory-admission.js +39 -2
- package/dist/parked-decide.d.ts +4 -3
- package/dist/parked-decide.js +29 -9
- package/dist/peer-directory.d.ts +2 -1
- package/dist/peer-directory.js +7 -5
- package/dist/permission-rule-list.d.ts +2 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +8 -0
- package/dist/plugins/approval-ask-store-sql.js +3 -0
- package/dist/plugins/blob-backend.js +2 -1
- package/dist/plugins/checkpoint-index-columns.d.ts +50 -1
- package/dist/plugins/checkpoint-index-columns.js +28 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +46 -12
- package/dist/plugins/checkpoint-store-sql.js +64 -35
- package/dist/plugins/file-history-store-sql.d.ts +6 -0
- package/dist/plugins/file-history-store-sql.js +37 -37
- package/dist/plugins/file-run-store.js +8 -2
- package/dist/plugins/k8s-exec-protocol.d.ts +69 -13
- package/dist/plugins/k8s-exec-protocol.js +116 -28
- package/dist/plugins/k8s-pod-delete-failure.d.ts +25 -0
- package/dist/plugins/k8s-pod-delete-failure.js +17 -0
- package/dist/plugins/k8s-pod-reaper.d.ts +112 -0
- package/dist/plugins/k8s-pod-reaper.js +122 -0
- package/dist/plugins/local-checkpoint-store.d.ts +3 -6
- package/dist/plugins/local-checkpoint-store.js +7 -6
- package/dist/plugins/memory-run-store.js +2 -0
- package/dist/plugins/one-time-migrations.d.ts +49 -37
- package/dist/plugins/one-time-migrations.js +87 -128
- package/dist/plugins/permission-rule-store-file.js +2 -2
- package/dist/plugins/permission-rule-store-sql.d.ts +17 -17
- package/dist/plugins/permission-rule-store-sql.js +16 -17
- package/dist/plugins/pg-pool.js +4 -0
- package/dist/plugins/pg-session-storage.js +2 -2
- 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 +4 -0
- package/dist/plugins/remote-env-e2b.d.ts +3 -0
- package/dist/plugins/remote-env-e2b.js +1 -0
- package/dist/plugins/remote-env-file-error.d.ts +8 -1
- package/dist/plugins/remote-env-file-error.js +7 -1
- package/dist/plugins/remote-env-host.d.ts +7 -1
- package/dist/plugins/remote-env-host.js +7 -1
- package/dist/plugins/remote-env-k8s.d.ts +154 -14
- package/dist/plugins/remote-env-k8s.js +300 -21
- package/dist/plugins/remote-env-local-docker.d.ts +3 -0
- package/dist/plugins/remote-env-local-docker.js +1 -0
- package/dist/plugins/remote-env-ssh.d.ts +3 -0
- package/dist/plugins/remote-env-ssh.js +1 -0
- package/dist/plugins/run-store-sql.js +10 -4
- package/dist/plugins/s3-answer.d.ts +15 -0
- package/dist/plugins/s3-answer.js +5 -0
- package/dist/plugins/session-ownership.d.ts +17 -3
- package/dist/plugins/session-ownership.js +19 -5
- package/dist/plugins/snapshot-bucket-presence.d.ts +39 -4
- package/dist/plugins/snapshot-bucket-presence.js +35 -7
- package/dist/plugins/sql-errors.d.ts +60 -0
- package/dist/plugins/sql-errors.js +64 -1
- package/dist/plugins/store-contracts.d.ts +10 -1
- package/dist/plugins/store-fault.d.ts +4 -0
- package/dist/plugins/store-fault.js +10 -0
- package/dist/plugins/tidb-pool.js +8 -1
- package/dist/plugins/tidb-session-store.js +2 -2
- package/dist/plugins/web-search.d.ts +1 -1
- package/dist/plugins/web-search.js +2 -2
- package/dist/request-declaration-refusal.d.ts +94 -0
- package/dist/request-declaration-refusal.js +78 -0
- package/dist/request-image-urls.d.ts +6 -0
- package/dist/request-image-urls.js +27 -0
- package/dist/request-key-closure.d.ts +5 -0
- package/dist/request-key-closure.js +5 -2
- package/dist/request-value-closure.d.ts +31 -2
- package/dist/request-value-closure.js +7 -1
- package/dist/rule-entry-list.d.ts +3 -2
- package/dist/rule-entry-list.js +2 -2
- package/dist/rules-consent.js +7 -4
- package/dist/run-local.d.ts +2 -2
- package/dist/runs.js +2 -1
- package/dist/runtime-caps-resolver.js +1 -1
- package/dist/runtime-governance.d.ts +5 -5
- package/dist/sandbox-git-lease.d.ts +49 -0
- package/dist/sandbox-git-lease.js +60 -0
- package/dist/sandbox-git-plane.d.ts +84 -0
- package/dist/sandbox-git-plane.js +105 -0
- package/dist/sandbox-pkg-source.d.ts +28 -1
- package/dist/sandbox-pkg-source.js +1 -2
- package/dist/sealed-key.d.ts +19 -0
- package/dist/sealed-key.js +47 -4
- package/dist/security.d.ts +16 -4
- package/dist/security.js +8 -3
- package/dist/server-secret-env.d.ts +6 -0
- package/dist/server-secret-env.js +14 -0
- package/dist/session-error-wire.d.ts +14 -6
- package/dist/session-error-wire.js +2 -1
- package/dist/session-incarnation.d.ts +16 -5
- package/dist/session-incarnation.js +7 -4
- package/dist/session-policy-wire.d.ts +1 -1
- package/dist/session-policy-wire.js +2 -2
- package/dist/session-row.d.ts +3 -17
- package/dist/session-row.js +4 -0
- package/dist/session-sync.d.ts +15 -3
- package/dist/session-sync.js +5 -2
- package/dist/spec-fields.d.ts +43 -13
- package/dist/spec-fields.js +33 -12
- package/dist/stored-request-prompt-profile-m30.d.ts +49 -0
- package/dist/stored-request-prompt-profile-m30.js +25 -0
- package/dist/task-a2a.d.ts +52 -81
- package/dist/task-a2a.js +219 -89
- package/dist/task-mcp.d.ts +7 -15
- package/dist/task-mcp.js +16 -51
- package/dist/task-settings.d.ts +2 -2
- package/dist/tool-approval.d.ts +35 -12
- package/dist/tool-approval.js +59 -39
- package/dist/tool-rule-names.d.ts +5 -0
- package/dist/trace/core-keyset-guard.d.ts +5 -5
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +2 -0
- package/dist/trace/exit-seat.js +37 -13
- package/dist/trace/ledger-sink.d.ts +4 -5
- package/dist/trace/ledger-sink.js +3 -7
- package/dist/trace/project.d.ts +37 -3
- package/dist/trace/project.js +20 -6
- package/dist/trace/redact.d.ts +40 -12
- package/dist/trace/redact.js +332 -128
- package/dist/trace/self-minted-wire.d.ts +641 -0
- package/dist/trace/self-minted-wire.js +201 -0
- package/dist/trace/wire-projection-faces.d.ts +5 -3
- package/dist/trace/wire-projection-faces.js +7 -3
- package/dist/url-credential-refusal.d.ts +52 -0
- package/dist/url-credential-refusal.js +14 -0
- package/dist/url-refusal.d.ts +13 -4
- package/dist/url-refusal.js +8 -2
- package/dist/web-admin-client/apply-effective.js +0 -1
- package/dist/web-admin-client/center-request.d.ts +20 -2
- package/dist/web-admin-client/center-request.js +40 -5
- package/dist/web-admin-client/http-client.js +6 -6
- package/dist/web-admin-client/types.d.ts +5 -5
- package/dist/workspace-space.d.ts +27 -0
- package/dist/workspace-space.js +26 -0
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +11 -5
- package/package.json +4 -3
- package/scripts/drain-check-local.mjs +2 -1
- package/scripts/drain-check.mysql.sql +3 -1
- package/scripts/drain-check.pg.sql +3 -1
- package/skills/schedule.md +1 -1
- package/wire-changes/server@7.104.0.json +134 -0
- package/wire-changes/server@7.105.0.json +53 -0
- package/wire-changes/server@7.106.0.json +475 -0
- package/wire-changes/server@7.107.0.json +64 -0
- package/wire-changes/server@7.108.0.json +153 -0
- package/wire-changes/server@7.109.0.json +46 -0
- package/wire-changes/server@7.110.0.json +90 -0
- package/wire-changes/server@7.111.0.json +86 -0
- package/wire-changes/server@7.112.0.json +60 -0
- package/wire-changes/server@7.113.0.json +26 -0
- package/wire-changes/server@7.114.0.json +26 -0
- package/wire-changes/server@7.115.0.json +97 -0
- package/wire-changes/server@7.116.0.json +218 -0
- package/wire-changes/server@7.116.1.json +26 -0
- package/wire-changes/server@7.117.0.json +65 -0
- package/wire-changes/server@7.118.0.json +129 -0
- package/wire-changes/server@7.119.0.json +65 -0
- package/wire-changes/server@7.120.0.json +89 -0
- package/wire-changes/server@7.121.0.json +219 -0
- package/wire-changes/server@7.122.0.json +54 -0
- package/wire-changes/server@7.123.0.json +26 -0
- package/wire-changes/server@7.124.0.json +336 -0
- package/wire-changes/server@7.124.1.json +26 -0
- package/wire-changes/server@7.125.0.json +111 -0
- package/wire-changes/server@7.126.0.json +285 -0
- package/wire-changes/server@7.127.0.json +77 -0
- package/wire-changes/server@7.127.1.json +26 -0
- package/wire-changes/server@7.127.2.json +53 -0
- package/wire-changes/server@7.128.0.json +26 -0
- package/wire-changes/server@7.129.0.json +106 -0
- package/wire-changes/server@7.129.1.json +26 -0
- package/wire-changes/server@7.130.0.json +26 -0
- package/wire-changes/server@7.131.0.json +118 -0
- package/wire-changes/server@7.132.0.json +226 -0
- package/wire-changes/server@7.133.0.json +1155 -0
- package/wire-changes/server@7.134.0.json +107 -0
- package/wire-changes/server@7.135.0.json +174 -0
- package/wire-changes/server@7.136.0.json +448 -0
- package/wire-changes/server@7.137.0.json +825 -0
- package/dist/url-credential.d.ts +0 -52
- package/dist/url-credential.js +0 -49
package/dist/tool-approval.d.ts
CHANGED
|
@@ -213,11 +213,14 @@ export declare function carriesDeploymentListQuestion(deploymentListAsks: boolea
|
|
|
213
213
|
* 本仓**策略层自己交出去的一问**的 {@link StandingAnswerFacts}。读者两个:部署名单门(`approval.ts`,`deploymentListQuestion: true`)与 workflow 问句门
|
|
214
214
|
* (`task-settings.ts`,`false`)—— 它们在交出这一问之前先读按工具名记的耐久豁免店(「本会话不再询问」在本层兑现,继承链上的同一问才够得着;审批席依约不退役
|
|
215
215
|
* 继承问),而**能不能读**与审批席 / 回决写侧是同一只判据({@link standingAnswerDurablyRecordable}):记得下的才代答,记不下的(带授予绑定的问 ……)不代答,
|
|
216
|
-
* 存量行也不例外 —— 一事一读。事实取自**这一问本身**:类集经 core 包根唯一的类派生 `classifyAsk`({@link
|
|
216
|
+
* 存量行也不例外 —— 一事一读。事实取自**这一问本身**:类集经 core 包根唯一的类派生 `classifyAsk`({@link noGateFacts},调用坐标取 `req`);`requiresRealApproval` /
|
|
217
217
|
* `mandated` 读这一问自报的成员;治理位恒假(本层不是治理层);授予绑定读**调用**(`callGrantBindingOf` —— 本层手里还没有引擎铸的卡,core 7.51.0 不在
|
|
218
218
|
* `ToolCallRequest` 上盖绑定词,[ref] 载体问题见 `standing-answer-grant.ts` 头注)。
|
|
219
219
|
*/
|
|
220
|
-
export declare function policyAskStandingAnswerFacts(req: StandingAnswerCall
|
|
220
|
+
export declare function policyAskStandingAnswerFacts(req: StandingAnswerCall & {
|
|
221
|
+
readonly toolCallId: string;
|
|
222
|
+
readonly toolName: string;
|
|
223
|
+
}, ask: Extract<PermissionResult, {
|
|
221
224
|
action: "ask";
|
|
222
225
|
}>, deploymentListQuestion: boolean): StandingAnswerFacts;
|
|
223
226
|
/**
|
|
@@ -507,7 +510,8 @@ export interface ToolApprovalFrame {
|
|
|
507
510
|
* `approval-content-kind.ts` 的 `readApprovalCard` 闭集窄读(集外 ⇒ 缺席 + 计一次 closed-word-out-of-set)。`question` = 问用户的问题(引擎保留的
|
|
508
511
|
* 问答工具),不是副作用工具。**本仓不从工具名回推卡**(工具名只作展示):此前按名字铸的 `livePending` 行 / 队列行 `contentKind` 随本键删。
|
|
509
512
|
* 停驻孪生 = 门的 `gate.approvalCard`(运维队列行顶层同名键,两只店读同一只 `parkedApprovalCard`)。display:本仓不按它裁决。
|
|
510
|
-
* 🔴 缺席即缺席(宿主自建的 ask / 老引擎),不编 `generic
|
|
513
|
+
* 🔴 缺席即缺席(宿主自建的 ask / 老引擎),不编 `generic`。7.136.0 起卡面同带(`ApprovalCardSchema.approvalCard`:发帧点把这一格交给铸卡 ⇒
|
|
514
|
+
* `card_json` 与断连重放帧的卡上是同一个词)。
|
|
511
515
|
*/
|
|
512
516
|
approvalCard?: ToolApprovalCard;
|
|
513
517
|
/**
|
|
@@ -1026,6 +1030,13 @@ export type UnattendedAskOutcome = Extract<AskOutcome, "unavailable"> | Unattend
|
|
|
1026
1030
|
/** [ref] 候裁 16:耐久会话授权店(`src/plugins/approval-exemption-store.ts` 的同一只店):审批席读它(引擎的问),活卡上部署名单那一问的
|
|
1027
1031
|
* 「本会话放行」写它(名单门在出问之前读同一行)。 */
|
|
1028
1032
|
export type SessionGrantStore = Pick<ApprovalExemptionStore, "has" | "grant">;
|
|
1033
|
+
/** redactDeep + size-bound the UNTRUSTED tool args before they are streamed. Over the cap / unserializable ⇒
|
|
1034
|
+
* undefined (frame rides argsOmitted — see MAX_APPROVAL_ARGS_BYTES). */
|
|
1035
|
+
/**
|
|
1036
|
+
* 给审批人看的一份入参 —— 卡上 `args` 的**同一种读法**({@link boundArgs}:脱敏 + 字节帽;超帽 / 序列化不出 ⇒ `undefined`)。
|
|
1037
|
+
* 读者:卡帧 / 卡面(经 `boundArgs` 本体)与续跑拒体的 `acceptableForm`(core 7.56.0 [ref]:编辑复判只收改写后的那一形,人在决定口看到它、批准它)。
|
|
1038
|
+
*/
|
|
1039
|
+
export declare function approverFacingArgs(args: unknown): unknown;
|
|
1029
1040
|
/**
|
|
1030
1041
|
* [ref] 车3 刀 3b —— 「流内审批协议到底上不上场」的**单一谓词**(设计稿 §2.3 注入 / §2.4 能力面 /
|
|
1031
1042
|
* §8.4 park 设施自检,三处同一份判据)。
|
|
@@ -1969,16 +1980,21 @@ export declare class ToolApprovalCoordinator {
|
|
|
1969
1980
|
status: number;
|
|
1970
1981
|
body: unknown;
|
|
1971
1982
|
}>;
|
|
1983
|
+
/** [ref]:这条登记**有没有问账行**(有 ⇒ 属主的唯一来源是行上当下的 owner 列;没有 ⇒ 登记记下的那一位是唯一可读的属主事实)。 */
|
|
1984
|
+
private registrationHasRow;
|
|
1972
1985
|
/**
|
|
1973
|
-
* [ref]
|
|
1974
|
-
*
|
|
1975
|
-
*
|
|
1986
|
+
* [ref]([ref] 的接管登记一臂并进来):**读行判属主**的应答 —— 接管登记恒走这里;活登记在登记记下的属主不认调用方时走这里(行可能已被收编改给调用方)。
|
|
1987
|
+
* 属主门读**行当下的** owner:登记上记下的那一格是铸卡(或接管)那一刻的进程内快照,`/v1/adoption` 改写行之后它就落后了(契约:应答口的授权判据取
|
|
1988
|
+
* 当下的持久事实,收编之后旧属主手里的卡作废、新属主照常答得了 —— 与耐久决断口同答)。行仍 `STREAM_PENDING` ⇒ {@link answerRegistration}(同一把
|
|
1989
|
+
* `decideAsk` CAS,绑门刚读到的那位属主,[ref];活登记上那条在等的腿照常收到决议);行已有终局(别处答了 / 对账器收了,本副本还没闻讯)⇒ 按行的真相答
|
|
1990
|
+
* (与晚答口同一张表)。读不出行 ⇒ 不知道属主是谁 ⇒ 与未知 id 同形同码(属主门 fail-closed)。
|
|
1976
1991
|
*/
|
|
1977
|
-
private
|
|
1992
|
+
private respondByRow;
|
|
1978
1993
|
/** 一条已过属主门的登记(活登记或接管登记)的应答 —— 两者同一条路:规则文本前门 → 要人门 → CAS → 兑付。
|
|
1979
1994
|
* `judgedOwner` = 门判过的那位属主([ref]:决议作用域的属主维,CAS 与确认读都绑它;见 `askRowCarriesOwner`)。 */
|
|
1980
1995
|
private answerRegistration;
|
|
1981
|
-
/** 一次 live 回决**落定之后**的两件兑付(部署名单那一问的豁免、「不再询问」的规则)—— 两件都只在 200 那一支、都读同一只资格。
|
|
1996
|
+
/** 一次 live 回决**落定之后**的两件兑付(部署名单那一问的豁免、「不再询问」的规则)—— 两件都只在 200 那一支、都读同一只资格。
|
|
1997
|
+
* `judgedOwner` = 这次决议的门判过的那位属主([ref]:一次决议只读一次属主 —— 决议 CAS、会话放行、规则落店、豁免记账都用这一份,不回头重读登记上的那一格)。 */
|
|
1982
1998
|
private afterLiveDecision;
|
|
1983
1999
|
/**
|
|
1984
2000
|
* **部署名单(`APPROVAL_REQUIRE`)那一问的「本会话放行」只落 server 的会话豁免店**(谁问的,谁的站着的答案算数):名单的问是 server 铸的,
|
|
@@ -2026,8 +2042,13 @@ export declare class ToolApprovalCoordinator {
|
|
|
2026
2042
|
status: number;
|
|
2027
2043
|
body: unknown;
|
|
2028
2044
|
}>;
|
|
2029
|
-
/**
|
|
2030
|
-
|
|
2045
|
+
/**
|
|
2046
|
+
* [ref]:有行的登记的按问读口 —— 行可见且仍 `STREAM_PENDING` ⇒ `pending`(列表面同一只行投影);否则按行的态答(与读行半场同一张表)。
|
|
2047
|
+
* 🔴 行**读不出**(店抛 / 超时)⇒ 只有**本协调器自己铸的活登记**回落:登记记下的属主认调用方 ⇒ `pending`,否则与未知 id 同答 —— 与同一刻的应答口同答
|
|
2048
|
+
* (活登记的应答拿登记属主当候选、不多读一次店,店抖动不挡真实回决,D5),也与 7.135.x 的读口同答。**接管登记**([ref],起服从问账接管、没有引擎腿在等)的
|
|
2049
|
+
* 属主跟着行走,登记上那一格不是权威 —— 应答口对它恒读行判、读不出 ⇒ 404,读口同样 404(两口同答;7.135.x 两口都 404)。读得出的「没有这一行」不回落(那是行的真相)。
|
|
2050
|
+
*/
|
|
2051
|
+
private readByRow;
|
|
2031
2052
|
/** {@link readApproval} 的读行半场。 */
|
|
2032
2053
|
private readAskRowState;
|
|
2033
2054
|
/**
|
|
@@ -2068,8 +2089,10 @@ export declare class ToolApprovalCoordinator {
|
|
|
2068
2089
|
/** {@link respondLate} 的读行:按 id 读出行,交 {@link dispatchRowTruth}。 */
|
|
2069
2090
|
private dispatchLateByRow;
|
|
2070
2091
|
/**
|
|
2071
|
-
* 按 wire 身份(= 行的键)
|
|
2072
|
-
*
|
|
2092
|
+
* 按 wire 身份(= 行的键)读行 —— 三态分开交回({@link AskRowRead}):读到了 / 读得出的「没有这一行」/ 读不出(店抛或超时,记账)。
|
|
2093
|
+
* 「读不出」与「不在」不折成一个值:调用点各自表态 —— 应答口与晚答口按「查无」答(读不出 = **不知道**这只 ask 落在哪一态,而受理臂都在对客户端做承诺,
|
|
2094
|
+
* 不知道 ⇒ 回那句 404,绝不把未知说成受理;D5 的 fail-open 只覆盖「不挡人的真实回决」那一面,这条腿方向相反),按问读口对本协调器自己铸的活登记回落那一份登记
|
|
2095
|
+
* (接管登记不回落,{@link readByRow})。
|
|
2073
2096
|
*/
|
|
2074
2097
|
private askRowFor;
|
|
2075
2098
|
/**
|
package/dist/tool-approval.js
CHANGED
|
@@ -13,7 +13,7 @@ import { recordFailOpen } from "./observability/fail-open.js";
|
|
|
13
13
|
import { ownerOfCheckpointScope } from "./security.js";
|
|
14
14
|
import { deriveAskId, deriveAskScopedBatchId, deriveBatchId, MAX_DECISION_NOTE_CHARS, noteLandedOnRow, noteRecordedReceipt } from "./approval-ask-machine.js";
|
|
15
15
|
import { currentParkArm, MAX_RULE_OFFERS, buildApprovalCard, buildApprovalCardEnvelope, buildApprovalRequestFrame, buildReplayFrame, buildRevokeFrame, readDenialLimitFallback, readProbeCause, readProbeReason, readReadRootCandidate, readStoredCardEnvelope, readRuleEvidence, readAllowRuleShadowed, readRuleOffersAbsence, readRuleOffersAbsenceSeat, readParkRowTrueSeat, readAskClassPair, readClosedWordSeat, buildApprovalCompleteFrame, readRuleOfferList, } from "./approval-card.js";
|
|
16
|
-
import { askRowCarriesOwner, POLICY_REFUSAL_DECISION, projectAskTerminalClaimTruth } from "./plugins/approval-ask-store-sql.js";
|
|
16
|
+
import { askOwnerAdmits, askRowCarriesOwner, POLICY_REFUSAL_DECISION, projectAskTerminalClaimTruth } from "./plugins/approval-ask-store-sql.js";
|
|
17
17
|
import { APPROVAL_ENDING_CAUSES, SETTLE_OUTCOME, causeOfAskRow } from "./approval-deny-reasons.js";
|
|
18
18
|
import { settleByPolicy } from "./approval-policy-settlement.js";
|
|
19
19
|
import { governanceAskMarksFor, runWithGovernanceAskScope } from "./governance-ask-marks.js";
|
|
@@ -123,8 +123,10 @@ function askStandingAnswerFacts(req, governanceForced, deploymentListAsks) {
|
|
|
123
123
|
deploymentListQuestion,
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
function noGateFacts(call) {
|
|
127
|
+
return { call, contentQuestion: false, markedUnresolvable: false, org: undefined, tightened: undefined, mandateMarks: {} };
|
|
128
|
+
}
|
|
129
|
+
const DEPLOYMENT_LIST_ASK_CLASSES = new Set(classifyAsk(operatorAsk("APPROVAL_REQUIRE", ""), noGateFacts({ toolCallId: "", toolName: "" })).classes);
|
|
128
130
|
export function carriesDeploymentListQuestion(deploymentListAsks, classes) {
|
|
129
131
|
return deploymentListAsks && classes !== undefined && classes.some((c) => DEPLOYMENT_LIST_ASK_CLASSES.has(c));
|
|
130
132
|
}
|
|
@@ -134,7 +136,7 @@ export function policyAskStandingAnswerFacts(req, ask, deploymentListQuestion) {
|
|
|
134
136
|
requiresRealApproval: ask.requiresRealApproval === true,
|
|
135
137
|
mandated: ask.mandated === true,
|
|
136
138
|
grantBinding: callGrantBindingOf(req),
|
|
137
|
-
classes: [...classifyAsk(ask,
|
|
139
|
+
classes: [...classifyAsk(ask, noGateFacts({ toolCallId: req.toolCallId, toolName: req.toolName })).classes],
|
|
138
140
|
deploymentListQuestion,
|
|
139
141
|
};
|
|
140
142
|
}
|
|
@@ -195,8 +197,11 @@ function mandatedFromSeat(seat) {
|
|
|
195
197
|
return false;
|
|
196
198
|
}
|
|
197
199
|
}
|
|
200
|
+
function rowOrUnknown(read) {
|
|
201
|
+
return read.kind === "row" ? read.row : null;
|
|
202
|
+
}
|
|
198
203
|
function askRowVisibleTo(row, principal) {
|
|
199
|
-
return row !== null && (row.owner
|
|
204
|
+
return row !== null && askOwnerAdmits(row.owner, principal);
|
|
200
205
|
}
|
|
201
206
|
function waitingLegsReached(entry, othersReached) {
|
|
202
207
|
return (entry.adopted === true ? 0 : 1) + othersReached;
|
|
@@ -206,7 +211,7 @@ function withConsumerDisclosure(result, waitingLegs) {
|
|
|
206
211
|
}
|
|
207
212
|
function livePendingRowOf(e) {
|
|
208
213
|
const listFrame = e.adopted === true ? e.cardFrame : (e.cardFrame ?? e.frame);
|
|
209
|
-
const approvalCard = e.adopted === true ? e.cardFrame.approvalCard : e.frame.approvalCard;
|
|
214
|
+
const approvalCard = e.adopted === true ? e.cardFrame.card.approvalCard : e.frame.approvalCard;
|
|
210
215
|
return {
|
|
211
216
|
approvalId: e.approvalId,
|
|
212
217
|
toolName: e.toolName,
|
|
@@ -332,6 +337,9 @@ function unattendedRefusalReason(site) {
|
|
|
332
337
|
function isChildAsk(req) {
|
|
333
338
|
return req.fromSubagent === true;
|
|
334
339
|
}
|
|
340
|
+
export function approverFacingArgs(args) {
|
|
341
|
+
return boundArgs(args).args;
|
|
342
|
+
}
|
|
335
343
|
function boundArgs(args) {
|
|
336
344
|
const redacted = redactDeep(args);
|
|
337
345
|
let hasBidi = false;
|
|
@@ -2049,17 +2057,21 @@ export class ToolApprovalCoordinator {
|
|
|
2049
2057
|
}
|
|
2050
2058
|
const entry = this.liveEntryFor(id);
|
|
2051
2059
|
if (entry?.adopted === true)
|
|
2052
|
-
return this.
|
|
2053
|
-
if (
|
|
2054
|
-
return this.
|
|
2055
|
-
|
|
2056
|
-
|
|
2060
|
+
return this.respondByRow(entry, id, principal, parsed, httpReq);
|
|
2061
|
+
if (entry !== undefined && askOwnerAdmits(entry.owner, principal))
|
|
2062
|
+
return this.answerRegistration(entry, entry.owner, id, principal, parsed, httpReq);
|
|
2063
|
+
if (entry !== undefined && this.registrationHasRow(entry))
|
|
2064
|
+
return this.respondByRow(entry, id, principal, parsed, httpReq);
|
|
2065
|
+
return this.respondLate(id, principal, parsed, httpReq);
|
|
2066
|
+
}
|
|
2067
|
+
registrationHasRow(entry) {
|
|
2068
|
+
return this.askStore !== undefined && entry.askId !== undefined;
|
|
2057
2069
|
}
|
|
2058
|
-
async
|
|
2070
|
+
async respondByRow(entry, id, principal, parsed, httpReq) {
|
|
2059
2071
|
const store = this.askStore;
|
|
2060
2072
|
if (!store)
|
|
2061
2073
|
return this.notPending();
|
|
2062
|
-
const row = await this.askRowFor(store, id, "getAsk(respond-
|
|
2074
|
+
const row = rowOrUnknown(await this.askRowFor(store, id, "getAsk(respond-by-row)"));
|
|
2063
2075
|
if (!askRowVisibleTo(row, principal))
|
|
2064
2076
|
return this.notPending(NOT_PENDING_UNKNOWN_CAUSE);
|
|
2065
2077
|
if (row.state !== "STREAM_PENDING")
|
|
@@ -2067,7 +2079,7 @@ export class ToolApprovalCoordinator {
|
|
|
2067
2079
|
return this.answerRegistration(entry, row.owner, id, principal, parsed, httpReq);
|
|
2068
2080
|
}
|
|
2069
2081
|
answerRegistration(entry, judgedOwner, id, principal, parsed, httpReq) {
|
|
2070
|
-
const preRule = this.precheckEditedRuleBeforeDecision(entry, parsed);
|
|
2082
|
+
const preRule = this.precheckEditedRuleBeforeDecision(entry, judgedOwner, parsed);
|
|
2071
2083
|
if (preRule !== undefined)
|
|
2072
2084
|
return preRule;
|
|
2073
2085
|
if (parsed.value !== "deny" && policyCannotAnswer(heldAskOf(entry.requiresRealApproval === true), parsed.decidedBy)) {
|
|
@@ -2076,17 +2088,17 @@ export class ToolApprovalCoordinator {
|
|
|
2076
2088
|
const ruleEligibility = { eligible: true };
|
|
2077
2089
|
const store = this.askStore;
|
|
2078
2090
|
if (store && entry.askId !== undefined && entry.batchId !== undefined) {
|
|
2079
|
-
return this.respondWithCas(store, entry.askId, entry.batchId, judgedOwner, entry, parsed, ruleEligibility).then((cas) => cas.lost ? this.dispatchRowTruth(cas.row, id, parsed, httpReq, principal) : this.afterLiveDecision(cas.result, entry, parsed, principal, ruleEligibility));
|
|
2091
|
+
return this.respondWithCas(store, entry.askId, entry.batchId, judgedOwner, entry, parsed, ruleEligibility).then((cas) => cas.lost ? this.dispatchRowTruth(cas.row, id, parsed, httpReq, principal) : this.afterLiveDecision(cas.result, entry, judgedOwner, parsed, principal, ruleEligibility));
|
|
2080
2092
|
}
|
|
2081
|
-
return this.afterLiveDecision(this.finishRespond(entry, parsed), entry, parsed, principal, ruleEligibility);
|
|
2093
|
+
return this.afterLiveDecision(this.finishRespond(entry, judgedOwner, parsed), entry, judgedOwner, parsed, principal, ruleEligibility);
|
|
2082
2094
|
}
|
|
2083
|
-
afterLiveDecision(decided, entry, parsed, principal, ruleEligibility) {
|
|
2084
|
-
const settled = this.recordDeploymentListAnswer(decided, entry, parsed, principal, ruleEligibility);
|
|
2095
|
+
afterLiveDecision(decided, entry, judgedOwner, parsed, principal, ruleEligibility) {
|
|
2096
|
+
const settled = this.recordDeploymentListAnswer(decided, entry, judgedOwner, parsed, principal, ruleEligibility);
|
|
2085
2097
|
if (parsed.persistRule === undefined)
|
|
2086
2098
|
return settled;
|
|
2087
|
-
return this.persistRuleAfterDecision(settled, entry, parsed.persistRule, parsed.updatedInput !== undefined, ruleEligibility);
|
|
2099
|
+
return this.persistRuleAfterDecision(settled, entry, judgedOwner, parsed.persistRule, parsed.updatedInput !== undefined, ruleEligibility);
|
|
2088
2100
|
}
|
|
2089
|
-
recordDeploymentListAnswer(decided, entry, parsed, principal, eligibility) {
|
|
2101
|
+
recordDeploymentListAnswer(decided, entry, judgedOwner, parsed, principal, eligibility) {
|
|
2090
2102
|
const store = this.sessionGrants;
|
|
2091
2103
|
const sessionId = entry.sessionId;
|
|
2092
2104
|
if (parsed.value !== "allow_session" || !sessionId || store === undefined)
|
|
@@ -2101,9 +2113,9 @@ export class ToolApprovalCoordinator {
|
|
|
2101
2113
|
return { ...result, body: { ...result.body, rememberApplied: false } };
|
|
2102
2114
|
let rememberApplied = false;
|
|
2103
2115
|
try {
|
|
2104
|
-
await this.withStoreDeadline(store.grant(sessionId, entry.toolName, principal ??
|
|
2116
|
+
await this.withStoreDeadline(store.grant(sessionId, entry.toolName, principal ?? judgedOwner), "sessionGrants.grant(deployment-list)", DURABLE_CALL_TIMEOUT_MS);
|
|
2105
2117
|
rememberApplied = true;
|
|
2106
|
-
defaultLogger.info("approval_exemption_granted", { sessionId, toolName: entry.toolName, grantedBy: principal ??
|
|
2118
|
+
defaultLogger.info("approval_exemption_granted", { sessionId, toolName: entry.toolName, grantedBy: principal ?? judgedOwner });
|
|
2107
2119
|
}
|
|
2108
2120
|
catch (err) {
|
|
2109
2121
|
defaultLogger.warn("approval_exemption_grant_failed", { sessionId, toolName: entry.toolName, error: String(err).slice(0, 200) });
|
|
@@ -2111,7 +2123,7 @@ export class ToolApprovalCoordinator {
|
|
|
2111
2123
|
return { ...result, body: { ...result.body, rememberApplied } };
|
|
2112
2124
|
})();
|
|
2113
2125
|
}
|
|
2114
|
-
precheckEditedRuleBeforeDecision(entry, parsed) {
|
|
2126
|
+
precheckEditedRuleBeforeDecision(entry, judgedOwner, parsed) {
|
|
2115
2127
|
const persistRule = parsed.persistRule;
|
|
2116
2128
|
if (persistRule === undefined || persistRule.kind !== "text" || !persistRule.edited)
|
|
2117
2129
|
return undefined;
|
|
@@ -2120,7 +2132,7 @@ export class ToolApprovalCoordinator {
|
|
|
2120
2132
|
if (entry.governanceForced === true)
|
|
2121
2133
|
return undefined;
|
|
2122
2134
|
const command = entry.ruleLane?.command;
|
|
2123
|
-
if (this.ruleConsent === undefined || command === undefined ||
|
|
2135
|
+
if (this.ruleConsent === undefined || command === undefined || judgedOwner === null)
|
|
2124
2136
|
return undefined;
|
|
2125
2137
|
const verdict = precheckCardRuleText(persistRule.rule, command);
|
|
2126
2138
|
if (verdict === undefined || verdict.ok)
|
|
@@ -2155,9 +2167,9 @@ export class ToolApprovalCoordinator {
|
|
|
2155
2167
|
}
|
|
2156
2168
|
readApproval(id, principal) {
|
|
2157
2169
|
const entry = this.liveEntryFor(id);
|
|
2158
|
-
if (entry
|
|
2159
|
-
return this.
|
|
2160
|
-
if (entry !== undefined && (entry.owner
|
|
2170
|
+
if (entry !== undefined && this.registrationHasRow(entry))
|
|
2171
|
+
return this.readByRow(entry, id, principal);
|
|
2172
|
+
if (entry !== undefined && askOwnerAdmits(entry.owner, principal)) {
|
|
2161
2173
|
const body = { state: "pending", ...livePendingRowOf(entry) };
|
|
2162
2174
|
return { status: 200, body };
|
|
2163
2175
|
}
|
|
@@ -2166,11 +2178,18 @@ export class ToolApprovalCoordinator {
|
|
|
2166
2178
|
return this.notPending();
|
|
2167
2179
|
return this.readAskRowState(store, id, principal);
|
|
2168
2180
|
}
|
|
2169
|
-
async
|
|
2181
|
+
async readByRow(entry, id, principal) {
|
|
2170
2182
|
const store = this.askStore;
|
|
2171
2183
|
if (!store)
|
|
2172
2184
|
return this.notPending();
|
|
2173
|
-
const
|
|
2185
|
+
const read = await this.askRowFor(store, id, "getAsk(read-by-row)");
|
|
2186
|
+
if (read.kind === "unreadable") {
|
|
2187
|
+
if (entry.adopted === true || !askOwnerAdmits(entry.owner, principal))
|
|
2188
|
+
return this.notPending(NOT_PENDING_UNKNOWN_CAUSE);
|
|
2189
|
+
const body = { state: "pending", ...livePendingRowOf(entry) };
|
|
2190
|
+
return { status: 200, body };
|
|
2191
|
+
}
|
|
2192
|
+
const row = rowOrUnknown(read);
|
|
2174
2193
|
if (askRowVisibleTo(row, principal) && row.state === "STREAM_PENDING") {
|
|
2175
2194
|
const body = { state: "pending", ...livePendingRowOf(entry) };
|
|
2176
2195
|
return { status: 200, body };
|
|
@@ -2178,7 +2197,7 @@ export class ToolApprovalCoordinator {
|
|
|
2178
2197
|
return this.readStateOfRow(row, principal);
|
|
2179
2198
|
}
|
|
2180
2199
|
async readAskRowState(store, id, principal) {
|
|
2181
|
-
return this.readStateOfRow(await this.askRowFor(store, id, "getAsk(read)"), principal);
|
|
2200
|
+
return this.readStateOfRow(rowOrUnknown(await this.askRowFor(store, id, "getAsk(read)")), principal);
|
|
2182
2201
|
}
|
|
2183
2202
|
async readParkedGate(row) {
|
|
2184
2203
|
const gate = this.parkedGate;
|
|
@@ -2310,15 +2329,16 @@ export class ToolApprovalCoordinator {
|
|
|
2310
2329
|
return undefined;
|
|
2311
2330
|
}
|
|
2312
2331
|
async dispatchLateByRow(store, id, parsed, httpReq, principal) {
|
|
2313
|
-
return this.dispatchRowTruth(await this.askRowFor(store, id, "getAsk(respond-late)"), id, parsed, httpReq, principal);
|
|
2332
|
+
return this.dispatchRowTruth(rowOrUnknown(await this.askRowFor(store, id, "getAsk(respond-late)")), id, parsed, httpReq, principal);
|
|
2314
2333
|
}
|
|
2315
2334
|
async askRowFor(store, id, label) {
|
|
2316
2335
|
try {
|
|
2317
|
-
|
|
2336
|
+
const row = await this.withStoreDeadline(store.getAsk(id), label, DURABLE_CONVERGE_READ_TIMEOUT_MS);
|
|
2337
|
+
return row === null ? { kind: "absent" } : { kind: "row", row };
|
|
2318
2338
|
}
|
|
2319
2339
|
catch (err) {
|
|
2320
2340
|
this.noteStoreError(err, label);
|
|
2321
|
-
return
|
|
2341
|
+
return { kind: "unreadable" };
|
|
2322
2342
|
}
|
|
2323
2343
|
}
|
|
2324
2344
|
async dispatchRowTruth(row, id, parsed, httpReq, principal) {
|
|
@@ -2580,13 +2600,13 @@ export class ToolApprovalCoordinator {
|
|
|
2580
2600
|
},
|
|
2581
2601
|
};
|
|
2582
2602
|
}
|
|
2583
|
-
async persistRuleAfterDecision(settled, entry, persistRule, inputWasEdited, ruleEligibility) {
|
|
2603
|
+
async persistRuleAfterDecision(settled, entry, judgedOwner, persistRule, inputWasEdited, ruleEligibility) {
|
|
2584
2604
|
const result = await settled;
|
|
2585
2605
|
if (result.status !== 200)
|
|
2586
2606
|
return result;
|
|
2587
2607
|
const lane = this.ruleConsent;
|
|
2588
2608
|
const material = entry.ruleLane;
|
|
2589
|
-
const owner =
|
|
2609
|
+
const owner = judgedOwner;
|
|
2590
2610
|
const withFlag = (rulePersisted, ruleRefusal, echo) => ({
|
|
2591
2611
|
status: result.status,
|
|
2592
2612
|
body: { ...result.body, rulePersisted, ...(ruleRefusal !== undefined ? { ruleRefusal } : {}), ...(echo ?? {}) },
|
|
@@ -2708,11 +2728,11 @@ export class ToolApprovalCoordinator {
|
|
|
2708
2728
|
if (!converged) {
|
|
2709
2729
|
return { lost: false, result: this.notPending() };
|
|
2710
2730
|
}
|
|
2711
|
-
return { lost: false, result: withConsumerDisclosure(this.finishRespond(entry, parsed, { updatedInputDelivered: false, noteRecorded: noteLanded }), waitingLegsReached(entry, othersReached)) };
|
|
2731
|
+
return { lost: false, result: withConsumerDisclosure(this.finishRespond(entry, owner, parsed, { updatedInputDelivered: false, noteRecorded: noteLanded }), waitingLegsReached(entry, othersReached)) };
|
|
2712
2732
|
}
|
|
2713
2733
|
const payloadIsMine = ambiguousConfirmedRow === undefined ||
|
|
2714
2734
|
approvalPayloadFingerprint({ updatedInput: ambiguousConfirmedRow.updatedInput }) === approvalPayloadFingerprint({ updatedInput: parsed.updatedInput });
|
|
2715
|
-
const result = this.finishRespond(entry, parsed, {
|
|
2735
|
+
const result = this.finishRespond(entry, owner, parsed, {
|
|
2716
2736
|
noteRecorded: noteLanded,
|
|
2717
2737
|
...(winnerRow !== undefined ? { settleOutcome: outcomeOfDecidedRow(winnerRow), settleOutcomeIsThisRequest: ambiguousConfirmedRow === undefined } : {}),
|
|
2718
2738
|
...(entry.adopted === true ? { updatedInputDelivered: false } : ambiguousConfirmedRow !== undefined ? { updatedInputDelivered: payloadIsMine } : {}),
|
|
@@ -2720,7 +2740,7 @@ export class ToolApprovalCoordinator {
|
|
|
2720
2740
|
const othersReached = winnerRow !== undefined ? this.notifyExternalDecision(askId, outcomeOfDecidedRow(winnerRow)).settled : 0;
|
|
2721
2741
|
return { lost: false, result: withConsumerDisclosure(result, waitingLegsReached(entry, othersReached)) };
|
|
2722
2742
|
}
|
|
2723
|
-
finishRespond(entry, parsed, opts) {
|
|
2743
|
+
finishRespond(entry, judgedOwner, parsed, opts) {
|
|
2724
2744
|
let rememberApplied;
|
|
2725
2745
|
const home = standingAnswerHome(pendingEntryStandingAnswerFacts(entry));
|
|
2726
2746
|
let grantable;
|
|
@@ -2745,7 +2765,7 @@ export class ToolApprovalCoordinator {
|
|
|
2745
2765
|
if (oldest !== undefined)
|
|
2746
2766
|
this.allowAllSessions.delete(oldest);
|
|
2747
2767
|
}
|
|
2748
|
-
this.allowAllSessions.add(sessionAllowKey(
|
|
2768
|
+
this.allowAllSessions.add(sessionAllowKey(judgedOwner, entry.sessionId, sessionAllowCategory(entry.toolName), entry.grantBinding));
|
|
2749
2769
|
}
|
|
2750
2770
|
const allowed = parsed.value !== "deny";
|
|
2751
2771
|
const settleArgs = opts?.settleOutcome !== undefined ? settleArgsOfDecided(opts.settleOutcome) : { allowed, updatedInput: parsed.updatedInput, settledBy: liveSettledBy(parsed.decidedBy) };
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
* 7.53.x 及以前,`MyShell` 的 `egress: true` / `irreversibility: "always"` 会让引擎 `Bash` 的调用多问一次(收紧),它的恒可逆探针会让引擎 `Bash` 的
|
|
23
23
|
* `touch` 不问就跑(放宽);7.54.0 起两者都不再作用于引擎 shell。要收紧引擎 shell:给**正名**叫 `Bash` 的工具声明标记(同名标记仍作用),或请求
|
|
24
24
|
* `TaskSpec.shellGate: "always"`(本仓的入口 `MANUAL_MODE_SHELL_GATE` / 请求 `shellGate`)。
|
|
25
|
+
* ⚠️ **反方向(core 7.56.0 [ref])**:一次调用的安全轴只按它答得上的名字读,别名不带副本;两个名字的层级**平局时归 wire 名**(真正跑的那只工具)。
|
|
26
|
+
* 于是 `MyShell{irreversibility:"maybe", aliases:["Bash"]}` 在引擎 shell 被选择器卸下的腿上按 `Bash` 被调时,判它的是 **`MyShell` 自己的探针**
|
|
27
|
+
* (7.55.x 及以前是引擎 shell 席的形状探针:`ls` 不问就跑、`MyShell` 的探针从未被问)。⇒ 嵌入方给这类工具**照实声明**判它自己命令的探针,
|
|
28
|
+
* 或不声明层级、或 `irreversibility: "always"`;不声明层级时引擎 shell 席的层级仍够得着它(引擎侧候设计车,问的模式下按 shell 探针问,
|
|
29
|
+
* `bypassPermissions` 下照放)。本仓自身不声明带别名的工具,零码;这一形只有经 `resolveSpec` 席挂别名工具的嵌入方走得到。
|
|
25
30
|
*
|
|
26
31
|
* 返回**命中的那个名字**(调用答得上的名字里第一个被规则够到的,拼写在先)—— 规则归因(`matchedAskRule`)写运维名单里的那个名,
|
|
27
32
|
* 不写一个名单里查不到的 wire 名;够不到 ⇒ `undefined`。判定式(精确集 / covering 规则)由调用方给,本函数只管「读哪些名字」。
|
|
@@ -45,7 +45,7 @@ type RosterProjected = "name" | "agentId" | "sessionId" | "toolUseId" | "owner"
|
|
|
45
45
|
type _GuardRoster = AssertAllKeysHandled<Exclude<keyof RosterEntry, RosterProjected>>;
|
|
46
46
|
type _GuardRosterReverse = AssertAllKeysHandled<Exclude<RosterProjected, keyof RosterEntry>>;
|
|
47
47
|
type AskProjected = "toolName" | "toolCallId" | "args" | "message" | "sourceTaskId" | "fromSubagent" | "sourceAgentName" | "delegation" | "ruleOffers" | "ruleOffersAbsence" | "allowRuleShadowed" | "probeCause" | "probeReason" | "ruleEvidence" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "readRootCandidate" | "mandated" | "mandate" | "askClass" | "classes" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "approvalCard" | "boundGrantAbsence";
|
|
48
|
-
type AskExcluded = "preview" | "principal" | "riskAxes" | "boundInputHash" | "isDelegatedChild" | "hasBidiControls" | "previewWithheld" | "execCwd" | "authoredBy";
|
|
48
|
+
type AskExcluded = "preview" | "principal" | "riskAxes" | "boundInputHash" | "isDelegatedChild" | "hasBidiControls" | "previewWithheld" | "execCwd" | "authoredBy" | "requestedBy" | "editRewritten";
|
|
49
49
|
type _GuardAsk = AssertAllKeysHandled<Exclude<keyof AskRequest, AskProjected | AskExcluded>>;
|
|
50
50
|
type _GuardAskReverse = AssertAllKeysHandled<Exclude<AskProjected | AskExcluded, keyof AskRequest>>;
|
|
51
51
|
type AskFrameServerMinted = "type" | "approvalId" | "argsOmitted" | "outcome" | "governanceForced" | "expiresAtMs" | "expiresInMs" | "serverNowMs" | "parked" | "cause" | "inputHasBidi" | "rememberRefused";
|
|
@@ -218,17 +218,17 @@ type _GuardInboxSummaryReverse = AssertAllKeysHandled<Exclude<SummaryProjected |
|
|
|
218
218
|
type ParkArmKeys = keyof Extract<PendingAction, {
|
|
219
219
|
kind: "tool_approval";
|
|
220
220
|
}>;
|
|
221
|
-
type ParkArmQueueProjected = "toolName" | "toolCallId" | "boundInputHash" | "ruleOffers" | "hasBidiControls" | keyof import("../approval-card.js").ParkRowFacts;
|
|
222
|
-
type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "hostTarget" | "targets" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "
|
|
221
|
+
type ParkArmQueueProjected = "toolName" | "toolCallId" | "boundInputHash" | "ruleOffers" | "hasBidiControls" | keyof import("../approval-card.js").ParkRowFacts | keyof import("../approval-card.js").SkillCardFacts;
|
|
222
|
+
type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "hostTarget" | "targets" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "engineMounted";
|
|
223
223
|
type _GuardParkArmQueue = AssertAllKeysHandled<Exclude<ParkArmKeys, ParkArmQueueProjected | ParkArmQueueExcluded>>;
|
|
224
224
|
type _GuardParkArmQueueReverse = AssertAllKeysHandled<Exclude<ParkArmQueueProjected | ParkArmQueueExcluded, ParkArmKeys>>;
|
|
225
225
|
type _NoDoubleBookParkArmQueue = AssertAllKeysHandled<Extract<ParkArmQueueProjected, ParkArmQueueExcluded>>;
|
|
226
|
-
type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "
|
|
226
|
+
type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptLean" | "toolPolicy" | "onAsk" | "onQuestion" | "mods" | "durableApproval" | "resourceSuspend" | "resilience" | "finalVerification" | "checkpointStore" | "handsReadOnly" | "memoryPersistenceCapable" | "additionalDirectories" | "additionalReadDirectories" | "enablePlanMode" | "interactiveTools" | "enableFork" | "shellGate" | "approvalReach" | "writeFace" | "mcp" | "a2a" | "skills" | "backgroundScope" | "envFacts" | "limits" | "configOverrides" | "forwardSubagentEvents" | "retainSubagentSessions" | "retainBackgroundProcesses" | "outputSchema" | "outputRetries" | "compaction" | "attachments" | "selfOrchestration" | "getApiKeyAndHeaders" | "interactionPosture" | "agents" | "permissionMode" | "taskId" | "signal" | "preemptSignal" | "maxSuspends" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "excludeAllTools" | "fileHistory" | "userInvokedSkills" | "outputStyle" | "projectMemory" | "allowedTools" | "allowTools" | "userAttachments" | "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies";
|
|
227
227
|
/** 导出:请求体键闭集门(`request-key-closure.ts`)据它锁「本仓记为未接线的引擎座,提交口不许受理」—— 两处分类只能同向。 */
|
|
228
228
|
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel";
|
|
229
229
|
type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
|
|
230
230
|
type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
|
|
231
|
-
type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "terminal" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "remoteEnvFailures" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveWriteFace" | "effectiveMemoryScopes" | "stats" | "editedFiles" | "responseModel" | "compaction";
|
|
231
|
+
type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "terminal" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "remoteEnvFailures" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveWriteFace" | "effectiveMemoryScopes" | "stats" | "editedFiles" | "responseModel" | "compaction" | "resultEntryIds";
|
|
232
232
|
type TaskResultStripped = never;
|
|
233
233
|
type _GuardTaskResult = AssertAllKeysHandled<Exclude<keyof TaskResult, TaskResultForwarded | TaskResultStripped>>;
|
|
234
234
|
type _GuardTaskResultReverse = AssertAllKeysHandled<Exclude<TaskResultForwarded | TaskResultStripped, keyof TaskResult>>;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* 同文件 G1 e2e 的全码扇出夹具、以及契约文档附录 D.3 那张表(含**小节标题里的码数** —— 那道门本批
|
|
17
17
|
* 刚立,立完就在下一次加码时自己咬住了)。
|
|
18
18
|
*/
|
|
19
|
-
export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached"];
|
|
19
|
+
export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached", "inherit_env.names_withheld", "model.capability_downgraded"];
|
|
20
20
|
export type EngineNoticeWireCode = (typeof ENGINE_NOTICE_WIRE_CODES)[number];
|
|
21
21
|
/** 白名单谓词(单点):路由与门都读这一个,不许第二处手抄码串。 */
|
|
22
22
|
export declare function isEngineNoticeWireCode(code: string): code is EngineNoticeWireCode;
|
|
@@ -44,6 +44,8 @@ export const ENGINE_NOTICE_WIRE_CODES = [
|
|
|
44
44
|
"mods.registration_refused",
|
|
45
45
|
"config.session_rules_earlier_grammar",
|
|
46
46
|
"advisor.not_attached",
|
|
47
|
+
"inherit_env.names_withheld",
|
|
48
|
+
"model.capability_downgraded",
|
|
47
49
|
];
|
|
48
50
|
const WIRE_CODES = new Set(ENGINE_NOTICE_WIRE_CODES);
|
|
49
51
|
export function isEngineNoticeWireCode(code) {
|
package/dist/trace/exit-seat.js
CHANGED
|
@@ -3,7 +3,7 @@ import { CALLER_TEXT_CUT_MARK } from "../caller-text-echo.js";
|
|
|
3
3
|
import { errorKindOf } from "../observability/err-text.js";
|
|
4
4
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
5
5
|
import { OVERSIZED_REDACTION_PLACEHOLDER } from "../observability/run-terminal.js";
|
|
6
|
-
import { proposeRedactionSpans, REDACTION_TOKEN_RE_SRC } from "./redact.js";
|
|
6
|
+
import { proposeRedactionSpans, readingHeadEnd, REDACTION_TOKEN_RE_SRC, WHOLE_EXTENT } from "./redact.js";
|
|
7
7
|
const EXIT_SEATS = {
|
|
8
8
|
"trace-frame-text": { scope: "free-text" },
|
|
9
9
|
"trace-frame-line": { scope: "free-text", maxChars: 300 },
|
|
@@ -38,8 +38,7 @@ function mergeSpans(spans) {
|
|
|
38
38
|
return out;
|
|
39
39
|
}
|
|
40
40
|
const TOKEN_AT = new RegExp(REDACTION_TOKEN_RE_SRC, "y");
|
|
41
|
-
function
|
|
42
|
-
let cut = room;
|
|
41
|
+
function safeCutPoint(gap, cut) {
|
|
43
42
|
const hi = gap.charCodeAt(cut - 1);
|
|
44
43
|
if (cut > 0 && hi >= 0xd800 && hi <= 0xdbff && (gap.charCodeAt(cut) & 0xfc00) === 0xdc00)
|
|
45
44
|
cut -= 1;
|
|
@@ -50,16 +49,19 @@ function cutPlain(gap, room) {
|
|
|
50
49
|
if (m !== null && open + m[0].length > cut)
|
|
51
50
|
cut = open;
|
|
52
51
|
}
|
|
53
|
-
return
|
|
52
|
+
return cut;
|
|
54
53
|
}
|
|
55
|
-
|
|
54
|
+
const cutPlain = (gap, room) => gap.slice(0, safeCutPoint(gap, room));
|
|
55
|
+
function renderOnce(text, groups, until = Number.POSITIVE_INFINITY) {
|
|
56
56
|
const parts = [];
|
|
57
57
|
let at = 0;
|
|
58
58
|
for (const g of groups) {
|
|
59
|
+
if (g.start >= until)
|
|
60
|
+
break;
|
|
59
61
|
parts.push(text.slice(at, g.start), g.repl);
|
|
60
62
|
at = g.end;
|
|
61
63
|
}
|
|
62
|
-
parts.push(text.slice(at));
|
|
64
|
+
parts.push(text.slice(at, until));
|
|
63
65
|
return parts.join("");
|
|
64
66
|
}
|
|
65
67
|
function emitAs(form, text) {
|
|
@@ -79,12 +81,18 @@ function emitAs(form, text) {
|
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
const layoutOf = (row) => (row.emit === undefined ? "multi-line" : "single-line");
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
const SCAN_WINDOW_FLOOR = 4096;
|
|
85
|
+
const SCAN_WINDOW_PER_BOUND = 8;
|
|
86
|
+
const scanWindowOf = (maxChars) => Math.max(SCAN_WINDOW_FLOOR, maxChars * SCAN_WINDOW_PER_BOUND);
|
|
87
|
+
function boundRow(out, row, cutUpstream) {
|
|
88
|
+
if (row.maxChars === undefined)
|
|
84
89
|
return out;
|
|
85
90
|
if (row.emit === undefined)
|
|
86
|
-
return cutPlain(out, row.maxChars);
|
|
87
|
-
|
|
91
|
+
return out.length <= row.maxChars ? out : cutPlain(out, row.maxChars);
|
|
92
|
+
if (out.length <= row.maxChars && !cutUpstream)
|
|
93
|
+
return out;
|
|
94
|
+
const room = row.maxChars - CALLER_TEXT_CUT_MARK.length;
|
|
95
|
+
return (out.length <= room ? out : cutPlain(out, room)) + CALLER_TEXT_CUT_MARK;
|
|
88
96
|
}
|
|
89
97
|
export function seatText(seat, text) {
|
|
90
98
|
const row = SEAT_ROWS.get(seat);
|
|
@@ -92,11 +100,27 @@ export function seatText(seat, text) {
|
|
|
92
100
|
throw new Error(`exit seat: ${JSON.stringify(seat)} is not a row of the seat table`);
|
|
93
101
|
let out;
|
|
94
102
|
try {
|
|
95
|
-
|
|
103
|
+
const layout = layoutOf(row);
|
|
104
|
+
const scanWindow = row.maxChars === undefined ? undefined : scanWindowOf(row.maxChars);
|
|
105
|
+
let windowEnd;
|
|
106
|
+
let regionEnd;
|
|
107
|
+
if (scanWindow !== undefined && text.length > scanWindow) {
|
|
108
|
+
const half = scanWindow >>> 1;
|
|
109
|
+
const region = safeCutPoint(text, readingHeadEnd(text, layout, half));
|
|
110
|
+
const end = safeCutPoint(text, readingHeadEnd(text, layout, scanWindow - half, region));
|
|
111
|
+
if (end < text.length) {
|
|
112
|
+
windowEnd = end;
|
|
113
|
+
regionEnd = region;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const head = windowEnd === undefined ? text : text.slice(0, windowEnd);
|
|
117
|
+
if (row.emit !== undefined && emitAs(row.emit, head) === "")
|
|
96
118
|
out = "";
|
|
97
119
|
else {
|
|
98
|
-
const
|
|
99
|
-
|
|
120
|
+
const emitUntil = regionEnd;
|
|
121
|
+
const extent = windowEnd === undefined || regionEnd === undefined ? WHOLE_EXTENT : { kind: "head", emitEnd: regionEnd };
|
|
122
|
+
const rendered = renderOnce(head, mergeSpans(proposeRedactionSpans(head, row.scope, layout, extent)), emitUntil);
|
|
123
|
+
out = boundRow(row.emit === undefined ? rendered : emitAs(row.emit, rendered), row, windowEnd !== undefined);
|
|
100
124
|
}
|
|
101
125
|
}
|
|
102
126
|
catch (err) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type TerminalCause } from "@sema-agent/core";
|
|
2
|
-
import { brainStatusEventData } from "./project.js";
|
|
2
|
+
import { brainStatusEventData, type LegWiringSections } from "./project.js";
|
|
3
3
|
import { NotifiedKeys } from "../orchestration/workflow-completion-inbox.js";
|
|
4
4
|
import { type LedgerEventType, type ParkLedgerEventType } from "./ledger-events.js";
|
|
5
|
-
import type { InstructionsSegment } from "../instruction-selection.js";
|
|
6
5
|
/**
|
|
7
6
|
* LedgerSink — the SINGLE "stream event → durable runs-ledger" projection, shared by the background leg
|
|
8
7
|
* (runs.ts `runInBackground`) and the sync `/v1/tasks/stream` detach lane (server.ts, `x-detach-on-disconnect`).
|
|
@@ -152,8 +151,8 @@ export declare function createLedgerSink(opts: {
|
|
|
152
151
|
* 各传自己看得见的那个词(位①=流事件 `ev.type`,位②=账本行 `type`);拿不到类型的打点方
|
|
153
152
|
* (core 的 onActivity 第五席、resume 腿手动打点)省参,`kind` 诚实缺席(见 turn-activity.ts)。 */
|
|
154
153
|
onActivity?: (kind?: string, statusData?: Record<string, unknown>) => void;
|
|
155
|
-
/** [ref]
|
|
156
|
-
*
|
|
157
|
-
|
|
154
|
+
/** 这条腿的 `wiring_manifest` **本仓自铸段**(`LegWiringSections`:[ref] `instructions` 读腿的 `InstructionSelectionLeg.segment`、run 级 `skills` 读 spec 字段
|
|
155
|
+
* `runSkillsOf`)。**必填**:账本行与 live 帧是同一条腿的两个载体,段必须来自同一只腿;在投帧那一刻读(core 推帧之前已 await 过 loader)。 */
|
|
156
|
+
legSections: () => LegWiringSections;
|
|
158
157
|
}): LedgerSink;
|
|
159
158
|
//# sourceMappingURL=ledger-sink.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {} from "@sema-agent/core";
|
|
2
2
|
import { outwardPlane } from "../terminal.js";
|
|
3
3
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
4
|
-
import { modelTextEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, compactionStartedEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, turnEndEventData, contextUsageEventData } from "./project.js";
|
|
4
|
+
import { modelTextEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, compactionStartedEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, turnEndEventData, contextUsageEventData, parkEventData } from "./project.js";
|
|
5
5
|
import { NotifiedKeys, taskNotificationStreamKeyOf } from "../orchestration/workflow-completion-inbox.js";
|
|
6
6
|
import { isParkLedgerEventType } from "./ledger-events.js";
|
|
7
7
|
import { isModelSegmentBoundary, reasoningDeltaBytes, reasoningSegmentEventId } from "./model-segment.js";
|
|
@@ -115,7 +115,7 @@ export function createLedgerSink(opts) {
|
|
|
115
115
|
await append("workspace_changed", workspaceChangedEventData(ev));
|
|
116
116
|
break;
|
|
117
117
|
case "wiring_manifest":
|
|
118
|
-
await append("wiring_manifest", wiringManifestEventData(ev, opts.
|
|
118
|
+
await append("wiring_manifest", wiringManifestEventData(ev, opts.legSections()));
|
|
119
119
|
break;
|
|
120
120
|
case "tool_roster_delta": {
|
|
121
121
|
const rosterDelta = toolRosterDeltaEventData(ev);
|
|
@@ -179,11 +179,7 @@ export function createLedgerSink(opts) {
|
|
|
179
179
|
return append("status", statusData);
|
|
180
180
|
};
|
|
181
181
|
const appendParked = (kind, result) => {
|
|
182
|
-
|
|
183
|
-
return append(kind, {
|
|
184
|
-
gate: t?.kind === "paused" ? t.gate : null,
|
|
185
|
-
...(typeof result?.toolCallId === "string" ? { toolCallId: result.toolCallId } : {}),
|
|
186
|
-
});
|
|
182
|
+
return append(kind, parkEventData(result));
|
|
187
183
|
};
|
|
188
184
|
const appendDone = (result) => append("done", { result });
|
|
189
185
|
const onDone = async (result) => {
|