@sema-agent/server 7.137.0 → 7.139.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 +600 -142
- package/README.md +7 -3
- package/README.zh-CN.md +6 -3
- package/USAGE.md +132 -41
- package/deploy/sema-up/README.md +1 -1
- package/deploy/sema-up/lib/lanes.json +3 -2
- package/dist/adoption/wire.d.ts +3 -3
- package/dist/approval-card.d.ts +23 -16
- package/dist/approval-card.js +1 -0
- package/dist/audit.js +1 -0
- package/dist/background-agent-name.d.ts +5 -0
- package/dist/background-agent-name.js +5 -0
- package/dist/bench/s1/arms.d.ts +1 -1
- package/dist/bench/s1/arms.js +1 -3
- package/dist/bench/s1/run-firm.js +2 -2
- package/dist/boot/budget-tracing.d.ts +1 -12
- package/dist/boot/deployment-mods.d.ts +46 -16
- package/dist/boot/deployment-mods.js +82 -6
- package/dist/boot/device-lane.d.ts +8 -3
- package/dist/boot/device-lane.js +7 -2
- package/dist/boot/execution-env.d.ts +4 -2
- package/dist/boot/execution-env.js +16 -24
- package/dist/boot/execution-lane.d.ts +1 -1
- package/dist/boot/governance-seams.d.ts +12 -18
- package/dist/boot/governance-seams.js +10 -24
- package/dist/boot/leader.d.ts +3 -0
- package/dist/boot/leader.js +1 -0
- package/dist/boot/memory-consolidation.js +2 -2
- package/dist/boot/org-delivery.js +15 -2
- package/dist/boot/resolve-spec.d.ts +4 -1
- package/dist/boot/resolve-spec.js +29 -19
- package/dist/boot/retention-lane.d.ts +14 -8
- package/dist/boot/retention-lane.js +2 -8
- package/dist/boot/runner-deps.d.ts +10 -4
- package/dist/boot/runner-deps.js +2 -0
- package/dist/boot/session-faces.d.ts +0 -3
- package/dist/boot/session-faces.js +15 -8
- package/dist/boot/stage-02-web-admin-pull.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -12
- package/dist/boot/stage-05-execution-env.d.ts +3 -12
- package/dist/boot/stage-05-execution-env.js +8 -5
- package/dist/boot/stage-06-runners.d.ts +3 -12
- package/dist/boot/stage-06-runners.js +5 -3
- package/dist/boot/stage-07-capability-layer.d.ts +3 -12
- package/dist/boot/stage-07-capability-layer.js +2 -2
- package/dist/boot/stage-08-reapers.d.ts +3 -12
- package/dist/boot/stage-09-leader.d.ts +3 -12
- package/dist/boot/stage-09-leader.js +2 -3
- package/dist/boot/stage-10-http-server.d.ts +3 -12
- package/dist/boot/stage-10-http-server.js +5 -3
- package/dist/boot/stores.js +4 -4
- package/dist/boot/web-admin.d.ts +5 -2
- package/dist/boot/web-admin.js +5 -5
- package/dist/brain.js +5 -5
- package/dist/budget.d.ts +17 -15
- package/dist/budget.js +2 -2
- package/dist/capabilities/mcp-probe.d.ts +36 -11
- package/dist/capabilities/mcp-probe.js +44 -5
- package/dist/capabilities/scenarios.d.ts +1 -1
- package/dist/capability-facts.d.ts +21 -7
- package/dist/capability-facts.js +13 -3
- package/dist/checkpoint-identity.d.ts +13 -6
- package/dist/config-catalog.js +14 -8
- package/dist/config-invariants.d.ts +23 -3
- package/dist/config-invariants.js +42 -0
- package/dist/config-provider.d.ts +19 -24
- package/dist/config-provider.js +27 -12
- package/dist/config-types.d.ts +25 -12
- package/dist/config.d.ts +33 -0
- package/dist/config.js +52 -20
- package/dist/delegated-session-owner.d.ts +2 -2
- package/dist/deployment-shape.d.ts +7 -7
- package/dist/device-enrollment.d.ts +41 -2
- package/dist/device-enrollment.js +27 -12
- package/dist/device-store.d.ts +58 -85
- package/dist/device-store.js +19 -49
- package/dist/device-ws-hub.js +2 -1
- package/dist/env-name-allowlist-knobs.d.ts +5 -4
- package/dist/exec-cut.d.ts +60 -0
- package/dist/exec-cut.js +36 -0
- package/dist/execution-lane-caps.d.ts +19 -0
- package/dist/execution-lane-caps.js +10 -0
- package/dist/execution-placement.d.ts +259 -0
- package/dist/execution-placement.js +199 -0
- package/dist/field-conflict.d.ts +3 -2
- package/dist/field-conflict.js +1 -0
- package/dist/gate-settlement.d.ts +71 -0
- package/dist/gate-settlement.js +40 -0
- package/dist/hooks/classic-stations.d.ts +1 -0
- package/dist/hooks/classic-stations.js +1 -0
- package/dist/hooks/command-spawn.d.ts +2 -2
- package/dist/hooks/hook-runner.js +14 -14
- package/dist/hosted-posture.d.ts +2 -2
- package/dist/http/admission.js +10 -19
- package/dist/http/checkpoint-ctx.d.ts +21 -12
- package/dist/http/checkpoint-ctx.js +4 -2
- package/dist/http/claimed-run.d.ts +1 -1
- package/dist/http/dispatch.d.ts +4 -0
- package/dist/http/dispatch.js +3 -0
- package/dist/http/durable-run-leg.js +12 -6
- package/dist/http/execution-context.d.ts +218 -0
- package/dist/http/execution-context.js +330 -0
- package/dist/http/memory-compliance-failure-reply.js +3 -0
- package/dist/http/resume-legs.d.ts +5 -11
- package/dist/http/resume-legs.js +179 -104
- package/dist/http/route-ctx.d.ts +44 -59
- package/dist/http/route-ctx.js +2 -5
- package/dist/http/routes/a2a-serve.js +10 -4
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +5 -1
- package/dist/http/routes/approvals-assistant.js +6 -6
- package/dist/http/routes/background.d.ts +29 -1
- package/dist/http/routes/background.js +29 -2
- package/dist/http/routes/capabilities.js +12 -10
- package/dist/http/routes/devices.d.ts +13 -19
- package/dist/http/routes/devices.js +21 -26
- package/dist/http/routes/mcp-reconnect.d.ts +3 -2
- package/dist/http/routes/mcp-reconnect.js +7 -5
- package/dist/http/routes/memory-consolidation.d.ts +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/rules.js +3 -3
- package/dist/http/routes/runs.js +11 -7
- package/dist/http/routes/session-sync.js +110 -15
- package/dist/http/routes/sessions.d.ts +6 -0
- package/dist/http/routes/sessions.js +119 -13
- package/dist/http/routes/side-query.d.ts +12 -4
- package/dist/http/routes/side-query.js +6 -8
- package/dist/http/routes/tasks.js +800 -782
- package/dist/http/server.d.ts +61 -39
- package/dist/http/server.js +11 -0
- package/dist/http/session-inherit-env.d.ts +3 -4
- package/dist/http/session-inherit-env.js +1 -1
- package/dist/http/wire-types.d.ts +22 -18
- package/dist/identity-source.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/leader/wire.d.ts +7 -0
- package/dist/leader/wire.js +5 -4
- package/dist/mcp-assertion-header.d.ts +51 -40
- package/dist/mcp-assertion-header.js +10 -11
- package/dist/mcp-authorization-face.d.ts +27 -0
- package/dist/mcp-authorization-face.js +15 -0
- package/dist/memory-operator-faces.d.ts +13 -4
- package/dist/memory-operator-faces.js +1 -17
- package/dist/memory-sync-client.d.ts +53 -14
- package/dist/memory-sync-client.js +187 -92
- package/dist/memory-sync.d.ts +1 -1
- package/dist/memory-sync.js +3 -2
- package/dist/model-route-gap.d.ts +6 -22
- package/dist/model-route-gap.js +7 -5
- package/dist/mods-declaration.d.ts +110 -0
- package/dist/mods-declaration.js +109 -0
- package/dist/observability/cost-taxonomy.d.ts +2 -2
- package/dist/observability/err-text.d.ts +5 -0
- package/dist/observability/err-text.js +9 -0
- package/dist/observability/fail-open.d.ts +17 -1
- package/dist/observability/fail-open.js +17 -1
- package/dist/observability/run-terminal.js +0 -1
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/secret-env-scrub.js +1 -1
- package/dist/orchestration/workflow-notify-journal.js +4 -4
- package/dist/org-memory-admission.d.ts +4 -3
- package/dist/org-memory-admission.js +6 -6
- package/dist/parked-decide.d.ts +49 -11
- package/dist/parked-decide.js +25 -26
- package/dist/parked-revive-surface.d.ts +12 -15
- package/dist/parked-revive-surface.js +3 -6
- package/dist/peer-seat.d.ts +156 -0
- package/dist/peer-seat.js +273 -0
- package/dist/permission-rule-vocab.d.ts +7 -7
- package/dist/permission-rule-vocab.js +3 -3
- package/dist/plain-string-record.d.ts +38 -0
- package/dist/plain-string-record.js +38 -0
- package/dist/plugins/approval-ask-store-file.d.ts +7 -0
- package/dist/plugins/approval-ask-store-file.js +11 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +6 -0
- package/dist/plugins/approval-ask-store-memory.js +12 -0
- package/dist/plugins/approval-ask-store-sql.d.ts +22 -5
- package/dist/plugins/approval-ask-store-sql.js +30 -12
- package/dist/plugins/background-agent-store-sql.js +6 -3
- package/dist/plugins/caching-session-store.d.ts +11 -2
- package/dist/plugins/caching-session-store.js +15 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +21 -25
- package/dist/plugins/checkpoint-store-sql.js +13 -15
- package/dist/plugins/device-store-sql.d.ts +25 -51
- package/dist/plugins/device-store-sql.js +49 -103
- package/dist/plugins/execution-placement-sql.d.ts +151 -0
- package/dist/plugins/execution-placement-sql.js +223 -0
- package/dist/plugins/file-history-store-sql.d.ts +7 -6
- package/dist/plugins/file-history-store-sql.js +8 -7
- package/dist/plugins/file-run-store.d.ts +6 -1
- package/dist/plugins/file-run-store.js +4 -0
- package/dist/plugins/fork-routing-session-store.d.ts +6 -0
- package/dist/plugins/fork-routing-session-store.js +16 -0
- package/dist/plugins/k8s-pod-reaper.d.ts +2 -8
- package/dist/plugins/k8s-pod-reaper.js +3 -3
- package/dist/plugins/local-checkpoint-store.d.ts +1 -11
- package/dist/plugins/local-checkpoint-store.js +0 -1
- package/dist/plugins/local-session-store.d.ts +183 -45
- package/dist/plugins/local-session-store.js +412 -105
- package/dist/plugins/mailbox-store-sql.d.ts +11 -3
- package/dist/plugins/mailbox-store-sql.js +103 -15
- package/dist/plugins/memory-key-guards.d.ts +4 -0
- package/dist/plugins/memory-key-guards.js +1 -0
- package/dist/plugins/memory-run-store.d.ts +1 -1
- package/dist/plugins/memory-sync-store-pg.d.ts +16 -5
- package/dist/plugins/memory-sync-store-tidb.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +117 -6
- package/dist/plugins/one-time-migrations.js +383 -14
- package/dist/plugins/outcome-ledger-sql.d.ts +2 -2
- package/dist/plugins/permission-rule-store-sql.d.ts +13 -15
- package/dist/plugins/permission-rule-store-sql.js +34 -29
- package/dist/plugins/pg-pool.d.ts +7 -3
- package/dist/plugins/pg-session-storage.d.ts +41 -22
- package/dist/plugins/pg-session-storage.js +136 -55
- package/dist/plugins/remote-env-adb.d.ts +22 -4
- package/dist/plugins/remote-env-adb.js +70 -62
- package/dist/plugins/remote-env-device.d.ts +32 -12
- package/dist/plugins/remote-env-device.js +18 -17
- package/dist/plugins/remote-env-e2b.d.ts +19 -3
- package/dist/plugins/remote-env-e2b.js +41 -42
- package/dist/plugins/remote-env-file-error.d.ts +2 -0
- package/dist/plugins/remote-env-file-error.js +1 -1
- package/dist/plugins/remote-env-host.d.ts +23 -8
- package/dist/plugins/remote-env-host.js +66 -70
- package/dist/plugins/remote-env-k8s.d.ts +13 -16
- package/dist/plugins/remote-env-k8s.js +61 -54
- package/dist/plugins/remote-env-local-docker.d.ts +30 -5
- package/dist/plugins/remote-env-local-docker.js +46 -59
- package/dist/plugins/remote-env-ssh.d.ts +18 -4
- package/dist/plugins/remote-env-ssh.js +72 -56
- package/dist/plugins/remote-shell.d.ts +100 -3
- package/dist/plugins/remote-shell.js +166 -2
- package/dist/plugins/retention-store-sql.d.ts +23 -8
- package/dist/plugins/retention-store-sql.js +13 -1
- package/dist/plugins/run-store-sql.d.ts +13 -3
- package/dist/plugins/run-store-sql.js +5 -0
- package/dist/plugins/schema-consistency.d.ts +15 -5
- package/dist/plugins/schema-consistency.js +14 -8
- package/dist/plugins/schema-drift-sentence.d.ts +27 -0
- package/dist/plugins/schema-drift-sentence.js +38 -0
- package/dist/plugins/session-fork.d.ts +63 -12
- package/dist/plugins/session-fork.js +38 -21
- package/dist/plugins/session-ownership.d.ts +7 -0
- package/dist/plugins/session-ownership.js +5 -0
- package/dist/plugins/session-row-sql.d.ts +22 -0
- package/dist/plugins/session-row-sql.js +81 -0
- package/dist/plugins/session-store.d.ts +1 -1
- package/dist/plugins/session-workspace-cell.d.ts +17 -0
- package/dist/plugins/session-workspace-cell.js +38 -0
- package/dist/plugins/store-backend.d.ts +1 -1
- package/dist/plugins/store-backend.js +26 -14
- package/dist/plugins/store-contracts.d.ts +25 -5
- package/dist/plugins/tidb-pool.d.ts +12 -7
- package/dist/plugins/tidb-pool.js +15 -3
- package/dist/plugins/tidb-session-store.d.ts +74 -28
- package/dist/plugins/tidb-session-store.js +132 -53
- package/dist/plugins/tool-result-store-sql.d.ts +16 -8
- package/dist/plugins/tool-result-store-sql.js +26 -17
- package/dist/plugins/worktree-isolation.d.ts +3 -2
- package/dist/plugins/worktree-isolation.js +1 -7
- package/dist/project-identity.d.ts +1 -14
- package/dist/project-identity.js +0 -4
- package/dist/project-memory.d.ts +9 -15
- package/dist/project-memory.js +5 -4
- package/dist/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +6 -7
- package/dist/request-value-closure.js +1 -3
- package/dist/rules-consent.js +6 -4
- package/dist/run-local.d.ts +6 -0
- package/dist/run-local.js +36 -26
- package/dist/runs.d.ts +9 -2
- package/dist/runs.js +9 -2
- package/dist/sandbox-git-plane.d.ts +2 -2
- package/dist/security.d.ts +38 -12
- package/dist/security.js +8 -2
- package/dist/server-secret-env.d.ts +15 -8
- package/dist/server-secret-env.js +4 -2
- package/dist/session-children-retire.d.ts +27 -9
- package/dist/session-children-retire.js +9 -5
- package/dist/session-incarnation.d.ts +19 -10
- package/dist/session-incarnation.js +5 -3
- package/dist/session-row.d.ts +114 -5
- package/dist/session-row.js +55 -5
- package/dist/session-titler.d.ts +2 -2
- package/dist/session-workspace.d.ts +130 -0
- package/dist/session-workspace.js +83 -0
- package/dist/spec-fields.d.ts +1 -1
- package/dist/standing-answer-grant.d.ts +2 -13
- package/dist/standing-answer-grant.js +0 -7
- package/dist/task-a2a.d.ts +44 -14
- package/dist/task-a2a.js +46 -20
- package/dist/task-cwd.d.ts +6 -1
- package/dist/task-mcp.d.ts +33 -20
- package/dist/task-mcp.js +46 -22
- package/dist/tool-approval.d.ts +38 -8
- package/dist/tool-approval.js +57 -13
- package/dist/trace/core-keyset-guard.d.ts +33 -18
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +2 -0
- package/dist/trace/exit-seat.d.ts +20 -1
- package/dist/trace/exit-seat.js +3 -0
- package/dist/trace/extension-call-face.d.ts +33 -0
- package/dist/trace/extension-call-face.js +39 -0
- package/dist/trace/project.d.ts +26 -7
- package/dist/trace/project.js +30 -3
- package/dist/trace/redact.js +42 -13
- package/dist/trace/self-minted-wire.d.ts +240 -12
- package/dist/trace/self-minted-wire.js +100 -4
- package/dist/trace/wire-projection-faces.d.ts +6 -6
- package/dist/trace/wire-projection-faces.js +6 -5
- package/dist/url-refusal.d.ts +1 -1
- package/dist/user-authored-text.d.ts +2 -2
- package/dist/user-authored-text.js +16 -1
- package/dist/web-admin-client/apply-effective.d.ts +17 -3
- package/dist/web-admin-client/apply-effective.js +20 -10
- package/dist/web-admin-client/center-request.d.ts +3 -2
- package/dist/web-admin-client/center-request.js +2 -3
- package/dist/web-admin-client/skills-mcp.d.ts +8 -4
- package/dist/web-admin-client/skills-mcp.js +32 -18
- package/dist/web-admin-client/types.d.ts +11 -0
- package/package.json +3 -3
- package/wire-changes/server@7.138.0.json +446 -0
- package/wire-changes/server@7.139.0.json +348 -0
- package/dist/http/device-placement.d.ts +0 -175
- package/dist/http/device-placement.js +0 -145
- package/dist/http/mcp-remote-text.d.ts +0 -5
- package/dist/http/mcp-remote-text.js +0 -7
package/dist/tool-approval.js
CHANGED
|
@@ -3,6 +3,7 @@ import { heldAskOf, liveSettledBy, readDecidedBy, retiredDecisionKeyFacts, DECID
|
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { uuidv7, classifyAsk, foldArbitrationRow, policyCannotAnswer, screenAskClassMembers, MAX_RULE_TEXT_CHARS, READ_ROOT_CANDIDATE_DIR_MAX, parseRuleText, pathConfinableWriteToolNames } from "@sema-agent/core";
|
|
5
5
|
import { precheckCardRuleText } from "./rules-consent.js";
|
|
6
|
+
import { cardTakesWholeToolConsent } from "./permission-rule-vocab.js";
|
|
6
7
|
import { redactDeep, redactSecrets, redactSecretsWithArms } from "./trace/redact.js";
|
|
7
8
|
import { seatText } from "./trace/exit-seat.js";
|
|
8
9
|
import { hasBidiControls } from "./text-bidi.js";
|
|
@@ -18,10 +19,12 @@ import { APPROVAL_ENDING_CAUSES, SETTLE_OUTCOME, causeOfAskRow } from "./approva
|
|
|
18
19
|
import { settleByPolicy } from "./approval-policy-settlement.js";
|
|
19
20
|
import { governanceAskMarksFor, runWithGovernanceAskScope } from "./governance-ask-marks.js";
|
|
20
21
|
import { governanceOriginOf } from "./runtime-governance.js";
|
|
21
|
-
import {
|
|
22
|
+
import { grantBindingOf } from "./standing-answer-grant.js";
|
|
22
23
|
import { operatorAsk } from "./operator-ask.js";
|
|
23
24
|
import { APPROVAL_EXEMPTED_EVENT } from "./plugins/approval-exemption-store.js";
|
|
24
25
|
import { refusalBody } from "./http/refusal-body.js";
|
|
26
|
+
import { withoutSettlementEvidence } from "./gate-settlement.js";
|
|
27
|
+
import { extensionRequesterOf } from "./trace/extension-call-face.js";
|
|
25
28
|
const defaultLogger = createLogger();
|
|
26
29
|
const MAX_APPROVAL_ARGS_BYTES = 16384;
|
|
27
30
|
const DEFAULT_APPROVAL_TTL_MS = 5 * 60_000;
|
|
@@ -118,7 +121,7 @@ function askStandingAnswerFacts(req, governanceForced, deploymentListAsks) {
|
|
|
118
121
|
governanceForced,
|
|
119
122
|
requiresRealApproval: req.requiresRealApproval === true,
|
|
120
123
|
mandated: req.mandated === true,
|
|
121
|
-
grantBinding:
|
|
124
|
+
grantBinding: grantBindingOf(req),
|
|
122
125
|
classes,
|
|
123
126
|
deploymentListQuestion,
|
|
124
127
|
};
|
|
@@ -135,7 +138,7 @@ export function policyAskStandingAnswerFacts(req, ask, deploymentListQuestion) {
|
|
|
135
138
|
governanceForced: false,
|
|
136
139
|
requiresRealApproval: ask.requiresRealApproval === true,
|
|
137
140
|
mandated: ask.mandated === true,
|
|
138
|
-
grantBinding:
|
|
141
|
+
grantBinding: grantBindingOf(req),
|
|
139
142
|
classes: [...classifyAsk(ask, noGateFacts({ toolCallId: req.toolCallId, toolName: req.toolName })).classes],
|
|
140
143
|
deploymentListQuestion,
|
|
141
144
|
};
|
|
@@ -172,7 +175,7 @@ export function parkRowStandingAnswerFacts(stored, gate, governance, deploymentL
|
|
|
172
175
|
governanceForced: governanceOriginOf({ riskDescriptor }, governance) === true,
|
|
173
176
|
requiresRealApproval: readParkRowTrueSeat(pending, "requiresRealApproval"),
|
|
174
177
|
mandated: readParkRowTrueSeat(pending, "mandated") || mandatedFromSeat(readRuleOffersAbsenceSeat(pending)),
|
|
175
|
-
grantBinding:
|
|
178
|
+
grantBinding: grantBindingOf(pending),
|
|
176
179
|
classes,
|
|
177
180
|
deploymentListQuestion,
|
|
178
181
|
};
|
|
@@ -750,7 +753,7 @@ export class ToolApprovalCoordinator {
|
|
|
750
753
|
};
|
|
751
754
|
if (offer.kind === "single") {
|
|
752
755
|
const d = derive(offer.rule);
|
|
753
|
-
return d !== undefined && d.rule === offer.rule && d.
|
|
756
|
+
return d !== undefined && d.rule === offer.rule && d.match === offer.match && d.command === offer.command && ToolApprovalCoordinator.singleOfferToolAgrees(d.match, d.tool);
|
|
754
757
|
}
|
|
755
758
|
return offer.rules.every((m) => {
|
|
756
759
|
const d = derive(m.rule);
|
|
@@ -766,6 +769,29 @@ export class ToolApprovalCoordinator {
|
|
|
766
769
|
}
|
|
767
770
|
});
|
|
768
771
|
}
|
|
772
|
+
static singleOfferToolAgrees(match, tool) {
|
|
773
|
+
switch (match) {
|
|
774
|
+
case "exact":
|
|
775
|
+
case "prefix":
|
|
776
|
+
case "wildcard":
|
|
777
|
+
case "pattern":
|
|
778
|
+
return tool === "Bash";
|
|
779
|
+
case "tool":
|
|
780
|
+
return cardTakesWholeToolConsent(tool);
|
|
781
|
+
case "subpath":
|
|
782
|
+
case "path":
|
|
783
|
+
case "name":
|
|
784
|
+
case "name_prefix":
|
|
785
|
+
case "host":
|
|
786
|
+
case "subdomain":
|
|
787
|
+
return false;
|
|
788
|
+
default: {
|
|
789
|
+
const unknown = match;
|
|
790
|
+
void unknown;
|
|
791
|
+
return false;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
769
795
|
static boundRuleOfferTexts(offers) {
|
|
770
796
|
const over = (s) => s.length > MAX_RULE_TEXT_CHARS;
|
|
771
797
|
const clipSegment = (s) => (over(s) ? s.slice(0, MAX_RULE_TEXT_CHARS) : s);
|
|
@@ -812,6 +838,17 @@ export class ToolApprovalCoordinator {
|
|
|
812
838
|
}
|
|
813
839
|
return out;
|
|
814
840
|
}
|
|
841
|
+
static cardBindingOf(args, offers) {
|
|
842
|
+
const isWholeTool = (o) => o.kind === "single" && o.match === "tool";
|
|
843
|
+
if (offers.length > 0 && offers.every(isWholeTool))
|
|
844
|
+
return "";
|
|
845
|
+
if (offers.some(isWholeTool))
|
|
846
|
+
return undefined;
|
|
847
|
+
if (args === null || typeof args !== "object" || Array.isArray(args))
|
|
848
|
+
return undefined;
|
|
849
|
+
const command = args.command;
|
|
850
|
+
return typeof command === "string" && command !== "" ? command : undefined;
|
|
851
|
+
}
|
|
815
852
|
buildRuleLaneMaterial(req, owner, governanceForced, sessionId) {
|
|
816
853
|
if (this.ruleConsent === undefined)
|
|
817
854
|
return undefined;
|
|
@@ -826,11 +863,8 @@ export class ToolApprovalCoordinator {
|
|
|
826
863
|
const offers = ToolApprovalCoordinator.boundRuleOfferTexts(capped);
|
|
827
864
|
if (offers === undefined)
|
|
828
865
|
return undefined;
|
|
829
|
-
const
|
|
830
|
-
if (
|
|
831
|
-
return undefined;
|
|
832
|
-
const command = args.command;
|
|
833
|
-
if (typeof command !== "string" || command === "")
|
|
866
|
+
const command = ToolApprovalCoordinator.cardBindingOf(req.args, offers);
|
|
867
|
+
if (command === undefined)
|
|
834
868
|
return undefined;
|
|
835
869
|
const boundInputHash = readBoundInputHash(req);
|
|
836
870
|
const scopeRoot = this.ruleScopeRootFor?.(sessionId);
|
|
@@ -981,7 +1015,7 @@ export class ToolApprovalCoordinator {
|
|
|
981
1015
|
}
|
|
982
1016
|
boundUnattendedAsk = (identity, why) => {
|
|
983
1017
|
return async (req) => {
|
|
984
|
-
const origin = { owner: identity.owner, taskId: identity.taskId, ...(identity.sessionId !== undefined ? { sessionId: identity.sessionId } : {}), legKey: "" };
|
|
1018
|
+
const origin = { owner: identity.owner, taskId: identity.taskId, ...(identity.sessionId !== undefined ? { sessionId: identity.sessionId } : {}), legKey: "", executionLane: identity.executionLane };
|
|
985
1019
|
if (await this.standingGrantSettles(origin, req, this.governanceForcedOf(origin, req)))
|
|
986
1020
|
return true;
|
|
987
1021
|
return this.unattendedAskOutcome({ ...why, taskId: identity.taskId, owner: identity.owner, toolName: req.toolName });
|
|
@@ -1233,6 +1267,7 @@ export class ToolApprovalCoordinator {
|
|
|
1233
1267
|
owner: ctx.owner,
|
|
1234
1268
|
...(ctx.sessionId !== undefined ? { sessionId: ctx.sessionId } : {}),
|
|
1235
1269
|
legKey: ctx.legKey ?? "",
|
|
1270
|
+
executionLane: ctx.executionLane,
|
|
1236
1271
|
...(ctx.legDeadlineMonotonic !== undefined ? { legDeadlineMonotonic: ctx.legDeadlineMonotonic } : {}),
|
|
1237
1272
|
}, [ctx], req, signal);
|
|
1238
1273
|
};
|
|
@@ -1245,6 +1280,7 @@ export class ToolApprovalCoordinator {
|
|
|
1245
1280
|
owner: identity.owner,
|
|
1246
1281
|
...(identity.sessionId !== undefined ? { sessionId: identity.sessionId } : {}),
|
|
1247
1282
|
legKey: identity.legKey ?? "",
|
|
1283
|
+
executionLane: identity.executionLane,
|
|
1248
1284
|
...(identity.legDeadlineMonotonic !== undefined ? { legDeadlineMonotonic: identity.legDeadlineMonotonic } : {}),
|
|
1249
1285
|
}, live, req, signal);
|
|
1250
1286
|
};
|
|
@@ -1295,6 +1331,7 @@ export class ToolApprovalCoordinator {
|
|
|
1295
1331
|
const cardWord = readApprovalCard(req.approvalCard);
|
|
1296
1332
|
const originWord = typeof req.origin === "string" && req.origin.length > 0 ? req.origin : undefined;
|
|
1297
1333
|
const askClassPair = readAskClassPair(req);
|
|
1334
|
+
const requester = extensionRequesterOf(req.requestedBy, "tool_approval");
|
|
1298
1335
|
const frame = {
|
|
1299
1336
|
type: "tool_approval",
|
|
1300
1337
|
approvalId: id,
|
|
@@ -1328,6 +1365,7 @@ export class ToolApprovalCoordinator {
|
|
|
1328
1365
|
...(mandateWord !== undefined ? { mandate: mandateWord } : {}),
|
|
1329
1366
|
...(originWord !== undefined ? { origin: originWord } : {}),
|
|
1330
1367
|
...(askClassPair ?? {}),
|
|
1368
|
+
...(requester !== undefined ? { requestedBy: requester } : {}),
|
|
1331
1369
|
...((d) => (d !== undefined ? { allowRuleShadowed: d } : {}))(readAllowRuleShadowed(req)),
|
|
1332
1370
|
...(ruleLaneMaterial !== undefined ? { ruleOffers: ruleLaneMaterial.offers } : {}),
|
|
1333
1371
|
...((a) => (a !== undefined ? { ruleOffersAbsence: a } : {}))(readRuleOffersAbsence(req)),
|
|
@@ -1347,6 +1385,7 @@ export class ToolApprovalCoordinator {
|
|
|
1347
1385
|
const card = this.askStore ? buildApprovalCard(frame, req, req.requiresRealApproval === true) : undefined;
|
|
1348
1386
|
let cardForFrame = card;
|
|
1349
1387
|
let persistedExpiresAtMs = expiresAtMs;
|
|
1388
|
+
let entryExecutionLane = origin.executionLane;
|
|
1350
1389
|
let lateEnsuredRow;
|
|
1351
1390
|
let lateTerminalRow;
|
|
1352
1391
|
let abandonedAs;
|
|
@@ -1386,6 +1425,7 @@ export class ToolApprovalCoordinator {
|
|
|
1386
1425
|
sourceTaskId,
|
|
1387
1426
|
sessionId: origin.sessionId ?? origin.taskId,
|
|
1388
1427
|
owner: origin.owner,
|
|
1428
|
+
executionLane: origin.executionLane,
|
|
1389
1429
|
batchId,
|
|
1390
1430
|
toolCallId: req.toolCallId,
|
|
1391
1431
|
legKey,
|
|
@@ -1422,6 +1462,7 @@ export class ToolApprovalCoordinator {
|
|
|
1422
1462
|
return existingOrCreated.inserted ? this.landUnattendedOutcome(unattended, existingOrCreated.row) : unattended;
|
|
1423
1463
|
}
|
|
1424
1464
|
persistedExpiresAtMs = existingOrCreated.row.expiresAtMs;
|
|
1465
|
+
entryExecutionLane = existingOrCreated.row.executionLane;
|
|
1425
1466
|
cardForFrame = persistedEnvelope.card;
|
|
1426
1467
|
if (cardForFrame.governanceForced === true)
|
|
1427
1468
|
frame.governanceForced = true;
|
|
@@ -1861,7 +1902,7 @@ export class ToolApprovalCoordinator {
|
|
|
1861
1902
|
}
|
|
1862
1903
|
const entryClasses = askClassPair?.classes;
|
|
1863
1904
|
const entryDeploymentListQuestion = carriesDeploymentListQuestion(deploymentListAsks, entryClasses);
|
|
1864
|
-
const entryGrantBinding =
|
|
1905
|
+
const entryGrantBinding = grantBindingOf(req);
|
|
1865
1906
|
const rememberRefused = standingAnswerHome(pendingEntryStandingAnswerFacts({
|
|
1866
1907
|
...(effectiveGovernanceForced ? { governanceForced: true } : {}),
|
|
1867
1908
|
...(req.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
@@ -1900,6 +1941,7 @@ export class ToolApprovalCoordinator {
|
|
|
1900
1941
|
...(entryDeploymentListQuestion ? { deploymentListQuestion: true } : {}),
|
|
1901
1942
|
registeredAtMs: Date.now(),
|
|
1902
1943
|
expiresAtMs: persistedExpiresAtMs,
|
|
1944
|
+
executionLane: entryExecutionLane,
|
|
1903
1945
|
...(ruleLaneMaterial !== undefined ? { ruleLane: ruleLaneMaterial } : {}),
|
|
1904
1946
|
...(effectiveGovernanceForced ? { governanceForced: true } : {}),
|
|
1905
1947
|
...(req.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
@@ -2586,10 +2628,11 @@ export class ToolApprovalCoordinator {
|
|
|
2586
2628
|
if (fresh?.terminal === true && memo.redeemed !== undefined)
|
|
2587
2629
|
memo.redeemed.rule = fresh.body;
|
|
2588
2630
|
}
|
|
2631
|
+
const sameDecision = (parsed.value === "deny") === (receipt.decision === "deny");
|
|
2589
2632
|
return {
|
|
2590
2633
|
status: 200,
|
|
2591
2634
|
body: {
|
|
2592
|
-
...receipt.body,
|
|
2635
|
+
...(sameDecision ? receipt.body : withoutSettlementEvidence(receipt.body)),
|
|
2593
2636
|
approvalId: id,
|
|
2594
2637
|
askId: row.askId,
|
|
2595
2638
|
accepted: "parked_redeemed",
|
|
@@ -2862,6 +2905,7 @@ export class ToolApprovalCoordinator {
|
|
|
2862
2905
|
forceParkNow: release,
|
|
2863
2906
|
settleParkRoute: (cause) => leave({ outcome: SETTLE_OUTCOME.EXPIRED, cause, parked: this.unattendedRoutesToPark }),
|
|
2864
2907
|
owner: row.owner,
|
|
2908
|
+
executionLane: row.executionLane,
|
|
2865
2909
|
...(row.sessionId !== row.taskId ? { sessionId: row.sessionId } : {}),
|
|
2866
2910
|
...(card.fromSubagent === true ? { originTaskId: row.sourceTaskId } : {}),
|
|
2867
2911
|
toolName: card.toolName,
|
|
@@ -44,8 +44,8 @@ type _GuardBgNotifReverse = AssertAllKeysHandled<Exclude<BgNotifProjected | BgNo
|
|
|
44
44
|
type RosterProjected = "name" | "agentId" | "sessionId" | "toolUseId" | "owner" | "scope" | "sessionScoped" | "rootSessionId" | "model" | "modelFallback" | "createdAt";
|
|
45
45
|
type _GuardRoster = AssertAllKeysHandled<Exclude<keyof RosterEntry, RosterProjected>>;
|
|
46
46
|
type _GuardRosterReverse = AssertAllKeysHandled<Exclude<RosterProjected, keyof RosterEntry>>;
|
|
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" | "
|
|
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" | "requestedBy";
|
|
48
|
+
type AskExcluded = "preview" | "principal" | "riskAxes" | "boundInputHash" | "isDelegatedChild" | "hasBidiControls" | "previewWithheld" | "execCwd" | "authoredBy" | "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";
|
|
@@ -54,10 +54,10 @@ type _GuardAskFrameReverse = AssertAllKeysHandled<Exclude<AskProjected | AskFram
|
|
|
54
54
|
type TaskEventHandled = "text_delta" | "reasoning_delta" | "tool_start" | "tool_end" | "turn_end" | "compacted" | "diagnostics" | "message_committed" | "status" | "task_notification" | "task_progress" | "steering_injected" | "workspace_changed" | "done" | "context_usage" | "compaction_outcome" | "human_input" | "wiring_manifest" | "text_end" | "tool_roster_delta" | "tool_progress" | "tool_disclosure" | "task_started" | "compaction_started";
|
|
55
55
|
type _GuardTaskEvent = AssertAllKeysHandled<Exclude<TaskEvent["type"], TaskEventHandled>>;
|
|
56
56
|
type _GuardTaskEventReverse = AssertAllKeysHandled<Exclude<TaskEventHandled, TaskEvent["type"]>>;
|
|
57
|
-
type MailboxProjected = "seq" | "from" | "content" | "sentAt" | "hopChain" | "peerMeta";
|
|
57
|
+
type MailboxProjected = "seq" | "from" | "content" | "sentAt" | "hopChain" | "peerMeta" | "decision" | "id";
|
|
58
58
|
type _GuardMailbox = AssertAllKeysHandled<Exclude<keyof MailboxMessage, MailboxProjected>>;
|
|
59
59
|
type _GuardMailboxReverse = AssertAllKeysHandled<Exclude<MailboxProjected, keyof MailboxMessage>>;
|
|
60
|
-
type MailboxAppendProjected = "from" | "content" | "sentAt" | "hopChain" | "peerMeta";
|
|
60
|
+
type MailboxAppendProjected = "from" | "content" | "sentAt" | "hopChain" | "peerMeta" | "id";
|
|
61
61
|
type _GuardMailboxAppend = AssertAllKeysHandled<Exclude<keyof MailboxAppendMessage, MailboxAppendProjected>>;
|
|
62
62
|
type _GuardMailboxAppendReverse = AssertAllKeysHandled<Exclude<MailboxAppendProjected, keyof MailboxAppendMessage>>;
|
|
63
63
|
type WiringSectionProjected = "schemaVersion" | "leg" | "ask" | "question" | "interaction" | "elicit" | "parkLane" | "session" | "fleet" | "permissionRules" | "modelGate" | "autoMode" | "mcp" | "tools" | "mods" | "lsp" | "hands" | "writeProtection" | "teamRole" | "fileHistory" | "permissionMode" | "sessionRules" | "projectMemory";
|
|
@@ -66,10 +66,11 @@ type _GuardWiringSections = AssertAllKeysHandled<Exclude<keyof WiringManifest, W
|
|
|
66
66
|
type _GuardWiringSectionsReverse = AssertAllKeysHandled<Exclude<WiringSectionProjected | WiringSectionExcluded, keyof WiringManifest>>;
|
|
67
67
|
type WiringSection<K extends keyof WiringManifest> = NonNullable<WiringManifest[K]>;
|
|
68
68
|
type WiringLegHandled = "kind";
|
|
69
|
-
type
|
|
70
|
-
type
|
|
69
|
+
type WiringLegExcluded = "runOrigin";
|
|
70
|
+
type _GuardWiringLeg = AssertAllKeysHandled<Exclude<keyof WiringSection<"leg">, WiringLegHandled | WiringLegExcluded>>;
|
|
71
|
+
type _GuardWiringLegReverse = AssertAllKeysHandled<Exclude<WiringLegHandled | WiringLegExcluded, keyof WiringSection<"leg">>>;
|
|
71
72
|
type WiringModRowKeys = WiringSection<"mods">[number] extends infer R ? (R extends unknown ? keyof R : never) : never;
|
|
72
|
-
type WiringModRowHandled = "name" | "seat" | "tier" | "events" | "observe" | "skipped" | "refusedBy" | "reason";
|
|
73
|
+
type WiringModRowHandled = "name" | "seat" | "tier" | "provenance" | "events" | "observe" | "skipped" | "refusedBy" | "reason";
|
|
73
74
|
type _GuardWiringModRow = AssertAllKeysHandled<Exclude<WiringModRowKeys, WiringModRowHandled>>;
|
|
74
75
|
type _GuardWiringModRowReverse = AssertAllKeysHandled<Exclude<WiringModRowHandled, WiringModRowKeys>>;
|
|
75
76
|
type WiringModSkipKeys = keyof NonNullable<Extract<WiringSection<"mods">[number], {
|
|
@@ -108,7 +109,11 @@ type _GuardSubagentTranscriptTierWords = AssertAllKeysHandled<Exclude<SubagentTr
|
|
|
108
109
|
type _GuardSubagentTranscriptTierWordsReverse = AssertAllKeysHandled<Exclude<SubagentTranscriptTierWords, SubagentTranscriptTier>>;
|
|
109
110
|
type WiringMcpEntry = WiringSection<"mcp">[number];
|
|
110
111
|
type WiringMcpExcluded = "error";
|
|
111
|
-
type WiringMcpHandled = "name" | "source" | "status" | "errorCode" | "delivered" | "httpStatus" | "toolCount" | "liveness" | WiringMcpExcluded;
|
|
112
|
+
type WiringMcpHandled = "name" | "source" | "status" | "errorCode" | "delivered" | "httpStatus" | "toolCount" | "liveness" | "authorization" | WiringMcpExcluded;
|
|
113
|
+
type McpAuthorizationRecord = NonNullable<WiringMcpEntry["authorization"]>;
|
|
114
|
+
type McpAuthorizationTables = typeof import("../mcp-authorization-face.js");
|
|
115
|
+
type _GuardMcpAuthorization = AssertAllKeysHandled<Exclude<keyof McpAuthorizationRecord, TableCoreKeys<McpAuthorizationTables["MCP_AUTHORIZATION_DISPOSITIONS"]>>>;
|
|
116
|
+
type _GuardMcpAuthorizationReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<McpAuthorizationTables["MCP_AUTHORIZATION_DISPOSITIONS"]>, keyof McpAuthorizationRecord>>;
|
|
112
117
|
type _GuardWiringMcp = AssertAllKeysHandled<Exclude<keyof WiringMcpEntry, WiringMcpHandled>>;
|
|
113
118
|
type _GuardWiringMcpReverse = AssertAllKeysHandled<Exclude<WiringMcpHandled, keyof WiringMcpEntry>>;
|
|
114
119
|
type WiringMcpLiveness = NonNullable<WiringMcpEntry["liveness"]>;
|
|
@@ -212,27 +217,27 @@ type _GuardPromptManifestKeysNonEmpty = AssertAllKeysHandled<{
|
|
|
212
217
|
[L in keyof ManifestCore]: [ManifestDeclared<ManifestFaces, L>] extends [never] ? L : never;
|
|
213
218
|
}[keyof ManifestCore]>;
|
|
214
219
|
type SummaryProjected = "sessionId" | "scope" | "createdAt" | "gateKind" | "severity" | "spentMicroUsd" | "deadline" | "hasBidiControls" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "mandated" | "mandate" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "boundGrantAbsence" | "checkpointId";
|
|
215
|
-
type SummaryExcluded = "token" | "toolInput" | "toolName" | "toolCallId" | "preview" | "principal" | "sourceTaskId" | "approvalCard" | "restoreMode" | "previewWithheld" | "authoredBy";
|
|
220
|
+
type SummaryExcluded = "token" | "toolInput" | "toolName" | "toolCallId" | "preview" | "principal" | "sourceTaskId" | "approvalCard" | "restoreMode" | "previewWithheld" | "authoredBy" | "runOrigin" | "requestedByCallId";
|
|
216
221
|
type _GuardInboxSummary = AssertAllKeysHandled<Exclude<keyof CheckpointSummary, SummaryProjected | SummaryExcluded>>;
|
|
217
222
|
type _GuardInboxSummaryReverse = AssertAllKeysHandled<Exclude<SummaryProjected | SummaryExcluded, keyof CheckpointSummary>>;
|
|
218
223
|
type ParkArmKeys = keyof Extract<PendingAction, {
|
|
219
224
|
kind: "tool_approval";
|
|
220
225
|
}>;
|
|
221
226
|
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";
|
|
227
|
+
type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "hostTarget" | "targets" | "targetReads" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "engineMounted" | "declarationDigest";
|
|
223
228
|
type _GuardParkArmQueue = AssertAllKeysHandled<Exclude<ParkArmKeys, ParkArmQueueProjected | ParkArmQueueExcluded>>;
|
|
224
229
|
type _GuardParkArmQueueReverse = AssertAllKeysHandled<Exclude<ParkArmQueueProjected | ParkArmQueueExcluded, ParkArmKeys>>;
|
|
225
230
|
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" | "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";
|
|
231
|
+
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" | "projectId";
|
|
227
232
|
/** 导出:请求体键闭集门(`request-key-closure.ts`)据它锁「本仓记为未接线的引擎座,提交口不许受理」—— 两处分类只能同向。 */
|
|
228
|
-
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel";
|
|
233
|
+
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel" | "runOrigin" | "planFile" | "classifyAllShell";
|
|
229
234
|
type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
|
|
230
235
|
type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
|
|
231
236
|
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
237
|
type TaskResultStripped = never;
|
|
233
238
|
type _GuardTaskResult = AssertAllKeysHandled<Exclude<keyof TaskResult, TaskResultForwarded | TaskResultStripped>>;
|
|
234
239
|
type _GuardTaskResultReverse = AssertAllKeysHandled<Exclude<TaskResultForwarded | TaskResultStripped, keyof TaskResult>>;
|
|
235
|
-
type PausedCauseForwarded = "kind" | "gate" | "checkpointId" | "restoreMode";
|
|
240
|
+
type PausedCauseForwarded = "kind" | "gate" | "checkpointId" | "restoreMode" | "requestedByCallId";
|
|
236
241
|
type PausedCauseStripped = "token";
|
|
237
242
|
type _GuardPausedCause = AssertAllKeysHandled<Exclude<keyof PausedCause, PausedCauseForwarded | PausedCauseStripped>>;
|
|
238
243
|
type _GuardPausedCauseReverse = AssertAllKeysHandled<Exclude<PausedCauseForwarded | PausedCauseStripped, keyof PausedCause>>;
|
|
@@ -247,7 +252,7 @@ type SessionMemoryStatusProjected = "captureOptedOut" | "committedCount" | "fold
|
|
|
247
252
|
type SessionMemoryStatusExcluded = "writeHome";
|
|
248
253
|
type _GuardSessionMemoryStatus = AssertAllKeysHandled<Exclude<keyof SessionMemoryStatus, SessionMemoryStatusProjected | SessionMemoryStatusExcluded>>;
|
|
249
254
|
type _GuardSessionMemoryStatusReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusProjected | SessionMemoryStatusExcluded, keyof SessionMemoryStatus>>;
|
|
250
|
-
type SideQueryResultForwarded = "text" | "toolCalls" | "model" | "servedModel" | "degraded" | "responseModel" | "usage" | "usageMissing" | "stopReason" | "errorMessage" | "errorCode" | "errorKind" | "inputTooLongRuledOut";
|
|
255
|
+
type SideQueryResultForwarded = "text" | "toolCalls" | "model" | "servedModel" | "degraded" | "responseModel" | "usage" | "usageMissing" | "stopReason" | "errorMessage" | "errorCode" | "errorKind" | "inputTooLongRuledOut" | "account";
|
|
251
256
|
type SideQueryResultStripped = never;
|
|
252
257
|
type _GuardSideQueryResult = AssertAllKeysHandled<Exclude<keyof SideQueryResult, SideQueryResultForwarded | SideQueryResultStripped>>;
|
|
253
258
|
type _GuardSideQueryResultReverse = AssertAllKeysHandled<Exclude<SideQueryResultForwarded | SideQueryResultStripped, keyof SideQueryResult>>;
|
|
@@ -261,7 +266,7 @@ type GateOutcomeProjected = "disposition" | "settlement" | "origin";
|
|
|
261
266
|
type _GuardGateOutcome = AssertAllKeysHandled<Exclude<keyof GateOutcome, GateOutcomeProjected>>;
|
|
262
267
|
type _GuardGateOutcomeReverse = AssertAllKeysHandled<Exclude<GateOutcomeProjected, keyof GateOutcome>>;
|
|
263
268
|
type GateDispositionKeys = GateDisposition extends infer D ? (D extends object ? keyof D : never) : never;
|
|
264
|
-
type GateDispositionProjected = "kind" | "deniedBy" | "cause" | "classifier" | "released" | "clearedBy" | "mode" | "askClass" | "classes";
|
|
269
|
+
type GateDispositionProjected = "kind" | "deniedBy" | "cause" | "classifier" | "released" | "clearedBy" | "mode" | "askClass" | "classes" | "extension";
|
|
265
270
|
type _GuardGateDisposition = AssertAllKeysHandled<Exclude<GateDispositionKeys, GateDispositionProjected>>;
|
|
266
271
|
type _GuardGateDispositionReverse = AssertAllKeysHandled<Exclude<GateDispositionProjected, GateDispositionKeys>>;
|
|
267
272
|
type SettlementProjected = "kind" | "who" | "when" | "note";
|
|
@@ -301,12 +306,12 @@ type McpReconnectWithheld = "axes" | "dropped" | "warnings";
|
|
|
301
306
|
type _GuardMcpReconnect = AssertAllKeysHandled<Exclude<keyof McpReconnectResult, McpReconnectProjected | McpReconnectWithheld>>;
|
|
302
307
|
type _NoDoubleBookMcpReconnect = AssertAllKeysHandled<Extract<McpReconnectProjected, McpReconnectWithheld>>;
|
|
303
308
|
type _GuardMcpReconnectReverse = AssertAllKeysHandled<Exclude<McpReconnectProjected | McpReconnectWithheld, keyof McpReconnectResult>>;
|
|
304
|
-
type McpRedialStatusProjected = "name" | "status" | "errorCode" | "httpStatus" | "delivered" | "serverInfo" | "error" | "transportClosed";
|
|
309
|
+
type McpRedialStatusProjected = "name" | "status" | "errorCode" | "httpStatus" | "delivered" | "authorization" | "serverInfo" | "error" | "transportClosed";
|
|
305
310
|
type McpRedialStatusWithheld = "toolNames" | "liveness";
|
|
306
311
|
type _GuardMcpRedialStatus = AssertAllKeysHandled<Exclude<keyof McpServerStatus, McpRedialStatusProjected | McpRedialStatusWithheld>>;
|
|
307
312
|
type _NoDoubleBookMcpRedialStatus = AssertAllKeysHandled<Extract<McpRedialStatusProjected, McpRedialStatusWithheld>>;
|
|
308
313
|
type _GuardMcpRedialStatusReverse = AssertAllKeysHandled<Exclude<McpRedialStatusProjected | McpRedialStatusWithheld, keyof McpServerStatus>>;
|
|
309
|
-
type McpPanelStatusProjected = "name" | "status" | "serverInfo" | "toolNames" | "error";
|
|
314
|
+
type McpPanelStatusProjected = "name" | "status" | "serverInfo" | "toolNames" | "error" | "authorization";
|
|
310
315
|
type McpPanelStatusWithheld = "errorCode" | "httpStatus" | "delivered" | "transportClosed" | "liveness";
|
|
311
316
|
type _GuardMcpPanelStatus = AssertAllKeysHandled<Exclude<keyof McpServerStatus, McpPanelStatusProjected | McpPanelStatusWithheld>>;
|
|
312
317
|
type _NoDoubleBookMcpPanelStatus = AssertAllKeysHandled<Extract<McpPanelStatusProjected, McpPanelStatusWithheld>>;
|
|
@@ -323,6 +328,12 @@ type _NoDoubleBookLspOptions = AssertAllKeysHandled<Extract<LspOptionsWired, Lsp
|
|
|
323
328
|
/** ⑯ 账上记过、已接线的 `RunnerDeps` 席([ref] 起 `fileHistoryCapture`)。反向钉:core 改名 / 退役 ⇒ 红。 */
|
|
324
329
|
type RunnerDepsLedgerWired = "fileHistoryCapture";
|
|
325
330
|
type _GuardLedgerRunnerDepsReverse = AssertAllKeysHandled<Exclude<RunnerDepsLedgerWired, keyof RunnerDeps>>;
|
|
331
|
+
type SessionWorkspaceTables = typeof import("../session-workspace.js");
|
|
332
|
+
type WorkspaceChangedArm = Extract<TaskEvent, {
|
|
333
|
+
type: "workspace_changed";
|
|
334
|
+
}>;
|
|
335
|
+
type _GuardSessionWorkspace = AssertAllKeysHandled<Exclude<keyof WorkspaceChangedArm, TableCoreKeys<SessionWorkspaceTables["SESSION_WORKSPACE_DISPOSITIONS"]>>>;
|
|
336
|
+
type _GuardSessionWorkspaceReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<SessionWorkspaceTables["SESSION_WORKSPACE_DISPOSITIONS"]>, keyof WorkspaceChangedArm>>;
|
|
326
337
|
export type CoreKeysetGuards = [
|
|
327
338
|
_GuardNotification,
|
|
328
339
|
_GuardTerminalArm,
|
|
@@ -384,6 +395,8 @@ export type CoreKeysetGuards = [
|
|
|
384
395
|
_GuardWiringModSkipReverse,
|
|
385
396
|
_GuardWiringMcp,
|
|
386
397
|
_GuardWiringMcpReverse,
|
|
398
|
+
_GuardMcpAuthorization,
|
|
399
|
+
_GuardMcpAuthorizationReverse,
|
|
387
400
|
_GuardWiringRules,
|
|
388
401
|
_GuardWiringRulesReverse,
|
|
389
402
|
_GuardWiringModelGate,
|
|
@@ -463,7 +476,9 @@ export type CoreKeysetGuards = [
|
|
|
463
476
|
_GuardLspOptions,
|
|
464
477
|
_NoDoubleBookLspOptions,
|
|
465
478
|
_GuardLspOptionsReverse,
|
|
466
|
-
_GuardLedgerRunnerDepsReverse
|
|
479
|
+
_GuardLedgerRunnerDepsReverse,
|
|
480
|
+
_GuardSessionWorkspace,
|
|
481
|
+
_GuardSessionWorkspaceReverse
|
|
467
482
|
];
|
|
468
483
|
export {};
|
|
469
484
|
//# sourceMappingURL=core-keyset-guard.d.ts.map
|
|
@@ -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", "inherit_env.names_withheld", "model.capability_downgraded"];
|
|
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", "context.image_removed", "mcp.authorization_required"];
|
|
20
20
|
export type EngineNoticeWireCode = (typeof ENGINE_NOTICE_WIRE_CODES)[number];
|
|
21
21
|
/** 白名单谓词(单点):路由与门都读这一个,不许第二处手抄码串。 */
|
|
22
22
|
export declare function isEngineNoticeWireCode(code: string): code is EngineNoticeWireCode;
|
|
@@ -46,6 +46,8 @@ export const ENGINE_NOTICE_WIRE_CODES = [
|
|
|
46
46
|
"advisor.not_attached",
|
|
47
47
|
"inherit_env.names_withheld",
|
|
48
48
|
"model.capability_downgraded",
|
|
49
|
+
"context.image_removed",
|
|
50
|
+
"mcp.authorization_required",
|
|
49
51
|
];
|
|
50
52
|
const WIRE_CODES = new Set(ENGINE_NOTICE_WIRE_CODES);
|
|
51
53
|
export function isEngineNoticeWireCode(code) {
|
|
@@ -13,7 +13,14 @@ export type SafeText = string & {
|
|
|
13
13
|
* · `operator-log-arg`:运维日志字段里模型写的工具入参(`tool_trace` 的 `arg.*`:路径 / 命令 / 模式 / 非对象入参的串形);界 120 码元(含截断记号);
|
|
14
14
|
* · `operator-log-error`:运维日志字段里 hook 一侧的报错 —— hook 命令的 stderr、prompt 条目的载体失败句、起子进程 / 读会话分支抛出的句子;界 300 码元(含截断记号);
|
|
15
15
|
* · `operator-log-message`:运维日志字段里写给人看的一段话 —— hook 输出的 `systemMessage`、Stop 评估者判「做不到」的理由;界 500 码元(含截断记号);
|
|
16
|
-
* · `session-title`:自动标题器落行的会话标题(落库 / 列表面 / `session_titled` 帧同一份);界 80 码元(含截断记号),在 `title`
|
|
16
|
+
* · `session-title`:自动标题器落行的会话标题(落库 / 列表面 / `session_titled` 帧同一份);界 80 码元(含截断记号),在 `title` 列宽之内;
|
|
17
|
+
* · `mcp-remote-text`:MCP 远端失败句(远端可控自由文本,租户面)—— `GET /v1/sessions/:id/mcp` 面板的 `servers[].error` 与 `POST /v1/sessions/:id/mcp/reconnect`
|
|
18
|
+
* 的 `reason` / `status.error` / `listingIncomplete.error`;引擎铸点已抹过请求回显与同主体词表(记号 `[redacted]`),这一行读同一个脱敏器(引擎记号 = 已抹的值,
|
|
19
|
+
* 引擎放过的形照抹);界 200 码元,原样出门(JSON 串值,消费方自己渲染)。
|
|
20
|
+
* · `peer-declaration-sentence`:引擎判官对一份 MCP / A2A 对端声明说的句子(`toolAxes` / `toolFaces` / `sessionMetaKey` / 启动界的原因句,逐字带着声明方写的工具名、键名),
|
|
21
|
+
* 进请求面 400 拒句、续跑重放的丢弃行与重读行、名册的跳过行 —— 读者是调用方与运维,句子已是一行;不设界(拒句要说全判官的话),原样出门。
|
|
22
|
+
* · `boot-refusal-line`:起服拒启的一行拒句 —— 部署座装配的拒句(`mods-declaration.ts`:声明的席名、包名、读包者 / 引擎准入交回的话);它经进程级 fatal 出口原样多行进 stderr,
|
|
23
|
+
* 所以必须在这里先压成一行(一句拒因里的换行会在运维的终端里伪造出第二条日志行);界 512 码元(含截断记号)。
|
|
17
24
|
*/
|
|
18
25
|
declare const EXIT_SEATS: {
|
|
19
26
|
readonly "trace-frame-text": {
|
|
@@ -48,6 +55,18 @@ declare const EXIT_SEATS: {
|
|
|
48
55
|
readonly maxChars: 80;
|
|
49
56
|
readonly emit: "title-line";
|
|
50
57
|
};
|
|
58
|
+
readonly "mcp-remote-text": {
|
|
59
|
+
readonly scope: "free-text";
|
|
60
|
+
readonly maxChars: 200;
|
|
61
|
+
};
|
|
62
|
+
readonly "peer-declaration-sentence": {
|
|
63
|
+
readonly scope: "free-text";
|
|
64
|
+
};
|
|
65
|
+
readonly "boot-refusal-line": {
|
|
66
|
+
readonly scope: "free-text";
|
|
67
|
+
readonly maxChars: 512;
|
|
68
|
+
readonly emit: "log-line";
|
|
69
|
+
};
|
|
51
70
|
};
|
|
52
71
|
export type ExitSeat = keyof typeof EXIT_SEATS;
|
|
53
72
|
/** 设了界的座名。 */
|
package/dist/trace/exit-seat.js
CHANGED
|
@@ -12,6 +12,9 @@ const EXIT_SEATS = {
|
|
|
12
12
|
"operator-log-error": { scope: "free-text", maxChars: 300, emit: "log-line" },
|
|
13
13
|
"operator-log-message": { scope: "free-text", maxChars: 500, emit: "log-line" },
|
|
14
14
|
"session-title": { scope: "free-text", maxChars: 80, emit: "title-line" },
|
|
15
|
+
"mcp-remote-text": { scope: "free-text", maxChars: 200 },
|
|
16
|
+
"peer-declaration-sentence": { scope: "free-text" },
|
|
17
|
+
"boot-refusal-line": { scope: "free-text", maxChars: 512, emit: "log-line" },
|
|
15
18
|
};
|
|
16
19
|
export function seatMaxChars(seat) {
|
|
17
20
|
return EXIT_SEATS[seat].maxChars;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 扩展自己发起 / 代答 / 改写的工具调用在 wire 上的三位 —— `requestedBy`(谁要的这只调用)、`answeredBy`(哪张注册在 `tool.call` 上代替工具体作答)与
|
|
3
|
+
* `tool_end.rewrite`(门放行时交给工具体的参数不是它收进来的那份:放行的那份 + 谁改的)的**唯一读法**。
|
|
4
|
+
*
|
|
5
|
+
* 引擎的事实(core `ExtensionRequester` / `tool_end.answeredBy`):一张注册经 `$.tool.call` 发起的调用,`tool_start` / `tool_end` 与审批卡都带
|
|
6
|
+
* `requestedBy: { kind: "extension", name }`(模型消息带来的调用上缺席);注册在 `tool.call` 站上以自己的结果或拒答代替工具体时,`tool_end` 带
|
|
7
|
+
* `answeredBy: <注册名>`(旁边恒有 `notExecuted: true`)。本仓的部署座装上运维声明的包之后,这两位真能到达 —— 投影它们。
|
|
8
|
+
*
|
|
9
|
+
* 读法(写腿与读腿、帧与卡同一只):
|
|
10
|
+
* · 注册名是**注册方定的串** ⇒ 过 {@link sanitizeWireText}(与 `wiring_manifest.mods[]` 的 `name`、通告 `mods.registration_refused` 同一只出口纪律),
|
|
11
|
+
* 同一张注册在三处的名逐字节相等;
|
|
12
|
+
* · 形不对(`kind` 不是 `"extension"`、`name` 不是非空串、`answeredBy` 不是非空串)⇒ 丢这一位、计一次 `server.trace.projection-input-malformed`
|
|
13
|
+
* (纯归因位:半张归因比没有更坏,不修补);缺席 = 没有这件事(正面事实),不计;
|
|
14
|
+
* · `rewrite`(引擎 7.58.0 `ToolInputRewrite`)整只一位:`by` 每项是改写者(扩展项的注册名同上过出口纪律;`policy` / `approver` 两项无成员),`input` 是工具参数
|
|
15
|
+
* (模型 / 扩展 / 审批人写的)⇒ 经调用方交进来的工具参数投影 —— 与 `tool_start.args` 同一只(`trace/project.ts` 的那一只;本文件不自己答脱敏);
|
|
16
|
+
* `by` 不是非空数组、有一项不在三形里、缺 `input` ⇒ 整只丢 + 计一次。
|
|
17
|
+
* 续跑腿的帧引擎不带它(引擎的未覆盖面),本读法不补。
|
|
18
|
+
*/
|
|
19
|
+
import type { ExtensionRequester, RewriteAuthor } from "@sema-agent/core";
|
|
20
|
+
/** wire 上的发起者位 = 引擎的 `ExtensionRequester` 同形(`name` 已过出口纪律);引擎加一类发起者 ⇒ 这里的形随之,读法下面一处判。 */
|
|
21
|
+
export type ExtensionRequesterFace = Readonly<ExtensionRequester>;
|
|
22
|
+
/** `requestedBy` 的投影(缺席 ⇒ 缺席;形不对 ⇒ 丢 + 计一次)。`where` 进留痕句(哪一面:`tool_start` / `tool_end` / `tool_approval` / 读腿)。 */
|
|
23
|
+
export declare function extensionRequesterOf(v: unknown, where: string): ExtensionRequesterFace | undefined;
|
|
24
|
+
/** `answeredBy` 的投影(缺席 ⇒ 缺席;形不对 ⇒ 丢 + 计一次)。 */
|
|
25
|
+
export declare function extensionAnswererOf(v: unknown, where: string): string | undefined;
|
|
26
|
+
/** wire 上的改写记录 = 引擎的 `ToolInputRewrite` 同形(扩展项的 `name` 已过出口纪律、`input` 已脱敏)。 */
|
|
27
|
+
export interface ToolInputRewriteFace {
|
|
28
|
+
readonly by: readonly Readonly<RewriteAuthor>[];
|
|
29
|
+
readonly input: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** `tool_end.rewrite` 的投影(缺席 ⇒ 缺席;形不对 ⇒ 整只丢 + 计一次)。`argsOnWire` = 工具参数上 wire 的那一只投影(与 `tool_start.args` 同一只,调用方交进来)。 */
|
|
32
|
+
export declare function toolInputRewriteOf(v: unknown, where: string, argsOnWire: (args: unknown) => unknown): ToolInputRewriteFace | undefined;
|
|
33
|
+
//# sourceMappingURL=extension-call-face.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { sanitizeWireText } from "./engine-notice-wire.js";
|
|
2
|
+
import { dropProjectedFace } from "./projection-drop.js";
|
|
3
|
+
export function extensionRequesterOf(v, where) {
|
|
4
|
+
if (v === undefined)
|
|
5
|
+
return undefined;
|
|
6
|
+
if (typeof v === "object" && v !== null && "kind" in v && "name" in v && v.kind === "extension" && typeof v.name === "string" && v.name !== "")
|
|
7
|
+
return { kind: "extension", name: sanitizeWireText(v.name) };
|
|
8
|
+
return dropProjectedFace("extension_call.requestedBy is not { kind: extension, name: <non-empty string> } on " + where);
|
|
9
|
+
}
|
|
10
|
+
export function extensionAnswererOf(v, where) {
|
|
11
|
+
if (v === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
if (typeof v === "string" && v !== "")
|
|
14
|
+
return sanitizeWireText(v);
|
|
15
|
+
return dropProjectedFace("extension_call.answeredBy is not a non-empty string on " + where);
|
|
16
|
+
}
|
|
17
|
+
const REWRITE_AUTHOR_READERS = {
|
|
18
|
+
extension: (v) => ("name" in v && typeof v.name === "string" && v.name !== "" ? { kind: "extension", name: sanitizeWireText(v.name) } : undefined),
|
|
19
|
+
policy: () => ({ kind: "policy" }),
|
|
20
|
+
approver: () => ({ kind: "approver" }),
|
|
21
|
+
};
|
|
22
|
+
const isRewriteAuthorKind = (kind) => typeof kind === "string" && Object.hasOwn(REWRITE_AUTHOR_READERS, kind);
|
|
23
|
+
function rewriteAuthorOf(v) {
|
|
24
|
+
if (typeof v !== "object" || v === null || !("kind" in v))
|
|
25
|
+
return undefined;
|
|
26
|
+
const kind = v.kind;
|
|
27
|
+
return isRewriteAuthorKind(kind) ? REWRITE_AUTHOR_READERS[kind](v) : undefined;
|
|
28
|
+
}
|
|
29
|
+
export function toolInputRewriteOf(v, where, argsOnWire) {
|
|
30
|
+
if (v === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
if (typeof v === "object" && v !== null && "by" in v && "input" in v && Array.isArray(v.by) && v.by.length > 0) {
|
|
33
|
+
const by = Array.from(v.by, rewriteAuthorOf);
|
|
34
|
+
if (by.every((a) => a !== undefined))
|
|
35
|
+
return { by, input: argsOnWire(v.input) };
|
|
36
|
+
}
|
|
37
|
+
return dropProjectedFace("tool_end.rewrite is not { by: <non-empty list of extension / policy / approver>, input } on " + where);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=extension-call-face.js.map
|