@chances-ai/engine 25.0.0 → 27.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.
Files changed (60) hide show
  1. package/dist/ai/adapters/ai-sdk-stream.d.ts.map +1 -1
  2. package/dist/ai/adapters/ai-sdk-stream.js +6 -1
  3. package/dist/ai/adapters/ai-sdk-stream.js.map +1 -1
  4. package/dist/ai/index.d.ts +1 -0
  5. package/dist/ai/index.d.ts.map +1 -1
  6. package/dist/ai/index.js +1 -0
  7. package/dist/ai/index.js.map +1 -1
  8. package/dist/ai/overflow.d.ts +40 -0
  9. package/dist/ai/overflow.d.ts.map +1 -0
  10. package/dist/ai/overflow.js +84 -0
  11. package/dist/ai/overflow.js.map +1 -0
  12. package/dist/ai/types.d.ts +8 -1
  13. package/dist/ai/types.d.ts.map +1 -1
  14. package/dist/core/engine.d.ts +205 -10
  15. package/dist/core/engine.d.ts.map +1 -1
  16. package/dist/core/engine.js +539 -272
  17. package/dist/core/engine.js.map +1 -1
  18. package/dist/core/index.d.ts +1 -1
  19. package/dist/core/index.d.ts.map +1 -1
  20. package/dist/core/index.js.map +1 -1
  21. package/dist/core/task-tool.d.ts.map +1 -1
  22. package/dist/core/task-tool.js +6 -0
  23. package/dist/core/task-tool.js.map +1 -1
  24. package/dist/session/index.d.ts +11 -0
  25. package/dist/session/index.d.ts.map +1 -1
  26. package/dist/session/index.js +22 -1
  27. package/dist/session/index.js.map +1 -1
  28. package/dist/tools/bash-readonly.d.ts +26 -0
  29. package/dist/tools/bash-readonly.d.ts.map +1 -0
  30. package/dist/tools/bash-readonly.js +130 -0
  31. package/dist/tools/bash-readonly.js.map +1 -0
  32. package/dist/tools/builtins/bash.d.ts.map +1 -1
  33. package/dist/tools/builtins/bash.js +12 -0
  34. package/dist/tools/builtins/bash.js.map +1 -1
  35. package/dist/tools/builtins/edit.d.ts.map +1 -1
  36. package/dist/tools/builtins/edit.js +18 -12
  37. package/dist/tools/builtins/edit.js.map +1 -1
  38. package/dist/tools/builtins/todo.d.ts +33 -0
  39. package/dist/tools/builtins/todo.d.ts.map +1 -0
  40. package/dist/tools/builtins/todo.js +245 -0
  41. package/dist/tools/builtins/todo.js.map +1 -0
  42. package/dist/tools/builtins/write.d.ts.map +1 -1
  43. package/dist/tools/builtins/write.js +10 -5
  44. package/dist/tools/builtins/write.js.map +1 -1
  45. package/dist/tools/concurrency.d.ts +37 -0
  46. package/dist/tools/concurrency.d.ts.map +1 -0
  47. package/dist/tools/concurrency.js +50 -0
  48. package/dist/tools/concurrency.js.map +1 -0
  49. package/dist/tools/file-lock.d.ts +22 -0
  50. package/dist/tools/file-lock.d.ts.map +1 -0
  51. package/dist/tools/file-lock.js +85 -0
  52. package/dist/tools/file-lock.js.map +1 -0
  53. package/dist/tools/index.d.ts +4 -0
  54. package/dist/tools/index.d.ts.map +1 -1
  55. package/dist/tools/index.js +4 -0
  56. package/dist/tools/index.js.map +1 -1
  57. package/dist/tools/types.d.ts +31 -0
  58. package/dist/tools/types.d.ts.map +1 -1
  59. package/dist/tools/types.js.map +1 -1
  60. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"ai-sdk-stream.d.ts","sourceRoot":"","sources":["../../../src/ai/adapters/ai-sdk-stream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAwB,aAAa,EAAE,MAAM,aAAa,CAAC;AAmDpF;;;;;;;;;;;;;;;GAeG;AACH,wBAAuB,eAAe,CACpC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,WAAW,EACnB,MAAM,GAAE,MAAM,OAAO,CAAC,OAAO,CAAsB,GAClD,aAAa,CAAC,aAAa,CAAC,CAwE9B"}
1
+ {"version":3,"file":"ai-sdk-stream.d.ts","sourceRoot":"","sources":["../../../src/ai/adapters/ai-sdk-stream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAwB,aAAa,EAAE,MAAM,aAAa,CAAC;AAoDpF;;;;;;;;;;;;;;;GAeG;AACH,wBAAuB,eAAe,CACpC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,WAAW,EACnB,MAAM,GAAE,MAAM,OAAO,CAAC,OAAO,CAAsB,GAClD,aAAa,CAAC,aAAa,CAAC,CA6E9B"}
@@ -61,6 +61,10 @@ export async function* streamFromAiSdk(model, req, signal, loadAi = () => import
61
61
  yield { type: "error", message: err instanceof Error ? err.message : String(err) };
62
62
  return;
63
63
  }
64
+ // (7.7 §7) The provider's finish reason, captured from the `finish` part and
65
+ // surfaced on the terminal `done` event so the engine can detect a length-stop
66
+ // overflow (Xiaomi MiMo: `finishReason: "length"` with zero output tokens).
67
+ let finishReason;
64
68
  try {
65
69
  for await (const part of result.fullStream) {
66
70
  switch (part.type) {
@@ -79,6 +83,7 @@ export async function* streamFromAiSdk(model, req, signal, loadAi = () => import
79
83
  break;
80
84
  case "finish": {
81
85
  const u = part.usage ?? {};
86
+ finishReason = typeof part.finishReason === "string" ? part.finishReason : undefined;
82
87
  yield {
83
88
  type: "usage",
84
89
  usage: {
@@ -98,7 +103,7 @@ export async function* streamFromAiSdk(model, req, signal, loadAi = () => import
98
103
  yield { type: "error", message: err instanceof Error ? err.message : String(err) };
99
104
  return;
100
105
  }
101
- yield { type: "done" };
106
+ yield { type: "done", finishReason };
102
107
  }
103
108
  function toCoreMessage(m) {
104
109
  if (m.role === "tool") {
@@ -1 +1 @@
1
- {"version":3,"file":"ai-sdk-stream.js","sourceRoot":"","sources":["../../../src/ai/adapters/ai-sdk-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,qBAAqB,CAAC;AAsC/D;;;;uEAIuE;AACvE,SAAS,UAAU,CAAC,CAAU;IAC5B,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAC7C,IAAI,CAAC;QACH,OAAO,IAAI,CA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CAAC,CAAC,CAAC,EAAE,EAAE,CAC5D;SACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACrG,CAAC"}
@@ -2,6 +2,7 @@ export type { Role, ContentPart, Message, ToolDefinition, ToolCallRequest, Usage
2
2
  export { ModelRegistry } from "./registry.js";
3
3
  export { ModelRouter, type RouteHints, type Route } from "./router.js";
4
4
  export { estimateCost } from "./cost.js";
5
+ export { type OverflowSignal, isContextOverflow, getOverflowPatterns } from "./overflow.js";
5
6
  export { MockAdapter } from "./adapters/mock.js";
6
7
  export { AiSdkAdapter, AI_SDK_PACKAGES, type AiSdkAdapterOptions, type AiSdkProvider, } from "./adapters/ai-sdk.js";
7
8
  export { OpenAICompatibleAdapter, type OpenAICompatibleAdapterOptions, } from "./adapters/openai-compatible.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,IAAI,EACJ,WAAW,EACX,OAAO,EACP,cAAc,EACd,eAAe,EACf,KAAK,EACL,SAAS,EACT,eAAe,EACf,WAAW,EACX,aAAa,EACb,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,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AK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/ai/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { ModelRegistry } from "./registry.js";
2
2
  export { ModelRouter } from "./router.js";
3
3
  export { estimateCost } from "./cost.js";
4
+ export { isContextOverflow, getOverflowPatterns } from "./overflow.js";
4
5
  export { MockAdapter } from "./adapters/mock.js";
5
6
  export { AiSdkAdapter, AI_SDK_PACKAGES, } from "./adapters/ai-sdk.js";
6
7
  export { OpenAICompatibleAdapter, } from "./adapters/openai-compatible.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAA+B,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EACL,YAAY,EACZ,eAAe,GAGhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,GAExB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAsB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAwB,MAAM,YAAY,CAAC;AACpF,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GAGnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAA+B,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAuB,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EACL,YAAY,EACZ,eAAe,GAGhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,GAExB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAsB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAwB,MAAM,YAAY,CAAC;AACpF,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GAGnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * (7.7 §7) Provider-agnostic context-overflow detection — ported from pi
3
+ * `packages/ai/src/utils/overflow.ts`. Replaces the old Anthropic-only
4
+ * `isAnthropicOverflowError`: a flat catalogue of per-provider error patterns +
5
+ * an inverse exclusion list (so rate-limit / throttling never reads as
6
+ * overflow) + three NON-error signals (silent z.ai, length-stop MiMo).
7
+ *
8
+ * Used by the engine's reactive overflow→compact→retry recovery so an
9
+ * OpenAI/Gemini/Groq/… 413 gets the same compaction recovery Anthropic already
10
+ * had, instead of looping or failing.
11
+ */
12
+ /** The minimal stream-outcome shape overflow detection needs. */
13
+ export interface OverflowSignal {
14
+ /** The stream's terminal reason. `"error"` drives the error-text catalogue;
15
+ * `"stop"` / `"length"` drive the silent / length-stop signals. */
16
+ stopReason: "error" | "stop" | "length" | (string & {});
17
+ /** The provider error text (present when `stopReason === "error"`). */
18
+ errorMessage?: string;
19
+ /** Token usage (for the non-error silent/length signals). */
20
+ usage?: {
21
+ input: number;
22
+ cacheRead?: number;
23
+ output: number;
24
+ };
25
+ /** Model context window (enables the silent/length signals). */
26
+ contextWindow?: number;
27
+ }
28
+ /**
29
+ * True when `signal` indicates a context overflow. Three cases (pi):
30
+ * 1. Error-text: `stopReason "error"` + an OVERFLOW_PATTERN match that is NOT a
31
+ * NON_OVERFLOW_PATTERN (rate-limit guard).
32
+ * 2. Silent overflow (z.ai): a SUCCESSFUL `stop` whose `input + cacheRead`
33
+ * exceeds the context window.
34
+ * 3. Length-stop overflow (Xiaomi MiMo): `length` with `output === 0` and the
35
+ * input filling ≥99% of the window (server truncated input, no room to gen).
36
+ */
37
+ export declare function isContextOverflow(signal: OverflowSignal): boolean;
38
+ /** Exported for tests — the raw pattern set. */
39
+ export declare function getOverflowPatterns(): RegExp[];
40
+ //# sourceMappingURL=overflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overflow.d.ts","sourceRoot":"","sources":["../../src/ai/overflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA0CH,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B;wEACoE;IACpE,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACxD,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAqBjE;AAED,gDAAgD;AAChD,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * (7.7 §7) Provider-agnostic context-overflow detection — ported from pi
3
+ * `packages/ai/src/utils/overflow.ts`. Replaces the old Anthropic-only
4
+ * `isAnthropicOverflowError`: a flat catalogue of per-provider error patterns +
5
+ * an inverse exclusion list (so rate-limit / throttling never reads as
6
+ * overflow) + three NON-error signals (silent z.ai, length-stop MiMo).
7
+ *
8
+ * Used by the engine's reactive overflow→compact→retry recovery so an
9
+ * OpenAI/Gemini/Groq/… 413 gets the same compaction recovery Anthropic already
10
+ * had, instead of looping or failing.
11
+ */
12
+ /** Error-text patterns that indicate a context overflow, keyed by provider in
13
+ * the inline comments (pi's catalogue, verbatim). */
14
+ const OVERFLOW_PATTERNS = [
15
+ /prompt is too long/i, // Anthropic token overflow
16
+ /request_too_large/i, // Anthropic request byte-size overflow (HTTP 413)
17
+ /input is too long for requested model/i, // Amazon Bedrock
18
+ /exceeds the context window/i, // OpenAI (Completions & Responses API)
19
+ /exceeds (?:the )?(?:model'?s )?maximum context length of [\d,]+ tokens?/i, // OpenAI-compatible proxies (LiteLLM)
20
+ /input token count.*exceeds the maximum/i, // Google (Gemini)
21
+ /maximum prompt length is \d+/i, // xAI (Grok)
22
+ /reduce the length of the messages/i, // Groq
23
+ /maximum context length is \d+ tokens/i, // OpenRouter (most backends)
24
+ /exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i, // OpenRouter/Poolside
25
+ /input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i, // Together AI
26
+ /exceeds the limit of \d+/i, // GitHub Copilot
27
+ /exceeds the available context size/i, // llama.cpp server
28
+ /greater than the context length/i, // LM Studio
29
+ /context window exceeds limit/i, // MiniMax
30
+ /exceeded model token limit/i, // Kimi For Coding
31
+ /too large for model with \d+ maximum context length/i, // Mistral
32
+ /model_context_window_exceeded/i, // z.ai non-standard finish_reason surfaced as error text
33
+ /prompt too long; exceeded (?:max )?context length/i, // Ollama explicit overflow error
34
+ /context[_ ]length[_ ]exceeded/i, // Generic fallback
35
+ /too many tokens/i, // Generic fallback
36
+ /token limit exceeded/i, // Generic fallback
37
+ /^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i, // Cerebras: 400/413 with no body
38
+ ];
39
+ /**
40
+ * Patterns that indicate NON-overflow errors (rate limiting, server errors).
41
+ * An error matching any of these is excluded even if it also matches an
42
+ * OVERFLOW_PATTERN — e.g. Bedrock's "ThrottlingException: Too many tokens,
43
+ * please wait" would otherwise false-positive on `/too many tokens/i`.
44
+ */
45
+ const NON_OVERFLOW_PATTERNS = [
46
+ /^(Throttling error|Service unavailable):/i, // AWS Bedrock non-overflow (human-readable prefixes)
47
+ /rate limit/i, // Generic rate limiting
48
+ /too many requests/i, // Generic HTTP 429 style
49
+ ];
50
+ /**
51
+ * True when `signal` indicates a context overflow. Three cases (pi):
52
+ * 1. Error-text: `stopReason "error"` + an OVERFLOW_PATTERN match that is NOT a
53
+ * NON_OVERFLOW_PATTERN (rate-limit guard).
54
+ * 2. Silent overflow (z.ai): a SUCCESSFUL `stop` whose `input + cacheRead`
55
+ * exceeds the context window.
56
+ * 3. Length-stop overflow (Xiaomi MiMo): `length` with `output === 0` and the
57
+ * input filling ≥99% of the window (server truncated input, no room to gen).
58
+ */
59
+ export function isContextOverflow(signal) {
60
+ // Case 1 — error message patterns.
61
+ if (signal.stopReason === "error" && signal.errorMessage) {
62
+ const msg = signal.errorMessage;
63
+ const isNonOverflow = NON_OVERFLOW_PATTERNS.some((p) => p.test(msg));
64
+ if (!isNonOverflow && OVERFLOW_PATTERNS.some((p) => p.test(msg)))
65
+ return true;
66
+ }
67
+ const { usage, contextWindow } = signal;
68
+ if (!usage || !contextWindow)
69
+ return false;
70
+ const inputTokens = usage.input + (usage.cacheRead ?? 0);
71
+ // Case 2 — silent overflow (z.ai): succeeded but input exceeds the window.
72
+ if (signal.stopReason === "stop" && inputTokens > contextWindow)
73
+ return true;
74
+ // Case 3 — length-stop overflow (MiMo): truncated to fit, no room for output.
75
+ if (signal.stopReason === "length" && usage.output === 0 && inputTokens >= contextWindow * 0.99) {
76
+ return true;
77
+ }
78
+ return false;
79
+ }
80
+ /** Exported for tests — the raw pattern set. */
81
+ export function getOverflowPatterns() {
82
+ return [...OVERFLOW_PATTERNS];
83
+ }
84
+ //# sourceMappingURL=overflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overflow.js","sourceRoot":"","sources":["../../src/ai/overflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;sDACsD;AACtD,MAAM,iBAAiB,GAAa;IAClC,qBAAqB,EAAE,2BAA2B;IAClD,oBAAoB,EAAE,kDAAkD;IACxE,wCAAwC,EAAE,iBAAiB;IAC3D,6BAA6B,EAAE,uCAAuC;IACtE,0EAA0E,EAAE,sCAAsC;IAClH,yCAAyC,EAAE,kBAAkB;IAC7D,+BAA+B,EAAE,aAAa;IAC9C,oCAAoC,EAAE,OAAO;IAC7C,uCAAuC,EAAE,6BAA6B;IACtE,kEAAkE,EAAE,sBAAsB;IAC1F,iFAAiF,EAAE,cAAc;IACjG,2BAA2B,EAAE,iBAAiB;IAC9C,qCAAqC,EAAE,mBAAmB;IAC1D,kCAAkC,EAAE,YAAY;IAChD,+BAA+B,EAAE,UAAU;IAC3C,6BAA6B,EAAE,kBAAkB;IACjD,sDAAsD,EAAE,UAAU;IAClE,gCAAgC,EAAE,yDAAyD;IAC3F,oDAAoD,EAAE,iCAAiC;IACvF,gCAAgC,EAAE,mBAAmB;IACrD,kBAAkB,EAAE,mBAAmB;IACvC,uBAAuB,EAAE,mBAAmB;IAC5C,+CAA+C,EAAE,iCAAiC;CACnF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,qBAAqB,GAAa;IACtC,2CAA2C,EAAE,qDAAqD;IAClG,aAAa,EAAE,wBAAwB;IACvC,oBAAoB,EAAE,yBAAyB;CAChD,CAAC;AAeF;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAsB;IACtD,mCAAmC;IACnC,IAAI,MAAM,CAAC,UAAU,KAAK,OAAO,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACzD,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;QAChC,MAAM,aAAa,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,aAAa,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;IAChF,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;IACxC,IAAI,CAAC,KAAK,IAAI,CAAC,aAAa;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;IAEzD,2EAA2E;IAC3E,IAAI,MAAM,CAAC,UAAU,KAAK,MAAM,IAAI,WAAW,GAAG,aAAa;QAAE,OAAO,IAAI,CAAC;IAE7E,8EAA8E;IAC9E,IAAI,MAAM,CAAC,UAAU,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,IAAI,aAAa,GAAG,IAAI,EAAE,CAAC;QAChG,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;AAChC,CAAC"}
@@ -68,8 +68,15 @@ export type ProviderEvent = {
68
68
  } | {
69
69
  type: "usage";
70
70
  usage: Usage;
71
- } | {
71
+ }
72
+ /** Terminal success event. `finishReason` mirrors the provider's finish
73
+ * reason when the adapter can surface it (the Vercel AI SDK `finish` part
74
+ * carries it) — `"length"` drives the (7.7 §7) length-stop overflow signal
75
+ * (Xiaomi MiMo). Absent for adapters that don't report it (treated as a
76
+ * normal `"stop"`). */
77
+ | {
72
78
  type: "done";
79
+ finishReason?: "stop" | "length" | "tool-calls" | "content-filter" | "error" | "other" | (string & {});
73
80
  } | {
74
81
  type: "error";
75
82
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAE5D,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvF,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,wFAAwF;AACxF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,UAAU,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;C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, 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 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
- * Safety valve against runaway tool loops. Matches claude-code's `maxTurns`
39
- * (`src/QueryEngine.ts:154`) and pi's `MAX_TURNS` test convention. When the
40
- * loop exhausts this budget without the model returning a final answer, the
41
- * engine throws `AppError(Provider, "Reached maximum number of turns (N)")`
42
- * claude-code's terminal-error pattern. Defaults to 12 when omitted; the
43
- * CLI threads `ChancesConfig.agent.maxTurns` in here.
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,33 @@ export interface AgentEngineOptions {
125
126
  * backgrounds never accidentally orphan into a process exit.
126
127
  */
127
128
  backgroundTasks?: AsyncTaskRegistry;
129
+ /**
130
+ * (7.7 §4) Per-session steering queue. When provided, the engine drains it at
131
+ * every turn boundary (turn-top + after each tool batch) and injects the
132
+ * queued user messages BEFORE the next model call — so a user who types while
133
+ * the agent is working steers it without cancelling the turn. The CLI / serve
134
+ * driver enqueue into it (via {@link AgentEngine.enqueueSteering}) instead of
135
+ * rejecting input during an active turn. Undefined ⇒ no steering (drain is a
136
+ * no-op). Peek-not-drain ack (same discipline as `backgroundTasks`): entries
137
+ * are acknowledged only after `session.appendTurn` persists the turn.
138
+ */
139
+ steering?: BoundaryInjectionQueue;
140
+ /**
141
+ * (7.7 §5.3) Max times per turn the engine nudges the model to finish
142
+ * incomplete todos before giving up and resolving. 0 disables the reminder.
143
+ * Defaults to 3.
144
+ */
145
+ todoReminderMax?: number;
146
+ /**
147
+ * (7.7 §6) Behaviour when the soft turn ceiling (`maxTurns`) is hit without a
148
+ * final answer. `true` (default, interactive) → emit `turn:paused` and return
149
+ * cleanly ("reached max actions, continue?"); the next user message / steering
150
+ * resumes. `false` (automation / `-p` / SDK) → throw `AppError(MaxTurns)` so a
151
+ * non-interactive caller gets a non-zero exit (preserving the pre-7.7
152
+ * contract, just with a precise error code instead of a misleading PROVIDER).
153
+ * The absolute hard cap (`CHANCES_HARD_MAX_TURNS`) always throws regardless.
154
+ */
155
+ pauseOnMaxTurns?: boolean;
128
156
  /**
129
157
  * (3.5) Auto-compaction orchestrator. When provided:
130
158
  * - After every appendTurn + before turn:end, the engine asks
@@ -193,8 +221,12 @@ export interface ResolvedMention {
193
221
  /** Why it couldn't be read (mutually exclusive with `text`). */
194
222
  note?: string;
195
223
  }
196
- /** Engine default when no caller-supplied or config-supplied value applies. */
197
- export declare const DEFAULT_MAX_TURNS = 12;
224
+ /** (7.7 §6) Soft turn ceiling raised from the old 12 (too low for a
225
+ * daily-driver agent). At this many tool iterations without a final answer the
226
+ * interactive engine PAUSES gracefully ("continue?") rather than throwing. The
227
+ * real runaway guard is the token/compaction machinery + the absolute hard cap
228
+ * below, not a low turn count. */
229
+ export declare const DEFAULT_MAX_TURNS = 50;
198
230
  /** Default base prompt the engine uses when no `systemBaseOverride` is set.
199
231
  * Exported so tests can assert "is this the default or an agent override?" and
200
232
  * so the doc + plugin authors can read the exact text. */
@@ -205,6 +237,90 @@ export interface AgentResult {
205
237
  outputTokens: number;
206
238
  costUsd: number;
207
239
  }
240
+ /**
241
+ * (7.7 §3.8) The outcome of streaming ONE assistant response: the streamed text
242
+ * plus the tool calls the model requested. Produced by
243
+ * {@link AgentLoopHooks.streamAssistant} — the careful per-attempt retry,
244
+ * provider-agnostic overflow recovery, and usage staging all live inside that
245
+ * unit, so the loop body stays a thin orchestrator.
246
+ */
247
+ export interface AssistantTurn {
248
+ text: string;
249
+ calls: ToolCallRequest[];
250
+ }
251
+ /**
252
+ * (7.7 §3.8) Per-turn mutable accumulators threaded through the loop units.
253
+ * Extracted out of `runTurnImpl`'s local scope so `streamAssistant` can fold
254
+ * usage and track overflow recovery without the orchestrator owning a dozen
255
+ * mutable locals (the very monolith Axis 3.8 set out to dissolve).
256
+ */
257
+ interface TurnState {
258
+ /** The turn-level result (text + aggregated tokens/cost). */
259
+ result: AgentResult;
260
+ /** The LAST provider request's `inputTokens` — feeds the post-turn
261
+ * compaction threshold check (NOT the cross-step aggregate). */
262
+ lastRequestInputTokens: number;
263
+ /** Reactive overflow recovery fires AT MOST ONCE per turn — a second overflow
264
+ * after we already compacted is a real ceiling we can't paper over. */
265
+ recoveredFromOverflow: boolean;
266
+ /** Most-recent route — the post-turn compaction check reads
267
+ * `model.contextWindow` off it. */
268
+ lastRoute?: Route;
269
+ }
270
+ /**
271
+ * (7.7 §3.8) One run of the turn loop: the immutable per-turn inputs plus the
272
+ * mutable accumulators the loop units read/append. `turnMessages` and the
273
+ * `injected*Ids` collections are mutated in place (append-only) by the loop and
274
+ * its hooks; the engine reads them back after the loop to persist + acknowledge.
275
+ */
276
+ export interface LoopRun {
277
+ turnId: string;
278
+ system: string;
279
+ toolDefs: ToolDefinition[];
280
+ /** Accumulator: assistant/tool/steering messages appended as the loop runs. */
281
+ turnMessages: Message[];
282
+ /** Notification ids already injected (turn-top + mid-turn) — ack after persist. */
283
+ injectedNotifIds: Set<string>;
284
+ /** Steering ids already injected — ack after persist. */
285
+ injectedSteerIds: string[];
286
+ /** Soft turn ceiling for THIS run (already clamped to the hard cap). */
287
+ maxTurns: number;
288
+ state: TurnState;
289
+ token: CancellationToken;
290
+ }
291
+ /**
292
+ * (7.7 §3.8) The agent loop's INJECTION SEAM — the named hooks
293
+ * {@link AgentEngine.runAgentLoop} dispatches through, mirroring pi's
294
+ * `AgentLoopConfig` (`packages/agent/src/types.ts`: `streamAssistantResponse` /
295
+ * `executeToolCalls` / `getSteeringMessages` / `shouldStopAfterTurn`).
296
+ *
297
+ * `AgentEngine` supplies a default set bound to its own methods
298
+ * ({@link AgentEngine.defaultLoopHooks}); task 08's coordinator can supply
299
+ * alternative hooks (dispatch tool batches to worker engines, a different stop
300
+ * condition, model re-selection) WITHOUT forking the loop body. Keeping the loop
301
+ * a small orchestrator over these hooks — instead of a ~440-line monolith — is
302
+ * the Axis 3.8 deliverable.
303
+ */
304
+ export interface AgentLoopHooks {
305
+ /** Stream one assistant response (careful retry + overflow + usage staging). */
306
+ streamAssistant(route: Route, run: LoopRun): Promise<AssistantTurn>;
307
+ /** Execute the assistant's tool calls: consecutive concurrency-safe calls run
308
+ * in a bounded parallel batch, any unsafe call serially, submission order
309
+ * preserved. Returns the `tool` messages + whether the model signalled
310
+ * terminate. */
311
+ executeToolBatch(calls: ToolCallRequest[], token: CancellationToken, turnId: string): Promise<{
312
+ messages: Message[];
313
+ terminate: boolean;
314
+ }>;
315
+ /** Iteration-boundary injections: steering the user queued mid-turn + bg-task
316
+ * notifications that completed mid-turn (peek-not-drain; ids recorded for the
317
+ * post-persist ack). pi `getSteeringMessages`. */
318
+ getBoundaryMessages(injectedNotifIds: Set<string>, injectedSteerIds: string[]): Message[];
319
+ /** When the model returned NO tool calls: a `user`-role reminder to finish
320
+ * open todos (loop continues) or `null` to let the turn resolve. The inverse
321
+ * of pi's `shouldStopAfterTurn`. */
322
+ incompleteTodoReminder(count: number): Message | null;
323
+ }
208
324
  /**
209
325
  * Mediator over ai/session/tools/memory. Depends only on interfaces (ports), so
210
326
  * any ProviderAdapter or Tool plugs in unchanged. Communicates outward purely by
@@ -220,6 +336,26 @@ export declare class AgentEngine {
220
336
  * copy) is intentional: writes must propagate back.
221
337
  */
222
338
  getSelection(): ModelSelection;
339
+ /**
340
+ * (7.7 §4) Queue a user steering message to be injected at the next turn
341
+ * boundary of the in-flight turn (or the top of the next turn if idle). A
342
+ * no-op when no `steering` queue was provided. The CLI / serve driver call
343
+ * this on a submit-while-busy instead of rejecting the input.
344
+ */
345
+ enqueueSteering(text: string): void;
346
+ /** (7.7 §4) Peek the steering queue for entries not yet injected this turn,
347
+ * render each as a user message, and append its id to `injectedSteerIds` for
348
+ * post-persist ack. Peek-not-drain: a cancelled turn re-delivers. */
349
+ private drainSteering;
350
+ /** (7.7 §4) Iteration-boundary drain: background-task notifications that
351
+ * arrived mid-turn (combined render, same as turn-top) PLUS steering. Both
352
+ * peek-not-drain; ids recorded for post-persist ack. */
353
+ private drainBoundaryInjections;
354
+ /** (7.7 §5.3) Build an incomplete-todos reminder when the model stopped with
355
+ * open (pending/in_progress) todos and the per-turn cap isn't exhausted.
356
+ * Returns a `user`-role system-reminder message (no `developer` role exists),
357
+ * or null to let the turn resolve. */
358
+ private maybeTodoReminder;
223
359
  /** Bus-emit wrapper. Three responsibilities (3.4):
224
360
  * 1. Suppress lifecycle frames (`turn:*`, `error`) when the engine is a
225
361
  * child (`suppressLifecycleEvents=true`). Codex Round-1 MUST-FIX #2.
@@ -233,6 +369,64 @@ export declare class AgentEngine {
233
369
  trustedContext?: string;
234
370
  }): Promise<AgentResult>;
235
371
  private runTurnImpl;
372
+ /**
373
+ * (7.7 §3.8) The hook-driven turn loop — a thin orchestrator over
374
+ * {@link AgentLoopHooks}, mirroring pi's `runLoop`
375
+ * (`packages/agent/src/agent-loop.ts`). Each iteration streams one assistant
376
+ * response, executes its tool batch, then drains boundary injections (steering
377
+ * + mid-turn notifications) before the next stream. Returns whether the turn
378
+ * reached a final answer (`resolved`) or exhausted `maxTurns`.
379
+ *
380
+ * Behaviour is IDENTICAL to the pre-refactor inline loop — `defaultLoopHooks`
381
+ * binds the same units; the seam exists so task 08's coordinator can inject
382
+ * alternatives without copying this body.
383
+ */
384
+ protected runAgentLoop(run: LoopRun, hooks: AgentLoopHooks): Promise<{
385
+ resolved: boolean;
386
+ }>;
387
+ /**
388
+ * (7.7 §3.8) The default loop hooks — an object binding the engine's own
389
+ * units. An object (not the methods passed directly) so the shape is a
390
+ * documented, swappable seam: task 08 supplies alternatives; a test can wrap a
391
+ * single hook to assert the loop dispatches through it.
392
+ */
393
+ protected defaultLoopHooks(): AgentLoopHooks;
394
+ /**
395
+ * (7.7 §3.8) Stream ONE assistant response — the careful inner unit (pi
396
+ * `streamAssistantResponse`). Owns: per-attempt classified retry with backoff,
397
+ * attempt-local usage staging (a discarded retry never double-counts),
398
+ * `assistant:reset` partial-undo, and provider-agnostic overflow recovery on
399
+ * BOTH the terminal-error path (a 413 before the throw) and the success path
400
+ * (z.ai silent truncation / MiMo length-stop). Folds usage into `state.result`
401
+ * and records `state.lastRequestInputTokens` once the stream completes. Throws
402
+ * `AppError(Provider|Cancelled)` on a terminal failure; otherwise returns the
403
+ * streamed text + requested tool calls.
404
+ */
405
+ private streamAssistantResponse;
406
+ /**
407
+ * (7.7 §7) Provider-agnostic reactive overflow recovery, shared by the
408
+ * terminal-error path and the success path. When `signal` reads as a context
409
+ * overflow AND a compactor is wired AND we haven't already recovered this turn,
410
+ * compact with `reason: "overflow"` (bypasses the circuit breaker) and report
411
+ * whether the caller should restream. Telemetry-gated: a non-Anthropic recovery
412
+ * emits a `log info` so a wrong pattern surfaces as an observable event, not a
413
+ * silent loop. Fires AT MOST ONCE per turn.
414
+ */
415
+ private maybeRecoverFromOverflow;
416
+ /**
417
+ * (7.7 §3.3) Execute one assistant turn's tool calls. Partitions into
418
+ * batches (consecutive concurrency-safe → one parallel batch; any unsafe →
419
+ * its own serial batch), preserving submission order so a write is never
420
+ * reordered before a preceding read. Returns the `tool` messages in
421
+ * submission order plus whether the model signalled `terminate`.
422
+ *
423
+ * Cancellation is ALL-SETTLED: `runConcurrent` drains every thunk before it
424
+ * propagates, and `runTool` emits a `tool:result` on every path (success /
425
+ * denied / error / cancelled), so each emitted `tool:call` always has its
426
+ * paired result on the bus even when a sibling cancels (codex 7.7 R1
427
+ * MUST-FIX #3).
428
+ */
429
+ private executeToolBatch;
236
430
  private runTool;
237
431
  private composeSystem;
238
432
  }
@@ -266,4 +460,5 @@ export declare function renderTaskNotificationXml(n: TaskNotification): string;
266
460
  * skips the message entirely).
267
461
  */
268
462
  export declare function renderMcpResourcesXml(resolved: ResolvedMention[]): string;
463
+ export {};
269
464
  //# 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,gBAAgB,EAGrB,cAAc,EAGf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EAMjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAW,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,QAAQ,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,cAAc,C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