@sema-agent/core 7.71.0 → 7.72.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/CHANGELOG.md +193 -0
- package/dist/agents/cross-session-ref.d.ts +2 -2
- package/dist/agents/cross-session-ref.js +7 -2
- package/dist/agents/inherited-tool-pool.d.ts +4 -1
- package/dist/agents/inherited-tool-pool.js +7 -5
- package/dist/agents/send-message-tool.js +6 -2
- package/dist/agents/subagent.js +5 -1
- package/dist/agents/verify.js +1 -0
- package/dist/core/a2a.d.ts +24 -3
- package/dist/core/a2a.js +27 -8
- package/dist/core/agent-state.d.ts +28 -7
- package/dist/core/agent-state.js +19 -6
- package/dist/core/approval-object.d.ts +7 -3
- package/dist/core/approval-object.js +30 -9
- package/dist/core/checkpoint-features.d.ts +13 -3
- package/dist/core/checkpoint-features.js +34 -5
- package/dist/core/checkpoint-requirements.d.ts +14 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +3 -3
- package/dist/core/checkpoint-store.d.ts +4 -0
- package/dist/core/effective-path-target.d.ts +19 -0
- package/dist/core/effective-path-target.js +95 -38
- package/dist/core/engine-notice.d.ts +4 -1
- package/dist/core/engine-version.js +1 -1
- package/dist/core/file-history-store.d.ts +15 -4
- package/dist/core/file-history-store.js +53 -23
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +4 -1
- package/dist/core/governance-codes.js +4 -0
- package/dist/core/judged-read.d.ts +57 -0
- package/dist/core/judged-read.js +1 -0
- package/dist/core/mcp-host-seat.d.ts +5 -0
- package/dist/core/mcp-host-seat.js +7 -1
- package/dist/core/mcp.js +3 -1
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.js +6 -4
- package/dist/core/memory-engine/scope-contract.d.ts +59 -6
- package/dist/core/memory-engine/scope-contract.js +90 -25
- package/dist/core/mounted-mcp.d.ts +7 -2
- package/dist/core/mounted-mcp.js +10 -1
- package/dist/core/param-rule-reach.d.ts +8 -3
- package/dist/core/param-rule-reach.js +9 -1
- package/dist/core/parent-spec-seat.d.ts +11 -1
- package/dist/core/parent-spec-seat.js +14 -0
- package/dist/core/peer-registration.d.ts +52 -0
- package/dist/core/peer-registration.js +37 -0
- package/dist/core/peer-seat.d.ts +3 -1
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/runner/chain-mismatch.d.ts +32 -0
- package/dist/core/runner/chain-mismatch.js +29 -0
- package/dist/core/runner/changes-history.d.ts +1 -0
- package/dist/core/runner/changes-history.js +2 -2
- package/dist/core/runner/contracts.d.ts +3 -0
- package/dist/core/runner/file-history-restore.d.ts +3 -1
- package/dist/core/runner/file-history-restore.js +9 -6
- package/dist/core/runner/loaded-skills.d.ts +2 -0
- package/dist/core/runner/loaded-skills.js +10 -0
- package/dist/core/runner/person-path-rows.d.ts +2 -4
- package/dist/core/runner/person-path-rows.js +2 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +7 -2
- package/dist/core/runner/prepare-file-history.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -0
- package/dist/core/runner/prepare-hands-readface.js +24 -21
- package/dist/core/runner/prepare-inherited-gate.d.ts +2 -2
- package/dist/core/runner/prepare-inherited-gate.js +1 -1
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +2 -2
- package/dist/core/runner/prepare-memory.js +3 -15
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-task.js +20 -16
- package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -0
- package/dist/core/runner/prepare-wiring-manifest.js +4 -3
- package/dist/core/runner/read-session-changes.js +1 -1
- package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
- package/dist/core/runner/resume-checkpoint-screen.js +7 -6
- package/dist/core/runner/rewind-files.js +3 -2
- package/dist/core/runner/run-leg.js +6 -2
- package/dist/core/runner/terminal-account.d.ts +4 -0
- package/dist/core/runner/terminal-account.js +7 -2
- package/dist/core/runner/tool-face-overlay.d.ts +2 -11
- package/dist/core/runner/tool-face-overlay.js +39 -0
- package/dist/core/runner/trim-stretch.js +7 -2
- package/dist/core/scheduler.d.ts +47 -7
- package/dist/core/scheduler.js +19 -7
- package/dist/core/secret-env.d.ts +7 -0
- package/dist/core/secret-env.js +1 -1
- package/dist/core/sensitive-path-policy.js +14 -7
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +7 -0
- package/dist/core/task-event.d.ts +4 -3
- package/dist/core/task-notification.d.ts +2 -1
- package/dist/core/task-spec.d.ts +13 -5
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-face-reader.js +1 -1
- package/dist/core/tool-face.d.ts +7 -0
- package/dist/core/tool-face.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +4 -2
- package/dist/core/tool-mount-facts.js +3 -3
- package/dist/core/tool-mount-plan.d.ts +4 -2
- package/dist/core/tool-mount-plan.js +5 -5
- package/dist/core/tool-mount-static.d.ts +1 -1
- package/dist/core/tool-mount-static.js +25 -13
- package/dist/core/tool-registry.d.ts +33 -1
- package/dist/core/tool-registry.js +33 -0
- package/dist/core/tool-roster.d.ts +16 -0
- package/dist/core/tool-roster.js +6 -0
- package/dist/core/tool-spec.d.ts +4 -2
- package/dist/core/tools.d.ts +6 -0
- package/dist/core/tools.js +1 -1
- package/dist/core/wiring-manifest.d.ts +66 -12
- package/dist/core/wiring-manifest.js +37 -1
- package/dist/engine/harness/messages.d.ts +1 -1
- package/dist/engine/harness/messages.js +2 -1
- package/dist/engine/loop/types.d.ts +2 -0
- package/dist/engine/session/session.js +1 -1
- package/dist/index.d.ts +11 -7
- package/dist/index.js +9 -6
- package/dist/orchestration/workflow.js +2 -1
- package/dist/stores/file/adoption/marker.d.ts +2 -27
- package/dist/stores/file/adoption/marker.js +12 -0
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +1 -1
- package/dist/tools/artifact/artifact-tool.js +11 -6
- package/dist/tools/fs/file-read-check.d.ts +45 -11
- package/dist/tools/fs/file-read-check.js +200 -57
- package/dist/tools/fs/judged-reads.d.ts +51 -0
- package/dist/tools/fs/judged-reads.js +68 -0
- package/dist/tools/fs/safety.d.ts +8 -0
- package/dist/tools/fs/safety.js +12 -1
- package/dist/tools/fs/shell-read-check.d.ts +16 -3
- package/dist/tools/fs/shell-read-check.js +4 -1
- package/dist/tools/fs/shell-read-establish.js +13 -3
- package/dist/tools/scheduler-store-move.d.ts +74 -0
- package/dist/tools/scheduler-store-move.js +103 -0
- package/dist/tools/scheduler-tools.d.ts +43 -29
- package/dist/tools/scheduler-tools.js +161 -118
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +47 -3
- package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
- package/wire-changes/answers/core@7.72.0.json +84 -0
- package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
- package/wire-changes/answers/primitives@7.72.0.json +6 -0
- package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
- package/wire-changes/core-stores-sql@7.71.1.json +40 -0
- package/wire-changes/core-stores-sql@7.72.0.json +215 -0
- package/wire-changes/core@7.71.1.json +118 -0
- package/wire-changes/core@7.72.0.json +2426 -0
- package/wire-changes/mods-kernel@7.71.1.json +40 -0
- package/wire-changes/mods-kernel@7.72.0.json +147 -0
- package/wire-changes/primitives@7.71.1.json +40 -0
- package/wire-changes/primitives@7.72.0.json +143 -0
- package/wire-changes/wiki-gate@7.71.1.json +40 -0
- package/wire-changes/wiki-gate@7.72.0.json +145 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** One stored row as the store's owner hands it to a move. Only these members are read; the rest of the row is the owner's and comes back untouched. */
|
|
2
|
+
export interface SchedulerStoredRow {
|
|
3
|
+
/** The key the row is filed under now. */
|
|
4
|
+
readonly scope: unknown;
|
|
5
|
+
/** The row's stored `ScheduledIntent.lifetime` (absent when the store kept none). */
|
|
6
|
+
readonly lifetime?: unknown;
|
|
7
|
+
/** The row's stored `ScheduledIntent.mode` (absent when the store kept none). */
|
|
8
|
+
readonly mode?: unknown;
|
|
9
|
+
/** The row's stored label. */
|
|
10
|
+
readonly label?: unknown;
|
|
11
|
+
/** The session the row's firings go to (the `SchedulerContext.sessionId` it was scheduled with): the owner of a session-lane row's key. */
|
|
12
|
+
readonly sessionId?: unknown;
|
|
13
|
+
/** The owner's own word on the row's lane (`"session"` / `"durable"`), for a row whose stored members do not name it. Read by the forward move only. */
|
|
14
|
+
readonly lane?: unknown;
|
|
15
|
+
}
|
|
16
|
+
/** Why a move hands a row back unmoved — the closed set of {@link SchedulerStoreMove.refused}'s `code`. */
|
|
17
|
+
export type SchedulerRowRefusalCode =
|
|
18
|
+
/** Its key is not a non-empty string (forward) or not a lane key (rollback), or a `lifetime` / `mode` / `lane` is outside the seam's words. */
|
|
19
|
+
"row_invalid"
|
|
20
|
+
/** Neither its stored members nor a stated `lane` name its lane: no `lifetime: "session"`, no `mode`, and the wakeup's label — a session
|
|
21
|
+
* wakeup on a store that kept no `mode`, or a job that was given that label. */
|
|
22
|
+
| "lane_unknown"
|
|
23
|
+
/** The stated `lane` is not the lane its stored members name. */
|
|
24
|
+
| "lane_contradicted"
|
|
25
|
+
/** A session-lane row whose firing destination (`sessionId`) is not a non-empty string: it has no owner to key. */
|
|
26
|
+
| "destination_unknown"
|
|
27
|
+
/** Rollback: a session-lane row and a durable-lane row of one owner would share one bare key, where an older release lists and stops
|
|
28
|
+
* them as one lane's rows. */
|
|
29
|
+
| "bare_key_shared"
|
|
30
|
+
/** Forward: rows filed under different bare keys would share one lane key (two explicit session scopes over one session id — two
|
|
31
|
+
* tenants' `A/42` and `B/42` — where the lane key is the session id alone): the move does not merge them. */
|
|
32
|
+
| "lane_key_shared";
|
|
33
|
+
/** What a move answers: the rows it placed, each with the key to file it under, in input order; and the rows it did not, each with why. */
|
|
34
|
+
export interface SchedulerStoreMove<R extends SchedulerStoredRow> {
|
|
35
|
+
readonly moved: ReadonlyArray<{
|
|
36
|
+
readonly row: R;
|
|
37
|
+
readonly scope: string;
|
|
38
|
+
}>;
|
|
39
|
+
readonly refused: ReadonlyArray<{
|
|
40
|
+
readonly row: R;
|
|
41
|
+
readonly code: SchedulerRowRefusalCode;
|
|
42
|
+
readonly reason: string;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
/** A whole store, as its owner hands it to a move: its rows and its own key declaration (the `scopeKeys` it declares today). */
|
|
46
|
+
export interface SchedulerStoreRows<R extends SchedulerStoredRow> {
|
|
47
|
+
readonly scopeKeys?: unknown;
|
|
48
|
+
readonly rows: readonly R[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Pure forward placement: each row filed under bare keys (a release before 7.72.0: a key was its owner alone) gets one lane key or one
|
|
52
|
+
* refusal — `session:<sessionId>` for a row of the session lane (keyed by the session it fires into: an older factory took an explicit
|
|
53
|
+
* session scope, so the bare key need not be the session), `durable:<bare key>` for a row of the durable lane. A row's lane is read off its
|
|
54
|
+
* stored `lifetime` and `mode` as scheduling picks it (`lifetime: "session"` or `mode: "session-wakeup"` ⇒ session); a row with no `mode`,
|
|
55
|
+
* a `lifetime` absent or `"durable"` and the wakeup's label is refused `lane_unknown` unless the owner states its `lane`. A bare key is never
|
|
56
|
+
* judged by its head. Rows of different bare keys that would land on one lane key are not merged: each is refused `lane_key_shared` (only
|
|
57
|
+
* the rows of this call are compared).
|
|
58
|
+
*
|
|
59
|
+
* Pure and write-free: call it once to move a store (writing `moved` and `scopeKeys: "lane"` in one write once `refused` is empty), or on
|
|
60
|
+
* every read in a backend that keeps bare keys stored and answers lane keys at its port (that backend's duties are written at
|
|
61
|
+
* `SchedulerCapability.schedulerCapabilities.scopeKeys`). `store.scopeKeys` is the stored rows' form (absent or `"bare"`; `"lane"` is refused
|
|
62
|
+
* whole, `config.invalid_argument`).
|
|
63
|
+
*/
|
|
64
|
+
export declare function migrateSchedulerStore<R extends SchedulerStoredRow>(store: SchedulerStoreRows<R>): SchedulerStoreMove<R>;
|
|
65
|
+
/**
|
|
66
|
+
* The rollback: every row of a store that declares lane keys with its bare key (the lane name and its `:` taken off), for an older release.
|
|
67
|
+
* Two lanes' rows that would share one bare key — a session whose id is some isolation scope's name — are both refused `bare_key_shared`:
|
|
68
|
+
* an older release reads them as one lane's rows, so one owner's stop or delete reaches the other's. Settle them (remove one, or keep
|
|
69
|
+
* the newer release) before rolling back. A row whose key is not a lane key is refused `row_invalid`.
|
|
70
|
+
*
|
|
71
|
+
* `store.scopeKeys` must be `"lane"` (anything else is refused whole, `config.invalid_argument`). Write `moved` together with the
|
|
72
|
+
* declaration `scopeKeys: "bare"`, and only when `refused` is empty.
|
|
73
|
+
*/
|
|
74
|
+
export declare function rollbackSchedulerStore<R extends SchedulerStoredRow>(store: SchedulerStoreRows<R>): SchedulerStoreMove<R>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { codedRefusal } from "../core/thrown-value.js";
|
|
2
|
+
import { describeRejectedValue } from "../core/tool-search-setting.js";
|
|
3
|
+
import { isLaneKey, laneKeyOf, laneOfIntent, WAKEUP_LABEL } from "./scheduler-tools.js";
|
|
4
|
+
const LIFETIMES = [undefined, "durable", "session"];
|
|
5
|
+
const MODES = [undefined, "task", "session-wakeup"];
|
|
6
|
+
const LANES = [undefined, "session", "durable"];
|
|
7
|
+
function rowsOf(store, direction, wanted, want) {
|
|
8
|
+
const held = store;
|
|
9
|
+
if (typeof held !== "object" || held === null || !Array.isArray(held.rows)) {
|
|
10
|
+
throw codedRefusal("config.invalid_argument", `the scheduler store handed to the ${direction} is ${describeRejectedValue(held)}, not { scopeKeys?, rows: [...] } — the ${direction} reads the whole store at once.`);
|
|
11
|
+
}
|
|
12
|
+
const keys = held.scopeKeys;
|
|
13
|
+
if (!wanted(keys))
|
|
14
|
+
throw codedRefusal("config.invalid_argument", `the scheduler store declares scopeKeys ${describeRejectedValue(keys)}; the ${direction} runs on a store that declares ${want} — it runs once, and a key's head does not say which form it is.`);
|
|
15
|
+
return held.rows;
|
|
16
|
+
}
|
|
17
|
+
function storedLaneOf(row) {
|
|
18
|
+
if (!LIFETIMES.includes(row.lifetime))
|
|
19
|
+
return { fault: `its lifetime is ${describeRejectedValue(row.lifetime)}, not "durable", "session" or absent` };
|
|
20
|
+
if (!MODES.includes(row.mode))
|
|
21
|
+
return { fault: `its mode is ${describeRejectedValue(row.mode)}, not "task", "session-wakeup" or absent` };
|
|
22
|
+
const lane = laneOfIntent(row);
|
|
23
|
+
return lane === "durable" && row.mode === undefined && row.label === WAKEUP_LABEL ? "unknown" : lane;
|
|
24
|
+
}
|
|
25
|
+
export function migrateSchedulerStore(store) {
|
|
26
|
+
const rows = rowsOf(store, "move", (keys) => keys === undefined || keys === "bare", 'none, or "bare"');
|
|
27
|
+
const placed = [];
|
|
28
|
+
const refused = [];
|
|
29
|
+
const refuse = (row, code, reason) => void refused.push({ row, code, reason });
|
|
30
|
+
for (const row of rows) {
|
|
31
|
+
const key = row?.scope;
|
|
32
|
+
if (typeof key !== "string" || key === "") {
|
|
33
|
+
refuse(row, "row_invalid", `the row's key is ${describeRejectedValue(key)}, not a non-empty string — there is no owner to file it under.`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const stored = storedLaneOf(row);
|
|
37
|
+
if (typeof stored === "object") {
|
|
38
|
+
refuse(row, "row_invalid", `${stored.fault} — its lane cannot be read.`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!LANES.includes(row.lane)) {
|
|
42
|
+
refuse(row, "row_invalid", `its stated lane is ${describeRejectedValue(row.lane)}, not "session", "durable" or absent.`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const stated = row.lane;
|
|
46
|
+
if (stated !== undefined && stored !== "unknown" && stated !== stored) {
|
|
47
|
+
refuse(row, "lane_contradicted", `its stated lane is "${stated}", but its stored lifetime and mode file it on the ${stored} lane.`);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const lane = stated ?? stored;
|
|
51
|
+
if (lane === "unknown") {
|
|
52
|
+
refuse(row, "lane_unknown", `it carries ${row.lifetime === undefined ? "no lifetime" : `lifetime "${String(row.lifetime)}"`} and no mode, and the wakeup's label "${WAKEUP_LABEL}" — a row both lanes may have written: a session wakeup on a store that kept no mode, or a job given that label. State its lane.`);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (lane === "durable") {
|
|
56
|
+
placed.push({ row, scope: laneKeyOf("durable", key), from: key });
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const destination = row.sessionId;
|
|
60
|
+
if (typeof destination !== "string" || destination === "") {
|
|
61
|
+
refuse(row, "destination_unknown", `it is a session-lane row whose session (sessionId) is ${describeRejectedValue(destination)}, not a non-empty string — the session it fires into is the owner of its key.`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
placed.push({ row, scope: laneKeyOf("session", destination), from: key });
|
|
65
|
+
}
|
|
66
|
+
const moved = unshared(placed, refused, (shared, froms) => ({
|
|
67
|
+
code: "lane_key_shared",
|
|
68
|
+
reason: `its lane key ${JSON.stringify(shared)} would be shared by rows filed under ${froms.map((k) => JSON.stringify(k)).join(" and ")}: the move does not merge two owners' rows into one lane.`,
|
|
69
|
+
}));
|
|
70
|
+
return { moved, refused };
|
|
71
|
+
}
|
|
72
|
+
function unshared(placed, refused, why) {
|
|
73
|
+
const fromsOf = new Map();
|
|
74
|
+
for (const p of placed)
|
|
75
|
+
fromsOf.set(p.scope, (fromsOf.get(p.scope) ?? new Set()).add(p.from));
|
|
76
|
+
const moved = [];
|
|
77
|
+
for (const p of placed) {
|
|
78
|
+
const froms = fromsOf.get(p.scope);
|
|
79
|
+
if (froms.size === 1)
|
|
80
|
+
moved.push({ row: p.row, scope: p.scope });
|
|
81
|
+
else
|
|
82
|
+
refused.push({ row: p.row, ...why(p.scope, [...froms]) });
|
|
83
|
+
}
|
|
84
|
+
return moved;
|
|
85
|
+
}
|
|
86
|
+
export function rollbackSchedulerStore(store) {
|
|
87
|
+
const rows = rowsOf(store, "rollback", (keys) => keys === "lane", '"lane"');
|
|
88
|
+
const placed = [];
|
|
89
|
+
const refused = [];
|
|
90
|
+
for (const row of rows) {
|
|
91
|
+
const key = row?.scope;
|
|
92
|
+
const lane = ["session", "durable"].find((l) => isLaneKey(l, key));
|
|
93
|
+
if (lane === undefined)
|
|
94
|
+
refused.push({ row, code: "row_invalid", reason: `the row's key is ${describeRejectedValue(key)}, not a lane's name, \`:\` and a non-empty owner.` });
|
|
95
|
+
else
|
|
96
|
+
placed.push({ row, scope: key.slice(lane.length + 1), from: key });
|
|
97
|
+
}
|
|
98
|
+
const moved = unshared(placed, refused, (_shared, froms) => ({
|
|
99
|
+
code: "bare_key_shared",
|
|
100
|
+
reason: `its bare key is shared by ${froms.map((k) => JSON.stringify(k)).join(" and ")}: an older release lists and stops them as one lane's rows.`,
|
|
101
|
+
}));
|
|
102
|
+
return { moved, refused };
|
|
103
|
+
}
|
|
@@ -19,24 +19,23 @@
|
|
|
19
19
|
* `createHandsToolkit` —— 与 present_plan/AskUserQuestion 同:这些工具都在 prepare-task 单独挂,那里有 spec.principal)。
|
|
20
20
|
*/
|
|
21
21
|
import type { AgentTool, ExecutionEnv, Result } from "../internal/harness-types.js";
|
|
22
|
-
import { SchedulerError, type SchedulerContext, type ScheduledTaskId, type ScheduledTaskSummary } from "../core/scheduler.js";
|
|
23
|
-
import { type
|
|
22
|
+
import { SchedulerError, type SchedulerReading, type SchedulerContext, type ScheduledTaskId, type ScheduledTaskSummary } from "../core/scheduler.js";
|
|
23
|
+
import { type EngineNotice } from "../core/engine-notice.js";
|
|
24
24
|
export declare const SCHEDULE_WAKEUP_TOOL_NAME = "ScheduleWakeup";
|
|
25
25
|
/** CronCreate-based autonomous-loop 哨兵(CC `Ldt`)。loop runtime(部署侧)在 fire 时解析回 autonomous-loop 指令。 */
|
|
26
26
|
export declare const AUTONOMOUS_LOOP_SENTINEL = "<<autonomous-loop>>";
|
|
27
27
|
/** ScheduleWakeup(dynamic-pacing)哨兵(CC `ePe`)——ScheduleWakeup 一律用 `-dynamic` 变体。 */
|
|
28
28
|
export declare const AUTONOMOUS_LOOP_DYNAMIC_SENTINEL = "<<autonomous-loop-dynamic>>";
|
|
29
|
+
/** wakeup intent 的保留 label:老 backend(list 不回 mode)时 stop 过滤的兜底键;店的迁移据它认出判不清车道的行。 */
|
|
30
|
+
export declare const WAKEUP_LABEL = "loop-wakeup";
|
|
29
31
|
/** Runner-held 上下文 + run-stop 出口,工具工厂闭包捕获(模型触不到)。 */
|
|
30
32
|
export interface SchedulerToolContext {
|
|
31
|
-
/**
|
|
32
|
-
* **会话腿**的越界隔离键(Runner 填 sessionId ?? isolation scope ?? taskId)。durable 腿不用这条链——它的键由
|
|
33
|
-
* {@link durableScopeOf} 从 isolation scope 独立铸(ruled 2026-08-03,见该函数注释)。
|
|
34
|
-
*/
|
|
35
|
-
scope: string;
|
|
36
|
-
/** 任务的人(`TaskSpec.principal`),原样交给宿主 capability;缺 `isolationScope` 时也是 durable 腿的键。 */
|
|
33
|
+
/** 任务的人(`TaskSpec.principal`),原样交给宿主 capability;缺 `isolationScope` 时也是 durable lane 的主人。 */
|
|
37
34
|
principal?: string;
|
|
38
|
-
/** 任务的 isolation scope(`TaskSpec.isolationScope
|
|
35
|
+
/** 任务的 isolation scope(`TaskSpec.isolationScope`):在场时是 durable lane 的主人(同一人的另一 scope 看不见这条 job)。 */
|
|
39
36
|
isolationScope?: string;
|
|
37
|
+
/** The session the run belongs to: the owner of the session lane (`session:<sessionId>`). Absent = the run has no session lane — the
|
|
38
|
+
* readers read the durable lane alone, and the two tools that schedule do not mount. */
|
|
40
39
|
sessionId?: string;
|
|
41
40
|
taskConfig?: unknown;
|
|
42
41
|
/** The user's zone as the engine judged it ({@link SchedulerContext.timeZone}); rides every context handed to the backend. */
|
|
@@ -45,26 +44,32 @@ export interface SchedulerToolContext {
|
|
|
45
44
|
* 保留(human-suspend saga 等共用同一 runner 原语;prepare-task 仍注入)——当前 scheduler 三件不消费。 */
|
|
46
45
|
requestStopAfterTurn?: () => void;
|
|
47
46
|
}
|
|
48
|
-
/** The
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export declare function
|
|
54
|
-
|
|
55
|
-
readonly taskId?: string | undefined;
|
|
56
|
-
}): string;
|
|
57
|
-
/** The two lanes of one run, each as the context the scheduler backend isolates by. */
|
|
47
|
+
/** The two lanes, the closed set a scheduler key starts with. */
|
|
48
|
+
export type LaneName = "session" | "durable";
|
|
49
|
+
/** The one spelling of a scheduler key: the lane's name, `:`, the owner. */
|
|
50
|
+
export declare function laneKeyOf(lane: LaneName, owner: string): string;
|
|
51
|
+
/** Whether `scope` is a key of `lane`: the lane's name, `:` and at least one more character. */
|
|
52
|
+
export declare function isLaneKey(lane: LaneName, scope: unknown): boolean;
|
|
53
|
+
/** The lanes of one run, each as the context the scheduler backend isolates by. Which lane an entry is on is {@link laneOfIntent}'s answer. */
|
|
58
54
|
export interface SchedulerLanes {
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
/** The entries bound to this session — a session-lifetime job, or a session wakeup (it ends with the session only on a backend that vouches for
|
|
56
|
+
* the session lifetime) — keyed `session:<session id>`. Absent for a run with no session. */
|
|
57
|
+
readonly session?: SchedulerContext;
|
|
58
|
+
/** Every other entry of the run's isolation scope, keyed `durable:<isolation scope>` (else `durable:default`): visible from every session of that scope. */
|
|
62
59
|
readonly durable: SchedulerContext;
|
|
63
60
|
}
|
|
64
|
-
/** The lanes of the run whose factory context is `ctx`: the session lane keyed by `ctx.
|
|
65
|
-
*
|
|
66
|
-
*
|
|
61
|
+
/** The lanes of the run whose factory context is `ctx`: the session lane keyed by `ctx.sessionId` when it has one, the durable lane by the
|
|
62
|
+
* isolation scope (else `default`). Derive `ctx` from a verified session / run — see the note above. A lane whose key does not come out
|
|
63
|
+
* of its lane's form (an empty or non-string session id) is refused. */
|
|
67
64
|
export declare function schedulerLanesOf(ctx: SchedulerToolContext): SchedulerLanes;
|
|
65
|
+
/** The lane an intent is filed on: the session lane for a job that ends with its session (`lifetime: "session"`) or a session wakeup
|
|
66
|
+
* (`mode: "session-wakeup"`), the durable lane for every other. Read off those two members only, never the label (a label is the
|
|
67
|
+
* caller's word: CronCreate may write the wakeup's label too). Scheduling picks a lane with it, and the store's move
|
|
68
|
+
* (`migrateSchedulerStore`) reads a stored row's lane with it. */
|
|
69
|
+
export declare function laneOfIntent(intent: {
|
|
70
|
+
readonly lifetime?: unknown;
|
|
71
|
+
readonly mode?: unknown;
|
|
72
|
+
}): LaneName;
|
|
68
73
|
/**
|
|
69
74
|
* Every entry of both lanes: the session lane's rows, then the durable lane's rows the first did not already list (a backend that does
|
|
70
75
|
* not filter by scope answers both lanes with the same rows; one id prints once). A lane that fails fails the whole read with that lane's
|
|
@@ -73,8 +78,8 @@ export declare function schedulerLanesOf(ctx: SchedulerToolContext): SchedulerLa
|
|
|
73
78
|
*/
|
|
74
79
|
export declare function listScheduled(env: ExecutionEnv, lanes: SchedulerLanes): Promise<Result<ScheduledTaskSummary[], SchedulerError>>;
|
|
75
80
|
/**
|
|
76
|
-
* Cancel one entry by id, on the lane that holds it
|
|
77
|
-
* (both belong to this run, so reading both widens nothing): a backend whose `cancel` answers ok for an id it does not hold would let a
|
|
81
|
+
* Cancel one entry by id, on the lane that holds it (a run with the durable lane alone asks that lane, with no listing). A bare id no longer
|
|
82
|
+
* names its lane, so the holder is found by listing the lanes in order until one holds it (both belong to this run, so reading both widens nothing): a backend whose `cancel` answers ok for an id it does not hold would let a
|
|
78
83
|
* first-lane try swallow the call while the real job on the other lane stays live under a receipt that says it is gone. Only when the
|
|
79
84
|
* listing is unavailable, or the id is not in the snapshot, does it fall back to trying each lane in turn — and then only a `not_found`
|
|
80
85
|
* is a reason to ask the next lane. The result is the backend's own: `not_found` for an id neither lane holds, `unsupported` for an
|
|
@@ -94,6 +99,15 @@ export declare function cutToUnits(text: string, limit: number): string;
|
|
|
94
99
|
*/
|
|
95
100
|
export declare function cronToHuman(expr: string): string;
|
|
96
101
|
/**
|
|
97
|
-
*
|
|
102
|
+
* Tells the operator, once per declared value per notice sink, that the env's scheduler backend offers the seam but does not declare its
|
|
103
|
+
* store holds lane keys — so {@link createSchedulerTools} mounts nothing on it (`config.scheduler_store_unmoved`). Every other reading:
|
|
104
|
+
* silence. `scheduler` is the leg's one reading of the declaration ({@link readSchedulerDeclaration}).
|
|
98
105
|
*/
|
|
99
|
-
export declare function
|
|
106
|
+
export declare function announceSchedulerStoreUnmoved(scheduler: SchedulerReading, onNotice: ((notice: EngineNotice) => void) | undefined): void;
|
|
107
|
+
/**
|
|
108
|
+
* 构建 scheduler 工具(仅当 `env` 暴露 {@link SchedulerCapability}、`supported:true` 且店声明 `scopeKeys: "lane"`;否则返回 `[]`,INERT):有会话 = CronCreate /
|
|
109
|
+
* CronDelete / CronList / ScheduleWakeup 四只,无会话 = CronDelete / CronList 两只(只读写 durable lane)。`scheduler` = 一条腿对声明的那一次读数
|
|
110
|
+
* ({@link readSchedulerDeclaration};缺 = 这里读一次):挂载与工具执行时读的能力位都出自它;CronList / CronDelete 经 {@link listScheduled} /
|
|
111
|
+
* {@link cancelScheduled},那两只读口每次调用再读一次声明(声明在实例寿命内不变)。
|
|
112
|
+
*/
|
|
113
|
+
export declare function createSchedulerTools(env: ExecutionEnv, ctx: SchedulerToolContext, scheduler?: SchedulerReading): AgentTool[];
|