@valni/cli-darwin-x64 0.1.2 → 0.1.4
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 +1 -2
- package/package.json +1 -1
- package/runtime/LICENSE +1 -2
- package/runtime/examples/extensions/auto-commit-on-exit.ts +6 -6
- package/runtime/examples/extensions/bash-spawn-hook.ts +3 -3
- package/runtime/examples/extensions/bookmark.ts +5 -5
- package/runtime/examples/extensions/border-status-editor.ts +7 -7
- package/runtime/examples/extensions/built-in-tool-renderer.ts +6 -6
- package/runtime/examples/extensions/claude-rules.ts +4 -4
- package/runtime/examples/extensions/commands.ts +5 -5
- package/runtime/examples/extensions/confirm-destructive.ts +3 -3
- package/runtime/examples/extensions/custom-footer.ts +2 -2
- package/runtime/examples/extensions/custom-header.ts +5 -5
- package/runtime/examples/extensions/custom-provider-anthropic/index.ts +4 -4
- package/runtime/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
- package/runtime/examples/extensions/custom-provider-anthropic/package.json +3 -3
- package/runtime/examples/extensions/dirty-repo-guard.ts +7 -7
- package/runtime/examples/extensions/doom-overlay/doom/build.sh +4 -4
- package/runtime/examples/extensions/doom-overlay/doom/{doomgeneric_pi.c → doomgeneric_valni.c} +1 -1
- package/runtime/examples/extensions/doom-overlay/index.ts +3 -3
- package/runtime/examples/extensions/dynamic-resources/dynamic.json +0 -1
- package/runtime/examples/extensions/dynamic-resources/index.ts +2 -4
- package/runtime/examples/extensions/dynamic-tools.ts +4 -4
- package/runtime/examples/extensions/entry-renderer.ts +6 -6
- package/runtime/examples/extensions/event-bus.ts +8 -8
- package/runtime/examples/extensions/file-trigger.ts +3 -3
- package/runtime/examples/extensions/git-checkpoint.ts +7 -7
- package/runtime/examples/extensions/git-merge-and-resolve.ts +14 -14
- package/runtime/examples/extensions/github-issue-autocomplete.ts +6 -6
- package/runtime/examples/extensions/hello.ts +2 -2
- package/runtime/examples/extensions/hidden-thinking-label.ts +4 -4
- package/runtime/examples/extensions/inline-bash.ts +5 -5
- package/runtime/examples/extensions/input-transform-streaming.ts +5 -5
- package/runtime/examples/extensions/input-transform.ts +5 -5
- package/runtime/examples/extensions/interactive-shell.ts +3 -3
- package/runtime/examples/extensions/mac-system-theme.ts +5 -5
- package/runtime/examples/extensions/message-renderer.ts +4 -4
- package/runtime/examples/extensions/minimal-mode.ts +9 -9
- package/runtime/examples/extensions/modal-editor.ts +3 -3
- package/runtime/examples/extensions/model-status.ts +3 -3
- package/runtime/examples/extensions/notify.ts +5 -5
- package/runtime/examples/extensions/overlay-qa-tests.ts +20 -20
- package/runtime/examples/extensions/overlay-test.ts +3 -3
- package/runtime/examples/extensions/permission-gate.ts +2 -2
- package/runtime/examples/extensions/pirate.ts +4 -4
- package/runtime/examples/extensions/plan-mode/index.ts +21 -21
- package/runtime/examples/extensions/preset.ts +26 -26
- package/runtime/examples/extensions/project-trust.ts +7 -7
- package/runtime/examples/extensions/prompt-customizer.ts +3 -3
- package/runtime/examples/extensions/protected-paths.ts +2 -2
- package/runtime/examples/extensions/provider-payload.ts +3 -3
- package/runtime/examples/extensions/question.ts +2 -2
- package/runtime/examples/extensions/questionnaire.ts +2 -2
- package/runtime/examples/extensions/rainbow-editor.ts +3 -3
- package/runtime/examples/extensions/reload-runtime.ts +4 -4
- package/runtime/examples/extensions/rpc-demo.ts +10 -10
- package/runtime/examples/extensions/sandbox/index.ts +15 -15
- package/runtime/examples/extensions/sandbox/package-lock.json +4 -4
- package/runtime/examples/extensions/sandbox/package.json +3 -3
- package/runtime/examples/extensions/send-user-message.ts +13 -13
- package/runtime/examples/extensions/session-name.ts +4 -4
- package/runtime/examples/extensions/shutdown-command.ts +10 -10
- package/runtime/examples/extensions/snake.ts +3 -3
- package/runtime/examples/extensions/space-invaders.ts +3 -3
- package/runtime/examples/extensions/ssh.ts +12 -12
- package/runtime/examples/extensions/status-line.ts +4 -4
- package/runtime/examples/extensions/structured-output.ts +2 -2
- package/runtime/examples/extensions/subagent/index.ts +5 -5
- package/runtime/examples/extensions/system-prompt-header.ts +3 -3
- package/runtime/examples/extensions/tic-tac-toe.ts +15 -15
- package/runtime/examples/extensions/timed-confirm.ts +4 -4
- package/runtime/examples/extensions/titlebar-spinner.ts +11 -11
- package/runtime/examples/extensions/todo.ts +5 -5
- package/runtime/examples/extensions/tool-override.ts +5 -5
- package/runtime/examples/extensions/tools.ts +10 -10
- package/runtime/examples/extensions/trigger-compact.ts +3 -3
- package/runtime/examples/extensions/truncated-tool.ts +3 -3
- package/runtime/examples/extensions/widget-placement.ts +2 -2
- package/runtime/examples/extensions/with-deps/index.ts +2 -2
- package/runtime/examples/extensions/with-deps/package-lock.json +4 -4
- package/runtime/examples/extensions/with-deps/package.json +3 -3
- package/runtime/examples/extensions/working-indicator.ts +7 -7
- package/runtime/examples/extensions/working-message-test.ts +3 -3
- package/runtime/examples/sdk/01-minimal.ts +1 -1
- package/runtime/examples/sdk/03-custom-prompt.ts +1 -1
- package/runtime/examples/sdk/04-skills.ts +1 -1
- package/runtime/examples/sdk/05-tools.ts +1 -1
- package/runtime/examples/sdk/06-extensions.ts +11 -11
- package/runtime/examples/sdk/08-prompt-templates.ts +1 -1
- package/runtime/export-html/template.js +3 -3
- package/runtime/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/runtime/package.json +8 -14
- package/runtime/theme/dark.json +0 -1
- package/runtime/theme/light.json +0 -1
- package/runtime/theme/theme-schema.json +2 -2
- package/runtime/valni +2 -2
- package/runtime/README.md +0 -674
- package/runtime/docs/extensions.md +0 -2910
- package/runtime/docs/json.md +0 -82
- package/runtime/docs/models.md +0 -540
- package/runtime/docs/packages.md +0 -228
- package/runtime/docs/rpc.md +0 -1480
- package/runtime/docs/sdk.md +0 -1183
- package/runtime/docs/session-format.md +0 -422
- package/runtime/docs/settings.md +0 -315
- package/runtime/docs/shell-aliases.md +0 -13
- package/runtime/docs/terminal-setup.md +0 -142
- package/runtime/docs/termux.md +0 -127
- package/runtime/docs/tmux.md +0 -63
- package/runtime/docs/tui.md +0 -927
- package/runtime/docs/windows.md +0 -17
- package/runtime/examples/README.md +0 -25
- package/runtime/examples/extensions/README.md +0 -212
- package/runtime/examples/extensions/doom-overlay/README.md +0 -46
- package/runtime/examples/extensions/dynamic-resources/SKILL.md +0 -8
- package/runtime/examples/extensions/dynamic-resources/dynamic.md +0 -5
- package/runtime/examples/extensions/gondolin/index.ts +0 -531
- package/runtime/examples/extensions/gondolin/package-lock.json +0 -185
- package/runtime/examples/extensions/gondolin/package.json +0 -19
- package/runtime/examples/extensions/plan-mode/README.md +0 -66
- package/runtime/examples/extensions/subagent/README.md +0 -175
- package/runtime/examples/extensions/subagent/agents/planner.md +0 -37
- package/runtime/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/runtime/examples/extensions/subagent/agents/scout.md +0 -50
- package/runtime/examples/extensions/subagent/agents/worker.md +0 -24
- package/runtime/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/runtime/examples/extensions/subagent/prompts/implement.md +0 -10
- package/runtime/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
- package/runtime/examples/sdk/README.md +0 -140
- package/runtime/node_modules/@mariozechner/clipboard/.yarnrc.yml +0 -1
- package/runtime/node_modules/@mariozechner/clipboard/Cargo.toml +0 -45
- package/runtime/node_modules/@mariozechner/clipboard/README.md +0 -60
- package/runtime/node_modules/@mariozechner/clipboard/build.rs +0 -5
- package/runtime/node_modules/@mariozechner/clipboard/clipboard.darwin-x64.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard/exp.ts +0 -12
- package/runtime/node_modules/@mariozechner/clipboard/index.js +0 -606
- package/runtime/node_modules/@mariozechner/clipboard/package.json +0 -56
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/common.rs +0 -307
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/mod.rs +0 -93
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/ios.rs +0 -313
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/macos.rs +0 -471
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/mod.rs +0 -252
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/wayland.rs +0 -431
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/win.rs +0 -712
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/x11.rs +0 -916
- package/runtime/node_modules/@mariozechner/clipboard/src/lib.rs +0 -194
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/README.md +0 -3
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/clipboard.darwin-x64.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/package.json +0 -22
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Rainbow Editor - highlights "ultrathink" with animated shine effect
|
|
3
3
|
*
|
|
4
|
-
* Usage:
|
|
4
|
+
* Usage: valni --extension ./examples/extensions/rainbow-editor.ts
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { CustomEditor, type ExtensionAPI } from "@valni/cli";
|
|
@@ -81,8 +81,8 @@ class RainbowEditor extends CustomEditor {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
export default function (
|
|
85
|
-
|
|
84
|
+
export default function (valni: ExtensionAPI) {
|
|
85
|
+
valni.on("session_start", (_event, ctx) => {
|
|
86
86
|
ctx.ui.setEditorComponent((tui, theme, kb) => new RainbowEditor(tui, theme, kb));
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import type { ExtensionAPI } from "@valni/cli";
|
|
9
9
|
import { Type } from "typebox";
|
|
10
10
|
|
|
11
|
-
export default function (
|
|
11
|
+
export default function (valni: ExtensionAPI) {
|
|
12
12
|
// Command entrypoint for reload.
|
|
13
13
|
// Treat reload as terminal for this handler.
|
|
14
|
-
|
|
14
|
+
valni.registerCommand("reload-runtime", {
|
|
15
15
|
description: "Reload extensions, skills, prompts, themes, and context files",
|
|
16
16
|
handler: async (_args, ctx) => {
|
|
17
17
|
await ctx.reload();
|
|
@@ -21,13 +21,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
21
21
|
|
|
22
22
|
// LLM-callable tool. Tools get ExtensionContext, so they cannot call ctx.reload() directly.
|
|
23
23
|
// Instead, queue a follow-up user command that executes the command above.
|
|
24
|
-
|
|
24
|
+
valni.registerTool({
|
|
25
25
|
name: "reload_runtime",
|
|
26
26
|
label: "Reload Runtime",
|
|
27
27
|
description: "Reload extensions, skills, prompts, themes, and context files",
|
|
28
28
|
parameters: Type.Object({}),
|
|
29
29
|
async execute() {
|
|
30
|
-
|
|
30
|
+
valni.sendUserMessage("/reload-runtime", { deliverAs: "followUp" });
|
|
31
31
|
return {
|
|
32
32
|
content: [{ type: "text", text: "Queued /reload-runtime as a follow-up command." }],
|
|
33
33
|
details: {},
|
|
@@ -19,31 +19,31 @@
|
|
|
19
19
|
|
|
20
20
|
import type { ExtensionAPI } from "@valni/cli";
|
|
21
21
|
|
|
22
|
-
export default function (
|
|
22
|
+
export default function (valni: ExtensionAPI) {
|
|
23
23
|
let turnCount = 0;
|
|
24
24
|
|
|
25
25
|
// -- setTitle, setWidget, setStatus on session lifecycle --
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
ctx.ui.setTitle(event.reason === "new" ? "
|
|
27
|
+
valni.on("session_start", async (event, ctx) => {
|
|
28
|
+
ctx.ui.setTitle(event.reason === "new" ? "valni RPC Demo (new session)" : "valni RPC Demo");
|
|
29
29
|
ctx.ui.setWidget("rpc-demo", ["--- RPC Extension UI Demo ---", "Loaded and ready."]);
|
|
30
30
|
ctx.ui.setStatus("rpc-demo", `Turns: ${turnCount}`);
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
// -- setStatus on turn lifecycle --
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
valni.on("turn_start", async (_event, ctx) => {
|
|
36
36
|
turnCount++;
|
|
37
37
|
ctx.ui.setStatus("rpc-demo", `Turn ${turnCount} running...`);
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
valni.on("turn_end", async (_event, ctx) => {
|
|
41
41
|
ctx.ui.setStatus("rpc-demo", `Turn ${turnCount} done`);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
// -- select on dangerous tool calls --
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
valni.on("tool_call", async (event, ctx) => {
|
|
47
47
|
if (event.toolName !== "bash") return undefined;
|
|
48
48
|
|
|
49
49
|
const command = event.input.command as string;
|
|
@@ -67,7 +67,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
67
67
|
|
|
68
68
|
// -- confirm on session clear --
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
valni.on("session_before_switch", async (event, ctx) => {
|
|
71
71
|
if (event.reason !== "new") return;
|
|
72
72
|
if (!ctx.hasUI) return;
|
|
73
73
|
|
|
@@ -80,7 +80,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
80
80
|
|
|
81
81
|
// -- input via command --
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
valni.registerCommand("rpc-input", {
|
|
84
84
|
description: "Prompt for text input (demonstrates ctx.ui.input in RPC)",
|
|
85
85
|
handler: async (_args, ctx) => {
|
|
86
86
|
const value = await ctx.ui.input("Enter a value", "type something...");
|
|
@@ -94,7 +94,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
94
94
|
|
|
95
95
|
// -- editor via command --
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
valni.registerCommand("rpc-editor", {
|
|
98
98
|
description: "Open multi-line editor (demonstrates ctx.ui.editor in RPC)",
|
|
99
99
|
handler: async (_args, ctx) => {
|
|
100
100
|
const text = await ctx.ui.editor("Edit some text", "Line 1\nLine 2\nLine 3");
|
|
@@ -108,7 +108,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
108
108
|
|
|
109
109
|
// -- setEditorText via command --
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
valni.registerCommand("rpc-prefill", {
|
|
112
112
|
description: "Prefill the input editor (demonstrates ctx.ui.setEditorText in RPC)",
|
|
113
113
|
handler: async (_args, ctx) => {
|
|
114
114
|
ctx.ui.setEditorText("This text was set by the rpc-demo extension.");
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* via `tool_call` input mutation without replacing the tool.
|
|
11
11
|
*
|
|
12
12
|
* Config files (merged, project takes precedence):
|
|
13
|
-
* - ~/.
|
|
14
|
-
* - <cwd>/.
|
|
13
|
+
* - ~/.valni/agent/extensions/sandbox.json (global)
|
|
14
|
+
* - <cwd>/.valni/sandbox.json (project-local)
|
|
15
15
|
*
|
|
16
|
-
* Example .
|
|
16
|
+
* Example .valni/sandbox.json:
|
|
17
17
|
* ```json
|
|
18
18
|
* {
|
|
19
19
|
* "enabled": true,
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
32
|
* Usage:
|
|
33
|
-
* - `
|
|
34
|
-
* - `
|
|
33
|
+
* - `valni -e ./sandbox` - sandbox enabled with default/config settings
|
|
34
|
+
* - `valni -e ./sandbox --no-sandbox` - disable sandboxing
|
|
35
35
|
* - `/sandbox` - show current sandbox configuration
|
|
36
36
|
*
|
|
37
37
|
* Setup:
|
|
38
|
-
* 1. Copy sandbox/ directory to ~/.
|
|
39
|
-
* 2. Run `npm install` in ~/.
|
|
38
|
+
* 1. Copy sandbox/ directory to ~/.valni/agent/extensions/
|
|
39
|
+
* 2. Run `npm install` in ~/.valni/agent/extensions/sandbox/
|
|
40
40
|
*
|
|
41
41
|
* Linux also requires: bubblewrap, socat, ripgrep
|
|
42
42
|
*/
|
|
@@ -198,8 +198,8 @@ function createSandboxedBashOps(): BashOperations {
|
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
export default function (
|
|
202
|
-
|
|
201
|
+
export default function (valni: ExtensionAPI) {
|
|
202
|
+
valni.registerFlag("no-sandbox", {
|
|
203
203
|
description: "Disable OS-level sandboxing for bash commands",
|
|
204
204
|
type: "boolean",
|
|
205
205
|
default: false,
|
|
@@ -211,7 +211,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
211
211
|
let sandboxEnabled = false;
|
|
212
212
|
let sandboxInitialized = false;
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
valni.registerTool({
|
|
215
215
|
...localBash,
|
|
216
216
|
label: "bash (sandboxed)",
|
|
217
217
|
async execute(id, params, signal, onUpdate, _ctx) {
|
|
@@ -226,13 +226,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
226
226
|
},
|
|
227
227
|
});
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
valni.on("user_bash", () => {
|
|
230
230
|
if (!sandboxEnabled || !sandboxInitialized) return;
|
|
231
231
|
return { operations: createSandboxedBashOps() };
|
|
232
232
|
});
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
const noSandbox =
|
|
234
|
+
valni.on("session_start", async (_event, ctx) => {
|
|
235
|
+
const noSandbox = valni.getFlag("no-sandbox") as boolean;
|
|
236
236
|
|
|
237
237
|
if (noSandbox) {
|
|
238
238
|
sandboxEnabled = false;
|
|
@@ -284,7 +284,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
284
284
|
}
|
|
285
285
|
});
|
|
286
286
|
|
|
287
|
-
|
|
287
|
+
valni.on("session_shutdown", async () => {
|
|
288
288
|
if (sandboxInitialized) {
|
|
289
289
|
try {
|
|
290
290
|
await SandboxManager.reset();
|
|
@@ -294,7 +294,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
294
294
|
}
|
|
295
295
|
});
|
|
296
296
|
|
|
297
|
-
|
|
297
|
+
valni.registerCommand("sandbox", {
|
|
298
298
|
description: "Show sandbox configuration",
|
|
299
299
|
handler: async (_args, ctx) => {
|
|
300
300
|
if (!sandboxEnabled) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
3
|
-
"version": "1.10.
|
|
2
|
+
"name": "valni-extension-sandbox",
|
|
3
|
+
"version": "1.10.11",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
|
-
"name": "
|
|
9
|
-
"version": "1.10.
|
|
8
|
+
"name": "valni-extension-sandbox",
|
|
9
|
+
"version": "1.10.11",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "valni-extension-sandbox",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "1.10.
|
|
4
|
+
"version": "1.10.11",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"clean": "echo 'nothing to clean'",
|
|
8
8
|
"build": "echo 'nothing to build'",
|
|
9
9
|
"check": "echo 'nothing to check'"
|
|
10
10
|
},
|
|
11
|
-
"
|
|
11
|
+
"valni": {
|
|
12
12
|
"extensions": [
|
|
13
13
|
"./index.ts"
|
|
14
14
|
]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Send User Message Example
|
|
3
3
|
*
|
|
4
|
-
* Demonstrates
|
|
5
|
-
* Unlike
|
|
4
|
+
* Demonstrates valni.sendUserMessage() for sending user messages from extensions.
|
|
5
|
+
* Unlike valni.sendMessage() which sends custom messages, sendUserMessage() sends
|
|
6
6
|
* actual user messages that appear in the conversation as if typed by the user.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
import type { ExtensionAPI } from "@valni/cli";
|
|
15
15
|
|
|
16
|
-
export default function (
|
|
16
|
+
export default function (valni: ExtensionAPI) {
|
|
17
17
|
// Simple command that sends a user message
|
|
18
|
-
|
|
18
|
+
valni.registerCommand("ask", {
|
|
19
19
|
description: "Send a user message to the agent",
|
|
20
20
|
handler: async (args, ctx) => {
|
|
21
21
|
if (!args.trim()) {
|
|
@@ -30,12 +30,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
valni.sendUserMessage(args);
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
// Command that steers the agent mid-conversation
|
|
38
|
-
|
|
38
|
+
valni.registerCommand("steer", {
|
|
39
39
|
description: "Send a steering message (interrupts current processing)",
|
|
40
40
|
handler: async (args, ctx) => {
|
|
41
41
|
if (!args.trim()) {
|
|
@@ -45,16 +45,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
45
45
|
|
|
46
46
|
if (ctx.isIdle()) {
|
|
47
47
|
// Not streaming, just send normally
|
|
48
|
-
|
|
48
|
+
valni.sendUserMessage(args);
|
|
49
49
|
} else {
|
|
50
50
|
// Streaming - use steer to interrupt
|
|
51
|
-
|
|
51
|
+
valni.sendUserMessage(args, { deliverAs: "steer" });
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
// Command that queues a follow-up message
|
|
57
|
-
|
|
57
|
+
valni.registerCommand("followup", {
|
|
58
58
|
description: "Queue a follow-up message (waits for current processing)",
|
|
59
59
|
handler: async (args, ctx) => {
|
|
60
60
|
if (!args.trim()) {
|
|
@@ -64,17 +64,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
64
64
|
|
|
65
65
|
if (ctx.isIdle()) {
|
|
66
66
|
// Not streaming, just send normally
|
|
67
|
-
|
|
67
|
+
valni.sendUserMessage(args);
|
|
68
68
|
} else {
|
|
69
69
|
// Streaming - queue as follow-up
|
|
70
|
-
|
|
70
|
+
valni.sendUserMessage(args, { deliverAs: "followUp" });
|
|
71
71
|
ctx.ui.notify("Follow-up queued", "info");
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
// Example with content array (text + images would go here)
|
|
77
|
-
|
|
77
|
+
valni.registerCommand("askwith", {
|
|
78
78
|
description: "Send a user message with structured content",
|
|
79
79
|
handler: async (args, ctx) => {
|
|
80
80
|
if (!args.trim()) {
|
|
@@ -88,7 +88,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// sendUserMessage accepts string or (TextContent | ImageContent)[]
|
|
91
|
-
|
|
91
|
+
valni.sendUserMessage([
|
|
92
92
|
{ type: "text", text: `User request: ${args}` },
|
|
93
93
|
{ type: "text", text: "Please respond concisely." },
|
|
94
94
|
]);
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
|
|
10
10
|
import type { ExtensionAPI } from "@valni/cli";
|
|
11
11
|
|
|
12
|
-
export default function (
|
|
13
|
-
|
|
12
|
+
export default function (valni: ExtensionAPI) {
|
|
13
|
+
valni.registerCommand("session-name", {
|
|
14
14
|
description: "Set or show session name (usage: /session-name [new name])",
|
|
15
15
|
handler: async (args, ctx) => {
|
|
16
16
|
const name = args.trim();
|
|
17
17
|
|
|
18
18
|
if (name) {
|
|
19
|
-
|
|
19
|
+
valni.setSessionName(name);
|
|
20
20
|
ctx.ui.notify(`Session named: ${name}`, "info");
|
|
21
21
|
} else {
|
|
22
|
-
const current =
|
|
22
|
+
const current = valni.getSessionName();
|
|
23
23
|
ctx.ui.notify(current ? `Session: ${current}` : "No session name set", "info");
|
|
24
24
|
}
|
|
25
25
|
},
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
* Shutdown Command Extension
|
|
3
3
|
*
|
|
4
4
|
* Adds a /quit command that allows extensions to trigger clean shutdown.
|
|
5
|
-
* Demonstrates how extensions can use ctx.shutdown() to exit
|
|
5
|
+
* Demonstrates how extensions can use ctx.shutdown() to exit valni cleanly.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { ExtensionAPI } from "@valni/cli";
|
|
9
9
|
import { Type } from "typebox";
|
|
10
10
|
|
|
11
|
-
export default function (
|
|
12
|
-
// Register a /quit command that cleanly exits
|
|
13
|
-
|
|
14
|
-
description: "Exit
|
|
11
|
+
export default function (valni: ExtensionAPI) {
|
|
12
|
+
// Register a /quit command that cleanly exits valni
|
|
13
|
+
valni.registerCommand("quit", {
|
|
14
|
+
description: "Exit valni cleanly",
|
|
15
15
|
handler: async (_args, ctx) => {
|
|
16
16
|
ctx.shutdown();
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
// You can also create a tool that shuts down after completing work
|
|
21
|
-
|
|
21
|
+
valni.registerTool({
|
|
22
22
|
name: "finish_and_exit",
|
|
23
23
|
label: "Finish and Exit",
|
|
24
|
-
description: "Complete a task and exit
|
|
24
|
+
description: "Complete a task and exit valni",
|
|
25
25
|
parameters: Type.Object({}),
|
|
26
26
|
async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
|
|
27
27
|
// Do any final work here...
|
|
@@ -37,10 +37,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
// You could also create a more complex tool with parameters
|
|
40
|
-
|
|
40
|
+
valni.registerTool({
|
|
41
41
|
name: "deploy_and_exit",
|
|
42
42
|
label: "Deploy and Exit",
|
|
43
|
-
description: "Deploy the application and exit
|
|
43
|
+
description: "Deploy the application and exit valni",
|
|
44
44
|
parameters: Type.Object({
|
|
45
45
|
environment: Type.String({ description: "Target environment (e.g., production, staging)" }),
|
|
46
46
|
}),
|
|
@@ -48,7 +48,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
48
48
|
onUpdate?.({ content: [{ type: "text", text: `Deploying to ${params.environment}...` }], details: {} });
|
|
49
49
|
|
|
50
50
|
// Example deployment logic
|
|
51
|
-
// const result = await
|
|
51
|
+
// const result = await valni.exec("npm", ["run", "deploy", params.environment], { signal });
|
|
52
52
|
|
|
53
53
|
// On success, request graceful shutdown
|
|
54
54
|
onUpdate?.({ content: [{ type: "text", text: "Deployment complete, exiting..." }], details: {} });
|
|
@@ -306,8 +306,8 @@ class SnakeComponent {
|
|
|
306
306
|
|
|
307
307
|
const SNAKE_SAVE_TYPE = "snake-save";
|
|
308
308
|
|
|
309
|
-
export default function (
|
|
310
|
-
|
|
309
|
+
export default function (valni: ExtensionAPI) {
|
|
310
|
+
valni.registerCommand("snake", {
|
|
311
311
|
description: "Play Snake!",
|
|
312
312
|
|
|
313
313
|
handler: async (_args, ctx) => {
|
|
@@ -333,7 +333,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
333
333
|
() => done(undefined),
|
|
334
334
|
(state) => {
|
|
335
335
|
// Save or clear state
|
|
336
|
-
|
|
336
|
+
valni.appendEntry(SNAKE_SAVE_TYPE, state);
|
|
337
337
|
},
|
|
338
338
|
savedState,
|
|
339
339
|
);
|
|
@@ -524,8 +524,8 @@ class SpaceInvadersComponent {
|
|
|
524
524
|
|
|
525
525
|
const INVADERS_SAVE_TYPE = "space-invaders-save";
|
|
526
526
|
|
|
527
|
-
export default function (
|
|
528
|
-
|
|
527
|
+
export default function (valni: ExtensionAPI) {
|
|
528
|
+
valni.registerCommand("invaders", {
|
|
529
529
|
description: "Play Space Invaders!",
|
|
530
530
|
|
|
531
531
|
handler: async (_args, ctx) => {
|
|
@@ -550,7 +550,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
550
550
|
tui,
|
|
551
551
|
() => done(undefined),
|
|
552
552
|
(state) => {
|
|
553
|
-
|
|
553
|
+
valni.appendEntry(INVADERS_SAVE_TYPE, state);
|
|
554
554
|
},
|
|
555
555
|
savedState,
|
|
556
556
|
);
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* When --ssh is provided, read/write/edit/bash run on the remote.
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* valni -e ./ssh.ts --ssh user@host
|
|
9
|
+
* valni -e ./ssh.ts --ssh user@host:/remote/path
|
|
10
10
|
*
|
|
11
11
|
* Requirements:
|
|
12
12
|
* - SSH key-based auth (no password prompts)
|
|
@@ -111,8 +111,8 @@ function createRemoteBashOps(remote: string, remoteCwd: string, localCwd: string
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
export default function (
|
|
115
|
-
|
|
114
|
+
export default function (valni: ExtensionAPI) {
|
|
115
|
+
valni.registerFlag("ssh", { description: "SSH remote: user@host or user@host:/path", type: "string" });
|
|
116
116
|
|
|
117
117
|
const localCwd = process.cwd();
|
|
118
118
|
const localRead = createReadTool(localCwd);
|
|
@@ -125,7 +125,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
125
125
|
|
|
126
126
|
const getSsh = () => resolvedSsh;
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
valni.registerTool({
|
|
129
129
|
...localRead,
|
|
130
130
|
async execute(id, params, signal, onUpdate, _ctx) {
|
|
131
131
|
const ssh = getSsh();
|
|
@@ -139,7 +139,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
139
139
|
},
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
valni.registerTool({
|
|
143
143
|
...localWrite,
|
|
144
144
|
async execute(id, params, signal, onUpdate, _ctx) {
|
|
145
145
|
const ssh = getSsh();
|
|
@@ -153,7 +153,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
153
153
|
},
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
valni.registerTool({
|
|
157
157
|
...localEdit,
|
|
158
158
|
async execute(id, params, signal, onUpdate, _ctx) {
|
|
159
159
|
const ssh = getSsh();
|
|
@@ -167,7 +167,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
167
167
|
},
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
valni.registerTool({
|
|
171
171
|
...localBash,
|
|
172
172
|
async execute(id, params, signal, onUpdate, _ctx) {
|
|
173
173
|
const ssh = getSsh();
|
|
@@ -181,9 +181,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
181
181
|
},
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
valni.on("session_start", async (_event, ctx) => {
|
|
185
185
|
// Resolve SSH config now that CLI flags are available
|
|
186
|
-
const arg =
|
|
186
|
+
const arg = valni.getFlag("ssh") as string | undefined;
|
|
187
187
|
if (arg) {
|
|
188
188
|
if (arg.includes(":")) {
|
|
189
189
|
const [remote, path] = arg.split(":");
|
|
@@ -200,14 +200,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
200
200
|
});
|
|
201
201
|
|
|
202
202
|
// Handle user ! commands via SSH
|
|
203
|
-
|
|
203
|
+
valni.on("user_bash", (_event) => {
|
|
204
204
|
const ssh = getSsh();
|
|
205
205
|
if (!ssh) return; // No SSH, use local execution
|
|
206
206
|
return { operations: createRemoteBashOps(ssh.remote, ssh.remoteCwd, localCwd) };
|
|
207
207
|
});
|
|
208
208
|
|
|
209
209
|
// Replace local cwd with remote cwd in system prompt
|
|
210
|
-
|
|
210
|
+
valni.on("before_agent_start", async (event) => {
|
|
211
211
|
const ssh = getSsh();
|
|
212
212
|
if (ssh) {
|
|
213
213
|
const modified = event.systemPrompt.replace(
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import type { ExtensionAPI } from "@valni/cli";
|
|
9
9
|
|
|
10
|
-
export default function (
|
|
10
|
+
export default function (valni: ExtensionAPI) {
|
|
11
11
|
let turnCount = 0;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
valni.on("session_start", async (_event, ctx) => {
|
|
14
14
|
const theme = ctx.ui.theme;
|
|
15
15
|
ctx.ui.setStatus("status-demo", theme.fg("dim", "Ready"));
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
valni.on("turn_start", async (_event, ctx) => {
|
|
19
19
|
turnCount++;
|
|
20
20
|
const theme = ctx.ui.theme;
|
|
21
21
|
const spinner = theme.fg("accent", "●");
|
|
@@ -23,7 +23,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
23
23
|
ctx.ui.setStatus("status-demo", spinner + text);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
valni.on("turn_end", async (_event, ctx) => {
|
|
27
27
|
const theme = ctx.ui.theme;
|
|
28
28
|
const check = theme.fg("success", "✓");
|
|
29
29
|
const text = theme.fg("dim", ` Turn ${turnCount} complete`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Subagent Tool - Delegate tasks to specialized agents
|
|
3
3
|
*
|
|
4
|
-
* Spawns a separate `
|
|
4
|
+
* Spawns a separate `valni` process for each subagent invocation,
|
|
5
5
|
* giving it an isolated context window.
|
|
6
6
|
*
|
|
7
7
|
* Supports three modes:
|
|
@@ -231,7 +231,7 @@ async function mapWithConcurrencyLimit<TIn, TOut>(
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
async function writePromptToTempFile(agentName: string, prompt: string): Promise<{ dir: string; filePath: string }> {
|
|
234
|
-
const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "
|
|
234
|
+
const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "valni-subagent-"));
|
|
235
235
|
const safeName = agentName.replace(/[^\w.-]+/g, "_");
|
|
236
236
|
const filePath = path.join(tmpDir, `prompt-${safeName}.md`);
|
|
237
237
|
await withFileMutationQueue(filePath, async () => {
|
|
@@ -253,7 +253,7 @@ function getPiInvocation(args: string[]): { command: string; args: string[] } {
|
|
|
253
253
|
return { command: process.execPath, args };
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
return { command: "
|
|
256
|
+
return { command: "valni", args };
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
type OnUpdateCallback = (partial: AgentToolResult<SubagentDetails>) => void;
|
|
@@ -451,8 +451,8 @@ const SubagentParams = Type.Object({
|
|
|
451
451
|
cwd: Type.Optional(Type.String({ description: "Working directory for the agent process (single mode)" })),
|
|
452
452
|
});
|
|
453
453
|
|
|
454
|
-
export default function (
|
|
455
|
-
|
|
454
|
+
export default function (valni: ExtensionAPI) {
|
|
455
|
+
valni.registerTool({
|
|
456
456
|
name: "subagent",
|
|
457
457
|
label: "Subagent",
|
|
458
458
|
description: [
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { ExtensionAPI } from "@valni/cli";
|
|
7
7
|
|
|
8
|
-
export default function (
|
|
9
|
-
|
|
8
|
+
export default function (valni: ExtensionAPI) {
|
|
9
|
+
valni.on("agent_start", (_event, ctx) => {
|
|
10
10
|
const prompt = ctx.getSystemPrompt();
|
|
11
11
|
ctx.ui.setStatus("system-prompt", `System: ${prompt.length} chars`);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
valni.on("session_shutdown", (_event, ctx) => {
|
|
15
15
|
ctx.ui.setStatus("system-prompt", undefined);
|
|
16
16
|
});
|
|
17
17
|
}
|