@halfagiraf/clawx 0.1.7 → 0.1.9
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 +52 -7
- package/dist/cli/tui.d.ts.map +1 -1
- package/dist/cli/tui.js +20 -1
- package/dist/cli/tui.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -480,16 +480,16 @@ clawx chat -d ./my-project
|
|
|
480
480
|
|
|
481
481
|
## Programmatic usage
|
|
482
482
|
|
|
483
|
-
|
|
484
|
-
import { loadConfig, runAgent, createStreamRenderer } from "@halfagiraf/clawx";
|
|
483
|
+
Use clawx as a library in your own scripts and tools.
|
|
485
484
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
});
|
|
485
|
+
**Single task:**
|
|
486
|
+
|
|
487
|
+
```js
|
|
488
|
+
import { loadConfig, runAgent, createStreamRenderer } from "@halfagiraf/clawx";
|
|
491
489
|
|
|
490
|
+
const config = loadConfig(); // reads from ~/.clawx/config or .env
|
|
492
491
|
const renderer = createStreamRenderer();
|
|
492
|
+
|
|
493
493
|
const result = await runAgent(config, {
|
|
494
494
|
prompt: "Create a hello world Express server",
|
|
495
495
|
onEvent: (event) => renderer.onEvent(event),
|
|
@@ -497,6 +497,51 @@ const result = await runAgent(config, {
|
|
|
497
497
|
renderer.finish();
|
|
498
498
|
```
|
|
499
499
|
|
|
500
|
+
**Multi-turn with shared context:**
|
|
501
|
+
|
|
502
|
+
```js
|
|
503
|
+
let messages = [];
|
|
504
|
+
|
|
505
|
+
for (const prompt of ["Create calc.js with add/subtract", "Add tests"]) {
|
|
506
|
+
const result = await runAgent(config, { prompt, messages,
|
|
507
|
+
onEvent: (event) => renderer.onEvent(event),
|
|
508
|
+
});
|
|
509
|
+
messages = result.messages; // carry context forward
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
**Headless for CI/automation:**
|
|
514
|
+
|
|
515
|
+
```js
|
|
516
|
+
const events = [];
|
|
517
|
+
const result = await runAgent(config, {
|
|
518
|
+
prompt: "Generate a Dockerfile for this project",
|
|
519
|
+
onEvent: (event) => events.push(event), // collect instead of printing
|
|
520
|
+
});
|
|
521
|
+
const toolCalls = events.filter(e => e.type === "tool_execution_start");
|
|
522
|
+
console.log(`Done: ${toolCalls.length} tool calls, aborted: ${result.aborted}`);
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
See [examples/](examples/) for runnable scripts.
|
|
526
|
+
|
|
527
|
+
## Troubleshooting
|
|
528
|
+
|
|
529
|
+
### TUI launches a file manager instead of the coding agent (Linux)
|
|
530
|
+
|
|
531
|
+
If running `clawx` opens "FD(File & Directory tool)" — a Japanese file manager — instead of the TUI, you have `fdclone` installed which conflicts with the `fd` (sharkdp/fd-find) tool used for autocomplete.
|
|
532
|
+
|
|
533
|
+
**Fix:**
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
sudo apt remove fdclone
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Next time you run `clawx`, the correct `fd` binary will be downloaded automatically.
|
|
540
|
+
|
|
541
|
+
### `/models` shows no models
|
|
542
|
+
|
|
543
|
+
If you set up clawx via `clawx init`, your configured model should appear in `/models`. If it doesn't, check that your `~/.clawx/config` file has the correct `CLAWDEX_PROVIDER`, `CLAWDEX_MODEL`, and `CLAWDEX_API_KEY` values.
|
|
544
|
+
|
|
500
545
|
## License
|
|
501
546
|
|
|
502
547
|
MIT — extracted and adapted from [OpenClaw](https://github.com/openclaw/openclaw) (MIT).
|
package/dist/cli/tui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../src/cli/tui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../src/cli/tui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAUH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAwCrD;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE;IACP,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACd,GACL,OAAO,CAAC,IAAI,CAAC,CAwDf"}
|
package/dist/cli/tui.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* OpenClaw wraps this same InteractiveMode with 3000+ lines of
|
|
20
20
|
* additional platform integration. We skip all of that.
|
|
21
21
|
*/
|
|
22
|
-
import { createAgentSession, InteractiveMode, AuthStorage, } from "@mariozechner/pi-coding-agent";
|
|
22
|
+
import { createAgentSession, InteractiveMode, AuthStorage, ModelRegistry, } from "@mariozechner/pi-coding-agent";
|
|
23
23
|
import { resolveModel } from "../core/provider.js";
|
|
24
24
|
import { createSshRunTool } from "../tools/sshRun.js";
|
|
25
25
|
import { createGitStatusTool } from "../tools/gitStatus.js";
|
|
@@ -69,6 +69,24 @@ export async function startTui(config, options = {}) {
|
|
|
69
69
|
// doesn't reject local endpoints that have no env-var mapping
|
|
70
70
|
const authStorage = AuthStorage.create();
|
|
71
71
|
authStorage.setRuntimeApiKey(config.provider, config.apiKey);
|
|
72
|
+
// Create ModelRegistry and register our configured provider so /models works
|
|
73
|
+
const modelRegistry = new ModelRegistry(authStorage);
|
|
74
|
+
modelRegistry.registerProvider(config.provider, {
|
|
75
|
+
baseUrl: config.baseUrl,
|
|
76
|
+
apiKey: config.apiKey,
|
|
77
|
+
api: model.api,
|
|
78
|
+
models: [
|
|
79
|
+
{
|
|
80
|
+
id: model.id,
|
|
81
|
+
name: model.name ?? model.id,
|
|
82
|
+
reasoning: model.reasoning ?? false,
|
|
83
|
+
input: model.input ?? ["text"],
|
|
84
|
+
cost: model.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
85
|
+
contextWindow: model.contextWindow ?? 32768,
|
|
86
|
+
maxTokens: model.maxTokens ?? config.maxTokens,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
});
|
|
72
90
|
// Create session via the SDK
|
|
73
91
|
const { session, extensionsResult, modelFallbackMessage } = await createAgentSession({
|
|
74
92
|
cwd: config.workDir,
|
|
@@ -76,6 +94,7 @@ export async function startTui(config, options = {}) {
|
|
|
76
94
|
thinkingLevel: config.thinkingLevel === "off" ? undefined : config.thinkingLevel,
|
|
77
95
|
customTools,
|
|
78
96
|
authStorage,
|
|
97
|
+
modelRegistry,
|
|
79
98
|
});
|
|
80
99
|
// Override system prompt with our Clawx-specific one
|
|
81
100
|
// AgentSession exposes the underlying Agent which has setSystemPrompt()
|
package/dist/cli/tui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../../src/cli/tui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,WAAW,
|
|
1
|
+
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../../src/cli/tui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,aAAa,GAEd,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MA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