@sema-agent/core 5.63.0 → 5.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/dist/agents/cascade.d.ts +5 -1
- package/dist/agents/cascade.js +6 -1
- package/dist/agents/subagent.js +1 -0
- package/dist/agents/verify.d.ts +5 -1
- package/dist/agents/verify.js +5 -2
- package/dist/core/checkpoint-store.d.ts +100 -5
- package/dist/core/fs-write-gate-policy.d.ts +21 -0
- package/dist/core/fs-write-gate-policy.js +14 -3
- package/dist/core/hooks.d.ts +9 -1
- package/dist/core/hooks.js +1 -1
- package/dist/core/memory-engine/dual-root.js +3 -0
- package/dist/core/memory-engine/engine.d.ts +1 -0
- package/dist/core/memory-engine/engine.js +9 -5
- package/dist/core/memory-engine/types.d.ts +16 -0
- package/dist/core/remote-env.d.ts +34 -2
- package/dist/core/runner/prepare-hands-readface.d.ts +9 -0
- package/dist/core/runner/prepare-hands-readface.js +4 -1
- package/dist/core/runner/prepare-memory.js +1 -1
- package/dist/core/runner/prepare-task.d.ts +31 -0
- package/dist/core/runner/prepare-task.js +53 -18
- package/dist/core/runner/prepare-workspace-restore.js +13 -0
- package/dist/core/runner/runtask.d.ts +18 -0
- package/dist/core/runner/runtask.js +173 -20
- package/dist/core/stub-env.d.ts +4 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/task-registry-shared.js +20 -2
- package/dist/core/types.d.ts +104 -11
- package/dist/core/usage-window-store.d.ts +44 -12
- package/dist/core/usage-window-store.js +11 -3
- package/dist/core/workflow-run-store-contract.js +30 -0
- package/dist/core/workflow-run-store.d.ts +39 -1
- package/dist/core/workflow-run-store.js +2 -0
- package/dist/engine/harness/agent-harness.d.ts +8 -3
- package/dist/engine/harness/agent-harness.js +9 -4
- package/dist/engine/harness/types.d.ts +107 -3
- package/dist/engine/loop/agent-loop.js +39 -15
- package/dist/engine/loop/types.d.ts +43 -22
- package/dist/index.d.ts +2 -2
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +6 -0
- package/dist/orchestration/run-workflow-tool.js +1 -0
- package/dist/orchestration/workflow-types.d.ts +35 -0
- package/dist/orchestration/workflow-types.js +2 -2
- package/dist/orchestration/workflow.d.ts +6 -0
- package/dist/orchestration/workflow.js +21 -1
- package/dist/prompts/default.d.ts +8 -0
- package/dist/prompts/default.js +3 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +44 -1
- package/dist/tools/fs/bash-readonly-classifier.js +132 -5
- package/dist/tools/fs/fs-bash.js +9 -2
- package/dist/tools/fs/fs-write.js +19 -8
- package/dist/tools/fs/index.d.ts +1 -0
- package/dist/tools/fs/index.js +1 -0
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +9 -1
|
@@ -4,6 +4,16 @@ import { defineTool, errorResult } from "../../core/tools.js";
|
|
|
4
4
|
import { sha256, resolveKey, violationText, violationDetails, requireRead, checkStale, checkEditMatch, checkNoChange, fileArgPath, resolveQuoteMatch, adaptNewStringQuotes, resolveEscapeMatch, adaptNewStringEscapes, escapeMatchWasAttempted, ESCAPE_MATCH_MISS_NOTE, deletionOldString, countOccurrences, READ_REFUSED_ESCAPE_HINT, } from "./safety.js";
|
|
5
5
|
import { decodeTextBytes, encodeTextForFile, normalizeEditText, normalizeFileText } from "./encoding.js";
|
|
6
6
|
import { MAX_EDIT_BYTES, decodeEditBytes, tooLargeToEditMessage, truncatedUtf16BodyMessage, persistedTextOf, notReadRefusalText, enoentMessage, FILE_STATE_TRAILER, FILE_PATH_PARAMS, ipynbRedirect, countLines, } from "./fs-shared.js";
|
|
7
|
+
async function envFinalWrite(env, key, content, signal, opts) {
|
|
8
|
+
if (env.writeFileGuarded !== undefined) {
|
|
9
|
+
const r = await env.writeFileGuarded(key, content, { canonicalPath: key, ...(opts?.exclusive === true ? { exclusive: true } : {}) }, signal);
|
|
10
|
+
return r.ok ? { ok: true } : r;
|
|
11
|
+
}
|
|
12
|
+
if (opts?.exclusive === true && env.writeFileExclusive !== undefined) {
|
|
13
|
+
return env.writeFileExclusive(key, content, signal);
|
|
14
|
+
}
|
|
15
|
+
return env.writeFile(key, content, signal);
|
|
16
|
+
}
|
|
7
17
|
async function gateToolWrite(hook, tool, path, key, content) {
|
|
8
18
|
if (hook === undefined)
|
|
9
19
|
return undefined;
|
|
@@ -71,13 +81,14 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
71
81
|
const gated = await gateToolWrite(beforeWrite, "Edit", path, r.key, created);
|
|
72
82
|
if (gated !== undefined)
|
|
73
83
|
return errorResult(gated);
|
|
74
|
-
const write = env.
|
|
75
|
-
? await env.writeFileExclusive(r.key, created, ctx.signal)
|
|
76
|
-
: await env.writeFile(r.key, created, ctx.signal);
|
|
84
|
+
const write = await envFinalWrite(env, r.key, created, ctx.signal, { exclusive: true });
|
|
77
85
|
if (!write.ok) {
|
|
78
86
|
if (write.error.code === "already_exists") {
|
|
79
87
|
return errorResult(`Error (Edit): cannot create "${path}": file already exists (created concurrently since the existence check). Read the file first, then edit it normally (or Write after the Read to overwrite it).`);
|
|
80
88
|
}
|
|
89
|
+
if (write.error.code === "precondition_failed") {
|
|
90
|
+
return errorResult(`Error (Edit): cannot create "${path.slice(0, 512)}": the atomic write refused its precondition (${write.error.message.slice(0, 512)}) — the on-disk state at that path changed between the existence check and the write (something may now exist there, or the path may now resolve somewhere else, e.g. through a symlink). Nothing was written. Read the path to see what is actually there before acting on it.`);
|
|
91
|
+
}
|
|
81
92
|
return errorResult(`Error (Edit): cannot write "${path}": ${write.error.message}`);
|
|
82
93
|
}
|
|
83
94
|
const createdNorm = normalizeFileText(created);
|
|
@@ -121,7 +132,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
121
132
|
if (gated !== undefined)
|
|
122
133
|
return errorResult(gated);
|
|
123
134
|
const encodedOverwrite = encodeTextForFile(newContent, preDec.encoding, preDec.endings);
|
|
124
|
-
const write = await env
|
|
135
|
+
const write = await envFinalWrite(env, r.key, encodedOverwrite, ctx.signal);
|
|
125
136
|
if (!write.ok)
|
|
126
137
|
return errorResult(`Error (Edit): cannot write "${path}": ${write.error.message}`);
|
|
127
138
|
const persistedOverwrite = persistedTextOf(encodedOverwrite);
|
|
@@ -194,7 +205,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
194
205
|
if (gated !== undefined)
|
|
195
206
|
return errorResult(gated);
|
|
196
207
|
const encodedEdit = encodeTextForFile(working, decoded.encoding, decoded.endings);
|
|
197
|
-
const write = await env
|
|
208
|
+
const write = await envFinalWrite(env, r.key, encodedEdit, ctx.signal);
|
|
198
209
|
if (!write.ok)
|
|
199
210
|
return errorResult(`Error (Edit): cannot write "${path}": ${write.error.message}`);
|
|
200
211
|
const persistedEdit = persistedTextOf(encodedEdit);
|
|
@@ -265,7 +276,7 @@ export function createWriteFileTool(env, state, rootCanonical, cwdRef, additiona
|
|
|
265
276
|
if (gated !== undefined)
|
|
266
277
|
return errorResult(gated);
|
|
267
278
|
const encodedWrite = encodeTextForFile(content, decodedPrev.encoding, "preserve");
|
|
268
|
-
const write = await env
|
|
279
|
+
const write = await envFinalWrite(env, r.key, encodedWrite, ctx.signal);
|
|
269
280
|
if (!write.ok)
|
|
270
281
|
return errorResult(`Error (Write): cannot write "${path}": ${write.error.message}`);
|
|
271
282
|
const persistedWrite = persistedTextOf(encodedWrite);
|
|
@@ -278,7 +289,7 @@ export function createWriteFileTool(env, state, rootCanonical, cwdRef, additiona
|
|
|
278
289
|
const gatedCreate = await gateToolWrite(beforeWrite, "Write", path, r.key, content);
|
|
279
290
|
if (gatedCreate !== undefined)
|
|
280
291
|
return errorResult(gatedCreate);
|
|
281
|
-
const write = await env
|
|
292
|
+
const write = await envFinalWrite(env, r.key, content, ctx.signal);
|
|
282
293
|
if (!write.ok)
|
|
283
294
|
return errorResult(`Error (Write): cannot write "${path}": ${write.error.message}`);
|
|
284
295
|
const totalLines = countLines(content);
|
|
@@ -409,7 +420,7 @@ export function createNotebookEditTool(env, state, rootCanonical, cwdRef, additi
|
|
|
409
420
|
const gated = await gateToolWrite(beforeWrite, "NotebookEdit", notebook_path, r.key, updated);
|
|
410
421
|
if (gated !== undefined)
|
|
411
422
|
return errorResult(gated);
|
|
412
|
-
const w = await env
|
|
423
|
+
const w = await envFinalWrite(env, r.key, encodeTextForFile(updated, decodedNb.encoding, decodedNb.endings), ctx.signal);
|
|
413
424
|
if (!w.ok)
|
|
414
425
|
return errorResult(`Error (NotebookEdit): cannot write "${notebook_path}": ${w.error.message}`);
|
|
415
426
|
state.set(r.key, { hash: sha256(updated), totalLines: countLines(updated), truncated: false, lastReadAt: Date.now() });
|
package/dist/tools/fs/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./fs-search-tools.js";
|
|
|
11
11
|
export * from "./bash-readonly-classifier.js";
|
|
12
12
|
export * from "./fs-bash.js";
|
|
13
13
|
export * from "./read-deny.js";
|
|
14
|
+
export { BASH_CLASSIFY_DEFAULT_ALLOW } from "./bash-readonly-classifier.js";
|
|
14
15
|
import { type ReadDenyEntry } from "./read-deny.js";
|
|
15
16
|
export * from "./read-face.js";
|
|
16
17
|
import { type CwdRef, type ReadImageDownsamplerOption } from "./fs-shared.js";
|
package/dist/tools/fs/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export * from "./bash-readonly-classifier.js";
|
|
|
12
12
|
export * from "./fs-bash.js";
|
|
13
13
|
export * from "./read-deny.js";
|
|
14
14
|
import { BASH_READONLY_DEFAULT_ALLOW, } from "./bash-readonly-classifier.js";
|
|
15
|
+
export { BASH_CLASSIFY_DEFAULT_ALLOW } from "./bash-readonly-classifier.js";
|
|
15
16
|
import { compileReadDeny } from "./read-deny.js";
|
|
16
17
|
import { deploymentReadFaceClampNotice, resolveReadFace } from "./read-face.js";
|
|
17
18
|
export * from "./read-face.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_comment": "design/87 L3 — frozen public export surface of src/index.ts (name -> kind). DO NOT edit by hand to silence a red test. A removed/changed entry = a SemVer-BREAKING change; bump MAJOR and update this fixture in the SAME commit (design/87 §4.2 / §5.2). Regenerate via REGEN in test/export-surface.test.ts.",
|
|
3
3
|
"_tierComment": "#435 v1 — machine-readable layering of the public surface: stable = demonstrated by README.md / src/examples; internal = an `Internal`-marked name or a runner/engine deep-subtree declaration (the model seam src/engine/llm is excluded — it is the BYOM contract, not an engine internal); advanced = a supported export the front door does not walk you through. THIS IS AN INITIAL HEURISTIC, derived mechanically and expected to be refined ticket by ticket: no human reviewed these 1700+ entries one by one, and nothing here claims otherwise. Known bias: a short or English-word export name (ok, err, Result, Usage) can match ordinary prose in README.md and land `stable` on a coincidence. Every export MUST carry a tier — a new export with no row fails the gate in export-surface.test.ts.",
|
|
4
|
-
"count":
|
|
4
|
+
"count": 1768,
|
|
5
5
|
"exports": {
|
|
6
6
|
"A2ATaskState": "type",
|
|
7
7
|
"A2ATaskStateReversal": "type",
|
|
@@ -829,6 +829,8 @@
|
|
|
829
829
|
"ResourceLimitReason": "type",
|
|
830
830
|
"Result": "type",
|
|
831
831
|
"ResumeOutcome": "type",
|
|
832
|
+
"ResumePreflightInfo": "interface",
|
|
833
|
+
"ResumePreflightVerdict": "type",
|
|
832
834
|
"ResumeTaskConfig": "type",
|
|
833
835
|
"RetentionDeclaration": "type",
|
|
834
836
|
"RetentionDeclaring": "interface",
|
|
@@ -1192,11 +1194,13 @@
|
|
|
1192
1194
|
"WorktreeSessionRef": "interface",
|
|
1193
1195
|
"WorktreeToolsOptions": "interface",
|
|
1194
1196
|
"WritablePermissionRuleStore": "interface",
|
|
1197
|
+
"WriteExpectation": "interface",
|
|
1195
1198
|
"WriteProtectedEntry": "type",
|
|
1196
1199
|
"WriteProtectedHit": "interface",
|
|
1197
1200
|
"WriteProtectedKind": "type",
|
|
1198
1201
|
"WriteProtectedRow": "interface",
|
|
1199
1202
|
"WriteProtectionMatcher": "interface",
|
|
1203
|
+
"WriteReceipt": "interface",
|
|
1200
1204
|
"ackAdoptionConfig": "function",
|
|
1201
1205
|
"acquireCcLock": "function",
|
|
1202
1206
|
"addDotsOf": "function",
|
|
@@ -2595,6 +2599,8 @@
|
|
|
2595
2599
|
"ResourceLimitReason": "advanced",
|
|
2596
2600
|
"Result": "stable",
|
|
2597
2601
|
"ResumeOutcome": "stable",
|
|
2602
|
+
"ResumePreflightInfo": "advanced",
|
|
2603
|
+
"ResumePreflightVerdict": "advanced",
|
|
2598
2604
|
"ResumeTaskConfig": "stable",
|
|
2599
2605
|
"RetentionDeclaration": "advanced",
|
|
2600
2606
|
"RetentionDeclaring": "advanced",
|
|
@@ -2958,11 +2964,13 @@
|
|
|
2958
2964
|
"WorktreeSessionRef": "advanced",
|
|
2959
2965
|
"WorktreeToolsOptions": "advanced",
|
|
2960
2966
|
"WritablePermissionRuleStore": "advanced",
|
|
2967
|
+
"WriteExpectation": "internal",
|
|
2961
2968
|
"WriteProtectedEntry": "advanced",
|
|
2962
2969
|
"WriteProtectedHit": "advanced",
|
|
2963
2970
|
"WriteProtectedKind": "advanced",
|
|
2964
2971
|
"WriteProtectedRow": "advanced",
|
|
2965
2972
|
"WriteProtectionMatcher": "advanced",
|
|
2973
|
+
"WriteReceipt": "internal",
|
|
2966
2974
|
"ackAdoptionConfig": "advanced",
|
|
2967
2975
|
"acquireCcLock": "advanced",
|
|
2968
2976
|
"addDotsOf": "advanced",
|