@sema-agent/core 7.29.0 → 7.30.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 (149) hide show
  1. package/CHANGELOG.md +361 -0
  2. package/dist/agents/child-model-seat.d.ts +59 -7
  3. package/dist/agents/child-model-seat.js +33 -7
  4. package/dist/agents/cross-session-judge.d.ts +27 -5
  5. package/dist/agents/cross-session-judge.js +23 -12
  6. package/dist/agents/list-agents-tool.d.ts +31 -6
  7. package/dist/agents/list-agents-tool.js +66 -14
  8. package/dist/agents/peer-admission.d.ts +20 -8
  9. package/dist/agents/peer-admission.js +21 -12
  10. package/dist/agents/peer-directory.d.ts +29 -0
  11. package/dist/agents/peer-directory.js +20 -0
  12. package/dist/agents/peer-held-queue.d.ts +31 -4
  13. package/dist/agents/peer-held-queue.js +32 -1
  14. package/dist/agents/peer-session-drain.d.ts +91 -13
  15. package/dist/agents/peer-session-drain.js +409 -102
  16. package/dist/agents/read-inbox-tool.d.ts +22 -0
  17. package/dist/agents/read-inbox-tool.js +39 -0
  18. package/dist/agents/roster-store.d.ts +2 -4
  19. package/dist/agents/roster-store.js +1 -1
  20. package/dist/agents/send-message-tool.d.ts +4 -4
  21. package/dist/agents/send-message-tool.js +22 -2
  22. package/dist/agents/subagent.js +62 -44
  23. package/dist/agents/team-role.d.ts +34 -0
  24. package/dist/agents/team-role.js +17 -0
  25. package/dist/agents/verify.js +2 -2
  26. package/dist/core/auto-compaction.d.ts +42 -0
  27. package/dist/core/auto-compaction.js +35 -2
  28. package/dist/core/child-clamp-seats.d.ts +11 -0
  29. package/dist/core/child-clamp-seats.js +3 -0
  30. package/dist/core/context-edit.d.ts +3 -2
  31. package/dist/core/context-edit.js +6 -5
  32. package/dist/core/context-guard.d.ts +2 -1
  33. package/dist/core/context-guard.js +3 -2
  34. package/dist/core/context-settings.d.ts +103 -0
  35. package/dist/core/context-settings.js +60 -0
  36. package/dist/core/engine-notice.d.ts +11 -1
  37. package/dist/core/frame-settlement.d.ts +97 -0
  38. package/dist/core/frame-settlement.js +36 -0
  39. package/dist/core/governance-codes.d.ts +1 -1
  40. package/dist/core/governance-codes.js +2 -0
  41. package/dist/core/hooks.d.ts +10 -10
  42. package/dist/core/mailbox-store.d.ts +41 -7
  43. package/dist/core/mailbox-store.js +9 -3
  44. package/dist/core/parent-spec-seat.d.ts +14 -1
  45. package/dist/core/parent-spec-seat.js +6 -0
  46. package/dist/core/permission-rule-model.js +1 -1
  47. package/dist/core/roles.d.ts +20 -0
  48. package/dist/core/roles.js +35 -16
  49. package/dist/core/runner/assemble-result.d.ts +2 -0
  50. package/dist/core/runner/assemble-result.js +1 -1
  51. package/dist/core/runner/compaction-call-options.d.ts +26 -2
  52. package/dist/core/runner/compaction-call-options.js +9 -0
  53. package/dist/core/runner/compaction-seams.d.ts +4 -3
  54. package/dist/core/runner/compaction-seams.js +13 -6
  55. package/dist/core/runner/contracts.d.ts +56 -7
  56. package/dist/core/runner/decide-continuation.d.ts +2 -1
  57. package/dist/core/runner/decide-continuation.js +11 -10
  58. package/dist/core/runner/initial-run-state.js +1 -1
  59. package/dist/core/runner/prepare-caps-and-workflow.js +9 -1
  60. package/dist/core/runner/prepare-config-doors.js +4 -1
  61. package/dist/core/runner/prepare-context-lane.d.ts +9 -2
  62. package/dist/core/runner/prepare-context-lane.js +15 -10
  63. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -2
  64. package/dist/core/runner/prepare-delegation-surface.js +9 -3
  65. package/dist/core/runner/prepare-file-history.js +10 -8
  66. package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
  67. package/dist/core/runner/prepare-gate-stations.js +3 -1
  68. package/dist/core/runner/prepare-inherited-gate.js +1 -0
  69. package/dist/core/runner/prepare-prompt-inputs.d.ts +6 -0
  70. package/dist/core/runner/prepare-prompt-inputs.js +2 -1
  71. package/dist/core/runner/prepare-task.js +22 -9
  72. package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -1
  73. package/dist/core/runner/prepare-wiring-manifest.js +6 -1
  74. package/dist/core/runner/retired-runner-deps.d.ts +3 -1
  75. package/dist/core/runner/retired-runner-deps.js +1 -0
  76. package/dist/core/runner/run-compaction-machinery.d.ts +4 -2
  77. package/dist/core/runner/run-compaction-machinery.js +5 -3
  78. package/dist/core/runner/run-harness-handlers.js +1 -1
  79. package/dist/core/runner/run-identity-wiring.js +19 -1
  80. package/dist/core/runner/run-leg.js +1 -1
  81. package/dist/core/runner/run-notification-lane.js +8 -2
  82. package/dist/core/runner/run-recovery-lanes.js +9 -5
  83. package/dist/core/runner/run-settle-and-teardown.d.ts +4 -22
  84. package/dist/core/runner/run-settle-and-teardown.js +6 -10
  85. package/dist/core/runner/run-stop-and-final-verify.js +1 -0
  86. package/dist/core/runner/run-terminal-adoption.js +5 -5
  87. package/dist/core/runner/run-turn-boundary.js +32 -5
  88. package/dist/core/runner/runtask.d.ts +8 -1
  89. package/dist/core/runner/runtask.js +32 -1
  90. package/dist/core/runner-deps.d.ts +44 -13
  91. package/dist/core/swappable-deps.d.ts +20 -4
  92. package/dist/core/swappable-deps.js +6 -1
  93. package/dist/core/task-event.d.ts +5 -0
  94. package/dist/core/task-notification.d.ts +144 -2
  95. package/dist/core/task-notification.js +154 -5
  96. package/dist/core/task-result.d.ts +14 -0
  97. package/dist/core/task-spec.d.ts +7 -0
  98. package/dist/core/tool-catalog-entries.js +2 -1
  99. package/dist/core/tool-conformance.js +1 -0
  100. package/dist/core/tool-policy.d.ts +9 -4
  101. package/dist/core/tool-spec.d.ts +14 -0
  102. package/dist/core/wiring-manifest.d.ts +12 -0
  103. package/dist/core/wiring-manifest.js +5 -1
  104. package/dist/engine/harness/agent-harness.d.ts +14 -1
  105. package/dist/engine/harness/agent-harness.js +28 -3
  106. package/dist/engine/harness/types.d.ts +3 -1
  107. package/dist/engine/llm/types.d.ts +8 -7
  108. package/dist/engine/llm/types.js +1 -1
  109. package/dist/engine/session/import-validate.js +4 -0
  110. package/dist/index.d.ts +10 -7
  111. package/dist/index.js +7 -5
  112. package/dist/orchestration/run-workflow-tool.d.ts +4 -4
  113. package/dist/orchestration/workflow.d.ts +1 -1
  114. package/dist/orchestration/workflow.js +8 -5
  115. package/dist/shell/lex.d.ts +30 -51
  116. package/dist/shell/lex.js +237 -284
  117. package/dist/stores/cc/mailbox-store.js +3 -2
  118. package/dist/stores/file/corrupt-read-sink.d.ts +28 -2
  119. package/dist/stores/file/file-history-store.d.ts +2 -4
  120. package/dist/stores/file/file-history-store.js +1 -1
  121. package/dist/stores/file/fs-atomic.d.ts +16 -11
  122. package/dist/stores/file/fs-atomic.js +17 -6
  123. package/dist/stores/file/index.d.ts +5 -6
  124. package/dist/stores/file/index.js +1 -1
  125. package/dist/stores/file/mailbox-store.d.ts +4 -9
  126. package/dist/stores/file/mailbox-store.js +29 -30
  127. package/dist/stores/file/session-policy-store.d.ts +2 -0
  128. package/dist/stores/file/session-policy-store.js +1 -1
  129. package/dist/stores/file/session-store.d.ts +11 -7
  130. package/dist/stores/file/session-store.js +23 -16
  131. package/dist/stores/file/shared-ledger.js +3 -14
  132. package/dist/stores/file/tool-result-store.d.ts +2 -0
  133. package/dist/stores/file/tool-result-store.js +5 -2
  134. package/dist/stores/file/workflow-journal-store.js +14 -9
  135. package/dist/tools/fs/bash-program-position.d.ts +15 -24
  136. package/dist/tools/fs/bash-program-position.js +11 -29
  137. package/dist/tools/fs/bash-readonly-classifier.d.ts +125 -117
  138. package/dist/tools/fs/bash-readonly-classifier.js +400 -272
  139. package/dist/tools/fs/shell-read-check.js +3 -3
  140. package/dist/tools/fs/shell-read-establish.js +1 -1
  141. package/dist/tools/fs/shell-read-plan.d.ts +11 -6
  142. package/dist/tools/fs/shell-read-plan.js +167 -183
  143. package/dist/tools/fs/shell-read-word.d.ts +50 -0
  144. package/dist/tools/fs/shell-read-word.js +59 -0
  145. package/dist/tools/fs/shell-reentry-text.d.ts +10 -0
  146. package/dist/tools/fs/shell-reentry-text.js +73 -0
  147. package/package.json +1 -1
  148. package/test/export-surface.snapshot.json +58 -8
  149. package/wire-changes/core@7.30.0.json +1821 -0
@@ -5,13 +5,11 @@
5
5
  * environment's last-resort `sh` reads `$'…'`, `+=`, a subscript, `<<<`, `<(…)` and `&>` differently; see
6
6
  * {@link bashOnlyConstructsOf}).
7
7
  *
8
- * Two modes remain. STRICT is the residual space the classify faces live in: the caller has hard-rejected
9
- * `< > $ ( ) \` \n \r \\` (or passes `<`/`>` through as text under the rule lane's tolerate option), so the whole of
10
- * bash's word grammar left to model there is quote pairing, the four connectors and whitespace. LENIENT is the space
11
- * the read faces read — everything the strict gate refused, RECORDED instead of refused. The lenient-only
12
- * constructs are branches the strict caller can never reach, so for every strict-accepted input the two modes
13
- * produce the same words and connectors, up to the strict mode's two residuals (a `#` is a word there, and JS
14
- * whitespace rather than bash's blanks bounds a word).
8
+ * ONE walk, ONE reading: every construct bash reads is RECORDED — a redirection, a substitution, an escape, a
9
+ * comment, a line break, a backgrounding `&` — never refused here. Which of them a face refuses is that face's
10
+ * predicate over the result (the classify faces' residual predicate in the read-only classifier); the lexer has
11
+ * no modes. Bash's own word rules hold throughout: an unquoted word-start `#` begins a comment, and only a blank
12
+ * (space or tab) bounds a word — a non-breaking space or a vertical tab is a word character.
15
13
  *
16
14
  * A command bash cannot parse is a {@link LexParseFailure}, never a guessed reading: an unterminated quote,
17
15
  * substitution, subscript or here-document yields NO segments. A word bash reads but whose VALUE the text does not
@@ -21,13 +19,6 @@
21
19
  * a comment and a QUOTED here-document body. Every lookahead below reads the next LOGICAL character past any
22
20
  * continuation, so a pair can stand inside a construct's spelling and never inside the three places bash keeps it.
23
21
  */
24
- export type LexMode = "strict" | "lenient";
25
- export interface LexOptions {
26
- readonly mode: LexMode;
27
- /** `"split"` (default): the connectors bound segments. `"text"`: a single segment is being tokenized and an
28
- * unquoted connector character is a word character. */
29
- readonly connectors?: "split" | "text";
30
- }
31
22
  /** The dialect this lexer reads. The execution environment falls back to `sh` when no bash is found; a reader on
32
23
  * that path must degrade every word carrying a {@link BashOnlyConstruct} to the conservative reading. */
33
24
  export declare const SHELL_LEX_DIALECT = "bash";
@@ -42,18 +33,9 @@ export type ExpansionKind = (typeof EXPANSION_KINDS)[number];
42
33
  * contain — never "the lexer did not look". */
43
34
  export declare const UNRESOLVED_REASONS: readonly ["ansi_c_escape", "locale_string", "parameter_text", "subscript_text", "compound_array_value"];
44
35
  export type UnresolvedReason = (typeof UNRESOLVED_REASONS)[number];
45
- /** What the {@link lexShellText} view does with an unresolved word: `refuse` hands the consumer the reason's
46
- * sentence; `fold` hands it the folded spelling as the pre-fact readers judged it. The locale string folds:
47
- * refusing it would turn a deny row's HIT (judged on the untranslated spelling) into a mere question, and a
48
- * reader that asks on both faces AND keeps the deny judgment reads the fact, not this view. */
49
- export declare const UNRESOLVED_VIEW: {
50
- readonly ansi_c_escape: "refuse";
51
- readonly locale_string: "fold";
52
- readonly parameter_text: "refuse";
53
- readonly subscript_text: "refuse";
54
- readonly compound_array_value: "refuse";
55
- };
56
- /** The sentence the {@link lexShellText} view hands a consumer for an unresolved word it refuses. */
36
+ /** The sentence a consumer hands on for an unresolved word: every reason is one a face ASKS about (the locale
37
+ * string included — its translation is not in the text), and a deny row is still judged on the written spelling
38
+ * by the readers that keep the word beside the reason. */
57
39
  export declare const UNRESOLVED_SENTENCE: {
58
40
  readonly ansi_c_escape: "an ANSI-C quoted word carries an escape this lexer does not fold";
59
41
  readonly locale_string: "a locale-translated string carries text this lexer does not read";
@@ -61,9 +43,8 @@ export declare const UNRESOLVED_SENTENCE: {
61
43
  readonly subscript_text: "a subscript carries text this lexer does not read";
62
44
  readonly compound_array_value: "a compound assignment value is a list this lexer does not read";
63
45
  };
64
- /** Why a command yields no segments: bash's own syntax errors, the two constructs this lexer cannot delimit, and
65
- * the strict mode's backgrounding refusal. */
66
- export declare const PARSE_FAILURE_REASONS: readonly ["unterminated_single_quote", "unterminated_double_quote", "unterminated_ansi_c", "unterminated_subscript", "unterminated_compound_value", "unterminated_command_substitution", "unterminated_process_substitution", "unterminated_parameter_expansion", "unterminated_heredoc", "undelimited_substitution", "redirect_without_target", "heredoc_without_delimiter", "heredoc_delimiter_expands", "background_operator"];
46
+ /** Why a command yields no segments: bash's own syntax errors and the two constructs this lexer cannot delimit. */
47
+ export declare const PARSE_FAILURE_REASONS: readonly ["unterminated_single_quote", "unterminated_double_quote", "unterminated_ansi_c", "unterminated_subscript", "unterminated_compound_value", "unterminated_command_substitution", "unterminated_process_substitution", "unterminated_parameter_expansion", "unterminated_heredoc", "undelimited_substitution", "redirect_without_target", "heredoc_without_delimiter", "heredoc_delimiter_expands"];
67
48
  export type ParseFailureReason = (typeof PARSE_FAILURE_REASONS)[number];
68
49
  export declare const PARSE_FAILURE_SENTENCE: {
69
50
  readonly unterminated_single_quote: "a single-quoted word never closes";
@@ -79,10 +60,9 @@ export declare const PARSE_FAILURE_SENTENCE: {
79
60
  readonly redirect_without_target: "a redirection names no target";
80
61
  readonly heredoc_without_delimiter: "a here-document operator names no delimiter";
81
62
  readonly heredoc_delimiter_expands: "a here-document delimiter is not a plain word";
82
- readonly background_operator: "`&` backgrounding is not allowed — a backgrounded process outlives the command";
83
63
  };
84
64
  /** The constructs of this dialect a POSIX `sh` reads as something else. */
85
- export declare const BASH_ONLY_CONSTRUCTS: readonly ["ansi_c_quoting", "locale_string", "append_assignment", "subscript_assignment", "compound_assignment", "here_string", "process_substitution", "redirect_both", "brace_expansion"];
65
+ export declare const BASH_ONLY_CONSTRUCTS: readonly ["ansi_c_quoting", "locale_string", "append_assignment", "subscript_assignment", "compound_assignment", "here_string", "process_substitution", "redirect_both", "pipe_both", "brace_expansion"];
86
66
  export type BashOnlyConstruct = (typeof BASH_ONLY_CONSTRUCTS)[number];
87
67
  /**
88
68
  * The ANSI-C escapes this lexer folds: the thirteen single-letter ones, whose byte is the same in every bash and
@@ -172,11 +152,16 @@ export interface LexedWord {
172
152
  * assignment word, after a bare control-prefix word, or after a leading redirection list. */
173
153
  readonly atCommandPosition: boolean;
174
154
  }
175
- /** A redirection and the word it takes. A descriptor duplication (`>&2`, `<&0`, `>&-`, `>&1-`) takes none. */
155
+ /** A redirection and the word it takes. A descriptor duplication (`>&2`, `<&0`, `>&-`, `>&1-`) takes none: its
156
+ * operand is `dup`, the descriptor (or `-`, or a descriptor followed by `-`) as written. `fd` is the descriptor
157
+ * number written in front of the operator (`2>f`, `3>&0`); absent when none was (bash's default, `1` for an
158
+ * output form and `0` for an input form, is the reader's to apply). */
176
159
  export interface LexedRedirect {
177
160
  readonly kind: "redirect";
178
161
  readonly op: "<" | ">" | ">>" | "<<<" | "&>" | "&>>" | ">&" | "<&";
162
+ readonly fd?: number;
179
163
  readonly target?: LexedWord;
164
+ readonly dup?: string;
180
165
  }
181
166
  /** A here-document: the body is DATA the program reads on stdin, never command text. `quoted` records whether
182
167
  * the delimiter word carried a quote or an escape, which is bash's rule for "the body does not expand". */
@@ -197,13 +182,17 @@ export type LexedToken = LexedWord | LexedRedirect | LexedHeredoc | LexedGroup;
197
182
  * exited ZERO, `||` is the only one under which the previous segment may have been SKIPPED ENTIRELY, `|`
198
183
  * puts the segment in a subshell whose directory changes never reach the parent, and `;` is plain sequence. */
199
184
  export type ShellSegmentConnector = "start" | ";" | "&&" | "||" | "|";
200
- /** The lenient mode's two extra boundaries: a backgrounding `&` and a line break. */
185
+ /** The two boundaries the read boundary does not distinguish from a plain sequence: a backgrounding `&` and a
186
+ * line break. */
201
187
  export type LenientConnector = ShellSegmentConnector | "&" | "\n";
202
188
  export interface LexedSegment {
203
189
  /** The segment's text exactly as written (surrounding whitespace included). Here-document bodies are not part
204
190
  * of any segment's text. */
205
191
  readonly text: string;
206
192
  readonly connector: LenientConnector;
193
+ /** The `|` was spelled `|&`: the previous segment's standard error is piped too (bash 4+; a syntax error on
194
+ * bash 3.2, so a reader on the fail-closed side treats the pipe as real). */
195
+ readonly pipesStderr?: true;
207
196
  readonly tokens: readonly LexedToken[];
208
197
  /** The bodies of the substitutions found in THIS segment (its words and its redirection targets), in order. */
209
198
  readonly substitutions: readonly string[];
@@ -233,7 +222,6 @@ export declare const SUBSTITUTION_PLACEHOLDER = " subst";
233
222
  /** Shell control words that stand BEFORE a command: transparent for the boundary walk (the command behind them is
234
223
  * judged), and a position after which bash still accepts an assignment word. */
235
224
  export declare const SHELL_CONTROL_PREFIXES: ReadonlySet<string>;
236
- export type QuoteOpen = '"' | "'" | undefined;
237
225
  /**
238
226
  * Does the `$` at `at` OPEN a quote form (`$'…'` / `$"…"`)? ONE question, asked by every walker that has to
239
227
  * answer it. Escaped means an ODD run of backslashes in front of it: `\$'y'` is a literal `$`, while `x\\$'y'`
@@ -244,34 +232,25 @@ export declare function dollarOpensQuote(text: string, at: number): boolean;
244
232
  /** The `'` that CLOSES the ANSI-C quote opened at `open`, or `undefined` when none does. `\'` does not close
245
233
  * one — the single place a quote region honours a backslash. */
246
234
  export declare function ansiCQuoteClose(source: string, open: number): number | undefined;
247
- /**
248
- * Which QUOTE holds each character of `s`, by the same pairing rule the lexer walks with, and the boolean view of
249
- * it. The pairing quote characters belong to the region they bound. `balanced` is false when a region is still
250
- * open at the end of the string; callers must then NOT use the mask. This models bash only for the residual
251
- * character space the strict faces operate in, where backslash escapes are rejected outright.
252
- */
253
- export declare function quoteMask(s: string): {
254
- openedBy: readonly QuoteOpen[];
255
- quoted: readonly boolean[];
256
- balanced: boolean;
257
- };
258
235
  /** The ONE spelling of a LITERAL leading tilde — `./~…`, the relative path it is — for every position bash does not
259
236
  * expand it in; a word without a leading tilde is returned as is. */
260
237
  export declare function literalTildeSpelling(word: string): string;
261
- /** The argv-word projection of a segment: redirections, here-documents and groups are not words the program
262
- * receives (bash removes them before exec). */
238
+ /** The argv words of a segment: redirections, here-documents and groups are not words the program receives (bash
239
+ * removes them before exec). */
240
+ export declare function argvOf(segment: LexedSegment): readonly LexedWord[];
241
+ /** The two-spelling view of {@link argvOf}, for the readers that compare spellings. */
263
242
  export declare function wordsOf(segment: LexedSegment): SegmentTokens;
264
243
  /** The substitution bodies of an UNQUOTED here-document body: `$(…)` and backticks are live there, quotes are
265
244
  * ordinary characters, a backslash protects the next character. `undefined` when a substitution never closes. */
266
245
  export declare function substitutionsInHeredocBody(body: string): string[] | undefined;
267
246
  /** Lex a command: its segments, or the one reason bash (or this lexer) cannot delimit them. */
268
- export declare function lexShell(source: string, opts: LexOptions): ShellLex;
247
+ export declare function lexShell(source: string): ShellLex;
269
248
  /**
270
249
  * The refused-reading view of {@link lexShell}: a parse failure, and any word whose value cannot be read off the
271
- * text and whose reason {@link UNRESOLVED_VIEW} refuses, become the one `{ reject }` sentence a consumer's
272
- * unreadable arm already takes.
250
+ * text, become the one `{ reject }` sentence a consumer's unreadable arm already takes. A reader that keeps the
251
+ * other words (the read station) reads {@link lexShell} and the word's {@link LexedWord.unresolved} instead.
273
252
  */
274
- export declare function lexShellText(source: string, opts: LexOptions): LexedCommand | {
253
+ export declare function lexShellText(source: string): LexedCommand | {
275
254
  reject: string;
276
255
  };
277
256
  /** The constructs of this dialect the command leans on — what a POSIX `sh` would read as something else. Empty