opencandle 0.7.0 → 0.8.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/README.md +34 -21
- package/dist/cli-main.d.ts +1 -0
- package/dist/cli-main.js +200 -0
- package/dist/cli-main.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +13 -229
- package/dist/cli.js.map +1 -1
- package/dist/doctor/cli-command.d.ts +1 -0
- package/dist/doctor/cli-command.js +69 -0
- package/dist/doctor/cli-command.js.map +1 -0
- package/dist/doctor/render.d.ts +2 -0
- package/dist/doctor/render.js +32 -0
- package/dist/doctor/render.js.map +1 -0
- package/dist/doctor/report.d.ts +63 -0
- package/dist/doctor/report.js +500 -0
- package/dist/doctor/report.js.map +1 -0
- package/dist/infra/native-dependencies.d.ts +8 -0
- package/dist/infra/native-dependencies.js +49 -0
- package/dist/infra/native-dependencies.js.map +1 -1
- package/dist/infra/node-version.js +2 -5
- package/dist/infra/node-version.js.map +1 -1
- package/dist/monitor.d.ts +1 -1
- package/dist/monitor.js +2 -1
- package/dist/monitor.js.map +1 -1
- package/dist/onboarding/provider-status.d.ts +3 -5
- package/dist/onboarding/provider-status.js +5 -34
- package/dist/onboarding/provider-status.js.map +1 -1
- package/dist/pi/session.d.ts +0 -1
- package/dist/pi/session.js +2 -1
- package/dist/pi/session.js.map +1 -1
- package/dist/prompts/policy-cards.js +8 -4
- package/dist/prompts/policy-cards.js.map +1 -1
- package/dist/prompts/workflow-prompts.js +10 -6
- package/dist/prompts/workflow-prompts.js.map +1 -1
- package/dist/providers/external-tool-command.d.ts +17 -0
- package/dist/providers/external-tool-command.js +114 -0
- package/dist/providers/external-tool-command.js.map +1 -0
- package/dist/providers/reddit-cli.d.ts +2 -6
- package/dist/providers/reddit-cli.js +4 -33
- package/dist/providers/reddit-cli.js.map +1 -1
- package/dist/providers/twitter-cli.d.ts +2 -6
- package/dist/providers/twitter-cli.js +4 -33
- package/dist/providers/twitter-cli.js.map +1 -1
- package/dist/routing/classify-intent.js +7 -3
- package/dist/routing/classify-intent.js.map +1 -1
- package/dist/routing/planning.js +9 -6
- package/dist/routing/planning.js.map +1 -1
- package/dist/routing/router.js +7 -3
- package/dist/routing/router.js.map +1 -1
- package/gui/server/http-routes.ts +419 -0
- package/gui/server/server.ts +29 -292
- package/gui/web/dist/assets/CatalogOverlay-CCVKwBUB.js +1 -0
- package/gui/web/dist/assets/index-Dm4Aom2_.js +69 -0
- package/gui/web/dist/assets/{index-hwbx24a5.css → index-UzZUg3dx.css} +1 -1
- package/gui/web/dist/index.html +2 -2
- package/package.json +13 -9
- package/src/cli-main.ts +233 -0
- package/src/cli.ts +14 -267
- package/src/doctor/cli-command.ts +83 -0
- package/src/doctor/render.ts +37 -0
- package/src/doctor/report.ts +638 -0
- package/src/infra/native-dependencies.ts +67 -0
- package/src/infra/node-version.ts +2 -5
- package/src/monitor.ts +3 -1
- package/src/onboarding/provider-status.ts +10 -38
- package/src/pi/session.ts +2 -1
- package/src/prompts/policy-cards.ts +12 -4
- package/src/prompts/workflow-prompts.ts +13 -6
- package/src/providers/external-tool-command.ts +164 -0
- package/src/providers/reddit-cli.ts +10 -41
- package/src/providers/twitter-cli.ts +10 -41
- package/src/routing/classify-intent.ts +11 -6
- package/src/routing/planning.ts +15 -10
- package/src/routing/router.ts +11 -6
- package/gui/web/dist/assets/CatalogOverlay-CgeY5Pkp.js +0 -1
- package/gui/web/dist/assets/index-C6W_2eAn.js +0 -69
package/README.md
CHANGED
|
@@ -8,19 +8,23 @@ npx opencandle gui
|
|
|
8
8
|
|
|
9
9
|
OpenCandle is an open source financial investigator: a terminal agent and local browser workbench for market research that starts from real provider data, shows source gaps, and keeps risk visible.
|
|
10
10
|
|
|
11
|
-
[
|
|
11
|
+
[](https://github.com/Kahtaf/OpenCandle/actions/workflows/ci.yml)
|
|
12
|
+
[](https://www.npmjs.com/package/opencandle)
|
|
13
|
+
[](https://github.com/Kahtaf/OpenCandle/blob/main/LICENSE)
|
|
14
|
+
|
|
15
|
+
[Docs](https://opencandle.app/docs/) | [First run](https://opencandle.app/docs/first-run.html) | [GUI quickstart](https://opencandle.app/docs/gui-quickstart.html) | [Data sources](https://opencandle.app/docs/data-sources.html) | [Build a tool](https://opencandle.app/docs/build-a-tool.html)
|
|
12
16
|
|
|
13
17
|
## See It Work
|
|
14
18
|
|
|
15
19
|
### Terminal UI
|
|
16
20
|
|
|
17
|
-
[](https://cdn.jsdelivr.net/gh/Kahtaf/OpenCandle@main/assets/opencandle-tui.mp4)
|
|
18
22
|
|
|
19
23
|
[Watch the terminal UI demo](https://cdn.jsdelivr.net/gh/Kahtaf/OpenCandle@main/assets/opencandle-tui.mp4) | [Download MP4](https://github.com/Kahtaf/OpenCandle/raw/refs/heads/main/assets/opencandle-tui.mp4)
|
|
20
24
|
|
|
21
25
|
### Local GUI
|
|
22
26
|
|
|
23
|
-
[](https://cdn.jsdelivr.net/gh/Kahtaf/OpenCandle@main/assets/opencandle-gui.mp4)
|
|
24
28
|
|
|
25
29
|
[Watch the local GUI demo](https://cdn.jsdelivr.net/gh/Kahtaf/OpenCandle@main/assets/opencandle-gui.mp4) | [Download MP4](https://github.com/Kahtaf/OpenCandle/raw/refs/heads/main/assets/opencandle-gui.mp4)
|
|
26
30
|
|
|
@@ -53,13 +57,13 @@ OpenCandle is read-only research software. It does not place trades, route order
|
|
|
53
57
|
|
|
54
58
|
## Quick Start
|
|
55
59
|
|
|
56
|
-
Requires Node.js
|
|
60
|
+
Requires Node.js `>=22.19.0 <27`.
|
|
57
61
|
|
|
58
62
|
```bash
|
|
59
63
|
npx opencandle
|
|
60
64
|
```
|
|
61
65
|
|
|
62
|
-
On first run, OpenCandle walks you through model setup.
|
|
66
|
+
On first run, OpenCandle walks you through model setup. In the terminal, you can use Pi sign-in when available or provide a model API key. In the GUI, use the API-key setup panel or complete terminal `/setup` first and refresh the browser. Data-provider keys are separate and optional.
|
|
63
67
|
|
|
64
68
|
Start the GUI instead:
|
|
65
69
|
|
|
@@ -69,7 +73,7 @@ npx opencandle gui
|
|
|
69
73
|
|
|
70
74
|
Then open `http://127.0.0.1:14567`.
|
|
71
75
|
|
|
72
|
-
For a five-minute path from install to a successful answer, see [
|
|
76
|
+
For a five-minute path from install to a successful answer, see [First Run](https://opencandle.app/docs/first-run.html).
|
|
73
77
|
|
|
74
78
|
## Example Prompts
|
|
75
79
|
|
|
@@ -93,13 +97,18 @@ Useful slash commands:
|
|
|
93
97
|
/analyze AAPL
|
|
94
98
|
```
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
Health diagnostics run from your shell:
|
|
97
101
|
|
|
98
102
|
```bash
|
|
99
103
|
opencandle doctor
|
|
104
|
+
opencandle doctor --json
|
|
105
|
+
opencandle doctor --sessions
|
|
106
|
+
opencandle doctor --full
|
|
100
107
|
opencandle doctor --enable twitter
|
|
101
108
|
```
|
|
102
109
|
|
|
110
|
+
The GUI also has a Diagnostics page at `/diagnostics` with the same health report, provider setup links, model setup actions, and an explicit browser-session check for Reddit and Twitter/X.
|
|
111
|
+
|
|
103
112
|
## Data Sources
|
|
104
113
|
|
|
105
114
|
| Area | Examples | Source |
|
|
@@ -134,7 +143,7 @@ Model access comes from Pi. Market data provider keys can be set in the environm
|
|
|
134
143
|
| `OPENCANDLE_GUI_PORT` | GUI port, default `14567` |
|
|
135
144
|
| `OPENCANDLE_NOTIFICATION_WEBHOOK_URL` | Optional local webhook target for alert/report notification delivery attempts |
|
|
136
145
|
|
|
137
|
-
Environment variables override `~/.opencandle/config.json`. See [
|
|
146
|
+
Environment variables override `~/.opencandle/config.json`. See [Configuration](https://opencandle.app/docs/configuration.html) for the full reference, including advanced routing and diagnostic switches.
|
|
138
147
|
|
|
139
148
|
## From Source
|
|
140
149
|
|
|
@@ -196,7 +205,7 @@ Package exports:
|
|
|
196
205
|
- `opencandle/tools`
|
|
197
206
|
- `opencandle/workflows`
|
|
198
207
|
|
|
199
|
-
If you want to add a new first-party tool or publish an add-on package, start with [
|
|
208
|
+
If you want to add a new first-party tool or publish an add-on package, start with [Build a Tool](https://opencandle.app/docs/build-a-tool.html).
|
|
200
209
|
|
|
201
210
|
## Development
|
|
202
211
|
|
|
@@ -220,7 +229,7 @@ Baseline check:
|
|
|
220
229
|
npm test
|
|
221
230
|
```
|
|
222
231
|
|
|
223
|
-
The e2e, provider, and eval commands can hit live APIs, live model providers, or local agent CLIs. Run them intentionally; see [
|
|
232
|
+
The e2e, provider, and eval commands can hit live APIs, live model providers, or local agent CLIs. Run them intentionally; see [Testing and Evals](https://opencandle.app/docs/testing-and-evals.html).
|
|
224
233
|
|
|
225
234
|
Repository rules that matter:
|
|
226
235
|
|
|
@@ -238,21 +247,25 @@ npx tsx tests/harness/cli.ts wait --ipc /tmp/opencandle-ipc
|
|
|
238
247
|
npx tsx tests/harness/cli.ts trace --ipc /tmp/opencandle-ipc
|
|
239
248
|
```
|
|
240
249
|
|
|
241
|
-
See [tests/harness/README.md](
|
|
250
|
+
See [tests/harness/README.md](https://github.com/Kahtaf/OpenCandle/blob/main/tests/harness/README.md) for the full flow.
|
|
242
251
|
|
|
243
252
|
## Documentation
|
|
244
253
|
|
|
245
|
-
- [Getting Started](
|
|
246
|
-
- [First Run](
|
|
247
|
-
- [TUI](
|
|
248
|
-
- [GUI Quickstart](
|
|
249
|
-
- [Investigation Recipes](
|
|
250
|
-
- [Data Sources](
|
|
251
|
-
- [Configuration](
|
|
252
|
-
- [System Architecture](
|
|
253
|
-
- [Testing and Evals](
|
|
254
|
-
- [Benchmarking](
|
|
254
|
+
- [Getting Started](https://opencandle.app/docs/getting-started.html)
|
|
255
|
+
- [First Run](https://opencandle.app/docs/first-run.html)
|
|
256
|
+
- [TUI](https://opencandle.app/docs/tui.html)
|
|
257
|
+
- [GUI Quickstart](https://opencandle.app/docs/gui-quickstart.html)
|
|
258
|
+
- [Investigation Recipes](https://opencandle.app/docs/investigation-recipes.html)
|
|
259
|
+
- [Data Sources](https://opencandle.app/docs/data-sources.html)
|
|
260
|
+
- [Configuration](https://opencandle.app/docs/configuration.html)
|
|
261
|
+
- [System Architecture](https://opencandle.app/docs/system-architecture.html)
|
|
262
|
+
- [Testing and Evals](https://opencandle.app/docs/testing-and-evals.html)
|
|
263
|
+
- [Benchmarking](https://opencandle.app/docs/benchmarking.html)
|
|
255
264
|
|
|
256
265
|
## License
|
|
257
266
|
|
|
258
267
|
MIT
|
|
268
|
+
|
|
269
|
+
## Contributing and Security
|
|
270
|
+
|
|
271
|
+
See [Contributing](https://opencandle.app/docs/contributing.html), [Security](https://opencandle.app/docs/security.html), and the [Code of Conduct](https://github.com/Kahtaf/OpenCandle/blob/main/CODE_OF_CONDUCT.md) before opening large changes or reporting sensitive issues. Redact API keys, account identifiers, holdings, and local state from public issues.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli-main.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { AuthStorage, createAgentSessionRuntime, createAgentSessionServices, DefaultPackageManager, getAgentDir, InteractiveMode, initTheme, ModelRegistry, SettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { loadEnv } from "./config.js";
|
|
7
|
+
import { handleDoctorCommand } from "./doctor/cli-command.js";
|
|
8
|
+
import { createOpenCandleSession } from "./pi/session.js";
|
|
9
|
+
import { continueOpenCandleSession } from "./pi/session-storage.js";
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
12
|
+
async function handlePackageCommand(args, cwd, agentDir) {
|
|
13
|
+
const [command, ...rest] = args;
|
|
14
|
+
if (!command || !["install", "remove", "uninstall", "list", "update"].includes(command)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const settingsManager = SettingsManager.create(cwd, agentDir);
|
|
18
|
+
const packageManager = new DefaultPackageManager({
|
|
19
|
+
cwd,
|
|
20
|
+
agentDir,
|
|
21
|
+
settingsManager,
|
|
22
|
+
});
|
|
23
|
+
packageManager.setProgressCallback((event) => {
|
|
24
|
+
if (event.type === "start" || event.type === "progress") {
|
|
25
|
+
process.stdout.write(`${event.message}\n`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const source = rest.find((a) => !a.startsWith("-"));
|
|
29
|
+
const local = rest.includes("-l") || rest.includes("--local");
|
|
30
|
+
switch (command === "uninstall" ? "remove" : command) {
|
|
31
|
+
case "install": {
|
|
32
|
+
if (!source) {
|
|
33
|
+
console.error("Usage: opencandle install <source> [-l]");
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
await packageManager.install(source, { local });
|
|
38
|
+
packageManager.addSourceToSettings(source, { local });
|
|
39
|
+
console.log(`Installed ${source}`);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
case "remove": {
|
|
43
|
+
if (!source) {
|
|
44
|
+
console.error("Usage: opencandle remove <source> [-l]");
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
await packageManager.remove(source, { local });
|
|
49
|
+
const removed = packageManager.removeSourceFromSettings(source, {
|
|
50
|
+
local,
|
|
51
|
+
});
|
|
52
|
+
if (!removed) {
|
|
53
|
+
console.error(`No matching package found for ${source}`);
|
|
54
|
+
process.exitCode = 1;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
console.log(`Removed ${source}`);
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
case "list": {
|
|
62
|
+
const globalPkgs = settingsManager.getGlobalSettings().packages ?? [];
|
|
63
|
+
const projectPkgs = settingsManager.getProjectSettings().packages ?? [];
|
|
64
|
+
if (globalPkgs.length === 0 && projectPkgs.length === 0) {
|
|
65
|
+
console.log("No packages installed.");
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (globalPkgs.length > 0) {
|
|
69
|
+
console.log("User packages:");
|
|
70
|
+
for (const pkg of globalPkgs) {
|
|
71
|
+
const s = typeof pkg === "string" ? pkg : pkg.source;
|
|
72
|
+
const path = packageManager.getInstalledPath(s, "user");
|
|
73
|
+
console.log(` ${s}${path ? `\n ${path}` : ""}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (projectPkgs.length > 0) {
|
|
77
|
+
console.log("Project packages:");
|
|
78
|
+
for (const pkg of projectPkgs) {
|
|
79
|
+
const s = typeof pkg === "string" ? pkg : pkg.source;
|
|
80
|
+
const path = packageManager.getInstalledPath(s, "project");
|
|
81
|
+
console.log(` ${s}${path ? `\n ${path}` : ""}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
case "update": {
|
|
87
|
+
await packageManager.update(source);
|
|
88
|
+
console.log(source ? `Updated ${source}` : "All packages updated.");
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
async function handleGuiCommand(args, cwd) {
|
|
95
|
+
if (args[0] !== "gui")
|
|
96
|
+
return false;
|
|
97
|
+
const tsxCli = require.resolve("tsx/cli");
|
|
98
|
+
const serverPath = resolve(packageRoot, "gui/server/server.ts");
|
|
99
|
+
const child = spawn(process.execPath, [tsxCli, serverPath, ...args.slice(1)], {
|
|
100
|
+
cwd,
|
|
101
|
+
env: process.env,
|
|
102
|
+
stdio: "inherit",
|
|
103
|
+
});
|
|
104
|
+
const exitCode = await new Promise((resolveExit) => {
|
|
105
|
+
child.on("close", (code, signal) => {
|
|
106
|
+
if (signal) {
|
|
107
|
+
resolveExit(1);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
resolveExit(code ?? 0);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
process.exitCode = exitCode;
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
async function handleMonitorCommand(args, cwd) {
|
|
118
|
+
if (args[0] !== "monitor")
|
|
119
|
+
return false;
|
|
120
|
+
const tsxCli = require.resolve("tsx/cli");
|
|
121
|
+
const monitorPath = resolve(packageRoot, "src/monitor.ts");
|
|
122
|
+
const child = spawn(process.execPath, [tsxCli, monitorPath, ...args.slice(1)], {
|
|
123
|
+
cwd,
|
|
124
|
+
env: process.env,
|
|
125
|
+
stdio: "inherit",
|
|
126
|
+
});
|
|
127
|
+
const exitCode = await new Promise((resolveExit) => {
|
|
128
|
+
child.on("close", (code, signal) => {
|
|
129
|
+
if (signal) {
|
|
130
|
+
resolveExit(1);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
resolveExit(code ?? 0);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
process.exitCode = exitCode;
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
async function main() {
|
|
141
|
+
const rawArgs = process.argv.slice(2);
|
|
142
|
+
const cwd = process.cwd();
|
|
143
|
+
const agentDir = getAgentDir();
|
|
144
|
+
loadEnv();
|
|
145
|
+
if (await handleGuiCommand(rawArgs, cwd)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (await handleMonitorCommand(rawArgs, cwd)) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (await handleDoctorCommand(rawArgs, cwd, agentDir)) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (await handlePackageCommand(rawArgs, cwd, agentDir)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
// Default: start the OpenCandle interactive agent
|
|
158
|
+
const settingsManager = SettingsManager.create(cwd, agentDir);
|
|
159
|
+
const authStorage = AuthStorage.create();
|
|
160
|
+
const modelRegistry = ModelRegistry.create(authStorage);
|
|
161
|
+
const shouldSuppressFallbackMessage = modelRegistry.getAvailable().length === 0;
|
|
162
|
+
initTheme(settingsManager.getTheme(), true);
|
|
163
|
+
const sessionManager = continueOpenCandleSession(cwd);
|
|
164
|
+
const runtime = await createAgentSessionRuntime(async (opts) => {
|
|
165
|
+
const services = await createAgentSessionServices({
|
|
166
|
+
cwd: opts.cwd,
|
|
167
|
+
agentDir: opts.agentDir,
|
|
168
|
+
authStorage,
|
|
169
|
+
settingsManager,
|
|
170
|
+
modelRegistry,
|
|
171
|
+
});
|
|
172
|
+
const result = await createOpenCandleSession({
|
|
173
|
+
cwd: opts.cwd,
|
|
174
|
+
agentDir: opts.agentDir,
|
|
175
|
+
settingsManager,
|
|
176
|
+
authStorage,
|
|
177
|
+
modelRegistry,
|
|
178
|
+
sessionManager: opts.sessionManager,
|
|
179
|
+
bindExtensions: false,
|
|
180
|
+
});
|
|
181
|
+
return {
|
|
182
|
+
...result,
|
|
183
|
+
services,
|
|
184
|
+
diagnostics: services.diagnostics,
|
|
185
|
+
};
|
|
186
|
+
}, { cwd, agentDir, sessionManager });
|
|
187
|
+
try {
|
|
188
|
+
const interactiveMode = new InteractiveMode(runtime, {
|
|
189
|
+
modelFallbackMessage: shouldSuppressFallbackMessage
|
|
190
|
+
? undefined
|
|
191
|
+
: runtime.modelFallbackMessage,
|
|
192
|
+
});
|
|
193
|
+
await interactiveMode.run();
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
await runtime.dispose();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
await main();
|
|
200
|
+
//# sourceMappingURL=cli-main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-main.js","sourceRoot":"","sources":["../src/cli-main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM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
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import { getProvider } from "./onboarding/providers.js";
|
|
11
|
-
import { clearProviderOnboardingEntry, loadOnboardingState, saveOnboardingState, } from "./onboarding/state.js";
|
|
12
|
-
import { createOpenCandleSession } from "./pi/session.js";
|
|
13
|
-
import { continueOpenCandleSession } from "./pi/session-storage.js";
|
|
14
|
-
const require = createRequire(import.meta.url);
|
|
15
|
-
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
16
|
-
async function handlePackageCommand(args, cwd, agentDir) {
|
|
17
|
-
const [command, ...rest] = args;
|
|
18
|
-
if (!command || !["install", "remove", "uninstall", "list", "update"].includes(command)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
const settingsManager = SettingsManager.create(cwd, agentDir);
|
|
22
|
-
const packageManager = new DefaultPackageManager({
|
|
23
|
-
cwd,
|
|
24
|
-
agentDir,
|
|
25
|
-
settingsManager,
|
|
26
|
-
});
|
|
27
|
-
packageManager.setProgressCallback((event) => {
|
|
28
|
-
if (event.type === "start" || event.type === "progress") {
|
|
29
|
-
process.stdout.write(`${event.message}\n`);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const source = rest.find((a) => !a.startsWith("-"));
|
|
33
|
-
const local = rest.includes("-l") || rest.includes("--local");
|
|
34
|
-
switch (command === "uninstall" ? "remove" : command) {
|
|
35
|
-
case "install": {
|
|
36
|
-
if (!source) {
|
|
37
|
-
console.error("Usage: opencandle install <source> [-l]");
|
|
38
|
-
process.exitCode = 1;
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
await packageManager.install(source, { local });
|
|
42
|
-
packageManager.addSourceToSettings(source, { local });
|
|
43
|
-
console.log(`Installed ${source}`);
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
case "remove": {
|
|
47
|
-
if (!source) {
|
|
48
|
-
console.error("Usage: opencandle remove <source> [-l]");
|
|
49
|
-
process.exitCode = 1;
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
await packageManager.remove(source, { local });
|
|
53
|
-
const removed = packageManager.removeSourceFromSettings(source, {
|
|
54
|
-
local,
|
|
55
|
-
});
|
|
56
|
-
if (!removed) {
|
|
57
|
-
console.error(`No matching package found for ${source}`);
|
|
58
|
-
process.exitCode = 1;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
console.log(`Removed ${source}`);
|
|
62
|
-
}
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
case "list": {
|
|
66
|
-
const globalPkgs = settingsManager.getGlobalSettings().packages ?? [];
|
|
67
|
-
const projectPkgs = settingsManager.getProjectSettings().packages ?? [];
|
|
68
|
-
if (globalPkgs.length === 0 && projectPkgs.length === 0) {
|
|
69
|
-
console.log("No packages installed.");
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
if (globalPkgs.length > 0) {
|
|
73
|
-
console.log("User packages:");
|
|
74
|
-
for (const pkg of globalPkgs) {
|
|
75
|
-
const s = typeof pkg === "string" ? pkg : pkg.source;
|
|
76
|
-
const path = packageManager.getInstalledPath(s, "user");
|
|
77
|
-
console.log(` ${s}${path ? `\n ${path}` : ""}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (projectPkgs.length > 0) {
|
|
81
|
-
console.log("Project packages:");
|
|
82
|
-
for (const pkg of projectPkgs) {
|
|
83
|
-
const s = typeof pkg === "string" ? pkg : pkg.source;
|
|
84
|
-
const path = packageManager.getInstalledPath(s, "project");
|
|
85
|
-
console.log(` ${s}${path ? `\n ${path}` : ""}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
case "update": {
|
|
91
|
-
await packageManager.update(source);
|
|
92
|
-
console.log(source ? `Updated ${source}` : "All packages updated.");
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
async function handleGuiCommand(args, cwd) {
|
|
99
|
-
if (args[0] !== "gui")
|
|
100
|
-
return false;
|
|
101
|
-
const tsxCli = require.resolve("tsx/cli");
|
|
102
|
-
const serverPath = resolve(packageRoot, "gui/server/server.ts");
|
|
103
|
-
const child = spawn(process.execPath, [tsxCli, serverPath, ...args.slice(1)], {
|
|
104
|
-
cwd,
|
|
105
|
-
env: process.env,
|
|
106
|
-
stdio: "inherit",
|
|
107
|
-
});
|
|
108
|
-
const exitCode = await new Promise((resolveExit) => {
|
|
109
|
-
child.on("close", (code, signal) => {
|
|
110
|
-
if (signal) {
|
|
111
|
-
resolveExit(1);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
resolveExit(code ?? 0);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
process.exitCode = exitCode;
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
async function handleMonitorCommand(args, cwd) {
|
|
122
|
-
if (args[0] !== "monitor")
|
|
123
|
-
return false;
|
|
124
|
-
const tsxCli = require.resolve("tsx/cli");
|
|
125
|
-
const monitorPath = resolve(packageRoot, "src/monitor.ts");
|
|
126
|
-
const child = spawn(process.execPath, [tsxCli, monitorPath, ...args.slice(1)], {
|
|
127
|
-
cwd,
|
|
128
|
-
env: process.env,
|
|
129
|
-
stdio: "inherit",
|
|
130
|
-
});
|
|
131
|
-
const exitCode = await new Promise((resolveExit) => {
|
|
132
|
-
child.on("close", (code, signal) => {
|
|
133
|
-
if (signal) {
|
|
134
|
-
resolveExit(1);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
resolveExit(code ?? 0);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
process.exitCode = exitCode;
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
async function handleDoctorCommand(args) {
|
|
145
|
-
if (args[0] !== "doctor")
|
|
146
|
-
return false;
|
|
2
|
+
import { ensureOpenCandleNativeDependencies } from "./infra/native-dependencies.js";
|
|
3
|
+
import { assertSupportedNodeVersion } from "./infra/node-version.js";
|
|
4
|
+
if (process.argv[2] === "doctor") {
|
|
5
|
+
const [{ loadEnv }, { handleDoctorCommand }, { getAgentDir }] = await Promise.all([
|
|
6
|
+
import("./config.js"),
|
|
7
|
+
import("./doctor/cli-command.js"),
|
|
8
|
+
import("@earendil-works/pi-coding-agent"),
|
|
9
|
+
]);
|
|
147
10
|
loadEnv();
|
|
148
|
-
|
|
149
|
-
if (enableFlag >= 0) {
|
|
150
|
-
const providerId = args[enableFlag + 1];
|
|
151
|
-
if (!providerId) {
|
|
152
|
-
console.error("Usage: opencandle doctor --enable <provider>");
|
|
153
|
-
process.exitCode = 1;
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
getProvider(providerId);
|
|
158
|
-
}
|
|
159
|
-
catch {
|
|
160
|
-
console.error(`Unknown provider: ${providerId}`);
|
|
161
|
-
process.exitCode = 1;
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
164
|
-
saveOnboardingState(clearProviderOnboardingEntry(loadOnboardingState(), providerId));
|
|
165
|
-
console.log(`Re-enabled ${providerId}.`);
|
|
166
|
-
}
|
|
167
|
-
const statuses = await probeAllProviderStatuses({ force: args.includes("--no-cache") });
|
|
168
|
-
console.log("OpenCandle provider status");
|
|
169
|
-
for (const status of statuses) {
|
|
170
|
-
console.log(` ${formatProviderStatus(status)}`);
|
|
171
|
-
}
|
|
172
|
-
return true;
|
|
11
|
+
await handleDoctorCommand(process.argv.slice(2), process.cwd(), getAgentDir());
|
|
173
12
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (await handleGuiCommand(rawArgs, cwd)) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (await handleMonitorCommand(rawArgs, cwd)) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (await handleDoctorCommand(rawArgs)) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
if (await handlePackageCommand(rawArgs, cwd, agentDir)) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
// Default: start the OpenCandle interactive agent
|
|
191
|
-
loadEnv();
|
|
192
|
-
const settingsManager = SettingsManager.create(cwd, agentDir);
|
|
193
|
-
const authStorage = AuthStorage.create();
|
|
194
|
-
const modelRegistry = ModelRegistry.create(authStorage);
|
|
195
|
-
const shouldSuppressFallbackMessage = modelRegistry.getAvailable().length === 0;
|
|
196
|
-
initTheme(settingsManager.getTheme(), true);
|
|
197
|
-
const sessionManager = continueOpenCandleSession(cwd);
|
|
198
|
-
const runtime = await createAgentSessionRuntime(async (opts) => {
|
|
199
|
-
const services = await createAgentSessionServices({
|
|
200
|
-
cwd: opts.cwd,
|
|
201
|
-
agentDir: opts.agentDir,
|
|
202
|
-
authStorage,
|
|
203
|
-
settingsManager,
|
|
204
|
-
modelRegistry,
|
|
205
|
-
});
|
|
206
|
-
const result = await createOpenCandleSession({
|
|
207
|
-
cwd: opts.cwd,
|
|
208
|
-
agentDir: opts.agentDir,
|
|
209
|
-
settingsManager,
|
|
210
|
-
authStorage,
|
|
211
|
-
modelRegistry,
|
|
212
|
-
sessionManager: opts.sessionManager,
|
|
213
|
-
bindExtensions: false,
|
|
214
|
-
});
|
|
215
|
-
return {
|
|
216
|
-
...result,
|
|
217
|
-
services,
|
|
218
|
-
diagnostics: services.diagnostics,
|
|
219
|
-
};
|
|
220
|
-
}, { cwd, agentDir, sessionManager });
|
|
221
|
-
try {
|
|
222
|
-
const interactiveMode = new InteractiveMode(runtime, {
|
|
223
|
-
modelFallbackMessage: shouldSuppressFallbackMessage
|
|
224
|
-
? undefined
|
|
225
|
-
: runtime.modelFallbackMessage,
|
|
226
|
-
});
|
|
227
|
-
await interactiveMode.run();
|
|
228
|
-
}
|
|
229
|
-
finally {
|
|
230
|
-
await runtime.dispose();
|
|
231
|
-
}
|
|
13
|
+
else {
|
|
14
|
+
assertSupportedNodeVersion();
|
|
15
|
+
await ensureOpenCandleNativeDependencies();
|
|
16
|
+
await import("./cli-main.js");
|
|
232
17
|
}
|
|
233
|
-
await main();
|
|
234
18
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAErE,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAChF,MAAM,CAAC,aAAa,CAAC;QACrB,MAAM,CAAC,yBAAyB,CAAC;QACjC,MAAM,CAAC,iCAAiC,CAAC;KAC1C,CAAC,CAAC;IACH,OAAO,EAAE,CAAC;IACV,MAAM,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;AACjF,CAAC;KAAM,CAAC;IACN,0BAA0B,EAAE,CAAC;IAC7B,MAAM,kCAAkC,EAAE,CAAC;IAC3C,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function handleDoctorCommand(args: string[], cwd: string, agentDir: string): Promise<boolean>;
|