@sema-agent/server 7.140.0 → 7.141.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 +290 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +75 -13
- package/dist/approval-batch-census.d.ts +27 -0
- package/dist/approval-batch-census.js +27 -0
- package/dist/approval-card.d.ts +31 -16
- package/dist/approval-card.js +6 -3
- package/dist/approval.d.ts +15 -0
- package/dist/approval.js +10 -0
- package/dist/audit.d.ts +4 -2
- package/dist/audit.js +2 -2
- package/dist/boot/device-lane.d.ts +11 -0
- package/dist/boot/device-lane.js +16 -0
- package/dist/boot/engine-lease.d.ts +24 -3
- package/dist/boot/engine-lease.js +9 -2
- package/dist/boot/execution-env.js +8 -4
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-consolidation.d.ts +1 -1
- package/dist/boot/memory-consolidation.js +1 -1
- package/dist/boot/reapers.d.ts +2 -2
- package/dist/boot/resolve-spec.js +7 -4
- package/dist/boot/session-faces.d.ts +1 -1
- package/dist/boot/session-faces.js +4 -3
- package/dist/boot/shutdown.js +5 -0
- package/dist/boot/stage-05-execution-env.js +3 -1
- package/dist/boot/stage-06-runners.d.ts +0 -2
- package/dist/boot/stage-06-runners.js +1 -1
- package/dist/boot/stage-07-capability-layer.d.ts +0 -1
- package/dist/boot/stage-07-capability-layer.js +8 -10
- package/dist/boot/stage-08-reapers.d.ts +0 -1
- package/dist/boot/stage-09-leader.d.ts +0 -1
- package/dist/boot/stage-10-http-server.d.ts +0 -1
- package/dist/boot/stage-10-http-server.js +1 -0
- package/dist/boot/stores.js +10 -4
- package/dist/boot/web-admin.js +1 -0
- package/dist/capabilities/scenarios.d.ts +1 -1
- package/dist/capability-facts.d.ts +9 -0
- package/dist/capability-facts.js +9 -0
- package/dist/card-void.d.ts +38 -0
- package/dist/card-void.js +23 -0
- package/dist/config-catalog.js +11 -8
- package/dist/config-provider.d.ts +13 -13
- package/dist/config-provider.js +19 -33
- package/dist/config-types.d.ts +26 -8
- package/dist/config.js +55 -46
- package/dist/delegated-session-owner.d.ts +21 -19
- package/dist/delegated-session-owner.js +1 -1
- package/dist/device-store.d.ts +7 -0
- package/dist/device-store.js +3 -0
- package/dist/execution-config-root.d.ts +22 -0
- package/dist/execution-config-root.js +35 -0
- package/dist/execution-lane-caps.d.ts +49 -2
- package/dist/execution-lane-caps.js +90 -13
- package/dist/execution-placement.d.ts +3 -0
- package/dist/execution-placement.js +7 -0
- package/dist/fleet/drain-entry.d.ts +3 -0
- package/dist/hosted-posture.d.ts +8 -0
- package/dist/hosted-posture.js +4 -0
- package/dist/http/admission.js +3 -3
- package/dist/http/caller-trust.d.ts +3 -2
- package/dist/http/caller-trust.js +2 -1
- package/dist/http/dispatch.js +4 -0
- package/dist/http/live-frame.d.ts +24 -0
- package/dist/http/live-frame.js +16 -0
- package/dist/http/resume-legs.js +37 -20
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/approvals-assistant.js +1 -0
- package/dist/http/routes/capabilities.js +5 -4
- package/dist/http/routes/diagnostics.d.ts +0 -19
- package/dist/http/routes/diagnostics.js +16 -2
- package/dist/http/routes/memory-bundle.d.ts +2 -2
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-policy.js +2 -2
- package/dist/http/routes/run-permission-mode.d.ts +75 -0
- package/dist/http/routes/run-permission-mode.js +170 -0
- package/dist/http/routes/session-sync.d.ts +3 -6
- package/dist/http/routes/session-sync.js +7 -2
- package/dist/http/routes/sessions.js +5 -4
- package/dist/http/routes/tasks.js +63 -66
- package/dist/http/run-read-face.js +3 -3
- package/dist/http/send.d.ts +1 -1
- package/dist/http/send.js +2 -2
- package/dist/http/server.d.ts +9 -2
- package/dist/http/sse-log.d.ts +3 -8
- package/dist/http/stored-body-replay.d.ts +3 -3
- package/dist/http/stored-body-replay.js +3 -1
- package/dist/instruction-source-notice.d.ts +7 -0
- package/dist/instruction-source-notice.js +6 -6
- package/dist/mcp-assertion-header.d.ts +4 -0
- package/dist/mcp-assertion-header.js +5 -0
- package/dist/memory-posture.d.ts +1 -1
- package/dist/memory-scope.d.ts +4 -4
- package/dist/memory-scope.js +1 -1
- package/dist/memory-sync-client.d.ts +14 -2
- package/dist/memory-sync-client.js +80 -18
- package/dist/observability/fail-open.d.ts +30 -2
- package/dist/observability/fail-open.js +30 -2
- package/dist/observability/metrics.js +0 -1
- package/dist/observability/run-terminal.d.ts +6 -2
- package/dist/observability/run-terminal.js +25 -26
- package/dist/observability/secret-env-scrub.d.ts +20 -1
- package/dist/observability/secret-env-scrub.js +14 -0
- package/dist/orchestration/workflow-completion-inbox.d.ts +5 -2
- package/dist/orchestration/workflow-completion-inbox.js +13 -5
- package/dist/orchestration/workflow-notify-journal.d.ts +5 -3
- package/dist/orchestration/workflow-notify-journal.js +2 -1
- package/dist/permission-mode-admission.d.ts +68 -0
- package/dist/permission-mode-admission.js +23 -0
- package/dist/permission-rule-list.d.ts +55 -6
- package/dist/permission-rule-list.js +52 -5
- package/dist/plugins/caching-session-store.d.ts +6 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +65 -17
- package/dist/plugins/checkpoint-store-sql.js +74 -3
- package/dist/plugins/device-store-sql.d.ts +5 -2
- package/dist/plugins/device-store-sql.js +4 -1
- package/dist/plugins/execution-placement-sql.d.ts +11 -1
- package/dist/plugins/execution-placement-sql.js +12 -1
- package/dist/plugins/file-run-store.d.ts +2 -2
- package/dist/plugins/file-run-store.js +1 -1
- package/dist/plugins/fork-routing-session-store.d.ts +10 -32
- package/dist/plugins/fork-routing-session-store.js +2 -61
- package/dist/plugins/k8s-exec-protocol.d.ts +4 -1
- package/dist/plugins/k8s-exec-protocol.js +6 -1
- package/dist/plugins/local-checkpoint-store.d.ts +10 -1
- package/dist/plugins/local-checkpoint-store.js +22 -0
- package/dist/plugins/local-session-store.d.ts +227 -35
- package/dist/plugins/local-session-store.js +518 -37
- package/dist/plugins/local-session-window.d.ts +17 -3
- package/dist/plugins/local-session-window.js +7 -13
- package/dist/plugins/memory-run-store.d.ts +2 -2
- package/dist/plugins/memory-run-store.js +1 -1
- package/dist/plugins/one-time-migrations.d.ts +42 -2
- package/dist/plugins/one-time-migrations.js +65 -3
- package/dist/plugins/pg-pool.js +3 -2
- package/dist/plugins/pg-session-storage.d.ts +2 -0
- package/dist/plugins/pg-session-storage.js +3 -2
- package/dist/plugins/remote-env-e2b.d.ts +24 -3
- package/dist/plugins/remote-env-e2b.js +131 -18
- package/dist/plugins/remote-env-k8s.d.ts +20 -1
- package/dist/plugins/remote-env-k8s.js +148 -25
- package/dist/plugins/remote-env-local-docker.d.ts +25 -11
- package/dist/plugins/remote-env-local-docker.js +87 -21
- package/dist/plugins/run-store-sql.d.ts +3 -3
- package/dist/plugins/run-store-sql.js +4 -3
- package/dist/plugins/sandbox-read-floor.d.ts +273 -0
- package/dist/plugins/sandbox-read-floor.js +608 -0
- package/dist/plugins/session-ownership.d.ts +2 -1
- package/dist/plugins/session-placement.d.ts +17 -4
- package/dist/plugins/session-placement.js +2 -1
- package/dist/plugins/session-store.d.ts +18 -20
- package/dist/plugins/session-store.js +4 -12
- package/dist/plugins/store-backend.d.ts +31 -0
- package/dist/plugins/store-backend.js +21 -4
- package/dist/plugins/store-contracts.d.ts +9 -2
- package/dist/plugins/tidb-pool.js +2 -1
- package/dist/plugins/tidb-session-store.d.ts +4 -1
- package/dist/plugins/tidb-session-store.js +3 -2
- package/dist/run-cancel-context.d.ts +34 -0
- package/dist/run-cancel-context.js +7 -0
- package/dist/runs.d.ts +39 -12
- package/dist/runs.js +68 -53
- package/dist/security.d.ts +2 -2
- package/dist/server-secret-env.d.ts +2 -1
- package/dist/server-secret-env.js +2 -4
- package/dist/session-error-wire.d.ts +22 -4
- package/dist/session-error-wire.js +16 -0
- package/dist/session-incarnation.d.ts +9 -3
- package/dist/session-sync-kernel.d.ts +42 -1
- package/dist/session-sync-kernel.js +17 -0
- package/dist/session-sync.js +16 -4
- package/dist/sql-engine-coordinates.d.ts +49 -0
- package/dist/sql-engine-coordinates.js +27 -0
- package/dist/standing-answer-grant.d.ts +31 -2
- package/dist/standing-answer-grant.js +14 -2
- package/dist/store-posture.d.ts +1 -1
- package/dist/task-a2a.d.ts +1 -1
- package/dist/task-mcp.d.ts +1 -1
- package/dist/task-settings.d.ts +52 -25
- package/dist/task-settings.js +91 -28
- package/dist/terminal.d.ts +77 -20
- package/dist/terminal.js +66 -20
- package/dist/trace/core-keyset-guard.d.ts +79 -2
- package/dist/trace/exit-seat.d.ts +7 -0
- package/dist/trace/exit-seat.js +1 -0
- package/dist/trace/model-segment.d.ts +2 -2
- package/dist/trace/redact.js +323 -90
- package/dist/trace/self-minted-wire.d.ts +168 -2
- package/dist/trace/self-minted-wire.js +63 -0
- package/dist/verifier-pause-card.d.ts +8 -0
- package/dist/verifier-pause-card.js +19 -0
- package/dist/web-admin-client/apply-effective.d.ts +5 -7
- package/dist/web-admin-client/apply-effective.js +2 -2
- package/dist/web-admin-client/candidate-gate.d.ts +1 -1
- package/dist/web-admin-client/read-warnings.d.ts +2 -2
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +3 -2
- package/package.json +2 -2
- package/wire-changes/server@7.141.0.json +367 -0
package/dist/boot/device-lane.js
CHANGED
|
@@ -56,4 +56,20 @@ export function assertDeviceLaneWired(isDeviceLane, lane, hasFactory) {
|
|
|
56
56
|
"an assembly bug, not a configuration one — refusing to start rather than silently execute in-process (#157)");
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
export async function noteDeviceRelayBindings(relay, store, logger) {
|
|
60
|
+
switch (relay.kind) {
|
|
61
|
+
case "url":
|
|
62
|
+
return;
|
|
63
|
+
case "none": {
|
|
64
|
+
const bindings = await store.countDeviceBindings();
|
|
65
|
+
if (bindings > 0)
|
|
66
|
+
logger.warn("device_relay_withdrawn_with_bindings", { bindings });
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
default: {
|
|
70
|
+
const unknownKind = relay;
|
|
71
|
+
throw new Error(`noteDeviceRelayBindings: no arm for ${JSON.stringify(unknownKind)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
59
75
|
//# sourceMappingURL=device-lane.js.map
|
|
@@ -130,6 +130,29 @@ export interface EngineLeaseExitReport {
|
|
|
130
130
|
/** 成孤儿到自退之间隔了多久;非孤儿退出时键缺席(不编 0)。 */
|
|
131
131
|
orphanedForMs?: number;
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* [ref] —— 租约窗的 wire 读数(`GET /health` 的 `engineLease`;壳持租约的触点节拍据此定,别处起的短窗引擎不再让第二句失败)。
|
|
135
|
+
*
|
|
136
|
+
* ## 报的是什么
|
|
137
|
+
* · `lingerMs` = 本腿**会执行的最短静默窗**:父还活着的窗({@link EngineLeaseDeps.lingerMs})与孤儿窗({@link EngineLeaseOrphanLane.lingerMs},只在看门狗装了时存在)取小。
|
|
138
|
+
* 取**最短**而不是「此刻生效」:此刻生效的窗在父死那一拍从 owned 窗掉到孤儿窗,按旧读数定节拍的壳会在下一次读 `/health` 之前被拆台;
|
|
139
|
+
* 最短窗是配置的性质、不随状态变,壳的触点只要比它密,在任何状态下都留得住引擎。
|
|
140
|
+
* · `tickMs` = 自退检查的采样拍。自退发生在**生效窗**满之后、至多再晚一拍(顶注 8);生效窗恒 ≥ `lingerMs`(`lingerMs` 是各窗里最短的一个),所以触点比 `lingerMs` 密 ⇒ 在任何状态下都先于自退。
|
|
141
|
+
* 读数**不预言**自退时刻:父还活着时生效的是 owned 窗,自退只会更晚。
|
|
142
|
+
*
|
|
143
|
+
* ## 一源
|
|
144
|
+
* 与租约腿自己的行为同一处铸出:`engine_lease_armed` 日志、自退判据用的窗、拍频推导(`tickMs = min(15s, 最短窗)`)和本读数读的是同一组数 ——
|
|
145
|
+
* 不存在第二处去「算一遍租约窗」。一个永远不到期的窗(owned 窗 = `Infinity` 且没有孤儿车道)不是租约:读数整个缺席,不补 0、不把 `Infinity` 送进 JSON。
|
|
146
|
+
*/
|
|
147
|
+
export interface EngineLeaseFacts {
|
|
148
|
+
readonly lingerMs: number;
|
|
149
|
+
readonly tickMs: number;
|
|
150
|
+
}
|
|
151
|
+
/** {@link createEngineLeaseTracker} 的把手:`stop()` 收摊;`facts` 现读 —— **腿还在观察**时才有(收摊 / 自退触发之后缺席,says-yes ⟺ 腿在转)。 */
|
|
152
|
+
export interface EngineLeaseHandle {
|
|
153
|
+
stop(): void;
|
|
154
|
+
readonly facts: EngineLeaseFacts | undefined;
|
|
155
|
+
}
|
|
133
156
|
export interface EngineLeaseDeps {
|
|
134
157
|
/** 活附着数 = 本副本当前**打开着的 SSE 流**条数(`drainState.attachedStreams`,由 `createHttpServer` 自赋)。 */
|
|
135
158
|
attachedStreams: () => number;
|
|
@@ -167,7 +190,5 @@ export interface EngineLeaseDeps {
|
|
|
167
190
|
now?: () => number;
|
|
168
191
|
}
|
|
169
192
|
/** 装配并**立刻**起自退检查(装配即 `engine_lease_armed`)。返回停机链用的 `stop()`。 */
|
|
170
|
-
export declare function createEngineLeaseTracker(deps: EngineLeaseDeps):
|
|
171
|
-
stop(): void;
|
|
172
|
-
};
|
|
193
|
+
export declare function createEngineLeaseTracker(deps: EngineLeaseDeps): EngineLeaseHandle;
|
|
173
194
|
//# sourceMappingURL=engine-lease.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export const ENGINE_LEASE_TICK_MS = 15_000;
|
|
2
2
|
export function createEngineLeaseTracker(deps) {
|
|
3
3
|
const orphanLane = deps.orphan;
|
|
4
|
-
const
|
|
4
|
+
const shortestLingerMs = Math.min(deps.lingerMs, orphanLane?.lingerMs ?? Number.POSITIVE_INFINITY);
|
|
5
|
+
const tickMs = deps.tickMs ?? Math.min(ENGINE_LEASE_TICK_MS, shortestLingerMs);
|
|
6
|
+
const leaseFacts = Number.isFinite(shortestLingerMs) ? Object.freeze({ lingerMs: shortestLingerMs, tickMs }) : undefined;
|
|
5
7
|
const now = deps.now ?? (() => performance.now());
|
|
6
8
|
let stopped = false;
|
|
7
9
|
let idleSince = now();
|
|
@@ -66,6 +68,11 @@ export function createEngineLeaseTracker(deps) {
|
|
|
66
68
|
stopped = true;
|
|
67
69
|
clearInterval(timer);
|
|
68
70
|
}
|
|
69
|
-
return {
|
|
71
|
+
return {
|
|
72
|
+
stop,
|
|
73
|
+
get facts() {
|
|
74
|
+
return stopped ? undefined : leaseFacts;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
70
77
|
}
|
|
71
78
|
//# sourceMappingURL=engine-lease.js.map
|
|
@@ -30,12 +30,13 @@ import { derivePkgSourceEnv } from "../sandbox-pkg-source.js";
|
|
|
30
30
|
import { effectiveHostWorkspace } from "../task-cwd.js";
|
|
31
31
|
import { taskInheritEnvRefusal } from "../hosted-posture.js";
|
|
32
32
|
import { sessionFaceOfHead } from "../session-incarnation.js";
|
|
33
|
+
import { isCodeToken } from "../terminal.js";
|
|
33
34
|
import { createCacheMissMemory } from "../workspace-cache.js";
|
|
34
35
|
import { workspaceSnapshotTimeoutOf } from "../workspace-space.js";
|
|
35
36
|
import { sayEgressPolicyReading } from "../sandbox-egress-policy.js";
|
|
36
37
|
import { sandboxPathEnvSlots, withSandboxPathEnvSlot } from "./deferred-sandbox-path-env.js";
|
|
37
38
|
import { createLaneHomeAbsenceReporter } from "../lane-home-probe.js";
|
|
38
|
-
import { REMOTE_EXEC_PROVIDER_WORDS, buildLaneHomeBootNote, buildLaneHomeClaim, capabilitiesFor, executionLaneOf, laneBindsReads, laneIsolated } from "../execution-lane-caps.js";
|
|
39
|
+
import { REMOTE_EXEC_PROVIDER_WORDS, buildLaneHomeBootNote, buildLaneHomeClaim, capabilitiesFor, executionLaneOf, laneBindsReads, laneIsolated, laneSandboxReadFloorState } from "../execution-lane-caps.js";
|
|
39
40
|
import { warnReadDenyFloorUnkept } from "./execution-lane.js";
|
|
40
41
|
function boundedSessionSetter(map, maxEntries) {
|
|
41
42
|
return (sid, value) => {
|
|
@@ -126,7 +127,6 @@ export function createK8sRunEnvFactory(k8sCfg, seats, deps) {
|
|
|
126
127
|
}, deps)(ctx);
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
|
-
const STORE_ERROR_CODE = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
130
130
|
const INCARNATION_READ_TIMEOUT = "incarnation_read_timeout";
|
|
131
131
|
async function occupantOf(seats, sessionId, taskId, boundMs) {
|
|
132
132
|
let answer;
|
|
@@ -142,7 +142,7 @@ async function occupantOf(seats, sessionId, taskId, boundMs) {
|
|
|
142
142
|
}
|
|
143
143
|
catch (e) {
|
|
144
144
|
const code = e?.code;
|
|
145
|
-
return { fault:
|
|
145
|
+
return { fault: isCodeToken(code) ? code : "incarnation_read_failed" };
|
|
146
146
|
}
|
|
147
147
|
if (answer === undefined)
|
|
148
148
|
return { unread: "incarnation_unknown" };
|
|
@@ -252,6 +252,7 @@ export function createExecutionEnv(ctx) {
|
|
|
252
252
|
...(config.remoteExec.allowInternetAccess != null ? { allowInternetAccess: config.remoteExec.allowInternetAccess } : {}),
|
|
253
253
|
...(config.remoteExec.mountPath ? { mountPath: config.remoteExec.mountPath } : {}),
|
|
254
254
|
...((env) => (env !== undefined ? { sandboxEnv: env } : {}))(sandboxLaneEnvMerged(buildSandboxLaneEnv(config, config.remoteExec.sandboxEnv))),
|
|
255
|
+
sandboxReadFloor: config.sandboxReadFloor,
|
|
255
256
|
logger,
|
|
256
257
|
metrics,
|
|
257
258
|
});
|
|
@@ -278,6 +279,7 @@ export function createExecutionEnv(ctx) {
|
|
|
278
279
|
...(config.remoteExec.workspaceSnapshotExclude ? { snapshotExclude: config.remoteExec.workspaceSnapshotExclude } : {}),
|
|
279
280
|
logger,
|
|
280
281
|
...((lane) => ({ ...(lane.env !== undefined ? { podEnv: lane.env } : {}), ...(lane.secretEnv !== undefined ? { podSecretEnv: lane.secretEnv } : {}) }))(buildSandboxLaneEnv(config, config.remoteExec.sandboxEnv)),
|
|
282
|
+
sandboxReadFloor: config.sandboxReadFloor,
|
|
281
283
|
};
|
|
282
284
|
const brokerImage = config.remoteExec.brokerImage;
|
|
283
285
|
executionEnvFactory = createK8sRunEnvFactory(k8sCfg, {
|
|
@@ -394,6 +396,7 @@ export function createExecutionEnv(ctx) {
|
|
|
394
396
|
...(config.remoteExec.network ? { network: config.remoteExec.network } : {}),
|
|
395
397
|
...(config.remoteExec.commandTimeoutMs != null ? { commandTimeoutMs: config.remoteExec.commandTimeoutMs } : {}),
|
|
396
398
|
...(config.remoteExec.env ? { env: config.remoteExec.env } : {}),
|
|
399
|
+
sandboxReadFloor: config.sandboxReadFloor,
|
|
397
400
|
});
|
|
398
401
|
}
|
|
399
402
|
if (executionEnvFactory && DEPLOYMENT_SHAPE_PREDICATES.remoteScratchpad.holds(config)) {
|
|
@@ -466,8 +469,9 @@ export function createExecutionEnv(ctx) {
|
|
|
466
469
|
const isolated = laneIsolated(executionLaneOf(config.remoteExec.provider));
|
|
467
470
|
const suspendable = DEPLOYMENT_SHAPE_PREDICATES.suspendableHands.holds(config);
|
|
468
471
|
const keepsReadFloor = capabilitiesFor(config).keepsReadFloor;
|
|
472
|
+
const sandboxReadFloor = laneSandboxReadFloorState(config);
|
|
469
473
|
const sandboxEnvKeys = [...sandboxEnvNamesInForce(config)].sort();
|
|
470
|
-
logger.info("remote_exec_enabled", { provider: config.remoteExec.provider, isolated, suspendable, keepsReadFloor, ...(sandboxEnvKeys.length > 0 ? { sandboxEnvKeys } : {}) });
|
|
474
|
+
logger.info("remote_exec_enabled", { provider: config.remoteExec.provider, isolated, suspendable, keepsReadFloor, ...(sandboxReadFloor !== undefined ? { sandboxReadFloor } : {}), ...(sandboxEnvKeys.length > 0 ? { sandboxEnvKeys } : {}) });
|
|
471
475
|
if (!isolated)
|
|
472
476
|
logger.warn("remote_exec_real_system", { provider: config.remoteExec.provider, note: buildRealSystemNote(config.remoteExec) });
|
|
473
477
|
const homeLine = buildLaneHomeBootNote(config);
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
* `memory_harvest_rejections_total{code}` + 一条 warn,见 `boot/runner-deps.ts` 的 harvest 报告站点),
|
|
41
41
|
* 等下一次非受限会话走正常门收编。
|
|
42
42
|
* ⚠️ **这一层只在 file 记忆引擎上**(受限视图 = `FileMemoryEngineBackend` 的实装,`materialize` 取它是
|
|
43
|
-
* `?? this.backend` 的可选 seam):`MEMORY_ENGINE_BACKEND=pg|
|
|
43
|
+
* `?? this.backend` 的可选 seam):`MEMORY_ENGINE_BACKEND=pg|mysql` 的两条腿读侧走库、盘上只是每任务投影,
|
|
44
44
|
* 没有「读磁盘即收编」的通道,`false` 在它们上仍买到披露/写门/零收编 harvest 三件。
|
|
45
45
|
* ⚠️ **口径别混**:受限 = **会话级 verdict 单键**(declared-false 那一个键);`writeScope:null` 的只读
|
|
46
46
|
* **平面**(请求键 `memoryWrite:false` 的 per-run 暂停 / org 层默认只读 / 双根非写面)**保持 adopt-on-read
|
|
@@ -75,7 +75,7 @@ export interface MemoryWriteBoundaryFacts {
|
|
|
75
75
|
declaredCapable: boolean | undefined;
|
|
76
76
|
/** 本部署的记忆引擎后端(`config.memoryEngineBackend`)。**只进文案**,不参与任何判决 —— 它在这里的
|
|
77
77
|
* 唯一作用是把「怎么把根挪进围栏」这句话指向**在该腿上真的有效**的那个旋钮:`MEMORY_ENGINE_DIR` 只被
|
|
78
|
-
* file 腿读(memory-scope 的 `resolveMemoryEngineRoot`),pg/
|
|
78
|
+
* file 腿读(memory-scope 的 `resolveMemoryEngineRoot`),pg/mysql 腿的根是
|
|
79
79
|
* `<LOCAL_DATA_ROOT|数据根>/memory-work`(boot/stores.ts 两支),那条腿上指 MEMORY_ENGINE_DIR 是让
|
|
80
80
|
* operator 去拧一个不接线的旋钮 —— 修不好还以为自己修了。 */
|
|
81
81
|
engineBackend: MemoryEngineBackend;
|
|
@@ -210,7 +210,7 @@ export declare function consolidationSeatBillingOf(plane: ConsolidationSeatPlane
|
|
|
210
210
|
* (结构上跑不起来由下游 D1 三条拒启臂照拒,本判决不吞);开而座落主模型 ⇒ 开 + 一行
|
|
211
211
|
* `memory_consolidation_on_main_model`(部署方显式承担,但必须知道账按主模型记)。
|
|
212
212
|
* · **未设 = 出厂缺省派生**([ref] 取代 [ref] ① 的「出厂 off」实况):
|
|
213
|
-
* 结构上跑不起来(判官 {@link consolidationDriverUnwirable} 有成因:多租户 / `MEMORY_ENGINE=off` / pg·
|
|
213
|
+
* 结构上跑不起来(判官 {@link consolidationDriverUnwirable} 有成因:多租户 / `MEMORY_ENGINE=off` / pg·mysql
|
|
214
214
|
* 记忆后端 / `MEMORY_PROVENANCE=off`)⇒ **恒关、零提示、零探针** —— 派生开撞上 D1 拒启臂 = 每台配了便宜模型的
|
|
215
215
|
* 多租户 worker 升级即起不来;而配不配便宜模型它都开不了,一句指向 `MODEL_CHEAP_ID` 的提示是误导;
|
|
216
216
|
* 座不落主模型({@link consolidationSeatBillingOf} = `own-model`)⇒ **开**;
|
|
@@ -114,7 +114,7 @@ function unwirableRefusal(code, facts) {
|
|
|
114
114
|
`(MEMORY_ENGINE_BACKEND=${facts.memoryEngineBackend}) does NOT own an engine control plane (controlPlaneRoot) — ` +
|
|
115
115
|
`core would derive one on THIS replica's local disk, and a consolidation run's resumable account would die with ` +
|
|
116
116
|
`the pod (a lost run re-mints the whole library at full model cost on the next attempt). The file memory backend ` +
|
|
117
|
-
`owns a control plane; the pg/
|
|
117
|
+
`owns a control plane; the pg/mysql memory backends do not. Set MEMORY_ENGINE_BACKEND=file, or set ` +
|
|
118
118
|
`MEMORY_CONSOLIDATION_DRIVER=off.`);
|
|
119
119
|
case "provenance-off":
|
|
120
120
|
return (`MEMORY_CONSOLIDATION_DRIVER=on is incompatible with MEMORY_PROVENANCE=off — core refuses to enable consolidation ` +
|
package/dist/boot/reapers.d.ts
CHANGED
|
@@ -167,8 +167,8 @@ interface ReapSessionsInputs {
|
|
|
167
167
|
* 的那条臂**结构上看不见**它(它从行出发枚举),只有从会话侧枚举才找得到。
|
|
168
168
|
*
|
|
169
169
|
* 两只面必须落在**host durable 店**上,而 release 这一格是承重的:
|
|
170
|
-
* · `listPlaced` = host 店的分区枚举(SQL
|
|
171
|
-
*
|
|
170
|
+
* · `listPlaced` = host 店的分区枚举(三只持久会话店都实装:SQL 两孪生读 `session_meta`,local 读会话存档行头;
|
|
171
|
+
* 店上没有这只面 ⇒ 键**不设**,core 那条腿如实不可用 —— 绝不给一个恒返回 `[]` 的假面,那会把「枚不了」读成「没有孤儿」);
|
|
172
172
|
* · `release` 对 **placed id** 必须走 host 店:路由店(`ForkRoutingSessionStore`)对一个重启后不认识
|
|
173
173
|
* 的 id 会回落 transient(进程内 no-op),那会让 core 数出一次**从未发生**的 release
|
|
174
174
|
* (`orphanPlacedReleased` 当场变成谎)而字节还在库里。故先按**持久化元组**判(一次 PK 探针),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { NodeExecutionEnv, QUESTION_AWAITS_RESUME, deriveAskEffective, expandTiers,
|
|
3
|
+
import { NodeExecutionEnv, QUESTION_AWAITS_RESUME, deriveAskEffective, expandTiers, resolveAskSeamForm } from "@sema-agent/core";
|
|
4
4
|
import { cappedCeiling } from "../budget.js";
|
|
5
5
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
6
6
|
import { SessionEnvironmentSelection, selectEnvironmentTool } from "../capabilities/select-environment-tool.js";
|
|
@@ -14,7 +14,7 @@ import { createDeploymentListExemption, gateIntentUnserviceableReason, singleUse
|
|
|
14
14
|
import { acceptShellScratchpadDir, buildEnvFacts, egressForRemoteExec, ensureScratchpadDir, resumeFactsForLane, scratchpadCoveringTaskRoot } from "../env-facts.js";
|
|
15
15
|
import { FleetEventBus } from "../fleet/fleet-bus.js";
|
|
16
16
|
import { createSettingsHooksRegistration, settingsHooksBudgetMs } from "../hooks/hook-runner.js";
|
|
17
|
-
import { HOST_POSTURE_REFUSED_CODE,
|
|
17
|
+
import { HOST_POSTURE_REFUSED_CODE, permissionModeWriteFaceRefusal, taskInheritEnvRefusal } from "../hosted-posture.js";
|
|
18
18
|
import { headerStr } from "../http/principal-gate.js";
|
|
19
19
|
import { explicitOperatorOk } from "../http/server.js";
|
|
20
20
|
import { isAtMentionable, matchCatalogModel, refusedCatalogEntry, resolveTaskModel, selectableCatalog, terminalCatalogName } from "../model-select.js";
|
|
@@ -51,6 +51,7 @@ import { TENANCY_WALL_CLOCK_BASE_SEC, enableForkFromBody, normalizeRetainSubagen
|
|
|
51
51
|
import { redactSecrets } from "../trace/redact.js";
|
|
52
52
|
import { DeferredSandboxPathEnv, sandboxPathEnvSlots } from "./deferred-sandbox-path-env.js";
|
|
53
53
|
import { executionLaneHomeDir, executionLaneOf, laneWiresExecutionEnv } from "../execution-lane-caps.js";
|
|
54
|
+
import { executionConfigRootOf } from "../execution-config-root.js";
|
|
54
55
|
import { withUnattendedLeg } from "../unattended-permission-mode.js";
|
|
55
56
|
import { fieldConflictFacts } from "../field-conflict.js";
|
|
56
57
|
function unrooted(spec) {
|
|
@@ -160,8 +161,8 @@ export function createResolveSpec(ctx) {
|
|
|
160
161
|
assertRequestImageUrls(body.images);
|
|
161
162
|
const gated = await gateScenarioAndAppend(body, auth, opts);
|
|
162
163
|
const effMode = effectivePermissionMode(body, gated.parsedSettings.settings);
|
|
163
|
-
|
|
164
|
-
const why =
|
|
164
|
+
{
|
|
165
|
+
const why = permissionModeWriteFaceRefusal(effMode, config);
|
|
165
166
|
if (why !== undefined)
|
|
166
167
|
throw new HttpError(422, why, { code: HOST_POSTURE_REFUSED_CODE });
|
|
167
168
|
}
|
|
@@ -579,9 +580,11 @@ export function createResolveSpec(ctx) {
|
|
|
579
580
|
? await ensureScratchpadDir(config.localDataRoot ?? localRoot, auth.sessionId, (msg, meta) => logger.warn(msg, { ...(meta ?? {}), sessionId: auth.sessionId }))
|
|
580
581
|
: undefined);
|
|
581
582
|
if (effectiveSettings) {
|
|
583
|
+
const configRoot = executionConfigRootOf(config);
|
|
582
584
|
const ruleBases = {
|
|
583
585
|
...(pathAdjudication.taskRoot !== undefined ? { taskRoot: pathAdjudication.taskRoot } : {}),
|
|
584
586
|
...(pathAdjudication.taskHome !== undefined ? { taskHome: pathAdjudication.taskHome } : {}),
|
|
587
|
+
...(configRoot !== undefined ? { configRoot } : {}),
|
|
585
588
|
};
|
|
586
589
|
try {
|
|
587
590
|
governed = applyTaskSettings(governedBase, effectiveSettings, ruleBases);
|
|
@@ -16,7 +16,7 @@ import type { Logger } from "../observability/logger.js";
|
|
|
16
16
|
import type { Metrics } from "../observability/metrics.js";
|
|
17
17
|
import type { WorkflowCompletionInbox } from "../orchestration/workflow-completion-inbox.js";
|
|
18
18
|
import { PlanCacheProbe } from "../plan-cache-probe.js";
|
|
19
|
-
import type
|
|
19
|
+
import { type CheckpointStoreFull, type StoreBackend, type ToolResultStoreFull } from "../plugins/store-backend.js";
|
|
20
20
|
import type { createSessionStore } from "../plugins/session-store.js";
|
|
21
21
|
import type { TaskAttachmentStore } from "../plugins/task-attachment-store.js";
|
|
22
22
|
import type { FileHistoryErasureFace } from "../file-history-capture.js";
|
|
@@ -2,6 +2,7 @@ import { buildRewindHandles, buildSessionAudit, buildSessionAuditLocal, buildSes
|
|
|
2
2
|
import { makeDegenerateInstrument } from "../degenerate-instrument.js";
|
|
3
3
|
import { PlanCacheProbe } from "../plan-cache-probe.js";
|
|
4
4
|
import { purgeScratchpadDir } from "../env-facts.js";
|
|
5
|
+
import { localSessionRowsOf } from "../plugins/store-backend.js";
|
|
5
6
|
import { setLeafAdvanceListener } from "../session-leaf-bus.js";
|
|
6
7
|
import { SessionWatchRegistry, posIntEnv } from "../session-watch.js";
|
|
7
8
|
import { defaultTaskRegistry, peerSessionBoxHandle } from "@sema-agent/core";
|
|
@@ -14,17 +15,17 @@ export function createSessionFaces(ctx) {
|
|
|
14
15
|
const { config, logger, metrics, localRoot, backend, sessionStore, runStore, checkpointStore, toolResultStore, resumeAnchorStore, approvalExemptionStore, sessionPolicyStore, taskAttachmentStore, fileHistoryErasure, workflowCompletionInbox, taskListLane, dropSessionScoped, mailboxStore, mailboxRecipientLifecycle, backgroundAgentStore, userInputLedgerStore, spaceReclaimer, } = ctx;
|
|
15
16
|
const mysqlPool = backend?.mysqlPool();
|
|
16
17
|
const auditPgPool = backend?.pgPool();
|
|
17
|
-
const
|
|
18
|
+
const auditLocalRows = localSessionRowsOf(backend);
|
|
18
19
|
const ownerAware = sessionStore;
|
|
19
20
|
const headOf = headReadOf(sessionStore);
|
|
20
|
-
const sessionAudit = mysqlPool || auditPgPool ||
|
|
21
|
+
const sessionAudit = mysqlPool || auditPgPool || auditLocalRows
|
|
21
22
|
? async (sessionId, opts) => {
|
|
22
23
|
const handles = opts !== undefined && resumeAnchorStore !== undefined ? buildRewindHandles(await resumeAnchorStore.listBySession(sessionId), opts.reader) : undefined;
|
|
23
24
|
const audit = mysqlPool
|
|
24
25
|
? await buildSessionAudit(mysqlPool, sessionId, handles)
|
|
25
26
|
: auditPgPool
|
|
26
27
|
? await buildSessionAuditPg(auditPgPool, sessionId, handles)
|
|
27
|
-
: await buildSessionAuditLocal(
|
|
28
|
+
: await buildSessionAuditLocal(auditLocalRows, sessionId, handles);
|
|
28
29
|
if (!audit)
|
|
29
30
|
return undefined;
|
|
30
31
|
const [head, placement] = await Promise.all([headOf?.(sessionId), opts !== undefined ? ownerAware.placementOf?.(sessionId) : undefined]);
|
package/dist/boot/shutdown.js
CHANGED
|
@@ -74,6 +74,7 @@ export function installShutdownHandlers(ctx) {
|
|
|
74
74
|
let closingAt = 0;
|
|
75
75
|
let parentWatch;
|
|
76
76
|
let engineLease;
|
|
77
|
+
let leaseFactsReader;
|
|
77
78
|
const hardShutdown = () => {
|
|
78
79
|
if (closing)
|
|
79
80
|
return;
|
|
@@ -280,6 +281,8 @@ export function installShutdownHandlers(ctx) {
|
|
|
280
281
|
: {}),
|
|
281
282
|
log: (event, fields) => logger.info(event, fields),
|
|
282
283
|
});
|
|
284
|
+
leaseFactsReader = () => engineLease?.facts;
|
|
285
|
+
drainState.engineLease = leaseFactsReader;
|
|
283
286
|
}
|
|
284
287
|
let disposed = false;
|
|
285
288
|
return {
|
|
@@ -302,6 +305,8 @@ export function installShutdownHandlers(ctx) {
|
|
|
302
305
|
engineLease?.stop();
|
|
303
306
|
if (drainState.enter === enterByRequest)
|
|
304
307
|
drainState.enter = undefined;
|
|
308
|
+
if (leaseFactsReader !== undefined && drainState.engineLease === leaseFactsReader)
|
|
309
|
+
drainState.engineLease = undefined;
|
|
305
310
|
},
|
|
306
311
|
};
|
|
307
312
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assembleDeploymentMods } from "./deployment-mods.js";
|
|
2
2
|
import { isBrandedDeployment } from "../capabilities/brand-identity.js";
|
|
3
|
-
import { assertDeviceLaneWired, createDeviceLane } from "./device-lane.js";
|
|
3
|
+
import { assertDeviceLaneWired, createDeviceLane, noteDeviceRelayBindings } from "./device-lane.js";
|
|
4
4
|
import { assertWorkspaceSpaceReadable, createExecutionEnv } from "./execution-env.js";
|
|
5
5
|
import { headReadOf } from "../session-incarnation.js";
|
|
6
6
|
import * as facts from "../capability-facts.js";
|
|
@@ -15,6 +15,8 @@ export async function runStage05(ctx) {
|
|
|
15
15
|
const spaceCommits = backend !== undefined ? () => runStore : undefined;
|
|
16
16
|
const { perTaskImage, sessionEnvSelection, perSessionCwd, setSessionCwd, setSessionShellEnv, setSessionInheritEnv, fenceSessionOwner, dropSessionScoped, executionEnvFactory, worktreeReap, sendUserFileTaskEnvs, lspManager, spaceReclaimer, sandboxSecretSeatGate, sandboxPodReaper, readSandboxGitPlane, } = createExecutionEnv({ config, logger, metrics, taskAttachmentStore, ...(deviceLane ? { deviceLane } : {}), ...(spaceCommits !== undefined ? { spaceCommits } : {}), ...(headOf !== undefined ? { headOf } : {}), ...(backend !== undefined ? { runRows: () => runStore } : {}) });
|
|
17
17
|
assertDeviceLaneWired(config.remoteExec?.provider === "device", deviceLane, executionEnvFactory !== undefined);
|
|
18
|
+
if (deviceLane !== undefined && config.remoteExec?.provider === "device")
|
|
19
|
+
await noteDeviceRelayBindings(config.remoteExec.relay, deviceLane.store, logger);
|
|
18
20
|
assertWorkspaceSpaceReadable(facts.workspaceSpace(config), { headOf, spaceCommits }, facts.workspaceCache(config), sessionStoreLabelOf(config.sessionBackend, backend?.kind));
|
|
19
21
|
if (sandboxSecretSeatGate !== undefined)
|
|
20
22
|
await sandboxSecretSeatGate();
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* 🔴 `runStore` / `parkedAskRedeem` 经 `late-binds.ts` 的晚绑 cell 读(原文同作用域前向引用/晚绑 holder)。
|
|
8
8
|
*/
|
|
9
9
|
import { Runner } from "@sema-agent/core";
|
|
10
|
-
import { ForkRoutingSessionStore } from "../plugins/fork-routing-session-store.js";
|
|
11
10
|
import type { runStage05 } from "./stage-05-execution-env.js";
|
|
12
11
|
export declare function runStage06(ctx: Awaited<ReturnType<typeof runStage05>>): Promise<{
|
|
13
12
|
approvalAskAudit: import("../approval-ask-audit-store.js").FileApprovalAskAuditStore | undefined;
|
|
@@ -44,7 +43,6 @@ export declare function runStage06(ctx: Awaited<ReturnType<typeof runStage05>>):
|
|
|
44
43
|
sqlWorkflowRunStore: import("@sema-agent/core").WorkflowRunStore | undefined;
|
|
45
44
|
streamApprovalGate: import("../tool-approval.js").StreamApprovalGate<import("../approval-gate-currency.js").GateCurrencyStore>;
|
|
46
45
|
subRunner: Runner;
|
|
47
|
-
subRunnerSessions: ForkRoutingSessionStore;
|
|
48
46
|
subagentSteerRegistry: import("../orchestration/subagent-steer.js").SubagentSteerRegistry;
|
|
49
47
|
toolApproval: import("../tool-approval.js").ToolApprovalCoordinator | undefined;
|
|
50
48
|
workflowAgentRegistry: import("../orchestration/workflow-agent-steer.js").WorkflowAgentRegistry | undefined;
|
|
@@ -230,6 +230,6 @@ export async function runStage06(ctx) {
|
|
|
230
230
|
onError: runnerDeps.onError ? runnerDeps.onError : undefined,
|
|
231
231
|
};
|
|
232
232
|
const subRunner = new Runner(subRunnerDeps);
|
|
233
|
-
return { ...ctx, approvalAskAudit, approvalExemptionStore, centerRuntimeCapsResolver, checkpointStore, checkpointCtxSealing, parkCommits, durableEnabled, elicitation, fleetBus, governanceSeams, handslessRunner, hookAgent, hookAgentRunner, hookLlm, mcpRevocations, memoryConsolidationFaces, memoryOptOutGrantStore, orgMemoryAdmission, outcomeSink, principalCaps, question, retentionExecutor, retentionLaneStore, runner, runnerDeps, runtimeCapsPeekResolver, sendFileLedger, sendUserFileEmitter, sendUserFileToolSpec, sessionTitler, sharedMemoryStore, sqlWorkflowRunStore, streamApprovalGate, subRunner,
|
|
233
|
+
return { ...ctx, approvalAskAudit, approvalExemptionStore, centerRuntimeCapsResolver, checkpointStore, checkpointCtxSealing, parkCommits, durableEnabled, elicitation, fleetBus, governanceSeams, handslessRunner, hookAgent, hookAgentRunner, hookLlm, mcpRevocations, memoryConsolidationFaces, memoryOptOutGrantStore, orgMemoryAdmission, outcomeSink, principalCaps, question, retentionExecutor, retentionLaneStore, runner, runnerDeps, runtimeCapsPeekResolver, sendFileLedger, sendUserFileEmitter, sendUserFileToolSpec, sessionTitler, sharedMemoryStore, sqlWorkflowRunStore, streamApprovalGate, subRunner, subagentSteerRegistry, toolApproval, workflowAgentRegistry, workflowAgentSessionIndex, workflowCompletionInbox, workflowJournalStore, workflowModelAllowlistSnapshot, workflowParkDecisions, workflowNotifyGate, workflowNotifyJournal, workflowRecoverOpts, workflowRunStore, workflowsCapable, orgDeliveryGate };
|
|
234
234
|
}
|
|
235
235
|
//# sourceMappingURL=stage-06-runners.js.map
|
|
@@ -60,7 +60,6 @@ export declare function runStage07(ctx: Awaited<ReturnType<typeof runStage06>>):
|
|
|
60
60
|
sqlWorkflowRunStore: import("@sema-agent/core").WorkflowRunStore | undefined;
|
|
61
61
|
streamApprovalGate: import("../tool-approval.js").StreamApprovalGate<import("../approval-gate-currency.js").GateCurrencyStore>;
|
|
62
62
|
subRunner: import("@sema-agent/core").Runner;
|
|
63
|
-
subRunnerSessions: import("../plugins/fork-routing-session-store.js").ForkRoutingSessionStore;
|
|
64
63
|
subagentSteerRegistry: import("../orchestration/subagent-steer.js").SubagentSteerRegistry;
|
|
65
64
|
toolApproval: import("../tool-approval.js").ToolApprovalCoordinator | undefined;
|
|
66
65
|
workflowAgentRegistry: import("../orchestration/workflow-agent-steer.js").WorkflowAgentRegistry | undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DEFAULT_MODEL_REF } from "../model-select.js";
|
|
2
|
-
import { probeSearchBackend, uuidv7 } from "@sema-agent/core";
|
|
2
|
+
import { probeSearchBackend, resolveSubagentTranscriptTier, uuidv7 } from "@sema-agent/core";
|
|
3
3
|
import { selectEnvironmentTool } from "../capabilities/select-environment-tool.js";
|
|
4
4
|
import { subagentSendUserFileExtraTools } from "../capabilities/send-user-file-tool.js";
|
|
5
5
|
import { parseCapEnv, parseNumOrFailNonNegative } from "../config.js";
|
|
6
|
-
import {
|
|
6
|
+
import { attestChildSessionDurable } from "../plugins/session-store.js";
|
|
7
7
|
import { webSearchConfigFromEnv, createWebSearchBackend, shouldProbeWebSearchOnBoot } from "../plugins/web-search.js";
|
|
8
8
|
import { createAuthorizer } from "../security.js";
|
|
9
|
-
import { buildForceDurableGateInertNotice, buildNoResponderBootWarns, gateIntentUnserviceableReason, singleUserAutoAcceptBaselineApplies } from "../approval.js";
|
|
9
|
+
import { buildForceDurableGateInertNotice, buildNoResponderBootWarns, buildSingleUserDefaultPostureNotice, gateIntentUnserviceableReason, singleUserAutoAcceptBaselineApplies } from "../approval.js";
|
|
10
10
|
import { executionLaneOf, laneWiresExecutionEnv } from "../execution-lane-caps.js";
|
|
11
11
|
import { loadDeploymentSkills } from "../capabilities/skills.js";
|
|
12
12
|
import { createRepoClient } from "../capabilities/repo-tools.js";
|
|
@@ -29,7 +29,7 @@ import { buildDisplaySafeUrl } from "../trace/redact.js";
|
|
|
29
29
|
import * as facts from "../capability-facts.js";
|
|
30
30
|
import { WEB_ADMIN_ENV } from "@sema-agent/settings-schema";
|
|
31
31
|
export async function runStage07(ctx) {
|
|
32
|
-
const { approvalAskAudit, approvalExemptionStore, backend, backgroundAgentStore, brain, checkpointStore, config, webAdmin, counterDegradeHook, peerDesk, durableEnabled, instanceId, localRoot, logger, question, runner, runnerDeps, sendUserFileToolSpec, sessionEnvSelection, sessionStore, subRunner,
|
|
32
|
+
const { approvalAskAudit, approvalExemptionStore, backend, backgroundAgentStore, brain, checkpointStore, config, webAdmin, counterDegradeHook, peerDesk, durableEnabled, instanceId, localRoot, logger, question, runner, runnerDeps, sendUserFileToolSpec, sessionEnvSelection, sessionStore, subRunner, taskListLane, toolApproval } = ctx;
|
|
33
33
|
const authorize = createAuthorizer(config, sessionStore);
|
|
34
34
|
const runStore = backend ? backend.run() : undefined;
|
|
35
35
|
bindRunStore(runStore);
|
|
@@ -126,10 +126,8 @@ export async function runStage07(ctx) {
|
|
|
126
126
|
}))
|
|
127
127
|
logger.warn(w.event, w.fields);
|
|
128
128
|
if (singleUserAutoAcceptBaselineApplies(config)) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
tighten: "APPROVAL_REQUIRE / AUTONOMY / commandPolicy (re-surfaces + gates specific surfaces)",
|
|
132
|
-
});
|
|
129
|
+
const posture = buildSingleUserDefaultPostureNotice();
|
|
130
|
+
logger.info(posture.event, posture.fields);
|
|
133
131
|
}
|
|
134
132
|
if (config.directDoorActive)
|
|
135
133
|
logger.info("direct_door_active", { iss: config.principalJwtIss, aud: config.principalJwtAud, operators: config.operatorPrincipals.length });
|
|
@@ -169,8 +167,8 @@ export async function runStage07(ctx) {
|
|
|
169
167
|
})
|
|
170
168
|
.catch((e) => logger.warn("web_search_probe_failed", { provider: webSearchCfg.provider, error: e instanceof Error ? e.message : String(e) }));
|
|
171
169
|
}
|
|
172
|
-
const ensureChildSessionDurable = checkpointStore &&
|
|
173
|
-
? (sessionId, root) =>
|
|
170
|
+
const ensureChildSessionDurable = checkpointStore && resolveSubagentTranscriptTier(backgroundAgentStore !== undefined, sessionStore) === "full"
|
|
171
|
+
? (sessionId, root) => attestChildSessionDurable(sessionStore, sessionId, root, logger)
|
|
174
172
|
: undefined;
|
|
175
173
|
const webFetchSummarize = createWebFetchSummarizeLane({ brain, config, getKeyResolver: () => webAdmin.getKeyResolver(), logger });
|
|
176
174
|
const scenarioDeps = {
|
|
@@ -73,7 +73,6 @@ export declare function runStage08(ctx: Awaited<ReturnType<typeof runStage07>>):
|
|
|
73
73
|
sqlWorkflowRunStore: import("@sema-agent/core").WorkflowRunStore | undefined;
|
|
74
74
|
streamApprovalGate: import("../tool-approval.js").StreamApprovalGate<import("../approval-gate-currency.js").GateCurrencyStore>;
|
|
75
75
|
subRunner: Runner;
|
|
76
|
-
subRunnerSessions: import("../plugins/fork-routing-session-store.js").ForkRoutingSessionStore;
|
|
77
76
|
subagentSteerRegistry: import("../orchestration/subagent-steer.js").SubagentSteerRegistry;
|
|
78
77
|
toolApproval: import("../tool-approval.js").ToolApprovalCoordinator | undefined;
|
|
79
78
|
workflowAgentRegistry: import("../orchestration/workflow-agent-steer.js").WorkflowAgentRegistry | undefined;
|
|
@@ -97,7 +97,6 @@ export declare function runStage09(ctx: Awaited<ReturnType<typeof runStage08>>):
|
|
|
97
97
|
sqlWorkflowRunStore: import("@sema-agent/core").WorkflowRunStore | undefined;
|
|
98
98
|
streamApprovalGate: import("../tool-approval.js").StreamApprovalGate<import("../approval-gate-currency.js").GateCurrencyStore>;
|
|
99
99
|
subRunner: import("@sema-agent/core").Runner;
|
|
100
|
-
subRunnerSessions: import("../plugins/fork-routing-session-store.js").ForkRoutingSessionStore;
|
|
101
100
|
subagentSteerRegistry: import("../orchestration/subagent-steer.js").SubagentSteerRegistry;
|
|
102
101
|
toolApproval: import("../tool-approval.js").ToolApprovalCoordinator | undefined;
|
|
103
102
|
workflowAgentRegistry: import("../orchestration/workflow-agent-steer.js").WorkflowAgentRegistry | undefined;
|
|
@@ -96,7 +96,6 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
|
|
|
96
96
|
sqlWorkflowRunStore: import("@sema-agent/core").WorkflowRunStore | undefined;
|
|
97
97
|
streamApprovalGate: import("../tool-approval.js").StreamApprovalGate<import("../approval-gate-currency.js").GateCurrencyStore>;
|
|
98
98
|
subRunner: import("@sema-agent/core").Runner;
|
|
99
|
-
subRunnerSessions: import("../plugins/fork-routing-session-store.js").ForkRoutingSessionStore;
|
|
100
99
|
subagentSteerRegistry: import("../orchestration/subagent-steer.js").SubagentSteerRegistry;
|
|
101
100
|
toolApproval: import("../tool-approval.js").ToolApprovalCoordinator | undefined;
|
|
102
101
|
workflowAgentRegistry: import("../orchestration/workflow-agent-steer.js").WorkflowAgentRegistry | undefined;
|
|
@@ -96,6 +96,7 @@ export async function runStage10(ctx) {
|
|
|
96
96
|
memoryCompliance: memoryComplianceFaces,
|
|
97
97
|
memoryOriginFace: memoryOriginFaces,
|
|
98
98
|
sessionMemoryStatus: sessionMemoryStatusFace,
|
|
99
|
+
memorySyncLeg: memorySyncRunner,
|
|
99
100
|
memoryAutoConsolidationArmed: autoRunOnRecommendationEffective(runnerDeps),
|
|
100
101
|
memoryConsolidationValve: consolidationValve,
|
|
101
102
|
memoryConsolidation: memoryConsolidationFaces,
|
package/dist/boot/stores.js
CHANGED
|
@@ -18,6 +18,8 @@ import { PgRosterStore, TiDBRosterStore, ensurePgRosterSchema, ensureTiDBRosterS
|
|
|
18
18
|
import { LocalTaskAttachmentStore } from "../plugins/local-task-attachment-store.js";
|
|
19
19
|
import { PgTaskAttachmentStore, TiDBTaskAttachmentStore, ensurePgTaskAttachmentSchema, ensureTiDBTaskAttachmentSchema } from "../plugins/task-attachment-store.js";
|
|
20
20
|
import { createSessionStore } from "../plugins/session-store.js";
|
|
21
|
+
import { buildSqlPoolMissingRefusal, missingSqlCoordinateKeys } from "../sql-engine-coordinates.js";
|
|
22
|
+
import { runApprovalBatchKindlessCensus } from "../approval-batch-census.js";
|
|
21
23
|
import { runAndLogOneTimeMigrations } from "../plugins/one-time-migrations.js";
|
|
22
24
|
import { createTaskListLane } from "./task-list-lane.js";
|
|
23
25
|
import { ensurePgTaskListSchema, ensureTiDBTaskListSchema } from "../plugins/task-list-store-sql.js";
|
|
@@ -33,7 +35,7 @@ import { assertToolResultProvenanceSchema } from "../plugins/tool-result-store-s
|
|
|
33
35
|
import { assertPermissionRuleApprovalSchema, assertPermissionRuleTicketSchema } from "../plugins/permission-rule-store-sql.js";
|
|
34
36
|
import { assertApprovalAskRuleMaterialSchema } from "../plugins/approval-ask-store-sql.js";
|
|
35
37
|
import { assertSchemaMatchesCode } from "../plugins/schema-consistency.js";
|
|
36
|
-
import { assertCheckpointColumnSchema } from "../plugins/checkpoint-store-sql.js";
|
|
38
|
+
import { SqlCheckpointStore, assertCheckpointColumnSchema } from "../plugins/checkpoint-store-sql.js";
|
|
37
39
|
import { assertFileHistorySchema } from "../plugins/file-history-store-sql.js";
|
|
38
40
|
import { buildMemoryBoundaryLaneFacts, buildMemoryWriteBoundaryAudit } from "./memory-boundary.js";
|
|
39
41
|
import { buildMemoryPosture } from "../memory-posture.js";
|
|
@@ -42,7 +44,7 @@ import { establishSqlEnginePosture, sqlPoolsOf } from "../sql-engine-posture.js"
|
|
|
42
44
|
import { buildStorePosture } from "../store-posture.js";
|
|
43
45
|
const DARK_REASON_PROSE = {
|
|
44
46
|
engine_off: () => "MEMORY_ENGINE=off",
|
|
45
|
-
multi_tenant_file_backend: () => "multi-tenant on the FILE backend (no tenant isolation; set MEMORY_ENGINE_BACKEND=pg|
|
|
47
|
+
multi_tenant_file_backend: () => "multi-tenant on the FILE backend (no tenant isolation; set MEMORY_ENGINE_BACKEND=pg|mysql to light up)",
|
|
46
48
|
remote_lane_split: (lane) => `remote exec lane "${lane}" (worker/sandbox file planes split; MEMORY_ENGINE_REMOTE_LANE=allow overrides)`,
|
|
47
49
|
};
|
|
48
50
|
export async function assertApprovalAskRuleMaterialOnBackend(backend) {
|
|
@@ -97,6 +99,10 @@ export async function openStores(ctx) {
|
|
|
97
99
|
}
|
|
98
100
|
if (backend)
|
|
99
101
|
await runAndLogOneTimeMigrations(logger, backend);
|
|
102
|
+
{
|
|
103
|
+
const censusStore = backend !== undefined && backend.kind !== "local" ? backend.checkpoint?.() : undefined;
|
|
104
|
+
void runApprovalBatchKindlessCensus(censusStore instanceof SqlCheckpointStore ? censusStore : undefined, logger);
|
|
105
|
+
}
|
|
100
106
|
if ((process.env.REWIND_SNAPSHOT_MAX_MB ?? "") !== "") {
|
|
101
107
|
logger.warn("rewind_snapshot_max_mb_retired", {
|
|
102
108
|
note: "REWIND_SNAPSHOT_MAX_MB no longer has an effect: the whole-tree snapshot epoch is retired (S-15); per-edited-file history captures only files the agent touches, with no tree walk and no size gate. Remove the env var. Per-blob SQL sizing is governed by SNAPSHOT_BLOB_SQL_MAX_BYTES / object storage as before.",
|
|
@@ -136,7 +142,7 @@ export async function openStores(ctx) {
|
|
|
136
142
|
if (dialect === "pg") {
|
|
137
143
|
const pool = backend?.pgPool();
|
|
138
144
|
if (!pool)
|
|
139
|
-
throw new Error(
|
|
145
|
+
throw new Error(buildSqlPoolMissingRefusal({ engine: dialect, declared: config.dbBackend === dialect, missing: missingSqlCoordinateKeys(dialect, process.env) }));
|
|
140
146
|
const q = async (text, params) => { const r = await pool.query(text, params); return { rows: r.rows }; };
|
|
141
147
|
await ensurePgMemoryEngineSchema(q);
|
|
142
148
|
await ensurePgMemoryHistorySchema(q);
|
|
@@ -173,7 +179,7 @@ export async function openStores(ctx) {
|
|
|
173
179
|
else {
|
|
174
180
|
const pool = backend?.mysqlPool();
|
|
175
181
|
if (!pool)
|
|
176
|
-
throw new Error(
|
|
182
|
+
throw new Error(buildSqlPoolMissingRefusal({ engine: dialect, declared: config.dbBackend === dialect, missing: missingSqlCoordinateKeys(dialect, process.env) }));
|
|
177
183
|
await ensureTiDBMemoryEngineSchema(pool);
|
|
178
184
|
await ensureTiDBMemoryHistorySchema(pool);
|
|
179
185
|
await ensureTiDBMemorySyncSchema(pool);
|
package/dist/boot/web-admin.js
CHANGED
|
@@ -37,6 +37,7 @@ const MODELS_REJECTION_PHRASE = {
|
|
|
37
37
|
invalid_json: "读不出(不是合法的 JSON)",
|
|
38
38
|
not_object: "读不出(解析出来不是 JSON 对象:null / 数组 / 标量)",
|
|
39
39
|
io: "读不出(文件读失败:权限、路径是目录或 I/O 错误)",
|
|
40
|
+
too_deep: "读不出(嵌套过深:深过整棵目录的内容版本能算的层数)",
|
|
40
41
|
retired_domain: "是带事实的退役域文档",
|
|
41
42
|
};
|
|
42
43
|
function lkgReadNote(scope) {
|
|
@@ -87,7 +87,7 @@ export interface ScenarioContext {
|
|
|
87
87
|
* 由**每一个**接了停驻挂点的取用方显式交出(一条读法,没有回落):请求腿 = 本请求经鉴权解析的会话与受理时那一读(`boot/resolve-spec.ts`);`/decide` 赎回面 = 行上的
|
|
88
88
|
* `rootSessionId` 与赎回腿写口放行的那一位住客(`parked-revive-surface.ts`,交不交座都交)。它**只**喂停驻挂点,不挂任何会话级设施(那是 {@link sessionId} 的事,
|
|
89
89
|
* 判据是「这只 bundle 是不是在那只会话上取用的」,与属主来源是两个独立判据)。缺席 = 没有根可交(boot 期探针、run-local、行上没有根)⇒ 律给哨兵。
|
|
90
|
-
* 挂点在停驻那一刻再读一次根行:住客不是见证的那一位(删了、同 id 被重新登记)⇒ 停驻否决 ——
|
|
90
|
+
* 挂点在停驻那一刻再读一次根行:住客不是见证的那一位(删了、同 id 被重新登记)⇒ 停驻否决 —— 不按新住客认领。
|
|
91
91
|
*/
|
|
92
92
|
delegationRoot?: DelegationRootWitness;
|
|
93
93
|
}
|
|
@@ -140,6 +140,15 @@ export declare function mcpReconnect(d: Pick<Deps, "runStore" | "sessionStorage"
|
|
|
140
140
|
runStore: Store<"runStore">;
|
|
141
141
|
sessionStorage: HeadReadingSessionStore;
|
|
142
142
|
}>;
|
|
143
|
+
/**
|
|
144
|
+
* 在飞 run 的切档口(`POST /v1/runs/:id/permission-mode`)= 持久 run 账面 ∧ checkpoint 店(ctx 面)。后一格是承重的:切档要读这条 run 的
|
|
145
|
+
* **存储体**(本任务 settings 的 kill-switch 由受理判官折,与提交口同一份事实),也要把准入的词写回存储体(run 模式词的唯一来源,续跑腿读它);
|
|
146
|
+
* 没有 ctx 面的部署两件都做不了 ⇒ 不提供这一口(能力位 `permissionModeWrite` 同读本事实)。
|
|
147
|
+
*/
|
|
148
|
+
export declare function permissionModeWrite(d: Pick<Deps, "runStore" | "checkpointStore">): Fact<"run_store_absent" | "checkpoint_store_absent", {
|
|
149
|
+
runStore: Store<"runStore">;
|
|
150
|
+
checkpointStore: Store<"checkpointStore">;
|
|
151
|
+
}>;
|
|
143
152
|
export declare function sessionAuditView(d: Pick<Deps, "sessionAudit">): Fact<"session_audit_absent", {
|
|
144
153
|
sessionAudit: Store<"sessionAudit">;
|
|
145
154
|
}>;
|
package/dist/capability-facts.js
CHANGED
|
@@ -113,6 +113,15 @@ export function mcpReconnect(d) {
|
|
|
113
113
|
return owned;
|
|
114
114
|
return yes({ runStore: runs.runStore, sessionStorage: owned.sessionStorage });
|
|
115
115
|
}
|
|
116
|
+
export function permissionModeWrite(d) {
|
|
117
|
+
const runs = durableRuns(d);
|
|
118
|
+
if (!runs.available)
|
|
119
|
+
return runs;
|
|
120
|
+
const park = checkpointPark(d);
|
|
121
|
+
if (!park.available)
|
|
122
|
+
return park;
|
|
123
|
+
return yes({ runStore: runs.runStore, checkpointStore: park.checkpointStore });
|
|
124
|
+
}
|
|
116
125
|
export function sessionAuditView(d) {
|
|
117
126
|
return d.sessionAudit !== undefined ? yes({ sessionAudit: d.sessionAudit }) : no("session_audit_absent");
|
|
118
127
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **结算时作废一张本服务兑现不了的卡** —— 全仓「结算作废」的唯一动词:读卡 → 卡仍 pending ∧ 卡在调用方说的那只会话上 ⇒
|
|
3
|
+
* 按卡**自己的** scope 走 checkpoint 店的 `expire`(与引擎的本进程仲裁器、续跑的 resolve 同一只 CAS,恰一个赢家)。不新增任何持久态。
|
|
4
|
+
*
|
|
5
|
+
* 规则只有一条:**本服务兑现不了的卡不留在待决面上**。两个产地读这一只动词,各自只答「手里是哪一张卡、它该在哪只会话上」:
|
|
6
|
+
* · 验证器自己的停驻(`verifier-pause-card.ts`):卡在验证器现铸的会话上,本服务的续跑链连不回它;
|
|
7
|
+
* · 停驻没落定就以失败收场的腿(`runs.ts` 的 `voidHeldParkCard`:后台腿与续跑腿):卡在本 run 的会话上,但兑现它的那条 run 已经
|
|
8
|
+
* `failed`、认领已放 —— 卡的命运先于认领释放(调用方先调本动词、再放认领)。
|
|
9
|
+
*
|
|
10
|
+
* 不抛:作废没做成(店读 / 作废抛错、卡的会话对不上、没接店)⇒ 卡回到「留在待决面上、由审批兜底收割收走」的形,按产地登记的 tag
|
|
11
|
+
* 响亮留痕(计数 + 探针行 + 一次 warn),结算照常往下走。卡已不 pending / 已不在 ⇒ 什么都不做(CAS 输给了别的结算者,结局相同)。
|
|
12
|
+
*
|
|
13
|
+
* ## 🚧 过渡(引擎动词到货即改调)
|
|
14
|
+
* 店级 `expire` 只作废卡,**不释放**引擎为这张卡钉住的会话(引擎在停驻时 pin 会话,只在续跑终局 / 续跑失败臂 unpin):
|
|
15
|
+
* 被作废的卡的会话在本副本内存里一直常驻到进程重启。引擎给出「作废停驻卡并释放其会话」的动词之后,本动词改调它(两个产地一字不改)。
|
|
16
|
+
*/
|
|
17
|
+
import type { CheckpointToken } from "@sema-agent/core";
|
|
18
|
+
import { type FailOpenTag } from "./observability/fail-open.js";
|
|
19
|
+
/** 结算点手里那只 checkpoint 店的两个动词:读卡(取它自己的 scope / 会话 / 状态)→ 按卡自己的 scope CAS 作废。 */
|
|
20
|
+
export interface CardVoidPort {
|
|
21
|
+
get(token: CheckpointToken): Promise<{
|
|
22
|
+
readonly scope?: string;
|
|
23
|
+
readonly sessionId?: string;
|
|
24
|
+
readonly status?: string;
|
|
25
|
+
} | null>;
|
|
26
|
+
expire(token: CheckpointToken, scope: string): Promise<boolean>;
|
|
27
|
+
}
|
|
28
|
+
/** 要作废的那一张:停驻带回的凭据 + 它应在的会话(对不上就不动它 —— 只作废**这一张**)。 */
|
|
29
|
+
export interface CardRef {
|
|
30
|
+
readonly token: CheckpointToken;
|
|
31
|
+
readonly sessionId: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 作废 `card`(见模块头注)。`tag` = 产地登记的 F 类 tag;`at` = 探针行上的产地现场(例 `leg=bg`),接在 `reason=` 之后;
|
|
35
|
+
* detail 形 `reason=<词>[ <at>][ err=<原句>]`,不含凭据。
|
|
36
|
+
*/
|
|
37
|
+
export declare function voidPendingCard(card: CardRef, cards: CardVoidPort | undefined, tag: FailOpenTag, at?: string): Promise<void>;
|
|
38
|
+
//# sourceMappingURL=card-void.d.ts.map
|