aura-code 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +137 -0
- package/dist/agent/context.d.ts +13 -0
- package/dist/agent/context.js +183 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/loop.d.ts +60 -0
- package/dist/agent/loop.js +228 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/session-store.d.ts +30 -0
- package/dist/agent/session-store.js +178 -0
- package/dist/agent/session-store.js.map +1 -0
- package/dist/agent/spawner.d.ts +57 -0
- package/dist/agent/spawner.js +112 -0
- package/dist/agent/spawner.js.map +1 -0
- package/dist/agent/system-prompt.d.ts +3 -0
- package/dist/agent/system-prompt.js +100 -0
- package/dist/agent/system-prompt.js.map +1 -0
- package/dist/architect/engine.d.ts +47 -0
- package/dist/architect/engine.js +217 -0
- package/dist/architect/engine.js.map +1 -0
- package/dist/architect/types.d.ts +61 -0
- package/dist/architect/types.js +6 -0
- package/dist/architect/types.js.map +1 -0
- package/dist/cli/diamond.d.ts +1 -0
- package/dist/cli/diamond.js +23 -0
- package/dist/cli/diamond.js.map +1 -0
- package/dist/cli/display.d.ts +44 -0
- package/dist/cli/display.js +234 -0
- package/dist/cli/display.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +1734 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/defaults.d.ts +46 -0
- package/dist/config/defaults.js +106 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/project-config.d.ts +90 -0
- package/dist/config/project-config.js +141 -0
- package/dist/config/project-config.js.map +1 -0
- package/dist/harness/proposer.d.ts +26 -0
- package/dist/harness/proposer.js +204 -0
- package/dist/harness/proposer.js.map +1 -0
- package/dist/harness/weakness-miner.d.ts +28 -0
- package/dist/harness/weakness-miner.js +359 -0
- package/dist/harness/weakness-miner.js.map +1 -0
- package/dist/integrations/harnesses.d.ts +23 -0
- package/dist/integrations/harnesses.js +161 -0
- package/dist/integrations/harnesses.js.map +1 -0
- package/dist/orchestration/competence.d.ts +53 -0
- package/dist/orchestration/competence.js +181 -0
- package/dist/orchestration/competence.js.map +1 -0
- package/dist/orchestration/executor.d.ts +42 -0
- package/dist/orchestration/executor.js +206 -0
- package/dist/orchestration/executor.js.map +1 -0
- package/dist/orchestration/index.d.ts +20 -0
- package/dist/orchestration/index.js +39 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/orchestrator-prompts.d.ts +11 -0
- package/dist/orchestration/orchestrator-prompts.js +153 -0
- package/dist/orchestration/orchestrator-prompts.js.map +1 -0
- package/dist/orchestration/orchestrator.d.ts +27 -0
- package/dist/orchestration/orchestrator.js +169 -0
- package/dist/orchestration/orchestrator.js.map +1 -0
- package/dist/orchestration/plan-store.d.ts +53 -0
- package/dist/orchestration/plan-store.js +176 -0
- package/dist/orchestration/plan-store.js.map +1 -0
- package/dist/orchestration/router-prompts.d.ts +6 -0
- package/dist/orchestration/router-prompts.js +55 -0
- package/dist/orchestration/router-prompts.js.map +1 -0
- package/dist/orchestration/router.d.ts +23 -0
- package/dist/orchestration/router.js +70 -0
- package/dist/orchestration/router.js.map +1 -0
- package/dist/orchestration/ruby-detect.d.ts +6 -0
- package/dist/orchestration/ruby-detect.js +130 -0
- package/dist/orchestration/ruby-detect.js.map +1 -0
- package/dist/orchestration/ruby-types.d.ts +44 -0
- package/dist/orchestration/ruby-types.js +6 -0
- package/dist/orchestration/ruby-types.js.map +1 -0
- package/dist/orchestration/specialist-prompts.d.ts +19 -0
- package/dist/orchestration/specialist-prompts.js +143 -0
- package/dist/orchestration/specialist-prompts.js.map +1 -0
- package/dist/orchestration/specialists.d.ts +66 -0
- package/dist/orchestration/specialists.js +175 -0
- package/dist/orchestration/specialists.js.map +1 -0
- package/dist/orchestration/types.d.ts +82 -0
- package/dist/orchestration/types.js +6 -0
- package/dist/orchestration/types.js.map +1 -0
- package/dist/perception/extractor.d.ts +7 -0
- package/dist/perception/extractor.js +521 -0
- package/dist/perception/extractor.js.map +1 -0
- package/dist/perception/graph-store.d.ts +25 -0
- package/dist/perception/graph-store.js +117 -0
- package/dist/perception/graph-store.js.map +1 -0
- package/dist/perception/index.d.ts +4 -0
- package/dist/perception/index.js +18 -0
- package/dist/perception/index.js.map +1 -0
- package/dist/perception/queries.d.ts +29 -0
- package/dist/perception/queries.js +354 -0
- package/dist/perception/queries.js.map +1 -0
- package/dist/perception/types.d.ts +103 -0
- package/dist/perception/types.js +6 -0
- package/dist/perception/types.js.map +1 -0
- package/dist/providers/anthropic.d.ts +11 -0
- package/dist/providers/anthropic.js +172 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/factory.d.ts +58 -0
- package/dist/providers/factory.js +354 -0
- package/dist/providers/factory.js.map +1 -0
- package/dist/providers/fallback.d.ts +24 -0
- package/dist/providers/fallback.js +72 -0
- package/dist/providers/fallback.js.map +1 -0
- package/dist/providers/google.d.ts +11 -0
- package/dist/providers/google.js +129 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +24 -0
- package/dist/providers/openai-compatible.js +216 -0
- package/dist/providers/openai-compatible.js.map +1 -0
- package/dist/providers/resilient-factory.d.ts +24 -0
- package/dist/providers/resilient-factory.js +57 -0
- package/dist/providers/resilient-factory.js.map +1 -0
- package/dist/providers/resilient.d.ts +63 -0
- package/dist/providers/resilient.js +145 -0
- package/dist/providers/resilient.js.map +1 -0
- package/dist/providers/types.d.ts +84 -0
- package/dist/providers/types.js +6 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/ruby/alternator.d.ts +40 -0
- package/dist/ruby/alternator.js +233 -0
- package/dist/ruby/alternator.js.map +1 -0
- package/dist/ruby/competence.d.ts +34 -0
- package/dist/ruby/competence.js +264 -0
- package/dist/ruby/competence.js.map +1 -0
- package/dist/ruby/episode-capture.d.ts +56 -0
- package/dist/ruby/episode-capture.js +193 -0
- package/dist/ruby/episode-capture.js.map +1 -0
- package/dist/ruby/fine-tune.d.ts +16 -0
- package/dist/ruby/fine-tune.js +253 -0
- package/dist/ruby/fine-tune.js.map +1 -0
- package/dist/ruby/index.d.ts +10 -0
- package/dist/ruby/index.js +26 -0
- package/dist/ruby/index.js.map +1 -0
- package/dist/ruby/ruby-model.d.ts +36 -0
- package/dist/ruby/ruby-model.js +81 -0
- package/dist/ruby/ruby-model.js.map +1 -0
- package/dist/ruby/training-data.d.ts +11 -0
- package/dist/ruby/training-data.js +107 -0
- package/dist/ruby/training-data.js.map +1 -0
- package/dist/ruby/types.d.ts +136 -0
- package/dist/ruby/types.js +20 -0
- package/dist/ruby/types.js.map +1 -0
- package/dist/safety/permissions.d.ts +32 -0
- package/dist/safety/permissions.js +304 -0
- package/dist/safety/permissions.js.map +1 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +342 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/session.d.ts +22 -0
- package/dist/server/session.js +16 -0
- package/dist/server/session.js.map +1 -0
- package/dist/setup/first-run.d.ts +41 -0
- package/dist/setup/first-run.js +386 -0
- package/dist/setup/first-run.js.map +1 -0
- package/dist/setup/global-config.d.ts +19 -0
- package/dist/setup/global-config.js +97 -0
- package/dist/setup/global-config.js.map +1 -0
- package/dist/tools/audio-transcribe.d.ts +8 -0
- package/dist/tools/audio-transcribe.js +156 -0
- package/dist/tools/audio-transcribe.js.map +1 -0
- package/dist/tools/browser.d.ts +15 -0
- package/dist/tools/browser.js +241 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/calendar.d.ts +12 -0
- package/dist/tools/calendar.js +196 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/clipboard.d.ts +7 -0
- package/dist/tools/clipboard.js +90 -0
- package/dist/tools/clipboard.js.map +1 -0
- package/dist/tools/cron.d.ts +10 -0
- package/dist/tools/cron.js +167 -0
- package/dist/tools/cron.js.map +1 -0
- package/dist/tools/edit-file.d.ts +6 -0
- package/dist/tools/edit-file.js +98 -0
- package/dist/tools/edit-file.js.map +1 -0
- package/dist/tools/email.d.ts +11 -0
- package/dist/tools/email.js +153 -0
- package/dist/tools/email.js.map +1 -0
- package/dist/tools/git.d.ts +1 -0
- package/dist/tools/git.js +7 -0
- package/dist/tools/git.js.map +1 -0
- package/dist/tools/http-request.d.ts +12 -0
- package/dist/tools/http-request.js +91 -0
- package/dist/tools/http-request.js.map +1 -0
- package/dist/tools/image-read.d.ts +7 -0
- package/dist/tools/image-read.js +125 -0
- package/dist/tools/image-read.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +201 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-dir.d.ts +1 -0
- package/dist/tools/list-dir.js +6 -0
- package/dist/tools/list-dir.js.map +1 -0
- package/dist/tools/mcp.d.ts +11 -0
- package/dist/tools/mcp.js +356 -0
- package/dist/tools/mcp.js.map +1 -0
- package/dist/tools/memory.d.ts +9 -0
- package/dist/tools/memory.js +124 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/notify.d.ts +9 -0
- package/dist/tools/notify.js +40 -0
- package/dist/tools/notify.js.map +1 -0
- package/dist/tools/read-file.d.ts +6 -0
- package/dist/tools/read-file.js +76 -0
- package/dist/tools/read-file.js.map +1 -0
- package/dist/tools/run-shell.d.ts +1 -0
- package/dist/tools/run-shell.js +6 -0
- package/dist/tools/run-shell.js.map +1 -0
- package/dist/tools/run-tests.d.ts +1 -0
- package/dist/tools/run-tests.js +6 -0
- package/dist/tools/run-tests.js.map +1 -0
- package/dist/tools/search-code.d.ts +1 -0
- package/dist/tools/search-code.js +6 -0
- package/dist/tools/search-code.js.map +1 -0
- package/dist/tools/telegram-bot.d.ts +2 -0
- package/dist/tools/telegram-bot.js +693 -0
- package/dist/tools/telegram-bot.js.map +1 -0
- package/dist/tools/telegram-safety.d.ts +52 -0
- package/dist/tools/telegram-safety.js +189 -0
- package/dist/tools/telegram-safety.js.map +1 -0
- package/dist/tools/telegram.d.ts +16 -0
- package/dist/tools/telegram.js +227 -0
- package/dist/tools/telegram.js.map +1 -0
- package/dist/tools/tools.d.ts +48 -0
- package/dist/tools/tools.js +328 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +11 -0
- package/dist/tools/web-fetch.js +119 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +8 -0
- package/dist/tools/web-search.js +81 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/whatsapp.d.ts +10 -0
- package/dist/tools/whatsapp.js +222 -0
- package/dist/tools/whatsapp.js.map +1 -0
- package/dist/tools/write-file.d.ts +1 -0
- package/dist/tools/write-file.js +6 -0
- package/dist/tools/write-file.js.map +1 -0
- package/dist/tools/youtube-transcript.d.ts +9 -0
- package/dist/tools/youtube-transcript.js +200 -0
- package/dist/tools/youtube-transcript.js.map +1 -0
- package/dist/util/circuit-breaker.d.ts +44 -0
- package/dist/util/circuit-breaker.js +78 -0
- package/dist/util/circuit-breaker.js.map +1 -0
- package/dist/util/env.d.ts +18 -0
- package/dist/util/env.js +39 -0
- package/dist/util/env.js.map +1 -0
- package/dist/util/errors.d.ts +42 -0
- package/dist/util/errors.js +121 -0
- package/dist/util/errors.js.map +1 -0
- package/dist/util/rate-limiter.d.ts +71 -0
- package/dist/util/rate-limiter.js +141 -0
- package/dist/util/rate-limiter.js.map +1 -0
- package/dist/util/retry.d.ts +30 -0
- package/dist/util/retry.js +57 -0
- package/dist/util/retry.js.map +1 -0
- package/dist/util/sanitize.d.ts +16 -0
- package/dist/util/sanitize.js +255 -0
- package/dist/util/sanitize.js.map +1 -0
- package/dist/verify/checks.d.ts +21 -0
- package/dist/verify/checks.js +311 -0
- package/dist/verify/checks.js.map +1 -0
- package/dist/verify/index.d.ts +33 -0
- package/dist/verify/index.js +127 -0
- package/dist/verify/index.js.map +1 -0
- package/dist/verify/types.d.ts +20 -0
- package/dist/verify/types.js +3 -0
- package/dist/verify/types.js.map +1 -0
- package/dist/versioncheck.d.ts +22 -0
- package/dist/versioncheck.js +203 -0
- package/dist/versioncheck.js.map +1 -0
- package/dist/viz/index.d.ts +2 -0
- package/dist/viz/index.js +733 -0
- package/dist/viz/index.js.map +1 -0
- package/dist/workflows/engine.d.ts +46 -0
- package/dist/workflows/engine.js +320 -0
- package/dist/workflows/engine.js.map +1 -0
- package/dist/workflows/types.d.ts +92 -0
- package/dist/workflows/types.js +6 -0
- package/dist/workflows/types.js.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,342 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.startServer = startServer;
|
|
40
|
+
const http = __importStar(require("http"));
|
|
41
|
+
const express_1 = __importDefault(require("express"));
|
|
42
|
+
const ws_1 = require("ws");
|
|
43
|
+
const factory_js_1 = require("../providers/factory.js");
|
|
44
|
+
const context_js_1 = require("../agent/context.js");
|
|
45
|
+
const loop_js_1 = require("../agent/loop.js");
|
|
46
|
+
const permissions_js_1 = require("../safety/permissions.js");
|
|
47
|
+
const session_js_1 = require("./session.js");
|
|
48
|
+
const index_js_1 = require("../orchestration/index.js");
|
|
49
|
+
async function startServer(opts) {
|
|
50
|
+
const app = (0, express_1.default)();
|
|
51
|
+
const server = http.createServer(app);
|
|
52
|
+
const wss = new ws_1.WebSocketServer({ server });
|
|
53
|
+
app.use(express_1.default.json());
|
|
54
|
+
const ctx = await (0, context_js_1.loadProjectContext)(opts.cwd);
|
|
55
|
+
const session = new session_js_1.Session();
|
|
56
|
+
console.log('\n Aura \u2014 web client');
|
|
57
|
+
console.log(' Project : ' + ctx.name + ' \u00b7 ' + ctx.language);
|
|
58
|
+
console.log(' Model : ' + opts.model);
|
|
59
|
+
console.log(' URL : http://localhost:' + opts.port + '\n');
|
|
60
|
+
app.get('/', (_req, res) => {
|
|
61
|
+
res.setHeader('Content-Type', 'text/html');
|
|
62
|
+
res.send(buildUI(ctx.name, opts.model));
|
|
63
|
+
});
|
|
64
|
+
app.get('/api/history', (_req, res) => res.json(session.getDisplay()));
|
|
65
|
+
app.get('/api/project', (_req, res) => res.json({
|
|
66
|
+
name: ctx.name, language: ctx.language, model: opts.model, models: factory_js_1.KNOWN_MODELS,
|
|
67
|
+
}));
|
|
68
|
+
app.post('/api/reset', (_req, res) => { session.reset(); res.json({ ok: true }); });
|
|
69
|
+
wss.on('connection', (ws) => {
|
|
70
|
+
send(ws, { type: 'connected' });
|
|
71
|
+
ws.on('message', async (raw) => {
|
|
72
|
+
let msg;
|
|
73
|
+
try {
|
|
74
|
+
msg = JSON.parse(raw.toString());
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (msg.type === 'task' && msg.task)
|
|
80
|
+
await runTask(ws, msg.task, msg.model ?? opts.model);
|
|
81
|
+
if (msg.type === 'reset') {
|
|
82
|
+
session.reset();
|
|
83
|
+
send(ws, { type: 'reset_ok' });
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
async function runTask(ws, task, model) {
|
|
88
|
+
session.addUser(task);
|
|
89
|
+
let provider;
|
|
90
|
+
try {
|
|
91
|
+
provider = (0, factory_js_1.createProvider)({ model, apiKey: opts.apiKey, baseUrl: opts.baseUrl });
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
send(ws, { type: 'error', message: String(e) });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const display = {
|
|
98
|
+
agentThinking: () => send(ws, { type: 'thinking' }),
|
|
99
|
+
streamText: (t) => send(ws, { type: 'text', text: t }),
|
|
100
|
+
streamEnd: () => send(ws, { type: 'text_end' }),
|
|
101
|
+
toolStart: () => { },
|
|
102
|
+
toolCall: (name, input) => send(ws, { type: 'tool_call', name, input }),
|
|
103
|
+
toolResult: (name, result, ms) => send(ws, { type: 'tool_result', name, result, ms }),
|
|
104
|
+
toolBlocked: (name, reason) => send(ws, { type: 'tool_blocked', name, reason }),
|
|
105
|
+
warning: (msg) => send(ws, { type: 'warning', message: msg }),
|
|
106
|
+
success: () => { },
|
|
107
|
+
error: (msg) => send(ws, { type: 'error', message: msg }),
|
|
108
|
+
header: () => { },
|
|
109
|
+
summary: (text, turns, toolCount) => send(ws, { type: 'done', text, turns, toolCount, success: true }),
|
|
110
|
+
showPlan: (plan) => send(ws, { type: 'plan_created', plan }),
|
|
111
|
+
stepStarted: (step) => send(ws, { type: 'step_started', step }),
|
|
112
|
+
stepCompleted: (step, result) => send(ws, { type: 'step_completed', step, result }),
|
|
113
|
+
};
|
|
114
|
+
// Try orchestration first
|
|
115
|
+
try {
|
|
116
|
+
const decision = await (0, index_js_1.routeTask)({ provider, context: ctx, task });
|
|
117
|
+
if (decision.shouldDecompose) {
|
|
118
|
+
send(ws, { type: 'plan_creating' });
|
|
119
|
+
const plan = await (0, index_js_1.createPlan)({ provider, context: ctx, task });
|
|
120
|
+
send(ws, { type: 'plan_created', plan });
|
|
121
|
+
const executedPlan = await (0, index_js_1.executePlan)({ provider, context: ctx, plan, display });
|
|
122
|
+
const text = executedPlan.outcome ?? 'Plan completed.';
|
|
123
|
+
const success = executedPlan.status === 'done';
|
|
124
|
+
send(ws, { type: 'plan_done', outcome: text, success });
|
|
125
|
+
session.addAssistant(text, executedPlan.steps.length, 0);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Orchestration failed — fall through to single agent
|
|
131
|
+
}
|
|
132
|
+
// Single agent (existing behaviour)
|
|
133
|
+
const result = await (0, loop_js_1.runAgentLoop)({
|
|
134
|
+
provider, task, context: ctx,
|
|
135
|
+
permissions: new permissions_js_1.PermissionSystem('normal'), display,
|
|
136
|
+
});
|
|
137
|
+
session.addAssistant(result.summary, result.turns, result.toolCallCount);
|
|
138
|
+
send(ws, { type: 'done', success: result.success, text: result.summary, turns: result.turns, toolCount: result.toolCallCount });
|
|
139
|
+
}
|
|
140
|
+
server.listen(opts.port, () => {
|
|
141
|
+
if (opts.open) {
|
|
142
|
+
try {
|
|
143
|
+
require('child_process').exec('xdg-open http://localhost:' + opts.port);
|
|
144
|
+
}
|
|
145
|
+
catch { }
|
|
146
|
+
}
|
|
147
|
+
console.log(' Ready \u2192 http://localhost:' + opts.port + ' (Ctrl+C to stop)\n');
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function send(ws, data) {
|
|
151
|
+
if (ws.readyState === ws_1.WebSocket.OPEN)
|
|
152
|
+
ws.send(JSON.stringify(data));
|
|
153
|
+
}
|
|
154
|
+
function buildUI(project, defaultModel) {
|
|
155
|
+
const modelOpts = factory_js_1.KNOWN_MODELS
|
|
156
|
+
.map(m => `<option value="${m.id}">${m.provider} \u2014 ${m.name}</option>`)
|
|
157
|
+
.join('');
|
|
158
|
+
return `<!doctype html>
|
|
159
|
+
<html lang="en">
|
|
160
|
+
<head>
|
|
161
|
+
<meta charset="utf-8"/>
|
|
162
|
+
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
|
163
|
+
<title>${project} \u2014 Aura</title>
|
|
164
|
+
<style>
|
|
165
|
+
:root{
|
|
166
|
+
--bg:#0e0a06;--bg2:#150e08;--s:#1c1208;--ink:#ede0cc;--inks:#c8b5a0;
|
|
167
|
+
--m:#8a7768;--f:#4e3d30;--c:#cc785c;--cd:#b15439;--g:#5a9e6e;
|
|
168
|
+
--l:#2c1e14;--l2:#3a2818;--ti:rgba(204,120,92,.12);
|
|
169
|
+
}
|
|
170
|
+
*{box-sizing:border-box;margin:0;padding:0}
|
|
171
|
+
html,body{height:100%;background:var(--bg);color:var(--ink);font-family:system-ui,sans-serif;font-size:14px;overflow:hidden}
|
|
172
|
+
.app{display:grid;grid-template-rows:52px 1fr 76px;height:100vh}
|
|
173
|
+
.bar{background:var(--bg2);border-bottom:1px solid var(--l2);display:flex;align-items:center;gap:12px;padding:0 20px}
|
|
174
|
+
.logo{font-family:Georgia,serif;font-size:17px;font-weight:600}
|
|
175
|
+
.logo em{font-style:italic;color:var(--c)}
|
|
176
|
+
.proj{font-family:monospace;font-size:11px;color:var(--m)}
|
|
177
|
+
.dot{width:7px;height:7px;border-radius:50%;background:var(--f);flex-shrink:0;transition:.3s}
|
|
178
|
+
.dot.on{background:var(--g);box-shadow:0 0 0 3px rgba(90,158,110,.2)}
|
|
179
|
+
select{margin-left:auto;background:var(--s);border:1px solid var(--l2);color:var(--inks);border-radius:6px;padding:6px 10px;font-size:11px}
|
|
180
|
+
.btn-r{font-size:11px;color:var(--m);background:transparent;border:1px solid var(--l2);border-radius:5px;padding:5px 10px;cursor:pointer}
|
|
181
|
+
.btn-r:hover{border-color:var(--c);color:var(--c)}
|
|
182
|
+
.chat{overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:10px}
|
|
183
|
+
.ibar{background:var(--bg2);border-top:1px solid var(--l2);padding:14px 18px;display:flex;gap:10px;align-items:flex-end}
|
|
184
|
+
.iw{flex:1;background:var(--s);border:1px solid var(--l2);border-radius:12px;display:flex;align-items:flex-end;padding:8px 12px;gap:10px;transition:.2s}
|
|
185
|
+
.iw:focus-within{border-color:var(--c);box-shadow:0 0 0 2px rgba(204,120,92,.15)}
|
|
186
|
+
#inp{flex:1;background:transparent;border:none;outline:none;color:var(--ink);font-size:14px;resize:none;max-height:130px;line-height:1.5;padding:4px 0}
|
|
187
|
+
#inp::placeholder{color:var(--f)}
|
|
188
|
+
#sb{background:var(--c);color:#fff;border:none;border-radius:8px;width:36px;height:36px;cursor:pointer;font-size:18px;flex-shrink:0;transition:.2s}
|
|
189
|
+
#sb:hover{background:var(--cd)}
|
|
190
|
+
#sb:disabled{background:var(--f);cursor:not-allowed}
|
|
191
|
+
.mu{display:flex;justify-content:flex-end}
|
|
192
|
+
.mu .b{background:var(--ti);border:1px solid rgba(204,120,92,.2);border-radius:14px 14px 4px 14px;padding:11px 16px;max-width:75%;line-height:1.55}
|
|
193
|
+
.ma .b{background:var(--s);border:1px solid var(--l2);border-radius:4px 14px 14px 14px;padding:13px 16px;color:var(--inks);line-height:1.65;white-space:pre-wrap}
|
|
194
|
+
.mt{background:#1a1008;border:1px solid var(--l);border-left:2px solid var(--c);border-radius:6px;padding:9px 13px;font-family:monospace;font-size:12px}
|
|
195
|
+
.tn{color:var(--c);font-weight:700;margin-bottom:3px}
|
|
196
|
+
.ti{color:var(--m)}
|
|
197
|
+
.tr{color:var(--inks);margin-top:5px;padding-top:5px;border-top:1px solid var(--l);font-size:11px;white-space:pre-wrap;max-height:90px;overflow-y:auto}
|
|
198
|
+
.sy{font-family:monospace;font-size:11px;color:#d4903a;text-align:center;padding:4px}
|
|
199
|
+
.tk{display:flex;align-items:center;gap:8px;font-family:monospace;font-size:11px;color:var(--m);padding:6px 0}
|
|
200
|
+
.tk::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--c);flex-shrink:0;animation:p 1.2s infinite}
|
|
201
|
+
.sk{background:var(--s);border:1px solid var(--l2);border-left:2px solid var(--c);border-radius:6px;padding:13px 16px;color:var(--inks);line-height:1.65;white-space:pre-wrap}
|
|
202
|
+
.cur{display:inline-block;width:8px;height:14px;background:var(--c);margin-left:2px;animation:bk 1s steps(1) infinite;vertical-align:text-bottom}
|
|
203
|
+
.plc{border:1px solid var(--l2);border-radius:10px;padding:14px 16px;margin:4px 0}
|
|
204
|
+
.plh{color:var(--c);font-weight:700;font-size:13px;margin-bottom:8px}
|
|
205
|
+
.plg{color:var(--m);font-size:12px;margin-bottom:10px}
|
|
206
|
+
.ps{display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:12px;border-bottom:1px solid var(--l);color:var(--inks)}
|
|
207
|
+
.ps:last-child{border-bottom:none}
|
|
208
|
+
.ps .psi{width:20px;height:20px;border-radius:50%;text-align:center;line-height:20px;font-size:11px;flex-shrink:0;margin-top:1px}
|
|
209
|
+
.ps.wait .psi{background:var(--f);color:var(--m)}
|
|
210
|
+
.ps.running .psi{background:#d4903a;color:#fff;animation:p 1.2s infinite}
|
|
211
|
+
.ps.done .psi{background:var(--g);color:#fff}
|
|
212
|
+
.ps.failed .psi{background:var(--cd);color:#fff}
|
|
213
|
+
.ps .psb{flex:1}
|
|
214
|
+
.ps .pss{font-weight:600;color:var(--inks)}
|
|
215
|
+
.ps .pst{color:var(--m);font-size:11px}
|
|
216
|
+
.ps .psr{font-size:10px;color:var(--g);margin-top:2px}
|
|
217
|
+
@keyframes p{0%,100%{opacity:1}50%{opacity:.3}}
|
|
218
|
+
@keyframes bk{0%,100%{opacity:1}50%{opacity:0}}
|
|
219
|
+
</style>
|
|
220
|
+
</head>
|
|
221
|
+
<body>
|
|
222
|
+
<div class="app">
|
|
223
|
+
<div class="bar">
|
|
224
|
+
<div class="logo">Aura</div>
|
|
225
|
+
<div class="proj">${project}</div>
|
|
226
|
+
<div class="dot" id="dot"></div>
|
|
227
|
+
<select id="ms">${modelOpts}</select>
|
|
228
|
+
<button class="btn-r" id="btnR">New chat</button>
|
|
229
|
+
</div>
|
|
230
|
+
<div class="chat" id="ch"></div>
|
|
231
|
+
<div class="ibar">
|
|
232
|
+
<div class="iw">
|
|
233
|
+
<textarea id="inp" rows="1" placeholder="Ask anything about your code\u2026"></textarea>
|
|
234
|
+
<button id="sb">\u2191</button>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
<script>
|
|
239
|
+
(function() {
|
|
240
|
+
var ch = document.getElementById('ch');
|
|
241
|
+
var inp = document.getElementById('inp');
|
|
242
|
+
var sb = document.getElementById('sb');
|
|
243
|
+
var dot = document.getElementById('dot');
|
|
244
|
+
var ms = document.getElementById('ms');
|
|
245
|
+
var btnR = document.getElementById('btnR');
|
|
246
|
+
|
|
247
|
+
ms.value = '${defaultModel}';
|
|
248
|
+
if (!ms.value) ms.selectedIndex = 0;
|
|
249
|
+
|
|
250
|
+
var ws, busy = false, sEl = null, sText = '', tEl = null, pEl = null;
|
|
251
|
+
|
|
252
|
+
function conn() {
|
|
253
|
+
ws = new WebSocket('ws://' + location.host);
|
|
254
|
+
ws.onopen = function() { dot.className = 'dot on'; lh(); };
|
|
255
|
+
ws.onclose = function() { dot.className = 'dot'; setTimeout(conn, 2000); };
|
|
256
|
+
ws.onmessage = function(e) { hv(JSON.parse(e.data)); };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function hv(d) {
|
|
260
|
+
if (d.type === 'plan_creating') { pEl = mk('div','plc'); pEl.innerHTML = '<div class="plh">Orchestrator</div><div class="plg">Creating execution plan\u2026</div>'; ch.appendChild(pEl); sc(); return; }
|
|
261
|
+
if (d.type === 'plan_created') { rp(d.plan); sc(); return; }
|
|
262
|
+
if (d.type === 'step_started') { us(d.step); sc(); return; }
|
|
263
|
+
if (d.type === 'step_completed') { uf(d.step, d.result); sc(); return; }
|
|
264
|
+
if (d.type === 'plan_done') { idle(); if (d.outcome) { var e = mk('div','ma'); e.innerHTML = '<div class="b">' + ex(d.outcome) + '</div>'; ch.appendChild(e); } fn(); sc(); return; }
|
|
265
|
+
if (d.type === 'thinking') { rt(); var e = mk('div','tk'); e.id = 'thi'; e.textContent = 'thinking\u2026'; ch.appendChild(e); sc(); return; }
|
|
266
|
+
if (d.type === 'text') { rt(); if (!sEl) { sEl = mk('div','sk'); ch.appendChild(sEl); } sText += d.text; sEl.innerHTML = ex(sText) + '<span class="cur"></span>'; sc(); return; }
|
|
267
|
+
if (d.type === 'text_end' || d.type === 'done') { fn(); if (d.type === 'done') idle(); sc(); return; }
|
|
268
|
+
if (d.type === 'tool_call') { rt(); var e = mk('div','mt'); e.innerHTML = '<div class="tn">' + ic(d.name) + ' ' + d.name + '</div><div class="ti">' + ex(si(d.name, d.input)) + '</div><div class="tr">running\u2026</div>'; ch.appendChild(e); tEl = e; sc(); return; }
|
|
269
|
+
if (d.type === 'tool_result') { if (tEl) { var r = tEl.querySelector('.tr'), ls = d.result.split('\\n'); r.textContent = ls.length > 5 ? ls.slice(0,5).join('\\n') + '\\n\u2026(+' + (ls.length-5) + ' lines)' : d.result; } tEl = null; return; }
|
|
270
|
+
if (d.type === 'error' || d.type === 'warning') { var e = mk('div','sy'); e.textContent = d.message || d.reason || ''; ch.appendChild(e); if (d.type === 'error') idle(); sc(); return; }
|
|
271
|
+
if (d.type === 'reset_ok') { ch.innerHTML = ''; }
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function rp(plan) {
|
|
275
|
+
if (!pEl) pEl = mk('div','plc');
|
|
276
|
+
var h = '<div class="plh">Execution Plan</div><div class="plg">' + ex(plan.goal||'') + '</div>';
|
|
277
|
+
for (var i = 0; i < (plan.steps||[]).length; i++) {
|
|
278
|
+
var s = plan.steps[i];
|
|
279
|
+
var cls = s.specialist === 'researcher' ? 'R' : s.specialist === 'coder' ? 'C' : s.specialist === 'reviewer' ? 'V' : 'P';
|
|
280
|
+
h += '<div class="ps wait" id="ps-' + s.id + '"><div class="psi">' + cls + '</div><div class="psb"><div class="pss">[' + s.specialist + '] ' + ex(s.task||'') + '</div></div></div>';
|
|
281
|
+
}
|
|
282
|
+
pEl.innerHTML = h;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function us(step) {
|
|
286
|
+
var e = document.getElementById('ps-' + step.id);
|
|
287
|
+
if (e) { e.className = 'ps running'; e.querySelector('.psi').textContent = '\u2026'; }
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function uf(step, result) {
|
|
291
|
+
var e = document.getElementById('ps-' + step.id);
|
|
292
|
+
if (e) {
|
|
293
|
+
e.className = result ? 'ps done' : 'ps failed';
|
|
294
|
+
var cls = step.specialist === 'researcher' ? 'R' : step.specialist === 'coder' ? 'C' : step.specialist === 'reviewer' ? 'V' : 'P';
|
|
295
|
+
e.querySelector('.psi').textContent = '\\u2713';
|
|
296
|
+
if (result) {
|
|
297
|
+
var re = mk('div','psr'); re.textContent = String(result||'').slice(0,120); e.appendChild(re);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function rt() { var t = document.getElementById('thi'); if (t) t.remove(); }
|
|
303
|
+
function fn() { rt(); if (sEl && sText) { var d = mk('div','ma'); d.innerHTML = '<div class="b">' + ex(sText) + '</div>'; sEl.replaceWith(d); } else if (sEl) sEl.remove(); sEl = null; sText = ''; tEl = null; }
|
|
304
|
+
function idle() { busy = false; sb.disabled = false; }
|
|
305
|
+
function mk(tag, cls) { var e = document.createElement(tag); e.className = cls; return e; }
|
|
306
|
+
function ex(s) { return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }
|
|
307
|
+
function sc() { ch.scrollTop = ch.scrollHeight; }
|
|
308
|
+
function ic(n) { return ({read_file:'\ud83d\udcc4',list_dir:'\ud83d\udcc1',edit_file:'\u270f\ufe0f',write_file:'\ud83d\udcdd',search_code:'\ud83d\udd0d',run_shell:'\u26a1',run_tests:'\ud83e\uddea',git_status:'\ud83c\udf3f',git_diff:'\ud83d\udcca'})[n] || '\ud83d\udd27'; }
|
|
309
|
+
function si(n, i) { if (n==='read_file') return (i.path||'') + (i.start_line ? ':'+i.start_line+'-'+(i.end_line||'?') : ''); if (n==='run_shell') return '$ ' + (i.command||''); if (n==='search_code') return '"' + (i.pattern||'') + '"'; return i.path || JSON.stringify(i).slice(0,60); }
|
|
310
|
+
|
|
311
|
+
function go() {
|
|
312
|
+
var t = inp.value.trim();
|
|
313
|
+
if (!t || busy) return;
|
|
314
|
+
var e = mk('div','mu'); e.innerHTML = '<div class="b">' + ex(t) + '</div>'; ch.appendChild(e);
|
|
315
|
+
inp.value = ''; ar(); busy = true; sb.disabled = true;
|
|
316
|
+
ws.send(JSON.stringify({ type: 'task', task: t, model: ms.value }));
|
|
317
|
+
sc();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function ar() { inp.style.height = 'auto'; inp.style.height = Math.min(inp.scrollHeight, 130) + 'px'; }
|
|
321
|
+
|
|
322
|
+
async function lh() {
|
|
323
|
+
var msgs = await fetch('/api/history').then(function(r) { return r.json(); });
|
|
324
|
+
msgs.forEach(function(m) {
|
|
325
|
+
if (m.role === 'user') { var e = mk('div','mu'); e.innerHTML = '<div class="b">' + ex(m.content) + '</div>'; ch.appendChild(e); }
|
|
326
|
+
else if (m.role === 'assistant' && m.content) { var e = mk('div','ma'); e.innerHTML = '<div class="b">' + ex(m.content) + '</div>'; ch.appendChild(e); }
|
|
327
|
+
});
|
|
328
|
+
sc();
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
sb.addEventListener('click', go);
|
|
332
|
+
inp.addEventListener('keydown', function(e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); go(); } });
|
|
333
|
+
inp.addEventListener('input', ar);
|
|
334
|
+
btnR.addEventListener('click', function() { fetch('/api/reset', { method: 'POST' }); ws.send(JSON.stringify({ type: 'reset' })); });
|
|
335
|
+
|
|
336
|
+
conn();
|
|
337
|
+
})();
|
|
338
|
+
</script>
|
|
339
|
+
</body>
|
|
340
|
+
</html>`;
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,kCAyFC;AA1GD,2CAA6B;AAC7B,sDAA8B;AAC9B,2BAAgD;AAChD,wDAAuE;AACvE,oDAAyD;AACzD,8CAAgD;AAChD,6DAA4D;AAC5D,6CAAuC;AACvC,wDAA+E;AASxE,KAAK,UAAU,WAAW,CAAC,IAAkB;IAClD,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;IACtB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,IAAI,oBAAe,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACxB,MAAM,GAAG,GAAG,MAAM,IAAA,+BAAkB,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,OAAO,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AC,GAAG,CAAC,kCAAkC,GAAG,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,IAAI,CAAC,EAAa,EAAE,IAAY;IACvC,IAAI,EAAE,CAAC,UAAU,KAAK,cAAS,CAAC,IAAI;QAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,OAAO,CAAC,OAAe,EAAE,YAAoB;IACpD,MAAM,SAAS,GAAG,yBAAY;SAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,QAAQ,WAAW,CAAC,CAAC,IAAI,WAAW,CAAC;SAC3E,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,OAAO;;;;;SAKA,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8DQ,OAAO;;sBAET,SAAS;;;;;;;;;;;;;;;;;;;;gBAoBf,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6FpB,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HistoryMessage } from '../providers/types.js';
|
|
2
|
+
export interface SessionMessage {
|
|
3
|
+
id: string;
|
|
4
|
+
role: string;
|
|
5
|
+
content: string;
|
|
6
|
+
toolName?: string;
|
|
7
|
+
toolInput?: Record<string, unknown>;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
turns?: number;
|
|
10
|
+
toolCount?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class Session {
|
|
13
|
+
private history;
|
|
14
|
+
private display;
|
|
15
|
+
private n;
|
|
16
|
+
getHistory(): HistoryMessage[];
|
|
17
|
+
getDisplay(): SessionMessage[];
|
|
18
|
+
addUser(content: string): void;
|
|
19
|
+
addAssistant(content: string, turns?: number, toolCount?: number): void;
|
|
20
|
+
addTool(toolName: string, toolInput: Record<string, unknown>, content: string): void;
|
|
21
|
+
reset(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Session = void 0;
|
|
4
|
+
class Session {
|
|
5
|
+
history = [];
|
|
6
|
+
display = [];
|
|
7
|
+
n = 0;
|
|
8
|
+
getHistory() { return [...this.history]; }
|
|
9
|
+
getDisplay() { return [...this.display]; }
|
|
10
|
+
addUser(content) { this.history.push({ role: 'user', content }); this.display.push({ id: 'm' + (++this.n), role: 'user', content, timestamp: Date.now() }); }
|
|
11
|
+
addAssistant(content, turns = 0, toolCount = 0) { this.display.push({ id: 'm' + (++this.n), role: 'assistant', content, timestamp: Date.now(), turns, toolCount }); }
|
|
12
|
+
addTool(toolName, toolInput, content) { this.display.push({ id: 'm' + (++this.n), role: 'tool_call', toolName, toolInput, content, timestamp: Date.now() }); }
|
|
13
|
+
reset() { this.history = []; this.display = []; }
|
|
14
|
+
}
|
|
15
|
+
exports.Session = Session;
|
|
16
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/server/session.ts"],"names":[],"mappings":";;;AAMA,MAAa,OAAO;IACV,OAAO,GAAqB,EAAE,CAAC;IAC/B,OAAO,GAAqB,EAAE,CAAC;IAC/B,CAAC,GAAG,CAAC,CAAC;IACd,UAAU,KAAK,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1C,UAAU,KAAK,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,OAAe,IAAI,IAAI,CAAC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rl?: string;
|
|
8
|
+
description: string;
|
|
9
|
+
models: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare const PROVIDER_CHOICES: ProviderChoice[];
|
|
12
|
+
/** True iff the user has a saved global config (their default provider). */
|
|
13
|
+
export declare function hasGlobalConfig(): boolean;
|
|
14
|
+
/** True iff the user has set at least one known provider env var (any case). */
|
|
15
|
+
export declare function hasAnyEnvKey(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Pure detection: would we need the wizard?
|
|
18
|
+
*
|
|
19
|
+
* The wizard fires when the user has no MODEL picked. An API key in env
|
|
20
|
+
* does NOT count as "configured" — the user still needs to choose a model.
|
|
21
|
+
* The wizard will detect the env key and pre-select that provider.
|
|
22
|
+
*/
|
|
23
|
+
export declare function needsWizard(opts?: {
|
|
24
|
+
cliApiKey?: string;
|
|
25
|
+
cliModel?: string;
|
|
26
|
+
}): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Pick a provider automatically when exactly one of the known env vars is set.
|
|
29
|
+
* Returns the provider id (e.g. 'anthropic') or null if 0 / 2+ match.
|
|
30
|
+
* Used by the wizard to pre-select the provider menu option and skip the
|
|
31
|
+
* API-key prompt when the user already has a key in their shell.
|
|
32
|
+
*/
|
|
33
|
+
export declare function detectProviderFromEnv(): string | null;
|
|
34
|
+
/** Kept for backward compatibility (some callers still use it). */
|
|
35
|
+
export declare function hasAnyProvider(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Run the wizard. Returns the chosen config, or null if the user aborted.
|
|
38
|
+
* Saves to the global config and exports the API key env var for the
|
|
39
|
+
* current process so the rest of the run works without re-prompting.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runFirstRunWizard(): Promise<GlobalConfig | null>;
|