@sema-agent/server 7.132.0 → 7.133.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 +266 -0
- package/README.md +8 -9
- package/README.zh-CN.md +7 -6
- package/USAGE.md +174 -55
- package/deploy/sema-up/README.md +19 -1
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -2
- package/deploy/sema-up/chart/templates/server.yaml +5 -2
- package/deploy/sema-up/stack/compose.yaml +3 -0
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -2
- package/dist/adoption/plan.d.ts +3 -2
- package/dist/adoption/plan.js +7 -5
- package/dist/adoption/runner.js +3 -10
- package/dist/adoption/sql.d.ts +3 -2
- package/dist/adoption/sql.js +3 -5
- package/dist/adoption/wire.d.ts +4 -1
- package/dist/adoption/wire.js +1 -0
- package/dist/approval-ask-audit-store.d.ts +31 -13
- package/dist/approval-ask-audit-store.js +272 -74
- package/dist/approval-ask-machine.d.ts +15 -0
- package/dist/approval-ask-machine.js +6 -0
- package/dist/approval-ask-retention.d.ts +136 -0
- package/dist/approval-ask-retention.js +102 -0
- package/dist/approval-card.d.ts +79 -19
- package/dist/approval-card.js +44 -13
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval.d.ts +9 -0
- package/dist/approval.js +24 -3
- package/dist/audit.d.ts +27 -10
- package/dist/audit.js +12 -16
- package/dist/bake-runner/main.js +3 -2
- package/dist/boot/deferred-sandbox-path-env.js +1 -1
- package/dist/boot/execution-env.js +9 -7
- package/dist/boot/execution-lane.js +11 -0
- package/dist/boot/leader.js +2 -0
- package/dist/boot/memory-boundary.js +2 -2
- package/dist/boot/memory-consolidation.d.ts +5 -4
- package/dist/boot/memory-consolidation.js +7 -6
- package/dist/boot/org-delivery.d.ts +28 -0
- package/dist/boot/org-delivery.js +20 -0
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +21 -1
- package/dist/boot/resolve-spec.d.ts +3 -0
- package/dist/boot/resolve-spec.js +60 -81
- package/dist/boot/runner-deps.js +1 -0
- package/dist/boot/session-faces.d.ts +1 -0
- package/dist/boot/session-faces.js +4 -2
- package/dist/boot/stage-02-web-admin-pull.js +4 -1
- package/dist/boot/stage-06-runners.d.ts +2 -0
- package/dist/boot/stage-06-runners.js +6 -3
- package/dist/boot/stage-07-capability-layer.d.ts +2 -0
- package/dist/boot/stage-07-capability-layer.js +24 -3
- package/dist/boot/stage-08-reapers.d.ts +2 -0
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +3 -0
- package/dist/boot/stage-10-http-server.d.ts +3 -0
- package/dist/boot/stage-10-http-server.js +5 -6
- package/dist/boot/stores.js +2 -2
- package/dist/boot/web-admin.d.ts +4 -0
- package/dist/boot/web-admin.js +151 -63
- package/dist/boot/workflow-orchestration.d.ts +2 -0
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/brain.js +8 -3
- package/dist/breaker-key.d.ts +6 -0
- package/dist/breaker-key.js +29 -0
- package/dist/caller-text-echo.d.ts +9 -6
- package/dist/caller-text-echo.js +8 -11
- package/dist/capabilities/center-plugins.d.ts +7 -0
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +21 -0
- package/dist/capabilities/hands-lane.js +10 -0
- package/dist/capabilities/mcp-probe.d.ts +36 -4
- package/dist/capabilities/mcp-probe.js +27 -4
- package/dist/capabilities/scenarios.d.ts +63 -7
- package/dist/capabilities/scenarios.js +39 -7
- package/dist/capability-facts.d.ts +34 -4
- package/dist/capability-facts.js +28 -2
- package/dist/center-config-tier.d.ts +69 -0
- package/dist/center-config-tier.js +42 -0
- package/dist/checkpoint-identity.d.ts +16 -0
- package/dist/checkpoint-identity.js +19 -0
- package/dist/config-catalog.d.ts +17 -10
- package/dist/config-catalog.js +43 -28
- package/dist/config-d-migration.d.ts +3 -1
- package/dist/config-d-migration.js +2 -2
- package/dist/config-dir-trust.d.ts +114 -0
- package/dist/config-dir-trust.js +388 -0
- package/dist/config-invariants.d.ts +18 -5
- package/dist/config-invariants.js +35 -3
- package/dist/config-provider.d.ts +6 -1
- package/dist/config-provider.js +6 -2
- package/dist/config-types.d.ts +71 -14
- package/dist/config-types.js +8 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +121 -59
- package/dist/delegated-session-owner.d.ts +185 -0
- package/dist/delegated-session-owner.js +119 -0
- package/dist/device-protocol.d.ts +5 -3
- package/dist/device-protocol.js +1 -1
- package/dist/device-ws-hub.js +21 -2
- package/dist/device-ws-protocol.d.ts +70 -6
- package/dist/device-ws-protocol.js +50 -23
- package/dist/elicitation.js +3 -2
- package/dist/entry-problems.d.ts +34 -0
- package/dist/entry-problems.js +14 -0
- package/dist/execution-lane-caps.d.ts +49 -10
- package/dist/execution-lane-caps.js +43 -4
- package/dist/field-conflict.d.ts +43 -0
- package/dist/field-conflict.js +20 -0
- package/dist/fleet/fleet-bus.d.ts +80 -6
- package/dist/fleet/fleet-bus.js +41 -9
- package/dist/hooks/classic-stations.d.ts +10 -5
- package/dist/hooks/classic-stations.js +4 -4
- package/dist/hooks/command-spawn.d.ts +57 -0
- package/dist/hooks/command-spawn.js +139 -0
- package/dist/hooks/hook-llm.js +2 -2
- package/dist/hooks/hook-runner.d.ts +127 -25
- package/dist/hooks/hook-runner.js +668 -287
- package/dist/hooks/hook-source.d.ts +44 -0
- package/dist/hooks/hook-source.js +40 -0
- package/dist/http/active-run-conflict.d.ts +5 -13
- package/dist/http/active-run-conflict.js +17 -27
- package/dist/http/admission.js +103 -60
- package/dist/http/approval-sweeps.js +55 -18
- package/dist/http/caller-trust.d.ts +77 -0
- package/dist/http/caller-trust.js +143 -0
- package/dist/http/checkpoint-ctx.d.ts +16 -16
- package/dist/http/checkpoint-ctx.js +13 -10
- package/dist/http/claimed-run.d.ts +4 -3
- package/dist/http/device-placement.d.ts +2 -4
- package/dist/http/device-placement.js +2 -1
- package/dist/http/dispatch.js +10 -4
- package/dist/http/durable-run-leg.d.ts +4 -32
- package/dist/http/durable-run-leg.js +34 -10
- package/dist/http/owner-access.d.ts +56 -0
- package/dist/http/owner-access.js +42 -0
- package/dist/http/principal-gate.d.ts +48 -23
- package/dist/http/principal-gate.js +39 -12
- package/dist/http/readiness.d.ts +11 -5
- package/dist/http/readiness.js +10 -3
- package/dist/http/request-guards.d.ts +16 -23
- package/dist/http/request-guards.js +30 -15
- package/dist/http/resume-ctx-read.d.ts +2 -5
- package/dist/http/resume-ctx-read.js +7 -4
- package/dist/http/resume-legs.d.ts +3 -4
- package/dist/http/resume-legs.js +126 -69
- package/dist/http/retired-service-deps.d.ts +43 -0
- package/dist/http/retired-service-deps.js +18 -0
- package/dist/http/route-ctx.d.ts +44 -28
- package/dist/http/route-ctx.js +4 -0
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/a2a-serve.js +3 -4
- package/dist/http/routes/admin-config-refresh.js +1 -1
- package/dist/http/routes/admin-drain.js +1 -1
- package/dist/http/routes/admin-memory-optout.js +5 -1
- package/dist/http/routes/adoption.js +2 -9
- package/dist/http/routes/approvals-assistant.js +49 -48
- package/dist/http/routes/background.js +3 -2
- package/dist/http/routes/capabilities.js +20 -4
- package/dist/http/routes/config-catalog.d.ts +3 -3
- package/dist/http/routes/config-catalog.js +1 -1
- package/dist/http/routes/devices.js +3 -17
- package/dist/http/routes/diagnostics.js +5 -1
- package/dist/http/routes/images.js +6 -7
- package/dist/http/routes/leader.js +1 -8
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +3 -2
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-consolidation.js +1 -1
- package/dist/http/routes/memory-origin.js +1 -1
- package/dist/http/routes/memory-policy.d.ts +1 -1
- package/dist/http/routes/memory-policy.js +3 -2
- package/dist/http/routes/notify-wake.js +8 -21
- package/dist/http/routes/observability.js +2 -2
- package/dist/http/routes/principal-inbox.d.ts +39 -0
- package/dist/http/routes/principal-inbox.js +76 -0
- package/dist/http/routes/retention-ops.js +2 -9
- package/dist/http/routes/rules.js +5 -18
- package/dist/http/routes/runs.d.ts +5 -0
- package/dist/http/routes/runs.js +33 -106
- package/dist/http/routes/session-sync.js +15 -28
- package/dist/http/routes/sessions.js +30 -40
- package/dist/http/routes/side-query.js +6 -4
- package/dist/http/routes/tasks.js +50 -14
- package/dist/http/routes/workflows.d.ts +351 -0
- package/dist/http/routes/workflows.js +153 -119
- package/dist/http/send.d.ts +24 -3
- package/dist/http/send.js +14 -2
- package/dist/http/server.d.ts +17 -18
- package/dist/http/server.js +15 -13
- package/dist/http/stored-body-replay.js +17 -4
- package/dist/http/submit-ctx.js +4 -3
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +5 -4
- package/dist/http/wire-types.d.ts +10 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/dist/lane-home-probe.d.ts +78 -9
- package/dist/lane-home-probe.js +78 -12
- package/dist/leader/endpoint.d.ts +4 -1
- package/dist/leader/endpoint.js +11 -10
- package/dist/limit-refusal.d.ts +17 -5
- package/dist/limit-refusal.js +4 -1
- package/dist/mcp-assertion-header.d.ts +31 -10
- package/dist/mcp-assertion-header.js +10 -3
- package/dist/mcp-tool-faces.js +1 -3
- package/dist/memory-project-layer.d.ts +37 -0
- package/dist/memory-project-layer.js +46 -0
- package/dist/memory-scope.d.ts +23 -16
- package/dist/memory-scope.js +24 -8
- package/dist/memory-sync-client.d.ts +27 -13
- package/dist/memory-sync-client.js +107 -18
- package/dist/model-entry-refusal.d.ts +9 -1
- package/dist/model-entry-refusal.js +6 -1
- package/dist/model-plane-face.d.ts +51 -0
- package/dist/model-plane-face.js +24 -0
- package/dist/model-provider.d.ts +5 -0
- package/dist/model-provider.js +4 -2
- package/dist/model-route-endpoint.d.ts +8 -11
- package/dist/model-route-endpoint.js +4 -7
- package/dist/model-route-env.d.ts +22 -0
- package/dist/model-route-env.js +2 -0
- package/dist/model-route-gap.d.ts +60 -30
- package/dist/model-route-gap.js +21 -15
- package/dist/observability/corrupt-read-seat.d.ts +7 -0
- package/dist/observability/corrupt-read-seat.js +9 -0
- package/dist/observability/err-text.d.ts +6 -0
- package/dist/observability/err-text.js +18 -4
- package/dist/observability/fail-open.d.ts +35 -9
- package/dist/observability/fail-open.js +35 -9
- package/dist/observability/metrics.js +1 -0
- package/dist/observability/prompt-manifest.d.ts +3 -17
- package/dist/observability/prompt-manifest.js +45 -42
- package/dist/observability/tool-trace.js +9 -9
- package/dist/operator-ask.d.ts +10 -0
- package/dist/operator-ask.js +3 -0
- package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
- package/dist/orchestration/workflow-agent-session-index.js +9 -13
- package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
- package/dist/orchestration/workflow-completion-inbox.js +13 -0
- package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
- package/dist/orchestration/workflow-notify-journal.js +27 -34
- package/dist/orchestration/workflow-park-decision.d.ts +89 -0
- package/dist/orchestration/workflow-park-decision.js +118 -0
- package/dist/org-delivery-gate.d.ts +81 -0
- package/dist/org-delivery-gate.js +59 -0
- package/dist/panel-tool-names.d.ts +23 -0
- package/dist/panel-tool-names.js +8 -0
- package/dist/parked-decide.d.ts +39 -6
- package/dist/parked-decide.js +98 -51
- package/dist/parked-revive-surface.d.ts +9 -2
- package/dist/parked-revive-surface.js +11 -8
- package/dist/permission-rule-list.d.ts +1 -1
- package/dist/permission-rule-list.js +2 -2
- package/dist/plugins/approval-ask-store-file.d.ts +16 -1
- package/dist/plugins/approval-ask-store-file.js +21 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
- package/dist/plugins/approval-ask-store-memory.js +34 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
- package/dist/plugins/approval-ask-store-sql.js +37 -1
- package/dist/plugins/blob-backend.d.ts +38 -25
- package/dist/plugins/blob-backend.js +29 -19
- package/dist/plugins/breaker-state-sql.d.ts +2 -2
- package/dist/plugins/breaker-state-sql.js +4 -4
- package/dist/plugins/caching-session-store.d.ts +3 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +14 -0
- package/dist/plugins/checkpoint-store-sql.js +20 -2
- package/dist/plugins/file-history-store-sql.d.ts +5 -2
- package/dist/plugins/file-history-store-sql.js +3 -1
- package/dist/plugins/file-run-store.d.ts +5 -13
- package/dist/plugins/file-run-store.js +9 -0
- package/dist/plugins/fork-routing-session-store.d.ts +9 -1
- package/dist/plugins/fork-routing-session-store.js +12 -1
- package/dist/plugins/host-platform.d.ts +2 -0
- package/dist/plugins/host-platform.js +2 -1
- package/dist/plugins/local-checkpoint-store.d.ts +2 -0
- package/dist/plugins/local-checkpoint-store.js +6 -1
- package/dist/plugins/local-session-store.d.ts +1 -1
- package/dist/plugins/local-session-window.d.ts +39 -0
- package/dist/plugins/local-session-window.js +54 -0
- package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
- package/dist/plugins/mailbox-store-sql.d.ts +30 -48
- package/dist/plugins/mailbox-store-sql.js +77 -52
- package/dist/plugins/memory-embedder-fingerprint.js +2 -1
- package/dist/plugins/memory-run-store.d.ts +5 -13
- package/dist/plugins/memory-run-store.js +8 -0
- package/dist/plugins/one-time-migrations.d.ts +110 -5
- package/dist/plugins/one-time-migrations.js +320 -8
- package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
- package/dist/plugins/org-delivery-quota-store.js +228 -0
- package/dist/plugins/pg-pool.js +39 -7
- package/dist/plugins/pg-session-storage.d.ts +17 -4
- package/dist/plugins/pg-session-storage.js +29 -6
- package/dist/plugins/remote-env-adb.d.ts +6 -12
- package/dist/plugins/remote-env-adb.js +12 -2
- package/dist/plugins/remote-env-k8s.d.ts +8 -12
- package/dist/plugins/remote-env-k8s.js +23 -5
- package/dist/plugins/remote-env-local-docker.d.ts +10 -15
- package/dist/plugins/remote-env-local-docker.js +12 -9
- package/dist/plugins/remote-env-ssh.d.ts +10 -16
- package/dist/plugins/remote-env-ssh.js +17 -11
- package/dist/plugins/run-store-sql.d.ts +16 -14
- package/dist/plugins/run-store-sql.js +22 -2
- package/dist/plugins/schema-indexes.js +2 -0
- package/dist/plugins/send-user-file.js +2 -2
- package/dist/plugins/session-epoch-anchor.d.ts +32 -6
- package/dist/plugins/session-epoch-anchor.js +2 -3
- package/dist/plugins/session-store.d.ts +18 -8
- package/dist/plugins/session-store.js +15 -4
- package/dist/plugins/sql-driver.d.ts +74 -11
- package/dist/plugins/sql-driver.js +210 -12
- package/dist/plugins/sql-errors.d.ts +23 -0
- package/dist/plugins/sql-errors.js +21 -0
- package/dist/plugins/store-backend.d.ts +36 -1
- package/dist/plugins/store-backend.js +40 -14
- package/dist/plugins/store-contracts.d.ts +42 -0
- package/dist/plugins/store-contracts.js +1 -0
- package/dist/plugins/tidb-pool.d.ts +6 -1
- package/dist/plugins/tidb-pool.js +44 -10
- package/dist/plugins/tidb-session-storage.d.ts +3 -2
- package/dist/plugins/tidb-session-storage.js +2 -2
- package/dist/plugins/tidb-session-store.d.ts +24 -4
- package/dist/plugins/tidb-session-store.js +28 -4
- package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
- package/dist/plugins/workflow-journal-store-sql.js +19 -6
- package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
- package/dist/plugins/workflow-run-store-sql.js +50 -9
- package/dist/posture-source.d.ts +18 -10
- package/dist/posture-source.js +4 -1
- package/dist/project-identity.d.ts +45 -6
- package/dist/project-identity.js +162 -8
- package/dist/project-layer-key.d.ts +28 -0
- package/dist/project-layer-key.js +29 -0
- package/dist/question.js +3 -2
- package/dist/read-deny-entry.d.ts +25 -0
- package/dist/read-deny-entry.js +12 -0
- package/dist/read-face-posture.d.ts +37 -11
- package/dist/read-face-posture.js +32 -3
- package/dist/request-key-closure.d.ts +7 -0
- package/dist/request-key-closure.js +9 -1
- package/dist/request-value-closure.d.ts +5 -0
- package/dist/request-value-closure.js +11 -3
- package/dist/rule-entry-list.d.ts +26 -2
- package/dist/rule-entry-list.js +72 -12
- package/dist/rules-consent.js +3 -4
- package/dist/run-acceptance.d.ts +19 -3
- package/dist/run-acceptance.js +13 -1
- package/dist/run-local.js +36 -6
- package/dist/runs.d.ts +10 -9
- package/dist/runs.js +21 -3
- package/dist/runtime-caps-resolver.d.ts +16 -6
- package/dist/runtime-caps-resolver.js +18 -5
- package/dist/sandbox-pkg-source.d.ts +19 -1
- package/dist/sandbox-pkg-source.js +29 -7
- package/dist/security.d.ts +87 -9
- package/dist/security.js +52 -9
- package/dist/session-error-wire.d.ts +19 -2
- package/dist/session-error-wire.js +5 -1
- package/dist/session-titled-frame.d.ts +33 -0
- package/dist/session-titled-frame.js +4 -0
- package/dist/session-titler.d.ts +9 -1
- package/dist/session-titler.js +15 -4
- package/dist/spec-fields.js +21 -2
- package/dist/sql-engine-posture.d.ts +3 -1
- package/dist/task-cwd.d.ts +1 -1
- package/dist/task-mcp.d.ts +3 -3
- package/dist/task-mcp.js +7 -66
- package/dist/task-settings.d.ts +89 -88
- package/dist/task-settings.js +71 -63
- package/dist/text-bidi.d.ts +0 -4
- package/dist/text-bidi.js +1 -3
- package/dist/tighten-only-seats.d.ts +150 -0
- package/dist/tighten-only-seats.js +196 -0
- package/dist/tool-approval.d.ts +303 -87
- package/dist/tool-approval.js +623 -239
- package/dist/trace/core-keyset-guard.d.ts +104 -22
- package/dist/trace/exit-seat.d.ts +28 -0
- package/dist/trace/exit-seat.js +76 -0
- package/dist/trace/ledger-events.d.ts +3 -2
- package/dist/trace/project.d.ts +80 -12
- package/dist/trace/project.js +41 -28
- package/dist/trace/projection-table.d.ts +100 -0
- package/dist/trace/projection-table.js +130 -0
- package/dist/trace/redact.d.ts +54 -0
- package/dist/trace/redact.js +778 -152
- package/dist/trace/self-minted-wire.d.ts +345 -1
- package/dist/trace/self-minted-wire.js +117 -1
- package/dist/trace/wire-projection-faces.d.ts +298 -2
- package/dist/trace/wire-projection-faces.js +154 -13
- package/dist/url-refusal.js +2 -0
- package/dist/web-admin-client/apply-effective.d.ts +12 -0
- package/dist/web-admin-client/apply-effective.js +56 -5
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/read-face.js +5 -9
- package/dist/web-admin-client/skills-mcp.js +4 -5
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -9
- package/package.json +7 -3
|
@@ -17,6 +17,7 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
|
|
|
17
17
|
}>) | undefined;
|
|
18
18
|
webAdminJwtVerifier: import("../auth-bridge.js").WebAdminJwtVerifier | undefined;
|
|
19
19
|
sessionAudit: ((sessionId: string, opts?: import("../audit.js").SessionAuditReadOpts) => Promise<{
|
|
20
|
+
agent?: import("../audit.js").SessionAgent | undefined;
|
|
20
21
|
owner: string | null;
|
|
21
22
|
sessionId: string;
|
|
22
23
|
createdAt: string;
|
|
@@ -101,6 +102,7 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
|
|
|
101
102
|
workflowCompletionInbox: import("../orchestration/workflow-completion-inbox.js").WorkflowCompletionInbox | undefined;
|
|
102
103
|
workflowJournalStore: import("../plugins/store-backend.js").ServiceWorkflowJournalStore | undefined;
|
|
103
104
|
workflowModelAllowlistSnapshot: readonly string[];
|
|
105
|
+
workflowParkDecisions: import("../orchestration/workflow-park-decision.js").WorkflowParkDecisionStore | undefined;
|
|
104
106
|
workflowNotifyGate: import("../orchestration/workflow-notify-journal.js").WorkflowNotifyGate | undefined;
|
|
105
107
|
workflowNotifyJournal: import("../orchestration/workflow-notify-journal.js").WorkflowNotifyJournalStore | undefined;
|
|
106
108
|
workflowRecoverOpts: {
|
|
@@ -110,6 +112,7 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
|
|
|
110
112
|
};
|
|
111
113
|
workflowRunStore: import("../orchestration/workflow-notify-journal.js").JournalingWorkflowRunStore | undefined;
|
|
112
114
|
workflowsCapable: boolean;
|
|
115
|
+
orgDeliveryGate: import("@sema-agent/core").OrgDeliveryGate | undefined;
|
|
113
116
|
deploymentMods: readonly import("@sema-agent/core").ModRegistration<import("@sema-agent/core").EngineDollar>[];
|
|
114
117
|
deviceLane: import("./device-lane.js").DeviceLane | undefined;
|
|
115
118
|
dropSessionScoped: (sid: string) => void;
|
|
@@ -9,7 +9,6 @@ import { createHttpServer } from "../http/server.js";
|
|
|
9
9
|
import { exportMemoryScope } from "../memory-export.js";
|
|
10
10
|
import { performMemorySync } from "../memory-sync.js";
|
|
11
11
|
import { backgroundAgentOutput, taskHandleOutput, taskHandleStop } from "../runs.js";
|
|
12
|
-
import { sqlBlobCapOf } from "../plugins/blob-backend.js";
|
|
13
12
|
import { createStoreLiveProbe } from "../store-live-probe.js";
|
|
14
13
|
import { counterStoreLabel } from "../plugins/store-backend.js";
|
|
15
14
|
import { sessionStoreLabelOf } from "../store-posture.js";
|
|
@@ -30,7 +29,7 @@ import { bindServerLateSeats } from "./late-binds.js";
|
|
|
30
29
|
import { serviceVersion } from "../service-version.js";
|
|
31
30
|
import { buildDisplaySafeUrl } from "../trace/redact.js";
|
|
32
31
|
export async function runStage10(ctx) {
|
|
33
|
-
const { approvalAskAudit, approvalExemptionStore, approvalNonceStore, authorize, backend, backgroundAgentStore, brain, breakerState, centerRuntimeCapsResolver, checkpointStore, parkCommits, config, webAdmin, consolidationValve, costQuota, deviceLane, drainState, durableEnabled, elicitation, fenceSessionOwner, fileHistoryStore, fleetBus, fleetLease, fleetUsage, governanceSeams, handslessRunner, hookAgent, hookLlm, hookWakeBus, imageBakes, imageIndex, instanceId, instrumentDegenerate, leaderEndpoint, localRoot, logger, lspManager, mcpRevocations, memoryBundleFaces, memoryComplianceFaces, memoryConsolidationFaces, memoryEngine, memoryExportBackend, memoryOptOutGrantStore, memoryOriginFaces, memoryPosture, memorySyncCursors, metrics, modelUsageTracker, orgMemoryAdmission, otelExporter, outcomeSink, ownerAware, parkedReviveInheritedGate, parkedReviveSurface, perSessionCwd, perTaskImage, planCacheProbe, pricing, principalCaps, promptManifestTracker, purgeSession, question, rateLimiter, reaper, webAdminJwtVerifier, resumeAnchorStore, retentionLaneStarted, retentionLaneStore, ruleConsent, runStore, runner, runnerDeps, runtimeCapsPeekResolver, scenarioDetails, scenarios, selectEnvTool, sendFileLedger, sendUserFileEmitter, sendUserFileToolSpec, sessionAudit, sessionEnvSelection, sessionMemoryStatusFace, sessionPolicyStore, sessionTitler, sessionWatchRegistry, setSessionCwd, setSessionInheritEnv, setSessionShellEnv, sharedMemoryStore, sideQueryAccounting, sqlEngine, sqlWorkflowRunStore, staticWiring, storePosture, subRunner, subagentSteerRegistry, taskAttachmentStore, taskLimitCaps, taskTimeoutSec, toolApproval, toolResultStore, usageWindowStore, userInputLedger, webSearchProvider, workflowAgentRegistry, workflowAgentSessionIndex, workflowCompletionInbox, workflowJournalStore, workflowModelAllowlistSnapshot, workflowNotifyGate, workflowNotifyJournal, workflowRecoverOpts, workflowRunStore, workflowsCapable } = ctx;
|
|
32
|
+
const { approvalAskAudit, approvalExemptionStore, approvalNonceStore, authorize, backend, backgroundAgentStore, brain, breakerState, centerRuntimeCapsResolver, checkpointStore, parkCommits, config, webAdmin, consolidationValve, costQuota, deviceLane, drainState, durableEnabled, elicitation, fenceSessionOwner, fileHistoryStore, fleetBus, fleetLease, fleetUsage, governanceSeams, handslessRunner, hookAgent, hookLlm, hookWakeBus, imageBakes, imageIndex, instanceId, instrumentDegenerate, leaderEndpoint, localRoot, logger, lspManager, mcpRevocations, memoryBundleFaces, memoryComplianceFaces, memoryConsolidationFaces, memoryEngine, memoryExportBackend, memoryOptOutGrantStore, memoryOriginFaces, memoryPosture, memorySyncCursors, memorySyncRunner, metrics, modelUsageTracker, orgMemoryAdmission, otelExporter, outcomeSink, ownerAware, parkedReviveInheritedGate, parkedReviveSurface, perSessionCwd, perTaskImage, planCacheProbe, pricing, principalCaps, promptManifestTracker, purgeSession, question, rateLimiter, reaper, webAdminJwtVerifier, resumeAnchorStore, retentionLaneStarted, retentionLaneStore, ruleConsent, runStore, runner, runnerDeps, runtimeCapsPeekResolver, scenarioDetails, scenarios, selectEnvTool, sendFileLedger, sendUserFileEmitter, sendUserFileToolSpec, sessionAudit, sessionEnvSelection, sessionMemoryStatusFace, sessionPolicyStore, sessionTitler, sessionWatchRegistry, setSessionCwd, setSessionInheritEnv, setSessionShellEnv, sharedMemoryStore, sideQueryAccounting, sqlEngine, sqlWorkflowRunStore, staticWiring, storePosture, subRunner, subagentSteerRegistry, taskAttachmentStore, taskLimitCaps, taskTimeoutSec, toolApproval, toolResultStore, usageWindowStore, userInputLedger, webSearchProvider, workflowAgentRegistry, workflowAgentSessionIndex, workflowParkDecisions, workflowCompletionInbox, workflowJournalStore, workflowModelAllowlistSnapshot, workflowNotifyGate, workflowNotifyJournal, workflowRecoverOpts, workflowRunStore, workflowsCapable, orgDeliveryGate } = ctx;
|
|
34
33
|
const stores = {
|
|
35
34
|
runStore,
|
|
36
35
|
resumeAnchorStore: resumeAnchorStore ? resumeAnchorStore : undefined,
|
|
@@ -47,6 +46,7 @@ export async function runStage10(ctx) {
|
|
|
47
46
|
peerDirectory: runnerDeps.peerDirectory,
|
|
48
47
|
workflowRunStore: workflowRunStore ? workflowRunStore : undefined,
|
|
49
48
|
workflowAgentSessionIndex: workflowAgentSessionIndex ? workflowAgentSessionIndex : undefined,
|
|
49
|
+
workflowParkDecisions: workflowParkDecisions ? workflowParkDecisions : undefined,
|
|
50
50
|
workflowJournalStore: workflowJournalStore ? workflowJournalStore : undefined,
|
|
51
51
|
imageIndex,
|
|
52
52
|
imageBakes,
|
|
@@ -99,6 +99,7 @@ export async function runStage10(ctx) {
|
|
|
99
99
|
memoryConsolidation: memoryConsolidationFaces,
|
|
100
100
|
memoryOptOutGrant: memoryOptOutGrantStore,
|
|
101
101
|
orgMemoryDirectory: orgMemoryAdmission.directory,
|
|
102
|
+
orgDeliveryGate,
|
|
102
103
|
sharedMemoryStore: sharedMemoryStore ? sharedMemoryStore : undefined,
|
|
103
104
|
sessionMirrorRuling: principalCaps
|
|
104
105
|
? async (p) => (await principalCaps.executionRuling(p))?.sessionMirror
|
|
@@ -177,6 +178,7 @@ export async function runStage10(ctx) {
|
|
|
177
178
|
restartState: () => webAdmin.restartState(),
|
|
178
179
|
configApplyState: () => webAdmin.configApplyState(),
|
|
179
180
|
centerCredentialState: () => webAdmin.centerCredentialState(),
|
|
181
|
+
centerIdentityNoticeState: () => webAdmin.centerIdentityNoticeState(),
|
|
180
182
|
modelRefusalsState: () => webAdmin.modelRefusalsState(),
|
|
181
183
|
candidateRejectionState: () => webAdmin.candidateRejectionState(),
|
|
182
184
|
configHandoffState: () => webAdmin.configHandoffState(),
|
|
@@ -191,9 +193,6 @@ export async function runStage10(ctx) {
|
|
|
191
193
|
storeLiveState: storeLiveProbe ? () => storeLiveProbe.state() : undefined,
|
|
192
194
|
};
|
|
193
195
|
const knobs = {
|
|
194
|
-
snapshotBlobSqlCap: sqlEngine !== undefined && !config.snapshotBlobStore
|
|
195
|
-
? () => sqlBlobCapOf(config.snapshotBlobSqlMaxBytes, sqlEngine)
|
|
196
|
-
: undefined,
|
|
197
196
|
sessionEventsMaxConnections: sessionWatchRegistry ? posIntEnv(process.env.SESSION_EVENTS_MAX_CONNS, 256, 100_000) : undefined,
|
|
198
197
|
};
|
|
199
198
|
const resolveSpec = createResolveSpec({
|
|
@@ -201,7 +200,7 @@ export async function runStage10(ctx) {
|
|
|
201
200
|
getKeyResolver: () => webAdmin.getKeyResolver(),
|
|
202
201
|
taskAttachmentStore, perSessionCwd, setSessionCwd, setSessionShellEnv, fenceSessionOwner,
|
|
203
202
|
hookLlm, hookAgent, fleetBus, hookWakeBus, resumeAnchorStore, ownerAware, taskLimitCaps, taskTimeoutSec,
|
|
204
|
-
selectEnvTool, sendUserFileToolSpec, memoryEngine, durableEnabled, approvalExemptionStore,
|
|
203
|
+
selectEnvTool, sendUserFileToolSpec, memoryEngine, memorySyncRunner, durableEnabled, approvalExemptionStore,
|
|
205
204
|
checkpointStore, imageIndex, perTaskImage,
|
|
206
205
|
sessionEnvSelection,
|
|
207
206
|
lockedKeys: governanceSeams.lockedKeys,
|
package/dist/boot/stores.js
CHANGED
|
@@ -377,7 +377,7 @@ export async function openStores(ctx) {
|
|
|
377
377
|
...(config.memorySync.maxPushEntries !== undefined ? { maxPushEntries: config.memorySync.maxPushEntries } : {}),
|
|
378
378
|
...(config.memorySync.maxPullEntries !== undefined ? { maxPullEntries: config.memorySync.maxPullEntries } : {}),
|
|
379
379
|
});
|
|
380
|
-
logger.info("memory_sync_enabled", { url: buildDisplaySafeUrl(config.memorySync.url), scope: config.memorySync.scope, cursorPath: memorySyncRunner.
|
|
380
|
+
logger.info("memory_sync_enabled", { url: buildDisplaySafeUrl(config.memorySync.url), scope: config.memorySync.scope, cursorPath: memorySyncRunner.cursorPathFor(config.memorySync.scope) });
|
|
381
381
|
memorySyncRunner.trigger("boot");
|
|
382
382
|
}
|
|
383
383
|
else {
|
|
@@ -436,7 +436,7 @@ export async function openStores(ctx) {
|
|
|
436
436
|
const breakerState = backend?.breaker && config.resilience.circuitBreaker
|
|
437
437
|
? backend
|
|
438
438
|
.breaker((streak) => {
|
|
439
|
-
metrics.setGauge("counter_flush_fail_streak", streak, { table: "
|
|
439
|
+
metrics.setGauge("counter_flush_fail_streak", streak, { table: "breaker_state", kind: "write_through" });
|
|
440
440
|
if (streak > 0)
|
|
441
441
|
metrics.inc("breaker_writethrough_failed_total", { backend: backend.kind });
|
|
442
442
|
if (streak === 3)
|
package/dist/boot/web-admin.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { buildPricing } from "../budget.js";
|
|
|
4
4
|
import { type Scenario, type ScenarioDeps, type ScenarioDetail } from "../capabilities/scenarios.js";
|
|
5
5
|
import type { LoadedSkill } from "../capabilities/skills.js";
|
|
6
6
|
import { type ServiceConfig } from "../config.js";
|
|
7
|
+
import { type CenterIdentityNotice } from "../center-config-tier.js";
|
|
7
8
|
import { type CenterCredentialHealthView } from "../center-credential-renewer.js";
|
|
8
9
|
import { type ModelKeyRef } from "../key-resolver.js";
|
|
9
10
|
import type { Logger } from "../observability/logger.js";
|
|
@@ -83,6 +84,9 @@ export interface WebAdminRuntime {
|
|
|
83
84
|
stopRefreshLoop(): void;
|
|
84
85
|
/** S-698:`/health.centerCredential` 的取值口 —— 凭证来源的健康态 + 续签器状态;都健康 / 没有中心 ⇒ `undefined`(键缺席)。 */
|
|
85
86
|
centerCredentialState(): CenterCredentialHealthView | undefined;
|
|
87
|
+
/** S-667:`/health.centerIdentityNotice` 的取值口 —— 中心凭证换人后的**最近一条**通告(`center_identity_demoted` 已降到无中心配置档 / `center_identity_landed`
|
|
88
|
+
* 新身份的配置已换上;码、冻结句与状态机见 `center-config-tier.ts`)。从未换过人 / 没有中心 ⇒ `undefined`(键缺席)。值形就是 wire 形 `{ code, message, at }`。 */
|
|
89
|
+
centerIdentityNoticeState(): CenterIdentityNotice | undefined;
|
|
86
90
|
/** [ref](core 5.50 [ref]):mid-turn MCP 撤销台账读口,喂 `RunnerDeps.mcpRevocations` 席。
|
|
87
91
|
* **取走即声明接线**——调用本方法后,restart 信号的 mcp 片对纯删除向豁免(台账即时承接);
|
|
88
92
|
* 不取 ⇒ 旧 restart 语义逐字保留(fail-closed)。 */
|
package/dist/boot/web-admin.js
CHANGED
|
@@ -11,14 +11,17 @@ import { applyCenterPlugins } from "../capabilities/center-plugins.js";
|
|
|
11
11
|
import { applyCenterArtifact, centerSourceOnError, withPromptArtifactBackfill } from "../capabilities/center-prompts.js";
|
|
12
12
|
import { centerScenarios, centerScenarioDetails } from "../capabilities/scenarios.js";
|
|
13
13
|
import { isRosterGateArmed } from "../config.js";
|
|
14
|
+
import { toolsRunOnThisHost } from "../task-cwd.js";
|
|
14
15
|
import { defaultLkgPath, defaultSkillCacheDir, saveLkg, loadLkg, legacyV1LkgPath, migrateV1Lkg } from "../config-lkg.js";
|
|
15
16
|
import { answerStillCurrent, centerStateBin, credentialIdentityNow, judgeCenterCredentialAtBoot } from "../center-credential.js";
|
|
17
|
+
import { createCenterConfigTier } from "../center-config-tier.js";
|
|
16
18
|
import { buildCenterCredentialHealthView, createCenterCredentialRenewer } from "../center-credential-renewer.js";
|
|
17
19
|
import { centerManagedConfigKeys } from "../web-admin-client/apply-effective.js";
|
|
18
20
|
import { createConfigProvider, raceBootFetch, serviceConfigSourceKind, BOOT_FETCH_DEFERRED } from "../config-provider.js";
|
|
21
|
+
import { ConfigDirUntrustedError } from "../config-dir-trust.js";
|
|
19
22
|
import { createKeyResolver } from "../key-resolver.js";
|
|
20
23
|
import { buildSealedKeyPublicFace, ensureSealedKeyStore, reportExecutionPublicKey } from "../sealed-key.js";
|
|
21
|
-
import { applyEffective, applyCenterReadFace, buildReadFaceBaseline, buildReadFaceSwapCandidate, restoreReadFaceBaseline, mutateInPlace, logEffectiveDiff, applySkillsManifest, resolveMcpServers, resolveA2aPeers, restartReasons, modelPlaneChanged, withModelPlaneOf, fullyLandedForLkg, fetchPromptArtifact } from "../web-admin-client/facade.js";
|
|
24
|
+
import { applyEffective, applyCenterReadFace, buildReadFaceBaseline, buildReadFaceSwapCandidate, restoreReadFaceBaseline, mutateInPlace, logEffectiveDiff, applySkillsManifest, resolveMcpServers, resolveA2aPeers, restartReasons, modelPlaneChanged, withModelPlaneOf, fullyLandedForLkg, NO_CENTER_EFFECTIVE, isNoCenterEffective, fetchPromptArtifact } from "../web-admin-client/facade.js";
|
|
22
25
|
import { buildConfigHandoff, buildRestartSignal, configHandoffMissing } from "../fleet/engine-signal.js";
|
|
23
26
|
import { createMcpRevocationLedger, enabledMcpEntries } from "../web-admin-client/mcp-revocation.js";
|
|
24
27
|
import { buildUnreadConfigFileFields, buildUnreadConfigKeyFields } from "../web-admin-client/read-warnings.js";
|
|
@@ -26,6 +29,7 @@ import { CONFIG_DOMAIN_INVALID_NOTE, buildCandidateRejectedFields, candidateReje
|
|
|
26
29
|
import { SHA256_HEX_RE } from "../digest-form.js";
|
|
27
30
|
import { BOOT_REJUDGE_OF_REFUSED_GROUP, createConfigApplyLedger, modelPlaneCommitted, refusedGroups } from "../web-admin-client/apply-ledger.js";
|
|
28
31
|
import { announceReadDenyRows, buildDeploymentPostureSeats } from "./runner-deps.js";
|
|
32
|
+
import { echoCallerText } from "../caller-text-echo.js";
|
|
29
33
|
function lkgReadNote(scope) {
|
|
30
34
|
switch (scope) {
|
|
31
35
|
case "whole":
|
|
@@ -86,6 +90,21 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
86
90
|
? createCenterCredentialRenewer({ source: cc.credential, centerUrl: cc.baseUrl, leadMs: config.centerCredentialRenewLeadMs, logger })
|
|
87
91
|
: undefined;
|
|
88
92
|
const currentIdentity = () => (cc === undefined ? undefined : credentialIdentityNow(cc.credential));
|
|
93
|
+
const tier = createCenterConfigTier();
|
|
94
|
+
const announceTier = (n) => {
|
|
95
|
+
switch (n.code) {
|
|
96
|
+
case "center_identity_demoted":
|
|
97
|
+
logger.warn(n.code, { at: n.at, message: n.message, ...(n.retained !== undefined ? { retained: n.retained } : {}), note: "the credential identity changed: the previous account's center configuration is dropped (every center-supplied hot face is back on its env base, the center prompt layer is withdrawn, the Runners run the env model table) and a pull for the new identity is under way; skills / MCP / A2A / scenarios are baked at boot and stay the previous account's until a restart (see /health.restart)" });
|
|
98
|
+
return;
|
|
99
|
+
case "center_identity_landed":
|
|
100
|
+
logger.info(n.code, { at: n.at, message: n.message });
|
|
101
|
+
return;
|
|
102
|
+
default: {
|
|
103
|
+
const unknownCode = n.code;
|
|
104
|
+
throw new Error(`announceTier: unknown notice code ${JSON.stringify(unknownCode)}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
89
108
|
const candidateIdentity = new WeakMap();
|
|
90
109
|
const candidateIdentityOf = (eff) => candidateIdentity.get(eff);
|
|
91
110
|
const validatorIdentity = new Map();
|
|
@@ -133,6 +152,7 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
133
152
|
...(config.configProvider ? { provider: config.configProvider } : {}),
|
|
134
153
|
...(cc ? { webAdmin: { baseUrl: cc.baseUrl, credential: cc.credential, worker: cc.worker, dryRun: cc.dryRun } } : {}),
|
|
135
154
|
localDir: localRoot,
|
|
155
|
+
localOwnerUid: config.configLocalOwnerUid,
|
|
136
156
|
...(config.configLkgEnabled ? { skillBodyCacheDir: defaultSkillCacheDir(config) } : {}),
|
|
137
157
|
})
|
|
138
158
|
: undefined;
|
|
@@ -301,6 +321,10 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
301
321
|
if (configProvider && !cc?.dryRun)
|
|
302
322
|
await rebasePromptState(promptStateIdentity, "boot");
|
|
303
323
|
const adoptCenterPrompts = async (eff, prompts, phase) => {
|
|
324
|
+
if (isNoCenterEffective(eff)) {
|
|
325
|
+
await rebasePromptState(undefined, phase);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
304
328
|
const adoptedIdentity = candidateIdentityOf(eff);
|
|
305
329
|
if (adoptedIdentity !== undefined && adoptedIdentity !== promptStateIdentity) {
|
|
306
330
|
await rebasePromptState(adoptedIdentity, phase);
|
|
@@ -348,14 +372,20 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
348
372
|
return ledger;
|
|
349
373
|
};
|
|
350
374
|
const noteHandoff = (next) => {
|
|
351
|
-
const applied = next.applied ?? handoff.applied;
|
|
375
|
+
const applied = next.noneApplied === true ? undefined : (next.applied ?? handoff.applied);
|
|
352
376
|
const durable = next.durable ?? handoff.durable;
|
|
353
377
|
handoff = { ...(applied !== undefined ? { applied } : {}), ...(durable !== undefined ? { durable } : {}) };
|
|
354
378
|
latchHandoff();
|
|
355
379
|
};
|
|
356
|
-
const markApplied = (gen,
|
|
357
|
-
applyLedger.applied(gen, version);
|
|
358
|
-
|
|
380
|
+
const markApplied = (gen, eff) => {
|
|
381
|
+
applyLedger.applied(gen, eff.version);
|
|
382
|
+
if (isNoCenterEffective(eff))
|
|
383
|
+
noteHandoff({ noneApplied: true });
|
|
384
|
+
else
|
|
385
|
+
noteHandoff({ applied: eff.version });
|
|
386
|
+
const landed = tier.committed(candidateIdentityOf(eff));
|
|
387
|
+
if (landed !== undefined)
|
|
388
|
+
announceTier(landed);
|
|
359
389
|
};
|
|
360
390
|
let lkgBooted = false;
|
|
361
391
|
let bootLkgCandidate;
|
|
@@ -480,7 +510,7 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
480
510
|
const lkgIdentity = candidateIdentityOf(lkgR.effective);
|
|
481
511
|
if (lkgSurvivesRestart && lkgIdentity !== undefined)
|
|
482
512
|
noteHandoff({ durable: { version: lkgR.effective.version, identity: lkgIdentity } });
|
|
483
|
-
markApplied(lkgGen, lkgR.effective
|
|
513
|
+
markApplied(lkgGen, lkgR.effective);
|
|
484
514
|
await adoptCenterPrompts(lkgR.effective, lkgR.prompts, "boot-lkg");
|
|
485
515
|
const lkgPlane = modelPlaneCommitted(lkgReport);
|
|
486
516
|
if (lkgPlane)
|
|
@@ -585,7 +615,7 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
585
615
|
recordApply(rep);
|
|
586
616
|
},
|
|
587
617
|
});
|
|
588
|
-
markApplied(bootGen, r.effective
|
|
618
|
+
markApplied(bootGen, r.effective);
|
|
589
619
|
const bootClean = fullyLandedForLkg(r, bootReport);
|
|
590
620
|
if (bootClean)
|
|
591
621
|
ccEtag = r.etag;
|
|
@@ -622,11 +652,13 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
622
652
|
}
|
|
623
653
|
}
|
|
624
654
|
catch (err) {
|
|
655
|
+
if (err instanceof ConfigDirUntrustedError)
|
|
656
|
+
throw err;
|
|
625
657
|
if (bootApplyPhase)
|
|
626
658
|
logger.warn("config_apply_refused", { source: configProvider.kind, err: String(err), note: "the pulled candidate failed to apply at boot — falling back to the LKG / env; this is not a reachability failure" });
|
|
627
659
|
else
|
|
628
660
|
logger.warn("config_source_unreachable_using_env", { source: configProvider.kind, err: String(err) });
|
|
629
|
-
await bootFallBackWhole(`${bootApplyPhase ? "boot apply refused" : "boot fetch failed"}: ${String(err)
|
|
661
|
+
await bootFallBackWhole(`${bootApplyPhase ? "boot apply refused" : "boot fetch failed"}: ${echoCallerText(String(err), { maxChars: 120 })}`);
|
|
630
662
|
}
|
|
631
663
|
if (!dryRun && cc !== undefined && currentIdentity() !== promptStateIdentity)
|
|
632
664
|
await rebasePromptState(currentIdentity(), "boot-end");
|
|
@@ -669,6 +701,7 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
669
701
|
announceReadDenyRows(config, logger);
|
|
670
702
|
};
|
|
671
703
|
let ccTimer;
|
|
704
|
+
let unwatchCredential;
|
|
672
705
|
return {
|
|
673
706
|
providerKind: configProvider?.kind,
|
|
674
707
|
sealedKeyPublic: sealedKeys === undefined ? undefined : buildSealedKeyPublicFace(sealedKeys),
|
|
@@ -707,6 +740,7 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
707
740
|
const pluginOut = await applyCenterPlugins(skills, effective, {
|
|
708
741
|
cacheRoot: join(config.localDataRoot ?? join(homedir(), ".ai-agent"), "plugin-cache"),
|
|
709
742
|
allowHosts: config.pluginsAllowHosts,
|
|
743
|
+
toolsShareThisFilesystem: toolsRunOnThisHost(config),
|
|
710
744
|
logger,
|
|
711
745
|
}).catch((err) => {
|
|
712
746
|
logger.warn("center_plugins_apply_failed", { error: err instanceof Error ? err.message : String(err) });
|
|
@@ -839,6 +873,69 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
839
873
|
if (configProvider) {
|
|
840
874
|
const ccRef = config.webAdmin;
|
|
841
875
|
let refreshInFlight = false;
|
|
876
|
+
let followUp = false;
|
|
877
|
+
let ownRead = false;
|
|
878
|
+
const commitHot = async (c) => {
|
|
879
|
+
const { eff, prompts, gen, phase } = c;
|
|
880
|
+
const noCenter = isNoCenterEffective(eff);
|
|
881
|
+
const planeChanged = noCenter || modelPlaneChanged(appliedPlaneEff, eff);
|
|
882
|
+
let report;
|
|
883
|
+
const committed = applyEffective(config, eff, logger, {
|
|
884
|
+
leg: "hot",
|
|
885
|
+
checkpointStorePresent,
|
|
886
|
+
sealedKeys,
|
|
887
|
+
generation: gen,
|
|
888
|
+
report: (rep) => {
|
|
889
|
+
report = rep;
|
|
890
|
+
recordApply(rep);
|
|
891
|
+
},
|
|
892
|
+
...(planeChanged ? { swapPlane: swapRunnerDeps } : {}),
|
|
893
|
+
});
|
|
894
|
+
if (!committed)
|
|
895
|
+
return { committed: false, report, planeCommitted: false };
|
|
896
|
+
mutateInPlace(pricing, buildPricing(config.models));
|
|
897
|
+
keyResolver = createKeyResolver(config.modelApiKeyEnv, process.env, config.modelApiKeys);
|
|
898
|
+
limitSync?.sync();
|
|
899
|
+
ceilingVerdict?.judge();
|
|
900
|
+
if (phase !== "boot-deferred")
|
|
901
|
+
mcpRevocations.applyEnabledEntries(enabledMcpEntries(eff.mcp));
|
|
902
|
+
applyLiveReadFace(eff, swapRunnerDeps, phase);
|
|
903
|
+
markApplied(gen, eff);
|
|
904
|
+
const planeCommitted = modelPlaneCommitted(report);
|
|
905
|
+
if (planeCommitted)
|
|
906
|
+
appliedPlaneEff = noCenter ? undefined : eff;
|
|
907
|
+
planeDeferredNoHandoff = undefined;
|
|
908
|
+
await adoptCenterPrompts(eff, prompts, phase);
|
|
909
|
+
if (planeCommitted)
|
|
910
|
+
markRosterLanded(eff);
|
|
911
|
+
if (tier.drifted(currentIdentity()))
|
|
912
|
+
requestTick();
|
|
913
|
+
return { committed: true, report, planeCommitted };
|
|
914
|
+
};
|
|
915
|
+
const demoteToNoCenter = async (awaiting) => {
|
|
916
|
+
const gen = reserveArrivalGeneration();
|
|
917
|
+
applyLedger.seenTarget(gen, NO_CENTER_EFFECTIVE.version);
|
|
918
|
+
const hot = await commitHot({ eff: NO_CENTER_EFFECTIVE, prompts: undefined, gen, phase: "no-center" });
|
|
919
|
+
if (!hot.committed) {
|
|
920
|
+
throw new Error("the no-center tier was refused (the Runners did not accept the env model table) — the previous account's center configuration is still in force; retried next tick");
|
|
921
|
+
}
|
|
922
|
+
if (hot.report !== undefined && !hot.report.fullyApplied) {
|
|
923
|
+
logger.warn("center_identity_demotion_partial", { groups: refusedGroups(hot.report).map((g) => g.group), note: "a group of the no-center tier was refused — that group keeps its previous values (loud; the env base for that group could not be applied)" });
|
|
924
|
+
}
|
|
925
|
+
noteCandidateVerdict(gen, undefined);
|
|
926
|
+
latestEffective = undefined;
|
|
927
|
+
ccEtag = undefined;
|
|
928
|
+
announceTier(tier.demote(awaiting, hot.report !== undefined ? refusedGroups(hot.report).map((g) => g.group) : []));
|
|
929
|
+
};
|
|
930
|
+
const reconcileCenterIdentity = async (identity) => {
|
|
931
|
+
if (identity === undefined || !tier.drifted(identity))
|
|
932
|
+
return;
|
|
933
|
+
if (tier.isDemoted()) {
|
|
934
|
+
tier.retarget(identity);
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
await demoteToNoCenter(identity);
|
|
938
|
+
};
|
|
842
939
|
const refreshTick = async (arrival) => {
|
|
843
940
|
if (refreshInFlight)
|
|
844
941
|
return "ok";
|
|
@@ -850,6 +947,15 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
850
947
|
const refreshTickRan = async (arrival) => {
|
|
851
948
|
refreshInFlight = true;
|
|
852
949
|
try {
|
|
950
|
+
let ownIdentity;
|
|
951
|
+
ownRead = true;
|
|
952
|
+
try {
|
|
953
|
+
ownIdentity = currentIdentity();
|
|
954
|
+
}
|
|
955
|
+
finally {
|
|
956
|
+
ownRead = false;
|
|
957
|
+
}
|
|
958
|
+
await reconcileCenterIdentity(ownIdentity);
|
|
853
959
|
await retryPendingCatalog("refresh-retry");
|
|
854
960
|
if (planeDeferredNoHandoff) {
|
|
855
961
|
metrics.inc("models_tiers_plane_deferred_stuck_total");
|
|
@@ -875,6 +981,7 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
875
981
|
}
|
|
876
982
|
}
|
|
877
983
|
if (r) {
|
|
984
|
+
await reconcileCenterIdentity(candidateIdentityOf(r.effective));
|
|
878
985
|
const tickGen = arrival !== undefined ? useArrivalGeneration(r.effective.version, arrival.ordinal) : generationOf(r.effective.version);
|
|
879
986
|
applyLedger.seenTarget(tickGen, r.effective.version);
|
|
880
987
|
const verdict = judgeConfigCandidate(r);
|
|
@@ -889,35 +996,10 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
889
996
|
ccEtag = r.etag;
|
|
890
997
|
}
|
|
891
998
|
else {
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
const committed = applyEffective(config, r.effective, logger, {
|
|
895
|
-
leg: "hot",
|
|
896
|
-
checkpointStorePresent,
|
|
897
|
-
sealedKeys,
|
|
898
|
-
generation: tickGen,
|
|
899
|
-
report: (rep) => {
|
|
900
|
-
applyReport = rep;
|
|
901
|
-
recordApply(rep);
|
|
902
|
-
},
|
|
903
|
-
...(planeChanged ? { swapPlane: swapRunnerDeps } : {}),
|
|
904
|
-
});
|
|
905
|
-
if (!committed)
|
|
999
|
+
const hot = await commitHot({ eff: r.effective, prompts: verdict.prompts, gen: tickGen, phase: "refresh" });
|
|
1000
|
+
if (!hot.committed)
|
|
906
1001
|
return "ok";
|
|
907
|
-
|
|
908
|
-
keyResolver = createKeyResolver(config.modelApiKeyEnv, process.env, config.modelApiKeys);
|
|
909
|
-
limitSync?.sync();
|
|
910
|
-
ceilingVerdict?.judge();
|
|
911
|
-
mcpRevocations.applyEnabledEntries(enabledMcpEntries(r.effective.mcp));
|
|
912
|
-
applyLiveReadFace(r.effective, swapRunnerDeps, "refresh");
|
|
913
|
-
markApplied(tickGen, r.effective.version);
|
|
914
|
-
const tickPlane = modelPlaneCommitted(applyReport);
|
|
915
|
-
if (tickPlane)
|
|
916
|
-
appliedPlaneEff = r.effective;
|
|
917
|
-
planeDeferredNoHandoff = undefined;
|
|
918
|
-
await adoptCenterPrompts(r.effective, verdict.prompts, "refresh");
|
|
919
|
-
if (tickPlane)
|
|
920
|
-
markRosterLanded(r.effective);
|
|
1002
|
+
const applyReport = hot.report;
|
|
921
1003
|
if (!fullyLandedForLkg(r, applyReport)) {
|
|
922
1004
|
ccEtag = undefined;
|
|
923
1005
|
const refused = applyReport ? refusedGroups(applyReport) : [];
|
|
@@ -962,13 +1044,39 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
962
1044
|
return inFlight;
|
|
963
1045
|
const p = refreshTick(arrival).finally(() => {
|
|
964
1046
|
inFlight = undefined;
|
|
1047
|
+
afterLane();
|
|
965
1048
|
});
|
|
966
1049
|
inFlight = p;
|
|
967
1050
|
return p;
|
|
968
1051
|
};
|
|
1052
|
+
const requestTick = () => {
|
|
1053
|
+
if (ccTimer === undefined || ownRead)
|
|
1054
|
+
return;
|
|
1055
|
+
if (inFlight !== undefined || refreshInFlight) {
|
|
1056
|
+
followUp = true;
|
|
1057
|
+
return;
|
|
1058
|
+
}
|
|
1059
|
+
queueMicrotask(() => void runTick());
|
|
1060
|
+
};
|
|
1061
|
+
const afterLane = () => {
|
|
1062
|
+
if (!followUp)
|
|
1063
|
+
return;
|
|
1064
|
+
followUp = false;
|
|
1065
|
+
if (tier.drifted(currentIdentity()))
|
|
1066
|
+
requestTick();
|
|
1067
|
+
};
|
|
1068
|
+
unwatchCredential =
|
|
1069
|
+
ccRef !== undefined && !ccRef.dryRun && configProvider.kind === "remote"
|
|
1070
|
+
? ccRef.credential.onRead((read) => {
|
|
1071
|
+
if (tier.drifted(read.identity))
|
|
1072
|
+
requestTick();
|
|
1073
|
+
})
|
|
1074
|
+
: undefined;
|
|
969
1075
|
manualRefresh = runTick;
|
|
970
1076
|
ccTimer = setInterval(() => void runTick(), 60_000);
|
|
971
1077
|
ccTimer.unref?.();
|
|
1078
|
+
if (tier.drifted(currentIdentity()))
|
|
1079
|
+
requestTick();
|
|
972
1080
|
const deferredBootApply = async (r, arrivalGen) => {
|
|
973
1081
|
if (!r)
|
|
974
1082
|
return;
|
|
@@ -985,6 +1093,7 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
985
1093
|
}
|
|
986
1094
|
finally {
|
|
987
1095
|
refreshInFlight = false;
|
|
1096
|
+
afterLane();
|
|
988
1097
|
}
|
|
989
1098
|
};
|
|
990
1099
|
const deferredBootApplyInner = async (r, lateGen) => {
|
|
@@ -1001,34 +1110,10 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
1001
1110
|
ccEtag = r.etag;
|
|
1002
1111
|
return;
|
|
1003
1112
|
}
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1006
|
-
const committedLate = applyEffective(config, r.effective, logger, {
|
|
1007
|
-
leg: "hot",
|
|
1008
|
-
checkpointStorePresent,
|
|
1009
|
-
sealedKeys,
|
|
1010
|
-
generation: lateGen,
|
|
1011
|
-
report: (rep) => {
|
|
1012
|
-
applyReportLate = rep;
|
|
1013
|
-
recordApply(rep);
|
|
1014
|
-
},
|
|
1015
|
-
...(planeChangedLate ? { swapPlane: swapRunnerDeps } : {}),
|
|
1016
|
-
});
|
|
1017
|
-
if (!committedLate)
|
|
1113
|
+
const hotLate = await commitHot({ eff: r.effective, prompts: lateVerdict.prompts, gen: lateGen, phase: "boot-deferred" });
|
|
1114
|
+
if (!hotLate.committed)
|
|
1018
1115
|
return;
|
|
1019
|
-
|
|
1020
|
-
keyResolver = createKeyResolver(config.modelApiKeyEnv, process.env, config.modelApiKeys);
|
|
1021
|
-
limitSync?.sync();
|
|
1022
|
-
ceilingVerdict?.judge();
|
|
1023
|
-
applyLiveReadFace(r.effective, swapRunnerDeps, "boot-deferred");
|
|
1024
|
-
markApplied(lateGen, r.effective.version);
|
|
1025
|
-
const latePlane = modelPlaneCommitted(applyReportLate);
|
|
1026
|
-
if (latePlane)
|
|
1027
|
-
appliedPlaneEff = r.effective;
|
|
1028
|
-
planeDeferredNoHandoff = undefined;
|
|
1029
|
-
await adoptCenterPrompts(r.effective, lateVerdict.prompts, "boot-deferred");
|
|
1030
|
-
if (latePlane)
|
|
1031
|
-
markRosterLanded(r.effective);
|
|
1116
|
+
const applyReportLate = hotLate.report;
|
|
1032
1117
|
if (!fullyLandedForLkg(r, applyReportLate)) {
|
|
1033
1118
|
ccEtag = undefined;
|
|
1034
1119
|
const refusedLate = applyReportLate ? refusedGroups(applyReportLate) : [];
|
|
@@ -1069,10 +1154,13 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
1069
1154
|
ccTimer = undefined;
|
|
1070
1155
|
}
|
|
1071
1156
|
credentialRenewer?.stop();
|
|
1157
|
+
unwatchCredential?.();
|
|
1158
|
+
unwatchCredential = undefined;
|
|
1072
1159
|
},
|
|
1073
1160
|
centerCredentialState() {
|
|
1074
1161
|
return cc === undefined ? undefined : buildCenterCredentialHealthView(cc.credential.health(), credentialRenewer);
|
|
1075
1162
|
},
|
|
1163
|
+
centerIdentityNoticeState: () => tier.notice(),
|
|
1076
1164
|
};
|
|
1077
1165
|
}
|
|
1078
1166
|
//# sourceMappingURL=web-admin.js.map
|
|
@@ -15,6 +15,7 @@ import { type WorkflowRun, type WorkflowRunStore } from "@sema-agent/core";
|
|
|
15
15
|
import type { ServiceConfig } from "../config.js";
|
|
16
16
|
import { FleetEventBus } from "../fleet/fleet-bus.js";
|
|
17
17
|
import { type WorkflowAgentSessionIndex } from "../orchestration/workflow-agent-session-index.js";
|
|
18
|
+
import type { WorkflowParkDecisionStore } from "../orchestration/workflow-park-decision.js";
|
|
18
19
|
import type { Logger } from "../observability/logger.js";
|
|
19
20
|
import type { Metrics } from "../observability/metrics.js";
|
|
20
21
|
import { type WorkflowCompletionInbox } from "../orchestration/workflow-completion-inbox.js";
|
|
@@ -49,5 +50,6 @@ export declare function createWorkflowOrchestration(ctx: WorkflowOrchestrationCt
|
|
|
49
50
|
publishTerminalFleetRow?: (id: string, run: WorkflowRun) => void;
|
|
50
51
|
};
|
|
51
52
|
workflowAgentSessionIndex: WorkflowAgentSessionIndex | undefined;
|
|
53
|
+
workflowParkDecisions: WorkflowParkDecisionStore | undefined;
|
|
52
54
|
};
|
|
53
55
|
//# sourceMappingURL=workflow-orchestration.d.ts.map
|
|
@@ -66,6 +66,7 @@ export function createWorkflowOrchestration(ctx) {
|
|
|
66
66
|
? backend.workflowAgentSessionIndex()
|
|
67
67
|
: new LocalWorkflowAgentSessionIndex(join(config.localDataRoot ?? localRoot, "workflows"), undefined))
|
|
68
68
|
: undefined;
|
|
69
|
+
const workflowParkDecisions = config.selfOrchestrationEnabled && backend !== undefined && (sqlWorkflowRunStore !== undefined || backend.kind === "local") ? backend.workflowParkDecisions?.() : undefined;
|
|
69
70
|
const workflowRunStore = baseWorkflowRunStore
|
|
70
71
|
? new JournalingWorkflowRunStore(baseWorkflowRunStore, workflowNotifyGate, fleetBus, workflowAgentSessionIndex)
|
|
71
72
|
: undefined;
|
|
@@ -82,7 +83,7 @@ export function createWorkflowOrchestration(ctx) {
|
|
|
82
83
|
return {
|
|
83
84
|
sqlWorkflowRunStore, workflowNotifyJournal, workflowCompletionInbox, deliverWorkflowCompletion,
|
|
84
85
|
workflowNotifyGate, fleetBus, workflowRunStore, workflowJournalStore, outcomeSink,
|
|
85
|
-
workflowAgentRegistry, subagentSteerRegistry, workflowRecoverOpts, workflowAgentSessionIndex,
|
|
86
|
+
workflowAgentRegistry, subagentSteerRegistry, workflowRecoverOpts, workflowAgentSessionIndex, workflowParkDecisions,
|
|
86
87
|
};
|
|
87
88
|
}
|
|
88
89
|
//# sourceMappingURL=workflow-orchestration.js.map
|
package/dist/brain.js
CHANGED
|
@@ -9,6 +9,7 @@ import { openaiRouteBaseUrl } from "./model-route-endpoint.js";
|
|
|
9
9
|
import { catalogEntryFingerprint } from "./web-admin-client/restart-signal.js";
|
|
10
10
|
import { buildDisplaySafeRefusal, buildDisplaySafeUrl } from "./trace/redact.js";
|
|
11
11
|
import { createModelReachBrain } from "./model-unreachable-notice.js";
|
|
12
|
+
import { breakerKeyOf, routeDigestOf } from "./breaker-key.js";
|
|
12
13
|
function isOffDeploymentRoot(baseUrl, config) {
|
|
13
14
|
if (!baseUrl)
|
|
14
15
|
return false;
|
|
@@ -20,6 +21,9 @@ function isOffDeploymentRoot(baseUrl, config) {
|
|
|
20
21
|
function deploymentGatewayRoots(config) {
|
|
21
22
|
return config.gatewayBaseUrl !== undefined ? [config.gatewayBaseUrl, ...config.gatewayFallbackUrls] : [];
|
|
22
23
|
}
|
|
24
|
+
function breakerRoutesOf(config, r) {
|
|
25
|
+
return r.circuitBreaker ? deploymentGatewayRoots(config).slice(0, -1) : [];
|
|
26
|
+
}
|
|
23
27
|
function deploymentGatewayKey(config) {
|
|
24
28
|
return config.gatewayBaseUrl !== undefined ? config.gatewayApiKey : undefined;
|
|
25
29
|
}
|
|
@@ -53,6 +57,7 @@ export function createBrainAssembly(config, deps = {}) {
|
|
|
53
57
|
? { maxRetries: FAST_FAIL_MAX_RETRIES }
|
|
54
58
|
: {};
|
|
55
59
|
const routes = deploymentGatewayRoots(config);
|
|
60
|
+
const breakerRoutes = breakerRoutesOf(config, r);
|
|
56
61
|
const openaiBrains = routes.map((baseUrl, i) => {
|
|
57
62
|
const gatewayKey = deploymentGatewayKey(config);
|
|
58
63
|
const brain = constructRouteBrain(i === 0 ? "gateway route" : `gateway fallback route[${i - 1}]`, [baseUrl], () => createOpenAIBrain({
|
|
@@ -62,13 +67,12 @@ export function createBrainAssembly(config, deps = {}) {
|
|
|
62
67
|
fetchImpl,
|
|
63
68
|
...timeouts,
|
|
64
69
|
}));
|
|
65
|
-
|
|
66
|
-
return r.circuitBreaker && !isLast
|
|
70
|
+
return i < breakerRoutes.length
|
|
67
71
|
? createCircuitBreakerBrain(brain, {
|
|
68
72
|
failureThreshold: r.failureThreshold,
|
|
69
73
|
cooldownMs: r.cooldownMs,
|
|
70
74
|
state: breakerState,
|
|
71
|
-
key: (m) =>
|
|
75
|
+
key: (m) => breakerKeyOf(m, baseUrl),
|
|
72
76
|
})
|
|
73
77
|
: brain;
|
|
74
78
|
});
|
|
@@ -206,6 +210,7 @@ export function brainSummary(config) {
|
|
|
206
210
|
idleTimeoutMs: r.idleTimeoutMs,
|
|
207
211
|
circuitBreaker: breakerActive,
|
|
208
212
|
circuitBreakerRequested: r.circuitBreaker,
|
|
213
|
+
circuitBreakerRoutes: breakerRoutesOf(config, r).map((u) => ({ route: buildDisplaySafeUrl(u), digest: routeDigestOf(u) })),
|
|
209
214
|
gatewayRetryCap: config.gatewayMaxRetries !== undefined
|
|
210
215
|
? `env:${config.gatewayMaxRetries}`
|
|
211
216
|
: hasFailover || r.circuitBreaker || config.degrade?.reactive
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Model } from "@sema-agent/core";
|
|
2
|
+
/** 一条路由的身份摘要(键的路由段;启动日志把它与该路由的展示串并排印出,运维据此把错误文本 / 表行对回路由)。 */
|
|
3
|
+
export declare function routeDigestOf(baseUrl: string): string;
|
|
4
|
+
/** 断路器键:`<头段>@<路由摘要>`,头段 = `<provider>:<model id>`(放不下列宽预算时见 {@link boundedHead})。provider 缺席按 `openai`(与 core 默认键同一个前半)。恒 ≤ 190 字节。 */
|
|
5
|
+
export declare function breakerKeyOf(model: Pick<Model, "provider" | "id">, baseUrl: string): string;
|
|
6
|
+
//# sourceMappingURL=breaker-key.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { routeKeyOf } from "@sema-agent/core";
|
|
3
|
+
const ROUTE_DIGEST_HEX = 24;
|
|
4
|
+
const BREAKER_KEY_MAX_BYTES = 190;
|
|
5
|
+
const HEAD_MAX_BYTES = BREAKER_KEY_MAX_BYTES - 1 - ROUTE_DIGEST_HEX;
|
|
6
|
+
const HEAD_DIGEST_HEX = 16;
|
|
7
|
+
const sha256Hex = (text) => createHash("sha256").update(text, "utf8").digest("hex");
|
|
8
|
+
export function routeDigestOf(baseUrl) {
|
|
9
|
+
return sha256Hex(routeKeyOf(baseUrl)).slice(0, ROUTE_DIGEST_HEX);
|
|
10
|
+
}
|
|
11
|
+
export function breakerKeyOf(model, baseUrl) {
|
|
12
|
+
return `${boundedHead(`${model.provider ?? "openai"}:${model.id}`)}@${routeDigestOf(baseUrl)}`;
|
|
13
|
+
}
|
|
14
|
+
function boundedHead(head) {
|
|
15
|
+
if (Buffer.byteLength(head, "utf8") <= HEAD_MAX_BYTES)
|
|
16
|
+
return head;
|
|
17
|
+
const tail = `~${sha256Hex(head).slice(0, HEAD_DIGEST_HEX)}`;
|
|
18
|
+
let prefix = "";
|
|
19
|
+
let used = 0;
|
|
20
|
+
for (const ch of head) {
|
|
21
|
+
const n = Buffer.byteLength(ch, "utf8");
|
|
22
|
+
if (used + n > HEAD_MAX_BYTES - tail.length)
|
|
23
|
+
break;
|
|
24
|
+
prefix += ch;
|
|
25
|
+
used += n;
|
|
26
|
+
}
|
|
27
|
+
return `${prefix}${tail}`;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=breaker-key.js.map
|
|
@@ -10,11 +10,14 @@ export declare function echoCallerText(text: string, opts?: EchoCallerTextOption
|
|
|
10
10
|
/** 句子里点名一个值的写法:{@link echoCallerText} 外加一对双引号。 */
|
|
11
11
|
export declare function quotedCallerText(text: string): string;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* (请求腿 / 声明腿同读),本函数只管回显 —— 回显清洗是消费方按自己的腿定的(契约包的判官模块头注同此分工)。
|
|
13
|
+
* 数据截断(**不是**回显):前 `max` 字 + `…(总长)`;不超则原样。给喂回模型 / 交给 hook 的**数据**用 —— 读的一方(模型、hook 作者)看得出被截、截掉多少。
|
|
14
|
+
* 不剥控制与双向字符:数据要原样(exit 2 的多行 stderr 保行)。写进日志字段 / 回到人面前的串**不用**它,用 {@link echoCallerText}。
|
|
16
15
|
*/
|
|
17
|
-
export declare function
|
|
18
|
-
/**
|
|
19
|
-
|
|
16
|
+
export declare function clipDataText(s: string, max: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* 硬帽:前 `max` 字,什么也不加;不超则原样,缺席(`undefined`)透传。给带 schema `.max()` 的 wire 字段用(审批卡:整只 ask 不能因为一个 200 KB 的字段落不了库)——
|
|
19
|
+
* 截断记号会让串超过 schema 的上限,所以这里没有记号;也不剥控制与双向字符(卡上的串是要被人审的那一串,清洗会让「看到的」与「将执行的」不是同一个东西)。
|
|
20
|
+
*/
|
|
21
|
+
export declare function capText(s: string, max: number): string;
|
|
22
|
+
export declare function capText(s: string | undefined, max: number): string | undefined;
|
|
20
23
|
//# sourceMappingURL=caller-text-echo.d.ts.map
|