@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
|
@@ -3,7 +3,6 @@ import { logStoreFormRefusal, storeFormRefusalOf } from "../memory-store-refusal
|
|
|
3
3
|
import { sentMemoryStoreRefusal } from "./memory-store-refusal-reply.js";
|
|
4
4
|
import { sendError } from "./send.js";
|
|
5
5
|
import { assertNever } from "./route-ctx.js";
|
|
6
|
-
import { MemoryErasureStoreUnjudged } from "../memory-operator-faces.js";
|
|
7
6
|
function sentCoreCode(res, coreCode, coreMessage, audience) {
|
|
8
7
|
switch (coreCode) {
|
|
9
8
|
case "config.memory_erasure_request":
|
|
@@ -18,8 +17,11 @@ function sentCoreCode(res, coreCode, coreMessage, audience) {
|
|
|
18
17
|
case "memory.erasure_selector_mismatch":
|
|
19
18
|
sendError(res, 409, "memory.erasure_selector_mismatch", textFor(audience, coreMessage, "session memory erasure refused — this requestId already names a different erasure; resend with a new requestId"));
|
|
20
19
|
return true;
|
|
20
|
+
case "config.memory_scope_key":
|
|
21
|
+
sendError(res, 400, "request.memory_layer", textFor(audience, coreMessage, "session memory erasure refused — the request names a memory layer this deployment cannot read; correct it and resend"));
|
|
22
|
+
return true;
|
|
21
23
|
case "memory.erasure_census_incomplete":
|
|
22
|
-
sendError(res, 409, "memory.erasure_census_incomplete", textFor(audience, coreMessage, "session memory erasure refused —
|
|
24
|
+
sendError(res, 409, "memory.erasure_census_incomplete", textFor(audience, coreMessage, "session memory erasure refused — a memory store could not be read completely, so that store erased nothing; where this deployment keeps memory in two stores the other store may already have carried out this erasure — ask the operator to repair the store, then resend with the same requestId to complete it"));
|
|
23
25
|
return true;
|
|
24
26
|
default:
|
|
25
27
|
return false;
|
|
@@ -43,10 +45,6 @@ function codeOf(err) {
|
|
|
43
45
|
return typeof code === "string" ? code : undefined;
|
|
44
46
|
}
|
|
45
47
|
export function sentMemoryComplianceFailure(res, err, audience, logger) {
|
|
46
|
-
if (err instanceof MemoryErasureStoreUnjudged) {
|
|
47
|
-
sendError(res, 409, "memory.erasure_store_unjudged", textFor(audience, err.message, "session memory erasure refused — this erasure reaches memory kept in this deployment's second memory store, which this build does not erase from (an erasure requestId is judged on the deployment's main store only); nothing was erased — it becomes available with the next engine update, or ask the operator"));
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
48
|
const coreCode = codeOf(err);
|
|
51
49
|
if (coreCode !== undefined && sentCoreCode(res, coreCode, err instanceof Error ? err.message : String(err), audience))
|
|
52
50
|
return true;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* {@link readOwnedRun} / {@link readOwnedSession} 并删两只 helper;裸 store 读口按文件计数钉在 `test/owner-gate-single-owner.test.ts`(增即红)。
|
|
15
15
|
*/
|
|
16
16
|
import type { ServiceConfig } from "../config-types.js";
|
|
17
|
+
import type { Logger } from "../observability/logger.js";
|
|
17
18
|
import type { RunRecord } from "../plugins/store-contracts.js";
|
|
18
19
|
import { type OwnerAwareSessionStore, type Principal, type SessionCaller, type SessionOwnerCell } from "../security.js";
|
|
19
20
|
import { type IdentityWiring, type OperatorRoster } from "./principal-gate.js";
|
|
@@ -45,6 +46,16 @@ export declare function readOwnedRun(config: OwnerAccessConfig, runStore: {
|
|
|
45
46
|
export declare function readOwnedSession(w: IdentityWiring & {
|
|
46
47
|
readonly config: OwnerAccessConfig;
|
|
47
48
|
}, store: Pick<OwnerAwareSessionStore, "placementOf"> & Required<Pick<OwnerAwareSessionStore, "headOf">>, caller: SessionCaller, sessionId: string, arm: OwnerArm): Promise<SessionOwnerCell | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* 🔴 **会话读面的属主读的第三个结局**:有主 / 无此行 / **属主读不出**(店交出具名拒 {@link SessionOwnerUnreadableError} —— 会话的行事实没有落下,补铸它要读的存档又用不了;
|
|
51
|
+
* 谁也判不了「这是不是你的会话」)。第三个读作第二个:**与「没有这一行」同一个值**(`undefined`),调用点落的就是它们对「不存在 / 非属主」的那一臂 ——
|
|
52
|
+
* 读者拿不到「这个 id 在盘上、且坏了」这件事(对非属主、对属主、对不存在的会话是同一只 404 `not_found.session`,同码同文),也就没有第二种拒绝形可漏存在性。
|
|
53
|
+
* 原故障(码与句)进运维日志一行 `session_owner_unreadable`:这是拒,不是兜底,不走 `recordFailOpen`;被折的读不再经全局兜底,日志里不能因此少一行。
|
|
54
|
+
*
|
|
55
|
+
* 只折这一个具名拒:别的读故障(I/O 级、边档整只拒、SQL 店的读故障、别的 `SessionError`)一概照旧上抛 —— 折的是「属主读不出」这件确定的事,不是「头读抛了」。
|
|
56
|
+
* 读面的所有属主读(会话视图三口共段 / 头探针 / 事件流 / 执行放置)经这一只;写口的属主读不在本只射程(它们对这一形仍答原故障的 500,契约 §17.2)。
|
|
57
|
+
*/
|
|
58
|
+
export declare function foldOwnerUnreadable<T>(logger: Pick<Logger, "warn"> | undefined, face: string, sessionId: string, read: () => Promise<T | undefined>): Promise<T | undefined>;
|
|
48
59
|
/**
|
|
49
60
|
* leader 登记表的判官形(boot 装配一次,`createLeaderEndpoint` 的必填席)—— leader 模块不再自判属主(修前它手抄 `owner == null || owner === requester`,
|
|
50
61
|
* 缺 C8 窄互认臂而注称 mirrors runOwnerOk)。leader 腿的调用方身份经幂等身份结构(`IdemCaller.principal`,即 `gatedPrincipal` 的回值)转手而来,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { mintDurableOwnerKey, mintPrincipal, sessionOwnerCellOf } from "../security.js";
|
|
2
|
+
import { openFaceFaultWire, SessionOwnerUnreadableError } from "../session-error-wire.js";
|
|
3
|
+
import { seatText } from "../trace/exit-seat.js";
|
|
2
4
|
import { explicitOperatorOk, runOwnerReadable, sessionOwnerReadable } from "./principal-gate.js";
|
|
3
5
|
function operatorArmHolds(config, principal, arm) {
|
|
4
6
|
switch (arm) {
|
|
@@ -36,6 +38,17 @@ export async function readOwnedSession(w, store, caller, sessionId, arm) {
|
|
|
36
38
|
const cell = await sessionOwnerCellOf(store, sessionId, owner);
|
|
37
39
|
return operatorArmHolds(w.config, caller.principal, arm) || sessionOwnerReadable(caller, cell, w) ? cell : undefined;
|
|
38
40
|
}
|
|
41
|
+
export async function foldOwnerUnreadable(logger, face, sessionId, read) {
|
|
42
|
+
try {
|
|
43
|
+
return await read();
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
if (!(e instanceof SessionOwnerUnreadableError))
|
|
47
|
+
throw e;
|
|
48
|
+
logger?.warn("session_owner_unreadable", { face, sessionId, errorCode: openFaceFaultWire(e).errorCode, err: seatText("operator-log-text", e.message) });
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
39
52
|
export function createLeaderRunVisibility(config) {
|
|
40
53
|
return (principal, owner) => runRowReadable(config, principal == null ? undefined : mintPrincipal(principal), owner ?? null, "owner");
|
|
41
54
|
}
|
|
@@ -2,6 +2,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
|
|
|
2
2
|
import type { ServiceConfig } from "../config-types.js";
|
|
3
3
|
import { type DurableOwnerKey, type Principal, type SessionCaller, type SessionOwnerCell } from "../security.js";
|
|
4
4
|
import { type IdentitySource, type RunIdentity } from "../identity-source.js";
|
|
5
|
+
import type { Logger } from "../observability/logger.js";
|
|
5
6
|
/** Coerce a possibly-repeated request header to a single string (or undefined). */
|
|
6
7
|
export declare function headerStr(v: string | string[] | undefined): string | undefined;
|
|
7
8
|
export declare function safeEqual(a: string, b: string): boolean;
|
|
@@ -28,8 +29,9 @@ export declare function verifiedIdentitySource(req: IncomingMessage, config: Ser
|
|
|
28
29
|
/**
|
|
29
30
|
* 🔴 **run 行身份元组的唯一铸点**(律见 `identity-source.ts` 头注;唯一调用点 = `dispatch.ts` 的凭据门,机器门钉着)。`source` = 凭据门那一次
|
|
30
31
|
* {@link verifiedIdentitySource} 的答案 —— 这里不再判来源,只把来源连同它的 scope / 化身号定成元组,挂在这个请求上;建 run 行的点经 {@link runIdentityOf} 读它。
|
|
32
|
+
* `logger` 收律 4 的告警行(令牌声明装不进列;凭据门交 `deps.logger`)。
|
|
31
33
|
*/
|
|
32
|
-
export declare function admitRunIdentity(req: IncomingMessage, source: IdentitySource | undefined): void;
|
|
34
|
+
export declare function admitRunIdentity(req: IncomingMessage, source: IdentitySource | undefined, logger: Pick<Logger, "warn"> | undefined): void;
|
|
33
35
|
/**
|
|
34
36
|
* 建 run 行时写进行里的身份元组 —— 每个 `createRun` 调用点(或替它建行的腿的调用方)读这一只,原样写入(机器门:`src/http/**` 每处 `createRun` 都写明 `identity`)。
|
|
35
37
|
* 只在**受理请求验过的主体就是这一行的属主**时交出凭据门铸下的元组(提交面恒成立:行的属主就是这个主体);别人替属主按下的那一跑(唤醒、决定投递铸的
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { timingSafeEqual } from "node:crypto";
|
|
2
2
|
import { DEPLOYMENT_SHAPE_PREDICATES } from "../deployment-shape.js";
|
|
3
|
-
import { PRINCIPAL_TOKEN_HEADER, verifiedPrincipal, ssoVerifiedPrincipal, ssoVerifiedScope, ownerlessRowOpen, mintPrincipal } from "../security.js";
|
|
4
|
-
import { IDENTITY_SOURCES,
|
|
3
|
+
import { PRINCIPAL_TOKEN_HEADER, verifiedPrincipal, ssoVerifiedPrincipal, ssoVerifiedPrincipalInc, ssoVerifiedScope, ownerlessRowOpen, mintPrincipal } from "../security.js";
|
|
4
|
+
import { IDENTITY_SOURCES, runIdentityClaimOverflow } from "../identity-source.js";
|
|
5
5
|
import { sendError } from "./send.js";
|
|
6
6
|
export function headerStr(v) {
|
|
7
7
|
return Array.isArray(v) ? v[0] : v;
|
|
@@ -60,19 +60,28 @@ export function verifiedIdentitySource(req, config) {
|
|
|
60
60
|
return IDENTITY_SOURCES.find((kind) => identitySourceVerified(kind, req, config));
|
|
61
61
|
}
|
|
62
62
|
const ADMITTED_RUN_IDENTITY = new WeakMap();
|
|
63
|
-
export function admitRunIdentity(req, source) {
|
|
64
|
-
ADMITTED_RUN_IDENTITY.set(req, mintRunIdentity(req, source));
|
|
65
|
-
}
|
|
66
|
-
function mintRunIdentity(req, source) {
|
|
63
|
+
export function admitRunIdentity(req, source, logger) {
|
|
64
|
+
ADMITTED_RUN_IDENTITY.set(req, mintRunIdentity(req, source, logger));
|
|
65
|
+
}
|
|
66
|
+
function mintRunIdentity(req, source, logger) {
|
|
67
|
+
const fits = (claim, value) => {
|
|
68
|
+
const overflow = runIdentityClaimOverflow(claim, value);
|
|
69
|
+
if (overflow !== undefined)
|
|
70
|
+
logger?.warn("run_identity_claim_unrecorded", { claim: overflow.claim, chars: overflow.chars, max: overflow.max });
|
|
71
|
+
return overflow === undefined;
|
|
72
|
+
};
|
|
67
73
|
switch (source) {
|
|
68
74
|
case "service_token":
|
|
69
75
|
case "direct_door_jwt":
|
|
70
76
|
return { source, scope: null, principalInc: null };
|
|
71
77
|
case "sso": {
|
|
72
78
|
const scope = ssoVerifiedScope(req);
|
|
73
|
-
if (scope === undefined
|
|
79
|
+
if (scope === undefined)
|
|
80
|
+
return null;
|
|
81
|
+
if (!fits("scope", scope))
|
|
74
82
|
return null;
|
|
75
|
-
|
|
83
|
+
const principalInc = ssoVerifiedPrincipalInc(req);
|
|
84
|
+
return { source, scope, principalInc: principalInc !== undefined && fits("principalInc", principalInc) ? principalInc : null };
|
|
76
85
|
}
|
|
77
86
|
case undefined:
|
|
78
87
|
return null;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { IncomingMessage } from "node:http";
|
|
15
15
|
import { CheckpointError, type QuestionAnswer, type CheckpointToken } from "@sema-agent/core";
|
|
16
|
-
import type { DecideBinding } from "./wire-types.js";
|
|
16
|
+
import type { DecideBinding, DecidedAction } from "./wire-types.js";
|
|
17
17
|
import type { CheckpointStoreFull } from "../plugins/store-backend.js";
|
|
18
18
|
import type { HostDecision } from "../host-decision.js";
|
|
19
19
|
import { type GateSighting } from "../approval-gate-currency.js";
|
|
@@ -23,6 +23,7 @@ import type { RunRegistry, RouteHelpers, RouteLegs } from "./route-ctx.js";
|
|
|
23
23
|
import type { createRequestGuards } from "./request-guards.js";
|
|
24
24
|
import type { FlatServiceDeps } from "./server.js";
|
|
25
25
|
import { type ResumeRefusalAnswer } from "./checkpoint-ctx.js";
|
|
26
|
+
import { type ResumeRestatement } from "./resume-restatement.js";
|
|
26
27
|
/**
|
|
27
28
|
* 🔴 **一次 `CheckpointError` 拒的处置 —— 唯一读口**:{@link CHECKPOINT_ERROR_DISPOSITION} 的读法(doctrine 在那张表头)。resume 腿的 catch 臂只调它一次,
|
|
28
29
|
* 行的落点与 wire 的 `retriable` 都读这一个结果。纯函数,钉直接调。运行期遇到表外的码(装树 core 比本二进制多一个码的版本偏斜 —— 型面上拼不出来)
|
|
@@ -35,18 +36,30 @@ export declare function checkpointRefusalAnswer(e: CheckpointError, at: {
|
|
|
35
36
|
readonly taskId?: string;
|
|
36
37
|
readonly versionKeys: Readonly<Record<string, string>>;
|
|
37
38
|
}): ResumeRefusalAnswer;
|
|
39
|
+
/**
|
|
40
|
+
* 一个答案只属于它被展示的那一个动作 —— 决断绑定的**唯一判官**:决断方点名它看到的那一对(`boundCallId` + `boundInputHash`,
|
|
41
|
+
* 队列行上展示的原值),两位都是非空串才成一只 {@link DecidedAction};缺哪位就点名哪位(序 = 体键序)。
|
|
42
|
+
* 不从当前停驻行补:补上的是此刻停在门上的动作,不是决断方看到的那一个(7.142.x 及以前的旧形 —— 同一调用 id 换了入参的新停驻会接住旧决定)。
|
|
43
|
+
*/
|
|
44
|
+
export declare function decidedActionOf(binding: Pick<DecideBinding, "boundCallId" | "boundInputHash">): {
|
|
45
|
+
readonly action: DecidedAction;
|
|
46
|
+
readonly missingKeys?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
readonly action?: undefined;
|
|
49
|
+
readonly missingKeys: readonly ("boundCallId" | "boundInputHash")[];
|
|
50
|
+
};
|
|
38
51
|
export declare function createResumeLegs(ctx: {
|
|
39
52
|
deps: FlatServiceDeps;
|
|
40
53
|
runnerFor: FlatServiceDeps["runnerFor"];
|
|
41
54
|
} & RunRegistry & RouteHelpers & Pick<RouteLegs, "prepareSpec" | "finalizeTaskResult"> & Pick<ReturnType<typeof createRequestGuards>, "ownerCostQuotaDenied" | "ownerFleetLeaseDenied" | "usageWindowDenialFor">): {
|
|
42
55
|
routeCtxBase: RouteCtxBase;
|
|
43
|
-
resumeCheckpoint: (sessionId: string, decision: "approve" | "deny", reason: string | undefined, hostDecision: HostDecision, req
|
|
56
|
+
resumeCheckpoint: (sessionId: string, decision: "approve" | "deny", reason: string | undefined, hostDecision: HostDecision, req: IncomingMessage | undefined, answer: QuestionAnswer | undefined, binding: DecideBinding, onResumeCommitted?: (grant: {
|
|
44
57
|
overrideSessionId?: string;
|
|
45
58
|
rememberableToolName: string | null;
|
|
46
59
|
}) => Promise<void>, acceptEarly?: boolean, decider?: {
|
|
47
60
|
principal?: string;
|
|
48
61
|
explicitOperator: boolean;
|
|
49
|
-
}) => Promise<ResumeLegOutcome>;
|
|
62
|
+
}, restatement?: ResumeRestatement) => Promise<ResumeLegOutcome>;
|
|
50
63
|
driveResumeIntoRunLog: (args: DriveResumeArgs) => Promise<ResumeLegOutcome>;
|
|
51
64
|
driveResumeLeg: (args: DriveResumeArgs, onAccepted?: (receipt: {
|
|
52
65
|
status: number;
|
|
@@ -59,9 +72,9 @@ export declare function createResumeLegs(ctx: {
|
|
|
59
72
|
resumePreempted: (sessionId: string, req: IncomingMessage | undefined, acceptEarly?: boolean, decider?: {
|
|
60
73
|
principal?: string;
|
|
61
74
|
explicitOperator: boolean;
|
|
62
|
-
}) => Promise<ResumeLegOutcome>;
|
|
63
|
-
startFreshHostTurn: (sessionId: string, objective: string, principal: string | undefined, req: IncomingMessage, workflowDecision: WorkflowDecisionDelivery, runId: string) => Promise<ResumeLegOutcome>;
|
|
64
|
-
resumeWake: (sessionId: string, message: string | undefined, caller: string | undefined, req: IncomingMessage | undefined, acceptEarly?: boolean, workflowDecision?: WorkflowDecisionDelivery, ownerLeaseAdmittedFor?: string) => Promise<ResumeLegOutcome>;
|
|
75
|
+
}, restatement?: ResumeRestatement) => Promise<ResumeLegOutcome>;
|
|
76
|
+
startFreshHostTurn: (sessionId: string, objective: string, principal: string | undefined, req: IncomingMessage, workflowDecision: WorkflowDecisionDelivery, runId: string, restatement?: ResumeRestatement) => Promise<ResumeLegOutcome>;
|
|
77
|
+
resumeWake: (sessionId: string, message: string | undefined, caller: string | undefined, req: IncomingMessage | undefined, acceptEarly?: boolean, workflowDecision?: WorkflowDecisionDelivery, ownerLeaseAdmittedFor?: string, restatement?: ResumeRestatement) => Promise<ResumeLegOutcome>;
|
|
65
78
|
preparePlanReview: (sessionId: string, log?: {
|
|
66
79
|
taskId?: string;
|
|
67
80
|
principalPresent?: boolean;
|
|
@@ -78,6 +91,7 @@ export declare function createResumeLegs(ctx: {
|
|
|
78
91
|
readonly ok: true;
|
|
79
92
|
readonly prepared: PreparedPlanReview;
|
|
80
93
|
}>;
|
|
81
|
-
drivePlanReview: (prepared: PreparedPlanReview, decision: "approve" | "edit" | "reject", editedPlan: string | undefined, reason: string | undefined, hostDecision: HostDecision, req: IncomingMessage | undefined, acceptEarly?: boolean, permissionModeAfter?: PlanApprovePermissionModeAfter) => Promise<ResumeLegOutcome>;
|
|
94
|
+
drivePlanReview: (prepared: PreparedPlanReview, decision: "approve" | "edit" | "reject", editedPlan: string | undefined, reason: string | undefined, hostDecision: HostDecision, req: IncomingMessage | undefined, acceptEarly?: boolean, permissionModeAfter?: PlanApprovePermissionModeAfter, restatement?: ResumeRestatement) => Promise<ResumeLegOutcome>;
|
|
95
|
+
sessionNotifyDoor: import("../session-notify-door.js").SessionNotifyDoor;
|
|
82
96
|
};
|
|
83
97
|
//# sourceMappingURL=resume-legs.d.ts.map
|