@chances-ai/engine 26.0.0 → 28.0.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/dist/agents/bundled.d.ts +5 -0
- package/dist/agents/bundled.d.ts.map +1 -0
- package/dist/agents/bundled.js +66 -0
- package/dist/agents/bundled.js.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +1 -0
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/parse.d.ts +3 -0
- package/dist/agents/parse.d.ts.map +1 -1
- package/dist/agents/parse.js +17 -0
- package/dist/agents/parse.js.map +1 -1
- package/dist/agents/types.d.ts +8 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/ai/adapters/ai-sdk-stream.d.ts.map +1 -1
- package/dist/ai/adapters/ai-sdk-stream.js +6 -1
- package/dist/ai/adapters/ai-sdk-stream.js.map +1 -1
- package/dist/ai/index.d.ts +1 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +1 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/overflow.d.ts +40 -0
- package/dist/ai/overflow.d.ts.map +1 -0
- package/dist/ai/overflow.js +84 -0
- package/dist/ai/overflow.js.map +1 -0
- package/dist/ai/types.d.ts +8 -1
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/core/coordinator-mode.d.ts +32 -0
- package/dist/core/coordinator-mode.d.ts.map +1 -0
- package/dist/core/coordinator-mode.js +98 -0
- package/dist/core/coordinator-mode.js.map +1 -0
- package/dist/core/coordinator-tools.d.ts +22 -0
- package/dist/core/coordinator-tools.d.ts.map +1 -0
- package/dist/core/coordinator-tools.js +262 -0
- package/dist/core/coordinator-tools.js.map +1 -0
- package/dist/core/engine.d.ts +235 -10
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/core/engine.js +585 -274
- package/dist/core/engine.js.map +1 -1
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/task-tool.d.ts +85 -1
- package/dist/core/task-tool.d.ts.map +1 -1
- package/dist/core/task-tool.js +456 -494
- package/dist/core/task-tool.js.map +1 -1
- package/dist/session/index.d.ts +11 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +22 -1
- package/dist/session/index.js.map +1 -1
- package/dist/tools/bash-readonly.d.ts +26 -0
- package/dist/tools/bash-readonly.d.ts.map +1 -0
- package/dist/tools/bash-readonly.js +130 -0
- package/dist/tools/bash-readonly.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +12 -0
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +18 -12
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/todo.d.ts +33 -0
- package/dist/tools/builtins/todo.d.ts.map +1 -0
- package/dist/tools/builtins/todo.js +245 -0
- package/dist/tools/builtins/todo.js.map +1 -0
- package/dist/tools/builtins/write.d.ts.map +1 -1
- package/dist/tools/builtins/write.js +10 -5
- package/dist/tools/builtins/write.js.map +1 -1
- package/dist/tools/concurrency.d.ts +37 -0
- package/dist/tools/concurrency.d.ts.map +1 -0
- package/dist/tools/concurrency.js +50 -0
- package/dist/tools/concurrency.js.map +1 -0
- package/dist/tools/file-lock.d.ts +22 -0
- package/dist/tools/file-lock.d.ts.map +1 -0
- package/dist/tools/file-lock.js +85 -0
- package/dist/tools/file-lock.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/types.d.ts +31 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/package.json +3 -3
package/dist/core/engine.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ApprovalMode, type AsyncTaskRegistry, type CancellationToken, type EventBus, type TaskNotification, ModelSelection } from "@chances-ai/runtime";
|
|
2
|
-
import { type ModelRouter, type RetryConfig } from "../ai/index.js";
|
|
1
|
+
import { type ApprovalMode, type AsyncTaskRegistry, type BoundaryInjectionQueue, type NotificationSource, type CancellationToken, type EventBus, type TaskNotification, ModelSelection } from "@chances-ai/runtime";
|
|
2
|
+
import { type Message, type ModelRouter, type Route, type RetryConfig, type ToolCallRequest, type ToolDefinition } from "../ai/index.js";
|
|
3
3
|
import type { SessionManager } from "../session/index.js";
|
|
4
4
|
import type { MemoryStore } from "../memory/index.js";
|
|
5
5
|
import type { PermissionGate, ToolRegistry } from "../tools/index.js";
|
|
@@ -35,12 +35,13 @@ export interface AgentEngineOptions {
|
|
|
35
35
|
/** @deprecated since v3.0 — pass `selection` instead. */
|
|
36
36
|
preferredProvider?: string;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
38
|
+
* (7.7 §6) Soft turn ceiling. When the loop exhausts this budget without a
|
|
39
|
+
* final answer, the engine emits `turn:paused` and — depending on
|
|
40
|
+
* {@link pauseOnMaxTurns} — either returns cleanly ("continue?") or throws
|
|
41
|
+
* `AppError(MaxTurns, "Reached maximum number of turns (N)")`. Defaults to
|
|
42
|
+
* {@link DEFAULT_MAX_TURNS} (50); clamped to the absolute hard cap
|
|
43
|
+
* (`CHANCES_HARD_MAX_TURNS`, default 500), which always throws. The CLI
|
|
44
|
+
* threads `ChancesConfig.agent.maxTurns` in here.
|
|
44
45
|
*/
|
|
45
46
|
maxTurns?: number;
|
|
46
47
|
/**
|
|
@@ -125,6 +126,42 @@ export interface AgentEngineOptions {
|
|
|
125
126
|
* backgrounds never accidentally orphan into a process exit.
|
|
126
127
|
*/
|
|
127
128
|
backgroundTasks?: AsyncTaskRegistry;
|
|
129
|
+
/**
|
|
130
|
+
* (7.8 §3.4) Persistent coordinator worker registry. A SECOND
|
|
131
|
+
* {@link NotificationSource} the engine drains alongside `backgroundTasks` at
|
|
132
|
+
* every turn boundary — a worker's per-message result reaches the coordinator
|
|
133
|
+
* as a `<task-notification>` exactly like a background subagent's. Undefined on
|
|
134
|
+
* a normal (non-coordinator) session (drain is a no-op). Per-session in the
|
|
135
|
+
* isolated serve path, same as `backgroundTasks`.
|
|
136
|
+
*/
|
|
137
|
+
workerRegistry?: NotificationSource;
|
|
138
|
+
/**
|
|
139
|
+
* (7.7 §4) Per-session steering queue. When provided, the engine drains it at
|
|
140
|
+
* every turn boundary (turn-top + after each tool batch) and injects the
|
|
141
|
+
* queued user messages BEFORE the next model call — so a user who types while
|
|
142
|
+
* the agent is working steers it without cancelling the turn. The CLI / serve
|
|
143
|
+
* driver enqueue into it (via {@link AgentEngine.enqueueSteering}) instead of
|
|
144
|
+
* rejecting input during an active turn. Undefined ⇒ no steering (drain is a
|
|
145
|
+
* no-op). Peek-not-drain ack (same discipline as `backgroundTasks`): entries
|
|
146
|
+
* are acknowledged only after `session.appendTurn` persists the turn.
|
|
147
|
+
*/
|
|
148
|
+
steering?: BoundaryInjectionQueue;
|
|
149
|
+
/**
|
|
150
|
+
* (7.7 §5.3) Max times per turn the engine nudges the model to finish
|
|
151
|
+
* incomplete todos before giving up and resolving. 0 disables the reminder.
|
|
152
|
+
* Defaults to 3.
|
|
153
|
+
*/
|
|
154
|
+
todoReminderMax?: number;
|
|
155
|
+
/**
|
|
156
|
+
* (7.7 §6) Behaviour when the soft turn ceiling (`maxTurns`) is hit without a
|
|
157
|
+
* final answer. `true` (default, interactive) → emit `turn:paused` and return
|
|
158
|
+
* cleanly ("reached max actions, continue?"); the next user message / steering
|
|
159
|
+
* resumes. `false` (automation / `-p` / SDK) → throw `AppError(MaxTurns)` so a
|
|
160
|
+
* non-interactive caller gets a non-zero exit (preserving the pre-7.7
|
|
161
|
+
* contract, just with a precise error code instead of a misleading PROVIDER).
|
|
162
|
+
* The absolute hard cap (`CHANCES_HARD_MAX_TURNS`) always throws regardless.
|
|
163
|
+
*/
|
|
164
|
+
pauseOnMaxTurns?: boolean;
|
|
128
165
|
/**
|
|
129
166
|
* (3.5) Auto-compaction orchestrator. When provided:
|
|
130
167
|
* - After every appendTurn + before turn:end, the engine asks
|
|
@@ -193,8 +230,12 @@ export interface ResolvedMention {
|
|
|
193
230
|
/** Why it couldn't be read (mutually exclusive with `text`). */
|
|
194
231
|
note?: string;
|
|
195
232
|
}
|
|
196
|
-
/**
|
|
197
|
-
|
|
233
|
+
/** (7.7 §6) Soft turn ceiling — raised from the old 12 (too low for a
|
|
234
|
+
* daily-driver agent). At this many tool iterations without a final answer the
|
|
235
|
+
* interactive engine PAUSES gracefully ("continue?") rather than throwing. The
|
|
236
|
+
* real runaway guard is the token/compaction machinery + the absolute hard cap
|
|
237
|
+
* below, not a low turn count. */
|
|
238
|
+
export declare const DEFAULT_MAX_TURNS = 50;
|
|
198
239
|
/** Default base prompt the engine uses when no `systemBaseOverride` is set.
|
|
199
240
|
* Exported so tests can assert "is this the default or an agent override?" and
|
|
200
241
|
* so the doc + plugin authors can read the exact text. */
|
|
@@ -205,6 +246,95 @@ export interface AgentResult {
|
|
|
205
246
|
outputTokens: number;
|
|
206
247
|
costUsd: number;
|
|
207
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* (7.7 §3.8) The outcome of streaming ONE assistant response: the streamed text
|
|
251
|
+
* plus the tool calls the model requested. Produced by
|
|
252
|
+
* {@link AgentLoopHooks.streamAssistant} — the careful per-attempt retry,
|
|
253
|
+
* provider-agnostic overflow recovery, and usage staging all live inside that
|
|
254
|
+
* unit, so the loop body stays a thin orchestrator.
|
|
255
|
+
*/
|
|
256
|
+
export interface AssistantTurn {
|
|
257
|
+
text: string;
|
|
258
|
+
calls: ToolCallRequest[];
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* (7.7 §3.8) Per-turn mutable accumulators threaded through the loop units.
|
|
262
|
+
* Extracted out of `runTurnImpl`'s local scope so `streamAssistant` can fold
|
|
263
|
+
* usage and track overflow recovery without the orchestrator owning a dozen
|
|
264
|
+
* mutable locals (the very monolith Axis 3.8 set out to dissolve).
|
|
265
|
+
*/
|
|
266
|
+
interface TurnState {
|
|
267
|
+
/** The turn-level result (text + aggregated tokens/cost). */
|
|
268
|
+
result: AgentResult;
|
|
269
|
+
/** The LAST provider request's `inputTokens` — feeds the post-turn
|
|
270
|
+
* compaction threshold check (NOT the cross-step aggregate). */
|
|
271
|
+
lastRequestInputTokens: number;
|
|
272
|
+
/** Reactive overflow recovery fires AT MOST ONCE per turn — a second overflow
|
|
273
|
+
* after we already compacted is a real ceiling we can't paper over. */
|
|
274
|
+
recoveredFromOverflow: boolean;
|
|
275
|
+
/** Most-recent route — the post-turn compaction check reads
|
|
276
|
+
* `model.contextWindow` off it. */
|
|
277
|
+
lastRoute?: Route;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* (7.7 §3.8) One run of the turn loop: the immutable per-turn inputs plus the
|
|
281
|
+
* mutable accumulators the loop units read/append. `turnMessages` and the
|
|
282
|
+
* `injected*Ids` collections are mutated in place (append-only) by the loop and
|
|
283
|
+
* its hooks; the engine reads them back after the loop to persist + acknowledge.
|
|
284
|
+
*/
|
|
285
|
+
/** (7.8 §3.4 — codex R2 M1) Per-source injected-notification tracking. Keyed by
|
|
286
|
+
* the `NotificationSource` object so each source's ack set is independent — a
|
|
287
|
+
* cross-source id collision can't shadow or mis-ack a note. Turn-local. */
|
|
288
|
+
export type InjectedNotifs = Map<NotificationSource, Set<string>>;
|
|
289
|
+
export interface LoopRun {
|
|
290
|
+
turnId: string;
|
|
291
|
+
system: string;
|
|
292
|
+
toolDefs: ToolDefinition[];
|
|
293
|
+
/** Accumulator: assistant/tool/steering messages appended as the loop runs. */
|
|
294
|
+
turnMessages: Message[];
|
|
295
|
+
/** (codex R2 M1) Notification ids already injected this turn, keyed PER source
|
|
296
|
+
* (turn-top + mid-turn) — ack the right source's own ids after persist. */
|
|
297
|
+
injectedNotifIds: InjectedNotifs;
|
|
298
|
+
/** Steering ids already injected — ack after persist. */
|
|
299
|
+
injectedSteerIds: string[];
|
|
300
|
+
/** Soft turn ceiling for THIS run (already clamped to the hard cap). */
|
|
301
|
+
maxTurns: number;
|
|
302
|
+
state: TurnState;
|
|
303
|
+
token: CancellationToken;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* (7.7 §3.8) The agent loop's INJECTION SEAM — the named hooks
|
|
307
|
+
* {@link AgentEngine.runAgentLoop} dispatches through, mirroring pi's
|
|
308
|
+
* `AgentLoopConfig` (`packages/agent/src/types.ts`: `streamAssistantResponse` /
|
|
309
|
+
* `executeToolCalls` / `getSteeringMessages` / `shouldStopAfterTurn`).
|
|
310
|
+
*
|
|
311
|
+
* `AgentEngine` supplies a default set bound to its own methods
|
|
312
|
+
* ({@link AgentEngine.defaultLoopHooks}); task 08's coordinator can supply
|
|
313
|
+
* alternative hooks (dispatch tool batches to worker engines, a different stop
|
|
314
|
+
* condition, model re-selection) WITHOUT forking the loop body. Keeping the loop
|
|
315
|
+
* a small orchestrator over these hooks — instead of a ~440-line monolith — is
|
|
316
|
+
* the Axis 3.8 deliverable.
|
|
317
|
+
*/
|
|
318
|
+
export interface AgentLoopHooks {
|
|
319
|
+
/** Stream one assistant response (careful retry + overflow + usage staging). */
|
|
320
|
+
streamAssistant(route: Route, run: LoopRun): Promise<AssistantTurn>;
|
|
321
|
+
/** Execute the assistant's tool calls: consecutive concurrency-safe calls run
|
|
322
|
+
* in a bounded parallel batch, any unsafe call serially, submission order
|
|
323
|
+
* preserved. Returns the `tool` messages + whether the model signalled
|
|
324
|
+
* terminate. */
|
|
325
|
+
executeToolBatch(calls: ToolCallRequest[], token: CancellationToken, turnId: string): Promise<{
|
|
326
|
+
messages: Message[];
|
|
327
|
+
terminate: boolean;
|
|
328
|
+
}>;
|
|
329
|
+
/** Iteration-boundary injections: steering the user queued mid-turn + bg-task
|
|
330
|
+
* notifications that completed mid-turn (peek-not-drain; ids recorded for the
|
|
331
|
+
* post-persist ack). pi `getSteeringMessages`. */
|
|
332
|
+
getBoundaryMessages(injectedNotifIds: InjectedNotifs, injectedSteerIds: string[]): Message[];
|
|
333
|
+
/** When the model returned NO tool calls: a `user`-role reminder to finish
|
|
334
|
+
* open todos (loop continues) or `null` to let the turn resolve. The inverse
|
|
335
|
+
* of pi's `shouldStopAfterTurn`. */
|
|
336
|
+
incompleteTodoReminder(count: number): Message | null;
|
|
337
|
+
}
|
|
208
338
|
/**
|
|
209
339
|
* Mediator over ai/session/tools/memory. Depends only on interfaces (ports), so
|
|
210
340
|
* any ProviderAdapter or Tool plugs in unchanged. Communicates outward purely by
|
|
@@ -220,6 +350,42 @@ export declare class AgentEngine {
|
|
|
220
350
|
* copy) is intentional: writes must propagate back.
|
|
221
351
|
*/
|
|
222
352
|
getSelection(): ModelSelection;
|
|
353
|
+
/**
|
|
354
|
+
* (7.7 §4) Queue a user steering message to be injected at the next turn
|
|
355
|
+
* boundary of the in-flight turn (or the top of the next turn if idle). A
|
|
356
|
+
* no-op when no `steering` queue was provided. The CLI / serve driver call
|
|
357
|
+
* this on a submit-while-busy instead of rejecting the input.
|
|
358
|
+
*/
|
|
359
|
+
enqueueSteering(text: string): void;
|
|
360
|
+
/** (7.7 §4) Peek the steering queue for entries not yet injected this turn,
|
|
361
|
+
* render each as a user message, and append its id to `injectedSteerIds` for
|
|
362
|
+
* post-persist ack. Peek-not-drain: a cancelled turn re-delivers. */
|
|
363
|
+
private drainSteering;
|
|
364
|
+
/** (7.8 §3.4) The notification sources the engine drains at turn boundaries:
|
|
365
|
+
* background subagent tasks AND persistent coordinator workers. Both
|
|
366
|
+
* implement {@link NotificationSource}; the engine renders their pending
|
|
367
|
+
* `<task-notification>`s together (FIFO within each) and acks EACH source's
|
|
368
|
+
* own ids after persist — never broadcasting a global id list (codex R1-§5). */
|
|
369
|
+
private notificationSources;
|
|
370
|
+
/** (7.7 §4 / 7.8 §3.4 — codex R2 M1) Collect notifications not yet injected this
|
|
371
|
+
* turn, across ALL sources, recording each into its OWN per-source injected set
|
|
372
|
+
* as it's taken. The injected tracking is keyed by `NotificationSource` (NOT a
|
|
373
|
+
* flat id set) so a hypothetical cross-source id collision can never make one
|
|
374
|
+
* source's note shadow another's, nor ack a note that was never injected. */
|
|
375
|
+
private collectFreshNotifications;
|
|
376
|
+
/** (7.7 §4 / 7.8 — codex R2 M1) Ack AFTER persist: each source acks EXACTLY the
|
|
377
|
+
* ids injected FROM it this turn (per-source set), never a merged global list.
|
|
378
|
+
* A cancelled turn (no ack) re-delivers; injected ids are turn-local. */
|
|
379
|
+
private ackNotifications;
|
|
380
|
+
/** (7.7 §4) Iteration-boundary drain: notifications that arrived mid-turn
|
|
381
|
+
* (combined render across all sources, same as turn-top) PLUS steering. Both
|
|
382
|
+
* peek-not-drain; ids recorded for post-persist ack. */
|
|
383
|
+
private drainBoundaryInjections;
|
|
384
|
+
/** (7.7 §5.3) Build an incomplete-todos reminder when the model stopped with
|
|
385
|
+
* open (pending/in_progress) todos and the per-turn cap isn't exhausted.
|
|
386
|
+
* Returns a `user`-role system-reminder message (no `developer` role exists),
|
|
387
|
+
* or null to let the turn resolve. */
|
|
388
|
+
private maybeTodoReminder;
|
|
223
389
|
/** Bus-emit wrapper. Three responsibilities (3.4):
|
|
224
390
|
* 1. Suppress lifecycle frames (`turn:*`, `error`) when the engine is a
|
|
225
391
|
* child (`suppressLifecycleEvents=true`). Codex Round-1 MUST-FIX #2.
|
|
@@ -233,6 +399,64 @@ export declare class AgentEngine {
|
|
|
233
399
|
trustedContext?: string;
|
|
234
400
|
}): Promise<AgentResult>;
|
|
235
401
|
private runTurnImpl;
|
|
402
|
+
/**
|
|
403
|
+
* (7.7 §3.8) The hook-driven turn loop — a thin orchestrator over
|
|
404
|
+
* {@link AgentLoopHooks}, mirroring pi's `runLoop`
|
|
405
|
+
* (`packages/agent/src/agent-loop.ts`). Each iteration streams one assistant
|
|
406
|
+
* response, executes its tool batch, then drains boundary injections (steering
|
|
407
|
+
* + mid-turn notifications) before the next stream. Returns whether the turn
|
|
408
|
+
* reached a final answer (`resolved`) or exhausted `maxTurns`.
|
|
409
|
+
*
|
|
410
|
+
* Behaviour is IDENTICAL to the pre-refactor inline loop — `defaultLoopHooks`
|
|
411
|
+
* binds the same units; the seam exists so task 08's coordinator can inject
|
|
412
|
+
* alternatives without copying this body.
|
|
413
|
+
*/
|
|
414
|
+
protected runAgentLoop(run: LoopRun, hooks: AgentLoopHooks): Promise<{
|
|
415
|
+
resolved: boolean;
|
|
416
|
+
}>;
|
|
417
|
+
/**
|
|
418
|
+
* (7.7 §3.8) The default loop hooks — an object binding the engine's own
|
|
419
|
+
* units. An object (not the methods passed directly) so the shape is a
|
|
420
|
+
* documented, swappable seam: task 08 supplies alternatives; a test can wrap a
|
|
421
|
+
* single hook to assert the loop dispatches through it.
|
|
422
|
+
*/
|
|
423
|
+
protected defaultLoopHooks(): AgentLoopHooks;
|
|
424
|
+
/**
|
|
425
|
+
* (7.7 §3.8) Stream ONE assistant response — the careful inner unit (pi
|
|
426
|
+
* `streamAssistantResponse`). Owns: per-attempt classified retry with backoff,
|
|
427
|
+
* attempt-local usage staging (a discarded retry never double-counts),
|
|
428
|
+
* `assistant:reset` partial-undo, and provider-agnostic overflow recovery on
|
|
429
|
+
* BOTH the terminal-error path (a 413 before the throw) and the success path
|
|
430
|
+
* (z.ai silent truncation / MiMo length-stop). Folds usage into `state.result`
|
|
431
|
+
* and records `state.lastRequestInputTokens` once the stream completes. Throws
|
|
432
|
+
* `AppError(Provider|Cancelled)` on a terminal failure; otherwise returns the
|
|
433
|
+
* streamed text + requested tool calls.
|
|
434
|
+
*/
|
|
435
|
+
private streamAssistantResponse;
|
|
436
|
+
/**
|
|
437
|
+
* (7.7 §7) Provider-agnostic reactive overflow recovery, shared by the
|
|
438
|
+
* terminal-error path and the success path. When `signal` reads as a context
|
|
439
|
+
* overflow AND a compactor is wired AND we haven't already recovered this turn,
|
|
440
|
+
* compact with `reason: "overflow"` (bypasses the circuit breaker) and report
|
|
441
|
+
* whether the caller should restream. Telemetry-gated: a non-Anthropic recovery
|
|
442
|
+
* emits a `log info` so a wrong pattern surfaces as an observable event, not a
|
|
443
|
+
* silent loop. Fires AT MOST ONCE per turn.
|
|
444
|
+
*/
|
|
445
|
+
private maybeRecoverFromOverflow;
|
|
446
|
+
/**
|
|
447
|
+
* (7.7 §3.3) Execute one assistant turn's tool calls. Partitions into
|
|
448
|
+
* batches (consecutive concurrency-safe → one parallel batch; any unsafe →
|
|
449
|
+
* its own serial batch), preserving submission order so a write is never
|
|
450
|
+
* reordered before a preceding read. Returns the `tool` messages in
|
|
451
|
+
* submission order plus whether the model signalled `terminate`.
|
|
452
|
+
*
|
|
453
|
+
* Cancellation is ALL-SETTLED: `runConcurrent` drains every thunk before it
|
|
454
|
+
* propagates, and `runTool` emits a `tool:result` on every path (success /
|
|
455
|
+
* denied / error / cancelled), so each emitted `tool:call` always has its
|
|
456
|
+
* paired result on the bus even when a sibling cancels (codex 7.7 R1
|
|
457
|
+
* MUST-FIX #3).
|
|
458
|
+
*/
|
|
459
|
+
private executeToolBatch;
|
|
236
460
|
private runTool;
|
|
237
461
|
private composeSystem;
|
|
238
462
|
}
|
|
@@ -266,4 +490,5 @@ export declare function renderTaskNotificationXml(n: TaskNotification): string;
|
|
|
266
490
|
* skips the message entirely).
|
|
267
491
|
*/
|
|
268
492
|
export declare function renderMcpResourcesXml(resolved: ResolvedMention[]): string;
|
|
493
|
+
export {};
|
|
269
494
|
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EAEb,KAAK,gBAAg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