aura-code 0.6.3 → 0.10.1

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 (265) hide show
  1. package/README.md +47 -164
  2. package/dist/agent/affect.d.ts +13 -0
  3. package/dist/agent/affect.js +34 -0
  4. package/dist/agent/affect.js.map +1 -0
  5. package/dist/agent/compactor.d.ts +27 -4
  6. package/dist/agent/compactor.js +185 -54
  7. package/dist/agent/compactor.js.map +1 -1
  8. package/dist/agent/confess.d.ts +35 -0
  9. package/dist/agent/confess.js +296 -0
  10. package/dist/agent/confess.js.map +1 -0
  11. package/dist/agent/context.d.ts +0 -4
  12. package/dist/agent/context.js +0 -38
  13. package/dist/agent/context.js.map +1 -1
  14. package/dist/agent/domain-expertise.d.ts +22 -0
  15. package/dist/agent/domain-expertise.js +110 -0
  16. package/dist/agent/domain-expertise.js.map +1 -0
  17. package/dist/agent/executive-queue.d.ts +26 -0
  18. package/dist/agent/executive-queue.js +50 -0
  19. package/dist/agent/executive-queue.js.map +1 -0
  20. package/dist/agent/generational-flush.d.ts +28 -0
  21. package/dist/agent/generational-flush.js +48 -0
  22. package/dist/agent/generational-flush.js.map +1 -0
  23. package/dist/agent/loop-profile.d.ts +50 -0
  24. package/dist/agent/loop-profile.js +88 -0
  25. package/dist/agent/loop-profile.js.map +1 -0
  26. package/dist/agent/loop.d.ts +14 -5
  27. package/dist/agent/loop.js +167 -39
  28. package/dist/agent/loop.js.map +1 -1
  29. package/dist/agent/memory-consolidate.d.ts +14 -0
  30. package/dist/agent/memory-consolidate.js +141 -0
  31. package/dist/agent/memory-consolidate.js.map +1 -0
  32. package/dist/agent/mixture.d.ts +33 -0
  33. package/dist/agent/mixture.js +138 -0
  34. package/dist/agent/mixture.js.map +1 -0
  35. package/dist/agent/spawner.js +2 -2
  36. package/dist/agent/spawner.js.map +1 -1
  37. package/dist/agent/system-prompt.d.ts +1 -1
  38. package/dist/agent/system-prompt.js +50 -22
  39. package/dist/agent/system-prompt.js.map +1 -1
  40. package/dist/agent/unified-memory.d.ts +15 -0
  41. package/dist/agent/unified-memory.js +164 -0
  42. package/dist/agent/unified-memory.js.map +1 -0
  43. package/dist/checkpoints/engine.d.ts +44 -0
  44. package/dist/checkpoints/engine.js +324 -0
  45. package/dist/checkpoints/engine.js.map +1 -0
  46. package/dist/cli/command-palette.d.ts +26 -0
  47. package/dist/cli/command-palette.js +133 -0
  48. package/dist/cli/command-palette.js.map +1 -0
  49. package/dist/cli/context-health.d.ts +51 -0
  50. package/dist/cli/context-health.js +187 -0
  51. package/dist/cli/context-health.js.map +1 -0
  52. package/dist/cli/diamond.d.ts +67 -0
  53. package/dist/cli/diamond.js +222 -12
  54. package/dist/cli/diamond.js.map +1 -1
  55. package/dist/cli/dic.d.ts +2 -0
  56. package/dist/cli/dic.js +106 -0
  57. package/dist/cli/dic.js.map +1 -0
  58. package/dist/cli/diff-view.d.ts +18 -0
  59. package/dist/cli/diff-view.js +114 -0
  60. package/dist/cli/diff-view.js.map +1 -0
  61. package/dist/cli/display.d.ts +18 -4
  62. package/dist/cli/display.js +74 -151
  63. package/dist/cli/display.js.map +1 -1
  64. package/dist/cli/help-data.d.ts +7 -0
  65. package/dist/cli/help-data.js +80 -0
  66. package/dist/cli/help-data.js.map +1 -0
  67. package/dist/cli/index.js +1002 -852
  68. package/dist/cli/index.js.map +1 -1
  69. package/dist/cli/markdown.d.ts +5 -0
  70. package/dist/cli/markdown.js +128 -0
  71. package/dist/cli/markdown.js.map +1 -0
  72. package/dist/cli/model-select.d.ts +39 -0
  73. package/dist/cli/model-select.js +65 -0
  74. package/dist/cli/model-select.js.map +1 -0
  75. package/dist/cli/tui.d.ts +34 -0
  76. package/dist/cli/tui.js +1176 -0
  77. package/dist/cli/tui.js.map +1 -0
  78. package/dist/config/defaults.d.ts +6 -17
  79. package/dist/config/defaults.js +25 -46
  80. package/dist/config/defaults.js.map +1 -1
  81. package/dist/config/project-config.d.ts +2 -6
  82. package/dist/config/project-config.js +2 -2
  83. package/dist/config/project-config.js.map +1 -1
  84. package/dist/doctor/checks.d.ts +18 -0
  85. package/dist/doctor/checks.js +524 -0
  86. package/dist/doctor/checks.js.map +1 -0
  87. package/dist/doctor/index.d.ts +4 -0
  88. package/dist/doctor/index.js +229 -0
  89. package/dist/doctor/index.js.map +1 -0
  90. package/dist/doctor/repair.d.ts +19 -0
  91. package/dist/doctor/repair.js +126 -0
  92. package/dist/doctor/repair.js.map +1 -0
  93. package/dist/doctor/types.d.ts +38 -0
  94. package/dist/doctor/types.js +10 -0
  95. package/dist/doctor/types.js.map +1 -0
  96. package/dist/dream/dream.d.ts +79 -59
  97. package/dist/dream/dream.js +324 -144
  98. package/dist/dream/dream.js.map +1 -1
  99. package/dist/dream/episode.d.ts +17 -0
  100. package/dist/dream/episode.js +116 -0
  101. package/dist/dream/episode.js.map +1 -0
  102. package/dist/kanban/engine.d.ts +26 -0
  103. package/dist/kanban/engine.js +208 -0
  104. package/dist/kanban/engine.js.map +1 -0
  105. package/dist/kanban/types.d.ts +19 -0
  106. package/dist/kanban/types.js +9 -1
  107. package/dist/kanban/types.js.map +1 -1
  108. package/dist/machina/render-html.js +4 -2
  109. package/dist/machina/render-html.js.map +1 -1
  110. package/dist/machina/render-terminal.js +11 -4
  111. package/dist/machina/render-terminal.js.map +1 -1
  112. package/dist/machina/repair.d.ts +23 -0
  113. package/dist/machina/repair.js +98 -0
  114. package/dist/machina/repair.js.map +1 -0
  115. package/dist/machina/spec.js +12 -12
  116. package/dist/machina/spec.js.map +1 -1
  117. package/dist/machina/verify.d.ts +13 -1
  118. package/dist/machina/verify.js +12 -2
  119. package/dist/machina/verify.js.map +1 -1
  120. package/dist/mining/extract.d.ts +34 -0
  121. package/dist/mining/extract.js +229 -0
  122. package/dist/mining/extract.js.map +1 -0
  123. package/dist/mining/refine.d.ts +28 -0
  124. package/dist/mining/refine.js +256 -0
  125. package/dist/mining/refine.js.map +1 -0
  126. package/dist/perception/extractor.js +5 -3
  127. package/dist/perception/extractor.js.map +1 -1
  128. package/dist/perception/graph-store.d.ts +0 -11
  129. package/dist/perception/graph-store.js +0 -33
  130. package/dist/perception/graph-store.js.map +1 -1
  131. package/dist/perception/index.d.ts +1 -1
  132. package/dist/perception/index.js +1 -2
  133. package/dist/perception/index.js.map +1 -1
  134. package/dist/plugins/commands.d.ts +38 -0
  135. package/dist/plugins/commands.js +134 -0
  136. package/dist/plugins/commands.js.map +1 -0
  137. package/dist/plugins/frontmatter.d.ts +14 -0
  138. package/dist/plugins/frontmatter.js +78 -0
  139. package/dist/plugins/frontmatter.js.map +1 -0
  140. package/dist/plugins/hooks.d.ts +12 -0
  141. package/dist/plugins/hooks.js +148 -0
  142. package/dist/plugins/hooks.js.map +1 -0
  143. package/dist/plugins/loader.d.ts +7 -0
  144. package/dist/plugins/loader.js +255 -0
  145. package/dist/plugins/loader.js.map +1 -0
  146. package/dist/plugins/market.d.ts +23 -0
  147. package/dist/plugins/market.js +281 -0
  148. package/dist/plugins/market.js.map +1 -0
  149. package/dist/plugins/types.d.ts +90 -0
  150. package/dist/plugins/types.js +20 -0
  151. package/dist/plugins/types.js.map +1 -0
  152. package/dist/providers/anthropic-oauth-draft.d.ts +119 -0
  153. package/dist/providers/anthropic-oauth-draft.js +414 -0
  154. package/dist/providers/anthropic-oauth-draft.js.map +1 -0
  155. package/dist/providers/anthropic.d.ts +4 -1
  156. package/dist/providers/anthropic.js +35 -7
  157. package/dist/providers/anthropic.js.map +1 -1
  158. package/dist/providers/factory.d.ts +43 -19
  159. package/dist/providers/factory.js +183 -129
  160. package/dist/providers/factory.js.map +1 -1
  161. package/dist/providers/google.js +9 -22
  162. package/dist/providers/google.js.map +1 -1
  163. package/dist/providers/live-models.d.ts +23 -0
  164. package/dist/providers/live-models.js +145 -0
  165. package/dist/providers/live-models.js.map +1 -0
  166. package/dist/providers/openai-compatible.d.ts +1 -12
  167. package/dist/providers/openai-compatible.js +71 -108
  168. package/dist/providers/openai-compatible.js.map +1 -1
  169. package/dist/providers/resilient-factory.js +1 -1
  170. package/dist/providers/resilient-factory.js.map +1 -1
  171. package/dist/repl/queue.d.ts +22 -0
  172. package/dist/repl/queue.js +165 -0
  173. package/dist/repl/queue.js.map +1 -0
  174. package/dist/repl/side-channel.d.ts +23 -0
  175. package/dist/repl/side-channel.js +63 -0
  176. package/dist/repl/side-channel.js.map +1 -0
  177. package/dist/research/council.d.ts +2 -0
  178. package/dist/research/council.js +29 -4
  179. package/dist/research/council.js.map +1 -1
  180. package/dist/ruby/alternator.d.ts +11 -30
  181. package/dist/ruby/alternator.js +59 -38
  182. package/dist/ruby/alternator.js.map +1 -1
  183. package/dist/ruby/episode-capture.d.ts +0 -10
  184. package/dist/ruby/episode-capture.js +0 -33
  185. package/dist/ruby/episode-capture.js.map +1 -1
  186. package/dist/ruby/types.js +1 -1
  187. package/dist/ruby/types.js.map +1 -1
  188. package/dist/safety/path-jail.d.ts +17 -0
  189. package/dist/safety/path-jail.js +100 -0
  190. package/dist/safety/path-jail.js.map +1 -0
  191. package/dist/safety/permissions.d.ts +12 -21
  192. package/dist/safety/permissions.js +81 -216
  193. package/dist/safety/permissions.js.map +1 -1
  194. package/dist/safety/ssrf.d.ts +29 -0
  195. package/dist/safety/ssrf.js +185 -0
  196. package/dist/safety/ssrf.js.map +1 -0
  197. package/dist/server/index.js +64 -10
  198. package/dist/server/index.js.map +1 -1
  199. package/dist/setup/first-run.d.ts +0 -24
  200. package/dist/setup/first-run.js +10 -344
  201. package/dist/setup/first-run.js.map +1 -1
  202. package/dist/setup/key-store.d.ts +12 -0
  203. package/dist/setup/key-store.js +108 -0
  204. package/dist/setup/key-store.js.map +1 -0
  205. package/dist/setup/provider-registry.js +31 -18
  206. package/dist/setup/provider-registry.js.map +1 -1
  207. package/dist/setup/provider-test.d.ts +7 -0
  208. package/dist/setup/provider-test.js +73 -10
  209. package/dist/setup/provider-test.js.map +1 -1
  210. package/dist/setup/provider-wizard.d.ts +4 -1
  211. package/dist/setup/provider-wizard.js +92 -26
  212. package/dist/setup/provider-wizard.js.map +1 -1
  213. package/dist/setup/xiaomi.d.ts +1 -1
  214. package/dist/setup/xiaomi.js +3 -3
  215. package/dist/setup/xiaomi.js.map +1 -1
  216. package/dist/tools/browser.js +14 -10
  217. package/dist/tools/browser.js.map +1 -1
  218. package/dist/tools/clipboard.js +7 -1
  219. package/dist/tools/clipboard.js.map +1 -1
  220. package/dist/tools/dictate.d.ts +60 -0
  221. package/dist/tools/dictate.js +983 -0
  222. package/dist/tools/dictate.js.map +1 -0
  223. package/dist/tools/dictate_patched.js +1057 -0
  224. package/dist/tools/edit-file.js +10 -2
  225. package/dist/tools/edit-file.js.map +1 -1
  226. package/dist/tools/http-request.js +14 -4
  227. package/dist/tools/http-request.js.map +1 -1
  228. package/dist/tools/image-read.js +34 -2
  229. package/dist/tools/image-read.js.map +1 -1
  230. package/dist/tools/index.d.ts +16 -1
  231. package/dist/tools/index.js +59 -8
  232. package/dist/tools/index.js.map +1 -1
  233. package/dist/tools/mcp.js +12 -0
  234. package/dist/tools/mcp.js.map +1 -1
  235. package/dist/tools/read-file.js +10 -14
  236. package/dist/tools/read-file.js.map +1 -1
  237. package/dist/tools/telegram-audio-policy.d.ts +30 -0
  238. package/dist/tools/telegram-audio-policy.js +49 -0
  239. package/dist/tools/telegram-audio-policy.js.map +1 -0
  240. package/dist/tools/telegram-bot.js +1136 -537
  241. package/dist/tools/telegram-bot.js.map +1 -1
  242. package/dist/tools/telegram-voice.d.ts +18 -5
  243. package/dist/tools/telegram-voice.js +54 -12
  244. package/dist/tools/telegram-voice.js.map +1 -1
  245. package/dist/tools/telegram.d.ts +3 -3
  246. package/dist/tools/telegram.js +5 -84
  247. package/dist/tools/telegram.js.map +1 -1
  248. package/dist/tools/tools.d.ts +2 -14
  249. package/dist/tools/tools.js +79 -144
  250. package/dist/tools/tools.js.map +1 -1
  251. package/dist/tools/web-fetch.js +39 -7
  252. package/dist/tools/web-fetch.js.map +1 -1
  253. package/dist/tools/web-search.d.ts +0 -20
  254. package/dist/tools/web-search.js +40 -137
  255. package/dist/tools/web-search.js.map +1 -1
  256. package/dist/util/errors.js +1 -15
  257. package/dist/util/errors.js.map +1 -1
  258. package/dist/util/json-repair.d.ts +11 -0
  259. package/dist/util/json-repair.js +31 -0
  260. package/dist/util/json-repair.js.map +1 -0
  261. package/dist/util/rate-limiter.js +2 -8
  262. package/dist/util/rate-limiter.js.map +1 -1
  263. package/dist/viz/index.js +793 -792
  264. package/dist/viz/index.js.map +1 -1
  265. package/package.json +12 -32
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Executive queue — a bounded record of recent state-altering tool calls.
3
+ *
4
+ * When history is compacted, the model loses the verbatim record of what it
5
+ * already executed; this queue's digest is injected into the compaction recap
6
+ * so the model never repeats a write/edit/shell command it already ran.
7
+ * Deliberately bounded (not an exhaustive ledger): only the most recent
8
+ * mutations matter for "don't repeat yourself", and a cap keeps the recap
9
+ * payload and state complexity flat.
10
+ */
11
+ /** Tools that can change the working tree — the checkpoint trigger set. */
12
+ export declare const MUTATING_TOOLS: Set<string>;
13
+ export declare const EXECUTIVE_QUEUE_MAX = 20;
14
+ export interface ExecutiveEntry {
15
+ name: string;
16
+ summary: string;
17
+ turn: number;
18
+ }
19
+ export declare class ExecutiveQueue {
20
+ private entries;
21
+ /** Record a call if it's state-altering; evicts the oldest past the cap. */
22
+ push(name: string, input: Record<string, unknown>, turn: number): void;
23
+ get size(): number;
24
+ /** Digest for the compaction recap; newest last. Empty string when empty. */
25
+ digest(): string;
26
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * Executive queue — a bounded record of recent state-altering tool calls.
4
+ *
5
+ * When history is compacted, the model loses the verbatim record of what it
6
+ * already executed; this queue's digest is injected into the compaction recap
7
+ * so the model never repeats a write/edit/shell command it already ran.
8
+ * Deliberately bounded (not an exhaustive ledger): only the most recent
9
+ * mutations matter for "don't repeat yourself", and a cap keeps the recap
10
+ * payload and state complexity flat.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ExecutiveQueue = exports.EXECUTIVE_QUEUE_MAX = exports.MUTATING_TOOLS = void 0;
14
+ /** Tools that can change the working tree — the checkpoint trigger set. */
15
+ exports.MUTATING_TOOLS = new Set(['write_file', 'edit_file', 'run_shell']);
16
+ exports.EXECUTIVE_QUEUE_MAX = 20;
17
+ /** One-line summary of a call, mirroring how confirmations render them. */
18
+ function summarise(name, input) {
19
+ if (name === 'run_shell') {
20
+ const cmd = String(input.command ?? '');
21
+ return cmd.length > 100 ? `${cmd.slice(0, 100)}…` : cmd;
22
+ }
23
+ return String(input.path ?? input.file_path ?? '(unknown target)');
24
+ }
25
+ class ExecutiveQueue {
26
+ entries = [];
27
+ /** Record a call if it's state-altering; evicts the oldest past the cap. */
28
+ push(name, input, turn) {
29
+ if (!exports.MUTATING_TOOLS.has(name))
30
+ return;
31
+ this.entries.push({ name, summary: summarise(name, input), turn });
32
+ if (this.entries.length > exports.EXECUTIVE_QUEUE_MAX)
33
+ this.entries.shift();
34
+ }
35
+ get size() {
36
+ return this.entries.length;
37
+ }
38
+ /** Digest for the compaction recap; newest last. Empty string when empty. */
39
+ digest() {
40
+ if (this.entries.length === 0)
41
+ return '';
42
+ const lines = this.entries.map(e => e.name === 'run_shell' ? `run_shell: ${e.summary}` : `${e.name} ${e.summary}`);
43
+ return [
44
+ 'Recent state-altering actions already executed (do not repeat):',
45
+ ...lines,
46
+ ].join('\n');
47
+ }
48
+ }
49
+ exports.ExecutiveQueue = ExecutiveQueue;
50
+ //# sourceMappingURL=executive-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executive-queue.js","sourceRoot":"","sources":["../../src/agent/executive-queue.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,2EAA2E;AAC9D,QAAA,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AAEnE,QAAA,mBAAmB,GAAG,EAA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,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAC9E,CAAC;QACF,OAAO;YACL,iEAAiE;YACjE,GAAG,KAAK;SACT,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF;AAzBD,wCAyBC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Generational rollover — the "new context window" step. In-place recap
3
+ * compaction (compactor.ts) can only escalate its trigger threshold so far
4
+ * (ROLLOVER_AT_GENERATION) before recompacting a recap starts destroying
5
+ * information no heuristic can recover cheaply. At that point, flush the
6
+ * whole recap through one LLM call — the same distillation primitive the
7
+ * cross-session dream pipeline uses (src/dream/dream.ts) — into the dream
8
+ * store, and replace it with a short pointer. This is "distill, don't
9
+ * discard" applied mid-session instead of only at process exit, and it
10
+ * means the flushed content is automatically picked up by the normal
11
+ * cross-session runReconciliation() pass alongside end-of-session dreams.
12
+ */
13
+ import type { HistoryMessage, LLMProvider } from '../providers/types.js';
14
+ export interface RolloverResult {
15
+ flushed: boolean;
16
+ flushPath?: string;
17
+ }
18
+ /**
19
+ * Flush the current recap to the dream store and replace it in `history`
20
+ * with a pointer line + a freshly regenerated executive digest and affect
21
+ * hint (never the old recap's text — that's what's being flushed). Mutates
22
+ * `history` in place, matching compactHistory's contract. No-ops if there's
23
+ * no recap to flush.
24
+ */
25
+ export declare function maybeRollover(history: HistoryMessage[], sessionRoot: string, provider: LLMProvider, extras?: {
26
+ executiveDigest?: string;
27
+ affectHint?: string;
28
+ }): Promise<RolloverResult>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maybeRollover = maybeRollover;
4
+ const compactor_js_1 = require("./compactor.js");
5
+ const dream_js_1 = require("../dream/dream.js");
6
+ const FLUSH_SYSTEM = [
7
+ 'You distill an in-progress coding session\'s compacted history into durable memory bullets.',
8
+ 'Write ONLY markdown bullet points, one per line, each starting with "- ".',
9
+ 'Each bullet must be a concrete, standalone fact: a decision made, a file touched, a root cause found, or an unresolved thread.',
10
+ 'Be specific — file names, exact behavior, not generic advice. No headers, no prose paragraphs.',
11
+ ].join(' ');
12
+ /** Per-process counter for sessionFlushFile's uniqueness suffix. */
13
+ let flushSeq = 0;
14
+ /**
15
+ * Flush the current recap to the dream store and replace it in `history`
16
+ * with a pointer line + a freshly regenerated executive digest and affect
17
+ * hint (never the old recap's text — that's what's being flushed). Mutates
18
+ * `history` in place, matching compactHistory's contract. No-ops if there's
19
+ * no recap to flush.
20
+ */
21
+ async function maybeRollover(history, sessionRoot, provider, extras = {}) {
22
+ const recapIndex = (0, compactor_js_1.findRecapIndex)(history);
23
+ if (recapIndex === -1)
24
+ return { flushed: false };
25
+ const recap = history[recapIndex];
26
+ flushSeq++;
27
+ const flushPath = (0, dream_js_1.sessionFlushFile)(sessionRoot, flushSeq);
28
+ await (0, dream_js_1.distillText)({
29
+ systemPrompt: FLUSH_SYSTEM,
30
+ userContent: recap.content,
31
+ provider,
32
+ outPath: flushPath,
33
+ });
34
+ const pointer = {
35
+ role: 'assistant',
36
+ content: [
37
+ `[Session context flushed to memory (${flushPath}) — continuing with a fresh context window.]`,
38
+ ...(extras.affectHint ? [extras.affectHint] : []),
39
+ ...(extras.executiveDigest ? ['', extras.executiveDigest] : []),
40
+ ].join('\n'),
41
+ };
42
+ // Note: the pointer's content deliberately does NOT start with compactor's
43
+ // RECAP_MARKER, so getRecapGeneration(history) reads back to 0 next time —
44
+ // this message is ordinary content from here on, not a growing recap.
45
+ history.splice(recapIndex, 1, pointer);
46
+ return { flushed: true, flushPath };
47
+ }
48
+ //# sourceMappingURL=generational-flush.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generational-flush.js","sourceRoot":"","sources":["../../src/agent/generational-flush.ts"],"names":[],"mappings":";;AAsCA,sCAmCC;AA5DD,iDAAgD;AAChD,gDAAkE;AAElE,MAAM,YAAY,GAAG;IACnB,6FAA6F;IAC7F,2EA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SAAS,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Task classification for turn-budget sizing.
3
+ *
4
+ * Cheap heuristics only — no LLM call. Spending a model turn to decide
5
+ * how many turns to allow defeats the purpose. This is pattern matching
6
+ * on the task string, nothing more.
7
+ */
8
+ export type TaskShape = 'single-file' | 'multi-file' | 'exploratory';
9
+ export interface LoopProfile {
10
+ maxTurns: number;
11
+ shape: TaskShape;
12
+ /** How many identical consecutive turn-signatures count as a stall. */
13
+ stallThreshold: number;
14
+ /**
15
+ * One-time budget upgrade: if the run hits maxTurns while still making
16
+ * progress (not stalled), widen once to this ceiling instead of ending
17
+ * with a resume hint. Absent for shapes already at the top tier and
18
+ * whenever the user passed an explicit --max-turns (a hard ceiling).
19
+ */
20
+ widenTo?: number;
21
+ }
22
+ /**
23
+ * Classify a task string into a rough shape. Defaults to 'single-file'
24
+ * when nothing matches — the common case (fix X, add Y to file Z).
25
+ */
26
+ export declare function classifyTask(task: string): TaskShape;
27
+ /**
28
+ * Get the loop profile for a task.
29
+ *
30
+ * @param task The task prompt.
31
+ * @param override Explicit maxTurns from CLI flag or config — always wins,
32
+ * and is a hard ceiling (no adaptive widening past it).
33
+ */
34
+ export declare function getLoopProfile(task: string, override?: number): LoopProfile;
35
+ export type StallKind = 'repeat' | 'cycle';
36
+ /**
37
+ * Detect a stalled run from the sequence of per-turn tool-call signatures.
38
+ *
39
+ * - 'repeat': the last `threshold` signatures are identical (A A A) — the
40
+ * agent retrying the same call verbatim.
41
+ * - 'cycle': the last `2 * threshold` signatures alternate between two
42
+ * distinct signatures (A B A B A B) — the agent bouncing between two
43
+ * equally-wrong edits. Requires `threshold` full repetitions of the pair,
44
+ * so it is strictly harder to trigger than 'repeat'.
45
+ *
46
+ * Exact-match only, deliberately conservative: a false stop on a run that
47
+ * was making slow progress is worse than a few wasted turns, since a human
48
+ * can always resume a stopped session.
49
+ */
50
+ export declare function detectStall(signatures: string[], threshold: number): StallKind | null;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * Task classification for turn-budget sizing.
4
+ *
5
+ * Cheap heuristics only — no LLM call. Spending a model turn to decide
6
+ * how many turns to allow defeats the purpose. This is pattern matching
7
+ * on the task string, nothing more.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.classifyTask = classifyTask;
11
+ exports.getLoopProfile = getLoopProfile;
12
+ exports.detectStall = detectStall;
13
+ const MULTI_FILE_SIGNALS = [
14
+ 'all endpoints', 'every file', 'across the', 'throughout the',
15
+ 'all files', 'each file', 'entire codebase', 'orchestrate',
16
+ ];
17
+ const EXPLORATORY_SIGNALS = [
18
+ 'explain', 'analyze', 'investigate', 'research', 'understand',
19
+ 'why does', 'why is', 'how does', 'what causes', 'diagnose',
20
+ ];
21
+ /**
22
+ * Classify a task string into a rough shape. Defaults to 'single-file'
23
+ * when nothing matches — the common case (fix X, add Y to file Z).
24
+ */
25
+ function classifyTask(task) {
26
+ const lower = task.toLowerCase();
27
+ if (MULTI_FILE_SIGNALS.some((s) => lower.includes(s))) {
28
+ return 'multi-file';
29
+ }
30
+ if (EXPLORATORY_SIGNALS.some((s) => lower.includes(s))) {
31
+ return 'exploratory';
32
+ }
33
+ return 'single-file';
34
+ }
35
+ const PROFILES = {
36
+ 'single-file': { maxTurns: 30, stallThreshold: 3, widenTo: 80 },
37
+ 'multi-file': { maxTurns: 150, stallThreshold: 4 },
38
+ 'exploratory': { maxTurns: 80, stallThreshold: 4 },
39
+ };
40
+ /**
41
+ * Get the loop profile for a task.
42
+ *
43
+ * @param task The task prompt.
44
+ * @param override Explicit maxTurns from CLI flag or config — always wins,
45
+ * and is a hard ceiling (no adaptive widening past it).
46
+ */
47
+ function getLoopProfile(task, override) {
48
+ const shape = classifyTask(task);
49
+ const base = PROFILES[shape];
50
+ if (override !== undefined) {
51
+ return { shape, maxTurns: override, stallThreshold: base.stallThreshold };
52
+ }
53
+ return {
54
+ shape,
55
+ maxTurns: base.maxTurns,
56
+ stallThreshold: base.stallThreshold,
57
+ widenTo: base.widenTo,
58
+ };
59
+ }
60
+ /**
61
+ * Detect a stalled run from the sequence of per-turn tool-call signatures.
62
+ *
63
+ * - 'repeat': the last `threshold` signatures are identical (A A A) — the
64
+ * agent retrying the same call verbatim.
65
+ * - 'cycle': the last `2 * threshold` signatures alternate between two
66
+ * distinct signatures (A B A B A B) — the agent bouncing between two
67
+ * equally-wrong edits. Requires `threshold` full repetitions of the pair,
68
+ * so it is strictly harder to trigger than 'repeat'.
69
+ *
70
+ * Exact-match only, deliberately conservative: a false stop on a run that
71
+ * was making slow progress is worse than a few wasted turns, since a human
72
+ * can always resume a stopped session.
73
+ */
74
+ function detectStall(signatures, threshold) {
75
+ const tail = signatures.slice(-threshold);
76
+ if (tail.length === threshold && tail.every((s) => s === tail[0])) {
77
+ return 'repeat';
78
+ }
79
+ const pairTail = signatures.slice(-2 * threshold);
80
+ if (pairTail.length === 2 * threshold) {
81
+ const [a, b] = pairTail;
82
+ if (a !== b && pairTail.every((s, i) => s === (i % 2 === 0 ? a : b))) {
83
+ return 'cycle';
84
+ }
85
+ }
86
+ return null;
87
+ }
88
+ //# sourceMappingURL=loop-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop-profile.js","sourceRoot":"","sources":["../../src/agent/loop-profile.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAgCH,oCAUC;AAeD,wCAaC;AAkBD,kCAcC;AApFD,MAAM,kBAAkB,GAAG;IACzB,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB;IAC7D,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa;CAC3D,CAAC;AAEF,MAAM,mBAAmB,GAAG;IAC1B,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY;IAC7D,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU;CAC5D,CAAC;AAEF;;;GAGG;AACH,SAAgB,YA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AW,CAAC,UAAoB,EAAE,SAAiB;IACjE,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAClD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,GAAG,SAAS,EAAE,CAAC;QACtC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -25,12 +25,20 @@ export interface LoopOptions {
25
25
  disableSpawn?: boolean;
26
26
  /** Internal: skip post-task verification (used by runWithVerification wrapper). */
27
27
  verify?: boolean;
28
- /**
29
- * Custom confirmation function for destructive operations.
30
- * Defaults to terminal-based confirm() from permissions.
31
- * Telegram bot overrides this to send approval requests via Telegram messages.
32
- */
28
+ /** Shadow-git checkpoints before mutating tool calls (default: true; no-op outside a git repo). */
29
+ checkpoints?: boolean;
30
+ /** Plugin hooks fired around tool execution (PreToolUse can block). */
31
+ hooks?: import('../plugins/types.js').HookEntry[];
32
+ /** Optional abort signal — when aborted the loop stops after the current tool turn. */
33
+ abortSignal?: AbortSignal;
34
+ /** Confirmation prompt override for needs-confirm tool calls. Defaults to the
35
+ * terminal readline confirm — embedded callers (alternator, bots) supply
36
+ * their own so confirmation isn't silently impossible off-terminal. */
33
37
  confirmFn?: (message: string) => Promise<boolean>;
38
+ /** Optional shared context-health tracker (e.g. the REPL's). When omitted the
39
+ * loop creates an internal one. Passing it in lets a /context command read
40
+ * the accumulated compaction history and per-turn snapshots. */
41
+ healthTracker?: import('../cli/context-health.js').ContextHealthTracker;
34
42
  }
35
43
  export interface LoopResult {
36
44
  success: boolean;
@@ -52,6 +60,7 @@ export interface TokenUsage {
52
60
  outputTokens: number;
53
61
  totalTokens: number;
54
62
  }
63
+ export declare function costFor(model: string, input: number, output: number): number;
55
64
  export declare function runAgentLoop(opts: LoopOptions): Promise<LoopResult>;
56
65
  export declare function runAgentLoopVerified(opts: LoopOptions, config: VerificationConfig, projectRoot: string): Promise<{
57
66
  loopResult: LoopResult;