@sema-agent/core 7.45.0 → 7.46.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.
Files changed (127) hide show
  1. package/CHANGELOG.md +246 -1
  2. package/dist/agents/extra-tool-names.d.ts +65 -0
  3. package/dist/agents/extra-tool-names.js +124 -0
  4. package/dist/agents/subagent.d.ts +17 -5
  5. package/dist/agents/subagent.js +33 -25
  6. package/dist/agents/tool-filter.d.ts +17 -1
  7. package/dist/agents/tool-filter.js +7 -0
  8. package/dist/core/agent-config-dir.d.ts +20 -0
  9. package/dist/core/agent-config-dir.js +49 -0
  10. package/dist/core/allow-entry.d.ts +5 -3
  11. package/dist/core/allow-entry.js +3 -1
  12. package/dist/core/ask-origin.js +1 -1
  13. package/dist/core/checkpoint-store.d.ts +39 -2
  14. package/dist/core/effective-path-target.d.ts +136 -4
  15. package/dist/core/effective-path-target.js +110 -2
  16. package/dist/core/engine-notice.d.ts +5 -0
  17. package/dist/core/gate-fold.js +3 -0
  18. package/dist/core/gate-lanes.js +9 -3
  19. package/dist/core/governance-codes.d.ts +3 -1
  20. package/dist/core/governance-codes.js +3 -0
  21. package/dist/core/hooks.d.ts +3 -0
  22. package/dist/core/path-rule-binding.d.ts +65 -0
  23. package/dist/core/path-rule-binding.js +99 -0
  24. package/dist/core/permission-rule-model.d.ts +47 -18
  25. package/dist/core/permission-rule-model.js +38 -42
  26. package/dist/core/permission-rule-provider.d.ts +7 -0
  27. package/dist/core/permission-rule-provider.js +10 -3
  28. package/dist/core/permission-rule-store.d.ts +8 -0
  29. package/dist/core/permission-rule-store.js +6 -2
  30. package/dist/core/permission-rule-sync.js +2 -2
  31. package/dist/core/permission-rules.d.ts +22 -40
  32. package/dist/core/permission-rules.js +50 -43
  33. package/dist/core/runner/child-tree.d.ts +97 -0
  34. package/dist/core/runner/child-tree.js +104 -0
  35. package/dist/core/runner/construction-doors.d.ts +5 -0
  36. package/dist/core/runner/construction-doors.js +6 -0
  37. package/dist/core/runner/contracts.d.ts +46 -0
  38. package/dist/core/runner/permission-rule-lanes.d.ts +34 -25
  39. package/dist/core/runner/permission-rule-lanes.js +18 -12
  40. package/dist/core/runner/persisted-path-rows.d.ts +31 -7
  41. package/dist/core/runner/persisted-path-rows.js +31 -12
  42. package/dist/core/runner/prepare-ask-lane.d.ts +4 -0
  43. package/dist/core/runner/prepare-ask-lane.js +4 -2
  44. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  45. package/dist/core/runner/prepare-execution-env.js +10 -3
  46. package/dist/core/runner/prepare-gate-stations.d.ts +3 -0
  47. package/dist/core/runner/prepare-gate-stations.js +2 -1
  48. package/dist/core/runner/prepare-hands-readface.d.ts +8 -4
  49. package/dist/core/runner/prepare-hands-readface.js +6 -6
  50. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -1
  51. package/dist/core/runner/prepare-inherited-gate.js +8 -2
  52. package/dist/core/runner/prepare-park-ask.d.ts +3 -0
  53. package/dist/core/runner/prepare-park-ask.js +5 -3
  54. package/dist/core/runner/prepare-policy-chain.d.ts +14 -2
  55. package/dist/core/runner/prepare-policy-chain.js +11 -4
  56. package/dist/core/runner/prepare-suspend-saga.d.ts +10 -0
  57. package/dist/core/runner/prepare-suspend-saga.js +7 -1
  58. package/dist/core/runner/prepare-task.js +37 -18
  59. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  60. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  61. package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
  62. package/dist/core/runner/prepare-workspace-restore.js +1 -0
  63. package/dist/core/runner/resume-apply.js +17 -3
  64. package/dist/core/runner/resume-checkpoint-screen.js +13 -0
  65. package/dist/core/runner/run-leg.js +5 -1
  66. package/dist/core/runner/runtask.js +2 -2
  67. package/dist/core/runner/sub-agent-deny-lists.d.ts +1 -1
  68. package/dist/core/runner/write-protection-station.d.ts +3 -2
  69. package/dist/core/runner/write-protection-station.js +1 -0
  70. package/dist/core/runner-deps.d.ts +14 -0
  71. package/dist/core/sensitive-path-policy.d.ts +8 -0
  72. package/dist/core/sensitive-path-policy.js +18 -2
  73. package/dist/core/shell-wrapper-projection.d.ts +11 -0
  74. package/dist/core/shell-wrapper-projection.js +56 -0
  75. package/dist/core/shell-wrapper-table.d.ts +144 -34
  76. package/dist/core/shell-wrapper-table.js +40 -20
  77. package/dist/core/synthetic-read-verdict.d.ts +3 -0
  78. package/dist/core/synthetic-read-verdict.js +3 -1
  79. package/dist/core/tool-catalog-entries.d.ts +21 -0
  80. package/dist/core/tool-catalog-entries.js +9 -0
  81. package/dist/core/tool-policy.d.ts +30 -8
  82. package/dist/core/tool-policy.js +9 -7
  83. package/dist/core/tool-spec.d.ts +3 -2
  84. package/dist/core/write-protect.d.ts +4 -0
  85. package/dist/core/write-protect.js +30 -9
  86. package/dist/index.d.ts +5 -3
  87. package/dist/index.js +4 -2
  88. package/dist/orchestration/run-spec.js +8 -7
  89. package/dist/orchestration/workflow.js +1 -1
  90. package/dist/shell/lex.d.ts +7 -0
  91. package/dist/shell/lex.js +17 -0
  92. package/dist/tools/fs/bash-program-position.d.ts +8 -87
  93. package/dist/tools/fs/bash-program-position.js +33 -69
  94. package/dist/tools/fs/bash-readonly-classifier.d.ts +17 -444
  95. package/dist/tools/fs/bash-readonly-classifier.js +169 -1225
  96. package/dist/tools/fs/index.d.ts +3 -2
  97. package/dist/tools/fs/program-read-model.d.ts +694 -0
  98. package/dist/tools/fs/program-read-model.js +1252 -0
  99. package/dist/tools/fs/program-read-model.rows.d.ts +18 -0
  100. package/dist/tools/fs/program-read-model.rows.js +613 -0
  101. package/dist/tools/fs/read-deny-home.d.ts +19 -1
  102. package/dist/tools/fs/read-deny-home.js +62 -24
  103. package/dist/tools/fs/read-deny.d.ts +54 -14
  104. package/dist/tools/fs/read-deny.js +104 -50
  105. package/dist/tools/fs/removal-targets.d.ts +7 -6
  106. package/dist/tools/fs/removal-targets.js +22 -22
  107. package/dist/tools/fs/safety.d.ts +3 -0
  108. package/dist/tools/fs/safety.js +10 -3
  109. package/dist/tools/fs/shell-read-argv.d.ts +85 -0
  110. package/dist/tools/fs/shell-read-argv.js +386 -0
  111. package/dist/tools/fs/shell-read-bindings.d.ts +273 -0
  112. package/dist/tools/fs/shell-read-bindings.js +746 -0
  113. package/dist/tools/fs/shell-read-check.js +23 -15
  114. package/dist/tools/fs/shell-read-establish.js +79 -5
  115. package/dist/tools/fs/shell-read-judge.d.ts +11 -1
  116. package/dist/tools/fs/shell-read-judge.js +9 -1
  117. package/dist/tools/fs/shell-read-plan.d.ts +31 -7
  118. package/dist/tools/fs/shell-read-plan.js +299 -393
  119. package/dist/tools/fs/shell-read-word.d.ts +29 -26
  120. package/dist/tools/fs/shell-read-word.js +30 -38
  121. package/dist/tools/fs/shell-read-write-targets.d.ts +15 -64
  122. package/dist/tools/fs/shell-read-write-targets.js +83 -136
  123. package/dist/tools/fs/shell-reentry-text.d.ts +38 -6
  124. package/dist/tools/fs/shell-reentry-text.js +90 -53
  125. package/package.json +1 -1
  126. package/test/export-surface.snapshot.json +17 -3
  127. package/wire-changes/core@7.46.0.json +1522 -0
@@ -1,25 +1,19 @@
1
- const CODE_BODY_OPERANDS = new Map([
2
- ["trap", trapAction],
3
- ["alias", aliasValues],
4
- ["mapfile", callbacksOf(new Set(["d", "u", "n", "O", "C", "c", "s"]))],
5
- ["readarray", callbacksOf(new Set(["d", "u", "n", "O", "C", "c", "s"]))],
6
- ["compgen", callbacksOf(new Set(["o", "A", "G", "W", "P", "S", "X", "F", "C", "V"]))],
7
- ]);
1
+ import { literalHeredocBody, literalTextOf } from "../../shell/lex.js";
2
+ import { readProgramPosition } from "./bash-program-position.js";
3
+ import { printedText, programRow, readArgRoles, selectedOptions } from "./program-read-model.js";
4
+ import { namesStandardInput } from "./safety.js";
8
5
  export function codeBodies(basename, args) {
9
- return CODE_BODY_OPERANDS.get(basename)?.(args) ?? [];
10
- }
11
- function trapAction(args) {
12
- let k = 0;
13
- for (; k < args.length; k++) {
14
- const a = args[k];
15
- if (a === "--") {
16
- k++;
17
- break;
18
- }
19
- if (!a.startsWith("-") || a === "-")
20
- break;
6
+ const row = programRow(basename);
7
+ switch (row?.body) {
8
+ case "first-operand": return firstOperandBody(row, args);
9
+ case "assignment-values": return aliasValues(args);
10
+ case "option-values": return shellTextOptionValues(row, args);
11
+ case undefined: return [];
21
12
  }
22
- const action = args[k];
13
+ }
14
+ function firstOperandBody(row, args) {
15
+ const first = readArgRoles(row, args).find((e) => e.kind === "operand");
16
+ const action = first === undefined ? undefined : args[first.at];
23
17
  return action === undefined || action === "" || action === "-" ? [] : [action];
24
18
  }
25
19
  function aliasValues(args) {
@@ -31,43 +25,86 @@ function aliasValues(args) {
31
25
  }
32
26
  return values;
33
27
  }
34
- function callbacksOf(valueLetters) {
35
- return (args) => {
36
- const callbacks = [];
37
- for (let k = 0; k < args.length; k++) {
38
- const a = args[k];
39
- if (a === "--" || !a.startsWith("-") || a === "-")
40
- break;
41
- for (let i = 1; i < a.length; i++) {
42
- if (!valueLetters.has(a[i]))
43
- continue;
44
- const value = i + 1 < a.length ? a.slice(i + 1) : args[++k];
45
- if (a[i] === "C" && value !== undefined)
46
- callbacks.push(value);
47
- break;
48
- }
49
- }
50
- return callbacks;
51
- };
28
+ function shellTextOptionValues(row, args) {
29
+ const callbacks = [];
30
+ for (const e of optionSection(readArgRoles(row, args))) {
31
+ const text = shellTextOf(e, args);
32
+ if (text !== undefined)
33
+ callbacks.push(text);
34
+ }
35
+ return callbacks;
52
36
  }
53
- export function reentryText(basename, args) {
54
- if (basename === "eval")
37
+ function optionSection(events) {
38
+ const end = events.findIndex((e) => e.kind === "operand" || e.kind === "dash-word-operand" || e.kind === "end-of-options");
39
+ return end === -1 ? [...events] : events.slice(0, end);
40
+ }
41
+ function shellTextOf(e, args) {
42
+ if (e.kind === "value" && e.role?.kind === "shell-text")
43
+ return args[e.at];
44
+ if (e.kind === "option" && typeof e.reading === "object" && e.reading.role?.kind === "shell-text")
45
+ return e.reading.attached;
46
+ return undefined;
47
+ }
48
+ export function reentryText(basename, args, stdin) {
49
+ const row = programRow(basename);
50
+ const r = row?.reentry;
51
+ if (row === undefined || r?.kind !== "shell")
52
+ return undefined;
53
+ const text = argvText(row, r.text, args);
54
+ if (text !== undefined || stdin === undefined)
55
+ return text;
56
+ const source = scriptSourceOf(row, args);
57
+ return (r.stdin === "script" && source.stdin) || (source.file !== undefined && namesStandardInput(args[source.file])) ? stdin : undefined;
58
+ }
59
+ function argvText(row, at, args) {
60
+ if (at === "words")
55
61
  return args.length === 0 ? undefined : args.join(" ");
56
- if (basename === "parallel")
62
+ if (at === "non-option-words")
57
63
  return args.filter((a) => !a.startsWith("-")).join(" ") || undefined;
58
- if (basename === "source" || basename === ".")
64
+ if (at === "file-operand")
59
65
  return undefined;
60
- for (let k = 0; k < args.length; k++) {
61
- const a = args[k];
62
- if (a === "--")
63
- return undefined;
64
- if (!a.startsWith("-") || a === "-")
65
- return undefined;
66
- const c = a.indexOf("c");
67
- if (a.startsWith("--"))
68
- continue;
69
- if (c > 0)
70
- return a.length > c + 1 ? a.slice(c + 1) : args[k + 1];
66
+ for (const e of optionSection(readArgRoles(row, args))) {
67
+ const text = shellTextOf(e, args);
68
+ if (text !== undefined)
69
+ return text;
71
70
  }
72
71
  return undefined;
73
72
  }
73
+ export function scriptFileAt(basename, args) {
74
+ const row = programRow(basename);
75
+ return row?.reentry?.kind === "shell" && argvText(row, row.reentry.text, args) === undefined ? scriptSourceOf(row, args).file : undefined;
76
+ }
77
+ function scriptSourceOf(row, args) {
78
+ const events = readArgRoles(row, args);
79
+ const options = optionSection(events);
80
+ const end = events[options.length]?.at ?? args.length;
81
+ if (selectedOptions(row, args.slice(0, end), "one-implementation").some((o) => o.mode === "interactive"))
82
+ return { stdin: true };
83
+ const first = events.find((e) => e.kind === "operand");
84
+ if (first?.kind !== "operand" || first.dash !== undefined)
85
+ return { stdin: true };
86
+ return { file: first.at, stdin: options.some((e) => e.kind === "option" && e.reading === "speculative") };
87
+ }
88
+ export function stdinTextsOf(segment, piped) {
89
+ const out = [];
90
+ let replacesPipe = false;
91
+ for (const t of segment.tokens) {
92
+ if (t.kind === "heredoc") {
93
+ const literal = t.quoted ? t.body : literalHeredocBody(t.body);
94
+ out.push(literal === undefined ? { from: t.body } : { from: t.body, literal });
95
+ }
96
+ else if (t.kind === "redirect" && (t.fd ?? 0) === 0 && (t.op === "<<<" || t.op === "<" || (t.op === "<&" && t.dup !== "-"))) {
97
+ const literal = t.op === "<<<" && t.target !== undefined ? literalTextOf(t.target.pieces) : undefined;
98
+ out.push({ from: `${t.op}${t.target?.raw ?? t.dup ?? ""}`, ...(literal !== undefined ? { literal } : {}) });
99
+ replacesPipe = true;
100
+ }
101
+ }
102
+ return piped === undefined || replacesPipe ? out : [piped, ...out];
103
+ }
104
+ export function pipedTextOf(segment, argv) {
105
+ const from = `${segment.text.trim()} |`;
106
+ const pos = readProgramPosition(argv);
107
+ const program = pos.program;
108
+ const literal = program === undefined || pos.refusal !== undefined || literalTextOf(argv[program.index].pieces) === undefined ? undefined : printedText(programRow(program.basename), argv.slice(program.index + 1).map((w) => literalTextOf(w.pieces)));
109
+ return literal === undefined ? { from } : { from, literal };
110
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/core",
3
- "version": "7.45.0",
3
+ "version": "7.46.0",
4
4
  "description": "Stateless, task-oriented AI agent core",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
@@ -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": 2617,
4
+ "count": 2624,
5
5
  "exports": {
6
6
  "A2ATaskState": "type",
7
7
  "A2ATaskStateReversal": "type",
@@ -212,6 +212,7 @@
212
212
  "BeforeWriteHook": "type",
213
213
  "BeforeWriteRequest": "interface",
214
214
  "BeforeWriteResult": "type",
215
+ "BoundPathRule": "interface",
215
216
  "BoundSkillGrants": "interface",
216
217
  "Brain": "interface",
217
218
  "BrainError": "class",
@@ -265,6 +266,8 @@
265
266
  "CacheBreakFinding": "interface",
266
267
  "CacheFamily": "type",
267
268
  "CacheIdentityElements": "interface",
269
+ "CallTargetReading": "interface",
270
+ "CallTargetView": "type",
268
271
  "CascadeAttempt": "interface",
269
272
  "CascadeConfig": "interface",
270
273
  "CascadeRunResult": "interface",
@@ -443,6 +446,7 @@
443
446
  "EMPTY_DURABLE_RULE_PARTITION": "variable",
444
447
  "EMPTY_USAGE_WINDOW_RECORD": "variable",
445
448
  "ENGINE_AUTHORITY_ENVELOPE_TAGS": "variable",
449
+ "ENGINE_BUILTIN_TOOL_NAMES": "variable",
446
450
  "ENGINE_NOTICE_CODES": "variable",
447
451
  "ENTER_PLAN_MODE_TOOL_NAME": "variable",
448
452
  "ENV_LIFETIME_SUSPEND_MARGIN_MS": "variable",
@@ -988,6 +992,7 @@
988
992
  "PathRuleBase": "type",
989
993
  "PathRuleBases": "type",
990
994
  "PathRuleDenyRow": "interface",
995
+ "PathRuleSpec": "interface",
991
996
  "PathTargetReading": "type",
992
997
  "PausedCause": "type",
993
998
  "PeerAdmission": "interface",
@@ -2158,6 +2163,7 @@
2158
2163
  "isDeclaredWrite": "function",
2159
2164
  "isDelegatedAgentTerminal": "function",
2160
2165
  "isDeniedBy": "function",
2166
+ "isEngineBuiltinToolName": "function",
2161
2167
  "isEngineRefusal": "variable",
2162
2168
  "isFreshPeerRow": "function",
2163
2169
  "isFullyReadable": "function",
@@ -2418,6 +2424,7 @@
2418
2424
  "renderCrossSessionIdleNotice": "function",
2419
2425
  "renderCrossSessionMessageFrame": "function",
2420
2426
  "renderCrossSessionNoticeLine": "function",
2427
+ "renderListEntry": "function",
2421
2428
  "renderNamedWorkflowListing": "function",
2422
2429
  "renderTaskNotificationXml": "function",
2423
2430
  "renderUntrustedCommandText": "function",
@@ -2577,7 +2584,7 @@
2577
2584
  "toolFaceProblem": "function",
2578
2585
  "toolIdentityOf": "function",
2579
2586
  "toolPolicyNameSets": "function",
2580
- "toolPolicyPathDenyRules": "function",
2587
+ "toolPolicyPathRules": "function",
2581
2588
  "toolResultContentSegment": "function",
2582
2589
  "toolResultProvenanceOf": "function",
2583
2590
  "toolResultStoreContract": "function",
@@ -2831,6 +2838,7 @@
2831
2838
  "BeforeWriteHook": "stable",
2832
2839
  "BeforeWriteRequest": "advanced",
2833
2840
  "BeforeWriteResult": "advanced",
2841
+ "BoundPathRule": "advanced",
2834
2842
  "BoundSkillGrants": "advanced",
2835
2843
  "Brain": "stable",
2836
2844
  "BrainError": "advanced",
@@ -2884,6 +2892,8 @@
2884
2892
  "CacheBreakFinding": "advanced",
2885
2893
  "CacheFamily": "internal",
2886
2894
  "CacheIdentityElements": "advanced",
2895
+ "CallTargetReading": "advanced",
2896
+ "CallTargetView": "advanced",
2887
2897
  "CascadeAttempt": "advanced",
2888
2898
  "CascadeConfig": "advanced",
2889
2899
  "CascadeRunResult": "advanced",
@@ -3062,6 +3072,7 @@
3062
3072
  "EMPTY_DURABLE_RULE_PARTITION": "advanced",
3063
3073
  "EMPTY_USAGE_WINDOW_RECORD": "advanced",
3064
3074
  "ENGINE_AUTHORITY_ENVELOPE_TAGS": "advanced",
3075
+ "ENGINE_BUILTIN_TOOL_NAMES": "advanced",
3065
3076
  "ENGINE_NOTICE_CODES": "advanced",
3066
3077
  "ENTER_PLAN_MODE_TOOL_NAME": "advanced",
3067
3078
  "ENV_LIFETIME_SUSPEND_MARGIN_MS": "internal",
@@ -3607,6 +3618,7 @@
3607
3618
  "PathRuleBase": "advanced",
3608
3619
  "PathRuleBases": "advanced",
3609
3620
  "PathRuleDenyRow": "advanced",
3621
+ "PathRuleSpec": "advanced",
3610
3622
  "PathTargetReading": "advanced",
3611
3623
  "PausedCause": "advanced",
3612
3624
  "PeerAdmission": "advanced",
@@ -4777,6 +4789,7 @@
4777
4789
  "isDeclaredWrite": "advanced",
4778
4790
  "isDelegatedAgentTerminal": "advanced",
4779
4791
  "isDeniedBy": "advanced",
4792
+ "isEngineBuiltinToolName": "advanced",
4780
4793
  "isEngineRefusal": "advanced",
4781
4794
  "isFreshPeerRow": "advanced",
4782
4795
  "isFullyReadable": "advanced",
@@ -5037,6 +5050,7 @@
5037
5050
  "renderCrossSessionIdleNotice": "advanced",
5038
5051
  "renderCrossSessionMessageFrame": "advanced",
5039
5052
  "renderCrossSessionNoticeLine": "advanced",
5053
+ "renderListEntry": "advanced",
5040
5054
  "renderNamedWorkflowListing": "advanced",
5041
5055
  "renderTaskNotificationXml": "advanced",
5042
5056
  "renderUntrustedCommandText": "advanced",
@@ -5196,7 +5210,7 @@
5196
5210
  "toolFaceProblem": "internal",
5197
5211
  "toolIdentityOf": "advanced",
5198
5212
  "toolPolicyNameSets": "advanced",
5199
- "toolPolicyPathDenyRules": "advanced",
5213
+ "toolPolicyPathRules": "advanced",
5200
5214
  "toolResultContentSegment": "advanced",
5201
5215
  "toolResultProvenanceOf": "advanced",
5202
5216
  "toolResultStoreContract": "advanced",