aura-code 0.3.6 → 0.5.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 (109) hide show
  1. package/README.md +54 -2
  2. package/dist/agent/compactor.d.ts +26 -0
  3. package/dist/agent/compactor.js +156 -0
  4. package/dist/agent/compactor.js.map +1 -0
  5. package/dist/agent/design.d.ts +17 -0
  6. package/dist/agent/design.js +175 -0
  7. package/dist/agent/design.js.map +1 -0
  8. package/dist/agent/loop.js +8 -1
  9. package/dist/agent/loop.js.map +1 -1
  10. package/dist/agent/system-prompt.d.ts +1 -1
  11. package/dist/agent/system-prompt.js +5 -2
  12. package/dist/agent/system-prompt.js.map +1 -1
  13. package/dist/cli/display.js +40 -4
  14. package/dist/cli/display.js.map +1 -1
  15. package/dist/cli/index.js +258 -44
  16. package/dist/cli/index.js.map +1 -1
  17. package/dist/config/defaults.js +1 -1
  18. package/dist/config/defaults.js.map +1 -1
  19. package/dist/config/project-config.d.ts +6 -0
  20. package/dist/config/project-config.js +2 -0
  21. package/dist/config/project-config.js.map +1 -1
  22. package/dist/dream/dream.d.ts +48 -0
  23. package/dist/dream/dream.js +187 -0
  24. package/dist/dream/dream.js.map +1 -0
  25. package/dist/kanban/index.d.ts +5 -0
  26. package/dist/kanban/index.js +11 -0
  27. package/dist/kanban/index.js.map +1 -0
  28. package/dist/kanban/pipeline.d.ts +16 -0
  29. package/dist/kanban/pipeline.js +910 -0
  30. package/dist/kanban/pipeline.js.map +1 -0
  31. package/dist/kanban/server.d.ts +5 -0
  32. package/dist/kanban/server.js +820 -0
  33. package/dist/kanban/server.js.map +1 -0
  34. package/dist/kanban/types.d.ts +75 -0
  35. package/dist/kanban/types.js +6 -0
  36. package/dist/kanban/types.js.map +1 -0
  37. package/dist/learnlight/driven.d.ts +2 -0
  38. package/dist/learnlight/driven.js +109 -0
  39. package/dist/learnlight/driven.js.map +1 -0
  40. package/dist/learnlight/index.d.ts +4 -0
  41. package/dist/learnlight/index.js +32 -0
  42. package/dist/learnlight/index.js.map +1 -0
  43. package/dist/learnlight/lesson-prep.d.ts +36 -0
  44. package/dist/learnlight/lesson-prep.js +224 -0
  45. package/dist/learnlight/lesson-prep.js.map +1 -0
  46. package/dist/learnlight/report.d.ts +2 -0
  47. package/dist/learnlight/report.js +37 -0
  48. package/dist/learnlight/report.js.map +1 -0
  49. package/dist/learnlight/types.d.ts +72 -0
  50. package/dist/learnlight/types.js +6 -0
  51. package/dist/learnlight/types.js.map +1 -0
  52. package/dist/perception/graph-store.d.ts +11 -0
  53. package/dist/perception/graph-store.js +33 -0
  54. package/dist/perception/graph-store.js.map +1 -1
  55. package/dist/perception/index.d.ts +1 -1
  56. package/dist/perception/index.js +2 -1
  57. package/dist/perception/index.js.map +1 -1
  58. package/dist/providers/factory.d.ts +16 -0
  59. package/dist/providers/factory.js +72 -0
  60. package/dist/providers/factory.js.map +1 -1
  61. package/dist/providers/openai-compatible.js +80 -49
  62. package/dist/providers/openai-compatible.js.map +1 -1
  63. package/dist/research/council.d.ts +26 -0
  64. package/dist/research/council.js +225 -0
  65. package/dist/research/council.js.map +1 -0
  66. package/dist/research/research.d.ts +24 -0
  67. package/dist/research/research.js +116 -0
  68. package/dist/research/research.js.map +1 -0
  69. package/dist/ruby/alternator.d.ts +36 -1
  70. package/dist/ruby/alternator.js +40 -31
  71. package/dist/ruby/alternator.js.map +1 -1
  72. package/dist/ruby/stats.js +10 -11
  73. package/dist/ruby/stats.js.map +1 -1
  74. package/dist/ruby/types.js +1 -1
  75. package/dist/ruby/types.js.map +1 -1
  76. package/dist/safety/permissions.d.ts +8 -0
  77. package/dist/safety/permissions.js +12 -0
  78. package/dist/safety/permissions.js.map +1 -1
  79. package/dist/setup/provider-registry.js +14 -0
  80. package/dist/setup/provider-registry.js.map +1 -1
  81. package/dist/setup/provider-test.js +24 -2
  82. package/dist/setup/provider-test.js.map +1 -1
  83. package/dist/setup/telegram-wizard.d.ts +57 -0
  84. package/dist/setup/telegram-wizard.js +343 -0
  85. package/dist/setup/telegram-wizard.js.map +1 -0
  86. package/dist/tools/audio-transcribe.d.ts +20 -0
  87. package/dist/tools/audio-transcribe.js +39 -28
  88. package/dist/tools/audio-transcribe.js.map +1 -1
  89. package/dist/tools/gmail-tool.d.ts +11 -0
  90. package/dist/tools/gmail-tool.js +221 -0
  91. package/dist/tools/gmail-tool.js.map +1 -0
  92. package/dist/tools/read-file.js +13 -0
  93. package/dist/tools/read-file.js.map +1 -1
  94. package/dist/tools/telegram-bot.js +103 -18
  95. package/dist/tools/telegram-bot.js.map +1 -1
  96. package/dist/tools/telegram-voice.d.ts +22 -0
  97. package/dist/tools/telegram-voice.js +203 -0
  98. package/dist/tools/telegram-voice.js.map +1 -0
  99. package/dist/tools/telegram.d.ts +6 -1
  100. package/dist/tools/telegram.js +115 -5
  101. package/dist/tools/telegram.js.map +1 -1
  102. package/dist/tools/video-render.d.ts +11 -0
  103. package/dist/tools/video-render.js +189 -0
  104. package/dist/tools/video-render.js.map +1 -0
  105. package/dist/util/errors.js +6 -0
  106. package/dist/util/errors.js.map +1 -1
  107. package/dist/viz/index.js +816 -30
  108. package/dist/viz/index.js.map +1 -1
  109. package/package.json +3 -2
@@ -0,0 +1,26 @@
1
+ import type { LLMProvider } from '../providers/types.js';
2
+ import type { ProjectContext } from '../agent/context.js';
3
+ import type { PermissionSystem } from '../safety/permissions.js';
4
+ import type { Display } from '../cli/display.js';
5
+ export interface CouncilResult {
6
+ path: string;
7
+ htmlPath: string;
8
+ topic: string;
9
+ panelSize: number;
10
+ agentFailures: number;
11
+ }
12
+ /**
13
+ * Run an Ecclesia: `panelSize` independent agents research the topic
14
+ * (sequentially, on a free local model), then one synthesis call on the
15
+ * caller's active provider reconciles their findings into a verdict.
16
+ */
17
+ export declare function runCouncil(opts: {
18
+ projectRoot: string;
19
+ topic: string;
20
+ synthesisProvider: LLMProvider;
21
+ context: ProjectContext;
22
+ permissions: PermissionSystem;
23
+ display: Display;
24
+ panelSize?: number;
25
+ panelModel?: string;
26
+ }): Promise<CouncilResult>;
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.runCouncil = runCouncil;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const marked_1 = require("marked");
40
+ const loop_js_1 = require("../agent/loop.js");
41
+ const factory_js_1 = require("../providers/factory.js");
42
+ /**
43
+ * Aura's `:council` ("Ecclesia") — N independent research agents investigate
44
+ * the same topic, then a synthesis pass reconciles their findings into one
45
+ * verdict: what they agreed on, what's contested, and what only a minority
46
+ * caught. Default panel size is 5 — odd, so majority agreement is always
47
+ * decisive (no 2.5/2.5 ties).
48
+ *
49
+ * Cost design, deliberately conservative (see compaction/dream incidents):
50
+ * - The N panel agents run SEQUENTIALLY, each a short findings-only pass
51
+ * (not a full polished report) on a free LOCAL model (Ollama by default)
52
+ * — so a 5-agent council costs roughly one :research pass, not five.
53
+ * - Only the final synthesis step uses the caller's active provider
54
+ * (better reasoning for reconciling disagreement), and it's one call.
55
+ * - Per-agent turns are capped well below :research's full budget.
56
+ *
57
+ * Output: dated `.md` + `.html` under `<projectRoot>/council/`.
58
+ */
59
+ const COUNCIL_DIRNAME = 'council';
60
+ const DEFAULT_PANEL_SIZE = 5;
61
+ const DEFAULT_PANEL_MODEL = 'ollama/qwen2.5-coder:3b';
62
+ const FOOTER = '\n---\n\n*Ecclesia — five voices, one verdict. Inspired by DeerFlow.*\n';
63
+ function councilDir(projectRoot) {
64
+ return path.join(projectRoot, COUNCIL_DIRNAME);
65
+ }
66
+ function slugify(topic) {
67
+ return topic
68
+ .toLowerCase()
69
+ .replace(/[^a-z0-9]+/g, '-')
70
+ .replace(/^-+|-+$/g, '')
71
+ .slice(0, 60) || 'topic';
72
+ }
73
+ function buildPanelTask(topic, seat, panelSize) {
74
+ return (`You are panel seat ${seat} of ${panelSize} in an independent research council on this topic: "${topic}"\n\n` +
75
+ `Research it on your own — search and fetch what you need. Do NOT try to write a polished ` +
76
+ `report. Instead, respond with ONLY a compact findings list:\n\n` +
77
+ `- 4-8 bullet points, each one specific claim or finding, with its source noted in parentheses.\n` +
78
+ `- If something is disputed, speculative, or you're unsure, say so explicitly in that bullet.\n` +
79
+ `- End with one line: "Stance: <your one-sentence bottom-line take>"\n\n` +
80
+ `No preamble, no headers, no questions back. Just the bullets and the stance line.`);
81
+ }
82
+ function buildSynthesisPrompt(topic, findings) {
83
+ const system = 'You are Aura synthesising an Ecclesia — an independent research council. You are given ' +
84
+ `${findings.length} separate agents' findings on the same topic, gathered without them seeing ` +
85
+ 'each other\'s work. Reconcile them into one verdict. Respond in Markdown with EXACTLY these ' +
86
+ 'sections:\n\n' +
87
+ '## Convergent findings\n(claims most or all agents independently arrived at — high confidence)\n\n' +
88
+ '## Contested\n(claims where agents disagreed, or where a majority/minority split exists — name the split, ' +
89
+ 'e.g. "3 of 5 agents..." )\n\n' +
90
+ '## Minority signal\n(something only one or two agents caught that seems worth surfacing anyway, even if unconfirmed)\n\n' +
91
+ '## Verdict\n(the council\'s bottom-line conclusion — what an informed reader should walk away believing, ' +
92
+ 'and how confident that conclusion is)\n\n' +
93
+ '## Sources\n(consolidated list of sources cited across all agents)';
94
+ const user = `Topic: ${topic}\n\n` +
95
+ findings.map((f, i) => `### Agent ${i + 1}\n${f}`).join('\n\n');
96
+ return { system, user };
97
+ }
98
+ function mdToHtml(md) {
99
+ marked_1.marked.setOptions({ gfm: true, breaks: false });
100
+ return marked_1.marked.parse(md);
101
+ }
102
+ function wrapHtml(title, bodyHtml, date, panelSize) {
103
+ const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
104
+ return `<!DOCTYPE html>
105
+ <html lang="en">
106
+ <head>
107
+ <meta charset="UTF-8">
108
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
109
+ <title>${esc(title)} — Ecclesia</title>
110
+ <style>
111
+ :root {
112
+ --bg: #fdf6f0; --card: #fffaf5; --text: #3e2f24; --muted: #8a7768;
113
+ --accent: #cc785c; --accent-2: #5a9e6e; --border: #e8d5c8;
114
+ --code-bg: #f4ede6; --bq: #cc785c; --hr: #e0cebc;
115
+ --shadow: 0 2px 12px rgba(62,47,36,0.06); --radius: 12px;
116
+ --serif: 'Georgia', 'Times New Roman', serif;
117
+ --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
118
+ --mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
119
+ }
120
+ @media (prefers-color-scheme: dark) {
121
+ :root {
122
+ --bg: #1e1b18; --card: #26221e; --text: #ede0cc; --muted: #9e8e80;
123
+ --accent: #e08a6e; --accent-2: #6db880; --border: #3a322a;
124
+ --code-bg: #2c2722; --bq: #e08a6e; --hr: #3a322a;
125
+ --shadow: 0 2px 12px rgba(0,0,0,0.25);
126
+ }
127
+ }
128
+ * { box-sizing: border-box; margin: 0; padding: 0; }
129
+ body { background: var(--bg); color: var(--text); font-family: var(--serif); line-height: 1.75; font-size: 18px; }
130
+ .container { max-width: 780px; margin: 0 auto; padding: 3rem 1.5rem 5rem; }
131
+ .hero { text-align: center; padding: 3rem 0 2.5rem; border-bottom: 2px solid var(--border); margin-bottom: 2.5rem; }
132
+ .hero .badge { display: inline-block; background: var(--accent); color: #fff; font-family: var(--sans); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; padding: 0.3em 1em; border-radius: 100px; margin-bottom: 1.25rem; }
133
+ .hero h1 { font-family: var(--sans); font-size: 2.4rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; margin-bottom: 0.5rem; }
134
+ .hero .meta { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
135
+ .card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.5rem 3rem; }
136
+ @media (max-width: 640px) { .card { padding: 1.5rem; border-radius: 8px; } .hero h1 { font-size: 1.7rem; } .container { padding: 1.5rem 0.75rem 3rem; } }
137
+ .card h1, .card h2, .card h3 { font-family: var(--sans); margin: 2rem 0 0.75rem; line-height: 1.3; }
138
+ .card h2:first-child { margin-top: 0; }
139
+ .card h2 { font-size: 1.45rem; color: var(--accent); border-bottom: 2px solid var(--border); padding-bottom: 0.4rem; }
140
+ .card h3 { font-size: 1.1rem; color: var(--accent-2); }
141
+ .card p { margin: 0.85rem 0; }
142
+ .card a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent); }
143
+ .card ul, .card ol { margin: 0.85rem 0; padding-left: 1.8rem; }
144
+ .card li { margin: 0.4rem 0; }
145
+ .card code { font-family: var(--mono); font-size: 0.88em; background: var(--code-bg); padding: 0.15em 0.4em; border-radius: 4px; border: 1px solid var(--border); }
146
+ .card hr { border: none; border-top: 1px solid var(--hr); margin: 2rem 0; }
147
+ .footer { text-align: center; margin-top: 2.5rem; font-family: var(--sans); font-size: 0.8rem; color: var(--muted); opacity: 0.7; }
148
+ </style>
149
+ </head>
150
+ <body>
151
+ <div class="container">
152
+ <header class="hero">
153
+ <div class="badge">Ecclesia &middot; ${panelSize} agents</div>
154
+ <h1>${esc(title)}</h1>
155
+ <div class="meta">${date}</div>
156
+ </header>
157
+ <article class="card">
158
+ ${bodyHtml}
159
+ </article>
160
+ <footer class="footer"><p>Generated by Aura Code &middot; Ecclesia &middot; Inspired by DeerFlow</p></footer>
161
+ </div>
162
+ </body>
163
+ </html>`;
164
+ }
165
+ /**
166
+ * Run an Ecclesia: `panelSize` independent agents research the topic
167
+ * (sequentially, on a free local model), then one synthesis call on the
168
+ * caller's active provider reconciles their findings into a verdict.
169
+ */
170
+ async function runCouncil(opts) {
171
+ const { projectRoot, topic, synthesisProvider, context, permissions, display, } = opts;
172
+ const panelSize = Math.max(1, opts.panelSize ?? DEFAULT_PANEL_SIZE);
173
+ const panelModel = opts.panelModel ?? DEFAULT_PANEL_MODEL;
174
+ const findings = [];
175
+ let agentFailures = 0;
176
+ // Sequential by design — see module doc. Each agent is independent: no
177
+ // agent sees another's findings, so agreement/disagreement is genuine.
178
+ for (let seat = 1; seat <= panelSize; seat++) {
179
+ try {
180
+ const panelProvider = (0, factory_js_1.createProvider)({ model: panelModel });
181
+ const res = await (0, loop_js_1.runAgentLoop)({
182
+ provider: panelProvider,
183
+ task: buildPanelTask(topic, seat, panelSize),
184
+ context,
185
+ permissions,
186
+ display,
187
+ maxTurns: 6,
188
+ disableSpawn: true,
189
+ });
190
+ const text = (res.summary ?? '').trim();
191
+ findings.push(text || `(Agent ${seat} returned no findings.)`);
192
+ }
193
+ catch (err) {
194
+ agentFailures++;
195
+ findings.push(`(Agent ${seat} failed: ${err instanceof Error ? err.message : String(err)})`);
196
+ }
197
+ }
198
+ // Synthesis — one call, on the caller's real provider.
199
+ const { system, user } = buildSynthesisPrompt(topic, findings);
200
+ let verdictBody;
201
+ try {
202
+ const synth = await synthesisProvider.complete(system, [{ role: 'user', content: user }], []);
203
+ verdictBody = (synth.text ?? '').trim();
204
+ }
205
+ catch (err) {
206
+ verdictBody =
207
+ `## Convergent findings\n_Synthesis failed: ${err instanceof Error ? err.message : String(err)}_\n\n` +
208
+ `## Contested\n- none (synthesis did not run)\n\n## Minority signal\n- none\n\n` +
209
+ `## Verdict\nSynthesis could not run, but the ${panelSize} agents' raw findings are preserved below.\n\n## Sources\n- see raw findings`;
210
+ }
211
+ const rawFindingsSection = `\n\n---\n\n## Raw panel findings\n\n` +
212
+ findings.map((f, i) => `### Agent ${i + 1}\n\n${f}`).join('\n\n');
213
+ const md = `# Ecclesia: ${topic}\n\n${verdictBody}${rawFindingsSection}\n${FOOTER}`;
214
+ const dir = councilDir(projectRoot);
215
+ fs.mkdirSync(dir, { recursive: true });
216
+ const date = new Date().toISOString().slice(0, 10);
217
+ const slug = slugify(topic);
218
+ const mdPath = path.join(dir, `${date}-${slug}.md`);
219
+ fs.writeFileSync(mdPath, md);
220
+ const htmlOut = wrapHtml(topic, mdToHtml(`${verdictBody}${rawFindingsSection}`), date, panelSize);
221
+ const htmlPath = path.join(dir, `${date}-${slug}.html`);
222
+ fs.writeFileSync(htmlPath, htmlOut);
223
+ return { path: mdPath, htmlPath, topic, panelSize, agentFailures };
224
+ }
225
+ //# sourceMappingURL=council.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"council.js","sourceRoot":"","sources":["../../src/research/council.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8JA,gCAyEC;AAvOD,uCAAyB;AACzB,2CAA6B;AAC7B,mCAAgC;AAChC,8CAAgD;AAChD,wDAAyD;AAMzD;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,eAAe,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,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;AACrE,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { LLMProvider } from '../providers/types.js';
2
+ import type { ProjectContext } from '../agent/context.js';
3
+ import type { PermissionSystem } from '../safety/permissions.js';
4
+ import type { Display } from '../cli/display.js';
5
+ export interface ResearchResult {
6
+ path: string;
7
+ topic: string;
8
+ turns: number;
9
+ toolCalls: number;
10
+ }
11
+ /**
12
+ * Run a research pass and save it to a dated file. Throws if the underlying
13
+ * agent loop fails outright (caller should catch and report — there is no
14
+ * silent error-stub here, unlike :dream, since a failed research run has no
15
+ * partial state worth preserving).
16
+ */
17
+ export declare function runResearch(opts: {
18
+ projectRoot: string;
19
+ topic: string;
20
+ provider: LLMProvider;
21
+ context: ProjectContext;
22
+ permissions: PermissionSystem;
23
+ display: Display;
24
+ }): Promise<ResearchResult>;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.runResearch = runResearch;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const loop_js_1 = require("../agent/loop.js");
40
+ /**
41
+ * Aura's `:research` — a focused, multi-step research pass on a topic.
42
+ *
43
+ * Pattern is inspired by ByteDance's DeerFlow SuperAgent harness: break a
44
+ * topic into sub-questions, gather evidence (web_search/web_fetch, already
45
+ * wired into the agent loop), and synthesise into a cited report. This is
46
+ * intentionally the *minimal* version of that idea — it reuses the existing
47
+ * agent loop and tool wiring rather than introducing a separate middleware
48
+ * pipeline or concurrent sub-agent executor. If that proves too slow or
49
+ * shallow for a given topic, the heavier DeerFlow-style architecture
50
+ * (concurrent sub-agents, confidence-scored memory, sandboxing) is a
51
+ * candidate for a later, separate pass — not bundled in here.
52
+ *
53
+ * Output is one dated Markdown file per topic under `<projectRoot>/research/`,
54
+ * ending with a short attribution footer.
55
+ */
56
+ const RESEARCH_DIRNAME = 'research';
57
+ const FOOTER = '\n---\n\n*Inspired by DeerFlow.*\n';
58
+ function researchDir(projectRoot) {
59
+ return path.join(projectRoot, RESEARCH_DIRNAME);
60
+ }
61
+ function slugify(topic) {
62
+ return topic
63
+ .toLowerCase()
64
+ .replace(/[^a-z0-9]+/g, '-')
65
+ .replace(/^-+|-+$/g, '')
66
+ .slice(0, 60) || 'topic';
67
+ }
68
+ function buildResearchTask(topic) {
69
+ return (`Research the following topic thoroughly and produce a well-organised, cited report: "${topic}"\n\n` +
70
+ `Approach:\n` +
71
+ `1. Break the topic into the 3-6 sub-questions that matter most (definition/background, ` +
72
+ `current state, key players or evidence, open debates or unknowns, practical takeaway).\n` +
73
+ `2. Search and fetch sources for each sub-question. Prefer primary/official sources over ` +
74
+ `aggregators. Note where claims are speculative, unverified, or disputed — do not present ` +
75
+ `speculation as settled fact.\n` +
76
+ `3. Synthesise into Markdown with clear section headers per sub-question, plus a short ` +
77
+ `"Bottom line" section at the end summarising the most defensible conclusion.\n` +
78
+ `4. List sources used at the end under a "Sources" heading.\n\n` +
79
+ `Respond with ONLY the finished Markdown report — no preamble, no meta-commentary about ` +
80
+ `your process, no questions back to the user.\n\n` +
81
+ `IMPORTANT: the report must be about "${topic}" — and nothing else. Do not write about ` +
82
+ `yourself, this tool, Aura, or this conversation; if you are tempted to, that means you have ` +
83
+ `drifted off-topic and should redirect back to "${topic}".`);
84
+ }
85
+ /**
86
+ * Run a research pass and save it to a dated file. Throws if the underlying
87
+ * agent loop fails outright (caller should catch and report — there is no
88
+ * silent error-stub here, unlike :dream, since a failed research run has no
89
+ * partial state worth preserving).
90
+ */
91
+ async function runResearch(opts) {
92
+ const { projectRoot, topic, provider, context, permissions, display } = opts;
93
+ const result = await (0, loop_js_1.runAgentLoop)({
94
+ provider,
95
+ task: buildResearchTask(topic),
96
+ context,
97
+ permissions,
98
+ display,
99
+ maxTurns: 12,
100
+ disableSpawn: true,
101
+ });
102
+ const body = (result.summary ?? '').trim() || '_No content was returned for this research pass._';
103
+ const md = `# ${topic}\n\n${body}\n${FOOTER}`;
104
+ const dir = researchDir(projectRoot);
105
+ fs.mkdirSync(dir, { recursive: true });
106
+ const date = new Date().toISOString().slice(0, 10);
107
+ const outPath = path.join(dir, `${date}-${slugify(topic)}.md`);
108
+ fs.writeFileSync(outPath, md);
109
+ return {
110
+ path: outPath,
111
+ topic,
112
+ turns: result.turns ?? 0,
113
+ toolCalls: result.toolCallCount ?? 0,
114
+ };
115
+ }
116
+ //# sourceMappingURL=research.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"research.js","sourceRoot":"","sources":["../../src/research/research.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;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AAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,mDAAmD,CAAC;IAClG,MAAM,EAAE,GAAG,KAAK,KAAK,OAAO,IAAI,KAAK,MAAM,EAAE,CAAC;IAE9C,MAAM,GAAG,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IACrC,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/D,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAE9B,OAAO;QACL,IAAI,EAAE,OAAO;QACb,KAAK;QACL,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;QACxB,SAAS,EAAE,MAAM,CAAC,aAAa,IAAI,CAAC;KACrC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,8 @@
1
1
  import type { LLMProvider } from '../providers/types.js';
2
+ import type { HistoryMessage } from '../providers/types.js';
3
+ import type { LoopResult } from '../agent/loop.js';
2
4
  import type { ProjectContext } from '../agent/context.js';
5
+ import { PermissionSystem } from '../safety/permissions.js';
3
6
  import type { Display } from '../cli/display.js';
4
7
  import type { AlternationDecision, Episode, RubyConfig } from './types.js';
5
8
  import type { EpisodeStats } from './episode-capture.js';
@@ -11,9 +14,41 @@ export interface AlternatorOptions {
11
14
  context: ProjectContext;
12
15
  /** When set, routing and loop events are surfaced to the user. */
13
16
  display?: Display;
17
+ /**
18
+ * The permission system governing the user's actual session. Pass this
19
+ * through from the caller so Ruby's attempt respects whatever mode the
20
+ * user chose (read-only / normal / auto) — without it, this previously
21
+ * defaulted to a hardcoded 'auto', meaning destructive operations could
22
+ * get silently approved during the Ruby attempt even in a session the
23
+ * user explicitly ran in confirmation-required 'normal' mode.
24
+ */
25
+ permissions?: PermissionSystem;
26
+ /**
27
+ * Confirmation callback for destructive operations, passed through to
28
+ * both the Ruby attempt and the large-model escalation. Pass the same
29
+ * one the caller already uses (e.g. the REPL's readline-based prompt) —
30
+ * without it, each inner loop falls back to its own default terminal
31
+ * confirm(), which can behave inconsistently alongside an already-active
32
+ * readline interface.
33
+ */
34
+ confirmFn?: (message: string) => Promise<boolean>;
35
+ /**
36
+ * Prior conversation history to resume from (e.g. the REPL's stay-active
37
+ * history, or a loaded session). Without this, every Ruby-alternated
38
+ * turn would silently start fresh, breaking multi-turn conversation
39
+ * continuation any time alternation activates mid-conversation.
40
+ */
41
+ initialHistory?: HistoryMessage[];
14
42
  }
15
43
  export interface AlternatorRunResult {
16
- result: string;
44
+ /**
45
+ * The full result from whichever path actually produced the final
46
+ * output — Ruby's if it succeeded without escalation, otherwise the
47
+ * large model's. Treat this exactly like a normal runAgentLoop() result:
48
+ * history, costUsd, turns, and toolCallLog are all populated correctly
49
+ * from whichever path ran, so callers don't need special-case handling.
50
+ */
51
+ loopResult: LoopResult;
17
52
  episode: Episode;
18
53
  usedRuby: boolean;
19
54
  decision: AlternationDecision;
@@ -88,10 +88,11 @@ function buildRubyProvider(config) {
88
88
  class RubyAlternator {
89
89
  opts;
90
90
  display;
91
- permissions = new permissions_js_1.PermissionSystem('auto');
91
+ permissions;
92
92
  constructor(opts) {
93
93
  this.opts = opts;
94
94
  this.display = opts.display ?? createNoopDisplay();
95
+ this.permissions = opts.permissions ?? new permissions_js_1.PermissionSystem('normal');
95
96
  }
96
97
  /**
97
98
  * Runs a task through Ruby and/or the large model, persists an episode, and
@@ -100,6 +101,7 @@ class RubyAlternator {
100
101
  async run(task) {
101
102
  const startMs = Date.now();
102
103
  const { rubyConfig, largeModelProvider, projectRoot, context } = this.opts;
104
+ const confirmFn = this.opts.confirmFn;
103
105
  let decision = {
104
106
  useRuby: false,
105
107
  reason: 'Initializing alternation.',
@@ -108,12 +110,12 @@ class RubyAlternator {
108
110
  };
109
111
  let rubyAttempted = false;
110
112
  let rubySucceeded = false;
111
- let rubyOutput;
112
- let rubyTokens = 0;
113
- let largeModelOutput;
114
- let largeModelTokens = 0;
113
+ let rubyLoopResult;
114
+ let largeModelLoopResult;
115
115
  let usedRuby = false;
116
- let result = '';
116
+ // Only used to build the error-path fallback LoopResult below; the
117
+ // success paths read everything from rubyLoopResult/largeModelLoopResult.
118
+ let errorSummary;
117
119
  try {
118
120
  const recent = await episode_capture_js_1.episodeStore.loadEpisodes(projectRoot, RECENT_EPISODE_LIMIT);
119
121
  decision = (0, competence_js_1.assessCompetence)(recent, task, rubyConfig);
@@ -129,21 +131,20 @@ class RubyAlternator {
129
131
  this.display.success(`Trying Ruby (${rubyConfig.modelName})…`);
130
132
  try {
131
133
  const rubyProvider = buildRubyProvider(rubyConfig);
132
- const loopResult = await (0, loop_js_1.runAgentLoop)({
134
+ rubyLoopResult = await (0, loop_js_1.runAgentLoop)({
133
135
  provider: rubyProvider,
134
136
  task,
135
137
  context,
136
138
  permissions: this.permissions,
137
139
  display: this.display,
140
+ confirmFn,
141
+ initialHistory: this.opts.initialHistory,
138
142
  disableSpawn: true,
139
143
  maxTurns: 15,
140
144
  });
141
- rubyTokens = loopResult.usage.totalTokens;
142
- rubyOutput = loopResult.summary;
143
- if (isNonEmptyResult(rubyOutput) && loopResult.success) {
145
+ if (isNonEmptyResult(rubyLoopResult.summary) && rubyLoopResult.success) {
144
146
  rubySucceeded = true;
145
147
  usedRuby = true;
146
- result = rubyOutput;
147
148
  this.display.success('Ruby handled the task without escalation.');
148
149
  }
149
150
  else {
@@ -152,40 +153,48 @@ class RubyAlternator {
152
153
  }
153
154
  catch (e) {
154
155
  this.display.warning(`Ruby error: ${String(e)} — escalating.`);
155
- rubyOutput = rubyOutput ?? `Error: ${String(e)}`;
156
156
  }
157
157
  }
158
158
  }
159
159
  if (!usedRuby) {
160
160
  this.display.header('Large model', largeModelProvider.name);
161
161
  try {
162
- const loopResult = await (0, loop_js_1.runAgentLoop)({
162
+ largeModelLoopResult = await (0, loop_js_1.runAgentLoop)({
163
163
  provider: largeModelProvider,
164
164
  task,
165
165
  context,
166
166
  permissions: this.permissions,
167
167
  display: this.display,
168
+ confirmFn,
169
+ initialHistory: this.opts.initialHistory,
168
170
  disableSpawn: true,
169
171
  });
170
- largeModelTokens = loopResult.usage.totalTokens;
171
- largeModelOutput = loopResult.summary;
172
- result = isNonEmptyResult(largeModelOutput)
173
- ? largeModelOutput
174
- : loopResult.success
175
- ? '(Task completed with no output)'
176
- : `Large model did not complete: ${loopResult.summary}`;
177
172
  }
178
173
  catch (e) {
179
- result = `Large model error: ${String(e)}`;
180
- largeModelOutput = result;
181
- this.display.error(result);
174
+ errorSummary = `Large model error: ${String(e)}`;
175
+ this.display.error(errorSummary);
182
176
  }
183
177
  }
184
178
  }
185
179
  catch (e) {
186
- result = `Alternation error: ${String(e)}`;
187
- this.display.error(result);
180
+ errorSummary = `Alternation error: ${String(e)}`;
181
+ this.display.error(errorSummary);
188
182
  }
183
+ // The full result that actually represents this run's output — Ruby's
184
+ // if it succeeded, otherwise the large model's, otherwise a safe empty
185
+ // result for the case where something threw before either path ran.
186
+ const finalLoopResult = usedRuby
187
+ ? rubyLoopResult
188
+ : largeModelLoopResult ?? {
189
+ success: false,
190
+ summary: errorSummary ?? 'Alternation failed before either model ran.',
191
+ turns: 0,
192
+ toolCallCount: 0,
193
+ usage: { inputTokens: 0, outputTokens: 0, totalTokens: 0 },
194
+ costUsd: 0,
195
+ history: [],
196
+ toolCallLog: [],
197
+ };
189
198
  const episode = {
190
199
  id: (0, crypto_1.randomUUID)(),
191
200
  timestamp: Date.now(),
@@ -193,13 +202,13 @@ class RubyAlternator {
193
202
  projectRoot,
194
203
  rubyAttempted,
195
204
  rubySucceeded,
196
- rubyOutput,
205
+ rubyOutput: rubyLoopResult?.summary,
197
206
  largeModelUsed: usedRuby ? undefined : largeModelProvider.model,
198
- largeModelOutput: usedRuby ? undefined : largeModelOutput,
199
- reviewerApproved: isNonEmptyResult(result),
207
+ largeModelOutput: usedRuby ? undefined : largeModelLoopResult?.summary,
208
+ reviewerApproved: isNonEmptyResult(finalLoopResult.summary) && finalLoopResult.success,
200
209
  tokensUsed: {
201
- ruby: rubyAttempted ? rubyTokens : undefined,
202
- largeModel: usedRuby ? undefined : largeModelTokens,
210
+ ruby: rubyAttempted ? rubyLoopResult?.usage.totalTokens : undefined,
211
+ largeModel: usedRuby ? undefined : largeModelLoopResult?.usage.totalTokens,
203
212
  },
204
213
  durationMs: Date.now() - startMs,
205
214
  taskCategory: inferTaskCategory(task),
@@ -219,7 +228,7 @@ class RubyAlternator {
219
228
  catch {
220
229
  /* best-effort */
221
230
  }
222
- return { result, episode, usedRuby, decision };
231
+ return { loopResult: finalLoopResult, episode, usedRuby, decision };
223
232
  }
224
233
  /**
225
234
  * Returns aggregate episode statistics for this alternator's project.
@@ -1 +1 @@
1
- {"version":3,"file":"alternator.js","sourceRoot":"","sources":["../../src/ruby/alternator.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,4EAA6E;AAC7E,8CAAgD;AAEhD,6DAA4D;AAQ5D,mDAAmE;AACnE,6DAAoD;AAwBpD,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF,SAAS,iBAAiB;IACxB,OAAO;QACL,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;QACvB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;QACpB,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;QACnB,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;QACnB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;QAClB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC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