@sema-agent/server 7.136.0 → 7.138.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 +501 -139
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/USAGE.md +149 -34
- package/deploy/sema-up/README.md +14 -0
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +7 -1
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +7 -1
- package/dist/approval-card.d.ts +21 -14
- package/dist/approval-card.js +1 -0
- package/dist/approval-content-kind.d.ts +6 -0
- package/dist/approval-content-kind.js +7 -0
- package/dist/approval-gate-currency.d.ts +48 -6
- package/dist/approval-gate-currency.js +16 -9
- package/dist/approval-hmac.d.ts +13 -1
- package/dist/approval-hmac.js +1 -1
- package/dist/approval.js +3 -3
- package/dist/audit.js +1 -0
- package/dist/auth-bridge.js +2 -2
- package/dist/background-agent-name.d.ts +5 -0
- package/dist/background-agent-name.js +5 -0
- 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/execution-env.d.ts +24 -1
- package/dist/boot/execution-env.js +69 -6
- package/dist/boot/governance-seams.d.ts +10 -17
- package/dist/boot/governance-seams.js +5 -17
- package/dist/boot/leader.d.ts +3 -0
- package/dist/boot/leader.js +1 -0
- package/dist/boot/org-delivery.js +15 -2
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +15 -1
- package/dist/boot/resolve-spec.d.ts +7 -0
- package/dist/boot/resolve-spec.js +36 -26
- package/dist/boot/retention-lane.d.ts +11 -5
- package/dist/boot/retention-lane.js +2 -2
- package/dist/boot/runner-deps.d.ts +7 -3
- package/dist/boot/runner-deps.js +1 -0
- package/dist/boot/stage-03-store-backend.d.ts +1 -1
- package/dist/boot/stage-04-stores.d.ts +2 -13
- package/dist/boot/stage-05-execution-env.d.ts +6 -13
- package/dist/boot/stage-05-execution-env.js +17 -5
- package/dist/boot/stage-06-runners.d.ts +6 -13
- package/dist/boot/stage-06-runners.js +10 -3
- package/dist/boot/stage-07-capability-layer.d.ts +7 -13
- package/dist/boot/stage-07-capability-layer.js +3 -3
- package/dist/boot/stage-08-reapers.d.ts +7 -13
- package/dist/boot/stage-08-reapers.js +2 -1
- package/dist/boot/stage-09-leader.d.ts +7 -13
- package/dist/boot/stage-09-leader.js +2 -2
- package/dist/boot/stage-10-http-server.d.ts +7 -13
- package/dist/boot/stage-10-http-server.js +6 -3
- package/dist/boot/stores.d.ts +1 -1
- package/dist/boot/web-admin.d.ts +5 -2
- package/dist/boot/web-admin.js +3 -3
- package/dist/brain.js +5 -5
- package/dist/broker/broker.d.ts +89 -0
- package/dist/broker/broker.js +287 -0
- package/dist/broker/constants.d.ts +39 -0
- package/dist/broker/constants.js +15 -0
- package/dist/broker/http1.d.ts +111 -0
- package/dist/broker/http1.js +256 -0
- package/dist/broker/lease-book.d.ts +87 -0
- package/dist/broker/lease-book.js +142 -0
- package/dist/broker/lease-file.d.ts +60 -0
- package/dist/broker/lease-file.js +127 -0
- package/dist/broker/main.d.ts +2 -0
- package/dist/broker/main.js +20 -0
- package/dist/budget.d.ts +17 -15
- package/dist/budget.js +2 -2
- package/dist/capabilities/composite-members.d.ts +2 -1
- package/dist/capabilities/composite-members.js +2 -1
- package/dist/capabilities/engine-capabilities.js +1 -0
- package/dist/capabilities/mcp-probe.d.ts +36 -11
- package/dist/capabilities/mcp-probe.js +44 -5
- package/dist/capabilities/scenarios.d.ts +23 -8
- package/dist/capabilities/scenarios.js +13 -8
- package/dist/capabilities/skills.d.ts +28 -5
- package/dist/capabilities/skills.js +8 -0
- package/dist/capability-facts.d.ts +6 -0
- package/dist/capability-facts.js +5 -0
- package/dist/center-credential-renewer.js +5 -1
- package/dist/checkpoint-ctx-seal-m28.d.ts +3 -10
- package/dist/checkpoint-ctx-seal-m28.js +1 -1
- package/dist/checkpoint-identity.d.ts +13 -6
- package/dist/config-catalog.js +16 -7
- package/dist/config-types.d.ts +24 -7
- package/dist/config.d.ts +1 -1
- package/dist/config.js +42 -13
- package/dist/deployment-governance.d.ts +2 -2
- package/dist/deployment-governance.js +7 -9
- package/dist/deployment-shape.d.ts +6 -6
- package/dist/device-ws-protocol.d.ts +1 -0
- package/dist/device-ws-protocol.js +2 -1
- package/dist/file-history-disclosure.d.ts +4 -2
- package/dist/file-history-disclosure.js +2 -0
- package/dist/gate-settlement.d.ts +71 -0
- package/dist/gate-settlement.js +40 -0
- package/dist/hooks/classic-stations.d.ts +12 -54
- 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/http/admission.js +14 -9
- package/dist/http/approval-sweeps.js +4 -3
- package/dist/http/caller-trust.d.ts +2 -1
- package/dist/http/caller-trust.js +1 -3
- package/dist/http/checkpoint-ctx.d.ts +48 -7
- package/dist/http/checkpoint-ctx.js +40 -0
- package/dist/http/dispatch.d.ts +4 -0
- package/dist/http/dispatch.js +18 -10
- package/dist/http/durable-run-leg.d.ts +5 -1
- package/dist/http/durable-run-leg.js +5 -3
- package/dist/http/health-self-report.d.ts +2 -2
- package/dist/http/memory-compliance-failure-reply.js +3 -0
- package/dist/http/principal-gate.d.ts +15 -10
- package/dist/http/principal-gate.js +48 -9
- package/dist/http/resume-legs.d.ts +7 -31
- package/dist/http/resume-legs.js +185 -126
- package/dist/http/route-ctx.d.ts +38 -53
- 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 +24 -10
- package/dist/http/routes/capabilities.js +23 -11
- package/dist/http/routes/mcp-reconnect.d.ts +3 -2
- package/dist/http/routes/mcp-reconnect.js +7 -7
- 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 +13 -8
- package/dist/http/routes/session-sync.js +42 -6
- package/dist/http/routes/sessions.js +6 -3
- package/dist/http/routes/side-query.js +2 -3
- package/dist/http/routes/tasks.js +794 -780
- package/dist/http/server.d.ts +35 -25
- package/dist/http/stored-body-replay.d.ts +3 -3
- package/dist/http/stored-body-replay.js +6 -1
- package/dist/http/wire-types.d.ts +66 -33
- package/dist/identity-source.d.ts +65 -0
- package/dist/identity-source.js +45 -0
- package/dist/index.d.ts +2 -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-store-refusal.d.ts +3 -3
- package/dist/memory-sync-client.js +72 -57
- package/dist/memory-sync.d.ts +1 -1
- package/dist/model-entry-refusal.d.ts +2 -0
- package/dist/model-entry-refusal.js +11 -0
- package/dist/model-route-gap.d.ts +6 -22
- package/dist/model-route-gap.js +7 -5
- package/dist/model-select.d.ts +6 -17
- package/dist/model-select.js +0 -3
- package/dist/mods-declaration.d.ts +110 -0
- package/dist/mods-declaration.js +109 -0
- package/dist/namespaced-rule-name.d.ts +1 -1
- 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/metrics.js +1 -1
- package/dist/observability/run-terminal.js +1 -0
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/secret-env-scrub.js +1 -1
- package/dist/operator-ask.d.ts +2 -2
- package/dist/org-delivery-gate.js +1 -1
- package/dist/org-memory-admission.d.ts +2 -2
- package/dist/org-memory-admission.js +39 -2
- package/dist/parked-decide.d.ts +15 -2
- package/dist/parked-decide.js +17 -10
- package/dist/peer-directory.js +2 -0
- package/dist/peer-seat.d.ts +150 -0
- package/dist/peer-seat.js +239 -0
- package/dist/permission-rule-list.d.ts +2 -2
- 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/background-agent-store-sql.js +6 -3
- package/dist/plugins/caching-session-store.d.ts +5 -0
- package/dist/plugins/caching-session-store.js +6 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +34 -29
- package/dist/plugins/checkpoint-store-sql.js +14 -14
- package/dist/plugins/file-history-store-sql.js +10 -16
- package/dist/plugins/file-run-store.js +8 -2
- package/dist/plugins/k8s-exec-protocol.d.ts +69 -13
- package/dist/plugins/k8s-exec-protocol.js +116 -28
- package/dist/plugins/k8s-pod-delete-failure.d.ts +25 -0
- package/dist/plugins/k8s-pod-delete-failure.js +17 -0
- package/dist/plugins/k8s-pod-reaper.d.ts +106 -0
- package/dist/plugins/k8s-pod-reaper.js +122 -0
- package/dist/plugins/local-checkpoint-store.d.ts +4 -17
- package/dist/plugins/local-checkpoint-store.js +3 -4
- package/dist/plugins/local-session-store.d.ts +66 -27
- package/dist/plugins/local-session-store.js +60 -28
- package/dist/plugins/mailbox-store-sql.d.ts +11 -3
- package/dist/plugins/mailbox-store-sql.js +103 -15
- package/dist/plugins/memory-run-store.js +2 -0
- 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 +34 -12
- package/dist/plugins/one-time-migrations.js +51 -9
- package/dist/plugins/permission-rule-store-file.js +2 -2
- package/dist/plugins/permission-rule-store-sql.d.ts +17 -17
- package/dist/plugins/permission-rule-store-sql.js +37 -30
- package/dist/plugins/pg-pool.js +4 -0
- package/dist/plugins/pg-session-storage.d.ts +10 -2
- package/dist/plugins/pg-session-storage.js +20 -7
- package/dist/plugins/remote-env-adb.d.ts +6 -1
- package/dist/plugins/remote-env-adb.js +2 -1
- package/dist/plugins/remote-env-device.d.ts +6 -1
- package/dist/plugins/remote-env-device.js +5 -1
- package/dist/plugins/remote-env-e2b.d.ts +5 -0
- package/dist/plugins/remote-env-e2b.js +2 -1
- package/dist/plugins/remote-env-file-error.d.ts +8 -1
- package/dist/plugins/remote-env-file-error.js +7 -1
- package/dist/plugins/remote-env-host.d.ts +10 -2
- package/dist/plugins/remote-env-host.js +8 -2
- package/dist/plugins/remote-env-k8s.d.ts +140 -11
- package/dist/plugins/remote-env-k8s.js +277 -15
- package/dist/plugins/remote-env-local-docker.d.ts +5 -0
- package/dist/plugins/remote-env-local-docker.js +2 -1
- package/dist/plugins/remote-env-ssh.d.ts +6 -1
- package/dist/plugins/remote-env-ssh.js +2 -1
- package/dist/plugins/retention-store-sql.d.ts +14 -2
- package/dist/plugins/retention-store-sql.js +6 -0
- package/dist/plugins/run-store-sql.js +10 -4
- package/dist/plugins/session-fork.d.ts +10 -13
- package/dist/plugins/session-fork.js +5 -25
- package/dist/plugins/session-ownership.d.ts +24 -3
- package/dist/plugins/session-ownership.js +24 -5
- package/dist/plugins/session-workspace-cell.d.ts +17 -0
- package/dist/plugins/session-workspace-cell.js +38 -0
- package/dist/plugins/sql-errors.d.ts +23 -2
- package/dist/plugins/sql-errors.js +15 -0
- package/dist/plugins/store-backend.js +7 -7
- package/dist/plugins/store-contracts.d.ts +10 -1
- package/dist/plugins/store-fault.d.ts +2 -2
- package/dist/plugins/store-fault.js +4 -2
- package/dist/plugins/tidb-pool.js +13 -0
- package/dist/plugins/tidb-session-store.d.ts +17 -2
- package/dist/plugins/tidb-session-store.js +18 -7
- package/dist/plugins/tool-result-store-sql.d.ts +13 -6
- package/dist/plugins/tool-result-store-sql.js +8 -7
- 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/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +31 -2
- package/dist/request-value-closure.js +7 -1
- package/dist/rule-entry-list.d.ts +3 -2
- package/dist/rule-entry-list.js +2 -2
- package/dist/rules-consent.js +12 -7
- package/dist/run-local.d.ts +2 -2
- package/dist/run-local.js +12 -6
- package/dist/runs.d.ts +7 -1
- package/dist/runs.js +8 -2
- package/dist/runtime-governance.d.ts +5 -5
- package/dist/sandbox-git-lease.d.ts +49 -0
- package/dist/sandbox-git-lease.js +60 -0
- package/dist/sandbox-git-plane.d.ts +84 -0
- package/dist/sandbox-git-plane.js +105 -0
- package/dist/security.d.ts +16 -4
- package/dist/security.js +8 -3
- package/dist/server-secret-env.d.ts +12 -3
- package/dist/server-secret-env.js +18 -2
- package/dist/session-error-wire.d.ts +14 -6
- package/dist/session-error-wire.js +2 -1
- package/dist/session-incarnation.d.ts +4 -5
- package/dist/session-incarnation.js +2 -2
- package/dist/session-policy-wire.d.ts +1 -1
- package/dist/session-policy-wire.js +2 -2
- package/dist/session-sync.d.ts +1 -1
- package/dist/session-workspace.d.ts +130 -0
- package/dist/session-workspace.js +83 -0
- package/dist/spec-fields.d.ts +44 -14
- package/dist/spec-fields.js +33 -12
- package/dist/standing-answer-grant.d.ts +2 -13
- package/dist/standing-answer-grant.js +0 -7
- package/dist/stored-request-prompt-profile-m30.d.ts +49 -0
- package/dist/stored-request-prompt-profile-m30.js +25 -0
- package/dist/task-a2a.d.ts +44 -14
- package/dist/task-a2a.js +46 -20
- package/dist/task-mcp.d.ts +34 -21
- package/dist/task-mcp.js +46 -22
- package/dist/task-settings.d.ts +2 -2
- package/dist/tool-approval.d.ts +43 -9
- package/dist/tool-approval.js +57 -15
- package/dist/tool-rule-names.d.ts +5 -0
- package/dist/trace/core-keyset-guard.d.ts +34 -19
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +4 -0
- package/dist/trace/exit-seat.d.ts +20 -1
- package/dist/trace/exit-seat.js +5 -2
- package/dist/trace/extension-call-face.d.ts +33 -0
- package/dist/trace/extension-call-face.js +39 -0
- package/dist/trace/ledger-sink.d.ts +4 -5
- package/dist/trace/ledger-sink.js +3 -7
- package/dist/trace/project.d.ts +62 -10
- package/dist/trace/project.js +49 -9
- package/dist/trace/redact.d.ts +18 -6
- package/dist/trace/redact.js +154 -60
- package/dist/trace/self-minted-wire.d.ts +500 -7
- package/dist/trace/self-minted-wire.js +182 -1
- package/dist/trace/wire-projection-faces.d.ts +7 -5
- package/dist/trace/wire-projection-faces.js +9 -4
- package/dist/user-authored-text.d.ts +2 -2
- package/dist/user-authored-text.js +16 -1
- package/dist/web-admin-client/apply-effective.js +0 -1
- package/dist/web-admin-client/center-request.d.ts +23 -4
- package/dist/web-admin-client/center-request.js +42 -8
- package/dist/web-admin-client/http-client.js +6 -6
- package/dist/web-admin-client/skills-mcp.d.ts +8 -4
- package/dist/web-admin-client/skills-mcp.js +31 -18
- package/dist/web-admin-client/types.d.ts +10 -5
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +11 -5
- package/package.json +3 -3
- package/wire-changes/server@7.137.0.json +825 -0
- package/wire-changes/server@7.138.0.json +446 -0
package/dist/http/routes/runs.js
CHANGED
|
@@ -22,7 +22,7 @@ import { invalidJsonError, sendJson, sendError, sendHttpError, sseHeaders } from
|
|
|
22
22
|
import { mintCancelledResult } from "../../run-cancel-context.js";
|
|
23
23
|
import { acceptedInputKindOf } from "../../user-input-ledger.js";
|
|
24
24
|
import { INJECTION_TIERS } from "../../trace/injection-tier.js";
|
|
25
|
-
import { headerStr, gatedPrincipal, explicitOperatorOk, sendPrincipalRefusal } from "../principal-gate.js";
|
|
25
|
+
import { headerStr, gatedPrincipal, explicitOperatorOk, sendPrincipalRefusal, runIdentityOf } from "../principal-gate.js";
|
|
26
26
|
import { ActorAssertionWire } from "@sema-agent/settings-schema";
|
|
27
27
|
import * as facts from "../../capability-facts.js";
|
|
28
28
|
import { assertNever } from "../route-ctx.js";
|
|
@@ -222,11 +222,16 @@ export async function handleRuns(req, res, match, ctx) {
|
|
|
222
222
|
const prepared = await prepareSpec(req, res, keyedBody);
|
|
223
223
|
if (!prepared)
|
|
224
224
|
return;
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
try {
|
|
226
|
+
const resp = await createDurableRun(req, res, ctx, prepared, idem);
|
|
227
|
+
if (!resp)
|
|
228
|
+
return;
|
|
229
|
+
sendJson(res, resp.status, resp.body);
|
|
227
230
|
return;
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
prepared.peerLease.release();
|
|
234
|
+
}
|
|
230
235
|
}
|
|
231
236
|
if (match.decl.id === "run-detail" || match.decl.id === "run-events" || match.decl.id === "runs-by-idem") {
|
|
232
237
|
const runs = facts.durableRuns(deps);
|
|
@@ -433,13 +438,12 @@ export async function handleRuns(req, res, match, ctx) {
|
|
|
433
438
|
const text = body.text;
|
|
434
439
|
const priority = body.priority;
|
|
435
440
|
const steerIdemRaw = headerStr(req.headers["idempotency-key"]);
|
|
436
|
-
const
|
|
437
|
-
const messageId = steerInputId ?? uuidv7();
|
|
441
|
+
const messageId = steerIdemRaw ? `idem-${idemKeyOf(steerIdemRaw, idemCallerOf(req, ctx), "run").slice(0, 32)}` : uuidv7();
|
|
438
442
|
const trusted = explicitOperatorOk(principal, deps.config);
|
|
439
443
|
const steerInput = () => ({
|
|
440
444
|
text,
|
|
441
445
|
trusted,
|
|
442
|
-
|
|
446
|
+
inputId: messageId,
|
|
443
447
|
...(priority !== undefined ? { priority } : {}),
|
|
444
448
|
});
|
|
445
449
|
try {
|
|
@@ -1603,6 +1607,7 @@ export async function createDurableRun(req, res, ctx, prepared, idem) {
|
|
|
1603
1607
|
fleetScope: submitter ?? "default",
|
|
1604
1608
|
elicitOwner: submitter ?? null,
|
|
1605
1609
|
source,
|
|
1610
|
+
identity: runIdentityOf(req, deps.config, prepared.auth?.principal ?? null),
|
|
1606
1611
|
});
|
|
1607
1612
|
return out.existing ? await replayOfExistingRun(out.existing, caller, "durable", deps, runStore) : out;
|
|
1608
1613
|
});
|
|
@@ -61,7 +61,15 @@ export async function handleSessionSync(req, res, match, ctx) {
|
|
|
61
61
|
const mayTouch = face !== undefined && (scope.fleetWide || face.owner === scope.gateOwner || legacyUnownedSessionOk(deps.config, sessionCallerOf(req, deps), await sessionOwnerCellOf(sessionStorage, sessionId, face.owner)));
|
|
62
62
|
return { face, mayPull: mayTouch, mayPush: face === undefined || mayTouch };
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
let gate;
|
|
65
|
+
try {
|
|
66
|
+
gate = await judgeSessionGate();
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
if (isPullPort(match.decl.id) && sendPullUnreadable(req, res, deps.logger, e))
|
|
70
|
+
return;
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
65
73
|
const gateFace = gate.face;
|
|
66
74
|
const owner = gateFace === undefined ? undefined : gateFace.owner;
|
|
67
75
|
const sendSessionAbsent = () => sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
|
|
@@ -586,6 +594,21 @@ export async function handleSessionSync(req, res, match, ctx) {
|
|
|
586
594
|
}
|
|
587
595
|
}
|
|
588
596
|
}
|
|
597
|
+
function isPullPort(id) {
|
|
598
|
+
switch (id) {
|
|
599
|
+
case "session-sync-manifest":
|
|
600
|
+
case "session-sync-entries":
|
|
601
|
+
case "session-sync-history-blob":
|
|
602
|
+
return true;
|
|
603
|
+
case "session-sync-plan":
|
|
604
|
+
case "session-sync-import":
|
|
605
|
+
case "session-sync-import-entries":
|
|
606
|
+
case "session-sync-blob-put":
|
|
607
|
+
return false;
|
|
608
|
+
default:
|
|
609
|
+
return assertNever(id);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
589
612
|
function sendPullUnreadable(req, res, logger, e) {
|
|
590
613
|
if (e instanceof FileHistoryUnreadableError) {
|
|
591
614
|
const permanence = e.failure.permanence;
|
|
@@ -593,11 +616,24 @@ function sendPullUnreadable(req, res, logger, e) {
|
|
|
593
616
|
sendError(res, 503, "state.file_history_unreadable", `this session's file history cannot be read whole (${e.failure.code}), so nothing was exported — ${advice}`, permanence === undefined ? undefined : { permanence });
|
|
594
617
|
return true;
|
|
595
618
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
619
|
+
const fault = storeFaultClassOf(e);
|
|
620
|
+
switch (fault) {
|
|
621
|
+
case "connection":
|
|
622
|
+
logRequestError(logger, req, e);
|
|
623
|
+
sendError(res, 503, "state.file_history_unreadable", "this session's stored state could not be read right now (the store connection failed), so nothing was exported — retry later", { permanence: "transient" });
|
|
624
|
+
return true;
|
|
625
|
+
case "deployment":
|
|
626
|
+
logRequestError(logger, req, e);
|
|
627
|
+
sendError(res, 503, "state.file_history_unreadable", "this session's stored state cannot be read: the store does not match what this deployment requires (a table is missing or the database account lacks a privilege), so nothing was exported — retrying will not help until an operator repairs the store", { permanence: "terminal" });
|
|
628
|
+
return true;
|
|
629
|
+
case "corrupt":
|
|
630
|
+
case "unclassified":
|
|
631
|
+
return false;
|
|
632
|
+
default: {
|
|
633
|
+
const unhandled = fault;
|
|
634
|
+
throw new Error(`store fault class without a session-sync pull-port answer: ${String(unhandled)}`);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
601
637
|
}
|
|
602
638
|
function sendMissingBlob(res) {
|
|
603
639
|
sendError(res, 422, "missing_blob", "missing blob; PUT all referenced blobs before import");
|
|
@@ -3,6 +3,7 @@ import { a2aForScenario, mcpForScenario } from "../../web-admin-client/facade.js
|
|
|
3
3
|
import { HttpError, isUuidShape, legacyUnownedSessionOk, sessionOwnerCellOf } from "../../security.js";
|
|
4
4
|
import { windowMessages, truncateMessageBlobs, redactSessionViewForRead } from "../../audit.js";
|
|
5
5
|
import { redactSecrets } from "../../trace/redact.js";
|
|
6
|
+
import { seatText } from "../../trace/exit-seat.js";
|
|
6
7
|
import { recordFailOpen } from "../../observability/fail-open.js";
|
|
7
8
|
import { MCP_DIAL_DEADLINE_MS, raceDeadline } from "../mcp-dial-deadline.js";
|
|
8
9
|
import { sentMemoryComplianceFailure } from "../memory-compliance-failure-reply.js";
|
|
@@ -18,6 +19,7 @@ import { rosterAgentId } from "./agents-roster.js";
|
|
|
18
19
|
import { projectSessionListRow } from "./sessions-list.js";
|
|
19
20
|
import { readSessionRowPatch } from "../../session-row.js";
|
|
20
21
|
import { buildBoundedToolNames } from "../../panel-tool-names.js";
|
|
22
|
+
import { projectMcpAuthorization } from "../../mcp-authorization-face.js";
|
|
21
23
|
const MCP_STATUS_TTL_MS = 5_000;
|
|
22
24
|
const A2A_STATUS_TTL_MS = 5_000;
|
|
23
25
|
const A2A_MATERIALIZE_TIMEOUT_MS = 10_000;
|
|
@@ -170,7 +172,7 @@ export async function handleSessions(req, res, match, ctx) {
|
|
|
170
172
|
mcpStatusCache.clear();
|
|
171
173
|
const panel = (async () => {
|
|
172
174
|
const stopDial = new AbortController();
|
|
173
|
-
const matP = materializeMcpTools(specs, principal, undefined, undefined, undefined, deps.mcpRevocations, undefined, undefined, undefined, stopDial.signal);
|
|
175
|
+
const matP = materializeMcpTools(specs, principal, undefined, undefined, undefined, deps.mcpRevocations, undefined, undefined, undefined, stopDial.signal, undefined, deps.peerDesk.seat.answer);
|
|
174
176
|
const mat = await raceDeadline(matP, MCP_DIAL_DEADLINE_MS).catch(() => null);
|
|
175
177
|
if (!mat) {
|
|
176
178
|
stopDial.abort();
|
|
@@ -185,7 +187,8 @@ export async function handleSessions(req, res, match, ctx) {
|
|
|
185
187
|
status: s.status,
|
|
186
188
|
...(s.serverInfo ? { serverInfo: s.serverInfo } : {}),
|
|
187
189
|
...(s.toolNames ? { toolNames: s.toolNames } : {}),
|
|
188
|
-
...(
|
|
190
|
+
...((a) => (a !== undefined ? { authorization: a } : {}))(projectMcpAuthorization(s.authorization)),
|
|
191
|
+
...(s.error ? { error: seatText("mcp-remote-text", String(s.error)) } : {}),
|
|
189
192
|
})),
|
|
190
193
|
};
|
|
191
194
|
}
|
|
@@ -218,7 +221,7 @@ export async function handleSessions(req, res, match, ctx) {
|
|
|
218
221
|
if (a2aStatusCache.size > 1024)
|
|
219
222
|
a2aStatusCache.clear();
|
|
220
223
|
const panel = (async () => {
|
|
221
|
-
const matP = materializeA2aTools(specs, principal);
|
|
224
|
+
const matP = materializeA2aTools(specs, principal, undefined, undefined, deps.peerDesk.seat.answer);
|
|
222
225
|
let timer;
|
|
223
226
|
const mat = await Promise.race([matP.catch(() => null), new Promise((r) => { timer = setTimeout(() => r(null), A2A_MATERIALIZE_TIMEOUT_MS); })]);
|
|
224
227
|
if (timer)
|
|
@@ -95,9 +95,8 @@ export async function handleSideQuery(req, res, match, ctx) {
|
|
|
95
95
|
};
|
|
96
96
|
try {
|
|
97
97
|
const result = await deps.sideQuery(spec);
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
deps.sideQueryAccounting?.(principal, { model: modelId, usage: rr.usage });
|
|
98
|
+
const modelId = typeof result.model === "string" ? result.model : "unknown";
|
|
99
|
+
deps.sideQueryAccounting?.(principal, { model: modelId, usage: result.usage, account: result.account });
|
|
101
100
|
deps.metrics?.inc?.("side_query_total", { result: "ok" });
|
|
102
101
|
if (!res.writableEnded)
|
|
103
102
|
sendJson(res, 200, projectSideQueryResult(result));
|