@sema-agent/core 7.14.0 → 7.15.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 +30 -0
- package/dist/core/ask-origin.d.ts +2 -2
- package/dist/core/checkpoint-store.d.ts +14 -15
- package/dist/core/hooks.d.ts +4 -3
- package/dist/core/runner/contracts.d.ts +2 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +3 -1
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
- package/dist/core/runner/prepare-defer-classify.js +12 -10
- package/dist/core/runner/prepare-gate-stations.d.ts +3 -4
- package/dist/core/runner/prepare-gate-stations.js +2 -2
- package/dist/core/runner/prepare-hands-readface.d.ts +8 -8
- package/dist/core/runner/prepare-hands-readface.js +27 -29
- package/dist/core/runner/prepare-inherited-gate.d.ts +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +5 -6
- package/dist/core/runner/prepare-park-ask.js +3 -3
- package/dist/core/runner/prepare-policy-chain.d.ts +2 -2
- package/dist/core/runner/prepare-policy-chain.js +2 -2
- package/dist/core/runner/prepare-task.js +5 -7
- package/dist/core/runner/tool-defer-gate.d.ts +86 -0
- package/dist/core/runner/tool-defer-gate.js +57 -0
- package/dist/core/runner/tool-disclosure.d.ts +0 -36
- package/dist/core/runner/tool-disclosure.js +0 -43
- package/dist/core/runner-deps.d.ts +16 -9
- package/dist/core/task-spec.d.ts +8 -2
- package/dist/core/tool-spec.d.ts +7 -4
- package/dist/core/types.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/tools/fs/fs-bash.d.ts +41 -0
- package/dist/tools/fs/fs-bash.js +86 -29
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +5 -1
package/dist/tools/fs/fs-bash.js
CHANGED
|
@@ -25,40 +25,100 @@ function operandFamily(paths) {
|
|
|
25
25
|
export function bashReversibilityProbe(allow, boundary) {
|
|
26
26
|
const allowSet = new Set(allow ?? BASH_CLASSIFY_DEFAULT_ALLOW);
|
|
27
27
|
return (args) => {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
if (typeof command !== "string")
|
|
28
|
+
const command = shellCommandOf(args);
|
|
29
|
+
if (command === undefined)
|
|
31
30
|
return { reversible: false };
|
|
32
31
|
const resolved = typeof boundary === "function" ? boundary() : boundary;
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const backgrounded =
|
|
32
|
+
const boundaryGate = (verdict) => readBoundaryMandate(command, allowSet, resolved, verdict);
|
|
33
|
+
const outOfRootGate = () => readBoundaryMandate(command, allowSet, resolved, {});
|
|
34
|
+
const backgrounded = isBackgroundShellCall(args);
|
|
36
35
|
const detailed = classifyCompoundReadonlyDetailed(command, allowSet, resolved);
|
|
37
36
|
if (backgrounded)
|
|
38
37
|
return { reversible: false, ...boundaryGate(detailed) };
|
|
39
38
|
if (detailed.reason === undefined) {
|
|
40
39
|
if (detailed.undecidedPaths !== undefined && detailed.undecidedPaths.length > 0) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
const others = detailed.undecidedPaths.filter((p) => !recursiveSet.has(p));
|
|
45
|
-
return {
|
|
46
|
-
reversible: false,
|
|
47
|
-
...boundaryGate(detailed),
|
|
48
|
-
cause: {
|
|
49
|
-
code: RECURSIVE_READ_CAUSE_CODE,
|
|
50
|
-
roots: operandFamily(recursive),
|
|
51
|
-
...(others.length > 0 ? { further: operandFamily(others) } : {}),
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
40
|
+
const cause = recursiveReadCause(detailed);
|
|
41
|
+
if (cause !== undefined)
|
|
42
|
+
return { reversible: false, ...boundaryGate(detailed), cause };
|
|
55
43
|
return { reversible: false, ...outOfRootGate() };
|
|
56
44
|
}
|
|
57
45
|
return { reversible: true };
|
|
58
46
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
const loopRefusal = classifyBoundedReadonlyPollLoop(command, allowSet, resolved);
|
|
48
|
+
if (loopRefusal === undefined)
|
|
49
|
+
return { reversible: true };
|
|
50
|
+
return { reversible: false, ...(pollLoopBoundaryVerdict(command, allowSet, resolved, loopRefusal) === "declared" ? { mandated: true } : boundaryGate(detailed)) };
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function attributeRefusal(face, resolved, fullRefusal) {
|
|
54
|
+
if (resolved === undefined)
|
|
55
|
+
return "shape";
|
|
56
|
+
const { denyMatch: _deny, ...withoutDenyJudge } = resolved;
|
|
57
|
+
const opened = face({ ...withoutDenyJudge, face: "open" });
|
|
58
|
+
if (opened === undefined || opened !== fullRefusal)
|
|
59
|
+
return "declared";
|
|
60
|
+
return face(undefined) === opened ? "shape" : "unread";
|
|
61
|
+
}
|
|
62
|
+
function pollLoopBoundaryVerdict(command, allowSet, resolved, fullRefusal) {
|
|
63
|
+
return attributeRefusal((b) => classifyBoundedReadonlyPollLoop(command, allowSet, b), resolved, fullRefusal);
|
|
64
|
+
}
|
|
65
|
+
function boundaryDeclared(verdict) {
|
|
66
|
+
return denyJudgeSpoke(verdict) || verdict.outOfRootRead === true;
|
|
67
|
+
}
|
|
68
|
+
function denyJudgeSpoke(verdict) {
|
|
69
|
+
return verdict.readDenied === true || (verdict.recursiveReadPaths !== undefined && verdict.recursiveReadPaths.length > 0);
|
|
70
|
+
}
|
|
71
|
+
function shellCommandOf(args) {
|
|
72
|
+
const command = args?.command;
|
|
73
|
+
return typeof command === "string" ? command : undefined;
|
|
74
|
+
}
|
|
75
|
+
function isBackgroundShellCall(args) {
|
|
76
|
+
return args?.run_in_background === true;
|
|
77
|
+
}
|
|
78
|
+
function readBoundaryMandate(command, allowSet, resolved, verdict) {
|
|
79
|
+
if (denyJudgeSpoke(verdict))
|
|
80
|
+
return { mandated: true };
|
|
81
|
+
return resolved !== undefined && classifyOutOfRootReadGate(command, allowSet, resolved).gated ? { mandated: true } : {};
|
|
82
|
+
}
|
|
83
|
+
function recursiveReadCause(detailed) {
|
|
84
|
+
const recursive = detailed.recursiveReadPaths;
|
|
85
|
+
if (recursive === undefined || recursive.length === 0)
|
|
86
|
+
return undefined;
|
|
87
|
+
const recursiveSet = new Set(recursive);
|
|
88
|
+
const others = (detailed.undecidedPaths ?? []).filter((p) => !recursiveSet.has(p));
|
|
89
|
+
return {
|
|
90
|
+
code: RECURSIVE_READ_CAUSE_CODE,
|
|
91
|
+
roots: operandFamily(recursive),
|
|
92
|
+
...(others.length > 0 ? { further: operandFamily(others) } : {}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function bashReadBoundaryProbe(boundary) {
|
|
96
|
+
const allowSet = new Set(BASH_CLASSIFY_DEFAULT_ALLOW);
|
|
97
|
+
return (args) => {
|
|
98
|
+
const command = shellCommandOf(args);
|
|
99
|
+
if (command === undefined)
|
|
100
|
+
return { reversible: false };
|
|
101
|
+
const resolved = typeof boundary === "function" ? boundary() : boundary;
|
|
102
|
+
if (resolved === undefined)
|
|
103
|
+
return { reversible: true };
|
|
104
|
+
const detailed = classifyCompoundReadonlyDetailed(command, allowSet, resolved);
|
|
105
|
+
if (boundaryDeclared(detailed)) {
|
|
106
|
+
const cause = recursiveReadCause(detailed);
|
|
107
|
+
return { reversible: false, mandated: true, ...(cause !== undefined ? { cause } : {}) };
|
|
108
|
+
}
|
|
109
|
+
if (detailed.reason === undefined) {
|
|
110
|
+
return detailed.undecidedPaths !== undefined && detailed.undecidedPaths.length > 0 ? { reversible: false } : { reversible: true };
|
|
111
|
+
}
|
|
112
|
+
const compound = attributeRefusal((b) => classifyCompoundReadonlyDetailed(command, allowSet, b).reason, resolved, detailed.reason);
|
|
113
|
+
if (compound === "declared")
|
|
114
|
+
return { reversible: false, mandated: true };
|
|
115
|
+
if (compound === "unread")
|
|
116
|
+
return { reversible: false };
|
|
117
|
+
const loopRefusal = classifyBoundedReadonlyPollLoop(command, allowSet, resolved);
|
|
118
|
+
if (loopRefusal === undefined)
|
|
119
|
+
return { reversible: true };
|
|
120
|
+
const loop = pollLoopBoundaryVerdict(command, allowSet, resolved, loopRefusal);
|
|
121
|
+
return loop === "shape" ? { reversible: true } : loop === "declared" ? { reversible: false, mandated: true } : { reversible: false };
|
|
62
122
|
};
|
|
63
123
|
}
|
|
64
124
|
export { FULL_SHELL_CONTRACT_ID } from "../../core/tool-catalog-entries.js";
|
|
@@ -563,13 +623,10 @@ export function createBashTool(env, rootCanonical, coAuthor = false, cwdRef = {
|
|
|
563
623
|
})),
|
|
564
624
|
}),
|
|
565
625
|
isConcurrencySafe: (args) => {
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
568
|
-
return false;
|
|
569
|
-
const bg = args.run_in_background;
|
|
570
|
-
if (bg === true)
|
|
626
|
+
const command = shellCommandOf(args);
|
|
627
|
+
if (command === undefined || isBackgroundShellCall(args))
|
|
571
628
|
return false;
|
|
572
|
-
return coarseReadonlyCheck(
|
|
629
|
+
return coarseReadonlyCheck(command, new Set(BASH_READONLY_DEFAULT_ALLOW)) === undefined;
|
|
573
630
|
},
|
|
574
631
|
execute: async (args, ctx) => {
|
|
575
632
|
const { command, timeout, run_in_background, description } = args;
|
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": 2293,
|
|
5
5
|
"exports": {
|
|
6
6
|
"A2ATaskState": "type",
|
|
7
7
|
"A2ATaskStateReversal": "type",
|
|
@@ -1256,6 +1256,7 @@
|
|
|
1256
1256
|
"SharedMemoryStoreProvider": "interface",
|
|
1257
1257
|
"SharedMemoryStoreReader": "interface",
|
|
1258
1258
|
"ShellCommandShape": "interface",
|
|
1259
|
+
"ShellGateDoctrine": "type",
|
|
1259
1260
|
"ShellRedirection": "interface",
|
|
1260
1261
|
"ShellSegment": "interface",
|
|
1261
1262
|
"ShellWord": "interface",
|
|
@@ -1578,6 +1579,7 @@
|
|
|
1578
1579
|
"autoModeArmingRecipeOf": "function",
|
|
1579
1580
|
"backgroundAgentStoreContract": "function",
|
|
1580
1581
|
"backgroundAgentStoreScopesContract": "function",
|
|
1582
|
+
"bashReadBoundaryProbe": "function",
|
|
1581
1583
|
"bashReversibilityProbe": "function",
|
|
1582
1584
|
"boundaryPublishVerdict": "function",
|
|
1583
1585
|
"boundedRedactedSummary": "function",
|
|
@@ -3549,6 +3551,7 @@
|
|
|
3549
3551
|
"SharedMemoryStoreProvider": "advanced",
|
|
3550
3552
|
"SharedMemoryStoreReader": "advanced",
|
|
3551
3553
|
"ShellCommandShape": "advanced",
|
|
3554
|
+
"ShellGateDoctrine": "advanced",
|
|
3552
3555
|
"ShellRedirection": "advanced",
|
|
3553
3556
|
"ShellSegment": "advanced",
|
|
3554
3557
|
"ShellWord": "advanced",
|
|
@@ -3871,6 +3874,7 @@
|
|
|
3871
3874
|
"autoModeArmingRecipeOf": "advanced",
|
|
3872
3875
|
"backgroundAgentStoreContract": "advanced",
|
|
3873
3876
|
"backgroundAgentStoreScopesContract": "advanced",
|
|
3877
|
+
"bashReadBoundaryProbe": "advanced",
|
|
3874
3878
|
"bashReversibilityProbe": "advanced",
|
|
3875
3879
|
"boundaryPublishVerdict": "advanced",
|
|
3876
3880
|
"boundedRedactedSummary": "advanced",
|