@sema-agent/server 7.141.0 → 7.143.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 +657 -0
- package/USAGE.md +102 -30
- package/dist/adoption/plan.js +22 -0
- package/dist/approval-ask-audit-store.d.ts +61 -43
- package/dist/approval-ask-audit-store.js +69 -44
- package/dist/approval-ask-machine.d.ts +15 -7
- package/dist/approval-ask-machine.js +10 -4
- package/dist/approval-card.d.ts +126 -27
- package/dist/approval-card.js +103 -23
- package/dist/approval-crash-convergence.d.ts +17 -7
- package/dist/approval-crash-convergence.js +94 -22
- package/dist/approval-deny-reasons.d.ts +34 -30
- package/dist/approval-deny-reasons.js +21 -6
- package/dist/approval-policy-settlement.d.ts +1 -1
- package/dist/approval-queue-kind.d.ts +27 -0
- package/dist/approval-queue-kind.js +6 -0
- package/dist/approval-reconciler.d.ts +41 -9
- package/dist/approval-reconciler.js +45 -42
- package/dist/audit.js +4 -2
- package/dist/auth-bridge.d.ts +9 -6
- package/dist/auth-bridge.js +9 -3
- package/dist/boot/adoption.js +2 -1
- package/dist/boot/budget-tracing.d.ts +17 -1
- package/dist/boot/budget-tracing.js +10 -6
- package/dist/boot/device-lane.d.ts +1 -1
- package/dist/boot/execution-env.d.ts +24 -4
- package/dist/boot/execution-env.js +26 -23
- package/dist/boot/execution-lane.js +2 -1
- package/dist/boot/exit-boundary.js +5 -4
- package/dist/boot/governance-seams.d.ts +26 -41
- package/dist/boot/governance-seams.js +61 -28
- package/dist/boot/late-binds.d.ts +7 -4
- package/dist/boot/late-binds.js +3 -1
- package/dist/boot/leader.js +2 -4
- package/dist/boot/memory-consolidation.d.ts +0 -8
- package/dist/boot/memory-consolidation.js +5 -4
- package/dist/boot/parked-revive-gate.js +2 -1
- package/dist/boot/permission-rules-audit.d.ts +0 -28
- package/dist/boot/permission-rules-audit.js +2 -1
- package/dist/boot/read-deny-anchor-audit.js +2 -1
- package/dist/boot/reapers.js +9 -7
- package/dist/boot/resolve-spec.d.ts +1 -1
- package/dist/boot/resolve-spec.js +19 -10
- package/dist/boot/retention-lane.js +5 -3
- package/dist/boot/runner-deps.d.ts +10 -7
- package/dist/boot/runner-deps.js +20 -29
- package/dist/boot/runtime-caps.js +3 -2
- package/dist/boot/session-faces.js +4 -3
- package/dist/boot/shutdown.d.ts +9 -0
- package/dist/boot/shutdown.js +19 -4
- package/dist/boot/stage-02-web-admin-pull.js +3 -0
- package/dist/boot/stage-03-store-backend.d.ts +4 -1
- package/dist/boot/stage-03-store-backend.js +1 -2
- package/dist/boot/stage-04-stores.d.ts +5 -2
- package/dist/boot/stage-04-stores.js +6 -7
- package/dist/boot/stage-05-execution-env.d.ts +6 -3
- package/dist/boot/stage-05-execution-env.js +8 -6
- package/dist/boot/stage-06-runners.d.ts +6 -3
- package/dist/boot/stage-06-runners.js +3 -4
- package/dist/boot/stage-07-capability-layer.d.ts +6 -3
- package/dist/boot/stage-07-capability-layer.js +7 -2
- package/dist/boot/stage-08-reapers.d.ts +6 -3
- package/dist/boot/stage-08-reapers.js +3 -2
- package/dist/boot/stage-09-leader.d.ts +6 -3
- package/dist/boot/stage-10-http-server.d.ts +6 -3
- package/dist/boot/stage-10-http-server.js +14 -5
- package/dist/boot/stores.d.ts +5 -2
- package/dist/boot/stores.js +10 -9
- package/dist/boot/web-admin.d.ts +5 -1
- package/dist/boot/web-admin.js +48 -36
- package/dist/boot/webfetch-summarize-lane.js +2 -1
- package/dist/boot/workflow-orchestration.js +3 -2
- package/dist/capabilities/builtin-tools.d.ts +2 -1
- package/dist/capabilities/builtin-tools.js +2 -4
- package/dist/capabilities/composite-members.d.ts +2 -1
- package/dist/capabilities/composite-members.js +2 -1
- package/dist/capabilities/hands-lane.d.ts +9 -39
- package/dist/capabilities/hands-lane.js +8 -13
- package/dist/capabilities/mcp-probe.d.ts +3 -2
- package/dist/capabilities/scenarios.d.ts +11 -1
- package/dist/capabilities/scenarios.js +1 -0
- package/dist/capabilities/skills.d.ts +1 -17
- package/dist/capabilities/skills.js +0 -8
- package/dist/capability-facts.d.ts +31 -7
- package/dist/capability-facts.js +27 -4
- package/dist/card-void.d.ts +6 -9
- package/dist/config-catalog.js +2 -1
- package/dist/config-dir-trust.js +58 -29
- package/dist/config-invariants.d.ts +7 -1
- package/dist/config-invariants.js +7 -0
- package/dist/config-provider.d.ts +10 -0
- package/dist/config-provider.js +15 -4
- package/dist/config-root-migration.d.ts +13 -0
- package/dist/config-root-migration.js +99 -0
- package/dist/config-types.d.ts +19 -8
- package/dist/config.d.ts +10 -3
- package/dist/config.js +18 -4
- package/dist/delegated-session-owner.d.ts +5 -3
- package/dist/delegated-session-owner.js +1 -1
- package/dist/device-ws-protocol.d.ts +1 -0
- package/dist/device-ws-protocol.js +2 -1
- package/dist/env-model-table-gate.d.ts +53 -0
- package/dist/env-model-table-gate.js +53 -0
- package/dist/execution-lane-caps.d.ts +2 -1
- package/dist/fleet/fleet-bus.d.ts +34 -55
- package/dist/fleet/fleet-bus.js +35 -100
- package/dist/fleet/fleet-reconciler.d.ts +4 -4
- package/dist/fleet/fleet-reconciler.js +1 -1
- package/dist/fleet/subagent-tail-bus.d.ts +14 -11
- package/dist/fleet/subagent-tail-bus.js +15 -28
- package/dist/hooks/hook-runner.d.ts +6 -0
- package/dist/hooks/hook-runner.js +58 -8
- package/dist/host-decision.d.ts +54 -20
- package/dist/host-decision.js +42 -14
- package/dist/http/admission.d.ts +1 -1
- package/dist/http/admission.js +7 -3
- package/dist/http/approval-sweeps.js +11 -8
- package/dist/http/caller-trust.d.ts +1 -1
- package/dist/http/dispatch.js +4 -2
- package/dist/http/durable-run-leg.js +2 -2
- package/dist/http/engine-refusal.d.ts +16 -0
- package/dist/http/engine-refusal.js +17 -0
- package/dist/http/execution-context.d.ts +2 -2
- package/dist/http/idempotency.d.ts +1 -1
- package/dist/http/memory-compliance-failure-reply.d.ts +1 -3
- package/dist/http/memory-compliance-failure-reply.js +4 -6
- package/dist/http/owner-access.d.ts +11 -0
- package/dist/http/owner-access.js +13 -0
- package/dist/http/principal-gate.d.ts +3 -1
- package/dist/http/principal-gate.js +17 -8
- package/dist/http/resume-legs.d.ts +21 -7
- package/dist/http/resume-legs.js +76 -58
- package/dist/http/resume-restatement.d.ts +39 -0
- package/dist/http/resume-restatement.js +25 -0
- package/dist/http/route-ctx.d.ts +35 -10
- package/dist/http/route-ctx.js +1 -1
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/approvals-assistant.d.ts +9 -1
- package/dist/http/routes/approvals-assistant.js +142 -31
- package/dist/http/routes/attachments.js +18 -0
- package/dist/http/routes/capabilities.js +16 -4
- package/dist/http/routes/memory-policy.d.ts +2 -2
- package/dist/http/routes/memory-policy.js +27 -7
- package/dist/http/routes/notify-wake.js +23 -25
- package/dist/http/routes/rules.js +48 -13
- package/dist/http/routes/runs.js +12 -11
- package/dist/http/routes/session-memory-sync.d.ts +91 -0
- package/dist/http/routes/session-memory-sync.js +174 -0
- package/dist/http/routes/session-sync.js +13 -20
- package/dist/http/routes/sessions-list.d.ts +2 -1
- package/dist/http/routes/sessions.d.ts +2 -2
- package/dist/http/routes/sessions.js +22 -23
- package/dist/http/routes/tasks.js +34 -54
- package/dist/http/run-read-face.d.ts +7 -0
- package/dist/http/run-read-face.js +9 -3
- package/dist/http/send.d.ts +5 -0
- package/dist/http/send.js +9 -2
- package/dist/http/server.d.ts +27 -15
- package/dist/http/server.js +4 -6
- package/dist/http/stored-body-replay.js +15 -4
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +2 -2
- package/dist/http/sync-submit-body.d.ts +21 -4
- package/dist/http/sync-submit-body.js +13 -0
- package/dist/http/wire-types.d.ts +17 -7
- package/dist/identity-source.d.ts +21 -2
- package/dist/identity-source.js +6 -0
- package/dist/leader/leader.js +5 -2
- package/dist/leader/wire.d.ts +7 -1
- package/dist/leader/wire.js +6 -5
- package/dist/leg-facts.d.ts +37 -0
- package/dist/leg-facts.js +15 -0
- package/dist/memory-bundle-engine.d.ts +1 -4
- package/dist/memory-bundle-engine.js +2 -2
- package/dist/memory-incident-sink.d.ts +19 -6
- package/dist/memory-incident-sink.js +8 -4
- package/dist/memory-operator-faces.d.ts +30 -66
- package/dist/memory-operator-faces.js +17 -88
- package/dist/memory-scope-stores.d.ts +38 -40
- package/dist/memory-scope-stores.js +51 -36
- package/dist/memory-scope.d.ts +0 -9
- package/dist/memory-scope.js +0 -9
- package/dist/memory-sync-client.d.ts +21 -21
- package/dist/memory-sync-client.js +62 -43
- package/dist/memory-sync-identity.d.ts +24 -0
- package/dist/memory-sync-identity.js +57 -0
- package/dist/memory-sync.d.ts +27 -5
- package/dist/memory-sync.js +29 -7
- package/dist/model-plane-face.d.ts +13 -7
- package/dist/model-plane-face.js +2 -1
- package/dist/observability/fail-open.d.ts +47 -14
- package/dist/observability/fail-open.js +37 -11
- package/dist/observability/run-terminal.d.ts +92 -34
- package/dist/observability/run-terminal.js +171 -162
- package/dist/orchestration/workflow-completion-inbox.d.ts +5 -19
- package/dist/orchestration/workflow-completion-inbox.js +0 -12
- package/dist/orchestration/workflow-notify-journal.d.ts +3 -2
- package/dist/orchestration/workflow-park-decision.d.ts +8 -3
- package/dist/orchestration/workflow-park-decision.js +5 -3
- package/dist/org-delivery-gate.d.ts +11 -0
- package/dist/org-delivery-gate.js +19 -1
- package/dist/parked-decide.d.ts +13 -9
- package/dist/parked-decide.js +7 -7
- package/dist/parked-revive-surface.js +1 -1
- package/dist/peer-inbound-face.d.ts +127 -0
- package/dist/peer-inbound-face.js +158 -0
- package/dist/permission-rule-list.d.ts +13 -9
- package/dist/permission-rule-list.js +7 -3
- package/dist/plugins/approval-ask-store-file.d.ts +14 -4
- package/dist/plugins/approval-ask-store-file.js +64 -11
- package/dist/plugins/approval-ask-store-memory.d.ts +2 -1
- package/dist/plugins/approval-ask-store-memory.js +17 -14
- package/dist/plugins/approval-ask-store-sql.d.ts +70 -23
- package/dist/plugins/approval-ask-store-sql.js +79 -30
- package/dist/plugins/checkpoint-store-sql.d.ts +4 -4
- package/dist/plugins/checkpoint-store-sql.js +9 -7
- package/dist/plugins/file-history-store-sql.d.ts +24 -18
- package/dist/plugins/file-history-store-sql.js +24 -19
- package/dist/plugins/file-run-store.d.ts +35 -1
- package/dist/plugins/file-run-store.js +108 -9
- package/dist/plugins/imported-layer-root-retirement.d.ts +82 -0
- package/dist/plugins/imported-layer-root-retirement.js +96 -0
- package/dist/plugins/local-checkpoint-store.d.ts +1 -1
- package/dist/plugins/local-checkpoint-store.js +2 -2
- package/dist/plugins/local-session-store.d.ts +42 -9
- package/dist/plugins/local-session-store.js +83 -33
- package/dist/plugins/local-task-attachment-store.d.ts +12 -2
- package/dist/plugins/local-task-attachment-store.js +67 -43
- package/dist/plugins/mailbox-recipient-lifecycle.d.ts +9 -31
- package/dist/plugins/mailbox-recipient-lifecycle.js +4 -0
- package/dist/plugins/mailbox-store-sql.d.ts +12 -8
- package/dist/plugins/mailbox-store-sql.js +76 -7
- package/dist/plugins/memory-key-guards.d.ts +3 -3
- package/dist/plugins/memory-run-store.d.ts +6 -1
- package/dist/plugins/memory-run-store.js +11 -1
- package/dist/plugins/memory-sync-store-pg.d.ts +15 -0
- package/dist/plugins/memory-sync-store-pg.js +21 -0
- package/dist/plugins/memory-sync-store-tidb.d.ts +2 -0
- package/dist/plugins/memory-sync-store-tidb.js +13 -1
- package/dist/plugins/one-time-migrations.d.ts +58 -2
- package/dist/plugins/one-time-migrations.js +161 -4
- package/dist/plugins/org-delivery-quota-store.d.ts +1 -1
- package/dist/plugins/org-delivery-quota-store.js +2 -12
- package/dist/plugins/park-commit-watch.d.ts +1 -1
- package/dist/plugins/permission-rule-store-file.d.ts +10 -1
- package/dist/plugins/permission-rule-store-file.js +15 -2
- package/dist/plugins/permission-rule-store-sql.d.ts +31 -1
- package/dist/plugins/permission-rule-store-sql.js +35 -2
- package/dist/plugins/remote-env-device.d.ts +8 -11
- package/dist/plugins/remote-env-device.js +6 -3
- package/dist/plugins/remote-env-e2b.d.ts +23 -4
- package/dist/plugins/remote-env-e2b.js +111 -28
- package/dist/plugins/remote-env-k8s.d.ts +61 -22
- package/dist/plugins/remote-env-k8s.js +133 -33
- package/dist/plugins/remote-env-local-docker.d.ts +15 -3
- package/dist/plugins/remote-env-local-docker.js +40 -12
- package/dist/plugins/retention-store-sql.d.ts +2 -2
- package/dist/plugins/run-store-sql.d.ts +9 -1
- package/dist/plugins/run-store-sql.js +9 -1
- package/dist/plugins/sandbox-read-floor.d.ts +5 -7
- package/dist/plugins/sandbox-read-floor.js +2 -7
- package/dist/plugins/sql-errors.d.ts +10 -1
- package/dist/plugins/sql-errors.js +13 -0
- package/dist/plugins/store-backend.d.ts +33 -35
- package/dist/plugins/store-backend.js +10 -1
- package/dist/plugins/store-contracts.d.ts +50 -1
- package/dist/plugins/store-contracts.js +6 -0
- package/dist/plugins/task-attachment-store.d.ts +112 -14
- package/dist/plugins/task-attachment-store.js +207 -29
- package/dist/plugins/tool-result-store-sql.d.ts +9 -8
- package/dist/plugins/tool-result-store-sql.js +23 -2
- package/dist/plugins/wiring-section-codec.d.ts +32 -0
- package/dist/plugins/wiring-section-codec.js +55 -0
- package/dist/plugins/workspace-fill.d.ts +60 -0
- package/dist/plugins/workspace-fill.js +106 -0
- package/dist/project-bundle.d.ts +38 -0
- package/dist/project-bundle.js +609 -0
- package/dist/rule-entry-list.d.ts +3 -2
- package/dist/rule-entry-list.js +5 -1
- package/dist/rules-consent.d.ts +28 -5
- package/dist/rules-consent.js +40 -28
- package/dist/run-local.js +11 -13
- package/dist/runs.d.ts +12 -8
- package/dist/runs.js +6 -8
- package/dist/runtime-governance.d.ts +1 -1
- package/dist/sandbox-egress-policy.d.ts +4 -1
- package/dist/sandbox-egress-policy.js +3 -1
- package/dist/sandbox-git-plane.d.ts +31 -12
- package/dist/sandbox-git-plane.js +24 -4
- package/dist/security.d.ts +9 -0
- package/dist/security.js +8 -0
- package/dist/server-secret-env.d.ts +4 -0
- package/dist/session-error-wire.d.ts +36 -0
- package/dist/session-error-wire.js +13 -0
- package/dist/session-incarnation.d.ts +1 -1
- package/dist/session-notify-door.d.ts +106 -0
- package/dist/session-notify-door.js +93 -0
- package/dist/session-sync.d.ts +9 -14
- package/dist/session-sync.js +5 -5
- package/dist/session-workspace.d.ts +3 -13
- package/dist/session-workspace.js +0 -9
- package/dist/standing-answer-grant.d.ts +5 -0
- package/dist/standing-answer-grant.js +10 -0
- package/dist/stores-sql/session-policy-store-sql.d.ts +4 -2
- package/dist/stores-sql/session-policy-store-sql.js +3 -13
- package/dist/task-mcp.d.ts +1 -1
- package/dist/task-settings.d.ts +21 -10
- package/dist/task-settings.js +46 -13
- package/dist/terminal.d.ts +39 -19
- package/dist/terminal.js +65 -22
- package/dist/tool-approval.d.ts +56 -37
- package/dist/tool-approval.js +78 -71
- package/dist/trace/core-keyset-guard.d.ts +134 -14
- package/dist/trace/engine-notice-wire.d.ts +9 -3
- package/dist/trace/engine-notice-wire.js +7 -3
- package/dist/trace/exit-seat.d.ts +9 -2
- package/dist/trace/exit-seat.js +1 -0
- package/dist/trace/ledger-sink.d.ts +10 -6
- package/dist/trace/ledger-sink.js +2 -2
- package/dist/trace/model-segment.d.ts +55 -25
- package/dist/trace/model-segment.js +101 -33
- package/dist/trace/project.d.ts +25 -5
- package/dist/trace/project.js +22 -0
- package/dist/trace/redact.d.ts +61 -9
- package/dist/trace/redact.js +1490 -468
- package/dist/trace/self-minted-wire.d.ts +745 -24
- package/dist/trace/self-minted-wire.js +239 -9
- package/dist/trace/wire-projection-faces.d.ts +2 -2
- package/dist/trace/wire-projection-faces.js +2 -2
- package/dist/verifier-pause-card.d.ts +33 -5
- package/dist/verifier-pause-card.js +15 -10
- package/dist/web-admin-client/apply-effective.d.ts +12 -16
- package/dist/web-admin-client/apply-effective.js +109 -9
- package/dist/web-admin-client/effective-keys.js +2 -0
- package/dist/web-admin-client/types.d.ts +4 -0
- package/dist/workspace-space.d.ts +19 -3
- package/dist/workspace-space.js +8 -4
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +3 -1
- package/package.json +3 -2
- package/wire-changes/server@7.142.0.json +639 -0
- package/wire-changes/server@7.143.0.json +1167 -0
package/dist/tool-approval.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readApprovalCard } from "./approval-content-kind.js";
|
|
2
|
-
import { heldAskOf,
|
|
2
|
+
import { heldAskOf, liveHostSource, readDecider, retiredDecisionKeyFacts, POLICY_CANNOT_ALLOW_PERSON_ASK } from "./host-decision.js";
|
|
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";
|
|
@@ -12,14 +12,14 @@ import { createLogger } from "./observability/logger.js";
|
|
|
12
12
|
import { errorKindOf } from "./observability/err-text.js";
|
|
13
13
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
14
14
|
import { ownerOfCheckpointScope } from "./security.js";
|
|
15
|
-
import { deriveAskId, deriveAskScopedBatchId, deriveBatchId, MAX_DECISION_NOTE_CHARS, noteLandedOnRow, noteRecordedReceipt } from "./approval-ask-machine.js";
|
|
16
|
-
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";
|
|
15
|
+
import { deriveAskId, deriveAskScopedBatchId, deriveBatchId, MAX_DECISION_NOTE_CHARS, noteLandedOnRow, noteRecordedReceipt, readBoundInputHash } from "./approval-ask-machine.js";
|
|
16
|
+
import { currentParkArm, MAX_RULE_OFFERS, buildApprovalCard, buildApprovalCardEnvelope, adoptStoredLiveFacts, buildApprovalRequestFrame, buildReplayFrame, buildRevokeFrame, readDenialLimitFallback, readProbeCause, readProbeReason, readReadRootCandidate, readStoredCardEnvelope, readRuleEvidence, readAllowRuleShadowed, readRuleOffersAbsence, readRuleOffersAbsenceSeat, readParkRowTrueSeat, readAskClassPair, readAskReasons, readClosedWordSeat, buildApprovalCompleteFrame, readRuleOfferList, } from "./approval-card.js";
|
|
17
17
|
import { askOwnerAdmits, askRowCarriesOwner, POLICY_REFUSAL_DECISION, projectAskTerminalClaimTruth } from "./plugins/approval-ask-store-sql.js";
|
|
18
|
-
import { APPROVAL_ENDING_CAUSES, SETTLE_OUTCOME,
|
|
18
|
+
import { APPROVAL_ENDING_CAUSES, SETTLE_OUTCOME, askRowEndingCause, askRowParkTrigger } from "./approval-deny-reasons.js";
|
|
19
19
|
import { settleByPolicy } from "./approval-policy-settlement.js";
|
|
20
20
|
import { governanceAskMarksFor, runWithGovernanceAskScope } from "./governance-ask-marks.js";
|
|
21
21
|
import { governanceOriginOf } from "./runtime-governance.js";
|
|
22
|
-
import { grantBindingOf } from "./standing-answer-grant.js";
|
|
22
|
+
import { agreedGrantBinding, grantBindingOf } from "./standing-answer-grant.js";
|
|
23
23
|
import { operatorAsk } from "./operator-ask.js";
|
|
24
24
|
import { APPROVAL_EXEMPTED_EVENT } from "./plugins/approval-exemption-store.js";
|
|
25
25
|
import { refusalBody } from "./http/refusal-body.js";
|
|
@@ -47,7 +47,7 @@ export function approvalDecidePath(sessionId) {
|
|
|
47
47
|
return `/v1/approvals/${encodeURIComponent(sessionId)}/decide`;
|
|
48
48
|
}
|
|
49
49
|
function parkSessionOf(row) {
|
|
50
|
-
return row.
|
|
50
|
+
return row.sourceSessionId === row.sessionId && row.sessionId !== row.taskId ? row.sessionId : undefined;
|
|
51
51
|
}
|
|
52
52
|
function ruleMaterialCarriesCredentialShape(command) {
|
|
53
53
|
return redactSecretsWithArms(command, { observe: false }).arms.has("full");
|
|
@@ -223,10 +223,11 @@ function livePendingRowOf(e) {
|
|
|
223
223
|
...(e.sessionId !== undefined ? { sessionId: e.sessionId } : {}),
|
|
224
224
|
...(e.requiresRealApproval ? { requiresRealApproval: true } : {}),
|
|
225
225
|
...(e.governanceForced ? { governanceForced: true } : {}),
|
|
226
|
-
...(
|
|
226
|
+
...(listFrame.mandated === true ? { mandated: true } : {}),
|
|
227
227
|
...(standingAnswerHome(pendingEntryStandingAnswerFacts(e)) === "none" ? { rememberRefused: true } : {}),
|
|
228
|
-
...(
|
|
229
|
-
...(
|
|
228
|
+
...(listFrame.mandate !== undefined ? { mandate: listFrame.mandate } : {}),
|
|
229
|
+
...(listFrame.origin !== undefined ? { origin: listFrame.origin } : {}),
|
|
230
|
+
...(listFrame.type === "approval_request" && listFrame.liveFactsUnknown === true ? { liveFactsUnknown: true } : {}),
|
|
230
231
|
...(e.originTaskId !== undefined ? { fromSubagent: true, originTaskId: e.originTaskId } : {}),
|
|
231
232
|
...(approvalCard !== undefined ? { approvalCard } : {}),
|
|
232
233
|
frame: listFrame,
|
|
@@ -294,17 +295,17 @@ function parseToolApprovalFields(body, retired) {
|
|
|
294
295
|
}
|
|
295
296
|
if (retired !== undefined)
|
|
296
297
|
return { ok: false, error: retired.error };
|
|
297
|
-
const
|
|
298
|
-
let
|
|
299
|
-
switch (
|
|
298
|
+
const deciderReading = readDecider(body, false);
|
|
299
|
+
let decider;
|
|
300
|
+
switch (deciderReading.kind) {
|
|
300
301
|
case "outside_closed_set":
|
|
301
|
-
return { ok: false, error:
|
|
302
|
+
return { ok: false, error: deciderReading.message };
|
|
302
303
|
case "accepted":
|
|
303
|
-
|
|
304
|
+
decider = deciderReading.decider;
|
|
304
305
|
break;
|
|
305
306
|
default: {
|
|
306
|
-
const unreachable =
|
|
307
|
-
throw new Error(`unhandled
|
|
307
|
+
const unreachable = deciderReading;
|
|
308
|
+
throw new Error(`unhandled decider reading: ${JSON.stringify(unreachable)}`);
|
|
308
309
|
}
|
|
309
310
|
}
|
|
310
311
|
const rawGrant = body.readRootGrant;
|
|
@@ -319,7 +320,7 @@ function parseToolApprovalFields(body, retired) {
|
|
|
319
320
|
...(d !== "deny" && u !== undefined ? { updatedInput: u } : {}),
|
|
320
321
|
...(persistRule !== undefined ? { persistRule } : {}),
|
|
321
322
|
...(note !== undefined ? { note } : {}),
|
|
322
|
-
|
|
323
|
+
decider,
|
|
323
324
|
...(readRootGrant !== undefined ? { readRootGrant } : {}),
|
|
324
325
|
};
|
|
325
326
|
}
|
|
@@ -357,12 +358,6 @@ function boundArgs(args) {
|
|
|
357
358
|
}
|
|
358
359
|
return { args: redacted, omitted: false, hasBidi };
|
|
359
360
|
}
|
|
360
|
-
function readBoundInputHash(req) {
|
|
361
|
-
if (req === null || typeof req !== "object")
|
|
362
|
-
return null;
|
|
363
|
-
const v = Reflect.get(req, "boundInputHash");
|
|
364
|
-
return typeof v === "string" && v.length > 0 ? v : null;
|
|
365
|
-
}
|
|
366
361
|
export function resolveStreamApprovalGate(input) {
|
|
367
362
|
if (!input.toolApprovalEnabled)
|
|
368
363
|
return { active: false, reason: "no_tool_approval" };
|
|
@@ -492,7 +487,7 @@ function replayTerminalAskRow(row) {
|
|
|
492
487
|
}
|
|
493
488
|
export function outcomeOfDecidedRow(row) {
|
|
494
489
|
const allow = row.decision === "approve";
|
|
495
|
-
const source = row.settledBy !== null ? { settledBy: row.settledBy } : {};
|
|
490
|
+
const source = row.settledBy !== null ? { settledBy: row.settledBy, ...(row.decidedVia !== null ? { decidedVia: row.decidedVia } : {}) } : {};
|
|
496
491
|
const edit = allow && row.updatedInput !== undefined ? { updatedInput: row.updatedInput } : {};
|
|
497
492
|
return row.settledBy === null && !("updatedInput" in edit) ? allow : { allow, ...edit, ...source };
|
|
498
493
|
}
|
|
@@ -502,7 +497,7 @@ function settleArgsOfDecided(outcome) {
|
|
|
502
497
|
return {
|
|
503
498
|
allowed: outcome.allow,
|
|
504
499
|
...(outcome.updatedInput !== undefined ? { updatedInput: outcome.updatedInput } : {}),
|
|
505
|
-
...(outcome.settledBy !== undefined ? { settledBy: outcome.settledBy } : {}),
|
|
500
|
+
...(outcome.settledBy !== undefined ? { source: { settledBy: outcome.settledBy, ...(outcome.decidedVia !== undefined ? { decidedVia: outcome.decidedVia } : {}) } } : {}),
|
|
506
501
|
};
|
|
507
502
|
}
|
|
508
503
|
function verdictOfDecided(args) {
|
|
@@ -510,7 +505,7 @@ function verdictOfDecided(args) {
|
|
|
510
505
|
by: "human",
|
|
511
506
|
allowed: args.allowed,
|
|
512
507
|
...(args.updatedInput !== undefined ? { updatedInput: args.updatedInput } : {}),
|
|
513
|
-
...(args.
|
|
508
|
+
...(args.source !== undefined ? { hostSource: args.source } : {}),
|
|
514
509
|
};
|
|
515
510
|
}
|
|
516
511
|
function settleArgsOf(outcome) {
|
|
@@ -633,8 +628,8 @@ export class ToolApprovalCoordinator {
|
|
|
633
628
|
get unattendedRoutesToPark() {
|
|
634
629
|
return this.unattendedPolicy !== "deny";
|
|
635
630
|
}
|
|
636
|
-
batchIdFor(askId,
|
|
637
|
-
return this.unattendedRoutesToPark ? deriveBatchId(
|
|
631
|
+
batchIdFor(askId, sourceSessionId, runId, legKey) {
|
|
632
|
+
return this.unattendedRoutesToPark ? deriveBatchId(sourceSessionId, runId, legKey) : deriveAskScopedBatchId(askId);
|
|
638
633
|
}
|
|
639
634
|
unattendedAskOutcome(site) {
|
|
640
635
|
const facts = {
|
|
@@ -898,7 +893,7 @@ export class ToolApprovalCoordinator {
|
|
|
898
893
|
await new Promise((r) => setTimeout(r, SHUTDOWN_DRAIN_POLL_MS));
|
|
899
894
|
}
|
|
900
895
|
await this.parkCommits?.quiesce(deadlineMs);
|
|
901
|
-
this.askAudit?.
|
|
896
|
+
this.askAudit?.noteInterruptedByShutdown();
|
|
902
897
|
return { uncommittedParks: [...this.parksAwaitingCommit].map((p) => ({ approvalId: p.approvalId, taskId: p.taskId })) };
|
|
903
898
|
}
|
|
904
899
|
noteParkCommitted(calls) {
|
|
@@ -1024,7 +1019,7 @@ export class ToolApprovalCoordinator {
|
|
|
1024
1019
|
async sessionGrantUncontestedByRow(origin, req) {
|
|
1025
1020
|
if (!this.askStore)
|
|
1026
1021
|
return true;
|
|
1027
|
-
const call = { taskId: origin.taskId, legKey: origin.legKey, toolCallId: req.toolCallId,
|
|
1022
|
+
const call = { taskId: origin.taskId, legKey: origin.legKey, toolCallId: req.toolCallId, sourceSessionId: req.sourceSessionId ?? origin.taskId };
|
|
1028
1023
|
try {
|
|
1029
1024
|
const rows = await this.withStoreDeadline(this.askStore.listByCall(call), "listByCall(session-grant-provenance)", DURABLE_CONVERGE_READ_TIMEOUT_MS);
|
|
1030
1025
|
return rows.length === 0;
|
|
@@ -1057,12 +1052,11 @@ export class ToolApprovalCoordinator {
|
|
|
1057
1052
|
classifyClaimLoss(askId, current, _where) {
|
|
1058
1053
|
if (current.state === "absent")
|
|
1059
1054
|
return { kind: "absent" };
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
return { kind: "ended", cause: rowCause.cause };
|
|
1055
|
+
if (current.endingCause !== undefined)
|
|
1056
|
+
return { kind: "ended", cause: current.endingCause };
|
|
1063
1057
|
const replayedOutcome = replayTerminalAskRow(current);
|
|
1064
1058
|
if (replayedOutcome === "unavailable") {
|
|
1065
|
-
return
|
|
1059
|
+
return current.parkTrigger !== undefined ? { kind: "parked", cause: current.parkTrigger } : { kind: "parked" };
|
|
1066
1060
|
}
|
|
1067
1061
|
const replayed = settleArgsOfDecided(replayedOutcome);
|
|
1068
1062
|
if (!replayed.allowed)
|
|
@@ -1331,6 +1325,7 @@ export class ToolApprovalCoordinator {
|
|
|
1331
1325
|
const cardWord = readApprovalCard(req.approvalCard);
|
|
1332
1326
|
const originWord = typeof req.origin === "string" && req.origin.length > 0 ? req.origin : undefined;
|
|
1333
1327
|
const askClassPair = readAskClassPair(req);
|
|
1328
|
+
const askReasonsOfReq = readAskReasons(req);
|
|
1334
1329
|
const requester = extensionRequesterOf(req.requestedBy, "tool_approval");
|
|
1335
1330
|
const frame = {
|
|
1336
1331
|
type: "tool_approval",
|
|
@@ -1339,7 +1334,7 @@ export class ToolApprovalCoordinator {
|
|
|
1339
1334
|
...(typeof req.toolCallId === "string" && req.toolCallId !== "" ? { toolCallId: req.toolCallId } : {}),
|
|
1340
1335
|
...(child
|
|
1341
1336
|
? {
|
|
1342
|
-
|
|
1337
|
+
sourceSessionId: req.sourceSessionId,
|
|
1343
1338
|
fromSubagent: true,
|
|
1344
1339
|
...(typeof req.sourceAgentName === "string" ? { sourceAgentName: redactSecrets(req.sourceAgentName) } : {}),
|
|
1345
1340
|
...(req.delegation
|
|
@@ -1353,7 +1348,9 @@ export class ToolApprovalCoordinator {
|
|
|
1353
1348
|
: {}),
|
|
1354
1349
|
}
|
|
1355
1350
|
: {}),
|
|
1351
|
+
...(typeof req.agentId === "string" && req.agentId !== "" ? { agentId: req.agentId } : {}),
|
|
1356
1352
|
message: typeof req.message === "string" ? redactDeep(req.message) : "",
|
|
1353
|
+
...(askReasonsOfReq !== undefined ? { askReasons: askReasonsOfReq } : {}),
|
|
1357
1354
|
...(governanceForced ? { governanceForced: true } : {}),
|
|
1358
1355
|
...(req.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
1359
1356
|
...(req.mandated === true ? { mandated: true } : {}),
|
|
@@ -1385,6 +1382,7 @@ export class ToolApprovalCoordinator {
|
|
|
1385
1382
|
const card = this.askStore ? buildApprovalCard(frame, req, req.requiresRealApproval === true) : undefined;
|
|
1386
1383
|
let cardForFrame = card;
|
|
1387
1384
|
let persistedExpiresAtMs = expiresAtMs;
|
|
1385
|
+
let factsOfRecord;
|
|
1388
1386
|
let entryExecutionLane = origin.executionLane;
|
|
1389
1387
|
let lateEnsuredRow;
|
|
1390
1388
|
let lateTerminalRow;
|
|
@@ -1413,16 +1411,16 @@ export class ToolApprovalCoordinator {
|
|
|
1413
1411
|
: replayed;
|
|
1414
1412
|
};
|
|
1415
1413
|
if (this.askStore && card) {
|
|
1416
|
-
const
|
|
1414
|
+
const sourceSessionId = req.sourceSessionId ?? origin.taskId;
|
|
1417
1415
|
const runId = origin.taskId;
|
|
1418
1416
|
const legKey = origin.legKey;
|
|
1419
|
-
askId = deriveAskId(
|
|
1420
|
-
batchId = this.batchIdFor(askId,
|
|
1417
|
+
askId = deriveAskId(sourceSessionId, runId, legKey, req);
|
|
1418
|
+
batchId = this.batchIdFor(askId, sourceSessionId, runId, legKey);
|
|
1421
1419
|
try {
|
|
1422
1420
|
const existingOrCreated = await this.withStoreDeadline(this.askStore.ensureAsk({
|
|
1423
1421
|
askId,
|
|
1424
1422
|
taskId: origin.taskId,
|
|
1425
|
-
|
|
1423
|
+
sourceSessionId,
|
|
1426
1424
|
sessionId: origin.sessionId ?? origin.taskId,
|
|
1427
1425
|
owner: origin.owner,
|
|
1428
1426
|
executionLane: origin.executionLane,
|
|
@@ -1430,7 +1428,7 @@ export class ToolApprovalCoordinator {
|
|
|
1430
1428
|
toolCallId: req.toolCallId,
|
|
1431
1429
|
legKey,
|
|
1432
1430
|
parentToolCallId: req.delegation?.parentToolCallId ?? null,
|
|
1433
|
-
cardJson: buildApprovalCardEnvelope(askId, card),
|
|
1431
|
+
cardJson: buildApprovalCardEnvelope(askId, card, frame),
|
|
1434
1432
|
boundInputHash: readBoundInputHash(req),
|
|
1435
1433
|
...durableRuleMaterial(ruleLaneMaterial),
|
|
1436
1434
|
schemaVersion: 1,
|
|
@@ -1464,6 +1462,9 @@ export class ToolApprovalCoordinator {
|
|
|
1464
1462
|
persistedExpiresAtMs = existingOrCreated.row.expiresAtMs;
|
|
1465
1463
|
entryExecutionLane = existingOrCreated.row.executionLane;
|
|
1466
1464
|
cardForFrame = persistedEnvelope.card;
|
|
1465
|
+
factsOfRecord = existingOrCreated.inserted ? undefined : persistedEnvelope.liveFacts;
|
|
1466
|
+
if (factsOfRecord !== undefined)
|
|
1467
|
+
adoptStoredLiveFacts(frame, factsOfRecord);
|
|
1467
1468
|
if (cardForFrame.governanceForced === true)
|
|
1468
1469
|
frame.governanceForced = true;
|
|
1469
1470
|
else
|
|
@@ -1561,7 +1562,7 @@ export class ToolApprovalCoordinator {
|
|
|
1561
1562
|
if (hostSettled !== undefined || (denyReasonSettled !== undefined && denyReasonSettled !== "")) {
|
|
1562
1563
|
return {
|
|
1563
1564
|
allow: false,
|
|
1564
|
-
...
|
|
1565
|
+
...hostSettled,
|
|
1565
1566
|
...(denyReasonSettled !== undefined && denyReasonSettled !== "" ? { reason: denyReasonSettled } : {}),
|
|
1566
1567
|
};
|
|
1567
1568
|
}
|
|
@@ -1578,7 +1579,7 @@ export class ToolApprovalCoordinator {
|
|
|
1578
1579
|
return {
|
|
1579
1580
|
allow: true,
|
|
1580
1581
|
...(settled.updatedInput !== undefined ? { updatedInput: settled.updatedInput } : {}),
|
|
1581
|
-
...
|
|
1582
|
+
...hostSettled,
|
|
1582
1583
|
...(settled.readRootGrant !== undefined ? { readRootGrant: settled.readRootGrant } : {}),
|
|
1583
1584
|
};
|
|
1584
1585
|
}
|
|
@@ -1590,10 +1591,10 @@ export class ToolApprovalCoordinator {
|
|
|
1590
1591
|
done = true;
|
|
1591
1592
|
const allowed = verdict.by === "human" && verdict.allowed;
|
|
1592
1593
|
const outcome = verdict.by === "system" ? SETTLE_OUTCOME.EXPIRED : verdict.allowed ? SETTLE_OUTCOME.ALLOWED : SETTLE_OUTCOME.DENIED;
|
|
1593
|
-
const
|
|
1594
|
+
const hostSource = verdict.hostSource;
|
|
1594
1595
|
const updatedInput = verdict.by === "human" ? verdict.updatedInput : undefined;
|
|
1595
1596
|
const readRootGrant = verdict.by === "human" ? verdict.readRootGrant : undefined;
|
|
1596
|
-
hostSettled =
|
|
1597
|
+
hostSettled = hostSource;
|
|
1597
1598
|
denyReasonSettled = verdict.by === "human" && !verdict.allowed ? verdict.denyReason : undefined;
|
|
1598
1599
|
if (timer)
|
|
1599
1600
|
clearTimeout(timer);
|
|
@@ -1627,7 +1628,7 @@ export class ToolApprovalCoordinator {
|
|
|
1627
1628
|
const common = {
|
|
1628
1629
|
approvalId: wireApprovalId,
|
|
1629
1630
|
...(windowRouteUnavailable ? { parkRouted: true } : {}),
|
|
1630
|
-
...(
|
|
1631
|
+
...(hostSource !== undefined ? { settledBy: hostSource.settledBy } : {}),
|
|
1631
1632
|
settledAtMs: Date.now(),
|
|
1632
1633
|
};
|
|
1633
1634
|
return verdict.by === "system"
|
|
@@ -1639,7 +1640,7 @@ export class ToolApprovalCoordinator {
|
|
|
1639
1640
|
approvalId: wireApprovalId,
|
|
1640
1641
|
taskId: origin.taskId,
|
|
1641
1642
|
carrierLeg,
|
|
1642
|
-
executingSessionId: req.
|
|
1643
|
+
executingSessionId: req.sourceSessionId,
|
|
1643
1644
|
toolCallId: req.toolCallId,
|
|
1644
1645
|
settleRecord,
|
|
1645
1646
|
});
|
|
@@ -1793,7 +1794,7 @@ export class ToolApprovalCoordinator {
|
|
|
1793
1794
|
if (done)
|
|
1794
1795
|
return;
|
|
1795
1796
|
windowRouteUnavailable = true;
|
|
1796
|
-
settle({ by: "system", cause, ...(hostSettledBy !== undefined ? { hostSettledBy } : {}) });
|
|
1797
|
+
settle({ by: "system", cause, ...(hostSettledBy !== undefined ? { hostSource: { settledBy: hostSettledBy } } : {}) });
|
|
1797
1798
|
};
|
|
1798
1799
|
const windowExpired = (hostSelfReport, cause) => {
|
|
1799
1800
|
void (async () => {
|
|
@@ -1902,11 +1903,13 @@ export class ToolApprovalCoordinator {
|
|
|
1902
1903
|
}
|
|
1903
1904
|
const entryClasses = askClassPair?.classes;
|
|
1904
1905
|
const entryDeploymentListQuestion = carriesDeploymentListQuestion(deploymentListAsks, entryClasses);
|
|
1905
|
-
const
|
|
1906
|
+
const legGrantBinding = grantBindingOf(req);
|
|
1907
|
+
const entryGrantBinding = factsOfRecord === undefined ? legGrantBinding : agreedGrantBinding(legGrantBinding, grantBindingOf(factsOfRecord));
|
|
1908
|
+
const entryMandated = req.mandated === true || factsOfRecord?.mandated === true;
|
|
1906
1909
|
const rememberRefused = standingAnswerHome(pendingEntryStandingAnswerFacts({
|
|
1907
1910
|
...(effectiveGovernanceForced ? { governanceForced: true } : {}),
|
|
1908
1911
|
...(req.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
1909
|
-
...(
|
|
1912
|
+
...(entryMandated ? { mandated: true } : {}),
|
|
1910
1913
|
grantBinding: entryGrantBinding,
|
|
1911
1914
|
classes: entryClasses,
|
|
1912
1915
|
...(entryDeploymentListQuestion ? { deploymentListQuestion: true } : {}),
|
|
@@ -1929,7 +1932,7 @@ export class ToolApprovalCoordinator {
|
|
|
1929
1932
|
owner: origin.owner,
|
|
1930
1933
|
...(primary ? { ctxTaskId: primary.taskId, originCtx: primary } : {}),
|
|
1931
1934
|
...(reachability === "unreached" ? { suspended: true } : {}),
|
|
1932
|
-
...(child ? { originTaskId: req.
|
|
1935
|
+
...(child ? { originTaskId: req.sourceSessionId } : primary ? { targetCtxs: new Set(aliveCtxs), onTargetGone } : {}),
|
|
1933
1936
|
...(origin.sessionId ? { sessionId: origin.sessionId } : {}),
|
|
1934
1937
|
frame,
|
|
1935
1938
|
...(cardFrame !== undefined ? { cardFrame } : {}),
|
|
@@ -1945,9 +1948,7 @@ export class ToolApprovalCoordinator {
|
|
|
1945
1948
|
...(ruleLaneMaterial !== undefined ? { ruleLane: ruleLaneMaterial } : {}),
|
|
1946
1949
|
...(effectiveGovernanceForced ? { governanceForced: true } : {}),
|
|
1947
1950
|
...(req.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
1948
|
-
...(
|
|
1949
|
-
...(mandateWord !== undefined ? { mandate: mandateWord } : {}),
|
|
1950
|
-
...(originWord !== undefined ? { origin: originWord } : {}),
|
|
1951
|
+
...(entryMandated ? { mandated: true } : {}),
|
|
1951
1952
|
...(askId !== undefined && batchId !== undefined ? { askId, batchId } : {}),
|
|
1952
1953
|
};
|
|
1953
1954
|
selfEntry = pendingEntry;
|
|
@@ -1964,7 +1965,7 @@ export class ToolApprovalCoordinator {
|
|
|
1964
1965
|
this.askAudit?.recordAsk({
|
|
1965
1966
|
approvalId: wireApprovalId,
|
|
1966
1967
|
taskId: origin.taskId,
|
|
1967
|
-
...(req.
|
|
1968
|
+
...(req.sourceSessionId !== undefined ? { sourceSessionId: req.sourceSessionId } : {}),
|
|
1968
1969
|
...(origin.sessionId !== undefined ? { sessionId: origin.sessionId } : {}),
|
|
1969
1970
|
owner: origin.owner,
|
|
1970
1971
|
toolName: req.toolName,
|
|
@@ -2124,7 +2125,7 @@ export class ToolApprovalCoordinator {
|
|
|
2124
2125
|
const preRule = this.precheckEditedRuleBeforeDecision(entry, judgedOwner, parsed);
|
|
2125
2126
|
if (preRule !== undefined)
|
|
2126
2127
|
return preRule;
|
|
2127
|
-
if (parsed.value !== "deny" && policyCannotAnswer(heldAskOf(entry.requiresRealApproval === true), parsed.decidedBy)) {
|
|
2128
|
+
if (parsed.value !== "deny" && policyCannotAnswer(heldAskOf(entry.requiresRealApproval === true), parsed.decider.decidedBy)) {
|
|
2128
2129
|
return { status: 400, body: refusalBody({ errorCode: "request.body_shape", message: POLICY_CANNOT_ALLOW_PERSON_ASK }) };
|
|
2129
2130
|
}
|
|
2130
2131
|
const ruleEligibility = { eligible: true };
|
|
@@ -2300,8 +2301,8 @@ export class ToolApprovalCoordinator {
|
|
|
2300
2301
|
}
|
|
2301
2302
|
case "DENIED":
|
|
2302
2303
|
case "VOID": {
|
|
2303
|
-
const
|
|
2304
|
-
body = { state: "void", ...projection, ...(
|
|
2304
|
+
const endingCause = askRowEndingCause(row);
|
|
2305
|
+
body = { state: "void", ...projection, ...(endingCause !== undefined ? { cause: endingCause } : {}) };
|
|
2305
2306
|
break;
|
|
2306
2307
|
}
|
|
2307
2308
|
case "STREAM_PENDING":
|
|
@@ -2413,8 +2414,7 @@ export class ToolApprovalCoordinator {
|
|
|
2413
2414
|
}
|
|
2414
2415
|
case "DENIED":
|
|
2415
2416
|
case "VOID": {
|
|
2416
|
-
|
|
2417
|
-
return this.notPending(rowCause?.kind === "ending" ? rowCause.cause : undefined);
|
|
2417
|
+
return this.notPending(askRowEndingCause(row));
|
|
2418
2418
|
}
|
|
2419
2419
|
case "STREAM_PENDING":
|
|
2420
2420
|
return this.notPending(NOT_PENDING_UNKNOWN_CAUSE);
|
|
@@ -2488,7 +2488,7 @@ export class ToolApprovalCoordinator {
|
|
|
2488
2488
|
gateBoundInputHash: row.gateBoundInputHash,
|
|
2489
2489
|
decision,
|
|
2490
2490
|
...(parsed.note !== undefined ? { note: parsed.note } : {}),
|
|
2491
|
-
|
|
2491
|
+
decider: parsed.decider,
|
|
2492
2492
|
...(parsed.updatedInput !== undefined && parsed.value !== "deny" ? { updatedInput: parsed.updatedInput } : {}),
|
|
2493
2493
|
...(principal !== undefined ? { principal } : {}),
|
|
2494
2494
|
...(httpReq !== undefined ? { httpReq } : {}),
|
|
@@ -2731,7 +2731,7 @@ export class ToolApprovalCoordinator {
|
|
|
2731
2731
|
decision: parsed.value === "deny" ? "deny" : "approve",
|
|
2732
2732
|
...(parsed.note !== undefined ? { decisionNote: parsed.note } : {}),
|
|
2733
2733
|
...(parsed.value !== "deny" && parsed.updatedInput !== undefined ? { updatedInput: parsed.updatedInput } : {}),
|
|
2734
|
-
...(
|
|
2734
|
+
...liveHostSource(parsed.decider),
|
|
2735
2735
|
}), "decideAsk", DURABLE_CALL_TIMEOUT_MS, (late) => {
|
|
2736
2736
|
if (late.ok)
|
|
2737
2737
|
this.notifyExternalDecision(askId, outcomeOfDecidedRow(late.row));
|
|
@@ -2811,13 +2811,13 @@ export class ToolApprovalCoordinator {
|
|
|
2811
2811
|
this.allowAllSessions.add(sessionAllowKey(judgedOwner, entry.sessionId, sessionAllowCategory(entry.toolName), entry.grantBinding));
|
|
2812
2812
|
}
|
|
2813
2813
|
const allowed = parsed.value !== "deny";
|
|
2814
|
-
const settleArgs = opts?.settleOutcome !== undefined ? settleArgsOfDecided(opts.settleOutcome) : { allowed, updatedInput: parsed.updatedInput,
|
|
2814
|
+
const settleArgs = opts?.settleOutcome !== undefined ? settleArgsOfDecided(opts.settleOutcome) : { allowed, updatedInput: parsed.updatedInput, source: liveHostSource(parsed.decider) };
|
|
2815
2815
|
const readRootGrant = opts?.settleOutcome === undefined || opts.settleOutcomeIsThisRequest === true ? parsed.readRootGrant : undefined;
|
|
2816
2816
|
entry.settle({
|
|
2817
2817
|
by: "human",
|
|
2818
2818
|
allowed: settleArgs.allowed,
|
|
2819
2819
|
updatedInput: settleArgs.updatedInput,
|
|
2820
|
-
...(settleArgs.
|
|
2820
|
+
...(settleArgs.source !== undefined ? { hostSource: settleArgs.source } : {}),
|
|
2821
2821
|
...(!settleArgs.allowed && parsed.note !== undefined ? { denyReason: parsed.note } : {}),
|
|
2822
2822
|
...(readRootGrant !== undefined ? { readRootGrant } : {}),
|
|
2823
2823
|
});
|
|
@@ -2873,6 +2873,7 @@ export class ToolApprovalCoordinator {
|
|
|
2873
2873
|
const facts = {
|
|
2874
2874
|
...(card.governanceForced === true ? { governanceForced: true } : {}),
|
|
2875
2875
|
...(card.risk.requiresRealApproval ? { requiresRealApproval: true } : {}),
|
|
2876
|
+
...(replayFrame.mandated === true ? { mandated: true } : {}),
|
|
2876
2877
|
grantBinding: { kind: "unreadable" },
|
|
2877
2878
|
...(card.classes !== undefined ? { classes: card.classes } : {}),
|
|
2878
2879
|
};
|
|
@@ -2907,7 +2908,7 @@ export class ToolApprovalCoordinator {
|
|
|
2907
2908
|
owner: row.owner,
|
|
2908
2909
|
executionLane: row.executionLane,
|
|
2909
2910
|
...(row.sessionId !== row.taskId ? { sessionId: row.sessionId } : {}),
|
|
2910
|
-
...(card.fromSubagent === true ? { originTaskId: row.
|
|
2911
|
+
...(card.fromSubagent === true ? { originTaskId: row.sourceSessionId } : {}),
|
|
2911
2912
|
toolName: card.toolName,
|
|
2912
2913
|
...facts,
|
|
2913
2914
|
approvalId: row.askId,
|
|
@@ -2964,10 +2965,16 @@ export class ToolApprovalCoordinator {
|
|
|
2964
2965
|
}
|
|
2965
2966
|
return rows;
|
|
2966
2967
|
}
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2968
|
+
hasLivePendingFromLeg(names) {
|
|
2969
|
+
if (names.length === 0)
|
|
2970
|
+
return false;
|
|
2971
|
+
for (const e of this.pending.values()) {
|
|
2972
|
+
if (e.adopted === true)
|
|
2973
|
+
continue;
|
|
2974
|
+
const { agentId, sourceSessionId } = e.frame;
|
|
2975
|
+
if ((agentId !== undefined && names.includes(agentId)) || (sourceSessionId !== undefined && names.includes(sourceSessionId)))
|
|
2970
2976
|
return true;
|
|
2977
|
+
}
|
|
2971
2978
|
return false;
|
|
2972
2979
|
}
|
|
2973
2980
|
async pollSuspendedDecisions() {
|
|
@@ -3028,17 +3035,17 @@ export class ToolApprovalCoordinator {
|
|
|
3028
3035
|
}
|
|
3029
3036
|
if (this.editedDecisionInFlight(askId))
|
|
3030
3037
|
continue;
|
|
3031
|
-
const
|
|
3032
|
-
if (
|
|
3038
|
+
const endingCause = askRowEndingCause(row);
|
|
3039
|
+
if (endingCause !== undefined) {
|
|
3033
3040
|
const before = this.waitingRegistrationCount(askId);
|
|
3034
|
-
this.settleVoidedSiblings([askId],
|
|
3041
|
+
this.settleVoidedSiblings([askId], endingCause);
|
|
3035
3042
|
settled += before;
|
|
3036
3043
|
continue;
|
|
3037
3044
|
}
|
|
3038
3045
|
const outcome = replayTerminalAskRow(row);
|
|
3039
3046
|
if (outcome === "unavailable") {
|
|
3040
3047
|
const before = this.waitingRegistrationCount(askId);
|
|
3041
|
-
const parkCause = (
|
|
3048
|
+
const parkCause = askRowParkTrigger(row) ?? (Date.now() >= row.expiresAtMs ? APPROVAL_ENDING_CAUSES.TTL_EXPIRED : APPROVAL_ENDING_CAUSES.SHUTDOWN_BEFORE_PARK);
|
|
3042
3049
|
this.settleSameAskIdParkRoute(askId, parkCause);
|
|
3043
3050
|
settled += before;
|
|
3044
3051
|
continue;
|