aura-code 0.6.3 → 0.10.2
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/README.md +47 -164
- package/dist/agent/affect.d.ts +13 -0
- package/dist/agent/affect.js +34 -0
- package/dist/agent/affect.js.map +1 -0
- package/dist/agent/compactor.d.ts +27 -4
- package/dist/agent/compactor.js +185 -54
- package/dist/agent/compactor.js.map +1 -1
- package/dist/agent/confess.d.ts +35 -0
- package/dist/agent/confess.js +296 -0
- package/dist/agent/confess.js.map +1 -0
- package/dist/agent/context.d.ts +0 -4
- package/dist/agent/context.js +0 -38
- package/dist/agent/context.js.map +1 -1
- package/dist/agent/domain-expertise.d.ts +22 -0
- package/dist/agent/domain-expertise.js +110 -0
- package/dist/agent/domain-expertise.js.map +1 -0
- package/dist/agent/executive-queue.d.ts +26 -0
- package/dist/agent/executive-queue.js +50 -0
- package/dist/agent/executive-queue.js.map +1 -0
- package/dist/agent/generational-flush.d.ts +28 -0
- package/dist/agent/generational-flush.js +48 -0
- package/dist/agent/generational-flush.js.map +1 -0
- package/dist/agent/loop-profile.d.ts +50 -0
- package/dist/agent/loop-profile.js +88 -0
- package/dist/agent/loop-profile.js.map +1 -0
- package/dist/agent/loop.d.ts +15 -5
- package/dist/agent/loop.js +182 -45
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/memory-consolidate.d.ts +14 -0
- package/dist/agent/memory-consolidate.js +141 -0
- package/dist/agent/memory-consolidate.js.map +1 -0
- package/dist/agent/mixture.d.ts +33 -0
- package/dist/agent/mixture.js +140 -0
- package/dist/agent/mixture.js.map +1 -0
- package/dist/agent/spawner.js +2 -2
- package/dist/agent/spawner.js.map +1 -1
- package/dist/agent/system-prompt.d.ts +1 -1
- package/dist/agent/system-prompt.js +50 -22
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/agent/unified-memory.d.ts +15 -0
- package/dist/agent/unified-memory.js +164 -0
- package/dist/agent/unified-memory.js.map +1 -0
- package/dist/checkpoints/engine.d.ts +44 -0
- package/dist/checkpoints/engine.js +324 -0
- package/dist/checkpoints/engine.js.map +1 -0
- package/dist/cli/command-palette.d.ts +26 -0
- package/dist/cli/command-palette.js +133 -0
- package/dist/cli/command-palette.js.map +1 -0
- package/dist/cli/context-health.d.ts +51 -0
- package/dist/cli/context-health.js +187 -0
- package/dist/cli/context-health.js.map +1 -0
- package/dist/cli/diamond.d.ts +67 -0
- package/dist/cli/diamond.js +222 -12
- package/dist/cli/diamond.js.map +1 -1
- package/dist/cli/dic.d.ts +2 -0
- package/dist/cli/dic.js +106 -0
- package/dist/cli/dic.js.map +1 -0
- package/dist/cli/diff-view.d.ts +18 -0
- package/dist/cli/diff-view.js +114 -0
- package/dist/cli/diff-view.js.map +1 -0
- package/dist/cli/display.d.ts +20 -4
- package/dist/cli/display.js +77 -151
- package/dist/cli/display.js.map +1 -1
- package/dist/cli/help-data.d.ts +7 -0
- package/dist/cli/help-data.js +80 -0
- package/dist/cli/help-data.js.map +1 -0
- package/dist/cli/index.js +1018 -851
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/markdown.d.ts +5 -0
- package/dist/cli/markdown.js +128 -0
- package/dist/cli/markdown.js.map +1 -0
- package/dist/cli/model-select.d.ts +39 -0
- package/dist/cli/model-select.js +65 -0
- package/dist/cli/model-select.js.map +1 -0
- package/dist/cli/tui.d.ts +34 -0
- package/dist/cli/tui.js +1190 -0
- package/dist/cli/tui.js.map +1 -0
- package/dist/config/defaults.d.ts +6 -17
- package/dist/config/defaults.js +25 -46
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/project-config.d.ts +2 -6
- package/dist/config/project-config.js +2 -2
- package/dist/config/project-config.js.map +1 -1
- package/dist/doctor/checks.d.ts +18 -0
- package/dist/doctor/checks.js +524 -0
- package/dist/doctor/checks.js.map +1 -0
- package/dist/doctor/index.d.ts +4 -0
- package/dist/doctor/index.js +229 -0
- package/dist/doctor/index.js.map +1 -0
- package/dist/doctor/repair.d.ts +19 -0
- package/dist/doctor/repair.js +126 -0
- package/dist/doctor/repair.js.map +1 -0
- package/dist/doctor/types.d.ts +38 -0
- package/dist/doctor/types.js +10 -0
- package/dist/doctor/types.js.map +1 -0
- package/dist/dream/dream.d.ts +79 -59
- package/dist/dream/dream.js +324 -144
- package/dist/dream/dream.js.map +1 -1
- package/dist/dream/episode.d.ts +17 -0
- package/dist/dream/episode.js +116 -0
- package/dist/dream/episode.js.map +1 -0
- package/dist/kanban/engine.d.ts +26 -0
- package/dist/kanban/engine.js +208 -0
- package/dist/kanban/engine.js.map +1 -0
- package/dist/kanban/types.d.ts +19 -0
- package/dist/kanban/types.js +9 -1
- package/dist/kanban/types.js.map +1 -1
- package/dist/machina/render-html.js +4 -2
- package/dist/machina/render-html.js.map +1 -1
- package/dist/machina/render-terminal.js +11 -4
- package/dist/machina/render-terminal.js.map +1 -1
- package/dist/machina/repair.d.ts +23 -0
- package/dist/machina/repair.js +98 -0
- package/dist/machina/repair.js.map +1 -0
- package/dist/machina/spec.js +12 -12
- package/dist/machina/spec.js.map +1 -1
- package/dist/machina/verify.d.ts +13 -1
- package/dist/machina/verify.js +12 -2
- package/dist/machina/verify.js.map +1 -1
- package/dist/mining/extract.d.ts +34 -0
- package/dist/mining/extract.js +229 -0
- package/dist/mining/extract.js.map +1 -0
- package/dist/mining/refine.d.ts +28 -0
- package/dist/mining/refine.js +256 -0
- package/dist/mining/refine.js.map +1 -0
- package/dist/perception/extractor.js +5 -3
- package/dist/perception/extractor.js.map +1 -1
- package/dist/perception/graph-store.d.ts +0 -11
- package/dist/perception/graph-store.js +0 -33
- package/dist/perception/graph-store.js.map +1 -1
- package/dist/perception/index.d.ts +1 -1
- package/dist/perception/index.js +1 -2
- package/dist/perception/index.js.map +1 -1
- package/dist/plugins/commands.d.ts +38 -0
- package/dist/plugins/commands.js +134 -0
- package/dist/plugins/commands.js.map +1 -0
- package/dist/plugins/frontmatter.d.ts +14 -0
- package/dist/plugins/frontmatter.js +78 -0
- package/dist/plugins/frontmatter.js.map +1 -0
- package/dist/plugins/hooks.d.ts +12 -0
- package/dist/plugins/hooks.js +148 -0
- package/dist/plugins/hooks.js.map +1 -0
- package/dist/plugins/loader.d.ts +7 -0
- package/dist/plugins/loader.js +255 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/market.d.ts +23 -0
- package/dist/plugins/market.js +281 -0
- package/dist/plugins/market.js.map +1 -0
- package/dist/plugins/types.d.ts +90 -0
- package/dist/plugins/types.js +20 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/providers/anthropic-oauth-draft.d.ts +119 -0
- package/dist/providers/anthropic-oauth-draft.js +414 -0
- package/dist/providers/anthropic-oauth-draft.js.map +1 -0
- package/dist/providers/anthropic.d.ts +4 -1
- package/dist/providers/anthropic.js +35 -7
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/factory.d.ts +43 -19
- package/dist/providers/factory.js +183 -129
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/google.js +9 -22
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/live-models.d.ts +23 -0
- package/dist/providers/live-models.js +145 -0
- package/dist/providers/live-models.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +1 -12
- package/dist/providers/openai-compatible.js +92 -108
- package/dist/providers/openai-compatible.js.map +1 -1
- package/dist/providers/resilient-factory.js +1 -1
- package/dist/providers/resilient-factory.js.map +1 -1
- package/dist/providers/types.d.ts +1 -0
- package/dist/repl/queue.d.ts +22 -0
- package/dist/repl/queue.js +165 -0
- package/dist/repl/queue.js.map +1 -0
- package/dist/repl/side-channel.d.ts +23 -0
- package/dist/repl/side-channel.js +63 -0
- package/dist/repl/side-channel.js.map +1 -0
- package/dist/research/council.d.ts +2 -0
- package/dist/research/council.js +29 -4
- package/dist/research/council.js.map +1 -1
- package/dist/ruby/alternator.d.ts +11 -30
- package/dist/ruby/alternator.js +59 -38
- package/dist/ruby/alternator.js.map +1 -1
- package/dist/ruby/episode-capture.d.ts +0 -10
- package/dist/ruby/episode-capture.js +0 -33
- package/dist/ruby/episode-capture.js.map +1 -1
- package/dist/ruby/types.js +1 -1
- package/dist/ruby/types.js.map +1 -1
- package/dist/safety/path-jail.d.ts +17 -0
- package/dist/safety/path-jail.js +100 -0
- package/dist/safety/path-jail.js.map +1 -0
- package/dist/safety/permissions.d.ts +12 -21
- package/dist/safety/permissions.js +81 -216
- package/dist/safety/permissions.js.map +1 -1
- package/dist/safety/ssrf.d.ts +29 -0
- package/dist/safety/ssrf.js +185 -0
- package/dist/safety/ssrf.js.map +1 -0
- package/dist/server/index.js +64 -10
- package/dist/server/index.js.map +1 -1
- package/dist/setup/first-run.d.ts +0 -24
- package/dist/setup/first-run.js +10 -344
- package/dist/setup/first-run.js.map +1 -1
- package/dist/setup/key-store.d.ts +12 -0
- package/dist/setup/key-store.js +108 -0
- package/dist/setup/key-store.js.map +1 -0
- package/dist/setup/provider-registry.js +31 -18
- package/dist/setup/provider-registry.js.map +1 -1
- package/dist/setup/provider-test.d.ts +7 -0
- package/dist/setup/provider-test.js +73 -10
- package/dist/setup/provider-test.js.map +1 -1
- package/dist/setup/provider-wizard.d.ts +4 -1
- package/dist/setup/provider-wizard.js +92 -26
- package/dist/setup/provider-wizard.js.map +1 -1
- package/dist/setup/xiaomi.d.ts +1 -1
- package/dist/setup/xiaomi.js +3 -3
- package/dist/setup/xiaomi.js.map +1 -1
- package/dist/tools/browser.js +14 -10
- package/dist/tools/browser.js.map +1 -1
- package/dist/tools/clipboard.js +7 -1
- package/dist/tools/clipboard.js.map +1 -1
- package/dist/tools/dictate.d.ts +60 -0
- package/dist/tools/dictate.js +983 -0
- package/dist/tools/dictate.js.map +1 -0
- package/dist/tools/dictate_patched.js +1057 -0
- package/dist/tools/edit-file.js +10 -2
- package/dist/tools/edit-file.js.map +1 -1
- package/dist/tools/http-request.js +14 -4
- package/dist/tools/http-request.js.map +1 -1
- package/dist/tools/image-read.js +34 -2
- package/dist/tools/image-read.js.map +1 -1
- package/dist/tools/index.d.ts +16 -1
- package/dist/tools/index.js +59 -8
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/mcp.js +12 -0
- package/dist/tools/mcp.js.map +1 -1
- package/dist/tools/read-file.js +10 -14
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/telegram-audio-policy.d.ts +30 -0
- package/dist/tools/telegram-audio-policy.js +49 -0
- package/dist/tools/telegram-audio-policy.js.map +1 -0
- package/dist/tools/telegram-bot.js +1136 -537
- package/dist/tools/telegram-bot.js.map +1 -1
- package/dist/tools/telegram-voice.d.ts +18 -5
- package/dist/tools/telegram-voice.js +54 -12
- package/dist/tools/telegram-voice.js.map +1 -1
- package/dist/tools/telegram.d.ts +3 -3
- package/dist/tools/telegram.js +5 -84
- package/dist/tools/telegram.js.map +1 -1
- package/dist/tools/tools.d.ts +2 -14
- package/dist/tools/tools.js +79 -144
- package/dist/tools/tools.js.map +1 -1
- package/dist/tools/web-fetch.js +39 -7
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/web-search.d.ts +0 -20
- package/dist/tools/web-search.js +40 -137
- package/dist/tools/web-search.js.map +1 -1
- package/dist/util/errors.js +1 -15
- package/dist/util/errors.js.map +1 -1
- package/dist/util/json-repair.d.ts +11 -0
- package/dist/util/json-repair.js +31 -0
- package/dist/util/json-repair.js.map +1 -0
- package/dist/util/rate-limiter.js +2 -8
- package/dist/util/rate-limiter.js.map +1 -1
- package/dist/viz/index.js +793 -792
- package/dist/viz/index.js.map +1 -1
- 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,EAAE,CAAC;AAQtC,2EAA2E;AAC3E,SAAS,SAAS,CAAC,IA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AI,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,2EAA2E;IAC3E,gIAAgI;IAChI,gGAAgG;CACjG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,oEAAoE;AACpE,IAAI,QAAQ,GAAG,CAAC,CAAC;AAOjB;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CACjC,OAAyB,EACzB,WAAmB,EACnB,QAAqB,EACrB,SAA4D,EAAE;IAE9D,MAAM,UAAU,GAAG,IAAA,6BAAc,EAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,UAAU,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAEjD,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAA2C,CAAC;IAC5E,QAAQ,EAAE,CAAC;IACX,MAAM,SAAS,GAAG,IAAA,2BAAgB,EAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAE1D,MAAM,IAAA,sBAAW,EAAC;QAChB,YAAY,EAAE,YAAY;QAC1B,WAAW,EAAE,KAAK,CAAC,OAAO;QAC1B,QAAQ;QACR,OAAO,EAAE,SAAS;KACnB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAmB;QAC9B,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE;YACP,uCAAuC,SAAS,8CAA8C;YAC9F,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAChE,CAAC,IAAI,CAAC,IAAI,CAAC;KACb,CAAC;IAEF,2EAA2E;IAC3E,2EAA2E;IAC3E,sEAAsE;IACtE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IAEvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,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,G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
|
/** Internal: skip post-task verification (used by runWithVerification wrapper). */
|
|
27
27
|
verify?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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;
|
|
@@ -51,7 +59,9 @@ export interface TokenUsage {
|
|
|
51
59
|
inputTokens: number;
|
|
52
60
|
outputTokens: number;
|
|
53
61
|
totalTokens: number;
|
|
62
|
+
cachedTokens: number;
|
|
54
63
|
}
|
|
64
|
+
export declare function costFor(model: string, input: number, output: number, cachedTokens?: number): number;
|
|
55
65
|
export declare function runAgentLoop(opts: LoopOptions): Promise<LoopResult>;
|
|
56
66
|
export declare function runAgentLoopVerified(opts: LoopOptions, config: VerificationConfig, projectRoot: string): Promise<{
|
|
57
67
|
loopResult: LoopResult;
|