@sema-agent/server 7.140.0 → 7.142.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 +505 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +142 -25
- package/dist/approval-ask-audit-store.d.ts +54 -38
- package/dist/approval-ask-audit-store.js +58 -39
- package/dist/approval-batch-census.d.ts +27 -0
- package/dist/approval-batch-census.js +27 -0
- package/dist/approval-card.d.ts +39 -24
- package/dist/approval-card.js +6 -3
- 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-reconciler.d.ts +33 -1
- package/dist/approval-reconciler.js +43 -40
- package/dist/approval.d.ts +15 -0
- package/dist/approval.js +10 -0
- package/dist/audit.d.ts +4 -2
- package/dist/audit.js +2 -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 +16 -0
- package/dist/boot/budget-tracing.js +10 -6
- package/dist/boot/device-lane.d.ts +11 -0
- package/dist/boot/device-lane.js +16 -0
- package/dist/boot/engine-lease.d.ts +24 -3
- package/dist/boot/engine-lease.js +9 -2
- package/dist/boot/execution-env.d.ts +24 -4
- package/dist/boot/execution-env.js +34 -27
- package/dist/boot/execution-lane.js +2 -1
- package/dist/boot/exit-boundary.js +5 -4
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-consolidation.d.ts +1 -1
- package/dist/boot/memory-consolidation.js +3 -2
- 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.d.ts +2 -2
- package/dist/boot/reapers.js +4 -3
- package/dist/boot/resolve-spec.js +18 -6
- package/dist/boot/retention-lane.js +5 -3
- package/dist/boot/runner-deps.js +16 -13
- package/dist/boot/runtime-caps.js +3 -2
- package/dist/boot/session-faces.d.ts +1 -1
- package/dist/boot/session-faces.js +8 -6
- package/dist/boot/shutdown.js +8 -2
- package/dist/boot/stage-04-stores.js +3 -2
- package/dist/boot/stage-05-execution-env.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.js +11 -7
- package/dist/boot/stage-06-runners.d.ts +1 -3
- package/dist/boot/stage-06-runners.js +3 -2
- package/dist/boot/stage-07-capability-layer.d.ts +1 -2
- package/dist/boot/stage-07-capability-layer.js +10 -11
- package/dist/boot/stage-08-reapers.d.ts +1 -2
- package/dist/boot/stage-08-reapers.js +3 -2
- package/dist/boot/stage-09-leader.d.ts +1 -2
- package/dist/boot/stage-10-http-server.d.ts +1 -2
- package/dist/boot/stage-10-http-server.js +6 -4
- package/dist/boot/stores.js +13 -6
- package/dist/boot/web-admin.js +18 -17
- 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/scenarios.d.ts +1 -1
- package/dist/capability-facts.d.ts +33 -0
- package/dist/capability-facts.js +32 -0
- package/dist/card-void.d.ts +38 -0
- package/dist/card-void.js +23 -0
- package/dist/config-catalog.js +12 -8
- package/dist/config-provider.d.ts +13 -13
- package/dist/config-provider.js +19 -33
- package/dist/config-types.d.ts +39 -10
- package/dist/config.d.ts +6 -0
- package/dist/config.js +72 -49
- package/dist/delegated-session-owner.d.ts +21 -19
- package/dist/delegated-session-owner.js +1 -1
- package/dist/device-store.d.ts +7 -0
- package/dist/device-store.js +3 -0
- package/dist/execution-config-root.d.ts +22 -0
- package/dist/execution-config-root.js +35 -0
- package/dist/execution-lane-caps.d.ts +50 -2
- package/dist/execution-lane-caps.js +90 -13
- package/dist/execution-placement.d.ts +3 -0
- package/dist/execution-placement.js +7 -0
- package/dist/fleet/drain-entry.d.ts +3 -0
- package/dist/fleet/fleet-bus.d.ts +6 -3
- package/dist/hooks/hook-runner.d.ts +6 -0
- package/dist/hooks/hook-runner.js +30 -1
- package/dist/hosted-posture.d.ts +8 -0
- package/dist/hosted-posture.js +4 -0
- package/dist/http/admission.js +3 -3
- package/dist/http/caller-trust.d.ts +3 -2
- package/dist/http/caller-trust.js +2 -1
- package/dist/http/dispatch.js +8 -2
- package/dist/http/execution-context.d.ts +2 -2
- package/dist/http/idempotency.d.ts +1 -1
- package/dist/http/live-frame.d.ts +24 -0
- package/dist/http/live-frame.js +16 -0
- package/dist/http/principal-gate.d.ts +3 -1
- package/dist/http/principal-gate.js +17 -8
- package/dist/http/resume-legs.js +42 -29
- package/dist/http/route-table.js +4 -0
- package/dist/http/routes/approvals-assistant.js +1 -0
- package/dist/http/routes/attachments.js +18 -0
- package/dist/http/routes/capabilities.js +10 -6
- package/dist/http/routes/diagnostics.d.ts +0 -19
- package/dist/http/routes/diagnostics.js +16 -2
- package/dist/http/routes/memory-bundle.d.ts +2 -2
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-policy.js +27 -7
- package/dist/http/routes/run-permission-mode.d.ts +75 -0
- package/dist/http/routes/run-permission-mode.js +170 -0
- package/dist/http/routes/runs.js +3 -3
- package/dist/http/routes/session-memory-sync.d.ts +63 -0
- package/dist/http/routes/session-memory-sync.js +157 -0
- package/dist/http/routes/session-sync.d.ts +3 -6
- package/dist/http/routes/session-sync.js +7 -2
- package/dist/http/routes/sessions-list.d.ts +2 -1
- package/dist/http/routes/sessions.js +5 -4
- package/dist/http/routes/tasks.js +70 -71
- package/dist/http/run-read-face.d.ts +7 -0
- package/dist/http/run-read-face.js +10 -4
- package/dist/http/send.d.ts +6 -1
- package/dist/http/send.js +10 -3
- package/dist/http/server.d.ts +20 -7
- package/dist/http/server.js +2 -4
- package/dist/http/sse-log.d.ts +3 -8
- package/dist/http/stored-body-replay.d.ts +3 -3
- package/dist/http/stored-body-replay.js +3 -1
- 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/identity-source.d.ts +21 -2
- package/dist/identity-source.js +6 -0
- package/dist/instruction-source-notice.d.ts +7 -0
- package/dist/instruction-source-notice.js +6 -6
- package/dist/mcp-assertion-header.d.ts +4 -0
- package/dist/mcp-assertion-header.js +5 -0
- package/dist/memory-incident-sink.d.ts +19 -6
- package/dist/memory-incident-sink.js +8 -4
- package/dist/memory-posture.d.ts +1 -1
- package/dist/memory-scope.d.ts +4 -4
- package/dist/memory-scope.js +1 -1
- package/dist/memory-sync-client.d.ts +35 -23
- package/dist/memory-sync-client.js +122 -52
- package/dist/memory-sync-identity.d.ts +24 -0
- package/dist/memory-sync-identity.js +57 -0
- package/dist/memory-sync.d.ts +7 -1
- package/dist/memory-sync.js +6 -3
- package/dist/observability/fail-open.d.ts +57 -12
- package/dist/observability/fail-open.js +50 -9
- package/dist/observability/metrics.js +0 -1
- package/dist/observability/run-terminal.d.ts +93 -31
- package/dist/observability/run-terminal.js +175 -171
- package/dist/observability/secret-env-scrub.d.ts +20 -1
- package/dist/observability/secret-env-scrub.js +14 -0
- package/dist/orchestration/workflow-completion-inbox.d.ts +5 -2
- package/dist/orchestration/workflow-completion-inbox.js +13 -5
- package/dist/orchestration/workflow-notify-journal.d.ts +5 -3
- package/dist/orchestration/workflow-notify-journal.js +2 -1
- package/dist/permission-mode-admission.d.ts +68 -0
- package/dist/permission-mode-admission.js +23 -0
- package/dist/permission-rule-list.d.ts +55 -6
- package/dist/permission-rule-list.js +52 -5
- package/dist/plugins/approval-ask-store-file.d.ts +14 -4
- package/dist/plugins/approval-ask-store-file.js +48 -7
- package/dist/plugins/approval-ask-store-memory.d.ts +2 -1
- package/dist/plugins/approval-ask-store-memory.js +9 -8
- package/dist/plugins/approval-ask-store-sql.d.ts +42 -10
- package/dist/plugins/approval-ask-store-sql.js +49 -19
- package/dist/plugins/caching-session-store.d.ts +6 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +65 -17
- package/dist/plugins/checkpoint-store-sql.js +74 -3
- package/dist/plugins/device-store-sql.d.ts +5 -2
- package/dist/plugins/device-store-sql.js +4 -1
- package/dist/plugins/execution-placement-sql.d.ts +11 -1
- package/dist/plugins/execution-placement-sql.js +12 -1
- package/dist/plugins/file-run-store.d.ts +7 -2
- package/dist/plugins/file-run-store.js +12 -2
- package/dist/plugins/fork-routing-session-store.d.ts +10 -32
- package/dist/plugins/fork-routing-session-store.js +2 -61
- package/dist/plugins/k8s-exec-protocol.d.ts +4 -1
- package/dist/plugins/k8s-exec-protocol.js +6 -1
- package/dist/plugins/local-checkpoint-store.d.ts +10 -1
- package/dist/plugins/local-checkpoint-store.js +22 -0
- package/dist/plugins/local-session-store.d.ts +260 -39
- package/dist/plugins/local-session-store.js +582 -57
- package/dist/plugins/local-session-window.d.ts +17 -3
- package/dist/plugins/local-session-window.js +7 -13
- package/dist/plugins/local-task-attachment-store.d.ts +12 -2
- package/dist/plugins/local-task-attachment-store.js +67 -43
- package/dist/plugins/memory-key-guards.d.ts +3 -3
- package/dist/plugins/memory-run-store.d.ts +7 -2
- package/dist/plugins/memory-run-store.js +12 -2
- package/dist/plugins/one-time-migrations.d.ts +68 -2
- package/dist/plugins/one-time-migrations.js +120 -4
- package/dist/plugins/pg-pool.js +3 -2
- package/dist/plugins/pg-session-storage.d.ts +2 -0
- package/dist/plugins/pg-session-storage.js +3 -2
- package/dist/plugins/remote-env-e2b.d.ts +47 -7
- package/dist/plugins/remote-env-e2b.js +242 -46
- package/dist/plugins/remote-env-k8s.d.ts +51 -6
- package/dist/plugins/remote-env-k8s.js +234 -44
- package/dist/plugins/remote-env-local-docker.d.ts +40 -14
- package/dist/plugins/remote-env-local-docker.js +127 -33
- package/dist/plugins/run-store-sql.d.ts +11 -3
- package/dist/plugins/run-store-sql.js +13 -4
- package/dist/plugins/sandbox-read-floor.d.ts +273 -0
- package/dist/plugins/sandbox-read-floor.js +608 -0
- package/dist/plugins/session-ownership.d.ts +2 -1
- package/dist/plugins/session-placement.d.ts +17 -4
- package/dist/plugins/session-placement.js +2 -1
- package/dist/plugins/session-store.d.ts +18 -20
- package/dist/plugins/session-store.js +4 -12
- package/dist/plugins/store-backend.d.ts +41 -7
- package/dist/plugins/store-backend.js +22 -4
- package/dist/plugins/store-contracts.d.ts +35 -3
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/task-attachment-store.d.ts +112 -14
- package/dist/plugins/task-attachment-store.js +221 -28
- package/dist/plugins/tidb-pool.js +2 -1
- package/dist/plugins/tidb-session-store.d.ts +4 -1
- package/dist/plugins/tidb-session-store.js +3 -2
- 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/run-cancel-context.d.ts +34 -0
- package/dist/run-cancel-context.js +7 -0
- package/dist/run-local.js +2 -8
- package/dist/runs.d.ts +39 -12
- package/dist/runs.js +69 -55
- 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 +11 -2
- package/dist/security.js +8 -0
- package/dist/server-secret-env.d.ts +2 -1
- package/dist/server-secret-env.js +2 -4
- package/dist/session-error-wire.d.ts +46 -4
- package/dist/session-error-wire.js +23 -0
- package/dist/session-incarnation.d.ts +9 -3
- package/dist/session-sync-kernel.d.ts +42 -1
- package/dist/session-sync-kernel.js +17 -0
- package/dist/session-sync.js +16 -4
- package/dist/sql-engine-coordinates.d.ts +49 -0
- package/dist/sql-engine-coordinates.js +27 -0
- package/dist/standing-answer-grant.d.ts +31 -2
- package/dist/standing-answer-grant.js +14 -2
- package/dist/store-posture.d.ts +1 -1
- package/dist/task-a2a.d.ts +1 -1
- package/dist/task-mcp.d.ts +1 -1
- package/dist/task-settings.d.ts +62 -27
- package/dist/task-settings.js +105 -29
- package/dist/terminal.d.ts +97 -20
- package/dist/terminal.js +107 -18
- package/dist/tool-approval.d.ts +4 -3
- package/dist/tool-approval.js +12 -14
- package/dist/trace/core-keyset-guard.d.ts +196 -2
- package/dist/trace/engine-notice-wire.d.ts +8 -2
- package/dist/trace/engine-notice-wire.js +4 -2
- package/dist/trace/exit-seat.d.ts +9 -1
- package/dist/trace/exit-seat.js +1 -0
- package/dist/trace/ledger-sink.d.ts +8 -4
- package/dist/trace/ledger-sink.js +2 -2
- package/dist/trace/model-segment.d.ts +2 -2
- package/dist/trace/project.d.ts +18 -1
- package/dist/trace/project.js +16 -0
- package/dist/trace/redact.js +323 -90
- package/dist/trace/self-minted-wire.d.ts +419 -4
- package/dist/trace/self-minted-wire.js +145 -0
- package/dist/trace/wire-projection-faces.d.ts +1 -1
- package/dist/trace/wire-projection-faces.js +1 -1
- package/dist/verifier-pause-card.d.ts +8 -0
- package/dist/verifier-pause-card.js +19 -0
- package/dist/web-admin-client/apply-effective.d.ts +5 -7
- package/dist/web-admin-client/apply-effective.js +22 -2
- package/dist/web-admin-client/candidate-gate.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.js +2 -0
- package/dist/web-admin-client/read-warnings.d.ts +2 -2
- package/dist/web-admin-client/types.d.ts +4 -0
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +3 -2
- package/package.json +2 -2
- package/wire-changes/server@7.141.0.json +367 -0
- package/wire-changes/server@7.142.0.json +639 -0
package/dist/http/server.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { ExecutionRoot, ResolvedTaskSpec } from "./execution-context.js";
|
|
|
13
13
|
import type { RunStore, ImageIndex, ImageBake, CheckpointStoreFull, ResumeAnchorStore, ApprovalExemptionStore, ApprovalNonceStore, ServiceSessionPolicyStore, ServiceFileHistoryStore, ToolResultStoreFull, StoreBackend } from "../plugins/store-backend.js";
|
|
14
14
|
import type { RuleConsentLane } from "../rules-consent.js";
|
|
15
15
|
import { type MemorySyncRequest, type MemorySyncResponse } from "../memory-sync.js";
|
|
16
|
+
import type { MemorySyncRunner } from "../memory-sync-client.js";
|
|
16
17
|
import type { TaskAttachmentStore } from "../plugins/task-attachment-store.js";
|
|
17
18
|
import type { LeaderEndpoint } from "../leader/endpoint.js";
|
|
18
19
|
import { type WorkflowAgentRegistry } from "../orchestration/workflow-agent-steer.js";
|
|
@@ -463,7 +464,8 @@ export interface ServiceSeamDeps {
|
|
|
463
464
|
}>;
|
|
464
465
|
/** 142-S5 §1.4: per-scope memory export reader (main.ts wires `exportMemoryScope` over the DB memory
|
|
465
466
|
* backend). Enables GET /v1/memory/export — present ONLY on a DB memory plane (MEMORY_ENGINE_BACKEND=
|
|
466
|
-
* pg|
|
|
467
|
+
* pg|mysql); absent ⇒ 501 (single-user file memory exports by copying the memory dir). The gate and the capability bit
|
|
468
|
+
* `memoryExport` read ONE fact (`capability-facts.ts` `memoryExport`) — whether this face is wired, never the backend name. */
|
|
467
469
|
memoryExport?: (scope: string) => Promise<MemoryEntry[]>;
|
|
468
470
|
/**
|
|
469
471
|
* [ref](core 5.57.0 `routePairingStatus`)—— **key↔URL 配对读面**:`GET /v1/models` 每行的
|
|
@@ -479,8 +481,10 @@ export interface ServiceSeamDeps {
|
|
|
479
481
|
/** 142-S2.5(设计 §2.5;裁定 plan 随数据走,core 零运行时半场):one full sync round for one
|
|
480
482
|
* (scope, peer) — main.ts wires `performMemorySync` over the DB memory backend + the sync-cursor
|
|
481
483
|
* store. Enables POST /v1/memory/sync/:scope — present ONLY on a DB memory plane
|
|
482
|
-
* (MEMORY_ENGINE_BACKEND=pg|
|
|
483
|
-
* IS the TOC side of a sync — it has no central-authority half to serve).
|
|
484
|
+
* (MEMORY_ENGINE_BACKEND=pg|mysql); absent ⇒ 501 honestly (a single-user file plane
|
|
485
|
+
* IS the TOC side of a sync — it has no central-authority half to serve). [ref]: the face also needs the center's
|
|
486
|
+
* declared sync identity (`config.memorySyncServeIdentity`) — the gate and the capability bit `memorySyncServe` read ONE
|
|
487
|
+
* fact (`capability-facts.ts` `memorySyncServe`). */
|
|
484
488
|
memorySync?: (scope: string, syncReq: MemorySyncRequest) => Promise<MemorySyncResponse>;
|
|
485
489
|
/** [ref] v2-c(core 5.40.0 `MemoryEngine.exportMemoryScopes`):治理完备包的**携出**面。main.ts 把它接到
|
|
486
490
|
* 装配好的 memory engine 上。启用 `POST /v1/memory/export`(operator-only)。
|
|
@@ -533,6 +537,14 @@ export interface ServiceSeamDeps {
|
|
|
533
537
|
* 装配漏接 ⇒ tsc 红(本行就是通知);测试桩在 `test/helpers/boot.ts` 显式给 false。
|
|
534
538
|
*/
|
|
535
539
|
memoryAutoConsolidationArmed: boolean;
|
|
540
|
+
/**
|
|
541
|
+
* [ref] —— 本**部署**的记忆同步腿(客户端半场):`MEMORY_SYNC_URL` 设了且 file 记忆引擎亮着、执行器起了才在场(`boot/stores.ts`)。
|
|
542
|
+
* `GET /v1/sessions/:id/memory-status` 的 `memorySync` 格只读它的 `parked()` —— 停驻事实的唯一读口(写者 = 执行器的轮,运维行 `memory_sync_layer_parked` 读同一份);
|
|
543
|
+
* 缺席 ⇒ 那一格缺席(没有同步腿)。与 `memoryAutoConsolidationArmed` 同类:部署事实,不随会话、不随层座。
|
|
544
|
+
* [ref]:会话记忆同步触发口(`POST /v1/sessions/:id/memory/sync`)读它的 `peer`(目标比对)与 `syncOnce`(一轮,交回每层每次调用;从不 reject)——
|
|
545
|
+
* 能力事实 `sessionMemorySync` 的第一格就是它在不在。
|
|
546
|
+
*/
|
|
547
|
+
memorySyncLeg?: Pick<MemorySyncRunner, "parked" | "peer" | "syncOnce">;
|
|
536
548
|
/**
|
|
537
549
|
* [ref] / [ref] + 车PI 修复轮 ④ —— 记忆整理阀门的**生效判决**(boot 第 4 段 `createConsolidationValve`:显式词,或出厂缺省按
|
|
538
550
|
* 装配结果派生)。配置目录那一行(`GET /v1/config/catalog` 的 `MEMORY_CONSOLIDATION_DRIVER` `effectiveValue`)读它 —— 那一列的契约是
|
|
@@ -691,10 +703,11 @@ export interface ServiceDeploymentDeps {
|
|
|
691
703
|
/** [ref] ②:caps `centerWiring` 的读面(`capabilities/center-wiring.ts` `createCenterWiringReader`;入参 = 请求的已验 principal)。
|
|
692
704
|
* 缺席 = 没接中心(或测试夹具)⇒ 键整个缺席。 */
|
|
693
705
|
centerWiring?: (principal: string | undefined) => import("../capabilities/center-wiring.js").CenterWiring;
|
|
694
|
-
/** The member git-credential plane's
|
|
695
|
-
* seat answer
|
|
696
|
-
*
|
|
697
|
-
|
|
706
|
+
/** The member git-credential plane's read function (`sandbox-git-plane.ts` `createSandboxGitPlaneSeat`'s `now`: the judge over the boot readings — the
|
|
707
|
+
* secret seat answer stage 5 settles, the static patch judge — and the live config, whose `sandboxGit` block hot-swaps with each effective-config commit).
|
|
708
|
+
* Caps `credentialPlane.sandboxGit` calls it on every read and projects the answer as is. Absent = not built by the composition root (a fixture) ⇒
|
|
709
|
+
* the same judge on config alone, the seat counted as not asked. */
|
|
710
|
+
sandboxGitPlane?: () => import("../sandbox-git-plane.js").SandboxGitPlane;
|
|
698
711
|
/**
|
|
699
712
|
* 本进程起服装上的**运维声明** mod 包数(部署座装配口 `assembleDeploymentMods` 的 `loaded.length`;本服务自铸的注册不算)。一个事实两个出口,同读这一格:
|
|
700
713
|
* `/health` 的 `mods: { deploymentPackages }` 与 `/v1/capabilities` 的 `modsDeploymentPackages: true` —— 都只在 > 0 时在场;0 / 缺席(没声明,或不是由
|
package/dist/http/server.js
CHANGED
|
@@ -18,7 +18,7 @@ import { cascadeConfig } from "./run-meta.js";
|
|
|
18
18
|
export { cascadeConfig };
|
|
19
19
|
import { coarseStatusForState, errorCodeForExit } from "./routes/images.js";
|
|
20
20
|
export { coarseStatusForState, errorCodeForExit };
|
|
21
|
-
import { sendError, sendHttpError,
|
|
21
|
+
import { sendError, sendHttpError, sendOpenFaceFault, logRequestError } from "./send.js";
|
|
22
22
|
import { createRequestGuards } from "./request-guards.js";
|
|
23
23
|
import { sqlEngineSeatIssue } from "../sql-engine-posture.js";
|
|
24
24
|
import { parkDecisionStoreRefusal } from "../orchestration/workflow-park-decision.js";
|
|
@@ -169,13 +169,11 @@ export function createHttpServer(rawDeps) {
|
|
|
169
169
|
res.end();
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
if (sendSessionError(res, err, "open"))
|
|
173
|
-
return;
|
|
174
172
|
if (err instanceof SessionForkInProgressError) {
|
|
175
173
|
sendError(res, 409, err.code, err.message);
|
|
176
174
|
return;
|
|
177
175
|
}
|
|
178
|
-
|
|
176
|
+
sendOpenFaceFault(res, err);
|
|
179
177
|
});
|
|
180
178
|
});
|
|
181
179
|
const deviceLane = facts.deviceLane(deps);
|
package/dist/http/sse-log.d.ts
CHANGED
|
@@ -70,15 +70,10 @@ export declare const SSE_PREAMBLE_TIMEOUT_MS = 2000;
|
|
|
70
70
|
* `ApprovalAskStore.listPendingBySession` 的注)。丢结果这条语义不变:preamble 只读,丢弃零副作用。
|
|
71
71
|
*
|
|
72
72
|
* 导出给 `routes/tasks.ts` 的 sync 腿直接用 —— 那条腿不走 `streamSseLog`(它不是账本 tail),但
|
|
73
|
-
* 「有界 + fail-open
|
|
73
|
+
* 「有界 + fail-open」这条判据必须是**同一份实现**,不能各腿各写一遍。帧型是调用方的(本泵写 `{ event, data }`,
|
|
74
|
+
* sync 腿把卡帧原样交给它自己的写口 `http/live-frame.ts`),所以按帧型泛化。
|
|
74
75
|
*/
|
|
75
|
-
export declare function collectSsePreamble(preamble: (signal: AbortSignal) => Promise<
|
|
76
|
-
event: string;
|
|
77
|
-
data: unknown;
|
|
78
|
-
}>>, onFailure?: (reason: "timeout" | "error", err?: unknown) => void, timeoutMs?: number): Promise<Array<{
|
|
79
|
-
event: string;
|
|
80
|
-
data: unknown;
|
|
81
|
-
}>>;
|
|
76
|
+
export declare function collectSsePreamble<F>(preamble: (signal: AbortSignal) => Promise<F[]>, onFailure?: (reason: "timeout" | "error", err?: unknown) => void, timeoutMs?: number): Promise<F[]>;
|
|
82
77
|
/** The shared resumable SSE pump (P2.8) — provider supplies the log-specific differences; the liveness/
|
|
83
78
|
* heartbeat/terminal-re-fetch/15-min-cap logic is identical for task_run + image_bake.
|
|
84
79
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { PermissionMode } from "@sema-agent/core";
|
|
11
11
|
import { type Autonomy } from "../runtime-governance.js";
|
|
12
|
-
import { type
|
|
12
|
+
import { type ExecutionConfigRootDeployment } from "../execution-config-root.js";
|
|
13
13
|
import { type StoredBodyReplayRefusal } from "./checkpoint-ctx.js";
|
|
14
14
|
import type { CheckpointCtx } from "./route-ctx.js";
|
|
15
15
|
/**
|
|
@@ -22,9 +22,9 @@ export declare function permissionModeReadingUnstated(ctx: CheckpointCtx, floor:
|
|
|
22
22
|
floor: PermissionMode;
|
|
23
23
|
} | undefined;
|
|
24
24
|
/**
|
|
25
|
-
* 预判读的部署配置:`autonomy`(第三问的模式词地板)
|
|
25
|
+
* 预判读的部署配置:`autonomy`(第三问的模式词地板)、执行车道的 home 两位(`~/` 形规则那一问)与配置根的几位(user 设置层 `/` 规则那一问)。`ServiceConfig` 结构上满足,四个问点传 `deps.config` 整份。
|
|
26
26
|
*/
|
|
27
|
-
export type StoredReplayDeployment =
|
|
27
|
+
export type StoredReplayDeployment = ExecutionConfigRootDeployment & {
|
|
28
28
|
readonly autonomy?: Autonomy | undefined;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
@@ -4,6 +4,7 @@ import { entryProblemsFacts } from "../entry-problems.js";
|
|
|
4
4
|
import { autonomyModeFloor, entryPermissionMode } from "../runtime-governance.js";
|
|
5
5
|
import { inertToolListEntryOf, replayInertEntry } from "../rule-entry-list.js";
|
|
6
6
|
import { executionLaneHomeDir } from "../execution-lane-caps.js";
|
|
7
|
+
import { executionConfigRootOf } from "../execution-config-root.js";
|
|
7
8
|
import { migrationWindowEnd } from "../plugins/one-time-migrations.js";
|
|
8
9
|
import { allowListReadingEraOf, allowListReadingUnstated, permissionModeReadingStated, retiredRequestKeyOf } from "./checkpoint-ctx.js";
|
|
9
10
|
export function permissionModeReadingUnstated(ctx, floor) {
|
|
@@ -35,7 +36,8 @@ function storedRulePolicyRefusal(body, deployment) {
|
|
|
35
36
|
if (permissions === undefined)
|
|
36
37
|
return undefined;
|
|
37
38
|
const home = executionLaneHomeDir(deployment);
|
|
38
|
-
const
|
|
39
|
+
const configRoot = executionConfigRootOf(deployment);
|
|
40
|
+
const refused = rulePolicyBucketsRefusal({ ...(Array.isArray(permissions["ask"]) ? { ask: permissions["ask"] } : {}), ...(Array.isArray(permissions["deny"]) ? { deny: permissions["deny"] } : {}) }, { ...(home !== undefined ? { home } : {}), ...(configRoot !== undefined ? { configRoot } : {}) });
|
|
39
41
|
if (refused !== undefined)
|
|
40
42
|
return replayInertEntry(`settings.permissions.${refused.bucket}`, "deny", SETTINGS_RULE_REFUSAL_CODE, `${REQUEST_SETTINGS_REFUSAL_PREFIX}${refused.message}`, { ...entryProblemsFacts(refused.problems) });
|
|
41
43
|
const neverAuto = readTightenOnlySeats({ permissions }).values.neverAuto;
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
*
|
|
19
19
|
* ## 回执两形(按提交腿)
|
|
20
20
|
* · `durable`(`POST /v1/runs`、A2A `message/send`)—— `202 { taskId, sessionId, status }`(这条腿首答的既有形);
|
|
21
|
-
* · `sync`(`POST /v1/tasks`;`/v1/tasks/stream` 把同一份体放进 `done.result`)—— `200 {
|
|
22
|
-
*
|
|
23
|
-
* `
|
|
21
|
+
* · `sync`(`POST /v1/tasks`;`/v1/tasks/stream` 把同一份体放进 `done.result`)—— `200 { …首答的信封, replay: true }`:
|
|
22
|
+
* 首答的信封由 `http/sync-submit-body.ts` 铸(`buildSyncSubmitBody`),重放经同文件的 `syncSubmitBodyOfRow` 读行 ——
|
|
23
|
+
* 终局 / 停驻行上有结果 ⇒ 与首答同形(结果的键在顶层,`result` 是串);行上没有结果可交(首投还在跑)⇒ 轮询回执 `{ taskId, sessionId, status }`。
|
|
24
|
+
* `replay: true` 是重放的判别位(本函数叠上,不在信封里)。
|
|
24
25
|
*/
|
|
25
26
|
import type { RunIdemBinding, RunRecord } from "../plugins/store-contracts.js";
|
|
26
27
|
import type { RunStore } from "../plugins/store-backend.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { runRowReadable } from "./owner-access.js";
|
|
2
|
-
import {
|
|
2
|
+
import { syncSubmitBodyOfRow } from "./sync-submit-body.js";
|
|
3
3
|
import { refusalBody } from "./refusal-body.js";
|
|
4
4
|
export function isRunExistsConflictBody(body) {
|
|
5
5
|
return typeof body === "object" && body !== null && body.errorCode === "conflict.run_exists";
|
|
@@ -19,7 +19,7 @@ export async function replayOfExistingRun(row, caller, face, deps, runStore) {
|
|
|
19
19
|
case "durable":
|
|
20
20
|
return { status: 202, body: { taskId: row.taskId, sessionId: row.sessionId, status: row.status } };
|
|
21
21
|
case "sync":
|
|
22
|
-
return { status: 200, body: { ...(
|
|
22
|
+
return { status: 200, body: { ...syncSubmitBodyOfRow(deps, row), replay: true } };
|
|
23
23
|
default: {
|
|
24
24
|
const unknown = face;
|
|
25
25
|
throw new Error(`replayOfExistingRun: unknown submit face ${String(unknown)}`);
|
|
@@ -25,14 +25,19 @@
|
|
|
25
25
|
* (`observability/run-terminal.ts`),调用方铸一次交进来;本函数只负责「体长什么样」。凭据(`paused.token` /
|
|
26
26
|
* `failed.nestedPause.token`)因此在进本函数之前就已摘掉,幂等缓存存的正是本函数的产物,重放体同体同脱。
|
|
27
27
|
*/
|
|
28
|
-
import type
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
import { type ParkedRunStatus, type PersistedTaskResult, type RunRecord } from "../plugins/store-contracts.js";
|
|
29
|
+
import { type RunFaceDeps } from "./run-read-face.js";
|
|
30
|
+
/** 同步 200 体上的 poll 回执三键:一条 run 的 poll 键、会话、对外词。park 体叠在结果之上带它({@link SyncParkReceipt});重放命中一条还没有结果可交的行时,它**就是**整个体({@link syncSubmitBodyOfRow})。 */
|
|
31
|
+
export interface SyncRunReceipt {
|
|
31
32
|
/** 同步腿提交时铸的 durable run id —— `GET /v1/runs/:taskId` 的 poll 键。 */
|
|
32
33
|
taskId: string;
|
|
33
34
|
/** 提交的会话。 */
|
|
34
35
|
sessionId: string;
|
|
35
|
-
/** 对外词 = `GET /v1/runs/:id` 行上的 `status
|
|
36
|
+
/** 对外词 = `GET /v1/runs/:id` 行上的 `status`。 */
|
|
37
|
+
status: RunRecord["status"];
|
|
38
|
+
}
|
|
39
|
+
/** park 中的 run 在同步 200 体上带的 poll 回执三键(修前 park 体的全部内容,值逐字不变);`status` 是 park 两词之一(闭集从 `RUN_STATUS_CLASS` 派生)。 */
|
|
40
|
+
export interface SyncParkReceipt extends SyncRunReceipt {
|
|
36
41
|
status: ParkedRunStatus;
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
@@ -40,4 +45,16 @@ export interface SyncParkReceipt {
|
|
|
40
45
|
* 返回的是纯数据(无方法、无闭包)⇒ `build*`。
|
|
41
46
|
*/
|
|
42
47
|
export declare function buildSyncSubmitBody<R extends PersistedTaskResult>(exitResult: R, parkReceipt?: SyncParkReceipt): R | (R & SyncParkReceipt);
|
|
48
|
+
/**
|
|
49
|
+
* **同键重放读行的出口** —— 同一条 run 的同步 200 体,首答与重放读**同一只信封**:终局行 / 停驻行上有结果 ⇒ 经 {@link buildSyncSubmitBody} 铸
|
|
50
|
+
* (终局 = 结果本身;停驻 = 结果 + 回执三键),与首答的三个 200 出口逐字同形 —— 首答恒 = 「出口封口 + 脱敏后的引擎结果」,那份对象就是落在行上的那一份
|
|
51
|
+
* (调用方铸一次、既落行又进体),重放读到的是它被读入口(同一只 {@link runRowExitResult},`GET /v1/runs/:id` 的 `result` 读的也是它)再封再脱的样子。
|
|
52
|
+
* 行上没有结果可交(首投还在跑、在别的副本上没落定;或终局行的结果已被收割清空)⇒ 首答在这一刻**不存在**,体只剩 {@link SyncRunReceipt} 三键 —— 去 `GET /v1/runs/:taskId` 轮询,
|
|
53
|
+
* 不把「读面」塞进同步体里充首答(失联折叠与读面同一只判据 {@link runRowStale}:折成 `failed`)。
|
|
54
|
+
*
|
|
55
|
+
* 首答体上另有两类**本次请求**的附注(`notice` / `warnings`,见 `routes/tasks.ts` 的 `withSyncSubmitKeys`):重放在 `prepareSpec` 之前就答了,
|
|
56
|
+
* 结构上不知道本次请求带没带 verify / cascade、放行侧选择器里有没有空条目 ⇒ 重放体没有它们。判别位 `replay: true` 由重放出口(`submit-replay.ts`)叠上,不在信封里。
|
|
57
|
+
* 纯数据 ⇒ `build*` 的近亲;名字取 `…OfRow`(行 → 体的读法),与 `buildSyncSubmitBody` 同文件同铸点。
|
|
58
|
+
*/
|
|
59
|
+
export declare function syncSubmitBodyOfRow(deps: RunFaceDeps, row: RunRecord): ReturnType<typeof buildSyncSubmitBody> | SyncRunReceipt;
|
|
43
60
|
//# sourceMappingURL=sync-submit-body.d.ts.map
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import { isParkedRunStatus, isTerminalRunStatus } from "../plugins/store-contracts.js";
|
|
2
|
+
import { runRowExitResult, runRowStale } from "./run-read-face.js";
|
|
1
3
|
export function buildSyncSubmitBody(exitResult, parkReceipt) {
|
|
2
4
|
return parkReceipt === undefined ? exitResult : { ...exitResult, ...parkReceipt };
|
|
3
5
|
}
|
|
6
|
+
export function syncSubmitBodyOfRow(deps, row) {
|
|
7
|
+
const stale = runRowStale(deps, row);
|
|
8
|
+
const exit = stale ? undefined : runRowExitResult(row);
|
|
9
|
+
if (exit !== undefined) {
|
|
10
|
+
if (isTerminalRunStatus(row.status))
|
|
11
|
+
return buildSyncSubmitBody(exit);
|
|
12
|
+
if (isParkedRunStatus(row.status))
|
|
13
|
+
return buildSyncSubmitBody(exit, { taskId: row.taskId, sessionId: row.sessionId, status: row.status });
|
|
14
|
+
}
|
|
15
|
+
return { taskId: row.taskId, sessionId: row.sessionId, status: stale ? "failed" : row.status };
|
|
16
|
+
}
|
|
4
17
|
//# sourceMappingURL=sync-submit-body.js.map
|
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
* 3. **缺席一种读法**:`null` = 这一行**没有「属主在受理时验过的凭据」的记录** —— 三列存在之前写下的行、没有任何验过凭据的受理(无鉴权写面
|
|
13
13
|
* `ALLOW_UNAUTHED_WRITES`)、以及别人替属主按下的那一跑(受理请求验过的主体不是这一行的属主:唤醒 / 决定投递铸的新一跑)。读者一律按「不合格」处置
|
|
14
14
|
* (fail-closed),不分辨三种成因;存量行不回填(没有事实可回填)。
|
|
15
|
+
* 4. **令牌声明装不进它的列就不记**(不截断:截断 = 两个不同的值折成一个):`sso` 臂从验过的令牌铸元组时,某一格装不进它的列宽({@link RUN_IDENTITY_CLAIM_COLUMNS})
|
|
16
|
+
* ⇒ 那一格「未记录」—— 可空的格(化身号)记 `null`;必填的格(scope)装不下就铸不出合形元组 ⇒ 无元组。两格结果不同来自元组的型,不是两条规则:
|
|
17
|
+
* 同一只判({@link runIdentityClaimOverflow})、同一行告警 `run_identity_claim_unrecorded { claim, chars, max }`(凭据门的铸点发;只名与长度,不带值)。
|
|
15
18
|
*
|
|
16
|
-
* 化身号 `principalInc`:令牌 `sub_inc`
|
|
17
|
-
*
|
|
19
|
+
* 化身号 `principalInc`:令牌 `sub_inc` 声明原样(契约包 `VerifiedIdentity.principalInc`)。来源链只有一条 —— 验证器读出 → 注入边界再判形(`auth-bridge.ts` 的
|
|
20
|
+
* `admitBridgeIdentity`)→ 入口预认证挂 request-local(`security.ts` 的 `setSsoPrincipalInc`)→ 凭据门 `admitRunIdentity` 的 `sso` 臂铸进元组(律 4)→ 建行原样写入。
|
|
21
|
+
* `null` 化身号只有一种读法:**未记录**(契约 §12.8「缺 ⇒ 化身号未记录」)—— 存量行、令牌没带、装不下,三种成因同一读法。
|
|
18
22
|
*/
|
|
19
23
|
/** 验过的身份来源的**闭集**(序 = 判定次序 = `/health.auth.kinds` 的出现序;加一个来源 = 加一个词,读它的各只穷举 `switch` 不接就编译红)。 */
|
|
20
24
|
export declare const IDENTITY_SOURCES: readonly ["service_token", "sso", "direct_door_jwt"];
|
|
@@ -36,6 +40,21 @@ export type RunIdentity = {
|
|
|
36
40
|
export declare const RUN_IDENTITY_SCOPE_MAX_CHARS = 190;
|
|
37
41
|
/** `identity_principal_inc` 的列宽(字符):化身号是签发方插入时铸的不透明随机串(与会话化身同宽)。 */
|
|
38
42
|
export declare const RUN_IDENTITY_PRINCIPAL_INC_MAX_CHARS = 64;
|
|
43
|
+
/** 令牌声明 → 它落的那一列的列宽(字符;律 4 的判读这一张)。 */
|
|
44
|
+
export declare const RUN_IDENTITY_CLAIM_COLUMNS: {
|
|
45
|
+
readonly scope: 190;
|
|
46
|
+
readonly principalInc: 64;
|
|
47
|
+
};
|
|
48
|
+
export type RunIdentityClaim = keyof typeof RUN_IDENTITY_CLAIM_COLUMNS;
|
|
49
|
+
/**
|
|
50
|
+
* 律 4 的判:这一格令牌声明装不装得进它的列(按码点数,与两方言 VARCHAR 同口径)。装得下 ⇒ `undefined`;装不下 ⇒ 告警行 `run_identity_claim_unrecorded` 的载荷
|
|
51
|
+
* (`claim` 名 + 码点数 + 列宽,不带值)。调用方按格的型处置:可空格记 `null`,必填格无元组。
|
|
52
|
+
*/
|
|
53
|
+
export declare function runIdentityClaimOverflow(claim: RunIdentityClaim, value: string): {
|
|
54
|
+
readonly claim: RunIdentityClaim;
|
|
55
|
+
readonly chars: number;
|
|
56
|
+
readonly max: number;
|
|
57
|
+
} | undefined;
|
|
39
58
|
/**
|
|
40
59
|
* `task_run` 三列的列定义 —— 两方言各一段,**唯一属主**:中央建表语句(`tidb-pool.ts` / `pg-pool.ts` 的 `CREATE TABLE task_run`)内插这同一段;
|
|
41
60
|
* 存量库缺列时起服列册对账(`schema-consistency.ts`)拒启,拒句里的 `ALTER TABLE task_run ADD COLUMN …` 由同一份建表语句解析生成 ⇒
|
package/dist/identity-source.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export const IDENTITY_SOURCES = ["service_token", "sso", "direct_door_jwt"];
|
|
2
2
|
export const RUN_IDENTITY_SCOPE_MAX_CHARS = 190;
|
|
3
3
|
export const RUN_IDENTITY_PRINCIPAL_INC_MAX_CHARS = 64;
|
|
4
|
+
export const RUN_IDENTITY_CLAIM_COLUMNS = { scope: RUN_IDENTITY_SCOPE_MAX_CHARS, principalInc: RUN_IDENTITY_PRINCIPAL_INC_MAX_CHARS };
|
|
5
|
+
export function runIdentityClaimOverflow(claim, value) {
|
|
6
|
+
const chars = [...value].length;
|
|
7
|
+
const max = RUN_IDENTITY_CLAIM_COLUMNS[claim];
|
|
8
|
+
return chars > max ? { claim, chars, max } : undefined;
|
|
9
|
+
}
|
|
4
10
|
export const RUN_IDENTITY_COLUMNS = {
|
|
5
11
|
mysql: [
|
|
6
12
|
"identity_source VARCHAR(32) NULL",
|
|
@@ -79,8 +79,15 @@ export declare function createInstructionSourceSeat(sessionStore: unknown, emit:
|
|
|
79
79
|
* 超时**(codex che-NM r2 [high];S-9 `write-behind-counter.ts` 先例:mysql2 `{sql, timeout}` / pg `query_timeout`,pg-pool
|
|
80
80
|
* 超时即销毁那条连接)—— 只放手不截断,卡住的查询会一直占着池里的连接。超期后仍在飞的写由 CAS 挡住,不会盖掉更新的基线。
|
|
81
81
|
* 数值与 core 给 `probeInstructionSources` 的 2s 天花板同量级:一行 PK 读写在健康库上是毫秒级。
|
|
82
|
+
* 第二个读者:回退锚写入(`runs.ts` 的 `settleResumeAnchor`)—— 同为单行 PK 写、同在腿的关键路径上(流式腿的终帧等它),
|
|
83
|
+
* 同为披露类(F)放手,所以读同一只数、同一只 {@link withinIoDeadline}。
|
|
82
84
|
*/
|
|
83
85
|
export declare const BASELINE_IO_DEADLINE_MS = 2000;
|
|
86
|
+
/** {@link withinIoDeadline} 到点放手。**具名型**:调用方据它分诊「超期」与「店报错」,不比对文案。 */
|
|
87
|
+
export declare class IoDeadlineExceeded extends Error {
|
|
88
|
+
}
|
|
89
|
+
/** 单行店操作的有界等待:`op` 在 {@link BASELINE_IO_DEADLINE_MS} 内落定就原样交出,否则 reject {@link IoDeadlineExceeded}。只放手不取消 —— 超期后仍在飞的那次操作照常落定(迟到的 reject 被吞,不成未处理拒绝)。 */
|
|
90
|
+
export declare function withinIoDeadline<T>(op: () => Promise<T>): Promise<T>;
|
|
84
91
|
/**
|
|
85
92
|
* **唯一铸点**:本次 prepare 选中的来源 `current`(链成员相对路径;没有 = `null`)与基线比。
|
|
86
93
|
* · 没有基线 ⇒ 只写不发(新会话首 run);
|
|
@@ -27,14 +27,14 @@ export function createInstructionSourceSeat(sessionStore, emit) {
|
|
|
27
27
|
}
|
|
28
28
|
const describeSource = (source) => source ?? "no project instruction file";
|
|
29
29
|
export const BASELINE_IO_DEADLINE_MS = 2_000;
|
|
30
|
-
class
|
|
30
|
+
export class IoDeadlineExceeded extends Error {
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
export function withinIoDeadline(op) {
|
|
33
33
|
const running = Promise.resolve().then(op);
|
|
34
34
|
running.catch(() => undefined);
|
|
35
35
|
let timer;
|
|
36
36
|
const deadline = new Promise((_, reject) => {
|
|
37
|
-
timer = setTimeout(() => reject(new
|
|
37
|
+
timer = setTimeout(() => reject(new IoDeadlineExceeded(`no answer within ${BASELINE_IO_DEADLINE_MS}ms`)), BASELINE_IO_DEADLINE_MS);
|
|
38
38
|
timer.unref?.();
|
|
39
39
|
});
|
|
40
40
|
return Promise.race([running, deadline]).finally(() => clearTimeout(timer));
|
|
@@ -42,7 +42,7 @@ function withinDeadline(op) {
|
|
|
42
42
|
export async function announceInstructionSource(seat, sessionId, current) {
|
|
43
43
|
let baseline;
|
|
44
44
|
try {
|
|
45
|
-
baseline = await
|
|
45
|
+
baseline = await withinIoDeadline(() => seat.store.readInstructionSource(sessionId));
|
|
46
46
|
}
|
|
47
47
|
catch (e) {
|
|
48
48
|
degraded("read", sessionId, e);
|
|
@@ -65,14 +65,14 @@ export async function announceInstructionSource(seat, sessionId, current) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
try {
|
|
68
|
-
await
|
|
68
|
+
await withinIoDeadline(() => seat.store.recordInstructionSource(sessionId, baseline, current));
|
|
69
69
|
}
|
|
70
70
|
catch (e) {
|
|
71
71
|
degraded("write", sessionId, e);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
function degraded(op, sessionId, e) {
|
|
75
|
-
const why = e instanceof
|
|
75
|
+
const why = e instanceof IoDeadlineExceeded ? `timeout=${BASELINE_IO_DEADLINE_MS}ms` : `err=${e instanceof Error ? e.message : String(e)}`;
|
|
76
76
|
recordFailOpen("server.instruction-source.announce-degraded", `op=${op} session=${sessionId} ${why}`);
|
|
77
77
|
}
|
|
78
78
|
//# sourceMappingURL=instruction-source-notice.js.map
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
import type { McpServerSpec } from "@sema-agent/core";
|
|
37
37
|
import type { RequestMcpTransport } from "@sema-agent/settings-schema";
|
|
38
38
|
import type { McpDraft } from "./peer-seat.js";
|
|
39
|
+
/** 请求面 `transport.kind` 的种类词(契约包请求传输形的判别键):`GET /v1/capabilities.mcpTransportKinds` 的元素型,也是自铸登记表 `mcpTransportKind` 集的键型。 */
|
|
40
|
+
export type McpRequestTransportKind = RequestMcpTransport["kind"];
|
|
39
41
|
/** 请求面 stdio 传输的形(契约包):引擎的 stdio 传输去掉凭据引用位、加上 `env`(件)。 */
|
|
40
42
|
export type RequestStdioMcpTransport = Extract<RequestMcpTransport, {
|
|
41
43
|
kind: "stdio";
|
|
@@ -66,6 +68,8 @@ export declare const MCP_HTTP_TRANSPORT_DISPOSITION: {
|
|
|
66
68
|
readonly principalHeader: "engine";
|
|
67
69
|
readonly url: "engine";
|
|
68
70
|
};
|
|
71
|
+
/** 位的值:请求面读器的传输种类(书写序 = 表序,冻结;能力位每次响应取一份拷贝)。 */
|
|
72
|
+
export declare const MCP_REQUEST_TRANSPORT_KINDS: readonly McpRequestTransportKind[];
|
|
69
73
|
/**
|
|
70
74
|
* 请求面条目 → 草稿:传输按它那一臂的处置表拆(`env` / `headers` 进件,`assertionHeader` 两边都不进,其余进声明);条目层的键原样进声明。件缺席或空 ⇒ 草稿不带件(登记时什么都不留)。
|
|
71
75
|
* 纯函数:不登记、不读部署状态;被扣下的 `assertionHeader` 由调用方另说一行 info。
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { splitDeclaration } from "./plain-string-record.js";
|
|
2
2
|
export const MCP_STDIO_TRANSPORT_DISPOSITION = { args: "engine", command: "engine", env: "seat", kind: "engine" };
|
|
3
3
|
export const MCP_HTTP_TRANSPORT_DISPOSITION = { assertionHeader: "withheld", headers: "seat", kind: "engine", principalHeader: "engine", url: "engine" };
|
|
4
|
+
const MCP_REQUEST_TRANSPORT_ARMS = {
|
|
5
|
+
stdio: MCP_STDIO_TRANSPORT_DISPOSITION,
|
|
6
|
+
http: MCP_HTTP_TRANSPORT_DISPOSITION,
|
|
7
|
+
};
|
|
8
|
+
export const MCP_REQUEST_TRANSPORT_KINDS = Object.freeze(Object.keys(MCP_REQUEST_TRANSPORT_ARMS));
|
|
4
9
|
export function toMcpDraft(spec) {
|
|
5
10
|
const { transport, ...entry } = spec;
|
|
6
11
|
const split = transport.kind === "http" ? splitDeclaration(transport, MCP_HTTP_TRANSPORT_DISPOSITION) : splitDeclaration(transport, MCP_STDIO_TRANSPORT_DISPOSITION);
|
|
@@ -14,14 +14,17 @@
|
|
|
14
14
|
* consolidation),run-local 腿把整族印成 `engine_error` 并用 `String(err)` 抹掉 `err.code`。
|
|
15
15
|
*
|
|
16
16
|
* ## 形(一处定义,四处引用)
|
|
17
|
-
* `memory_engine_incident` + `{ sessionId?, code
|
|
17
|
+
* `memory_engine_incident` + `{ sessionId?, code?, detail }`,并计 `memory_engine_incident_total{code?}`。
|
|
18
18
|
* 🔴 `code` 是**结构化字段**而不是被折进散文:它是运维唯一能按名告警的那一位,而这一族里最要紧的几条
|
|
19
|
-
* (一次性布局搬家、无主根内容、控制面写失败)一辈子只发生一次 ——
|
|
20
|
-
*
|
|
19
|
+
* (一次性布局搬家、无主根内容、控制面写失败)一辈子只发生一次 —— 折平就等于没说。
|
|
20
|
+
* 码的读法与 `boot/runner-deps.ts` 的 `onError` 汇点其余七条行**同一只**(`terminal.ts` 的 `codeFieldOf`:不抛的读口 + 码判官 `isCodeToken`):是码才带;
|
|
21
|
+
* 无码(core 里有大量不带 `.code` 的记忆相 Error)、不是串 / 空串、非 `Error` 抛出物、读取时抛、或带的不是码(超长 / 含空白 / 凭据形 —— 引擎错上的 `code` 是别人写的串)⇒ 行里**没有** `code` 键、
|
|
22
|
+
* 计数**没有** `code` 标签:不编码,也不写 `null` / `"none"` 之类的占位。
|
|
21
23
|
*
|
|
22
|
-
* ⚠️
|
|
23
|
-
* `memory_consolidation_incident`)
|
|
24
|
-
*
|
|
24
|
+
* ⚠️ 与三只 **operator 面**引擎座(`memory_compliance_incident` / `memory_origin_incident` /
|
|
25
|
+
* `memory_consolidation_incident`)**事件名刻意不合并**:那三条的事件名回答「哪一张操作面」,是三个产品面的
|
|
26
|
+
* 分辨位;本工厂回答「引擎事故席」,是同一件事的四个落点。合并会丢掉前者的分辨位。三座有自己的工厂
|
|
27
|
+
* {@link createOperatorFaceIncidentSink}(事件名由装配处点名),`code` 位与本工厂读同一只 `codeFieldOf`。
|
|
25
28
|
*/
|
|
26
29
|
import type { Logger } from "./observability/logger.js";
|
|
27
30
|
import type { Metrics } from "./observability/metrics.js";
|
|
@@ -34,4 +37,14 @@ export interface MemoryEngineIncidentSinkDeps {
|
|
|
34
37
|
export declare function createMemoryEngineIncidentSink(deps: MemoryEngineIncidentSinkDeps): (err: unknown, ctx?: {
|
|
35
38
|
sessionId?: string;
|
|
36
39
|
}) => void;
|
|
40
|
+
/** 三只 operator 面引擎座的事件名(闭集):事件名回答「哪一张操作面」—— 出处 / 抹除合规 · 外源标记人面 · 整理三面,由装配处点名。 */
|
|
41
|
+
export type OperatorFaceIncidentEvent = "memory_compliance_incident" | "memory_origin_incident" | "memory_consolidation_incident";
|
|
42
|
+
/**
|
|
43
|
+
* operator 面引擎座(各面工厂的 `onIncident` 形参:`(err: Error & { code?: string }) => void`)的唯一落点形:`<事件名>` + `{ code?, detail }`。
|
|
44
|
+
* 这三座此前各在装配处写一份 `{ code: err.code ?? null, detail }` —— 引擎错上的 `code` 是别人写的串,什么都照写(凭据形也进行),无码写 `null` 占位;
|
|
45
|
+
* 现在 `code` 位读 `codeFieldOf`(与 `onError` 汇点其余各行、{@link createMemoryEngineIncidentSink} 同一只):是码才带,其余键缺席;`detail` 句只经运维文本座。
|
|
46
|
+
*/
|
|
47
|
+
export declare function createOperatorFaceIncidentSink(deps: Pick<MemoryEngineIncidentSinkDeps, "logger">, event: OperatorFaceIncidentEvent): (err: Error & {
|
|
48
|
+
code?: string;
|
|
49
|
+
}) => void;
|
|
37
50
|
//# sourceMappingURL=memory-incident-sink.d.ts.map
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { redactIncarnations } from "./session-incarnation.js";
|
|
2
|
+
import { codeFieldOf } from "./terminal.js";
|
|
3
|
+
import { seatText } from "./trace/exit-seat.js";
|
|
2
4
|
export function createMemoryEngineIncidentSink(deps) {
|
|
3
5
|
return (err, ctx) => {
|
|
4
|
-
const
|
|
5
|
-
const codeText = typeof code === "string" && code !== "" ? code : undefined;
|
|
6
|
+
const codeField = codeFieldOf(err);
|
|
6
7
|
deps.logger.warn("memory_engine_incident", {
|
|
7
8
|
...(ctx?.sessionId !== undefined ? { sessionId: ctx.sessionId } : {}),
|
|
8
|
-
|
|
9
|
+
...codeField,
|
|
9
10
|
detail: redactIncarnations(String(err)),
|
|
10
11
|
});
|
|
11
|
-
deps.metrics?.inc("memory_engine_incident_total", {
|
|
12
|
+
deps.metrics?.inc("memory_engine_incident_total", { ...codeField });
|
|
12
13
|
};
|
|
13
14
|
}
|
|
15
|
+
export function createOperatorFaceIncidentSink(deps, event) {
|
|
16
|
+
return (err) => deps.logger.warn(event, { ...codeFieldOf(err), detail: seatText("operator-log-text", err.message) });
|
|
17
|
+
}
|
|
14
18
|
//# sourceMappingURL=memory-incident-sink.js.map
|
package/dist/memory-posture.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type MemoryVectorRung = "native" | "portable" | "lexical";
|
|
|
29
29
|
export type MemoryDarkReason =
|
|
30
30
|
/** operator 显式关停(`MEMORY_ENGINE=off`)。 */
|
|
31
31
|
"engine_off"
|
|
32
|
-
/** 多租户 + file 底座:file 基座无租户隔离,fail-closed 不点亮(改 `MEMORY_ENGINE_BACKEND=pg|
|
|
32
|
+
/** 多租户 + file 底座:file 基座无租户隔离,fail-closed 不点亮(改 `MEMORY_ENGINE_BACKEND=pg|mysql`)。 */
|
|
33
33
|
| "multi_tenant_file_backend"
|
|
34
34
|
/** 平面分裂车道:模型的文件工具在沙箱 fs、引擎在 worker fs,harvest 看不到沙箱写入 ⇒ fail-closed。 */
|
|
35
35
|
| "remote_lane_split";
|
package/dist/memory-scope.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare function memoryLayersNamedBy(config: Pick<ServiceConfig, "require
|
|
|
46
46
|
* **读列表的第二层**,不是写家:写家是该任务的**项目层**,由 {@link memoryProjectKeyFor} 按任务根派生、经
|
|
47
47
|
* {@link memorySpecForRequest} 的 `projectKey` 位铸进 spec(读 = [项目, 本 scope],`writeScope` 显式 = 项目)。
|
|
48
48
|
* 本函数在授权期调(还不知道任务根),所以项目层不在这里。
|
|
49
|
-
* ② MULTI-TENANT + DB 后端(`requirePrincipal === true` ∧ `memoryEngineBackend` ∈ {`pg`, `
|
|
49
|
+
* ② MULTI-TENANT + DB 后端(`requirePrincipal === true` ∧ `memoryEngineBackend` ∈ {`pg`, `mysql`}):按**验过的**
|
|
50
50
|
* principal 铸 v2 typed 键 —— 无 projectId ⇒ `user:<tenant>`(core `formatUserScope`),有形状合法的
|
|
51
51
|
* projectId ⇒ `proj:<tenant>/<projectId>`(core `formatProjScope`);principal 缺席(匿名 run)⇒ `undefined`
|
|
52
52
|
* (无记忆)。scope 列是租户分区,授权就是「验过的 principal 进、一个租户的 scope 出」这一绑定;身份永远不来自
|
|
@@ -128,7 +128,7 @@ export declare function memoryEngineRemoteLanePosture(config: ServiceConfig): {
|
|
|
128
128
|
* N0 启动告警的**文案**(纯,可单测;boot/stores.ts 的装配点只负责喂「引擎这一腿真的接上了吗」并打日志)。
|
|
129
129
|
*
|
|
130
130
|
* 为什么要按引擎真身分腿(2026-08-12 复扫,已核真):{@link memoryEngineRemoteLanePosture} 的 `dark` 只对
|
|
131
|
-
* **file** 引擎腿有裁决权 —— 车道门的唯一消费者是 {@link memoryEngineBackendFor}。`MEMORY_ENGINE_BACKEND=pg|
|
|
131
|
+
* **file** 引擎腿有裁决权 —— 车道门的唯一消费者是 {@link memoryEngineBackendFor}。`MEMORY_ENGINE_BACKEND=pg|mysql`
|
|
132
132
|
* 的两条腿在 boot/stores.ts 里**先于**任何车道判断就被点亮(库是持久真身,与手的文件平面无关),于是同一次
|
|
133
133
|
* 启动会先打 `memory_engine_enabled {enabled:true, backend:"pg"}`,几行之后再打一句「memory dark
|
|
134
134
|
* (fail-closed) … Set MEMORY_ENGINE_REMOTE_LANE=allow」—— 两句直接对撞,而且把运维指向一个在该腿上**不接线**
|
|
@@ -172,13 +172,13 @@ engineWired: boolean): {
|
|
|
172
172
|
* (壳布局 `~/.sema/engine-data`)」时分家 ⇒ 记忆库每一次 Write 被硬拒(7.58.0 放行 ⇒ 回归);反向
|
|
173
173
|
* (`CONFIG_LOCAL_DIR=~/.sema` 当 dataRoot)则让配置根自身免检。两根本就是两件事:店根归誊本门,引擎根归本函数。
|
|
174
174
|
*
|
|
175
|
-
* 形与 boot/stores.ts 逐字同律:DB 记忆腿(pg/
|
|
175
|
+
* 形与 boot/stores.ts 逐字同律:DB 记忆腿(pg/mysql)的根 = `<localDataRoot ?? localRoot>/memory-work`
|
|
176
176
|
* (per-worker 物化区);file 腿 = boot file 后端的链 `resolveMemoryEngineRoot(memoryEngineDir)`。**不判引擎是否
|
|
177
177
|
* 启用**——纯路径推导,禁用态下豁免根仍以「若开引擎会写到哪」为根(boot 的 `engineDataRoot` 恒铸,经共享基座交每只 Runner)。
|
|
178
178
|
*/
|
|
179
179
|
export declare function memoryEngineRootFor(config: Pick<ServiceConfig, "memoryEngineBackend" | "memoryEngineDir" | "localDataRoot">, localRoot?: string): string;
|
|
180
180
|
/** file 后端的根链(`MEMORY_ENGINE_DIR ?? fallback ?? $AGENT_DATA_DIR ?? ~/.ai-agent`)—— 与后端选择器**无关**:
|
|
181
|
-
* `memoryEngineBackendFor` 恒造 file 后端(run-local 从 env 继承 `MEMORY_ENGINE_BACKEND=pg|
|
|
181
|
+
* `memoryEngineBackendFor` 恒造 file 后端(run-local 从 env 继承 `MEMORY_ENGINE_BACKEND=pg|mysql` 时仍是 file),
|
|
182
182
|
* 所以它的根必须走这条链而不是 `memoryEngineRootFor` 的分派(codex 修复验证轮 [medium]:分派会把 run-local 的
|
|
183
183
|
* 记忆搬到 `<localDataRoot>/memory-work`,存量记忆与控制面升级后隐形)。 */
|
|
184
184
|
export declare function fileMemoryEngineRoot(config: Pick<ServiceConfig, "memoryEngineDir">, fallbackRoot?: string): string;
|
package/dist/memory-scope.js
CHANGED
|
@@ -29,7 +29,7 @@ export function memoryLayersNamedBy(config) {
|
|
|
29
29
|
export { MEMORY_SCOPE_COLUMN_CHARS, assertMemoryScopeWidth } from "./plugins/memory-key-guards.js";
|
|
30
30
|
export function memoryScopeFor(config, principal, projectId) {
|
|
31
31
|
if (config.requirePrincipal === true) {
|
|
32
|
-
if (config.memoryEngineBackend === "pg" || config.memoryEngineBackend === "
|
|
32
|
+
if (config.memoryEngineBackend === "pg" || config.memoryEngineBackend === "mysql") {
|
|
33
33
|
if (!principal)
|
|
34
34
|
return undefined;
|
|
35
35
|
const scope = projectId ? formatProjScope(principal, projectId) : formatUserScope(principal);
|