@nexrall/code-core 1.4.66 → 1.4.68

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 (91) hide show
  1. package/dist/agent/agentRegistry.d.ts +27 -0
  2. package/dist/agent/agentRegistry.d.ts.map +1 -1
  3. package/dist/agent/agentRegistry.js +45 -0
  4. package/dist/agent/agentTypes.d.ts +6 -2
  5. package/dist/agent/agentTypes.d.ts.map +1 -1
  6. package/dist/agent/agentTypes.js +13 -4
  7. package/dist/agent/askOnce.d.ts +12 -0
  8. package/dist/agent/askOnce.d.ts.map +1 -0
  9. package/dist/agent/askOnce.js +41 -0
  10. package/dist/agent/compaction.d.ts +244 -0
  11. package/dist/agent/compaction.d.ts.map +1 -0
  12. package/dist/agent/compaction.js +976 -0
  13. package/dist/agent/fileLocks.d.ts +34 -0
  14. package/dist/agent/fileLocks.d.ts.map +1 -0
  15. package/dist/agent/fileLocks.js +114 -0
  16. package/dist/agent/hooks.d.ts +331 -0
  17. package/dist/agent/hooks.d.ts.map +1 -0
  18. package/dist/agent/hooks.js +1239 -0
  19. package/dist/agent/iterationPolicy.d.ts +121 -0
  20. package/dist/agent/iterationPolicy.d.ts.map +1 -0
  21. package/dist/agent/iterationPolicy.js +297 -0
  22. package/dist/agent/lifecycleHost.d.ts +55 -0
  23. package/dist/agent/lifecycleHost.d.ts.map +1 -0
  24. package/dist/agent/lifecycleHost.js +294 -0
  25. package/dist/agent/loop.d.ts +39 -491
  26. package/dist/agent/loop.d.ts.map +1 -1
  27. package/dist/agent/loop.js +538 -3069
  28. package/dist/agent/planMode.d.ts.map +1 -1
  29. package/dist/agent/planMode.js +1 -0
  30. package/dist/agent/sharedTasks.d.ts +7 -0
  31. package/dist/agent/sharedTasks.d.ts.map +1 -1
  32. package/dist/agent/sharedTasks.js +16 -0
  33. package/dist/agent/subAgentBudget.d.ts +65 -0
  34. package/dist/agent/subAgentBudget.d.ts.map +1 -0
  35. package/dist/agent/subAgentBudget.js +269 -0
  36. package/dist/agent/subTask.d.ts +15 -0
  37. package/dist/agent/subTask.d.ts.map +1 -0
  38. package/dist/agent/subTask.js +730 -0
  39. package/dist/agent/subTaskSupport.d.ts +167 -0
  40. package/dist/agent/subTaskSupport.d.ts.map +1 -0
  41. package/dist/agent/subTaskSupport.js +425 -0
  42. package/dist/agent/toolDescriptions.d.ts +3 -0
  43. package/dist/agent/toolDescriptions.d.ts.map +1 -0
  44. package/dist/agent/toolDescriptions.js +116 -0
  45. package/dist/api/client.d.ts +41 -0
  46. package/dist/api/client.d.ts.map +1 -1
  47. package/dist/api/client.js +173 -1
  48. package/dist/index.d.ts +5 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +5 -0
  51. package/dist/mcp/client.d.ts +104 -0
  52. package/dist/mcp/client.d.ts.map +1 -1
  53. package/dist/mcp/client.js +136 -2
  54. package/dist/mcp/httpClient.d.ts +17 -1
  55. package/dist/mcp/httpClient.d.ts.map +1 -1
  56. package/dist/mcp/httpClient.js +120 -19
  57. package/dist/mcp/manager.d.ts +77 -2
  58. package/dist/mcp/manager.d.ts.map +1 -1
  59. package/dist/mcp/manager.js +275 -9
  60. package/dist/mcp/server.d.ts +39 -0
  61. package/dist/mcp/server.d.ts.map +1 -0
  62. package/dist/mcp/server.js +189 -0
  63. package/dist/mcp/sseClient.d.ts +7 -1
  64. package/dist/mcp/sseClient.d.ts.map +1 -1
  65. package/dist/mcp/sseClient.js +45 -1
  66. package/dist/mcp/stats.d.ts +41 -0
  67. package/dist/mcp/stats.d.ts.map +1 -0
  68. package/dist/mcp/stats.js +108 -0
  69. package/dist/permissions/destructive.d.ts +2 -0
  70. package/dist/permissions/destructive.d.ts.map +1 -1
  71. package/dist/permissions/destructive.js +6 -2
  72. package/dist/permissions/destructiveTokens.d.ts +5 -0
  73. package/dist/permissions/destructiveTokens.d.ts.map +1 -1
  74. package/dist/permissions/destructiveTokens.js +9 -3
  75. package/dist/permissions/modePolicy.d.ts.map +1 -1
  76. package/dist/permissions/modePolicy.js +5 -2
  77. package/dist/permissions/rules.d.ts +4 -1
  78. package/dist/permissions/rules.d.ts.map +1 -1
  79. package/dist/permissions/rules.js +29 -0
  80. package/dist/plugins/data.d.ts +23 -0
  81. package/dist/plugins/data.d.ts.map +1 -0
  82. package/dist/plugins/data.js +141 -0
  83. package/dist/plugins/index.d.ts +14 -2
  84. package/dist/plugins/index.d.ts.map +1 -1
  85. package/dist/plugins/index.js +45 -4
  86. package/dist/plugins/installer.d.ts +83 -0
  87. package/dist/plugins/installer.d.ts.map +1 -1
  88. package/dist/plugins/installer.js +207 -1
  89. package/dist/types.d.ts +45 -1
  90. package/dist/types.d.ts.map +1 -1
  91. package/package.json +1 -1
@@ -1,487 +1,19 @@
1
- import type { Message, ToolResult, AgentLoopOptions, EnvContext } from '../types';
1
+ import type { Message, ToolResult, AgentLoopOptions } from '../types';
2
2
  import { type BackgroundAgentHub } from './backgroundAgents';
3
- import { streamChat } from '../api/client';
4
- import { type AgentType, type AgentMemoryScope } from './agentTypes';
3
+ import { type AgentType } from './agentTypes';
5
4
  import { bashNeedsRepoLock } from '../permissions/bashClassify';
6
5
  export { bashNeedsRepoLock };
7
- /** Backoff for the Nth (0-based) empty-turn retry. Pure, so the schedule is testable. */
8
- export declare function emptyTurnBackoffMs(attempt: number): number;
9
- /**
10
- * Should an empty assistant turn be retried automatically, rather than surfaced?
11
- *
12
- * Split out as a pure function because the two "empty" causes look IDENTICAL at the
13
- * call site (both are `content.length === 0`) and telling them apart is the entire
14
- * point — the previous bug in this area was treating a deterministic truncation as a
15
- * transient hiccup and advising a retry that reproduced it verbatim.
16
- *
17
- * • `max_tokens` → the model burned its whole output budget on reasoning and was CUT
18
- * OFF. Retrying re-runs the same prompt with the same budget and the same reasoning
19
- * behaviour, so it fails the same way while billing again. Never retried; the user
20
- * is told to lower effort or split the task (stopReasonNotice 'output-limit').
21
- * • anything else → a genuinely transient empty turn. Retried, up to the limit.
22
- *
23
- * The attempt cap matters as much as the classification: a model that has decided to
24
- * return nothing (e.g. a prompt it refuses to continue) would otherwise loop forever
25
- * on a paid endpoint. After the cap we fall back to the old visible notice.
26
- */
27
- export declare function shouldRetryEmptyTurn(stopReason: string | null | undefined, attemptsSoFar: number): boolean;
28
- /** Empty-turn retry limits, exposed for tests. */
29
- export declare const _emptyTurnRetry: {
30
- EMPTY_TURN_RETRY_LIMIT: number;
31
- EMPTY_TURN_RETRY_BASE_MS: number;
32
- };
33
- /**
34
- * Fingerprint one round's tool failures, for the repeated-failure runaway guard.
35
- *
36
- * Exported (with the limits) purely as a test seam: the guard's whole value is in the
37
- * edge cases — that a DIFFERENT error each round must NOT trip it, that call order
38
- * within a round is irrelevant, that a long error body doesn't make every occurrence
39
- * look unique — and none of that is reachable without driving a live model loop.
40
- *
41
- * Sorted so parallel tool calls completing in a different order still compare equal;
42
- * truncated because errors often embed a varying path or timestamp late in the string.
43
- */
44
- export declare function errorRoundSignature(errored: Array<{
45
- name: string;
46
- error: string;
47
- }>): string;
48
- /** Runaway-guard limits, exposed for tests. */
49
- export declare const _stallLimits: {
50
- STALL_LIMIT: number;
51
- REPEAT_STALL_LIMIT: number;
52
- };
53
- /**
54
- * The single tool granted by a `memory:` frontmatter scope.
55
- *
56
- * Named distinctly from `memory_write` on purpose: they write to DIFFERENT stores, and
57
- * a model that saw one name for both would reasonably assume its notes were visible to
58
- * the main agent. They are not.
59
- */
60
- export declare const AGENT_MEMORY_TOOL = "agent_memory_write";
61
- /**
62
- * Schema advertised to the model, only for a sub-agent with a declared memory scope.
63
- *
64
- * The description does the load-bearing work of keeping the two stores apart in the
65
- * model's head: it must not believe these notes reach the user or the main agent.
66
- */
67
- export declare const AGENT_MEMORY_TOOL_SCHEMA: {
68
- readonly name: "agent_memory_write";
69
- readonly description: string;
70
- readonly input_schema: {
71
- readonly type: "object";
72
- readonly properties: {
73
- readonly content: {
74
- readonly type: "string";
75
- readonly description: "The single fact to remember, 1-2 sentences.";
76
- };
77
- };
78
- readonly required: readonly ["content"];
79
- };
80
- };
81
- /** Identifies whose notes an agent_memory_write call may touch. */
82
- export interface AgentMemoryBinding {
83
- agentName: string;
84
- scope: AgentMemoryScope;
85
- }
86
- /**
87
- * Execute an `agent_memory_write` call.
88
- *
89
- * Pure-ish and exported so the refusal paths are testable without spawning a real
90
- * sub-agent: the binding is data, so "no binding" and "unsafe agent name" can both be
91
- * exercised directly.
92
- */
93
- export declare function executeAgentMemoryWrite(input: Record<string, unknown>, binding: AgentMemoryBinding | undefined, workDir?: string): Promise<ToolResult>;
94
- /**
95
- * Why an agent run stopped.
96
- *
97
- * `'clean'` and `'aborted'` are the two silent-by-design outcomes: the model gave a
98
- * final answer, or the user pressed Ctrl+C and already knows why it stopped.
99
- * EVERYTHING else owes the user an explanation, which is what stopReasonNotice covers.
100
- */
101
- export type StopReason = 'clean' | 'aborted' | 'reported-elsewhere' | 'empty-response' | 'output-limit' | 'no-balance' | 'no-team-budget' | 'team-unavailable' | 'stalled' | 'stalled-repeat' | 'budget' | 'unknown';
102
- /**
103
- * The message shown when a run ends for any reason other than a clean finish.
104
- *
105
- * Pure and exported so every branch is testable: reaching some of these for real needs
106
- * an empty wallet, a dead upstream, or hundreds of iterations. Returns null only for
107
- * the two outcomes that are deliberately silent.
108
- *
109
- * `'unknown'` deliberately produces a message rather than nothing. If a future `break`
110
- * forgets to set a reason, the symptom should be a visible "ended unexpectedly" line —
111
- * annoying and reportable — not the silent stop that made this refactor necessary.
112
- */
113
- export declare function stopReasonNotice(reason: StopReason, ctx?: {
114
- budget?: number;
115
- repeatError?: string | null;
116
- }): string | null;
117
- export declare function resolveMaxIterations(optionValue: number | undefined, settingsRaw: Record<string, unknown>): number;
118
- /**
119
- * Every path a tool call will touch, so all of them can be locked.
120
- *
121
- * `move_file`/`copy_file` carry `source` + `destination`, the rest carry `path`. Both
122
- * `dest` and `destination` are accepted because the schema has used both spellings and
123
- * silently missing the key would mean silently losing the lock — a failure that shows
124
- * up as corrupted content rather than an error.
125
- *
126
- * Exported for tests: getting this wrong is invisible until two writes race.
127
- */
128
- export declare function lockPathsFor(name: string, input: Record<string, unknown>, workDir?: string): string[];
129
- /**
130
- * Resolve the fan-out limit: env → settings.json → default.
131
- *
132
- * Was env-ONLY, the same gap as the sub-task timeout: a project on a small machine that
133
- * wanted 2, or a big one that wanted 6, had to set a shell variable, and nobody reading
134
- * settings.json could see what the limit even was. Capped at HARD_MAX_CONCURRENT_SUBTASKS
135
- * (32 — above Claude Code's default 20, so a user who wants that width can have it)
136
- * because this bounds real shared resources (CPU, the API rate limit, file handles) and a
137
- * typo like 400 should degrade to "a lot" rather than fork-bomb the machine.
138
- */
139
- export declare function resolveMaxConcurrentSubtasks(settingsRaw?: Record<string, unknown>): number;
140
- /** Resolve the session-total sub-agent ceiling: env → settings.json → default. */
141
- export declare function resolveMaxSubagentsPerSession(settingsRaw?: Record<string, unknown>): number;
142
- /**
143
- * Minimal concurrency gate. Hand-rolled rather than pulling in `p-limit` because
144
- * the CLI ships as a single esbuild bundle with no node_modules, and this is a
145
- * dozen lines.
146
- */
147
- export declare function createLimiter(max: number): <T>(fn: () => Promise<T>) => Promise<T>;
148
- /** Test-only: forget the memoised limiter so a new limit can take effect. */
149
- export declare function _resetSubTaskLimiter(): void;
150
- /**
151
- * Start a fresh sub-agent budget. Call when a NEW conversation begins.
152
- *
153
- * Exported for clients that reuse one process across conversations (the VS Code extension
154
- * host). A client that never calls it gets process-lifetime semantics, which is correct
155
- * for a one-shot CLI invocation.
156
- */
157
- export declare function resetSessionSubAgentBudget(sessionKey?: string): void;
158
- /** Test-only: observe the session counter without exporting the mutable binding. */
159
- export declare function _sessionSubAgentCount(sessionKey?: string): number;
160
- /**
161
- * Deepest nesting level allowed to spawn: env → settings.json → default 3.
162
- *
163
- * Was a hard-coded 1, i.e. "sub-agents are leaves". That was the right default while the
164
- * three capability decisions disagreed with each other (see canSpawnSubAgents), but it is
165
- * no longer where the ecosystem is: Claude Code lifted the no-nesting rule and, after a
166
- * brief period with it disabled entirely, settled on a configurable default of 3.
167
- *
168
- * 3, not 5, deliberately. Depth is a budget you SPEND, not headroom you fill: every level
169
- * is a context window that receives only a dispatch prompt on the way down and returns
170
- * only a summary on the way up, so the deeper frames pay full freight to carry less
171
- * information. 3 covers orchestrator → worker → helper, which is where the observed value
172
- * is; beyond that latency and token cost tend to exceed the benefit.
173
- *
174
- * Depth 1 remains available (`maxSubagentDepth: 1`) for anyone who wants leaves-only.
175
- */
176
- export declare function resolveMaxSubagentDepth(settingsRaw?: Record<string, unknown>): number;
177
- /**
178
- * The ONE explanation for "this run may not spawn a sub-agent", shared by every place
179
- * that can refuse it, so the same impossibility never gets two different stories.
180
- *
181
- * Parameterised on the REASON because the reasons are no longer interchangeable. It used
182
- * to be a flat constant reading "Sub-agents cannot spawn further sub-agents — this is a
183
- * structural limit"; with nesting configurable that sentence is now false for most runs,
184
- * and telling a depth-1 agent its limit is structural when the user could raise it by one
185
- * line of settings is the same class of misdirection as the "needs a different agent" text
186
- * this replaced. A refusal has to be accurate about whether it can be lifted, or the model
187
- * either gives up when it shouldn't or hunts for an escape that doesn't exist.
188
- */
189
- export declare function noSpawnReason(kind: 'depth' | 'denied', limit?: number): string;
190
- /**
191
- * Whether a run at `depth` may spawn sub-agents.
192
- *
193
- * The single source of truth for THREE things that must agree: the `<available_subagents>`
194
- * catalogue in the system prompt, whether the backend is asked to send the `task` tool
195
- * schema at all, and which prompt block teaches delegation. They used to be decided
196
- * independently, and the result was a sub-agent that got the tool plus instructions to use
197
- * it but no catalogue — then a permission-gate refusal telling it not to ask for approval.
198
- *
199
- * `depth < limit` because the children this run would create land at `depth + 1`; the
200
- * guard inside runSubTask mirrors it as `depth >= limit`.
201
- *
202
- * `limit` is injected rather than read from module state so this stays pure and testable.
203
- * Callers pass the resolved per-workspace value; it defaults to the built-in for the
204
- * handful of call sites that have no settings in hand.
205
- */
206
- /**
207
- * A child sub-agent's effective tool allowlist: its own, narrowed by its parent's.
208
- *
209
- * Exported and pure because it is a SECURITY boundary and was previously verified only by
210
- * grepping the source for the intersection expression — which matched happily while the
211
- * code threw a TypeError on one of its own four cases. A boundary needs behavioural tests.
212
- *
213
- * `null` means "no allowlist" (unrestricted), and it is returned only when BOTH sides say
214
- * so. The four cases:
215
- * own + parent → intersection (a child can narrow, never widen)
216
- * own only → own (the main agent, which has no allowlist, spawning a specialist)
217
- * parent only → a COPY of parent (an unnamed/general-purpose child inherits the
218
- * restriction instead of resetting to full access — this is the
219
- * escalation path, since `general-purpose` declares no tools at all)
220
- * neither → null
221
- *
222
- * The parent-only case must COPY: the caller adds AGENT_MEMORY_TOOL to the returned set,
223
- * which would otherwise mutate the parent's live allowlist.
224
- */
225
- export declare function intersectAllowlists(own: Set<string> | null, parent: Set<string> | undefined): Set<string> | null;
226
- export declare function canSpawnSubAgents(depth: number, allowedTools?: Set<string>, limit?: number): boolean;
227
- /**
228
- * How long a sub-agent may make NO progress before it is stopped.
229
- *
230
- * Precedence matches every other tunable in this file
231
- * (env → settings.json → default) — it used to be env-ONLY, which meant a project that
232
- * legitimately needed longer sub-tasks had no way to say so in the file where every
233
- * other such preference lives, and the limit was invisible to anyone reading settings.
234
- *
235
- * Exported for tests: the behaviour that matters (a long-but-productive sub-agent is
236
- * NOT killed) takes minutes of wall clock to exercise through the real loop.
237
- */
238
- export declare function resolveSubtaskTimeoutMs(settingsRaw: Record<string, unknown>): number;
239
- /**
240
- * Thrown by a sub-agent's permission gate when the AGENT DEFINITION forbids a
241
- * tool — as opposed to the user declining it.
242
- *
243
- * The distinction matters to the model, which is why this is an exception rather
244
- * than a `false`: both used to collapse into "Permission denied by user", so an
245
- * agent blocked by its own allowlist (very often a mistyped tool name) was told
246
- * the human had refused. The rational response to that is to ask again, which
247
- * can never succeed. Carrying a reason lets the tool_result say what is actually
248
- * true and what to do instead.
249
- */
250
- export declare class ToolNotAllowedError extends Error {
251
- constructor(message: string);
252
- }
253
- /**
254
- * Reduce a sub-agent's message history to the text its parent should receive.
255
- *
256
- * Pure + exported so the salvage rules can be tested without running a real
257
- * sub-agent (which needs a live model stream and, for the timeout path, ten
258
- * minutes of wall clock).
259
- *
260
- * `preferLast` — the normal completion path — returns the final assistant
261
- * message, which is the sub-agent's actual answer.
262
- *
263
- * `preferLast: false` is the SALVAGE path, used when the sub-agent was cut off.
264
- * A stopped sub-agent usually has no closing summary at all (it was killed
265
- * mid-tool-round), so the last assistant message is frequently empty or a
266
- * fragment. Concatenating what it did produce is far more useful to the parent
267
- * model than nothing: it can build on the work instead of redoing it.
268
- */
269
- export declare function extractSubTaskText(messages: Message[], preferLast?: boolean): string;
270
- /** Apply the parent-context cap to a sub-task's text, keeping head + tail. */
271
- export declare function capSubTaskText(text: string, max?: number): string;
272
- /**
273
- * Summarise what a cut-short sub-agent actually accomplished, so the parent model
274
- * can continue from it rather than starting over.
275
- *
276
- * This is the whole point of the salvage path. Previously a timed-out sub-agent
277
- * returned ONLY an error string: ten minutes of work, dozens of tool calls and
278
- * any files it wrote were invisible to the parent, which typically responded by
279
- * re-running the same work from scratch — while the tokens for the discarded run
280
- * had already been billed in full.
281
- */
282
- export declare function summariseSubTaskProgress(messages: Message[]): string;
283
- /**
284
- * The last N tool results from a transcript, newest last, each truncated.
285
- *
286
- * Pure + exported so the salvage rules are testable without a real sub-agent.
287
- *
288
- * Truncation keeps the HEAD of each result: tool output is overwhelmingly
289
- * front-loaded (a file starts with its imports, a failing command starts with its
290
- * error), and a head slice is the half that identifies what was found.
291
- */
292
- export declare function lastToolResults(messages: Message[], count: number, maxChars: number): string;
293
- /**
294
- * Context window (tokens) for a model alias or real model id.
295
- *
296
- * Checks the LIVE catalogue (GET /api/code/models, modelCatalogue.ts) first —
297
- * populated once per process by whichever client fetched it (CLI at session
298
- * start, VS Code via _postModelCatalogue, desktop via its main-process
299
- * fetch) — falling back to this hard-coded table when no live data exists yet
300
- * (offline, older backend, or the catalogue simply hasn't been fetched by
301
- * this call site). This is what lets a model added to the backend registry
302
- * (services/providers/modelRegistry.js) get the CORRECT context window here
303
- * even before this table is updated by hand for a new nexrall-code release —
304
- * exactly the class of bug GPT-5.6's 922K-vs-1.05M mismatch was (see
305
- * modelRegistry.js's own comment on that row).
306
- *
307
- * The static-table fallback is deliberately the SMALLEST window in the table
308
- * rather than the largest. An unknown model is most likely a newly added one
309
- * this client build predates, and guessing high is the failure that cannot be
310
- * recovered from: the turn hits a provider 400 with no chance to compact.
311
- * Guessing low only costs an earlier, lossy compaction — annoying, not broken.
312
- */
313
- export declare function contextWindowFor(model?: string): number;
314
- /** Token counts at which auto-prune and auto-compact (summarise) fire for a model window. */
315
- export declare function compactionLimits(contextWindow: number, settingsRaw?: Record<string, unknown>): {
316
- prune: number;
317
- compact: number;
318
- };
319
- /** Auto-prune / auto-compact thresholds as fractions of the context window — for UI display (e.g. `/context`). */
320
- export declare function compactionThresholds(contextWindow?: number, settingsRaw?: Record<string, unknown>): {
321
- prune: number;
322
- compact: number;
323
- };
324
- export declare function pruneReclaimFloor(lastCallEndedAt: number | undefined, now?: number): number;
325
- /** Approximate serialised request-body size (bytes) for the messages array. */
326
- export declare function estimateBodyBytes(messages: Message[]): number;
327
- /** Tools that mutate the filesystem — used by the verification nudge (GAP D). */
328
- export declare const WRITE_TOOL_NAMES: Set<string>;
329
- /**
330
- * May an agent restricted to `testFilesOnly` perform this tool call?
331
- *
332
- * A tool allowlist is all-or-nothing per tool: granting `edit_file` grants it for
333
- * every path in the repo. A user-defined test-writer agent needs write access to produce
334
- * tests, but must NOT be able to "fix" production source so a failing test goes
335
- * green — the single most common way a test-writing agent destroys the signal it
336
- * was asked to create. Its prompt says so; this makes it a refusal rather than a
337
- * request.
338
- *
339
- * Pure + exported so the rules are testable directly, without running a real
340
- * sub-agent.
341
- *
342
- * KNOWN LIMIT, stated rather than hidden: this gates the file TOOLS, not `bash`.
343
- * A determined model could still write source via `bash: echo ... > src/x.ts`.
344
- * Closing that means parsing shell redirection, which is not reliably doable — so
345
- * this is a strong guardrail against the realistic failure mode, not a sandbox.
346
- * Real isolation is the sandbox config (tools/sandbox.ts), a separate mechanism.
347
- */
348
- export declare function allowsTestOnlyWrite(tool: string, input: Record<string, unknown> | undefined): boolean;
349
- /** Heuristic: does a bash command look like it's running tests/build/lint/typecheck? (GAP D) */
350
- export declare const VERIFY_CMD_RE: RegExp;
351
- /**
352
- * Find the latest index ≤ maxIdx where history can be cut safely.
353
- *
354
- * A safe cut point is a **turn boundary**: an assistant message (which always
355
- * begins a fresh turn after a user message). Cutting there guarantees that
356
- * `messages[cut..]` starts with an assistant whose `tool_use` blocks are all
357
- * answered by `tool_result`s that remain in the kept slice — so we never orphan
358
- * a tool_result (which the API rejects). We deliberately allow cutting across
359
- * tool_result-bearing user messages: the OLD implementation only cut at a
360
- * *non*-tool_result user message, which never exists inside a single long
361
- * agentic run (every user turn is a tool_result), so compaction was a no-op
362
- * exactly when a long task needs it most.
363
- */
364
- export declare function findSafeCutIndex(messages: Message[], maxIdx: number): number;
365
- /**
366
- * Render messages to a plain-text transcript for the summariser (tool noise
367
- * truncated per-block AND the whole transcript hard-capped). When the transcript
368
- * would exceed MAX_TRANSCRIPT_CHARS we keep the HEAD (original task + early
369
- * decisions) and the TAIL (most-recent, highest-signal context) and drop the
370
- * middle — a middle-out elision that preserves both "what we set out to do" and
371
- * "where we are now", which is what the continuation summary needs most.
372
- */
373
- /**
374
- * Appends the backend-announced runtime-context block to the user message it was
375
- * attached to. No-op if that message is not a user turn or already ends with the
376
- * identical block. Exported for tests.
377
- */
378
- export declare function persistRuntimeContext(messages: Message[], idx: number, text: string): boolean;
379
- export declare function transcriptOf(messages: Message[]): string;
380
- export interface ProgressLedger {
381
- filesTouched: Map<string, {
382
- tool: string;
383
- edits: number;
384
- }>;
385
- /**
386
- * DISTINCT paths ever touched, including any since evicted from `filesTouched`.
387
- *
388
- * The Map is bounded (see ledgerRecord), so `filesTouched.size` is a window, not a
389
- * total. The preamble states "FILES CHANGED THIS SESSION (N)" as a fact the model
390
- * reasons about, so N must not silently shrink when eviction kicks in on a very long
391
- * run — that would tell the model less work happened than actually did.
392
- */
393
- filesTouchedTotal: number;
394
- verifications: Array<{
395
- cmd: string;
396
- ok: boolean;
397
- epoch: number;
398
- }>;
399
- /** Test-integrity findings (reward-hacking signals) that must survive compaction. */
400
- testIntegrity: Array<{
401
- path: string;
402
- reason: string;
403
- }>;
404
- /**
405
- * TOTAL test-integrity findings ever recorded, including ones since trimmed.
406
- *
407
- * `testIntegrity` is a bounded window (older entries are spliced off once it grows
408
- * past 2×LEDGER_MAX_NOTES), so its `.length` STOPS being a running total after the
409
- * first trim. The one-shot nudge compares "how many findings exist" against "how
410
- * many I've already surfaced", and comparing against a window that shrinks meant the
411
- * count could never move ahead again — silently disabling the reward-hacking warning
412
- * for the remainder of a long session, i.e. exactly when it matters most.
413
- *
414
- * This counter only ever increases, so it is a safe basis for that comparison.
415
- */
416
- testIntegrityTotal: number;
417
- /**
418
- * Monotonic mutation epoch: incremented on every successful source write. Two
419
- * verification runs sharing an epoch had NO edit between them, so a PASS↔FAIL
420
- * flip across that boundary proves the test is flaky (see detectFlaky).
421
- */
422
- epoch: number;
423
- }
424
- export declare function createLedger(): ProgressLedger;
425
- /** Record one tool call's effect on the ledger (deterministic, no model call). */
426
- export declare function ledgerRecord(ledger: ProgressLedger, toolName: string, input: Record<string, unknown> | undefined, ok: boolean, output?: string, exitCode?: number): void;
427
- /** Render the ledger as a compact, verbatim block for the compaction preamble. */
428
- export declare function ledgerSummary(ledger: ProgressLedger): string;
429
- /**
430
- * Lossy-but-structure-preserving prune: shrink OLD, large tool_result blocks in
431
- * place, keeping the last PRUNE_KEEP_RECENT messages untouched. This is tried
432
- * BEFORE summarisation because it:
433
- * • keeps every turn and every tool_use/tool_result pair (API stays valid),
434
- * • never makes an extra model call (summarisation does — cost + latency),
435
- * • degrades gracefully on repeat (summarise-of-summarise loses the most on
436
- * long runs; pruning just trims already-consumed output further).
437
- *
438
- * IMPORTANT: pruned state is encoded in the content string (PRUNE_MARKER_TAIL
439
- * suffix), NOT as an extra property on the block — a stray field on a content
440
- * block is rejected by the Anthropic API as an unknown key (400). This keeps the
441
- * serialised body schema-clean while remaining idempotent across repeat calls.
442
- *
443
- * Returns the number of bytes reclaimed (0 if nothing was prunable).
444
- *
445
- * `minReclaimBytes` (default 0): if the TOTAL prunable amount is below this, the
446
- * function makes NO changes and returns 0. This is a cache-safety gate — pruning
447
- * even one old block changes the request prefix and invalidates the message-level
448
- * prompt cache, so a tiny prune would bust the cache (re-write at 1.25×) for
449
- * almost no size win. Measuring first, then applying only if worthwhile, keeps
450
- * the "don't bust cache for a trivial gain" contract truly atomic (the old code
451
- * mutated first and let the caller decide, which had already invalidated the
452
- * cache by the time the caller declined).
453
- */
454
- export declare function pruneOldToolResults(messages: Message[], minReclaimBytes?: number): number;
455
- /**
456
- * Summarises the WHOLE conversation by appending the instruction to its final user
457
- * message and sending it with the conversation's own request options — Claude Code's
458
- * approach. The prefix is byte-identical to the previous request, so the history is a
459
- * cache READ (0.10×) instead of a fresh uncached transcript of up to 600K chars.
460
- * Returns '' when it cannot be used (last turn is not the user's) or yields no text.
461
- */
462
- export type CachedSummarizer = (instruction: string) => Promise<string>;
463
- export declare function makeCachedSummarizer(messages: Message[], requestOptions: () => Parameters<typeof streamChat>[1], abortSignal?: {
464
- aborted: boolean;
465
- }): CachedSummarizer;
466
- /** Rough token estimate for a resumed transcript — no API round-trip needed. */
467
- export declare function estimateTokensRough(messages: Message[]): number;
468
- /**
469
- * Proactively compact `messages` in place if resuming this session would blow
470
- * past the auto-compact threshold on the very first turn. Returns true if any
471
- * compaction happened (so the caller can surface a one-line notice to the
472
- * user). Safe to call on any message array, including empty/small ones (no-op).
473
- *
474
- * `model` picks the right context window (mirrors runAgentLoop's own lookup);
475
- * `onNotice` is optional — pass it to show the same "auto-compacted" message
476
- * the in-loop path shows, so the behaviour is visually consistent.
477
- */
478
- export declare function compactMessagesForResume(messages: Message[], opts: {
479
- model?: string;
480
- workDir: string;
481
- clientType?: string;
482
- env?: EnvContext;
483
- onNotice?: (text: string) => void;
484
- }): Promise<boolean>;
6
+ export { loadHooks, parsePromptHookReply, classifyStopFailure, runLifecycleHooks, runPermissionRequestHooks, fireNotificationHooks, fireManualPostCompactHook, fireManualPreCompactHook, fireObserverHook, drainHookDeliveries, takeHookWakes, hasPendingHookWake, formatHookDeliveries, setHookWakeListener, setHookStatusListener, setHookMcpCaller, resetHookOnceState, setHookEventListener, hasHookEventListener, runElicitationHooks, runElicitationResultHooks, } from './hooks';
7
+ export type { HookDef, HookEntry, HooksConfig, ObserverEvent, HookDelivery, HookMcpCaller, HookLifecycleEvent, ElicitationAnswer, ElicitationAction } from './hooks';
8
+ export { contextWindowFor, compactionLimits, compactionThresholds, pruneReclaimFloor, estimateBodyBytes, WRITE_TOOL_NAMES, allowsTestOnlyWrite, VERIFY_CMD_RE, findSafeCutIndex, persistRuntimeContext, transcriptOf, createLedger, ledgerRecord, ledgerSummary, pruneOldToolResults, makeCachedSummarizer, estimateTokensRough, compactMessagesForResume, } from './compaction';
9
+ export type { ProgressLedger, CachedSummarizer } from './compaction';
10
+ export { emptyTurnBackoffMs, shouldRetryEmptyTurn, _emptyTurnRetry, errorRoundSignature, _stallLimits, AGENT_MEMORY_TOOL, AGENT_MEMORY_TOOL_SCHEMA, executeAgentMemoryWrite, stopReasonNotice, resolveMaxIterations } from './iterationPolicy';
11
+ export type { AgentMemoryBinding, StopReason } from './iterationPolicy';
12
+ export { lockPathsFor } from './fileLocks';
13
+ export { resolveMaxConcurrentSubtasks, resolveMaxSubagentsPerSession, createLimiter, _resetSubTaskLimiter, resetSessionSubAgentBudget, _sessionSubAgentCount } from './subAgentBudget';
14
+ export { resolveMaxSubagentDepth, noSpawnReason, intersectAllowlists, canSpawnSubAgents, resolveSubtaskTimeoutMs, ToolNotAllowedError, extractSubTaskText, capSubTaskText, summariseSubTaskProgress, lastToolResults } from './subTaskSupport';
15
+ import { type ForkContext } from './subTask';
16
+ export type { ForkContext };
485
17
  /**
486
18
  * Dispatch one `task` (sub-agent) call — the exact same path the `task` tool's
487
19
  * `runAgentLoop` switch-case uses (session-budget claim, per-depth concurrency
@@ -497,17 +29,33 @@ export declare function compactMessagesForResume(messages: Message[], opts: {
497
29
  * own about where agent definitions come from.
498
30
  */
499
31
  export declare function dispatchSubAgent(input: Record<string, unknown>, options: AgentLoopOptions, agentTypes: AgentType[]): Promise<ToolResult>;
500
- /**
501
- * `task` with run_in_background — start the sub-agent detached and return at once.
502
- *
503
- * The child runs with its OWN abort signal (the user's Stop on the main turn does not
504
- * kill it; the hub's stop() does), renders nothing into the chat (its tool calls are
505
- * only counted for the "N agents" badge), and cannot prompt the user: a call that the
506
- * project's rules or the session mode do not already allow is refused with an
507
- * explanation, which the child then reports (Claude Code auto-denies the same way).
508
- * Its final report reaches the main agent as a <task-notification>.
509
- */
510
32
  export declare function dispatchBackgroundSubAgent(input: Record<string, unknown>, options: AgentLoopOptions, agentTypes: AgentType[], hub: BackgroundAgentHub): ToolResult;
33
+ /**
34
+ * `/subtask` — fork the CURRENT conversation into a background agent.
35
+ *
36
+ * The difference from `dispatchBackgroundSubAgent` above is the starting history: that one
37
+ * hands the child a self-contained prompt (fresh context, described work, `task` tool
38
+ * semantics), whereas this one COPIES the caller's transcript in and appends the user's
39
+ * instruction to it. A user who has spent a conversation narrowing down a problem should not
40
+ * have to write a brief that re-states it — and a child that re-reads everything to catch up
41
+ * pays for the same context twice.
42
+ *
43
+ * Returns as soon as the child is started (the child runs detached, exactly like a
44
+ * background `task`): the caller gets the id and the description to show, and the report
45
+ * arrives later through the hub's notifications. Never `ToolResult`: nothing here is a tool
46
+ * result for a model to read, so the wording lives with whoever renders it.
47
+ *
48
+ * Permission policy is the shared background policy — the child cannot ask the user
49
+ * anything, because the user is not watching it.
50
+ */
51
+ export declare function dispatchForkedSubAgent(conversation: Message[], prompt: string, options: AgentLoopOptions, agentTypes: AgentType[], hub: BackgroundAgentHub): {
52
+ id: string;
53
+ description: string;
54
+ agentType: string;
55
+ messages: number;
56
+ } | {
57
+ error: string;
58
+ };
511
59
  export declare function runAgentLoop(initialMessages: Message[], options: AgentLoopOptions): Promise<Message[]>;
512
60
  /**
513
61
  * Cut a history back to the last point the API will accept as a resumable
@@ -1 +1 @@
1
- {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAKP,UAAU,EACV,gBAAgB,EAChB,UAAU,EAEX,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAiC,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAiF,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAmB,MAAM,cAAc,CAAC;AAQrK,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AA8P7B,yFAAyF;AACzF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACrC,aAAa,EAAE,MAAM,GACpB,OAAO,CAGT;AAED,kDAAkD;AAClD,eAAO,MAAM,eAAe;;;CAAuD,CAAC;AAEpF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9C,MAAM,CAKR;AAED,+CAA+C;AAC/C,eAAO,MAAM,YAAY;;;CAAsC,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;CAgB3B,CAAC;AAEX,mEAAmE;AACnE,MAA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