@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
|
@@ -14,8 +14,9 @@ import { auditToolCollisions, projectToolManifest } from "../../prompt-assembly/
|
|
|
14
14
|
import { buildEnvironmentContext } from "../../prompts/default.js";
|
|
15
15
|
import { raisePromptCompose } from "../mods/stations.js";
|
|
16
16
|
import { protocolOf } from "../protocol-table.js";
|
|
17
|
+
import { thrownText } from "../thrown-value.js";
|
|
17
18
|
import { hasConversationContent } from "../session.js";
|
|
18
|
-
import {
|
|
19
|
+
import { resolvePromptHashSalt } from "./session-hash-salt.js";
|
|
19
20
|
import { prefixHeadBlocksOf } from "./conversation-segment.js";
|
|
20
21
|
const CATALOG_DIGEST = catalogDigestOf(SEMA_DEFAULT_CATALOG);
|
|
21
22
|
const TASK_TEXT_DIGEST_SCHEME = "sid-sha256:";
|
|
@@ -34,9 +35,10 @@ function taskLayerOf(task, sessionId) {
|
|
|
34
35
|
}));
|
|
35
36
|
}
|
|
36
37
|
export async function preparePromptAssembly(input) {
|
|
37
|
-
const { session, deps, internals, resume, sugar, host, binding, locale, modBus, featureFlags, deferred, toolFace, mcpInstructionsBlock, memoryBlock, envFacts, promptTraits, tools, model, sessionId, onceLedger } = input;
|
|
38
|
+
const { session, deps, internals, resume, sugar, host, binding, locale, modBus, featureFlags, deferred, toolFace, mcpInstructionsBlock, memoryBlock, envFacts, promptTraits, skillsAnnounced, tools, model, sessionId, onceLedger } = input;
|
|
38
39
|
const topLevel = internals?.parentTaskId === undefined && internals?.parentSessionId === undefined && internals?.parentCenterArtifactDigest === undefined;
|
|
39
40
|
const stored = await session.getPromptEpoch();
|
|
41
|
+
const promptHashSalt = await resolvePromptHashSalt(session, (error, step) => onceLedger.onError(new Error(`prompt digests: the session's hash salt could not be ${step === "read" ? "read" : "stored"} (${thrownText(error)}) — this leg's prompt.assembled hashes, turn-snapshot digests and request heads compare within this leg only (hashScope "leg")`), { phase: "config", sessionId }));
|
|
40
42
|
let centerAdoption;
|
|
41
43
|
{
|
|
42
44
|
const failUnavailable = (what, refusal) => {
|
|
@@ -90,6 +92,7 @@ export async function preparePromptAssembly(input) {
|
|
|
90
92
|
...featureFlags,
|
|
91
93
|
orchestrationEnabled,
|
|
92
94
|
orchestrationDeferred: orchestrationEnabled && deferred.has("Workflow"),
|
|
95
|
+
skillToolMounted: skillsAnnounced,
|
|
93
96
|
toolFace,
|
|
94
97
|
};
|
|
95
98
|
const selectors = selectorsOf(facts, host, binding, promptTraits, locale);
|
|
@@ -156,14 +159,16 @@ export async function preparePromptAssembly(input) {
|
|
|
156
159
|
if (record !== undefined)
|
|
157
160
|
await session.appendPromptEpoch(record);
|
|
158
161
|
const current = record ?? (stored?.kind === "pin" ? stored.descriptor : undefined);
|
|
159
|
-
const
|
|
162
|
+
const { salt } = promptHashSalt;
|
|
163
|
+
const saltedHash = (text) => createHash("sha256").update(salt).update(text).digest("hex").slice(0, 12);
|
|
160
164
|
const contentHashOf = (s) => s.renderer !== undefined || s.chain.some((l) => l.source === "task")
|
|
161
|
-
? `salted:${createHash("sha256").update(
|
|
165
|
+
? `salted:${createHash("sha256").update(salt).update(s.text).digest("hex")}`
|
|
162
166
|
: textContentHashOf(s.text);
|
|
163
167
|
const promptManifest = {
|
|
164
168
|
identity: { artifact: current.identity, layers: current.layers, epoch: current.epoch, activatedBy: current.activatedBy },
|
|
165
169
|
selectors: selectorRecord,
|
|
166
170
|
blocks: promptBlocks.map((b) => ({ id: b.id, chars: b.text.length, hash: saltedHash(b.text) })),
|
|
171
|
+
hashScope: promptHashSalt.scope,
|
|
167
172
|
sections: assembled.sections.map((s) => ({
|
|
168
173
|
id: s.id,
|
|
169
174
|
band: s.band,
|
|
@@ -190,6 +195,7 @@ export async function preparePromptAssembly(input) {
|
|
|
190
195
|
renderWithDate,
|
|
191
196
|
systemBlocks: assembled.systemBlocks,
|
|
192
197
|
prefixHeadBlocks: prefixHeadBlocksOf(promptBlocks),
|
|
198
|
+
promptHashSalt,
|
|
193
199
|
promptManifest,
|
|
194
200
|
promptIdentity,
|
|
195
201
|
buildAssembleInputs,
|
|
@@ -32,7 +32,6 @@ import type { MaterializedMcp } from "../mcp.js";
|
|
|
32
32
|
import type { RosterBuilder } from "../tool-roster.js";
|
|
33
33
|
import type { ResolvedRole } from "../roles.js";
|
|
34
34
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
35
|
-
import type { SessionTreeEntry } from "../../internal/harness-types.js";
|
|
36
35
|
import type { ReadFloorSeat } from "../../tools/fs/read-floor.js";
|
|
37
36
|
import type { DateAnchorRead, PrepareResume, PromptFeatureFlags, RunInternals, ToolFaceSnapshot } from "./contracts.js";
|
|
38
37
|
import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
@@ -120,10 +119,9 @@ export interface PreparePromptInputsInput {
|
|
|
120
119
|
advertisedWritableDirs?: AdvertisedWritableDirs;
|
|
121
120
|
/** borrowed-readonly — the acquired session's id (operator-line context). */
|
|
122
121
|
sessionId: string;
|
|
123
|
-
/** borrowed-readonly — the
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
122
|
+
/** borrowed-readonly — the session's epoch anchor as prepare read it (undefined ⇒ the branch was unreadable): its date
|
|
123
|
+
* half is the prefix date when present. */
|
|
124
|
+
dateAnchor: DateAnchorRead | undefined;
|
|
127
125
|
/** borrowed-readonly — the deployment's window overlay for this leg, as it reads at PREPARE. The prompt's
|
|
128
126
|
* context-management sentence must not claim mid-task summarization a deployment has turned off for this
|
|
129
127
|
* model; the seat is live, so a later swap's effect on the SENTENCE lands at the next prepare while its
|
|
@@ -145,8 +143,6 @@ export interface PreparePromptInputsResult {
|
|
|
145
143
|
tzValid: boolean;
|
|
146
144
|
/** owned — the client's declared zone as given (paired with `tzValid`; unvalidated on its own). */
|
|
147
145
|
userTz: string | undefined;
|
|
148
|
-
/** owned — the session's date anchor as read here; `envFacts.date` is its prefix date when present. */
|
|
149
|
-
dateAnchor: DateAnchorRead | undefined;
|
|
150
146
|
/** owned — the git-status lane's run-local state (empty on a hands-less leg); the run loop and the checkpoint
|
|
151
147
|
* serializer mutate its fields from here on (`announced`, `mirrorOwed`, …; the frame's receipt rides the leg's shared `Prepared.frameReceipts`). */
|
|
152
148
|
gitStatusRef: GitStatusLaneRef;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { formatLocalDate,
|
|
1
|
+
import { formatLocalDate, judgedUserTimeZone } from "../../prompts/default.js";
|
|
2
2
|
import { requestBodySugar } from "../../prompt-assembly/sugar.js";
|
|
3
3
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
4
4
|
import { instructionsTaught, toldAtStart } from "../mounted-mcp.js";
|
|
5
5
|
import { isIsolated } from "../remote-env.js";
|
|
6
|
-
import { readDateAnchor } from "./conversation-segment.js";
|
|
7
6
|
import { probeGitStatusLane } from "./git-status-frame.js";
|
|
8
7
|
import { renderMcpInstructionsEntry } from "./turn-attachments.js";
|
|
9
8
|
import { cwdAlignmentProbe, cwdMisalignmentMessage, readCwdAlignment } from "./cwd-alignment-probe.js";
|
|
9
|
+
import { GIT_READ_ONLY as G } from "../git-read-only.js";
|
|
10
10
|
const ULTRA_REASONING_TIERS = new Set(["xhigh", "max"]);
|
|
11
11
|
import { compactionEnabled } from "../context-settings.js";
|
|
12
12
|
export async function preparePromptInputs(input) {
|
|
13
|
-
const { spec, deps, failClosedReason, lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, readFloor, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId,
|
|
13
|
+
const { spec, deps, failClosedReason, lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, readFloor, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, dateAnchor, advertisedWritableDirs } = input;
|
|
14
14
|
const promptPolicyEnabled = Boolean(lockedPreflight.toolPolicy);
|
|
15
15
|
const promptHooksEnabled = input.modBus.hasHandlers("classic.PreToolUse") || input.modBus.hasHandlers("classic.PostToolUse");
|
|
16
16
|
if (failClosedReason) {
|
|
@@ -38,8 +38,7 @@ export async function preparePromptInputs(input) {
|
|
|
38
38
|
const say = input.engineText;
|
|
39
39
|
const mcpInstructionsBlock = taught.length ? `${say("core/engine.mcp-header")}\n${taught.map((entry) => renderMcpInstructionsEntry(entry, say)).join("\n\n")}` : undefined;
|
|
40
40
|
const userTz = spec.clientContext?.timeZone;
|
|
41
|
-
const tzValid =
|
|
42
|
-
const dateAnchor = await readDateAnchor(session);
|
|
41
|
+
const tzValid = judgedUserTimeZone(spec.clientContext) !== undefined;
|
|
43
42
|
const envFacts = { date: dateAnchor?.current?.prefixDate ?? formatLocalDate(new Date(), tzValid ? userTz : undefined), modelId: model.id };
|
|
44
43
|
if (tzValid)
|
|
45
44
|
envFacts.timeZone = userTz;
|
|
@@ -86,7 +85,7 @@ export async function preparePromptInputs(input) {
|
|
|
86
85
|
}
|
|
87
86
|
try {
|
|
88
87
|
const probeFloor = readFloor(undefined);
|
|
89
|
-
const probe = await executionEnv.exec(
|
|
88
|
+
const probe = await executionEnv.exec(`uname -s; uname -r; (${G} rev-parse --is-inside-work-tree 2>/dev/null || echo false); (${G} symbolic-ref --short -q HEAD 2>/dev/null || echo "HEAD (detached)"); (${G} rev-parse --show-toplevel 2>/dev/null || echo); (test -n "$(${G} status --porcelain 2>/dev/null | head -1)" && echo dirty || echo clean); (s=$(ps -p $$ -o comm= 2>/dev/null); s=\${s##*/}; echo "\${s#-}"); (test "$(${G} rev-parse --git-dir 2>/dev/null)" != "$(${G} rev-parse --git-common-dir 2>/dev/null)" && echo linked || echo main); ` + cwdAlignmentProbe(taskRootFinal), { cwd: envFacts.cwd, timeout: 10, ...(probeFloor !== undefined ? { readFloor: probeFloor } : {}) });
|
|
90
89
|
if (probe.ok && probe.value.exitCode === 0) {
|
|
91
90
|
const lines = probe.value.stdout.split("\n");
|
|
92
91
|
if (lines.length >= 6) {
|
|
@@ -135,5 +134,5 @@ export async function preparePromptInputs(input) {
|
|
|
135
134
|
onDegrade: (reason) => deps.onError?.(new Error(`env git snapshot degraded — ${reason}`), { phase: "degraded", sessionId, classification: "env-git-snapshot" }),
|
|
136
135
|
say,
|
|
137
136
|
});
|
|
138
|
-
return { featureFlags, sugar, mcpInstructionsBlock, envFacts, tzValid, userTz,
|
|
137
|
+
return { featureFlags, sugar, mcpInstructionsBlock, envFacts, tzValid, userTz, gitStatusRef };
|
|
139
138
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { callerToolNameProblem } from "../caller-tool-name.js";
|
|
2
2
|
import { describeToolCatalog } from "../tool-registry.js";
|
|
3
|
+
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
3
4
|
import { callerCardIdOf, rosterMemberBoundProblem, schemaKeyBoundProblem, survivorsByName } from "../tool-roster.js";
|
|
4
5
|
import { toolFaceProblem } from "./tool-face-overlay.js";
|
|
5
6
|
import { callerEngineContractProblem } from "./caller-roster.js";
|
|
@@ -83,6 +84,12 @@ export function prepareSafetyScan(input) {
|
|
|
83
84
|
e.code = "config.tool_face_invalid";
|
|
84
85
|
throw e;
|
|
85
86
|
}
|
|
87
|
+
const perTurn = t.perTurn;
|
|
88
|
+
if (perTurn !== undefined && perTurn !== true) {
|
|
89
|
+
const e = new Error(`Tool "${t.name}" declares \`perTurn\` as ${describeRejectedValue(perTurn)}: it is \`true\` (the host mounts the tool on some turns only) or absent.`);
|
|
90
|
+
e.code = "config.tool_face_invalid";
|
|
91
|
+
throw e;
|
|
92
|
+
}
|
|
86
93
|
}
|
|
87
94
|
for (const [what, n] of [["name", t.name], ...(t.aliases ?? []).map((a) => ["alias", a])]) {
|
|
88
95
|
const problem = callerToolNameProblem(n);
|
|
@@ -67,6 +67,7 @@ export interface PrepareSuspendSagaInput {
|
|
|
67
67
|
/** borrowed-readonly — the command sandbox requirement this leg runs under (judged; the resumed leg's floor included), recorded on
|
|
68
68
|
* every row it mints (`CheckpointState.commandSandbox`). Absent ⇒ none. */
|
|
69
69
|
commandSandboxRequirement: import("../command-sandbox.js").TaskSandboxSettings | undefined;
|
|
70
|
+
/** borrowed-readonly — the leg's declared places (the driver's one mint): recorded on the row, a resume's floor. */ callerPlaces: import("./leg-caller-places.js").LegCallerPlaces;
|
|
70
71
|
/** borrowed-readonly — the wiring-manifest phase's ONE activation predicate; false ⇒ this phase builds nothing and
|
|
71
72
|
* returns an absent saga. */
|
|
72
73
|
gateMachineryActive: boolean;
|
|
@@ -115,6 +116,9 @@ export interface PrepareSuspendSagaInput {
|
|
|
115
116
|
faceCheckpointSection: () => SerializedCheckpointState["readFace"];
|
|
116
117
|
/** borrowed-readonly — the inherited-gate phase's WRITE-face section builder (the row's `writeFace`). */
|
|
117
118
|
writeFaceCheckpointSection: () => SerializedCheckpointState["writeFace"];
|
|
119
|
+
/** owned (value) — the leg's resolved `blockReadsOutsideRoots` (the hands phase's one answer: the declaration, or the resumed
|
|
120
|
+
* row's record of it): the row records it when it is on (`readBlock: true`), so a resume keeps it whatever the host re-sends. */
|
|
121
|
+
readBlock: boolean;
|
|
118
122
|
/** borrowed-readonly — the inherited-gate phase's SKILL-GRANT section builder (the row's `skillGrants`). */
|
|
119
123
|
skillGrantCheckpointSection: () => SerializedCheckpointState["skillGrants"];
|
|
120
124
|
/** borrowed-readonly — the leg's skill scopes (the mods admission's record): the row's `skillScopes`, read at the park. */
|
|
@@ -83,7 +83,7 @@ function stampPlacementRootSessionId(placementRootResolved) {
|
|
|
83
83
|
return placementValueOrAbsent(placementRootResolved);
|
|
84
84
|
}
|
|
85
85
|
export function prepareSuspendSaga(input) {
|
|
86
|
-
const { commandSandboxRequirement, gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, skillScopesCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, askSource, placementRootResolved, compositionLegResolved, checkpointScope, runOrigin, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, crossBoundary, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv } = input;
|
|
86
|
+
const { commandSandboxRequirement, callerPlaces, gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, readBlock, skillGrantCheckpointSection, skillScopesCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, askSource, placementRootResolved, compositionLegResolved, checkpointScope, runOrigin, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, crossBoundary, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv } = input;
|
|
87
87
|
if (!gateMachineryActive)
|
|
88
88
|
return { saga: undefined };
|
|
89
89
|
const taskAccess = { owner: hostTaskId, scope: taskScope, sessionId };
|
|
@@ -115,6 +115,7 @@ export function prepareSuspendSaga(input) {
|
|
|
115
115
|
readFileState: readFileStateForCheckpoint ? [...readFileStateForCheckpoint.entries()] : undefined,
|
|
116
116
|
readFace: faceCheckpointSection(),
|
|
117
117
|
writeFace: writeFaceCheckpointSection(),
|
|
118
|
+
readBlock: readBlock ? true : undefined,
|
|
118
119
|
skillGrants: skillGrantCheckpointSection(),
|
|
119
120
|
skillScopes: skillScopesCheckpointSection(),
|
|
120
121
|
reminderMark,
|
|
@@ -187,7 +188,7 @@ export function prepareSuspendSaga(input) {
|
|
|
187
188
|
toolCeiling: toolCeiling !== undefined ? toolCeiling.map((l) => ({ ...(l.allow !== undefined ? { allow: persistedToolNameList(l.allow, "allowed") } : {}), deny: persistedToolNameList(l.deny, "denied") })) : undefined,
|
|
188
189
|
toolListsJudged,
|
|
189
190
|
ownToolLists: ownToolLists !== undefined ? { toolName: ownToolLists.toolName, ...(ownToolLists.definition !== undefined ? { definition: ownToolLists.definition } : {}), lists: ownToolLists.lists } : undefined,
|
|
190
|
-
commandSandbox: commandSandboxRequirement,
|
|
191
|
+
commandSandbox: commandSandboxRequirement, ...callerPlaces.recorded(),
|
|
191
192
|
crossBoundaryRecorded: crossBoundary.recorded() ? true : undefined,
|
|
192
193
|
});
|
|
193
194
|
const compensatePausedVM = (remoteEnv, snapshotId) => compensateUnparkedPause(remoteEnv, snapshotId, {
|