@sema-agent/server 7.130.0 → 7.132.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 +396 -0
- package/README.md +13 -6
- package/README.zh-CN.md +9 -5
- package/USAGE.md +187 -50
- package/dist/approval-card.d.ts +3 -1
- package/dist/approval-card.js +2 -3
- package/dist/audit.d.ts +7 -10
- package/dist/audit.js +4 -1
- package/dist/auth-bridge.d.ts +4 -0
- package/dist/auth-bridge.js +10 -11
- package/dist/bench/s1/live-deps.js +2 -0
- package/dist/boot/deployment-mods.d.ts +31 -0
- package/dist/boot/deployment-mods.js +26 -0
- package/dist/boot/execution-env.d.ts +1 -1
- package/dist/boot/execution-env.js +19 -6
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/read-deny-anchor-audit.d.ts +17 -0
- package/dist/boot/read-deny-anchor-audit.js +36 -0
- package/dist/boot/resolve-spec.d.ts +1 -5
- package/dist/boot/resolve-spec.js +56 -61
- package/dist/boot/runner-deps.d.ts +19 -8
- package/dist/boot/runner-deps.js +14 -2
- package/dist/boot/session-faces.d.ts +1 -7
- package/dist/boot/stage-02-web-admin-pull.js +9 -1
- package/dist/boot/stage-03-store-backend.d.ts +1 -1
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.d.ts +4 -4
- package/dist/boot/stage-05-execution-env.js +7 -10
- package/dist/boot/stage-06-runners.d.ts +2 -2
- package/dist/boot/stage-06-runners.js +5 -4
- package/dist/boot/stage-07-capability-layer.d.ts +2 -2
- package/dist/boot/stage-07-capability-layer.js +3 -3
- package/dist/boot/stage-08-reapers.d.ts +2 -2
- package/dist/boot/stage-09-leader.d.ts +3 -9
- package/dist/boot/stage-10-http-server.d.ts +3 -9
- package/dist/boot/stage-10-http-server.js +12 -10
- package/dist/boot/stores.d.ts +1 -1
- package/dist/boot/stores.js +5 -6
- package/dist/boot/web-admin.d.ts +0 -3
- package/dist/boot/web-admin.js +35 -35
- package/dist/brain.js +17 -22
- package/dist/budget.js +5 -4
- package/dist/caller-text-echo.d.ts +20 -0
- package/dist/caller-text-echo.js +24 -0
- package/dist/capabilities/brand-identity.d.ts +26 -0
- package/dist/capabilities/brand-identity.js +27 -0
- package/dist/capabilities/builtin-tools.js +2 -1
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/center-prompts.d.ts +32 -59
- package/dist/capabilities/center-prompts.js +18 -32
- package/dist/capabilities/composite-members.d.ts +1 -0
- package/dist/capabilities/composite-members.js +1 -0
- package/dist/capabilities/engine-capabilities.js +2 -1
- package/dist/capabilities/hands-lane.d.ts +9 -6
- package/dist/capabilities/hands-lane.js +3 -3
- package/dist/capabilities/host-tool-names.d.ts +17 -0
- package/dist/capabilities/host-tool-names.js +15 -0
- package/dist/capabilities/mcp-probe.d.ts +14 -1
- package/dist/capabilities/mcp-probe.js +22 -133
- package/dist/capabilities/repo-tools.js +4 -3
- package/dist/capabilities/scenarios.d.ts +42 -47
- package/dist/capabilities/scenarios.js +19 -35
- package/dist/capabilities/select-environment-tool.js +2 -1
- package/dist/capabilities/send-user-file-tool.d.ts +0 -1
- package/dist/capabilities/send-user-file-tool.js +2 -2
- package/dist/capabilities/skills.d.ts +19 -4
- package/dist/capabilities/skills.js +30 -10
- package/dist/capabilities/tool-defer.js +2 -1
- package/dist/config-catalog.js +22 -11
- package/dist/config-invariants.js +2 -2
- package/dist/config-lkg.d.ts +9 -9
- package/dist/config-lkg.js +20 -4
- package/dist/config-provider.d.ts +3 -1
- package/dist/config-provider.js +14 -6
- package/dist/config-types.d.ts +13 -9
- package/dist/config.d.ts +2 -2
- package/dist/config.js +34 -20
- package/dist/device-ws-protocol.d.ts +1 -1
- package/dist/device-ws-protocol.js +1 -0
- package/dist/elicitation.d.ts +7 -0
- package/dist/elicitation.js +20 -5
- package/dist/env-name-allowlist-knobs.d.ts +12 -2
- package/dist/env-name-allowlist-knobs.js +5 -4
- package/dist/exec-bounds.d.ts +15 -3
- package/dist/exec-bounds.js +4 -0
- package/dist/execution-lane-caps.d.ts +9 -2
- package/dist/execution-lane-caps.js +11 -0
- package/dist/hooks/classic-stations.d.ts +86 -0
- package/dist/hooks/classic-stations.js +27 -0
- package/dist/hooks/hook-llm.d.ts +8 -5
- package/dist/hooks/hook-llm.js +80 -37
- package/dist/hooks/hook-runner.d.ts +273 -75
- package/dist/hooks/hook-runner.js +293 -317
- package/dist/http/admission.d.ts +8 -2
- package/dist/http/admission.js +103 -59
- package/dist/http/approval-sweeps.js +59 -18
- package/dist/http/checkpoint-ctx.d.ts +36 -18
- package/dist/http/checkpoint-ctx.js +14 -10
- package/dist/http/claimed-run.d.ts +13 -0
- package/dist/http/claimed-run.js +15 -0
- package/dist/http/device-placement.js +5 -10
- package/dist/http/dispatch.d.ts +0 -4
- package/dist/http/dispatch.js +6 -10
- package/dist/http/durable-run-leg.d.ts +2 -1
- package/dist/http/durable-run-leg.js +5 -3
- package/dist/http/health-self-report.d.ts +7 -5
- package/dist/http/health-self-report.js +4 -18
- package/dist/http/principal-gate.d.ts +23 -6
- package/dist/http/principal-gate.js +24 -5
- package/dist/http/refusal-body.d.ts +21 -0
- package/dist/http/refusal-body.js +4 -0
- package/dist/http/request-guards.d.ts +27 -0
- package/dist/http/request-guards.js +24 -3
- package/dist/http/resume-legs.d.ts +25 -0
- package/dist/http/resume-legs.js +48 -26
- package/dist/http/routes/approvals-assistant.js +1 -1
- package/dist/http/routes/capabilities.js +7 -17
- package/dist/http/routes/diagnostics.js +1 -1
- package/dist/http/routes/rules.js +2 -2
- package/dist/http/routes/runs.js +13 -17
- package/dist/http/routes/session-sync.js +4 -2
- package/dist/http/routes/sessions.js +23 -11
- package/dist/http/routes/shared-memory.js +2 -13
- package/dist/http/routes/side-query.js +2 -3
- package/dist/http/routes/tasks.js +34 -19
- package/dist/http/scenario-read-face.d.ts +14 -0
- package/dist/http/scenario-read-face.js +5 -0
- package/dist/http/send.d.ts +13 -1
- package/dist/http/send.js +12 -1
- package/dist/http/server.d.ts +37 -23
- package/dist/http/server.js +30 -4
- package/dist/http/stored-body-replay.d.ts +10 -3
- package/dist/http/stored-body-replay.js +27 -6
- package/dist/http/submit-ctx.d.ts +25 -0
- package/dist/http/submit-ctx.js +39 -0
- package/dist/http/wire-types.d.ts +18 -5
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/lane-home-probe.d.ts +43 -0
- package/dist/lane-home-probe.js +35 -0
- package/dist/limit-refusal.d.ts +47 -0
- package/dist/limit-refusal.js +12 -0
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +3 -11
- package/dist/mcp-assertion-header.js +3 -9
- package/dist/mcp-tool-faces.d.ts +5 -0
- package/dist/mcp-tool-faces.js +5 -1
- package/dist/memory-scope.d.ts +1 -1
- package/dist/model-entry-refusal.d.ts +1 -7
- package/dist/model-provider.d.ts +39 -12
- package/dist/model-provider.js +19 -2
- package/dist/model-route-endpoint.d.ts +52 -12
- package/dist/model-route-endpoint.js +48 -26
- package/dist/model-route-gap.d.ts +5 -4
- package/dist/model-route-gap.js +1 -1
- package/dist/model-select.d.ts +58 -0
- package/dist/model-select.js +31 -0
- package/dist/namespaced-rule-name.d.ts +7 -4
- package/dist/namespaced-rule-name.js +4 -3
- package/dist/observability/cost-taxonomy.d.ts +7 -7
- package/dist/observability/fail-open.d.ts +53 -12
- package/dist/observability/fail-open.js +47 -7
- package/dist/observability/metrics.js +3 -1
- package/dist/observability/prompt-manifest.d.ts +47 -82
- package/dist/observability/prompt-manifest.js +119 -17
- package/dist/observability/run-terminal.js +14 -6
- package/dist/observability/secret-env-scrub.d.ts +13 -1
- package/dist/observability/secret-env-scrub.js +13 -1
- package/dist/observability/tool-trace.d.ts +16 -21
- package/dist/observability/tool-trace.js +51 -42
- package/dist/per-task-image.d.ts +7 -1
- package/dist/per-task-image.js +3 -3
- package/dist/plain-string-record.d.ts +25 -0
- package/dist/plain-string-record.js +32 -0
- package/dist/plugins/blob-backend.d.ts +68 -13
- package/dist/plugins/blob-backend.js +53 -10
- package/dist/plugins/checkpoint-store-sql.d.ts +14 -4
- package/dist/plugins/checkpoint-store-sql.js +39 -26
- package/dist/plugins/k8s-bg-scripts.d.ts +11 -0
- package/dist/plugins/k8s-bg-scripts.js +22 -0
- package/dist/plugins/local-checkpoint-store.js +5 -2
- package/dist/plugins/local-session-store.js +3 -3
- package/dist/plugins/one-time-migrations.d.ts +147 -91
- package/dist/plugins/one-time-migrations.js +372 -208
- package/dist/plugins/permission-rule-store-sql.d.ts +13 -7
- package/dist/plugins/permission-rule-store-sql.js +4 -18
- package/dist/plugins/pg-session-storage.d.ts +4 -5
- package/dist/plugins/pg-session-storage.js +7 -17
- package/dist/plugins/remote-env-adb.d.ts +6 -0
- package/dist/plugins/remote-env-adb.js +9 -4
- package/dist/plugins/remote-env-device.js +3 -0
- package/dist/plugins/remote-env-e2b.d.ts +1 -1
- package/dist/plugins/remote-env-e2b.js +21 -9
- package/dist/plugins/remote-env-host.d.ts +9 -9
- package/dist/plugins/remote-env-host.js +10 -32
- package/dist/plugins/remote-env-k8s.d.ts +95 -26
- package/dist/plugins/remote-env-k8s.js +265 -90
- package/dist/plugins/remote-env-local-docker.d.ts +20 -1
- package/dist/plugins/remote-env-local-docker.js +77 -9
- package/dist/plugins/remote-env-ssh.d.ts +15 -0
- package/dist/plugins/remote-env-ssh.js +109 -3
- package/dist/plugins/remote-shell.d.ts +0 -1
- package/dist/plugins/remote-shell.js +1 -2
- package/dist/plugins/retention-store-sql.js +6 -2
- package/dist/plugins/schema-consistency.d.ts +54 -0
- package/dist/plugins/schema-consistency.js +52 -0
- package/dist/plugins/session-epoch-anchor.d.ts +13 -0
- package/dist/plugins/session-epoch-anchor.js +23 -0
- package/dist/plugins/shared-memory-store-sql.d.ts +9 -3
- package/dist/plugins/shared-memory-store-sql.js +5 -16
- package/dist/plugins/sql-driver.d.ts +141 -0
- package/dist/plugins/sql-driver.js +115 -1
- package/dist/plugins/sql-errors.d.ts +41 -0
- package/dist/plugins/sql-errors.js +36 -0
- package/dist/plugins/store-backend.js +2 -1
- package/dist/plugins/tidb-session-storage.d.ts +7 -11
- package/dist/plugins/tidb-session-storage.js +6 -16
- package/dist/plugins/tidb-session-store.js +1 -1
- package/dist/prompts-domain-validate.d.ts +17 -61
- package/dist/prompts-domain-validate.js +9 -119
- package/dist/question.d.ts +18 -9
- package/dist/question.js +21 -13
- package/dist/request-key-closure.d.ts +4 -4
- package/dist/request-key-closure.js +18 -13
- package/dist/rule-entry-list.d.ts +134 -24
- package/dist/rule-entry-list.js +162 -30
- package/dist/run-local.d.ts +3 -3
- package/dist/run-local.js +26 -25
- package/dist/runs.d.ts +48 -2
- package/dist/runs.js +61 -2
- package/dist/server-secret-env.d.ts +44 -18
- package/dist/server-secret-env.js +49 -8
- package/dist/session-incarnation.d.ts +15 -5
- package/dist/session-incarnation.js +16 -9
- package/dist/session-titler.js +12 -2
- package/dist/spec-fields.d.ts +34 -18
- package/dist/spec-fields.js +46 -53
- package/dist/sql-engine-posture.d.ts +29 -4
- package/dist/sql-engine-posture.js +36 -1
- package/dist/stored-request-hooks-m20.d.ts +23 -0
- package/dist/stored-request-hooks-m20.js +124 -0
- package/dist/stored-request-tool-axes-m19.d.ts +20 -5
- package/dist/stored-request-tool-axes-m19.js +30 -2
- package/dist/task-a2a.d.ts +9 -1
- package/dist/task-a2a.js +73 -47
- package/dist/task-mcp.d.ts +54 -102
- package/dist/task-mcp.js +194 -92
- package/dist/task-settings.d.ts +47 -25
- package/dist/task-settings.js +46 -61
- package/dist/text-bidi.d.ts +3 -46
- package/dist/text-bidi.js +3 -3
- package/dist/tool-approval.d.ts +1 -1
- package/dist/trace/core-keyset-guard.d.ts +24 -4
- package/dist/trace/engine-notice-wire.d.ts +11 -3
- package/dist/trace/engine-notice-wire.js +8 -1
- package/dist/trace/ledger-events.d.ts +3 -1
- package/dist/trace/ledger-sink.d.ts +29 -0
- package/dist/trace/ledger-sink.js +15 -1
- package/dist/trace/model-segment.js +1 -1
- package/dist/trace/project.d.ts +25 -6
- package/dist/trace/project.js +68 -22
- package/dist/trace/wire-projection-faces.d.ts +80 -2
- package/dist/trace/wire-projection-faces.js +23 -1
- package/dist/user-authored-text.d.ts +7 -0
- package/dist/user-authored-text.js +3 -0
- package/dist/web-admin-client/apply-effective.js +10 -5
- package/dist/web-admin-client/candidate-gate.d.ts +6 -6
- package/dist/web-admin-client/candidate-gate.js +3 -3
- package/dist/web-admin-client/http-client.js +0 -6
- package/dist/web-admin-client/read-warnings.d.ts +13 -0
- package/dist/web-admin-client/read-warnings.js +10 -0
- package/dist/web-admin-client/skills-mcp.d.ts +3 -0
- package/dist/web-admin-client/skills-mcp.js +9 -6
- package/dist/web-admin-client/types.d.ts +3 -4
- package/dist/workspace-cache.d.ts +35 -0
- package/dist/workspace-cache.js +36 -0
- package/dist/workspace-space.d.ts +3 -2
- package/dist/workspace-space.js +2 -0
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +8 -1
- package/package.json +4 -4
- package/scripts/drain-check-local.mjs +37 -3
- package/scripts/drain-check.mysql.sql +30 -2
- package/scripts/drain-check.pg.sql +29 -2
- package/dist/capabilities/memory-notice.d.ts +0 -138
- package/dist/capabilities/memory-notice.js +0 -64
- package/dist/capabilities/prompt.d.ts +0 -17
- package/dist/capabilities/prompt.js +0 -6
- package/dist/mcp-content-origin.d.ts +0 -34
- package/dist/mcp-content-origin.js +0 -10
- package/dist/tool-axis-words.d.ts +0 -27
- package/dist/tool-axis-words.js +0 -9
- package/dist/wire-name-bound.d.ts +0 -14
- package/dist/wire-name-bound.js +0 -13
|
@@ -4,6 +4,7 @@ import { createSessionTitler } from "../session-titler.js";
|
|
|
4
4
|
import { cardRuleScopeRoot } from "../task-cwd.js";
|
|
5
5
|
import { ForkRoutingSessionStore } from "../plugins/fork-routing-session-store.js";
|
|
6
6
|
import { withoutHands } from "../capabilities/hands-lane.js";
|
|
7
|
+
import { isBrandedDeployment } from "../capabilities/brand-identity.js";
|
|
7
8
|
import { redactSecrets } from "../trace/redact.js";
|
|
8
9
|
import { hasServiceAuth } from "../http/server.js";
|
|
9
10
|
import { workflowModelAllowlistFor } from "../task-workflow.js";
|
|
@@ -23,7 +24,7 @@ import { createSharedMemoryScopeAuthorizer } from "../shared-memory-scope-author
|
|
|
23
24
|
import { parkedAskRedeem, runStore } from "./late-binds.js";
|
|
24
25
|
import { withInternalRunEnvs } from "../internal-run-env.js";
|
|
25
26
|
export function runStage06(ctx) {
|
|
26
|
-
const { backend, backgroundAgentStore, brain, engineDataRoot, config, webAdmin, consolidationValve,
|
|
27
|
+
const { backend, backgroundAgentStore, brain, engineDataRoot, config, webAdmin, consolidationValve, deploymentMods, executionEnvFactory, fileHistoryStore, localRoot, logger, lspManager, mailboxRecipientLifecycle, mailboxStore, memoryEngine, memorySyncRunner, metrics, perSessionCwd, permissionRuleProvider, pricing, rosterStore, ruleConsent, sendUserFileTaskEnvs, sessionCaptureRecordStore, sessionCaptureRecords, sessionPolicyStore, sessionStore, taskAttachmentStore, taskListLane, toolResultStore, tracer, usageWindowStore } = ctx;
|
|
27
28
|
const { sqlWorkflowRunStore, workflowNotifyJournal, workflowCompletionInbox, deliverWorkflowCompletion, workflowNotifyGate, fleetBus, workflowRunStore, workflowJournalStore, outcomeSink, workflowRecoverOpts, workflowAgentRegistry, subagentSteerRegistry, workflowAgentSessionIndex, } = createWorkflowOrchestration({ config, logger, metrics, localRoot, backend, getRunStore: () => runStore });
|
|
28
29
|
const parkCommitted = backend?.checkpoint && config.durableApproval ? createParkCommitWatch(backend.checkpoint(logger)) : undefined;
|
|
29
30
|
const checkpointStore = parkCommitted?.store;
|
|
@@ -45,7 +46,7 @@ export function runStage06(ctx) {
|
|
|
45
46
|
if (sharedMemoryStore)
|
|
46
47
|
logger.info("shared_memory_stores_enabled", { backend: backend?.kind });
|
|
47
48
|
const runnerOffloadStore = toolResultStore ?? new InMemoryToolResultStore({ maxTotalChars: 64_000_000 });
|
|
48
|
-
const commitHands = config
|
|
49
|
+
const commitHands = isBrandedDeployment(config) ? { commitCoAuthor: "Sema <noreply@vivi-ai.com>" } : undefined;
|
|
49
50
|
const retentionExecutor = backend?.retention?.({ taskAttachmentTable: taskAttachmentStore !== undefined, taskListTables: taskListLane.backend !== "memory", logger });
|
|
50
51
|
const retentionLaneStore = backend?.retentionLane?.();
|
|
51
52
|
assertRetentionLaneWirable({
|
|
@@ -120,7 +121,7 @@ export function runStage06(ctx) {
|
|
|
120
121
|
sessionCaptureRecords,
|
|
121
122
|
memorySyncRunner, toolResultStore: runnerOffloadStore, checkpointStore, sessionPolicyStore, runtimeCapsResolver, fileHistoryStore,
|
|
122
123
|
permissionRuleStore: permissionRuleProvider,
|
|
123
|
-
executionEnvFactory, lspManager, fleetBus,
|
|
124
|
+
executionEnvFactory, lspManager, fleetBus, deploymentMods, workflowRunStore, workflowJournalStore,
|
|
124
125
|
workflowAgentRegistry, workflowNotifyGate, workflowCompletionInbox, deliverWorkflowCompletion, orgMemoryAdmission,
|
|
125
126
|
governanceSeams,
|
|
126
127
|
sharedMemoryStores: sharedMemoryStore ? sharedMemoryStore : undefined,
|
|
@@ -192,7 +193,7 @@ export function runStage06(ctx) {
|
|
|
192
193
|
backgroundAgentStore,
|
|
193
194
|
mailboxStore,
|
|
194
195
|
rosterStore,
|
|
195
|
-
|
|
196
|
+
deploymentMods,
|
|
196
197
|
toolResultStore: runnerOffloadStore,
|
|
197
198
|
checkpointStore,
|
|
198
199
|
sessionPolicyStore,
|
|
@@ -75,7 +75,7 @@ export declare function runStage07(ctx: Awaited<ReturnType<typeof runStage06>>):
|
|
|
75
75
|
};
|
|
76
76
|
workflowRunStore: import("../orchestration/workflow-notify-journal.js").JournalingWorkflowRunStore | undefined;
|
|
77
77
|
workflowsCapable: boolean;
|
|
78
|
-
|
|
78
|
+
deploymentMods: readonly import("@sema-agent/core").ModRegistration<import("@sema-agent/core").EngineDollar>[];
|
|
79
79
|
deviceLane: import("./device-lane.js").DeviceLane | undefined;
|
|
80
80
|
dropSessionScoped: (sid: string) => void;
|
|
81
81
|
executionEnvFactory: import("@sema-agent/core").ExecutionEnvFactory | undefined;
|
|
@@ -150,7 +150,7 @@ export declare function runStage07(ctx: Awaited<ReturnType<typeof runStage06>>):
|
|
|
150
150
|
sessionCaptureRecordStore: import("@sema-agent/core").SessionCaptureRecordStore | undefined;
|
|
151
151
|
sessionCaptureRecords: import("../index.js").SessionCaptureRecordSource | undefined;
|
|
152
152
|
sessionStore: import("@sema-agent/core").SessionStore;
|
|
153
|
-
|
|
153
|
+
sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
|
|
154
154
|
storePosture: import("../store-posture.js").StorePosture;
|
|
155
155
|
taskAttachmentStore: import("../plugins/task-attachment-store.js").TaskAttachmentStore | undefined;
|
|
156
156
|
taskListLane: import("./task-list-lane.js").TaskListLane;
|
|
@@ -11,6 +11,7 @@ import { executionLaneOf } from "../execution-lane-caps.js";
|
|
|
11
11
|
import { loadDeploymentSkills } from "../capabilities/skills.js";
|
|
12
12
|
import { createRepoClient } from "../capabilities/repo-tools.js";
|
|
13
13
|
import { buildScenarios, builtinScenarioDetails, danglingScenarioRefusal } from "../capabilities/scenarios.js";
|
|
14
|
+
import { isBrandedDeployment } from "../capabilities/brand-identity.js";
|
|
14
15
|
import { RateLimiter } from "../observability/rate-limit.js";
|
|
15
16
|
import { explicitOperatorOk } from "../http/server.js";
|
|
16
17
|
import { selfOrchestrationDenial } from "../task-workflow.js";
|
|
@@ -133,7 +134,7 @@ export async function runStage07(ctx) {
|
|
|
133
134
|
? backend.rateLimiter(config.rateLimitPerMin, counterDegradeHook).startRefresh()
|
|
134
135
|
: new RateLimiter(config.rateLimitPerMin);
|
|
135
136
|
bindRateLimiter(rateLimiter);
|
|
136
|
-
let skills = loadDeploymentSkills(config);
|
|
137
|
+
let skills = loadDeploymentSkills(config, logger);
|
|
137
138
|
skills = await webAdmin.applyCenterCapabilities(skills);
|
|
138
139
|
const repoClient = config.gitApiBaseUrl ? createRepoClient(config.gitApiKind, config.gitApiBaseUrl, config.gitApiToken) : undefined;
|
|
139
140
|
const webSearchCfg = webSearchConfigFromEnv();
|
|
@@ -159,7 +160,6 @@ export async function runStage07(ctx) {
|
|
|
159
160
|
checkpointStore: checkpointStore ? checkpointStore : undefined,
|
|
160
161
|
ensureChildSessionDurable: ensureChildSessionDurable ? ensureChildSessionDurable : undefined,
|
|
161
162
|
taskListStoreFor: taskListLane.storeFor,
|
|
162
|
-
brandIdentity: config.configProvider === "local",
|
|
163
163
|
subagentExtraTools: sendUserFileToolSpec ? subagentSendUserFileExtraTools({ spec: sendUserFileToolSpec }) : undefined,
|
|
164
164
|
};
|
|
165
165
|
const scenarios = buildScenarios(scenarioDeps);
|
|
@@ -174,7 +174,7 @@ export async function runStage07(ctx) {
|
|
|
174
174
|
autoModeSeatMounted: runnerDeps.autoMode !== undefined,
|
|
175
175
|
})
|
|
176
176
|
: undefined;
|
|
177
|
-
const scenarioDetails = builtinScenarioDetails(scenarios, scenarioDeps);
|
|
177
|
+
const scenarioDetails = builtinScenarioDetails(scenarios, scenarioDeps, isBrandedDeployment(config));
|
|
178
178
|
const builtinScenarioNames = Object.keys(scenarioDetails);
|
|
179
179
|
webAdmin.applyCenterScenarios({ scenarioDeps, scenarios, scenarioDetails, builtinScenarioNames });
|
|
180
180
|
const defaultScenarioRefusal = danglingScenarioRefusal(config.defaultScenario, "deployment", Object.keys(scenarios));
|
|
@@ -88,7 +88,7 @@ export declare function runStage08(ctx: Awaited<ReturnType<typeof runStage07>>):
|
|
|
88
88
|
};
|
|
89
89
|
workflowRunStore: import("../orchestration/workflow-notify-journal.js").JournalingWorkflowRunStore | undefined;
|
|
90
90
|
workflowsCapable: boolean;
|
|
91
|
-
|
|
91
|
+
deploymentMods: readonly import("@sema-agent/core").ModRegistration<import("@sema-agent/core").EngineDollar>[];
|
|
92
92
|
deviceLane: import("./device-lane.js").DeviceLane | undefined;
|
|
93
93
|
dropSessionScoped: (sid: string) => void;
|
|
94
94
|
executionEnvFactory: import("@sema-agent/core").ExecutionEnvFactory | undefined;
|
|
@@ -163,7 +163,7 @@ export declare function runStage08(ctx: Awaited<ReturnType<typeof runStage07>>):
|
|
|
163
163
|
sessionCaptureRecordStore: import("@sema-agent/core").SessionCaptureRecordStore | undefined;
|
|
164
164
|
sessionCaptureRecords: import("../index.js").SessionCaptureRecordSource | undefined;
|
|
165
165
|
sessionStore: import("@sema-agent/core").SessionStore;
|
|
166
|
-
|
|
166
|
+
sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
|
|
167
167
|
storePosture: import("../store-posture.js").StorePosture;
|
|
168
168
|
taskAttachmentStore: import("../plugins/task-attachment-store.js").TaskAttachmentStore | undefined;
|
|
169
169
|
taskListLane: import("./task-list-lane.js").TaskListLane;
|
|
@@ -28,13 +28,7 @@ export declare function runStage09(ctx: Awaited<ReturnType<typeof runStage08>>):
|
|
|
28
28
|
modelId: string;
|
|
29
29
|
} | null;
|
|
30
30
|
messages: unknown[];
|
|
31
|
-
promptEpoch?:
|
|
32
|
-
epoch: number;
|
|
33
|
-
artifactDigest: string;
|
|
34
|
-
packId: string;
|
|
35
|
-
assemblyApi: number;
|
|
36
|
-
activatedBy: "session_start" | "compaction" | "legacy_migration";
|
|
37
|
-
};
|
|
31
|
+
promptEpoch?: import("@sema-agent/core").StoredPromptEpoch;
|
|
38
32
|
} | undefined>) | undefined;
|
|
39
33
|
sessionWatchRegistry: import("../session-watch.js").SessionWatchRegistry | undefined;
|
|
40
34
|
staticWiring: import("@sema-agent/core").WiringManifest;
|
|
@@ -117,7 +111,7 @@ export declare function runStage09(ctx: Awaited<ReturnType<typeof runStage08>>):
|
|
|
117
111
|
};
|
|
118
112
|
workflowRunStore: import("../orchestration/workflow-notify-journal.js").JournalingWorkflowRunStore | undefined;
|
|
119
113
|
workflowsCapable: boolean;
|
|
120
|
-
|
|
114
|
+
deploymentMods: readonly import("@sema-agent/core").ModRegistration<import("@sema-agent/core").EngineDollar>[];
|
|
121
115
|
deviceLane: import("./device-lane.js").DeviceLane | undefined;
|
|
122
116
|
dropSessionScoped: (sid: string) => void;
|
|
123
117
|
executionEnvFactory: import("@sema-agent/core").ExecutionEnvFactory | undefined;
|
|
@@ -192,7 +186,7 @@ export declare function runStage09(ctx: Awaited<ReturnType<typeof runStage08>>):
|
|
|
192
186
|
sessionCaptureRecordStore: import("@sema-agent/core").SessionCaptureRecordStore | undefined;
|
|
193
187
|
sessionCaptureRecords: import("../index.js").SessionCaptureRecordSource | undefined;
|
|
194
188
|
sessionStore: import("@sema-agent/core").SessionStore;
|
|
195
|
-
|
|
189
|
+
sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
|
|
196
190
|
storePosture: import("../store-posture.js").StorePosture;
|
|
197
191
|
taskAttachmentStore: import("../plugins/task-attachment-store.js").TaskAttachmentStore | undefined;
|
|
198
192
|
taskListLane: import("./task-list-lane.js").TaskListLane;
|
|
@@ -27,13 +27,7 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
|
|
|
27
27
|
modelId: string;
|
|
28
28
|
} | null;
|
|
29
29
|
messages: unknown[];
|
|
30
|
-
promptEpoch?:
|
|
31
|
-
epoch: number;
|
|
32
|
-
artifactDigest: string;
|
|
33
|
-
packId: string;
|
|
34
|
-
assemblyApi: number;
|
|
35
|
-
activatedBy: "session_start" | "compaction" | "legacy_migration";
|
|
36
|
-
};
|
|
30
|
+
promptEpoch?: import("@sema-agent/core").StoredPromptEpoch;
|
|
37
31
|
} | undefined>) | undefined;
|
|
38
32
|
sessionWatchRegistry: import("../session-watch.js").SessionWatchRegistry | undefined;
|
|
39
33
|
staticWiring: import("@sema-agent/core").WiringManifest;
|
|
@@ -116,7 +110,7 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
|
|
|
116
110
|
};
|
|
117
111
|
workflowRunStore: import("../orchestration/workflow-notify-journal.js").JournalingWorkflowRunStore | undefined;
|
|
118
112
|
workflowsCapable: boolean;
|
|
119
|
-
|
|
113
|
+
deploymentMods: readonly import("@sema-agent/core").ModRegistration<import("@sema-agent/core").EngineDollar>[];
|
|
120
114
|
deviceLane: import("./device-lane.js").DeviceLane | undefined;
|
|
121
115
|
dropSessionScoped: (sid: string) => void;
|
|
122
116
|
executionEnvFactory: import("@sema-agent/core").ExecutionEnvFactory | undefined;
|
|
@@ -191,7 +185,7 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
|
|
|
191
185
|
sessionCaptureRecordStore: import("@sema-agent/core").SessionCaptureRecordStore | undefined;
|
|
192
186
|
sessionCaptureRecords: import("../plugins/store-backend.js").SessionCaptureRecordSource | undefined;
|
|
193
187
|
sessionStore: import("@sema-agent/core").SessionStore;
|
|
194
|
-
|
|
188
|
+
sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
|
|
195
189
|
storePosture: import("../store-posture.js").StorePosture;
|
|
196
190
|
taskAttachmentStore: import("../plugins/task-attachment-store.js").TaskAttachmentStore | undefined;
|
|
197
191
|
taskListLane: import("./task-list-lane.js").TaskListLane;
|
|
@@ -9,7 +9,7 @@ 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 {
|
|
12
|
+
import { sqlBlobCapOf } from "../plugins/blob-backend.js";
|
|
13
13
|
import { createStoreLiveProbe } from "../store-live-probe.js";
|
|
14
14
|
import { counterStoreLabel } from "../plugins/store-backend.js";
|
|
15
15
|
import { sessionStoreLabelOf } from "../store-posture.js";
|
|
@@ -30,7 +30,7 @@ import { bindServerLateSeats } from "./late-binds.js";
|
|
|
30
30
|
import { serviceVersion } from "../service-version.js";
|
|
31
31
|
import { buildDisplaySafeUrl } from "../trace/redact.js";
|
|
32
32
|
export async function runStage10(ctx) {
|
|
33
|
-
const { approvalAskAudit, approvalExemptionStore, approvalNonceStore, authorize, backend, backgroundAgentStore, brain, breakerState, centerRuntimeCapsResolver, checkpointStore, parkCommits, config, webAdmin, consolidationValve, costQuota,
|
|
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;
|
|
34
34
|
const stores = {
|
|
35
35
|
runStore,
|
|
36
36
|
resumeAnchorStore: resumeAnchorStore ? resumeAnchorStore : undefined,
|
|
@@ -103,7 +103,6 @@ export async function runStage10(ctx) {
|
|
|
103
103
|
sessionMirrorRuling: principalCaps
|
|
104
104
|
? async (p) => (await principalCaps.executionRuling(p))?.sessionMirror
|
|
105
105
|
: undefined,
|
|
106
|
-
scenarioGate: createScenarioGate({ config, scenarios, principalCaps, logger }, "peek"),
|
|
107
106
|
instrumentDegenerate,
|
|
108
107
|
sideQueryAccounting,
|
|
109
108
|
parkedReviveSurface: parkedReviveSurface ? parkedReviveSurface : undefined,
|
|
@@ -163,7 +162,7 @@ export async function runStage10(ctx) {
|
|
|
163
162
|
workflowModelAllowlist: workflowModelAllowlistSnapshot,
|
|
164
163
|
staticWiring,
|
|
165
164
|
memoryPosture,
|
|
166
|
-
|
|
165
|
+
sqlEngine,
|
|
167
166
|
writeProtection: buildWriteProtectionPosture(config),
|
|
168
167
|
webSearchProvider,
|
|
169
168
|
sealedKeyPublic: webAdmin.sealedKeyPublic,
|
|
@@ -192,19 +191,18 @@ export async function runStage10(ctx) {
|
|
|
192
191
|
storeLiveState: storeLiveProbe ? () => storeLiveProbe.state() : undefined,
|
|
193
192
|
};
|
|
194
193
|
const knobs = {
|
|
195
|
-
|
|
196
|
-
? (
|
|
194
|
+
snapshotBlobSqlCap: sqlEngine !== undefined && !config.snapshotBlobStore
|
|
195
|
+
? () => sqlBlobCapOf(config.snapshotBlobSqlMaxBytes, sqlEngine)
|
|
197
196
|
: undefined,
|
|
198
197
|
sessionEventsMaxConnections: sessionWatchRegistry ? posIntEnv(process.env.SESSION_EVENTS_MAX_CONNS, 256, 100_000) : undefined,
|
|
199
198
|
};
|
|
200
199
|
const resolveSpec = createResolveSpec({
|
|
201
200
|
config, logger, metrics, localRoot, scenarios, principalCaps, centerRuntimeCapsResolver,
|
|
202
|
-
getCenterPrompts: () => webAdmin.getCenterPrompts(),
|
|
203
201
|
getKeyResolver: () => webAdmin.getKeyResolver(),
|
|
204
202
|
taskAttachmentStore, perSessionCwd, setSessionCwd, setSessionShellEnv, fenceSessionOwner,
|
|
205
203
|
hookLlm, hookAgent, fleetBus, hookWakeBus, resumeAnchorStore, ownerAware, taskLimitCaps, taskTimeoutSec,
|
|
206
204
|
selectEnvTool, sendUserFileToolSpec, memoryEngine, durableEnabled, approvalExemptionStore,
|
|
207
|
-
checkpointStore,
|
|
205
|
+
checkpointStore, imageIndex, perTaskImage,
|
|
208
206
|
sessionEnvSelection,
|
|
209
207
|
lockedKeys: governanceSeams.lockedKeys,
|
|
210
208
|
liveQuestionFace: question,
|
|
@@ -212,7 +210,8 @@ export async function runStage10(ctx) {
|
|
|
212
210
|
});
|
|
213
211
|
const runnerFor = createHandsRunnerSelector({ full: runner, handsless: handslessRunner });
|
|
214
212
|
const sideQuery = createSideQueryLane({ brain, config, getKeyResolver: () => webAdmin.getKeyResolver() });
|
|
215
|
-
const
|
|
213
|
+
const scenarioGate = createScenarioGate({ config, scenarios, principalCaps, logger }, "peek");
|
|
214
|
+
const server = createHttpServer({ runner, runnerFor, sideQuery, scenarioGate, config, resolveSpec, stores, coordinators, seams, observability, governance, deployment, knobs });
|
|
216
215
|
bindServerLateSeats({ config, logger, server });
|
|
217
216
|
const fleetReconcile = startFleetReconciler({
|
|
218
217
|
bus: fleetBus,
|
|
@@ -284,8 +283,11 @@ export async function runStage10(ctx) {
|
|
|
284
283
|
const failoverFirstByte = buildFailoverFirstByteNotice(config);
|
|
285
284
|
if (failoverFirstByte)
|
|
286
285
|
logger.warn("failover_first_byte_lane", failoverFirstByte);
|
|
286
|
+
const bound = server.address();
|
|
287
|
+
if (bound === null || typeof bound === "string")
|
|
288
|
+
throw new Error(`http server listening without a TCP address (server.address() = ${JSON.stringify(bound)})`);
|
|
287
289
|
logger.info("listening", {
|
|
288
|
-
port:
|
|
290
|
+
port: bound.port,
|
|
289
291
|
bindHost: bindHost ?? "0.0.0.0/::(all interfaces)",
|
|
290
292
|
...(bindHost === "127.0.0.1" && !config.bindHost
|
|
291
293
|
? { bindHostNote: "auto-narrowed to loopback: write face is unauthenticated (ALLOW_UNAUTHED_WRITES with no service token). Set BIND_HOST explicitly to override." }
|
package/dist/boot/stores.d.ts
CHANGED
|
@@ -34,6 +34,6 @@ export declare function openStores(ctx: OpenStoresCtx): Promise<{
|
|
|
34
34
|
usageWindowStore: import("@sema-agent/core").UsageWindowStore | undefined;
|
|
35
35
|
memoryPosture: import("../memory-posture.js").MemoryPosture;
|
|
36
36
|
taskListLane: import("./task-list-lane.js").TaskListLane;
|
|
37
|
-
|
|
37
|
+
sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
|
|
38
38
|
}>;
|
|
39
39
|
//# sourceMappingURL=stores.d.ts.map
|
package/dist/boot/stores.js
CHANGED
|
@@ -37,7 +37,7 @@ import { assertFileHistorySchema } from "../plugins/file-history-store-sql.js";
|
|
|
37
37
|
import { resolveStreamApprovalGate } from "../tool-approval.js";
|
|
38
38
|
import { buildMemoryBoundaryLaneFacts, buildMemoryWriteBoundaryAudit, effectiveMemoryPersistenceCapable } from "./memory-boundary.js";
|
|
39
39
|
import { buildMemoryPosture } from "../memory-posture.js";
|
|
40
|
-
import { establishSqlEnginePosture } from "../sql-engine-posture.js";
|
|
40
|
+
import { establishSqlEnginePosture, sqlPoolsOf } from "../sql-engine-posture.js";
|
|
41
41
|
import { buildStorePosture } from "../store-posture.js";
|
|
42
42
|
import { buildDisplaySafeUrl } from "../trace/redact.js";
|
|
43
43
|
const DARK_REASON_PROSE = {
|
|
@@ -393,11 +393,10 @@ export async function openStores(ctx) {
|
|
|
393
393
|
await ensureTiDBTaskListSchema(mysqlPool);
|
|
394
394
|
return createTaskListLane({ mysqlPool, pgPool, logger });
|
|
395
395
|
})();
|
|
396
|
-
let
|
|
396
|
+
let sqlEngine;
|
|
397
397
|
{
|
|
398
|
-
const mysqlPool = backend
|
|
399
|
-
|
|
400
|
-
sqlEngineFacts = await establishSqlEnginePosture({ mysqlPool, pgPool });
|
|
398
|
+
const { mysqlPool, pgPool } = sqlPoolsOf(backend);
|
|
399
|
+
sqlEngine = await establishSqlEnginePosture({ mysqlPool, pgPool });
|
|
401
400
|
if (pgPool)
|
|
402
401
|
await ensurePgDeviceSchema(async (text, params) => pgPool.query(text, params));
|
|
403
402
|
if (mysqlPool)
|
|
@@ -450,7 +449,7 @@ export async function openStores(ctx) {
|
|
|
450
449
|
return {
|
|
451
450
|
backend, storePosture, memoryEngine, engineDataRoot, memorySyncCursors, rosterStore, backgroundAgentStore, mailboxRecipientLifecycle,
|
|
452
451
|
taskAttachmentStore, mailboxStore, memoryExportBackend, memorySyncRunner, sessionStore, breakerState,
|
|
453
|
-
usageWindowStore, memoryPosture, taskListLane,
|
|
452
|
+
usageWindowStore, memoryPosture, taskListLane, sqlEngine,
|
|
454
453
|
};
|
|
455
454
|
}
|
|
456
455
|
//# sourceMappingURL=stores.js.map
|
package/dist/boot/web-admin.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type ModelRefusalsSignal } from "@sema-agent/settings-schema";
|
|
2
2
|
import { CenterPromptSource, type SwappableDeps } from "@sema-agent/core";
|
|
3
3
|
import { buildPricing } from "../budget.js";
|
|
4
|
-
import { type PromptsDomainFaces } from "../prompts-domain-validate.js";
|
|
5
4
|
import { type Scenario, type ScenarioDeps, type ScenarioDetail } from "../capabilities/scenarios.js";
|
|
6
5
|
import type { LoadedSkill } from "../capabilities/skills.js";
|
|
7
6
|
import { type ServiceConfig } from "../config.js";
|
|
@@ -96,8 +95,6 @@ export interface WebAdminRuntime {
|
|
|
96
95
|
getKeyResolver(): ((model: ModelKeyRef) => Promise<{
|
|
97
96
|
apiKey: string;
|
|
98
97
|
} | undefined>) | undefined;
|
|
99
|
-
/** 晚绑取值:center 提示词面(热采用,新任务边界生效)。 */
|
|
100
|
-
getCenterPrompts(): PromptsDomainFaces | undefined;
|
|
101
98
|
/** boot ready 门:布防(`CONFIG_REQUIRE_ROSTER=true`,远程 registry 非 dryRun)且 roster 未落地 =
|
|
102
99
|
* 计费提交 503 + /health ready:false。缺省未布防 ⇒ 恒 true。 */
|
|
103
100
|
modelReady(): boolean;
|
package/dist/boot/web-admin.js
CHANGED
|
@@ -8,8 +8,7 @@ import { buildModelRefusalsSignal } from "../model-entry-refusal.js";
|
|
|
8
8
|
import { CenterPromptSource, FilePromptArtifactStore, FilePromptSourceStateStore, MemoryPromptArtifactStore, MemoryPromptSourceStateStore, } from "@sema-agent/core";
|
|
9
9
|
import { buildPricing } from "../budget.js";
|
|
10
10
|
import { applyCenterPlugins } from "../capabilities/center-plugins.js";
|
|
11
|
-
import {
|
|
12
|
-
import { CORE_ENGINE_VERSION } from "../prompts-domain-validate.js";
|
|
11
|
+
import { applyCenterArtifact, centerSourceOnError, withPromptArtifactBackfill } from "../capabilities/center-prompts.js";
|
|
13
12
|
import { centerScenarios, centerScenarioDetails } from "../capabilities/scenarios.js";
|
|
14
13
|
import { isRosterGateArmed } from "../config.js";
|
|
15
14
|
import { defaultLkgPath, defaultSkillCacheDir, saveLkg, loadLkg, legacyV1LkgPath, migrateV1Lkg } from "../config-lkg.js";
|
|
@@ -22,11 +21,11 @@ import { buildSealedKeyPublicFace, ensureSealedKeyStore, reportExecutionPublicKe
|
|
|
22
21
|
import { applyEffective, applyCenterReadFace, buildReadFaceBaseline, buildReadFaceSwapCandidate, restoreReadFaceBaseline, mutateInPlace, logEffectiveDiff, applySkillsManifest, resolveMcpServers, resolveA2aPeers, restartReasons, modelPlaneChanged, withModelPlaneOf, fullyLandedForLkg, fetchPromptArtifact } from "../web-admin-client/facade.js";
|
|
23
22
|
import { buildConfigHandoff, buildRestartSignal, configHandoffMissing } from "../fleet/engine-signal.js";
|
|
24
23
|
import { createMcpRevocationLedger, enabledMcpEntries } from "../web-admin-client/mcp-revocation.js";
|
|
25
|
-
import { buildUnreadConfigFileFields } from "../web-admin-client/read-warnings.js";
|
|
24
|
+
import { buildUnreadConfigFileFields, buildUnreadConfigKeyFields } from "../web-admin-client/read-warnings.js";
|
|
26
25
|
import { CONFIG_DOMAIN_INVALID_NOTE, buildCandidateRejectedFields, candidateRejectionOf, judgeConfigCandidate } from "../web-admin-client/candidate-gate.js";
|
|
27
26
|
import { SHA256_HEX_RE } from "../digest-form.js";
|
|
28
27
|
import { BOOT_REJUDGE_OF_REFUSED_GROUP, createConfigApplyLedger, modelPlaneCommitted, refusedGroups } from "../web-admin-client/apply-ledger.js";
|
|
29
|
-
import { buildDeploymentPostureSeats } from "./runner-deps.js";
|
|
28
|
+
import { announceReadDenyRows, buildDeploymentPostureSeats } from "./runner-deps.js";
|
|
30
29
|
function lkgReadNote(scope) {
|
|
31
30
|
switch (scope) {
|
|
32
31
|
case "whole":
|
|
@@ -143,6 +142,8 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
143
142
|
const warnReadNotices = (r, phase) => {
|
|
144
143
|
for (const f of r.unreadFiles ?? [])
|
|
145
144
|
logger.warn("config_unread_file", buildUnreadConfigFileFields(f, localDirField.dir));
|
|
145
|
+
for (const k of r.unreadKeys ?? [])
|
|
146
|
+
logger.warn("config_unread_key", buildUnreadConfigKeyFields(k, localDirField.dir));
|
|
146
147
|
for (const d of r.droppedEntries ?? []) {
|
|
147
148
|
logger.warn("config_entry_dropped", {
|
|
148
149
|
domain: d.domain,
|
|
@@ -202,15 +203,15 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
202
203
|
applyLedger.recordApply(rep);
|
|
203
204
|
publishModelRefusals(buildModelRefusalsSignal(rep.modelRefusals));
|
|
204
205
|
};
|
|
205
|
-
let
|
|
206
|
-
let
|
|
206
|
+
let adoptedArtifact;
|
|
207
|
+
let pendingCenterTarget;
|
|
207
208
|
const retryPendingCatalog = async (phase) => {
|
|
208
|
-
if (!
|
|
209
|
+
if (!pendingCenterTarget)
|
|
209
210
|
return;
|
|
210
|
-
const { target } =
|
|
211
|
-
if (await
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
const { target } = pendingCenterTarget;
|
|
212
|
+
if (await applyCenterArtifact(catalogSource, target, adoptedArtifact, logger, phase)) {
|
|
213
|
+
adoptedArtifact = target;
|
|
214
|
+
pendingCenterTarget = undefined;
|
|
214
215
|
}
|
|
215
216
|
};
|
|
216
217
|
const promptEpochDir = join(config.localDataRoot ?? localRoot, "prompt-epoch");
|
|
@@ -253,6 +254,7 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
253
254
|
},
|
|
254
255
|
});
|
|
255
256
|
const withByDigestBackfill = (inner) => cc?.baseUrl ? withPromptArtifactBackfill(inner, (d) => fetchPromptArtifact(cc, d), logger) : inner;
|
|
257
|
+
const sourceOnError = centerSourceOnError(logger);
|
|
256
258
|
const promptSource = (() => {
|
|
257
259
|
try {
|
|
258
260
|
const bootBin = promptStateBin();
|
|
@@ -261,15 +263,15 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
261
263
|
return new CenterPromptSource({
|
|
262
264
|
store: withByDigestBackfill(new FilePromptArtifactStore(promptEpochDir)),
|
|
263
265
|
stateStore: recordingStateStore(binnedPromptStateStore(fileStateStoreFor)),
|
|
264
|
-
|
|
266
|
+
onError: sourceOnError,
|
|
265
267
|
});
|
|
266
268
|
}
|
|
267
269
|
catch (e) {
|
|
268
|
-
logger.warn("center_prompts_store_unwritable", { dir: promptEpochDir, err: String(e), note: "file-backed prompt-epoch store unavailable — memory fallback (
|
|
270
|
+
logger.warn("center_prompts_store_unwritable", { dir: promptEpochDir, err: String(e), note: "file-backed prompt-epoch store unavailable — memory fallback (the center candidate is not restart-durable); built-ins unaffected" });
|
|
269
271
|
return new CenterPromptSource({
|
|
270
272
|
store: withByDigestBackfill(new MemoryPromptArtifactStore()),
|
|
271
273
|
stateStore: recordingStateStore(binnedPromptStateStore(storePerBin(() => new MemoryPromptSourceStateStore()))),
|
|
272
|
-
|
|
274
|
+
onError: sourceOnError,
|
|
273
275
|
});
|
|
274
276
|
}
|
|
275
277
|
})();
|
|
@@ -281,14 +283,14 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
281
283
|
};
|
|
282
284
|
const rebasePromptState = async (identity, phase) => {
|
|
283
285
|
promptStateIdentity = identity;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
+
adoptedArtifact = undefined;
|
|
287
|
+
pendingCenterTarget = undefined;
|
|
286
288
|
promptPersisted = undefined;
|
|
287
289
|
try {
|
|
288
290
|
await promptSource.restore();
|
|
289
291
|
}
|
|
290
292
|
catch (e) {
|
|
291
|
-
logger.warn("center_prompts_catalog_restore_failed", { phase, err: String(e), note: "the persisted
|
|
293
|
+
logger.warn("center_prompts_catalog_restore_failed", { phase, err: String(e), note: "the persisted center-layer state for this credential identity could not be loaded — the center candidate is absent until the next adopt; built-ins unaffected" });
|
|
292
294
|
}
|
|
293
295
|
if (cc !== undefined && identity !== undefined && currentIdentity() !== identity) {
|
|
294
296
|
promptStateIdentity = undefined;
|
|
@@ -304,36 +306,33 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
304
306
|
await rebasePromptState(adoptedIdentity, phase);
|
|
305
307
|
}
|
|
306
308
|
if (prompts === undefined) {
|
|
307
|
-
if (
|
|
308
|
-
logger.info("center_prompts_cleared", { phase, note: "effective carries no prompts key (publish gate off) — built-in
|
|
309
|
-
const cleared = await
|
|
309
|
+
if (adoptedArtifact)
|
|
310
|
+
logger.info("center_prompts_cleared", { phase, note: "effective carries no prompts key (publish gate off / nothing published) — the built-in prompt serves new tasks" });
|
|
311
|
+
const cleared = await applyCenterArtifact(catalogSource, undefined, adoptedArtifact, logger, phase);
|
|
310
312
|
if (cleared) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
+
adoptedArtifact = undefined;
|
|
314
|
+
pendingCenterTarget = undefined;
|
|
313
315
|
}
|
|
314
316
|
else {
|
|
315
|
-
|
|
317
|
+
pendingCenterTarget = { target: undefined };
|
|
316
318
|
}
|
|
317
319
|
return;
|
|
318
320
|
}
|
|
319
|
-
if (
|
|
321
|
+
if (adoptedArtifact?.artifactDigest !== prompts.artifactDigest) {
|
|
320
322
|
logger.info("center_prompts_adopted", {
|
|
321
323
|
phase,
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
: {}),
|
|
326
|
-
...(prompts.catalog ? { artifactDigest: prompts.catalog.artifact.artifactDigest, catalogDigest: prompts.catalog.artifact.payload.catalogDigest, sourceRevision: prompts.catalog.sourceRevision } : {}),
|
|
327
|
-
note: "new tasks assemble the new pack (epoch re-pins at the next task boundary); in-flight sessions stay pinned",
|
|
324
|
+
artifactDigest: prompts.artifactDigest,
|
|
325
|
+
sourceRevision: prompts.sourceRevision,
|
|
326
|
+
note: "new sessions adopt this center layer (a session pins it at its first run); in-flight sessions stay pinned",
|
|
328
327
|
});
|
|
329
328
|
}
|
|
330
|
-
const transitioned = await
|
|
329
|
+
const transitioned = await applyCenterArtifact(catalogSource, prompts, adoptedArtifact, logger, phase);
|
|
331
330
|
if (transitioned) {
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
adoptedArtifact = prompts;
|
|
332
|
+
pendingCenterTarget = undefined;
|
|
334
333
|
}
|
|
335
334
|
else {
|
|
336
|
-
|
|
335
|
+
pendingCenterTarget = { target: prompts };
|
|
337
336
|
}
|
|
338
337
|
};
|
|
339
338
|
let bootConfigPending;
|
|
@@ -666,6 +665,8 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
666
665
|
restoreReadFaceBaseline(config, before);
|
|
667
666
|
throw err;
|
|
668
667
|
}
|
|
668
|
+
if (changedSeats.includes("readDenyPatterns"))
|
|
669
|
+
announceReadDenyRows(config, logger);
|
|
669
670
|
};
|
|
670
671
|
let ccTimer;
|
|
671
672
|
return {
|
|
@@ -678,7 +679,6 @@ export async function createWebAdminRuntime(ctx) {
|
|
|
678
679
|
},
|
|
679
680
|
mcpRevocationState: () => (configProvider ? mcpRevocations.view() : undefined),
|
|
680
681
|
getKeyResolver: () => keyResolver,
|
|
681
|
-
getCenterPrompts: () => centerPrompts,
|
|
682
682
|
modelReady: () => modelReadyState.ready,
|
|
683
683
|
onSelfReportChange: (listener) => {
|
|
684
684
|
selfReportListeners.push(listener);
|
package/dist/brain.js
CHANGED
|
@@ -4,7 +4,7 @@ import { buildDefaultResilience } from "./config-types.js";
|
|
|
4
4
|
import { resolveModelApiKey } from "./key-resolver.js";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { isModelKeyPoison, modelKeyPoisonIdentity } from "./key-resolver.js";
|
|
7
|
-
import {
|
|
7
|
+
import { anthropicRouteRoot, brainLaneFor, mountRoutes, routeTableOf } from "./model-provider.js";
|
|
8
8
|
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";
|
|
@@ -77,23 +77,18 @@ export function createBrainAssembly(config, deps = {}) {
|
|
|
77
77
|
: openaiBrains.length > 1
|
|
78
78
|
? createFailoverBrain(openaiBrains)
|
|
79
79
|
: openaiBrains[0];
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}))
|
|
93
|
-
: undefined;
|
|
94
|
-
let brain = anthropicBrain
|
|
95
|
-
? createRoutingBrain({ anthropic: anthropicBrain }, { fallback: gatewayBrain })
|
|
96
|
-
: gatewayBrain;
|
|
80
|
+
const brainRoutes = mountRoutes(config, (anthropicCfg) => constructRouteBrain("anthropic route", [anthropicCfg.baseUrl], () => createAnthropicBrain({
|
|
81
|
+
...(anthropicCfg.authToken
|
|
82
|
+
? { headers: { Authorization: `Bearer ${anthropicCfg.authToken}` } }
|
|
83
|
+
: { apiKey: anthropicCfg.apiKey }),
|
|
84
|
+
baseUrl: anthropicRouteRoot(anthropicCfg),
|
|
85
|
+
version: anthropicCfg.version,
|
|
86
|
+
cacheBreakpoints: anthropicCfg.cacheBreakpoints,
|
|
87
|
+
...(anthropicCfg.maxRetries !== undefined ? { maxRetries: anthropicCfg.maxRetries } : {}),
|
|
88
|
+
fetchImpl,
|
|
89
|
+
...timeouts,
|
|
90
|
+
})));
|
|
91
|
+
let brain = Object.keys(brainRoutes).length > 0 ? createRoutingBrain(brainRoutes, { fallback: gatewayBrain }) : gatewayBrain;
|
|
97
92
|
let degradeBaked = null;
|
|
98
93
|
if (config.degrade?.reactive) {
|
|
99
94
|
const degradeTo = config.degrade.to;
|
|
@@ -104,12 +99,12 @@ export function createBrainAssembly(config, deps = {}) {
|
|
|
104
99
|
const ownEnvRef = credential.apiKeyEnv !== undefined ? { [fallbackModel.name]: credential.apiKeyEnv } : {};
|
|
105
100
|
const ownSealed = credential.sealed !== undefined ? { [fallbackModel.name]: credential.sealed } : {};
|
|
106
101
|
const fbOwnApiKey = () => resolveModelApiKey(fallbackModel.name, ownEnvRef, process.env, ownSealed);
|
|
107
|
-
const anthropicLaneHop =
|
|
102
|
+
const anthropicLaneHop = brainLaneFor(fallbackModel.provider, brainRoutes) === "anthropic";
|
|
108
103
|
const fbDeclaredRoot = degradeDeclaredRoot(fallbackModel.baseUrl, config);
|
|
109
104
|
const fbDeploymentKey = deploymentGatewayKey(config);
|
|
110
|
-
const fallback = anthropicLaneHop
|
|
105
|
+
const fallback = anthropicLaneHop
|
|
111
106
|
?
|
|
112
|
-
|
|
107
|
+
brainRoutes.anthropic
|
|
113
108
|
: constructRouteBrain(`degrade target "${degradeTo}"`, [fallbackModel.baseUrl, config.gatewayBaseUrl], () => createOpenAIBrain({
|
|
114
109
|
...(fbDeclaredRoot !== undefined ? { baseUrl: fbDeclaredRoot } : {}),
|
|
115
110
|
...(fbDeploymentKey ? { apiKey: fbDeploymentKey } : {}),
|
|
@@ -223,7 +218,7 @@ export function brainSummary(config) {
|
|
|
223
218
|
const target = degradeTarget;
|
|
224
219
|
if (!target)
|
|
225
220
|
return { reactiveDegradeRoutePairing: null, reactiveDegradeRouteRefusal: null };
|
|
226
|
-
if (
|
|
221
|
+
if (brainLaneFor(target.provider, routeTableOf(config)) === "anthropic") {
|
|
227
222
|
return { reactiveDegradeRoutePairing: "anthropic-lane", reactiveDegradeRouteRefusal: null };
|
|
228
223
|
}
|
|
229
224
|
const credential = degradeCredentialIdentityOf(config, target);
|
package/dist/budget.js
CHANGED
|
@@ -93,9 +93,11 @@ export function createTracer(metrics, costQuota, modelUsage, fleetUsage, fleetLe
|
|
|
93
93
|
const weightedTokens = Math.round((e.totalInputTokens + e.completionTokens) * qw);
|
|
94
94
|
fleetUsage?.record(currentPrincipal(), e.model, e.taskId, { inputTokens: e.totalInputTokens, outputTokens: e.completionTokens, ...(e.costMicroUsd !== undefined ? { costMicroUsd: e.costMicroUsd } : {}), weightedTokens, quotaWeightAtUse: qw });
|
|
95
95
|
fleetLease?.recordSpend(currentPrincipal(), { weightedTokens, ...(e.costMicroUsd !== undefined ? { costMicroUsd: e.costMicroUsd } : {}) });
|
|
96
|
-
if (e.
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
if (e.turn !== undefined) {
|
|
97
|
+
if (e.firstTokenMs !== undefined)
|
|
98
|
+
metrics.observe("brain_first_token_ms", e.firstTokenMs);
|
|
99
|
+
metrics.observe("brain_call_latency_ms", e.latencyMs);
|
|
100
|
+
}
|
|
99
101
|
}
|
|
100
102
|
else if (e.kind === "tool.call") {
|
|
101
103
|
metrics.inc("tool_calls_total", { name: toolName(e.name), ok: String(e.ok) });
|
|
@@ -107,7 +109,6 @@ export function createTracer(metrics, costQuota, modelUsage, fleetUsage, fleetLe
|
|
|
107
109
|
metrics.inc("degraded_total", { reason: e.reason });
|
|
108
110
|
}
|
|
109
111
|
else if (e.kind === "prompt.assembled") {
|
|
110
|
-
metrics.inc("prompt_constitution_total", { mode: e.constitution });
|
|
111
112
|
promptManifests?.record(e.taskId, promptManifestRecordOf(e));
|
|
112
113
|
}
|
|
113
114
|
else if (e.kind === "config.assembled") {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** 回显的字符上限(剥完控制与双向字符之后数)。 */
|
|
2
|
+
export declare const CALLER_TEXT_ECHO_MAX_CHARS = 64;
|
|
3
|
+
/** 站点给的回显选项。 */
|
|
4
|
+
export interface EchoCallerTextOptions {
|
|
5
|
+
/** 回显的字符上限(剥完控制与双向字符之后数);不给 = {@link CALLER_TEXT_ECHO_MAX_CHARS}。必须是正整数,否则抛 `RangeError`(编程错误,不静默落成某个长度)。 */
|
|
6
|
+
readonly maxChars?: number;
|
|
7
|
+
}
|
|
8
|
+
/** 调用方写的串的回显形(不带引号):剥控制与双向字符 → 截到 `maxChars`(缺省 {@link CALLER_TEXT_ECHO_MAX_CHARS})字 + 「…」。 */
|
|
9
|
+
export declare function echoCallerText(text: string, opts?: EchoCallerTextOptions): string;
|
|
10
|
+
/** 句子里点名一个值的写法:{@link echoCallerText} 外加一对双引号。 */
|
|
11
|
+
export declare function quotedCallerText(text: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* 一个**判不过**的申报名(MCP server / A2A 对端的 `name`)在拒句 / 告警元数据里的回显:非串只说种类、空串说 `empty`,否则按本口径的引号形
|
|
14
|
+
* 外加送来的原长度(运维要的是「我那个名字长了多少」,不是一屏乱码)。判据本身不在这里:「能不能用」只有契约包的 `isUsableWireName` 一只
|
|
15
|
+
* (请求腿 / 声明腿同读),本函数只管回显 —— 回显清洗是消费方按自己的腿定的(契约包的判官模块头注同此分工)。
|
|
16
|
+
*/
|
|
17
|
+
export declare function describeBadWireName(v: unknown): string;
|
|
18
|
+
/** 一个词表外的 `contentOrigin` 值在拒句 / 告警元数据里的回显:串 ⇒ 本口径的引号形;非串 ⇒ 只说种类。判据是契约包的 `isContentOriginWord`(不在这里)。 */
|
|
19
|
+
export declare function describeBadContentOrigin(v: unknown): string;
|
|
20
|
+
//# sourceMappingURL=caller-text-echo.d.ts.map
|