@sema-agent/core 7.69.0 → 7.69.1
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 +583 -0
- package/dist/agents/repair-loop.js +6 -14
- package/dist/agents/subagent.js +2 -1
- package/dist/agents/verify.d.ts +1 -1
- package/dist/agents/verify.js +7 -1
- package/dist/brain/reasoning-request.d.ts +7 -0
- package/dist/brain/reasoning-request.js +6 -0
- package/dist/core/agent-config-dir.d.ts +39 -3
- package/dist/core/agent-config-dir.js +67 -11
- package/dist/core/allow-entry.d.ts +5 -5
- package/dist/core/allow-entry.js +12 -6
- package/dist/core/ask-headline.d.ts +2 -2
- package/dist/core/ask-origin.d.ts +31 -31
- package/dist/core/ask-origin.js +20 -13
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +1 -0
- package/dist/core/auto-compaction.d.ts +44 -62
- package/dist/core/auto-compaction.js +44 -103
- package/dist/core/cache-break-detector.d.ts +23 -11
- package/dist/core/cache-break-detector.js +11 -5
- package/dist/core/checkpoint-features.d.ts +1 -1
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +6 -0
- package/dist/core/checkpoint-row-verdict.js +3 -0
- package/dist/core/checkpoint-store.d.ts +13 -2
- package/dist/core/child-clamp-seats.d.ts +30 -3
- package/dist/core/child-clamp-seats.js +24 -0
- package/dist/core/compaction-retired-members.d.ts +12 -0
- package/dist/core/compaction-retired-members.js +22 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +2 -0
- package/dist/core/context-edit.d.ts +32 -17
- package/dist/core/context-edit.js +28 -0
- package/dist/core/cron.d.ts +68 -0
- package/dist/core/cron.js +259 -0
- package/dist/core/engine-attestation.d.ts +16 -0
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-capabilities.d.ts +14 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +18 -7
- package/dist/core/engine-version.js +1 -1
- package/dist/core/gate-outcome.d.ts +29 -2
- package/dist/core/gate-outcome.js +6 -0
- package/dist/core/git-read-only.d.ts +10 -0
- package/dist/core/git-read-only.js +1 -0
- package/dist/core/git-worktree-env.js +9 -8
- package/dist/core/governance-codes.d.ts +9 -2
- package/dist/core/governance-codes.js +9 -0
- package/dist/core/locked-config.js +7 -3
- package/dist/core/lsp.d.ts +3 -0
- package/dist/core/lsp.js +3 -2
- package/dist/core/memory-engine/engine.d.ts +48 -12
- package/dist/core/memory-engine/engine.js +108 -46
- package/dist/core/memory-engine/file-backend.d.ts +2 -1
- package/dist/core/memory-engine/index-copies.d.ts +47 -0
- package/dist/core/memory-engine/index-copies.js +88 -0
- package/dist/core/memory-engine/layout.d.ts +20 -3
- package/dist/core/memory-engine/layout.js +39 -3
- package/dist/core/memory-engine/origin-clearance.d.ts +9 -7
- package/dist/core/memory-engine/origin-clearance.js +2 -4
- package/dist/core/memory-engine/types.d.ts +16 -3
- package/dist/core/mode-policy.d.ts +7 -1
- package/dist/core/mode-policy.js +9 -0
- package/dist/core/mods/session-compact.js +3 -3
- package/dist/core/mods/stations.d.ts +2 -0
- package/dist/core/mods/stations.js +2 -1
- package/dist/core/path-guard-rows.d.ts +8 -3
- package/dist/core/path-guard-rows.js +18 -5
- package/dist/core/peer-seat.d.ts +3 -0
- package/dist/core/peer-seat.js +3 -0
- package/dist/core/permission-rule-model.js +3 -2
- package/dist/core/process-identity.d.ts +11 -3
- package/dist/core/process-identity.js +26 -16
- package/dist/core/runner/assemble-result.d.ts +5 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/cleared-results-record.d.ts +33 -0
- package/dist/core/runner/cleared-results-record.js +56 -0
- package/dist/core/runner/compact-session.js +14 -9
- package/dist/core/runner/compaction-knobs.d.ts +1 -1
- package/dist/core/runner/continuation-gate.js +2 -1
- package/dist/core/runner/continues-from.d.ts +1 -1
- package/dist/core/runner/continues-from.js +1 -1
- package/dist/core/runner/contracts.d.ts +83 -31
- package/dist/core/runner/conversation-segment.d.ts +19 -12
- package/dist/core/runner/conversation-segment.js +27 -7
- package/dist/core/runner/derived-route-fallback.d.ts +2 -12
- package/dist/core/runner/derived-route-fallback.js +0 -6
- package/dist/core/runner/gate-exit.d.ts +2 -1
- package/dist/core/runner/gate-exit.js +4 -2
- package/dist/core/runner/git-status-frame.d.ts +2 -2
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/leg-caller-places.d.ts +39 -0
- package/dist/core/runner/leg-caller-places.js +23 -0
- package/dist/core/runner/leg-frame.d.ts +8 -2
- package/dist/core/runner/leg-receipt.d.ts +29 -2
- package/dist/core/runner/leg-receipt.js +37 -6
- package/dist/core/runner/media-removed-seat.d.ts +10 -6
- package/dist/core/runner/media-removed-seat.js +6 -3
- package/dist/core/runner/messages-omitted-seat.d.ts +2 -1
- package/dist/core/runner/messages-omitted-seat.js +15 -5
- package/dist/core/runner/person-path-rows.d.ts +25 -7
- package/dist/core/runner/person-path-rows.js +16 -2
- package/dist/core/runner/prefix-ledger.d.ts +120 -0
- package/dist/core/runner/prefix-ledger.js +176 -0
- package/dist/core/runner/prepare-advisor.d.ts +2 -0
- package/dist/core/runner/prepare-advisor.js +2 -1
- package/dist/core/runner/prepare-artifact.d.ts +3 -0
- package/dist/core/runner/prepare-artifact.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -8
- package/dist/core/runner/prepare-config-doors.js +15 -12
- package/dist/core/runner/prepare-context-lane.d.ts +25 -6
- package/dist/core/runner/prepare-context-lane.js +82 -27
- package/dist/core/runner/prepare-gate-stations.d.ts +1 -2
- package/dist/core/runner/prepare-gate-stations.js +2 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +18 -5
- package/dist/core/runner/prepare-hands-readface.js +41 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +5 -0
- package/dist/core/runner/prepare-inherited-gate.js +2 -0
- package/dist/core/runner/prepare-memory.d.ts +10 -2
- package/dist/core/runner/prepare-memory.js +51 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -0
- package/dist/core/runner/prepare-policy-chain.js +13 -2
- package/dist/core/runner/prepare-prompt-assembly.d.ts +12 -4
- package/dist/core/runner/prepare-prompt-assembly.js +10 -4
- package/dist/core/runner/prepare-prompt-inputs.d.ts +3 -7
- package/dist/core/runner/prepare-prompt-inputs.js +6 -7
- package/dist/core/runner/prepare-safety-scan.js +7 -0
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -0
- package/dist/core/runner/prepare-suspend-saga.js +3 -2
- package/dist/core/runner/prepare-task.js +59 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -11
- package/dist/core/runner/prepare-tool-disclosure-mount.js +7 -8
- package/dist/core/runner/prepare-turn-wiring.d.ts +16 -25
- package/dist/core/runner/prepare-turn-wiring.js +8 -18
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
- package/dist/core/runner/prepare-wiring-manifest.js +3 -2
- package/dist/core/runner/prompt-suggestions.d.ts +3 -1
- package/dist/core/runner/prompt-suggestions.js +1 -1
- package/dist/core/runner/read-block-judge.d.ts +47 -0
- package/dist/core/runner/read-block-judge.js +33 -0
- package/dist/core/runner/role-resolution-table.d.ts +15 -10
- package/dist/core/runner/role-resolution-table.js +4 -5
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +7 -4
- package/dist/core/runner/rule-store-unreadable-notice.js +4 -3
- package/dist/core/runner/run-compaction-machinery.d.ts +0 -10
- package/dist/core/runner/run-compaction-machinery.js +3 -39
- package/dist/core/runner/run-harness-handlers.js +4 -17
- package/dist/core/runner/run-identity-wiring.js +4 -1
- package/dist/core/runner/run-leg.js +11 -1
- package/dist/core/runner/run-recovery-lanes.d.ts +0 -4
- package/dist/core/runner/run-recovery-lanes.js +34 -18
- package/dist/core/runner/run-settle-and-teardown.d.ts +1 -3
- package/dist/core/runner/run-settle-and-teardown.js +14 -22
- package/dist/core/runner/run-telemetry-and-budget-seats.js +0 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +11 -30
- package/dist/core/runner/run-terminal-adoption.js +5 -88
- package/dist/core/runner/run-tool-mount-facts.js +1 -5
- package/dist/core/runner/run-turn-boundary.js +56 -26
- package/dist/core/runner/runtask.js +7 -7
- package/dist/core/runner/session-hash-salt.d.ts +18 -0
- package/dist/core/runner/session-hash-salt.js +36 -0
- package/dist/core/runner/shell-env-withheld.d.ts +8 -5
- package/dist/core/runner/shell-env-withheld.js +3 -3
- package/dist/core/runner/side-call-account.d.ts +9 -1
- package/dist/core/runner/side-call-account.js +15 -4
- package/dist/core/runner/skill-mention.d.ts +12 -0
- package/dist/core/runner/skill-mention.js +50 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-table-view.d.ts +5 -9
- package/dist/core/runner/tool-table-view.js +23 -21
- package/dist/core/runner/write-protection-station.d.ts +5 -2
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +25 -27
- package/dist/core/scheduler.d.ts +13 -3
- package/dist/core/scheduler.js +0 -12
- package/dist/core/secret-env.d.ts +47 -11
- package/dist/core/secret-env.js +65 -4
- package/dist/core/sensitive-path-policy.js +4 -0
- package/dist/core/session-checkout.js +10 -9
- package/dist/core/shell-read-silence.d.ts +2 -1
- package/dist/core/shell-run-candidates.d.ts +1 -1
- package/dist/core/shell-run-candidates.js +11 -3
- package/dist/core/task-event.d.ts +32 -10
- package/dist/core/task-intake.d.ts +5 -3
- package/dist/core/task-intake.js +6 -2
- package/dist/core/task-result.d.ts +39 -0
- package/dist/core/task-spec-members.d.ts +3 -0
- package/dist/core/task-spec-members.js +2 -2
- package/dist/core/task-spec.d.ts +37 -20
- package/dist/core/tool-policy.d.ts +30 -18
- package/dist/core/tool-policy.js +44 -32
- package/dist/core/tool-roster.d.ts +21 -7
- package/dist/core/tool-roster.js +34 -6
- package/dist/core/tool-spec-members.js +1 -1
- package/dist/core/tool-spec.d.ts +27 -0
- package/dist/core/tools.js +1 -0
- package/dist/core/trace.d.ts +42 -19
- package/dist/core/unc-spelling.d.ts +31 -0
- package/dist/core/unc-spelling.js +51 -0
- package/dist/core/wiring-manifest.d.ts +30 -3
- package/dist/core/wiring-manifest.js +10 -0
- package/dist/core/workflow-run-store-contract.js +22 -0
- package/dist/core/workflow-run-store.d.ts +17 -13
- package/dist/core/workflow-run-store.js +1 -1
- package/dist/core/write-protect.d.ts +4 -0
- package/dist/core/write-protect.js +17 -15
- package/dist/engine/compaction/compaction.d.ts +48 -98
- package/dist/engine/compaction/compaction.js +136 -216
- package/dist/engine/compaction/utils.d.ts +2 -11
- package/dist/engine/compaction/utils.js +4 -13
- package/dist/engine/execution-env/node-execution-env.js +17 -6
- package/dist/engine/harness/agent-harness.d.ts +19 -5
- package/dist/engine/harness/agent-harness.js +18 -7
- package/dist/engine/harness/types.d.ts +5 -7
- package/dist/engine/loop/agent-loop.d.ts +14 -1
- package/dist/engine/loop/agent-loop.js +31 -11
- package/dist/engine/loop/types.d.ts +8 -2
- package/dist/index.d.ts +9 -6
- package/dist/index.js +8 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-spec.js +7 -2
- package/dist/orchestration/run-workflow-tool.js +5 -3
- package/dist/orchestration/workflow-park-adoption.d.ts +66 -8
- package/dist/orchestration/workflow-park-adoption.js +195 -45
- package/dist/orchestration/workflow-types.d.ts +20 -0
- package/dist/orchestration/workflow-types.js +1 -0
- package/dist/orchestration/workflow.d.ts +3 -2
- package/dist/orchestration/workflow.js +10 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/events.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/mechanism.d.ts +8 -0
- package/dist/prompt-assembly/catalog/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +1 -1
- package/dist/prompt-assembly/catalog/schema.js +1 -0
- package/dist/prompt-assembly/catalog/sections.js +8 -0
- package/dist/prompt-assembly/event-registry.js +1 -0
- package/dist/prompt-assembly/select.js +1 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +14 -27
- package/dist/prompt-assembly/turn-snapshot.js +6 -18
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/default.d.ts +9 -0
- package/dist/prompts/default.js +4 -0
- package/dist/shell/lex.d.ts +75 -11
- package/dist/shell/lex.js +340 -76
- package/dist/tools/fs/bash-program-position.js +2 -6
- package/dist/tools/fs/bash-readonly-classifier.d.ts +18 -3
- package/dist/tools/fs/bash-readonly-classifier.js +19 -9
- package/dist/tools/fs/containment-face.d.ts +12 -3
- package/dist/tools/fs/containment-face.js +16 -7
- package/dist/tools/fs/file-read-check.d.ts +26 -1
- package/dist/tools/fs/file-read-check.js +20 -2
- package/dist/tools/fs/fs-bash.js +4 -4
- package/dist/tools/fs/fs-read.d.ts +3 -0
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-search-tools.d.ts +2 -2
- package/dist/tools/fs/fs-search-tools.js +4 -4
- package/dist/tools/fs/index.js +5 -3
- package/dist/tools/fs/pdf.js +12 -4
- package/dist/tools/fs/read-deny-home.d.ts +13 -2
- package/dist/tools/fs/read-deny-home.js +26 -22
- package/dist/tools/fs/read-deny.js +15 -6
- package/dist/tools/fs/removal-targets.d.ts +33 -17
- package/dist/tools/fs/removal-targets.js +160 -61
- package/dist/tools/fs/repo-map.d.ts +1 -1
- package/dist/tools/fs/repo-map.js +2 -2
- package/dist/tools/fs/safety.d.ts +28 -5
- package/dist/tools/fs/safety.js +72 -8
- package/dist/tools/fs/shell-read-bindings.d.ts +8 -2
- package/dist/tools/fs/shell-read-bindings.js +25 -6
- package/dist/tools/fs/shell-read-check.d.ts +3 -0
- package/dist/tools/fs/shell-read-check.js +22 -4
- package/dist/tools/fs/shell-read-establish.js +73 -43
- package/dist/tools/fs/shell-read-judge.d.ts +32 -14
- package/dist/tools/fs/shell-read-judge.js +13 -5
- package/dist/tools/fs/shell-read-object-path.d.ts +5 -1
- package/dist/tools/fs/shell-read-object-path.js +17 -4
- package/dist/tools/fs/shell-read-plan.d.ts +8 -2
- package/dist/tools/fs/shell-read-plan.js +36 -22
- package/dist/tools/fs/shell-read-sourced.js +12 -4
- package/dist/tools/fs/shell-read-start.d.ts +4 -2
- package/dist/tools/fs/shell-read-start.js +3 -3
- package/dist/tools/fs/shell-read-workdir.d.ts +14 -6
- package/dist/tools/fs/shell-read-workdir.js +35 -17
- package/dist/tools/scheduler-tools.d.ts +7 -17
- package/dist/tools/scheduler-tools.js +9 -85
- package/dist/tools/worktree.js +5 -4
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +47 -1
- package/wire-changes/core-stores-sql@7.68.6.json +39 -0
- package/wire-changes/core-stores-sql@7.69.1.json +39 -0
- package/wire-changes/core@7.68.6.json +125 -0
- package/wire-changes/core@7.69.1.json +2561 -0
- package/wire-changes/mods-kernel@7.68.6.json +39 -0
- package/wire-changes/mods-kernel@7.69.1.json +39 -0
- package/wire-changes/primitives@7.68.6.json +39 -0
- package/wire-changes/primitives@7.69.1.json +39 -0
- package/wire-changes/wiki-gate@7.68.6.json +39 -0
- package/wire-changes/wiki-gate@7.69.1.json +39 -0
- package/dist/core/runner/prompt-hash-salt.d.ts +0 -1
- package/dist/core/runner/prompt-hash-salt.js +0 -2
|
@@ -223,6 +223,34 @@ export function createClearedProjectionLedger() {
|
|
|
223
223
|
return { entries: new Map() };
|
|
224
224
|
}
|
|
225
225
|
const OCCURRENCE_KEY_SEP = String.fromCharCode(0);
|
|
226
|
+
export function clearedLedgerRecords(ledger) {
|
|
227
|
+
return [...ledger.entries]
|
|
228
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
229
|
+
.map(([key, e]) => {
|
|
230
|
+
const dupAt = key.lastIndexOf(OCCURRENCE_KEY_SEP);
|
|
231
|
+
const group = key.slice(0, dupAt);
|
|
232
|
+
const tsAt = group.lastIndexOf(OCCURRENCE_KEY_SEP);
|
|
233
|
+
return { toolCallId: group.slice(0, tsAt), at: group.slice(tsAt + 1), ordinal: Number(key.slice(dupAt + 1)), groupCount: e.groupCount, fp: e.fp, marker: e.marker };
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
const isCount = (v, min) => typeof v === "number" && Number.isInteger(v) && v >= min;
|
|
237
|
+
export function clearedLedgerFromRecords(records) {
|
|
238
|
+
if (!Array.isArray(records))
|
|
239
|
+
return undefined;
|
|
240
|
+
const list = records;
|
|
241
|
+
const ledger = createClearedProjectionLedger();
|
|
242
|
+
for (const r of list) {
|
|
243
|
+
const { toolCallId, at, ordinal, groupCount, fp, marker } = (r ?? {});
|
|
244
|
+
if (typeof toolCallId !== "string" || typeof at !== "string" || typeof fp !== "string" || typeof marker !== "string")
|
|
245
|
+
return undefined;
|
|
246
|
+
if (!isCount(groupCount, 1) || !isCount(ordinal, 0) || ordinal >= groupCount)
|
|
247
|
+
return undefined;
|
|
248
|
+
if (marker !== CC_CLEARED_MARKER && !marker.startsWith(CC_CLEARED_EXTENDED_PREFIX))
|
|
249
|
+
return undefined;
|
|
250
|
+
ledger.entries.set(`${toolCallId}${OCCURRENCE_KEY_SEP}${at}${OCCURRENCE_KEY_SEP}${ordinal}`, { marker, groupCount, fp });
|
|
251
|
+
}
|
|
252
|
+
return ledger;
|
|
253
|
+
}
|
|
226
254
|
function occurrenceGroupId(m) {
|
|
227
255
|
return `${m.toolCallId}${OCCURRENCE_KEY_SEP}${m.timestamp ?? 0}`;
|
|
228
256
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine's one cron grammar and its one next-fire search. The tool shell's CronCreate refuses an expression at intake
|
|
3
|
+
* with it, and a scheduler backend computes when an accepted expression fires next with it — so the set of expressions an
|
|
4
|
+
* intake accepts is, by construction, the set the firing side can compute a time for. A host that takes cron expressions
|
|
5
|
+
* at its own door asks these same two functions; it does not keep a second grammar.
|
|
6
|
+
*
|
|
7
|
+
* The reading follows the reference terminal's scheduler: the five-field grammar and its field expansion, the
|
|
8
|
+
* day-of-month / day-of-week union, "the first whole minute strictly after the base instant", one fire per repeated
|
|
9
|
+
* wall-clock time, and a bounded walk that answers "never" for a date that does not occur. What differs is where the
|
|
10
|
+
* clock is read: the reference reads the process's local zone (it runs on the user's machine); this function reads the
|
|
11
|
+
* zone it is handed and never the process's own, because the engine also runs in containers whose zone is not the user's.
|
|
12
|
+
*
|
|
13
|
+
* Pure: no I/O, no clock, no process time zone. Every fault of an input is answered as a value, never thrown.
|
|
14
|
+
*/
|
|
15
|
+
import { SchedulerError } from "./scheduler.js";
|
|
16
|
+
import type { Result } from "../internal/harness-types.js";
|
|
17
|
+
/** What separates two fields: any run of white space, as the reference reads an expression — the grammar's and every reader's
|
|
18
|
+
* that splits an expression into fields (the display too). */
|
|
19
|
+
export declare const CRON_FIELD_SEPARATOR: RegExp;
|
|
20
|
+
/**
|
|
21
|
+
* Does the engine's cron grammar accept `expr`? Exactly when {@link nextCronFireTime} would not refuse it as an expression:
|
|
22
|
+
* five fields of `*`, `*\/N`, `N`, `N-M`, `N-M/S` or comma lists of those, each value inside its field's range, at most
|
|
23
|
+
* 100 characters after trimming. The grammar's alphabet is digits, `* / , -` and white space, and any run of white space
|
|
24
|
+
* separates two fields — a line break or a carriage return among it, as the reference reads an expression. So an expression
|
|
25
|
+
* this accepts carries no quote, no substitution, no redirection and no word but its fields; it may carry a line break
|
|
26
|
+
* between two of them (a shell's command separator, a crontab's record end), so a consumer that writes it into one line of
|
|
27
|
+
* text writes the five fields joined by single spaces, not the text as given. An expression can be grammatical and still
|
|
28
|
+
* never fire (a 30th of February): the intake question "will it ever fire" is {@link nextCronFireTime} answering `null`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isValidCronExpr(expr: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* When does the cron expression `expr` fire next, strictly after the instant `after`, on the wall clock of `timeZone`?
|
|
33
|
+
*
|
|
34
|
+
* - **Grammar.** Five fields `minute hour day-of-month month day-of-week`, each `*`, `*\/N`, `N`, `N-M`, `N-M/S` or a
|
|
35
|
+
* comma list of those; ranges 0-59 / 0-23 / 1-31 / 1-12 / 0-6 (7 is Sunday too); no seconds field, no month or day
|
|
36
|
+
* names, no `@` shorthands, no `L` / `W` / `#` / `?`; at most 100 characters after trimming ({@link isValidCronExpr}).
|
|
37
|
+
* - **Day.** When day-of-month and day-of-week are both restricted, a day matches either; a field whose values cover its
|
|
38
|
+
* whole range (`*`, `1-31`, `0-7`) is unrestricted, and the day is then decided by the other field alone.
|
|
39
|
+
* - **Time.** The fields are read on the wall clock of `timeZone` — required, and any zone `Intl` accepts: an IANA name
|
|
40
|
+
* such as `"Asia/Tokyo"`, or a fixed offset such as `"+05:30"` (a clock with no shifts) where the runtime reads one; the
|
|
41
|
+
* same acceptance as the engine's own zone check for the environment block. The process's own zone is never read. The answer is the first whole minute strictly after `after` whose wall time
|
|
42
|
+
* matches. A wall time a forward shift skips does not fire. A wall time a backward shift repeats fires once.
|
|
43
|
+
* - **`recurring`** (default `true`) decides one thing only: which pass of a repeated wall time counts. A recurring job
|
|
44
|
+
* fires a repeated time in its first pass and never in the repeat; with `recurring: false` (a job that fires once and is
|
|
45
|
+
* removed) the first pass or the repeat counts, whichever first follows `after`. Away from a backward shift the two
|
|
46
|
+
* answers are the same.
|
|
47
|
+
* - **Missed fires and offsets are the caller's.** Pass the last fire as `after` (the creation time when it never fired):
|
|
48
|
+
* an answer at or before now means one fire is due, however many slots were missed. No per-job offset is added.
|
|
49
|
+
* - **Answer.** `{ ok: true, value }` with the epoch milliseconds of the fire; `{ ok: true, value: null }` when no wall
|
|
50
|
+
* minute ever matches (a 30th of February), found by a walk bounded at the reference walker's 527 040 steps; `{ ok:
|
|
51
|
+
* false, error }` with a {@link SchedulerError} of code `"invalid_schedule"` naming the input at fault — an expression
|
|
52
|
+
* the grammar refuses, a zone `Intl` does not know, an `after` that is not a number of milliseconds from 0 to the end
|
|
53
|
+
* of `Date`'s range, or a `recurring` that is not a boolean. Nothing is thrown.
|
|
54
|
+
*/
|
|
55
|
+
export declare function nextCronFireTime(expr: string, opts: {
|
|
56
|
+
readonly after: number;
|
|
57
|
+
readonly timeZone: string;
|
|
58
|
+
readonly recurring?: boolean;
|
|
59
|
+
}): Result<number | null, SchedulerError>;
|
|
60
|
+
/**
|
|
61
|
+
* The sentence an intake refuses `expr` with, judged at `after` in `timeZone`, or `null` when it accepts it: the refusal of
|
|
62
|
+
* {@link nextCronFireTime} (the grammar's, the zone's or the instant's own words) when it refuses, a never-fires sentence
|
|
63
|
+
* when it answers `null`. The intake asks the matcher the firing side computes with, so it accepts exactly what can be timed.
|
|
64
|
+
*/
|
|
65
|
+
export declare function cronIntakeRefusal(expr: string, at: {
|
|
66
|
+
readonly after: number;
|
|
67
|
+
readonly timeZone: string;
|
|
68
|
+
}): string | null;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { SchedulerError } from "./scheduler.js";
|
|
2
|
+
const MAX_EXPR_LENGTH = 100;
|
|
3
|
+
const CRON_ALPHABET = /^[0-9*/,\-\s]+$/;
|
|
4
|
+
export const CRON_FIELD_SEPARATOR = /\s+/;
|
|
5
|
+
const CRON_FIELDS = [
|
|
6
|
+
{ name: "minute", min: 0, max: 59 },
|
|
7
|
+
{ name: "hour", min: 0, max: 23 },
|
|
8
|
+
{ name: "day-of-month", min: 1, max: 31 },
|
|
9
|
+
{ name: "month", min: 1, max: 12 },
|
|
10
|
+
{ name: "day-of-week", min: 0, max: 6 },
|
|
11
|
+
];
|
|
12
|
+
function expandCronField(field, { min, max }) {
|
|
13
|
+
const out = new Set();
|
|
14
|
+
const isDow = min === 0 && max === 6;
|
|
15
|
+
for (const part of field.split(",")) {
|
|
16
|
+
const star = part.match(/^\*(?:\/(\d+))?$/);
|
|
17
|
+
if (star) {
|
|
18
|
+
const n = star[1] ? parseInt(star[1], 10) : 1;
|
|
19
|
+
if (n < 1)
|
|
20
|
+
return null;
|
|
21
|
+
for (let i = min; i <= max; i += n)
|
|
22
|
+
out.add(i);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const range = part.match(/^(\d+)-(\d+)(?:\/(\d+))?$/);
|
|
26
|
+
if (range) {
|
|
27
|
+
const lo = parseInt(range[1] ?? "", 10);
|
|
28
|
+
const hi = parseInt(range[2] ?? "", 10);
|
|
29
|
+
const n = range[3] ? parseInt(range[3], 10) : 1;
|
|
30
|
+
const top = isDow ? 7 : max;
|
|
31
|
+
if (lo > hi || n < 1 || lo < min || hi > top)
|
|
32
|
+
return null;
|
|
33
|
+
for (let i = lo; i <= hi; i += n)
|
|
34
|
+
out.add(isDow && i === 7 ? 0 : i);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (/^\d+$/.test(part)) {
|
|
38
|
+
let n = parseInt(part, 10);
|
|
39
|
+
if (isDow && n === 7)
|
|
40
|
+
n = 0;
|
|
41
|
+
if (n < min || n > max)
|
|
42
|
+
return null;
|
|
43
|
+
out.add(n);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return out.size > 0 ? [...out] : null;
|
|
49
|
+
}
|
|
50
|
+
function quoted(expr) {
|
|
51
|
+
return expr.length <= MAX_EXPR_LENGTH ? JSON.stringify(expr) : `(${expr.length} characters)`;
|
|
52
|
+
}
|
|
53
|
+
function parseCron(expr) {
|
|
54
|
+
if (typeof expr !== "string")
|
|
55
|
+
return { ok: false, reason: `it is ${expr === null ? "null" : typeof expr}, not a string.` };
|
|
56
|
+
const trimmed = expr.trim();
|
|
57
|
+
if (trimmed.length === 0)
|
|
58
|
+
return { ok: false, reason: "it is empty — expected 5 fields (minute hour day-of-month month day-of-week)." };
|
|
59
|
+
if (trimmed.length > MAX_EXPR_LENGTH)
|
|
60
|
+
return { ok: false, reason: `it is ${trimmed.length} characters long; at most ${MAX_EXPR_LENGTH} are read.` };
|
|
61
|
+
if (!CRON_ALPHABET.test(trimmed)) {
|
|
62
|
+
return { ok: false, reason: "only 5 space-separated cron fields of digits and * / , - are allowed (no names, no @ shorthands, no seconds field)." };
|
|
63
|
+
}
|
|
64
|
+
const fields = trimmed.split(CRON_FIELD_SEPARATOR);
|
|
65
|
+
if (fields.length === 6) {
|
|
66
|
+
return {
|
|
67
|
+
ok: false,
|
|
68
|
+
reason: `its leading seconds field is not supported — cron here fires on 5 fields, so one minute is the finest ` +
|
|
69
|
+
`granularity available. Pass "${fields.slice(1).join(" ")}" if that cadence works.`,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (fields.length !== 5)
|
|
73
|
+
return { ok: false, reason: `expected 5 fields (minute hour day-of-month month day-of-week), got ${fields.length}.` };
|
|
74
|
+
const values = [];
|
|
75
|
+
for (let i = 0; i < 5; i++) {
|
|
76
|
+
const range = CRON_FIELDS[i];
|
|
77
|
+
const field = fields[i];
|
|
78
|
+
const expanded = expandCronField(field, range);
|
|
79
|
+
if (expanded === null) {
|
|
80
|
+
const sunday = range.name === "day-of-week" ? " (7 is Sunday too)" : "";
|
|
81
|
+
return { ok: false, reason: `invalid ${range.name} field "${field}" — allowed ${range.min}-${range.max}${sunday} (syntax: N, N-M, */N, N-M/S, comma lists).` };
|
|
82
|
+
}
|
|
83
|
+
values.push(expanded);
|
|
84
|
+
}
|
|
85
|
+
const [minutes, hours, daysOfMonth, months, daysOfWeek] = values;
|
|
86
|
+
return {
|
|
87
|
+
ok: true,
|
|
88
|
+
schedule: {
|
|
89
|
+
minutes: new Set(minutes),
|
|
90
|
+
hours: new Set(hours),
|
|
91
|
+
daysOfMonth: new Set(daysOfMonth),
|
|
92
|
+
months: new Set(months),
|
|
93
|
+
daysOfWeek: new Set(daysOfWeek),
|
|
94
|
+
anyDayOfMonth: daysOfMonth.length === 31,
|
|
95
|
+
anyDayOfWeek: daysOfWeek.length === 7,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export function isValidCronExpr(expr) {
|
|
100
|
+
return parseCron(expr).ok;
|
|
101
|
+
}
|
|
102
|
+
const MINUTE_MS = 60_000;
|
|
103
|
+
const HOUR_MS = 3_600_000;
|
|
104
|
+
const DAY_MS = 86_400_000;
|
|
105
|
+
const MAX_INSTANT_MS = 8.64e15;
|
|
106
|
+
const MAX_WALK_STEPS = 527_040;
|
|
107
|
+
function daysFromCivil(year, month, day) {
|
|
108
|
+
const y = month <= 2 ? year - 1 : year;
|
|
109
|
+
const era = Math.floor(y / 400);
|
|
110
|
+
const yoe = y - era * 400;
|
|
111
|
+
const doy = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;
|
|
112
|
+
const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
|
|
113
|
+
return era * 146_097 + doe - 719_468;
|
|
114
|
+
}
|
|
115
|
+
function daysInMonth(year, month) {
|
|
116
|
+
if (month === 2)
|
|
117
|
+
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0 ? 29 : 28;
|
|
118
|
+
return month === 4 || month === 6 || month === 9 || month === 11 ? 30 : 31;
|
|
119
|
+
}
|
|
120
|
+
function wallAsUtcMs(w) {
|
|
121
|
+
return daysFromCivil(w.year, w.month, w.day) * DAY_MS + w.hour * HOUR_MS + w.minute * MINUTE_MS;
|
|
122
|
+
}
|
|
123
|
+
function nextMonth(w) {
|
|
124
|
+
return w.month === 12 ? { year: w.year + 1, month: 1, day: 1, hour: 0, minute: 0 } : { year: w.year, month: w.month + 1, day: 1, hour: 0, minute: 0 };
|
|
125
|
+
}
|
|
126
|
+
function nextDay(w) {
|
|
127
|
+
return w.day >= daysInMonth(w.year, w.month) ? nextMonth(w) : { year: w.year, month: w.month, day: w.day + 1, hour: 0, minute: 0 };
|
|
128
|
+
}
|
|
129
|
+
function nextHour(w) {
|
|
130
|
+
return w.hour === 23 ? nextDay(w) : { year: w.year, month: w.month, day: w.day, hour: w.hour + 1, minute: 0 };
|
|
131
|
+
}
|
|
132
|
+
function nextMinute(w) {
|
|
133
|
+
return w.minute === 59 ? nextHour(w) : { year: w.year, month: w.month, day: w.day, hour: w.hour, minute: w.minute + 1 };
|
|
134
|
+
}
|
|
135
|
+
function dayMatches(s, w) {
|
|
136
|
+
if (s.anyDayOfMonth && s.anyDayOfWeek)
|
|
137
|
+
return true;
|
|
138
|
+
if (s.anyDayOfWeek)
|
|
139
|
+
return s.daysOfMonth.has(w.day);
|
|
140
|
+
const dow = (((daysFromCivil(w.year, w.month, w.day) + 4) % 7) + 7) % 7;
|
|
141
|
+
if (s.anyDayOfMonth)
|
|
142
|
+
return s.daysOfWeek.has(dow);
|
|
143
|
+
return s.daysOfMonth.has(w.day) || s.daysOfWeek.has(dow);
|
|
144
|
+
}
|
|
145
|
+
function wallMatches(s, w) {
|
|
146
|
+
return s.months.has(w.month) && dayMatches(s, w) && s.hours.has(w.hour) && s.minutes.has(w.minute);
|
|
147
|
+
}
|
|
148
|
+
function zoneClock(timeZone) {
|
|
149
|
+
let format;
|
|
150
|
+
try {
|
|
151
|
+
format = new Intl.DateTimeFormat("en-US", {
|
|
152
|
+
timeZone,
|
|
153
|
+
hourCycle: "h23",
|
|
154
|
+
year: "numeric",
|
|
155
|
+
month: "numeric",
|
|
156
|
+
day: "numeric",
|
|
157
|
+
hour: "numeric",
|
|
158
|
+
minute: "numeric",
|
|
159
|
+
second: "numeric",
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
const fieldsOf = (instantMs) => {
|
|
166
|
+
const at = {};
|
|
167
|
+
for (const p of format.formatToParts(instantMs))
|
|
168
|
+
if (p.type !== "literal")
|
|
169
|
+
at[p.type] = parseInt(p.value, 10);
|
|
170
|
+
return { w: { year: at.year ?? NaN, month: at.month ?? NaN, day: at.day ?? NaN, hour: at.hour ?? NaN, minute: at.minute ?? NaN }, second: at.second ?? NaN };
|
|
171
|
+
};
|
|
172
|
+
const offsetAt = (instantMs) => {
|
|
173
|
+
const whole = Math.floor(instantMs / 1000) * 1000;
|
|
174
|
+
const { w, second } = fieldsOf(whole);
|
|
175
|
+
return wallAsUtcMs(w) + second * 1000 - whole;
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
wallOf: (instantMs) => fieldsOf(instantMs).w,
|
|
179
|
+
instantsOf: (w) => {
|
|
180
|
+
const wall = wallAsUtcMs(w);
|
|
181
|
+
const found = new Set();
|
|
182
|
+
for (const offset of [offsetAt(Math.max(wall - DAY_MS, -MAX_INSTANT_MS)), offsetAt(Math.min(wall + DAY_MS, MAX_INSTANT_MS))]) {
|
|
183
|
+
const t = wall - offset;
|
|
184
|
+
if (Math.abs(t) <= MAX_INSTANT_MS && offsetAt(t) === offset)
|
|
185
|
+
found.add(t);
|
|
186
|
+
}
|
|
187
|
+
return [...found].sort((a, b) => a - b);
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function invalid(message) {
|
|
192
|
+
return { ok: false, error: new SchedulerError("invalid_schedule", message) };
|
|
193
|
+
}
|
|
194
|
+
export function nextCronFireTime(expr, opts) {
|
|
195
|
+
const parsed = parseCron(expr);
|
|
196
|
+
if (!parsed.ok)
|
|
197
|
+
return invalid(`invalid cron expression${typeof expr === "string" ? ` ${quoted(expr)}` : ""} — ${parsed.reason}`);
|
|
198
|
+
const given = (opts ?? {});
|
|
199
|
+
const { after, timeZone, recurring } = given;
|
|
200
|
+
if (typeof after !== "number" || !Number.isFinite(after) || after < 0 || after > MAX_INSTANT_MS) {
|
|
201
|
+
return invalid(`invalid base instant: \`after\` must be a number of epoch milliseconds from 0 to ${MAX_INSTANT_MS}, got ${typeof after === "number" ? String(after) : typeof after}.`);
|
|
202
|
+
}
|
|
203
|
+
if (recurring !== undefined && typeof recurring !== "boolean") {
|
|
204
|
+
return invalid(`invalid \`recurring\`: it must be a boolean when given, got ${recurring === null ? "null" : typeof recurring}.`);
|
|
205
|
+
}
|
|
206
|
+
if (typeof timeZone !== "string" || timeZone.trim() === "") {
|
|
207
|
+
return invalid(`invalid time zone: \`timeZone\` must name a time zone such as "Asia/Tokyo", got ${typeof timeZone === "string" ? "an empty string" : typeof timeZone}.`);
|
|
208
|
+
}
|
|
209
|
+
const clock = zoneClock(timeZone);
|
|
210
|
+
if (clock === undefined)
|
|
211
|
+
return invalid(`invalid time zone ${quoted(timeZone)} — the runtime knows no time zone by that name (an IANA name such as "Asia/Tokyo" is expected).`);
|
|
212
|
+
const s = parsed.schedule;
|
|
213
|
+
const oneShot = recurring === false;
|
|
214
|
+
let at = Math.floor(after / MINUTE_MS) * MINUTE_MS + MINUTE_MS;
|
|
215
|
+
if (at > MAX_INSTANT_MS)
|
|
216
|
+
return { ok: true, value: null };
|
|
217
|
+
if (oneShot) {
|
|
218
|
+
const here = clock.instantsOf(clock.wallOf(at));
|
|
219
|
+
if (here.length === 2) {
|
|
220
|
+
const end = Math.min(at + 2 * (here[1] - here[0]), MAX_INSTANT_MS + MINUTE_MS);
|
|
221
|
+
for (; at < end; at += MINUTE_MS)
|
|
222
|
+
if (wallMatches(s, clock.wallOf(at)))
|
|
223
|
+
return { ok: true, value: at };
|
|
224
|
+
if (at > MAX_INSTANT_MS)
|
|
225
|
+
return { ok: true, value: null };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
let w = clock.wallOf(at);
|
|
229
|
+
for (let step = 0; step < MAX_WALK_STEPS; step++) {
|
|
230
|
+
if (wallAsUtcMs(w) > MAX_INSTANT_MS + DAY_MS)
|
|
231
|
+
return { ok: true, value: null };
|
|
232
|
+
if (!s.months.has(w.month))
|
|
233
|
+
w = nextMonth(w);
|
|
234
|
+
else if (!dayMatches(s, w))
|
|
235
|
+
w = nextDay(w);
|
|
236
|
+
else if (!s.hours.has(w.hour))
|
|
237
|
+
w = nextHour(w);
|
|
238
|
+
else if (!s.minutes.has(w.minute))
|
|
239
|
+
w = nextMinute(w);
|
|
240
|
+
else {
|
|
241
|
+
const instants = clock.instantsOf(w);
|
|
242
|
+
const pick = oneShot ? instants.find((t) => t > after) : instants[0] !== undefined && instants[0] > after ? instants[0] : undefined;
|
|
243
|
+
if (pick !== undefined)
|
|
244
|
+
return { ok: true, value: pick };
|
|
245
|
+
w = nextMinute(w);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return { ok: true, value: null };
|
|
249
|
+
}
|
|
250
|
+
export function cronIntakeRefusal(expr, at) {
|
|
251
|
+
const next = nextCronFireTime(expr, at);
|
|
252
|
+
if (!next.ok)
|
|
253
|
+
return next.error.message;
|
|
254
|
+
if (next.value === null) {
|
|
255
|
+
return (`cron expression ${quoted(expr)} — it never fires — no calendar date matches its day-of-month and month fields ` +
|
|
256
|
+
`(e.g. February has at most 29 days). Pick a real calendar date.`);
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import type { AskClass, AskClassMembers, AskOrigin, AskReason } from "./ask-origin.js";
|
|
19
19
|
import type { ClassifierDenyCause, Settlement } from "./gate-outcome.js";
|
|
20
|
+
import type { ShellReadRefusalDetails } from "../tools/fs/shell-read-check.js";
|
|
20
21
|
import type { AutoModeClassifierRound, ClassifierSaid } from "./auto-mode.js";
|
|
21
22
|
import type { AskUnresolvableCause } from "./ask-unresolvable-notice.js";
|
|
22
23
|
import type { PathDenialEvidence } from "../tools/fs/safety.js";
|
|
@@ -91,6 +92,21 @@ export interface EngineAttestation {
|
|
|
91
92
|
* floating an ancestor's ask back into this leg's fold: its mark frames, its denial-limit fallback's sentence). The chain's
|
|
92
93
|
* entry mint takes these instead of the sentence; empty = the station read no asker. Written only by that float. */
|
|
93
94
|
readonly receivedAskReasons?: readonly AskReason[];
|
|
95
|
+
/** A gate station's refusal settled AHEAD of the station's own seat in the gate — where an earlier layer would otherwise
|
|
96
|
+
* put a question about the call first (an inherited station settling an ancestor's ask): the station's layer word and its
|
|
97
|
+
* card. Written by one mint, the refusing station's ({@link STATION_REFUSAL_LAYERS} names the stations that settle so); read
|
|
98
|
+
* twice, each field once — the layer by the settlement ledger's `fromDecision` (the refusal's `deniedBy`), the card by the
|
|
99
|
+
* gate's deny exit beside a path denial's card. */
|
|
100
|
+
readonly stationRefusal?: StationRefusal;
|
|
101
|
+
}
|
|
102
|
+
/** The stations whose refusal an earlier layer settles in their name ({@link EngineAttestation.stationRefusal}) — each word is
|
|
103
|
+
* the station's own refusing-layer word. */
|
|
104
|
+
export declare const STATION_REFUSAL_LAYERS: readonly ["read_boundary"];
|
|
105
|
+
export type StationRefusalLayer = (typeof STATION_REFUSAL_LAYERS)[number];
|
|
106
|
+
/** {@link EngineAttestation.stationRefusal}: the refusing station's layer word and the card its refusal carries. */
|
|
107
|
+
export interface StationRefusal {
|
|
108
|
+
readonly layer: StationRefusalLayer;
|
|
109
|
+
readonly details?: ShellReadRefusalDetails;
|
|
94
110
|
}
|
|
95
111
|
/** The members a station attests — everything but the call binding. */
|
|
96
112
|
export type AttestationMembers = Omit<EngineAttestation, "toolCallId" | "toolName">;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const STATION_REFUSAL_LAYERS = Object.freeze(["read_boundary"]);
|
|
1
2
|
const ATTESTATION_GROUP_OF = {
|
|
2
3
|
settlement: "answer",
|
|
3
4
|
origin: "answer",
|
|
@@ -14,6 +15,7 @@ const ATTESTATION_GROUP_OF = {
|
|
|
14
15
|
bindingRefusal: "bindingRefusal",
|
|
15
16
|
sentence: "sentence",
|
|
16
17
|
receivedAskReasons: "receivedAskReasons",
|
|
18
|
+
stationRefusal: "stationRefusal",
|
|
17
19
|
};
|
|
18
20
|
const ATTESTATION_MEMBERS = Object.keys(ATTESTATION_GROUP_OF);
|
|
19
21
|
const groupLead = (g) => ATTESTATION_MEMBERS.find((k) => ATTESTATION_GROUP_OF[k] === g);
|
|
@@ -73,6 +73,19 @@
|
|
|
73
73
|
* provider pushes back (a session-wide cooldown, or that model refused for the session), and the reading
|
|
74
74
|
* (`fastModeReadingOf`) rides `wiring_manifest.fastMode`, `TaskResult.fastMode` and `model.fast_mode_changed`. An engine
|
|
75
75
|
* without the word refuses the spec key (`config.spec_unknown_key`), so a shell that offers a fast-mode toggle gates on it.
|
|
76
|
+
* - `task.agent_config_dirs` — the engine reads `TaskSpec.agentConfigDirs` (the caller's configuration roots): below every root the
|
|
77
|
+
* rows that name the configuration directory are placed exactly as below `RunnerDeps.agentConfigDir` — the read deny rows that
|
|
78
|
+
* open with `~/.sema/` and the always-on write-protection table's `.sema` rows — on every read face (the structured tools and the
|
|
79
|
+
* shell's read station) and every write face that table judges; the roots only add to the deployment's, ride every engine-built
|
|
80
|
+
* child and are recorded on a parked row (`CheckpointState.agentConfigDirs`, reader word `agent_config_dirs`); the leg's manifest
|
|
81
|
+
* says how many roots it holds and where each came from (`declaredPlaces.agentConfigDirs`). An engine without the word refuses
|
|
82
|
+
* the key (`config.spec_unknown_key`), so a host on an attached engine gates on the word and, without it, declares the files by
|
|
83
|
+
* name through `TaskSpec.readDenyPatterns`.
|
|
84
|
+
* - `task.agent_home_dirs` — the engine reads `TaskSpec.agentHomeDirs` (the caller's homes): the home-anchored read deny rows
|
|
85
|
+
* (`~/…`) are placed below every one beside the engine's own homes, on every read face, the list only adding (recorded as
|
|
86
|
+
* `CheckpointState.agentHomeDirs`, reader word `agent_home_dirs`; manifest `declaredPlaces.agentHomeDirs`). Nothing else reads
|
|
87
|
+
* the list: the engine looks for no configuration, skill, instruction or memory there. An engine without the word refuses the
|
|
88
|
+
* key (`config.spec_unknown_key`).
|
|
76
89
|
* - `task_notification.note_key` — every `task_notification` event this engine pushes states `noteKey`, the key of the event's
|
|
77
90
|
* own notification (`taskNotificationDedupKey(notification)`, a root export), on every road a notification takes: the live
|
|
78
91
|
* lane when it is accepted, the turn-open redelivery of one parked while the session sat idle, and so for each producer behind
|
|
@@ -84,6 +97,6 @@
|
|
|
84
97
|
* and no row. With the word, a `task_notification` without `noteKey` is not this engine's push (a relay's, or a projection that
|
|
85
98
|
* dropped the member). Without the word, the key's absence says nothing: a host decides on the word, not on a version number.
|
|
86
99
|
*/
|
|
87
|
-
export declare const ENGINE_CAPABILITIES: readonly ["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key"];
|
|
100
|
+
export declare const ENGINE_CAPABILITIES: readonly ["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.agent_config_dirs", "task.agent_home_dirs"];
|
|
88
101
|
/** One word of {@link ENGINE_CAPABILITIES}. */
|
|
89
102
|
export type EngineCapability = (typeof ENGINE_CAPABILITIES)[number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ENGINE_CAPABILITIES = Object.freeze(["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key"]);
|
|
1
|
+
export const ENGINE_CAPABILITIES = Object.freeze(["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.agent_config_dirs", "task.agent_home_dirs"]);
|
|
@@ -13,6 +13,11 @@ export interface EngineNotice {
|
|
|
13
13
|
* announced once per prepared task; `detail: { modelId, declaredAutoCompactTokens,
|
|
14
14
|
* physicalWindow, sessionId, runId }` — `runId` is what makes the "once per prepared task" claim
|
|
15
15
|
* checkable, the session id beside it being shared by every run of the session.
|
|
16
|
+
* - `"config.compaction_member_ignored"` — a host handed a compaction member this engine receives and no longer
|
|
17
|
+
* reads (the summary always runs on the main model, reusing the main request): `TaskSpec.compactionModel`,
|
|
18
|
+
* `TaskSpec.compaction.clampTolerance`, the same two on `Runner.compactSession`, and `maybeCompact`'s
|
|
19
|
+
* `compactionModel` / `fallbackBudget` / `onWindowSafety`. Told once per process per member; refused by name
|
|
20
|
+
* from 7.70.0. `detail: { member }`.
|
|
16
21
|
* - `"config.env_timeout_discarded"` — a Bash timeout knob (option or env) held a value that is not
|
|
17
22
|
* the value in force; `detail: { knob, raw, usedMs }`.
|
|
18
23
|
* - `"config.materialize_env_discarded"` — `SEMA_TOOL_MATERIALIZE_STRATEGY` held a value outside the
|
|
@@ -202,8 +207,8 @@ export interface EngineNotice {
|
|
|
202
207
|
* (`model`, `modelName`, `thinking`, …) is REFUSED at the membrane instead — a silently ignored
|
|
203
208
|
* `model` runs a different agent than the author asked for.
|
|
204
209
|
* - `"workflow.parked_decision_unused"` (#4390) — a person's decision for a card a finished workflow run parked on reached
|
|
205
|
-
* this leg (`RunInternals.workflowParkedResume`) and the engine did not use it to continue the run. Once per (leg, run);
|
|
206
|
-
* `detail: { runId, decisionIds, reason, holder?, code?, changed?, why?, askedBefore?, rowReason?, terminal?, continuedAs? }` plus the leg's address,
|
|
210
|
+
* this leg (`RunInternals.workflowParkedResume`) and the engine did not use it to continue the run. Once per (leg, run); a reason of `WORKFLOW_PARK_SETTLING_REASONS` is told once, recorded on the park's holder, and a later hand-over answered with nothing (`workflowParkDecisionOf` reads it);
|
|
211
|
+
* `detail: { runId, decisionIds, reason, holder?, code?, changed?, inputs?, why?, askedBefore?, rowReason?, terminal?, continuedAs? }` plus the leg's address,
|
|
207
212
|
* never the token; `reason` ∈ `WORKFLOW_PARK_UNUSED_REASONS`. `ask_unanswerable` = not used, still deliverable; `decision_spent` = used and refused,
|
|
208
213
|
* a person decides again; `card_unresumable` = this engine never resumes the card (`terminal: true` = no release does); `continuing_elsewhere` = the claim
|
|
209
214
|
* is held elsewhere, `waiting_elsewhere` = continuing the run would add a waiting line — another line waits on a card (`holder` = its head run, or every head run when several lines wait): not used, still deliverable (once none of those lines waits); `run_not_ended` = the run that holds a card still waiting is recorded as running (its end was never written): not used, deliverable again only once that run has ended; a card no longer pending is `not_pending` whatever the run's record says. Audience user.
|
|
@@ -623,8 +628,9 @@ export interface EngineNotice {
|
|
|
623
628
|
* The model can still call the tool. Audience `user`; `detail: { tool, sessionId, runId }`. ONCE PER REFUSAL.
|
|
624
629
|
* - `"context.messages_omitted"` (#1822) — the request's guard trim, the last resort after compaction declined, failed
|
|
625
630
|
* or did not get the request under its guard, left the OLDEST messages out of what the model sees (the model reads
|
|
626
|
-
* a line saying earlier messages were omitted; the session keeps every message)
|
|
627
|
-
* `detail: { omitted, sessionId, runId }`, `
|
|
631
|
+
* a line saying earlier messages were omitted; the session keeps every message): why compaction did not make it fit, what
|
|
632
|
+
* was left out, the way out. Audience `user`; `detail: { omitted, compaction?, sessionId, runId }`, `compaction` = the in-turn
|
|
633
|
+
* compaction's verdict (`landed` yet too large / `noop` / `failed` / `paused` / `off` / `suppressed` / `cut`). ONCE PER TRIMMED
|
|
628
634
|
* STRETCH: told on the first trimmed request a context hook handed on, silent while the requests after it stay
|
|
629
635
|
* trimmed, said again only after a request that fit (a provisional view the in-turn compaction replaced says
|
|
630
636
|
* nothing). A shell that renders a compaction failure as "the context was not shrunk" reads this code for that
|
|
@@ -1175,8 +1181,8 @@ export interface EngineNotice {
|
|
|
1175
1181
|
* report — that sharing is the contract (one report, several distinct facts): dedup on
|
|
1176
1182
|
* `(code, detail.reportId)`; a repeat with the same pair is a replay, a new pair is a new fact.
|
|
1177
1183
|
* - `"memory.harvest_refused"` (#2424) — the boundary harvest was refused wholesale by an incident
|
|
1178
|
-
*
|
|
1179
|
-
*
|
|
1184
|
+
* — the deletion fuse: nothing deleted, the removed files back from their saved copies (and how many
|
|
1185
|
+
* could not); a vanished write root or an unreadable control plane: its memory changes did not take effect.
|
|
1180
1186
|
* Minted by the runner at the harvest seat, one notice per refused harvest report;
|
|
1181
1187
|
* `detail: { kind, committed, reportId?, sessionId? }` (`kind` = `HarvestReport.incident.kind`,
|
|
1182
1188
|
* `committed` = the report's applied patch count, 0 unless a dual-root merge carries the other
|
|
@@ -1428,7 +1434,7 @@ export interface EngineNotice {
|
|
|
1428
1434
|
* throw rendered twice keeps one id, two refusals sharing a code/scope/message get two. Omitted
|
|
1429
1435
|
* (never fabricated) when the caller composes the line with no error in hand.
|
|
1430
1436
|
*
|
|
1431
|
-
* The
|
|
1437
|
+
* The six SERVER-minted rows ({@link NOTICE_MINTER} `"server"`) — catalogued so their audience and detail shape
|
|
1432
1438
|
* are read here like every other row; this engine never mints them. A server forwards them through the same sink.
|
|
1433
1439
|
* - `"permission.entry_mode_clamped"` — the permission mode the caller requested was clamped by the deployment's
|
|
1434
1440
|
* entry floor BEFORE the run reached this engine (the server's own clamp, through this package's
|
|
@@ -1456,6 +1462,11 @@ export interface EngineNotice {
|
|
|
1456
1462
|
* `"user"` — the person's parked work and later resume are what the declaration bounds, and the remedy (a
|
|
1457
1463
|
* durable store) stays the deployment's; `detail.sessionId` names the session. The sentence the person reads and
|
|
1458
1464
|
* how often it is told are the server's; this engine only catalogues the code.
|
|
1465
|
+
* - `"memory.sync_layer_parked"` — a memory sync layer of the serving process stopped syncing on its cursor (cause `cursor_refused` |
|
|
1466
|
+
* `cursor_unusable`) and stays stopped until the cursor is reset. Audience `"user"`, attention `"act"` (a server's frame skips the throat,
|
|
1467
|
+
* so the server writes the attention member itself); `detail: { scope, cause, axis?, found?, wayOut, sessionId }` — `axis` / `found` as the
|
|
1468
|
+
* engine's cursor-refusal detail when the cause is `cursor_refused`. Once per parking per serving process; the sentence is the server's,
|
|
1469
|
+
* and this engine only catalogues the code.
|
|
1459
1470
|
*
|
|
1460
1471
|
* Deliberately NOT a notice family: brain retry/reconnect liveness (a rate limit, a 5xx, a
|
|
1461
1472
|
* transient network failure being retried). Those are per-attempt liveness frames with their own
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ENGINE_VERSION = "7.69.
|
|
1
|
+
export const ENGINE_VERSION = "7.69.1";
|
|
@@ -48,8 +48,14 @@ import { type ClassifierCategory } from "./classifier-category.js";
|
|
|
48
48
|
* - `blanket_allow_refused` — an allow NO PERSON JUDGED met a `requiresRealApproval` ask: a blanket
|
|
49
49
|
* `onAsk:"allow"`, or an approver's allow it reported as the deployment's policy (`settledBy: "policy"`).
|
|
50
50
|
* - `task_aborted` — the wait's abort signal ended it (the run's own end, or a turn-level interrupt).
|
|
51
|
+
* - `approval_withdrawn` — the HOST's approval system closed the question before anyone answered it, while the
|
|
52
|
+
* run that asked is still going (a sibling of a batch whose outcome made this question moot, every target the
|
|
53
|
+
* card was sent to gone, a replay of a row its system had already closed): nobody refused, the call did not
|
|
54
|
+
* run, and asking again is legitimate. A synchronous approver reports it as `settledBy: "withdrawn"`; the
|
|
55
|
+
* host is the party (`who.party: "host"`, as for its own elapsed window), never `none` — that party is the
|
|
56
|
+
* engine's own fail-closed ends, which a host does not get to stamp.
|
|
51
57
|
*/
|
|
52
|
-
export declare const SETTLEMENT_KINDS: readonly ["human_allowed", "human_refused", "approval_window_expired", "denial_limit_window_expired", "park_sla_expired", "no_approver", "approver_unavailable", "approver_error", "approver_contract", "presentation_failed", "blanket_allow_refused", "policy_allowed", "policy_refused", "task_aborted"];
|
|
58
|
+
export declare const SETTLEMENT_KINDS: readonly ["human_allowed", "human_refused", "approval_window_expired", "denial_limit_window_expired", "park_sla_expired", "no_approver", "approver_unavailable", "approver_error", "approver_contract", "presentation_failed", "blanket_allow_refused", "policy_allowed", "policy_refused", "task_aborted", "approval_withdrawn"];
|
|
53
59
|
export type SettlementKind = (typeof SETTLEMENT_KINDS)[number];
|
|
54
60
|
/** Membership test for {@link SettlementKind} — the word crosses process boundaries on `tool_end`, so a
|
|
55
61
|
* consumer validating one it received must not hand-roll the set. */
|
|
@@ -67,7 +73,7 @@ export declare function isSettlementKind(v: unknown): v is SettlementKind;
|
|
|
67
73
|
*
|
|
68
74
|
* @contract settlement.single_mint — every `Settlement` kind is composed by CORE at the site whose wait
|
|
69
75
|
* ended (the ask resolver's arms, the approval factory's arms, the decide lane over a host's decision
|
|
70
|
-
* FACTS), and the four DECIDER words by one composer ({@link settledByDecider}). A host never mints a kind: a synchronous approver reports `"human"`/`"timeout"`/`"policy"` on its
|
|
76
|
+
* FACTS), and the four DECIDER words by one composer ({@link settledByDecider}). A host never mints a kind: a synchronous approver reports `"human"`/`"timeout"`/`"policy"`/`"withdrawn"` on its
|
|
71
77
|
* outcome and a durable decide reports `hostDecision.decidedBy` (`"person"`/`"sla_timeout"`/`"policy"`) — facts
|
|
72
78
|
* core turns into the word. A settlement reaches the gate's exit only inside an engine-minted record on the decision
|
|
73
79
|
* (`PermissionResult.attestation`, {@link import("./tool-policy.js").EngineAttestation}), which a policy cannot compose:
|
|
@@ -97,6 +103,12 @@ export type Settlement = {
|
|
|
97
103
|
party: "host";
|
|
98
104
|
};
|
|
99
105
|
when: number;
|
|
106
|
+
} | {
|
|
107
|
+
kind: "approval_withdrawn";
|
|
108
|
+
who: {
|
|
109
|
+
party: "host";
|
|
110
|
+
};
|
|
111
|
+
when: number;
|
|
100
112
|
} | {
|
|
101
113
|
kind: "denial_limit_window_expired";
|
|
102
114
|
who: {
|
|
@@ -240,6 +252,7 @@ export declare const SETTLEMENT_IS_REFUSAL: {
|
|
|
240
252
|
readonly policy_allowed: false;
|
|
241
253
|
readonly policy_refused: true;
|
|
242
254
|
readonly task_aborted: true;
|
|
255
|
+
readonly approval_withdrawn: true;
|
|
243
256
|
};
|
|
244
257
|
/** Compile-time fence: `never` while every settlement kind has a refusal row. */
|
|
245
258
|
export type SettlementRefusalTableCoversEveryKind = AssertAllKeysHandled<Exclude<SettlementKind, keyof typeof SETTLEMENT_IS_REFUSAL>>;
|
|
@@ -267,6 +280,8 @@ export type SettlementRefusalTableCoversEveryKind = AssertAllKeysHandled<Exclude
|
|
|
267
280
|
* engine could not use its answer, or could not put these arguments before it (or adopt its edit). Not a
|
|
268
281
|
* deployment with nobody home: with no approver, such arguments are refused under `no_approver`.
|
|
269
282
|
* - `task_aborted` — the run ended; nothing is escalating anywhere.
|
|
283
|
+
* - `approval_withdrawn` — the question was taken back before anyone answered it, not left with nobody to
|
|
284
|
+
* answer it: the same call asked again reaches the same approval system.
|
|
270
285
|
*/
|
|
271
286
|
export declare const SETTLEMENT_NOBODY_JUDGED: {
|
|
272
287
|
readonly human_allowed: false;
|
|
@@ -283,6 +298,7 @@ export declare const SETTLEMENT_NOBODY_JUDGED: {
|
|
|
283
298
|
readonly policy_allowed: false;
|
|
284
299
|
readonly policy_refused: true;
|
|
285
300
|
readonly task_aborted: false;
|
|
301
|
+
readonly approval_withdrawn: false;
|
|
286
302
|
};
|
|
287
303
|
/** Compile-time fence: `never` while every settlement kind has a nobody-judged row. */
|
|
288
304
|
export type NobodyJudgedTableCoversEveryKind = AssertAllKeysHandled<Exclude<SettlementKind, keyof typeof SETTLEMENT_NOBODY_JUDGED>>;
|
|
@@ -633,6 +649,17 @@ export interface GateOutcome {
|
|
|
633
649
|
settlement?: Settlement;
|
|
634
650
|
origin?: AskOrigin;
|
|
635
651
|
}
|
|
652
|
+
/**
|
|
653
|
+
* Whether `gate` is a person's refusal: the refusing layer is the ask's resolution and its settlement is a person's refusal — not a
|
|
654
|
+
* later layer's deny that followed a person's answer, nor a policy's, a window's, a cancellation's or a failed approver's settlement.
|
|
655
|
+
* The one reading behind every consequence the engine draws from a person's "no" (the bare refusal that ends a turn, the parked
|
|
656
|
+
* decision a person refused to continue).
|
|
657
|
+
*/
|
|
658
|
+
export declare function isHumanRefusal(gate: GateOutcome | undefined): gate is GateOutcome & {
|
|
659
|
+
readonly settlement: Settlement & {
|
|
660
|
+
readonly kind: "human_refused";
|
|
661
|
+
};
|
|
662
|
+
};
|
|
636
663
|
/** A release as `major.minor.patch`: the version whose engine stopped minting a retired word. */
|
|
637
664
|
type ReleaseVersion = `${number}.${number}.${number}`;
|
|
638
665
|
/**
|
|
@@ -19,6 +19,7 @@ export const SETTLEMENT_KINDS = Object.freeze([
|
|
|
19
19
|
"policy_allowed",
|
|
20
20
|
"policy_refused",
|
|
21
21
|
"task_aborted",
|
|
22
|
+
"approval_withdrawn",
|
|
22
23
|
]);
|
|
23
24
|
const SETTLEMENT_KIND_SET = new Set(SETTLEMENT_KINDS);
|
|
24
25
|
export function isSettlementKind(v) {
|
|
@@ -71,6 +72,7 @@ export const SETTLEMENT_IS_REFUSAL = {
|
|
|
71
72
|
policy_allowed: false,
|
|
72
73
|
policy_refused: true,
|
|
73
74
|
task_aborted: true,
|
|
75
|
+
approval_withdrawn: true,
|
|
74
76
|
};
|
|
75
77
|
export const SETTLEMENT_NOBODY_JUDGED = {
|
|
76
78
|
human_allowed: false,
|
|
@@ -87,6 +89,7 @@ export const SETTLEMENT_NOBODY_JUDGED = {
|
|
|
87
89
|
policy_allowed: false,
|
|
88
90
|
policy_refused: true,
|
|
89
91
|
task_aborted: false,
|
|
92
|
+
approval_withdrawn: false,
|
|
90
93
|
};
|
|
91
94
|
const WINNER_DECISION_ALLOWS = {
|
|
92
95
|
allow: true,
|
|
@@ -165,6 +168,9 @@ export function modeReleaseOf(a, unapplied) {
|
|
|
165
168
|
return { ...record, readUnestablished: { tiers: [], rows: [], rowCount: 0, tableUnread: true } };
|
|
166
169
|
return { ...record, readUnestablished: { tiers: [...unapplied.tiers], rows: unapplied.rows.slice(0, READ_DENY_ROWS_NAMED), rowCount: unapplied.rows.length } };
|
|
167
170
|
}
|
|
171
|
+
export function isHumanRefusal(gate) {
|
|
172
|
+
return gate?.disposition.kind === "denied" && gate.disposition.deniedBy === "ask_resolution" && gate.settlement?.kind === "human_refused";
|
|
173
|
+
}
|
|
168
174
|
const retired = (word, retiredIn) => Object.freeze({ word, retiredIn });
|
|
169
175
|
export const RETIRED_MEMBERS = Object.freeze({
|
|
170
176
|
askClass: Object.freeze([retired("write_protection_unresolved", "7.49.0"), retired("governance_unavailable", "7.51.0")]),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the engine starts a git that only reads the repository (status, log, rev-parse, check-ignore, …): the command word every
|
|
3
|
+
* such start opens with, spelled once. It runs no program the repository's own configuration names — no hook
|
|
4
|
+
* (`core.hooksPath=/dev/null`) and no file-system monitor (`core.fsmonitor=` empty) — and takes no optional lock
|
|
5
|
+
* (`--no-optional-locks`: a status does not write the index back), as the reference's own read-only git does. A start that
|
|
6
|
+
* changes the repository (a worktree add or remove, a ref update) does not open with it. `/dev/null` is written as the
|
|
7
|
+
* reference writes it, on every platform: a hooks directory that holds no hook. A shell word sequence: it is spliced at
|
|
8
|
+
* the head of a command line the execution environment's shell runs.
|
|
9
|
+
*/
|
|
10
|
+
export declare const GIT_READ_ONLY = "git -c core.hooksPath=/dev/null -c core.fsmonitor= --no-optional-locks";
|