hermesdesk-agent 0.1.0-alpha.4 → 0.1.0-alpha.6
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 +26 -3
- package/bin/hermesdesk.js +3 -4
- package/npm-shrinkwrap.json +4 -3
- package/package.json +3 -2
- package/src/agent.js +71 -2
- package/src/commands.js +293 -0
- package/src/config.js +1 -1
- package/src/policy.js +5 -31
- package/src/ui/approval.js +215 -0
- package/src/ui/chrome.js +175 -0
- package/src/ui/extension.js +75 -0
- package/src/ui/format.js +137 -0
- package/src/ui/interactive.js +14 -0
- package/src/ui/layout.js +63 -0
- package/src/ui/menu.js +56 -0
- package/src/ui/pi.js +5 -0
- package/src/ui/themes/hermesdesk-dark.json +81 -0
- package/src/ui/themes/hermesdesk-light.json +81 -0
- package/src/ui/tools.js +159 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/NKocur/hermesdesk-agent/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
|
-
**Windows alpha: 0.1.0-alpha.
|
|
5
|
+
**Windows alpha: 0.1.0-alpha.6.** Community client built on Pi; not affiliated with or endorsed by Earendil Works or Nous Research.
|
|
6
6
|
|
|
7
7
|
A running HermesDesk inference gateway is required. This client does not include a hosted model service, server access, or API keys.
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ hermesdesk.cmd connect
|
|
|
18
18
|
hermesdesk.cmd doctor
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Alternatively, download and extract a Windows alpha bundle from [Releases](https://github.com/NKocur/hermesdesk-agent/releases) and run `Install Agent.cmd`. A tarball can also be installed directly with `npm.cmd install -g --ignore-scripts ./hermesdesk-agent-0.1.0-alpha.
|
|
21
|
+
Alternatively, download and extract a Windows alpha bundle from [Releases](https://github.com/NKocur/hermesdesk-agent/releases) and run `Install Agent.cmd`. A tarball can also be installed directly with `npm.cmd install -g --ignore-scripts ./hermesdesk-agent-0.1.0-alpha.6.tgz`.
|
|
22
22
|
|
|
23
23
|
There is no default server address. `connect` asks for your HTTPS model endpoint ending in `/v1`. When the server supports browser sign-in, it opens your browser: sign in to HermesDesk and approve the computer. The CLI receives a short-lived, single-use authorization code on a loopback listener and redeems it with PKCE over HTTPS, then discovers the model and saves the credentials encrypted. You do not copy passwords, API keys, or connection codes. The browser and CLI must be on the same computer. Use `--no-browser` to open the printed browser link yourself. On legacy servers without browser sign-in, the API-key setup remains available; `--manual` explicitly selects it. No server credentials are included in this package.
|
|
24
24
|
|
|
@@ -39,7 +39,11 @@ hermesdesk.cmd chat --session SESSION_ID
|
|
|
39
39
|
hermesdesk.cmd chat --read-only
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
The interactive terminal uses Pi's UI, streaming, diffs, tool displays, session history and compaction
|
|
42
|
+
The interactive terminal uses Pi's UI, streaming, diffs, tool displays, session history and compaction, with a HermesDesk presentation layer (`src/ui/`). A compact header shows the safety mode and key commands; a two-line footer shows the workspace and git branch, model, thinking effort, output limit, approval mode, token totals and context fill. Tool calls appear as one line with a status mark (`●` running, `✓` done, `✗` failed or declined) and their output sits behind a quiet gutter; `ctrl+o` expands long output. Edits, writes and commands open an approval panel with a diff, file preview or highlighted command: `y` allows once, `n` or Escape denies.
|
|
43
|
+
|
|
44
|
+
Colors follow the terminal background automatically, using the HermesDesk light or dark palette. Body text keeps the terminal's own foreground color, and fonts and sizes always come from the terminal. Set `HERMESDESK_THEME` to `light` or `dark` to force a palette (for terminals that do not report their background), or `terminal` to use Pi's palette derived from your terminal colors.
|
|
45
|
+
|
|
46
|
+
Escape interrupts work. `/quit` exits; `/new` starts a new conversation and `/resume` opens Pi's session selector. The first interactive startup may download Pi's `fd` helper to this client's own Pi cache. Windows Terminal is recommended. Pi's inherited help and exit hints may still mention `pi`; resume this client with `hermesdesk chat --continue` or `--session ID`.
|
|
43
47
|
|
|
44
48
|
File tools are restricted to the chosen project and reject outside links and protected paths such as `.env`, `.git`, credential files and agent configurations. Each edit and shell command asks for approval. Shell commands execute as your user and are **not OS-sandboxed**; after approval they can access anything your account can access. Direct `!` shell shortcuts are disabled so commands use the managed approval path. Project JavaScript extensions, MCP servers and packages are not automatically loaded.
|
|
45
49
|
|
|
@@ -55,6 +59,25 @@ hermesdesk.cmd run "Summarize README.md" --json
|
|
|
55
59
|
|
|
56
60
|
One-shot operation denies writes unless `--approve-writes` is explicitly provided. It never approves shell commands without interactive confirmation. JSON mode streams `text`, `tool` and `done` records to stdout; diagnostics go to stderr.
|
|
57
61
|
|
|
62
|
+
## In-chat controls
|
|
63
|
+
|
|
64
|
+
Use these inside interactive chat. Commands run locally, consume no model tokens, and change the next request without restarting the conversation:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
/limits
|
|
68
|
+
/profile extended
|
|
69
|
+
/tokens 65536
|
|
70
|
+
/think xhigh
|
|
71
|
+
/thinking-budget 8192
|
|
72
|
+
/thinking-budget auto
|
|
73
|
+
/limits show
|
|
74
|
+
/limits save
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`/limits` opens a settings menu for the same controls, showing each current value; `/profile` and `/think` without a value open menus that mark the active choice. Profiles are `fast` (32K, thinking off), `balanced` (64K, xhigh), and `extended` (131K, xhigh). Output counts include thinking and answer. The model can stop before the allowance is used, and Strata can reduce the thinking cap to preserve answer room. Individual controls keep your other sampler settings; profiles apply the recommended sampler values.
|
|
78
|
+
|
|
79
|
+
Changes last for the current CLI session. `/limits save` keeps generation defaults for future launches; `/limits reset` restores saved defaults. Escape cancels a menu without applying changes. Changes are blocked while the agent is working. Pi's existing `/thinking off|low|medium|high` and keyboard thinking controls now also reach Strata (`high` maps to `xhigh`). Credentials, file permissions and command approvals are unaffected.
|
|
80
|
+
|
|
58
81
|
## Settings
|
|
59
82
|
|
|
60
83
|
```powershell
|
package/bin/hermesdesk.js
CHANGED
|
@@ -303,11 +303,10 @@ async function main() {
|
|
|
303
303
|
if (command === "run") {
|
|
304
304
|
await runPrompt(runtime, p.join(" "), { json: !!v.json });
|
|
305
305
|
} else {
|
|
306
|
-
const {
|
|
307
|
-
"
|
|
306
|
+
const { createInteractiveMode } = await import(
|
|
307
|
+
"../src/ui/interactive.js"
|
|
308
308
|
);
|
|
309
|
-
const ui =
|
|
310
|
-
verbose: false,
|
|
309
|
+
const ui = await createInteractiveMode(runtime, {
|
|
311
310
|
initialMessage: p.length ? p.join(" ") : undefined,
|
|
312
311
|
});
|
|
313
312
|
await ui.run();
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermesdesk-agent",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "hermesdesk-agent",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.6",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@earendil-works/pi-coding-agent": "1.5.0"
|
|
12
|
+
"@earendil-works/pi-coding-agent": "1.5.0",
|
|
13
|
+
"@earendil-works/pi-tui": "1.5.0"
|
|
13
14
|
},
|
|
14
15
|
"bin": {
|
|
15
16
|
"hermesdesk": "bin/hermesdesk.js",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermesdesk-agent",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"description": "Pi-based terminal coding client for HermesDesk and Strata",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"LICENSE"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@earendil-works/pi-coding-agent": "1.5.0"
|
|
28
|
+
"@earendil-works/pi-coding-agent": "1.5.0",
|
|
29
|
+
"@earendil-works/pi-tui": "1.5.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"prettier": "3.6.2"
|
package/src/agent.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { generationPayload } from "./generation.js";
|
|
3
|
+
import { generationCommands } from "./commands.js";
|
|
3
4
|
import path from "node:path";
|
|
4
|
-
import { projectSessionDir } from "./config.js";
|
|
5
|
+
import { VERSION, projectSessionDir, validateConfig } from "./config.js";
|
|
5
6
|
import { searchTool } from "./search.js";
|
|
6
7
|
import { modelFetch } from "./transport.js";
|
|
7
8
|
import { policyExtension, workspacePath } from "./policy.js";
|
|
9
|
+
import { THEME_DIR, interfaceExtension, themeSetting } from "./ui/extension.js";
|
|
8
10
|
export async function createRuntime({
|
|
9
11
|
config,
|
|
10
12
|
home,
|
|
@@ -16,6 +18,22 @@ export async function createRuntime({
|
|
|
16
18
|
continueSession = false,
|
|
17
19
|
sessionId,
|
|
18
20
|
}) {
|
|
21
|
+
config = validateConfig({ ...config });
|
|
22
|
+
let activeSession;
|
|
23
|
+
const syncThinking = () => {
|
|
24
|
+
if (activeSession) {
|
|
25
|
+
const level = activeSession.thinkingLevel;
|
|
26
|
+
config.thinking = level !== "off";
|
|
27
|
+
if (config.thinking)
|
|
28
|
+
config.reasoningEffort =
|
|
29
|
+
level === "low" || level === "minimal"
|
|
30
|
+
? "low"
|
|
31
|
+
: level === "medium"
|
|
32
|
+
? "medium"
|
|
33
|
+
: "xhigh";
|
|
34
|
+
}
|
|
35
|
+
return { ...config };
|
|
36
|
+
};
|
|
19
37
|
const agentDir = path.join(home, "pi");
|
|
20
38
|
fs.mkdirSync(agentDir, { recursive: true });
|
|
21
39
|
process.env.PI_CODING_AGENT_DIR = agentDir;
|
|
@@ -54,7 +72,7 @@ export async function createRuntime({
|
|
|
54
72
|
id: config.model,
|
|
55
73
|
name: config.model,
|
|
56
74
|
input: ["text"],
|
|
57
|
-
reasoning:
|
|
75
|
+
reasoning: true,
|
|
58
76
|
contextWindow: config.context,
|
|
59
77
|
maxTokens: config.maxTokens,
|
|
60
78
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
@@ -67,6 +85,7 @@ export async function createRuntime({
|
|
|
67
85
|
},
|
|
68
86
|
],
|
|
69
87
|
streamSimple: (model, context, options) => {
|
|
88
|
+
syncThinking();
|
|
70
89
|
if (++requestCount > config.maxRequests)
|
|
71
90
|
throw Error(
|
|
72
91
|
"Request budget reached. Send another message to continue.",
|
|
@@ -99,6 +118,9 @@ export async function createRuntime({
|
|
|
99
118
|
enableInstallTelemetry: false,
|
|
100
119
|
packages: [],
|
|
101
120
|
cacheWarming: "off",
|
|
121
|
+
// HermesDesk draws its own header; skip Pi's resource listing at startup.
|
|
122
|
+
quietStartup: "header",
|
|
123
|
+
theme: themeSetting(),
|
|
102
124
|
retry: { enabled: false },
|
|
103
125
|
providerRetry: { maxRetries: 0, timeoutMs: 1800000 },
|
|
104
126
|
compaction: {
|
|
@@ -128,12 +150,52 @@ export async function createRuntime({
|
|
|
128
150
|
noSkills: true,
|
|
129
151
|
noPromptTemplates: true,
|
|
130
152
|
noThemes: true,
|
|
153
|
+
additionalThemePaths: [THEME_DIR],
|
|
131
154
|
noContextFiles: true,
|
|
132
155
|
appendSystemPrompt: [
|
|
133
156
|
"You are HermesDesk Agent, a coding assistant powered by a locally hosted model. Inspect before editing, preserve unrelated work, verify changes with appropriate checks, and report results honestly. File tools are restricted to the selected workspace; never bypass a declined action. Shell commands require approval and are not OS-sandboxed.",
|
|
134
157
|
...instructions,
|
|
135
158
|
],
|
|
136
159
|
extensionFactories: [
|
|
160
|
+
generationCommands({
|
|
161
|
+
home,
|
|
162
|
+
read: syncThinking,
|
|
163
|
+
apply: async (next) => {
|
|
164
|
+
if (!activeSession || !activeSession.isIdle)
|
|
165
|
+
throw Error("Wait for the agent to become idle.");
|
|
166
|
+
const current = activeSession.model;
|
|
167
|
+
if (
|
|
168
|
+
!current ||
|
|
169
|
+
current.provider !== "hermesdesk" ||
|
|
170
|
+
current.id !== config.model
|
|
171
|
+
)
|
|
172
|
+
throw Error(
|
|
173
|
+
"Select the connected HermesDesk model before changing generation settings.",
|
|
174
|
+
);
|
|
175
|
+
await activeSession.setModel({
|
|
176
|
+
...current,
|
|
177
|
+
maxTokens: next.maxTokens,
|
|
178
|
+
reasoning: true,
|
|
179
|
+
});
|
|
180
|
+
Object.assign(config, next);
|
|
181
|
+
settingsManager.applyOverrides({
|
|
182
|
+
compaction: {
|
|
183
|
+
...settingsManager.getSettings().compaction,
|
|
184
|
+
reserveTokens: Math.min(
|
|
185
|
+
config.context - 1024,
|
|
186
|
+
Math.max(config.maxTokens + 2048, 16384),
|
|
187
|
+
),
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
activeSession.setThinkingLevel(
|
|
191
|
+
next.thinking
|
|
192
|
+
? next.reasoningEffort === "xhigh"
|
|
193
|
+
? "high"
|
|
194
|
+
: next.reasoningEffort
|
|
195
|
+
: "off",
|
|
196
|
+
);
|
|
197
|
+
},
|
|
198
|
+
}),
|
|
137
199
|
policyExtension({
|
|
138
200
|
root: target,
|
|
139
201
|
readOnly,
|
|
@@ -143,6 +205,12 @@ export async function createRuntime({
|
|
|
143
205
|
requestCount = 0;
|
|
144
206
|
},
|
|
145
207
|
}),
|
|
208
|
+
interfaceExtension({
|
|
209
|
+
version: VERSION,
|
|
210
|
+
readOnly,
|
|
211
|
+
approveWrites,
|
|
212
|
+
read: syncThinking,
|
|
213
|
+
}),
|
|
146
214
|
],
|
|
147
215
|
},
|
|
148
216
|
});
|
|
@@ -168,6 +236,7 @@ export async function createRuntime({
|
|
|
168
236
|
process.platform === "win32" ? "powershell" : "bash",
|
|
169
237
|
],
|
|
170
238
|
});
|
|
239
|
+
activeSession = result.session;
|
|
171
240
|
return { ...result, services, diagnostics: services.diagnostics };
|
|
172
241
|
};
|
|
173
242
|
let sessionManager = continueSession
|
package/src/commands.js
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { loadConfig, saveConfig, validateConfig } from "./config.js";
|
|
2
|
+
import { PROFILES, profile } from "./generation.js";
|
|
3
|
+
import { limitText } from "./ui/format.js";
|
|
4
|
+
import { chooseItem } from "./ui/menu.js";
|
|
5
|
+
|
|
6
|
+
const GENERATION_KEYS = [
|
|
7
|
+
"maxTokens",
|
|
8
|
+
"thinking",
|
|
9
|
+
"reasoningEffort",
|
|
10
|
+
"thinkingBudget",
|
|
11
|
+
"temperature",
|
|
12
|
+
"topP",
|
|
13
|
+
"topK",
|
|
14
|
+
];
|
|
15
|
+
const pick = (config) =>
|
|
16
|
+
Object.fromEntries(GENERATION_KEYS.map((key) => [key, config[key]]));
|
|
17
|
+
const number = (value) => value.toLocaleString("en-US");
|
|
18
|
+
export function tokenValue(value, automatic = false) {
|
|
19
|
+
const text = String(value).trim().toLowerCase();
|
|
20
|
+
if (automatic && ["auto", "automatic", "0"].includes(text)) return 0;
|
|
21
|
+
if (!/^\d+(?:k)?$/.test(text))
|
|
22
|
+
throw Error(
|
|
23
|
+
"Use a whole token count, or 32k, 64k, 128k." +
|
|
24
|
+
(automatic ? " Use auto for the thinking budget." : ""),
|
|
25
|
+
);
|
|
26
|
+
return Number(text.replace(/k$/, "")) * (text.endsWith("k") ? 1024 : 1);
|
|
27
|
+
}
|
|
28
|
+
export function generationSummary(config) {
|
|
29
|
+
return [
|
|
30
|
+
"Generation settings",
|
|
31
|
+
`Output ${number(config.maxTokens)} tokens, thinking + answer`,
|
|
32
|
+
`Thinking ${config.thinking ? config.reasoningEffort : "off"} · budget ${config.thinkingBudget ? number(config.thinkingBudget) : "automatic"}${config.thinking ? "" : " (unused while off)"}`,
|
|
33
|
+
`Sampling temperature ${config.temperature} · top-p ${config.topP} · top-k ${config.topK}`,
|
|
34
|
+
"Applies to this session now. /limits save keeps it for future launches.",
|
|
35
|
+
].join("\n");
|
|
36
|
+
}
|
|
37
|
+
const PROFILE_NOTES = {
|
|
38
|
+
fast: "quick answers",
|
|
39
|
+
balanced: "everyday work",
|
|
40
|
+
extended: "long tasks",
|
|
41
|
+
};
|
|
42
|
+
const THINK_NOTES = {
|
|
43
|
+
off: "answer directly",
|
|
44
|
+
low: "brief reasoning",
|
|
45
|
+
medium: "moderate reasoning",
|
|
46
|
+
xhigh: "deepest reasoning",
|
|
47
|
+
};
|
|
48
|
+
/** The profile whose settings exactly match the configuration, if any. */
|
|
49
|
+
export function currentProfile(config) {
|
|
50
|
+
return Object.keys(PROFILES).find((name) =>
|
|
51
|
+
Object.entries(PROFILES[name]).every(
|
|
52
|
+
([key, value]) => config[key] === value,
|
|
53
|
+
),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
export function generationCommands({ home, read, apply }) {
|
|
57
|
+
return (pi) => {
|
|
58
|
+
// Interactive chat shows these settings in the HermesDesk footer; other UI hosts get a status.
|
|
59
|
+
const status = (ctx) => {
|
|
60
|
+
const c = read();
|
|
61
|
+
if (ctx.hasUI && ctx.mode !== "tui")
|
|
62
|
+
ctx.ui.setStatus(
|
|
63
|
+
"hermesdesk-generation",
|
|
64
|
+
`${number(c.maxTokens)} tokens | thinking ${c.thinking ? c.reasoningEffort : "off"} | /limits`,
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
const inform = (ctx, text, type = "info") => ctx.ui.notify(text, type);
|
|
68
|
+
const idle = (ctx) => {
|
|
69
|
+
if (!ctx.isIdle())
|
|
70
|
+
throw Error(
|
|
71
|
+
"Wait for the current reply to finish, or press Escape before changing generation settings.",
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
const update = async (changes, ctx) => {
|
|
75
|
+
idle(ctx);
|
|
76
|
+
const next = validateConfig({ ...read(), ...changes });
|
|
77
|
+
await apply(next);
|
|
78
|
+
status(ctx);
|
|
79
|
+
inform(ctx, generationSummary(read()));
|
|
80
|
+
};
|
|
81
|
+
const register = (name, description, values, handler) => {
|
|
82
|
+
pi.registerCommand(name, {
|
|
83
|
+
description,
|
|
84
|
+
getArgumentCompletions: (prefix) =>
|
|
85
|
+
values
|
|
86
|
+
.filter((value) => value.startsWith(prefix.trim().toLowerCase()))
|
|
87
|
+
.map((value) => ({ value, label: value })),
|
|
88
|
+
handler: async (args, ctx) => {
|
|
89
|
+
try {
|
|
90
|
+
await handler(args.trim(), ctx);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
inform(ctx, error.message, "error");
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const choose = async (ctx, title, items, subtitle) => {
|
|
98
|
+
if (!ctx.hasUI)
|
|
99
|
+
throw Error(
|
|
100
|
+
"Provide a value, or open interactive chat to use the settings menu.",
|
|
101
|
+
);
|
|
102
|
+
return chooseItem(ctx, { title, subtitle, items });
|
|
103
|
+
};
|
|
104
|
+
const selectProfile = async (args, ctx) => {
|
|
105
|
+
idle(ctx);
|
|
106
|
+
const value =
|
|
107
|
+
args ||
|
|
108
|
+
(await choose(
|
|
109
|
+
ctx,
|
|
110
|
+
"Generation profile",
|
|
111
|
+
Object.entries(PROFILES).map(([name, p]) => ({
|
|
112
|
+
value: name,
|
|
113
|
+
label: name,
|
|
114
|
+
description: `${limitText(p.maxTokens)} output · thinking ${p.thinking ? p.reasoningEffort : "off"} · ${PROFILE_NOTES[name]}`,
|
|
115
|
+
current: currentProfile(read()) === name,
|
|
116
|
+
})),
|
|
117
|
+
"Sets output size, thinking and sampling together.",
|
|
118
|
+
));
|
|
119
|
+
if (value === undefined) return;
|
|
120
|
+
await update(profile(value.toLowerCase()), ctx);
|
|
121
|
+
};
|
|
122
|
+
const selectTokens = async (args, ctx) => {
|
|
123
|
+
idle(ctx);
|
|
124
|
+
const value =
|
|
125
|
+
args ||
|
|
126
|
+
(ctx.hasUI
|
|
127
|
+
? await ctx.ui.input(
|
|
128
|
+
"Total output tokens (thinking + answer)",
|
|
129
|
+
String(read().maxTokens),
|
|
130
|
+
)
|
|
131
|
+
: undefined);
|
|
132
|
+
if (value === undefined) {
|
|
133
|
+
if (!ctx.hasUI) throw Error("Usage: /tokens 65536");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
await update({ maxTokens: tokenValue(value) }, ctx);
|
|
137
|
+
};
|
|
138
|
+
const selectThinking = async (args, ctx) => {
|
|
139
|
+
idle(ctx);
|
|
140
|
+
const value =
|
|
141
|
+
args ||
|
|
142
|
+
(await choose(
|
|
143
|
+
ctx,
|
|
144
|
+
"Thinking effort",
|
|
145
|
+
["off", "low", "medium", "xhigh"].map((value) => ({
|
|
146
|
+
value,
|
|
147
|
+
label: value,
|
|
148
|
+
description: THINK_NOTES[value],
|
|
149
|
+
current:
|
|
150
|
+
value === (read().thinking ? read().reasoningEffort : "off"),
|
|
151
|
+
})),
|
|
152
|
+
"Thinking shares the total output limit with the answer.",
|
|
153
|
+
));
|
|
154
|
+
if (value === undefined) return;
|
|
155
|
+
const setting = value.toLowerCase();
|
|
156
|
+
if (!["on", "off", "low", "medium", "high", "xhigh"].includes(setting))
|
|
157
|
+
throw Error("Usage: /think off|on|low|medium|xhigh");
|
|
158
|
+
await update(
|
|
159
|
+
setting === "off"
|
|
160
|
+
? { thinking: false }
|
|
161
|
+
: {
|
|
162
|
+
thinking: true,
|
|
163
|
+
reasoningEffort:
|
|
164
|
+
setting === "on"
|
|
165
|
+
? read().reasoningEffort
|
|
166
|
+
: setting === "high"
|
|
167
|
+
? "xhigh"
|
|
168
|
+
: setting,
|
|
169
|
+
},
|
|
170
|
+
ctx,
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
const selectBudget = async (args, ctx) => {
|
|
174
|
+
idle(ctx);
|
|
175
|
+
const value =
|
|
176
|
+
args ||
|
|
177
|
+
(ctx.hasUI
|
|
178
|
+
? await ctx.ui.input(
|
|
179
|
+
"Thinking token budget (auto, or a count below the total limit)",
|
|
180
|
+
read().thinkingBudget ? String(read().thinkingBudget) : "auto",
|
|
181
|
+
)
|
|
182
|
+
: undefined);
|
|
183
|
+
if (value === undefined) {
|
|
184
|
+
if (!ctx.hasUI) throw Error("Usage: /thinking-budget auto|8192");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
await update({ thinkingBudget: tokenValue(value, true) }, ctx);
|
|
188
|
+
};
|
|
189
|
+
const save = (ctx) => {
|
|
190
|
+
idle(ctx);
|
|
191
|
+
// Merge only generation controls into fresh defaults; preserve another terminal's connection and model settings.
|
|
192
|
+
saveConfig({ ...loadConfig(home), ...pick(read()) }, home);
|
|
193
|
+
inform(
|
|
194
|
+
ctx,
|
|
195
|
+
"Generation defaults saved for future launches.\n" +
|
|
196
|
+
generationSummary(read()),
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
register(
|
|
200
|
+
"profile",
|
|
201
|
+
"Generation profile: fast (32K), balanced (64K), extended (131K)",
|
|
202
|
+
["fast", "balanced", "extended"],
|
|
203
|
+
selectProfile,
|
|
204
|
+
);
|
|
205
|
+
register(
|
|
206
|
+
"tokens",
|
|
207
|
+
"Set the total output limit, including thinking",
|
|
208
|
+
["32768", "65536", "131072"],
|
|
209
|
+
selectTokens,
|
|
210
|
+
);
|
|
211
|
+
// Pi already owns /thinking. Keep it available, with /think as the Strata xhigh/on/off control.
|
|
212
|
+
register(
|
|
213
|
+
"think",
|
|
214
|
+
"Set Strata thinking: off, low, medium or xhigh",
|
|
215
|
+
["off", "on", "low", "medium", "xhigh"],
|
|
216
|
+
selectThinking,
|
|
217
|
+
);
|
|
218
|
+
register(
|
|
219
|
+
"thinking-budget",
|
|
220
|
+
"Set a thinking-token ceiling, or auto",
|
|
221
|
+
["auto", "4096", "8192", "16384"],
|
|
222
|
+
selectBudget,
|
|
223
|
+
);
|
|
224
|
+
register(
|
|
225
|
+
"limits",
|
|
226
|
+
"Generation settings menu; show, save or reset defaults",
|
|
227
|
+
["show", "save", "reset"],
|
|
228
|
+
async (args, ctx) => {
|
|
229
|
+
if (args === "show") return inform(ctx, generationSummary(read()));
|
|
230
|
+
if (args === "save") return save(ctx);
|
|
231
|
+
if (args === "reset") return update(pick(loadConfig(home)), ctx);
|
|
232
|
+
if (args) throw Error("Usage: /limits [show|save|reset]");
|
|
233
|
+
idle(ctx);
|
|
234
|
+
const c = read();
|
|
235
|
+
const budget = c.thinkingBudget
|
|
236
|
+
? number(c.thinkingBudget)
|
|
237
|
+
: "automatic";
|
|
238
|
+
// Values stay as the plain labels used by non-interactive hosts; the menu shows label + detail.
|
|
239
|
+
const items = [
|
|
240
|
+
["Choose profile", "Profile", currentProfile(c) ?? "custom"],
|
|
241
|
+
[
|
|
242
|
+
`Total output: ${number(c.maxTokens)}`,
|
|
243
|
+
"Total output",
|
|
244
|
+
`${number(c.maxTokens)} tokens · thinking + answer`,
|
|
245
|
+
],
|
|
246
|
+
[
|
|
247
|
+
`Thinking: ${c.thinking ? c.reasoningEffort : "off"}`,
|
|
248
|
+
"Thinking",
|
|
249
|
+
c.thinking ? c.reasoningEffort : "off",
|
|
250
|
+
],
|
|
251
|
+
[
|
|
252
|
+
`Thinking budget: ${budget}`,
|
|
253
|
+
"Thinking budget",
|
|
254
|
+
budget + (c.thinking ? "" : " · unused while off"),
|
|
255
|
+
],
|
|
256
|
+
["Show current settings", "Show summary", "print every setting"],
|
|
257
|
+
["Save as defaults", "Save as defaults", "keep for future launches"],
|
|
258
|
+
[
|
|
259
|
+
"Restore saved defaults",
|
|
260
|
+
"Restore defaults",
|
|
261
|
+
"undo session changes",
|
|
262
|
+
],
|
|
263
|
+
].map(([value, label, description]) => ({ value, label, description }));
|
|
264
|
+
const actions = items.map((item) => item.value);
|
|
265
|
+
const selected = await choose(
|
|
266
|
+
ctx,
|
|
267
|
+
"Generation settings",
|
|
268
|
+
items,
|
|
269
|
+
"Changes apply now; save to keep them for future launches.",
|
|
270
|
+
);
|
|
271
|
+
if (selected === undefined) return;
|
|
272
|
+
switch (actions.indexOf(selected)) {
|
|
273
|
+
case 0:
|
|
274
|
+
return selectProfile("", ctx);
|
|
275
|
+
case 1:
|
|
276
|
+
return selectTokens("", ctx);
|
|
277
|
+
case 2:
|
|
278
|
+
return selectThinking("", ctx);
|
|
279
|
+
case 3:
|
|
280
|
+
return selectBudget("", ctx);
|
|
281
|
+
case 4:
|
|
282
|
+
return inform(ctx, generationSummary(read()));
|
|
283
|
+
case 5:
|
|
284
|
+
return save(ctx);
|
|
285
|
+
case 6:
|
|
286
|
+
return update(pick(loadConfig(home)), ctx);
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
);
|
|
290
|
+
pi.on("session_start", (_event, ctx) => status(ctx));
|
|
291
|
+
pi.on("thinking_level_select", (_event, ctx) => status(ctx));
|
|
292
|
+
};
|
|
293
|
+
}
|
package/src/config.js
CHANGED
package/src/policy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import { VERSION } from "./config.js";
|
|
3
2
|
import path from "node:path";
|
|
3
|
+
import { requestApproval } from "./ui/approval.js";
|
|
4
4
|
const protectedPart = (p) =>
|
|
5
5
|
/^\.env(?:\.|$)/i.test(p) ||
|
|
6
6
|
[".git", ".ssh", ".aws", ".codex", ".claude", ".pi", "node_modules"].includes(
|
|
@@ -94,7 +94,9 @@ export function policyExtension({
|
|
|
94
94
|
mutation = shell || ["edit", "write"].includes(name);
|
|
95
95
|
if (readOnly && mutation)
|
|
96
96
|
return { block: true, reason: "Read-only mode is enabled." };
|
|
97
|
-
|
|
97
|
+
const target = shell
|
|
98
|
+
? undefined
|
|
99
|
+
: workspacePath(root, input.path || ".");
|
|
98
100
|
if (mutation) {
|
|
99
101
|
if (!shell && approveWrites) return;
|
|
100
102
|
if (!ctx.hasUI)
|
|
@@ -104,18 +106,7 @@ export function policyExtension({
|
|
|
104
106
|
? "Shell commands require interactive approval."
|
|
105
107
|
: "File changes require interactive approval, or explicit --approve-writes.",
|
|
106
108
|
};
|
|
107
|
-
const
|
|
108
|
-
? "This command runs with your Windows account permissions, without an OS sandbox.\n\n" +
|
|
109
|
-
String(input.command || "")
|
|
110
|
-
: String(input.path) +
|
|
111
|
-
"\n\n" +
|
|
112
|
-
(name === "write"
|
|
113
|
-
? String(input.content || "")
|
|
114
|
-
: JSON.stringify(input.edits || input));
|
|
115
|
-
const yes = await ctx.ui.confirm(
|
|
116
|
-
shell ? "Approve shell command?" : "Approve " + name + "?",
|
|
117
|
-
detail,
|
|
118
|
-
);
|
|
109
|
+
const yes = await requestApproval(ctx, name, input, target);
|
|
119
110
|
if (!yes)
|
|
120
111
|
return { block: true, reason: "The user declined this action." };
|
|
121
112
|
}
|
|
@@ -134,22 +125,5 @@ export function policyExtension({
|
|
|
134
125
|
},
|
|
135
126
|
};
|
|
136
127
|
});
|
|
137
|
-
pi.on("session_start", (_e, ctx) => {
|
|
138
|
-
if (ctx.hasUI) {
|
|
139
|
-
ctx.ui.setStatus(
|
|
140
|
-
"hermesdesk",
|
|
141
|
-
readOnly
|
|
142
|
-
? "HermesDesk | read only"
|
|
143
|
-
: "HermesDesk | ask before edits and commands",
|
|
144
|
-
);
|
|
145
|
-
ctx.ui.setHeader(() => ({
|
|
146
|
-
render: () => [
|
|
147
|
-
`HermesDesk Agent ${VERSION} | powered by Pi`,
|
|
148
|
-
"Strata models run remotely. File tools act in this workspace.",
|
|
149
|
-
],
|
|
150
|
-
invalidate() {},
|
|
151
|
-
}));
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
128
|
};
|
|
155
129
|
}
|