hermesdesk-agent 0.1.0-alpha.4 → 0.1.0-alpha.5

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/NKocur/hermesdesk-agent/actions/workflows/ci.yml/badge.svg)](https://github.com/NKocur/hermesdesk-agent/actions/workflows/ci.yml)
4
4
 
5
- **Windows alpha: 0.1.0-alpha.4.** Community client built on Pi; not affiliated with or endorsed by Earendil Works or Nous Research.
5
+ **Windows alpha: 0.1.0-alpha.5.** 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.4.tgz`.
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.5.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
 
@@ -55,6 +55,25 @@ hermesdesk.cmd run "Summarize README.md" --json
55
55
 
56
56
  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
57
 
58
+ ## In-chat controls
59
+
60
+ Use these inside interactive chat. Commands run locally, consume no model tokens, and change the next request without restarting the conversation:
61
+
62
+ ```text
63
+ /limits
64
+ /profile extended
65
+ /tokens 65536
66
+ /think xhigh
67
+ /thinking-budget 8192
68
+ /thinking-budget auto
69
+ /limits show
70
+ /limits save
71
+ ```
72
+
73
+ `/limits` opens a selector for the same controls. 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.
74
+
75
+ 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.
76
+
58
77
  ## Settings
59
78
 
60
79
  ```powershell
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hermesdesk-agent",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "hermesdesk-agent",
9
- "version": "0.1.0-alpha.4",
9
+ "version": "0.1.0-alpha.5",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@earendil-works/pi-coding-agent": "1.5.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermesdesk-agent",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
4
4
  "description": "Pi-based terminal coding client for HermesDesk and Strata",
5
5
  "type": "module",
6
6
  "bin": {
package/src/agent.js CHANGED
@@ -1,7 +1,8 @@
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 { 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";
@@ -16,6 +17,22 @@ export async function createRuntime({
16
17
  continueSession = false,
17
18
  sessionId,
18
19
  }) {
20
+ config = validateConfig({ ...config });
21
+ let activeSession;
22
+ const syncThinking = () => {
23
+ if (activeSession) {
24
+ const level = activeSession.thinkingLevel;
25
+ config.thinking = level !== "off";
26
+ if (config.thinking)
27
+ config.reasoningEffort =
28
+ level === "low" || level === "minimal"
29
+ ? "low"
30
+ : level === "medium"
31
+ ? "medium"
32
+ : "xhigh";
33
+ }
34
+ return { ...config };
35
+ };
19
36
  const agentDir = path.join(home, "pi");
20
37
  fs.mkdirSync(agentDir, { recursive: true });
21
38
  process.env.PI_CODING_AGENT_DIR = agentDir;
@@ -54,7 +71,7 @@ export async function createRuntime({
54
71
  id: config.model,
55
72
  name: config.model,
56
73
  input: ["text"],
57
- reasoning: config.thinking,
74
+ reasoning: true,
58
75
  contextWindow: config.context,
59
76
  maxTokens: config.maxTokens,
60
77
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
@@ -67,6 +84,7 @@ export async function createRuntime({
67
84
  },
68
85
  ],
69
86
  streamSimple: (model, context, options) => {
87
+ syncThinking();
70
88
  if (++requestCount > config.maxRequests)
71
89
  throw Error(
72
90
  "Request budget reached. Send another message to continue.",
@@ -134,6 +152,45 @@ export async function createRuntime({
134
152
  ...instructions,
135
153
  ],
136
154
  extensionFactories: [
155
+ generationCommands({
156
+ home,
157
+ read: syncThinking,
158
+ apply: async (next) => {
159
+ if (!activeSession || !activeSession.isIdle)
160
+ throw Error("Wait for the agent to become idle.");
161
+ const current = activeSession.model;
162
+ if (
163
+ !current ||
164
+ current.provider !== "hermesdesk" ||
165
+ current.id !== config.model
166
+ )
167
+ throw Error(
168
+ "Select the connected HermesDesk model before changing generation settings.",
169
+ );
170
+ await activeSession.setModel({
171
+ ...current,
172
+ maxTokens: next.maxTokens,
173
+ reasoning: true,
174
+ });
175
+ Object.assign(config, next);
176
+ settingsManager.applyOverrides({
177
+ compaction: {
178
+ ...settingsManager.getSettings().compaction,
179
+ reserveTokens: Math.min(
180
+ config.context - 1024,
181
+ Math.max(config.maxTokens + 2048, 16384),
182
+ ),
183
+ },
184
+ });
185
+ activeSession.setThinkingLevel(
186
+ next.thinking
187
+ ? next.reasoningEffort === "xhigh"
188
+ ? "high"
189
+ : next.reasoningEffort
190
+ : "off",
191
+ );
192
+ },
193
+ }),
137
194
  policyExtension({
138
195
  root: target,
139
196
  readOnly,
@@ -168,6 +225,7 @@ export async function createRuntime({
168
225
  process.platform === "win32" ? "powershell" : "bash",
169
226
  ],
170
227
  });
228
+ activeSession = result.session;
171
229
  return { ...result, services, diagnostics: services.diagnostics };
172
230
  };
173
231
  let sessionManager = continueSession
@@ -0,0 +1,237 @@
1
+ import { loadConfig, saveConfig, validateConfig } from "./config.js";
2
+ import { profile } from "./generation.js";
3
+
4
+ const GENERATION_KEYS = [
5
+ "maxTokens",
6
+ "thinking",
7
+ "reasoningEffort",
8
+ "thinkingBudget",
9
+ "temperature",
10
+ "topP",
11
+ "topK",
12
+ ];
13
+ const pick = (config) =>
14
+ Object.fromEntries(GENERATION_KEYS.map((key) => [key, config[key]]));
15
+ const number = (value) => value.toLocaleString("en-US");
16
+ export function tokenValue(value, automatic = false) {
17
+ const text = String(value).trim().toLowerCase();
18
+ if (automatic && ["auto", "automatic", "0"].includes(text)) return 0;
19
+ if (!/^\d+(?:k)?$/.test(text))
20
+ throw Error(
21
+ "Use a whole token count, or 32k, 64k, 128k." +
22
+ (automatic ? " Use auto for the thinking budget." : ""),
23
+ );
24
+ return Number(text.replace(/k$/, "")) * (text.endsWith("k") ? 1024 : 1);
25
+ }
26
+ export function generationSummary(config) {
27
+ return [
28
+ `Total output: ${number(config.maxTokens)} tokens (thinking + answer)`,
29
+ `Thinking: ${config.thinking ? config.reasoningEffort : "off"}`,
30
+ `Thinking budget: ${config.thinkingBudget ? number(config.thinkingBudget) : "automatic"}${config.thinking ? "" : " (unused while thinking is off)"}`,
31
+ `Sampling: temperature ${config.temperature}, top-p ${config.topP}, top-k ${config.topK}`,
32
+ "Changes apply now to this CLI session. /limits save keeps them for future launches.",
33
+ ].join("\n");
34
+ }
35
+ export function generationCommands({ home, read, apply }) {
36
+ return (pi) => {
37
+ const status = (ctx) => {
38
+ const c = read();
39
+ if (ctx.hasUI)
40
+ ctx.ui.setStatus(
41
+ "hermesdesk-generation",
42
+ `${number(c.maxTokens)} tokens | thinking ${c.thinking ? c.reasoningEffort : "off"} | /limits`,
43
+ );
44
+ };
45
+ const inform = (ctx, text, type = "info") => ctx.ui.notify(text, type);
46
+ const idle = (ctx) => {
47
+ if (!ctx.isIdle())
48
+ throw Error(
49
+ "Wait for the current reply to finish, or press Escape before changing generation settings.",
50
+ );
51
+ };
52
+ const update = async (changes, ctx) => {
53
+ idle(ctx);
54
+ const next = validateConfig({ ...read(), ...changes });
55
+ await apply(next);
56
+ status(ctx);
57
+ inform(ctx, generationSummary(read()));
58
+ };
59
+ const register = (name, description, values, handler) => {
60
+ pi.registerCommand(name, {
61
+ description,
62
+ getArgumentCompletions: (prefix) =>
63
+ values
64
+ .filter((value) => value.startsWith(prefix.trim().toLowerCase()))
65
+ .map((value) => ({ value, label: value })),
66
+ handler: async (args, ctx) => {
67
+ try {
68
+ await handler(args.trim(), ctx);
69
+ } catch (error) {
70
+ inform(ctx, error.message, "error");
71
+ }
72
+ },
73
+ });
74
+ };
75
+ const choose = async (ctx, title, values) => {
76
+ if (!ctx.hasUI)
77
+ throw Error(
78
+ "Provide a value, or open interactive chat to use the settings menu.",
79
+ );
80
+ return ctx.ui.select(title, values);
81
+ };
82
+ const selectProfile = async (args, ctx) => {
83
+ idle(ctx);
84
+ const value =
85
+ args ||
86
+ (await choose(ctx, "Generation profile", [
87
+ "fast",
88
+ "balanced",
89
+ "extended",
90
+ ]));
91
+ if (value === undefined) return;
92
+ await update(profile(value.toLowerCase()), ctx);
93
+ };
94
+ const selectTokens = async (args, ctx) => {
95
+ idle(ctx);
96
+ const value =
97
+ args ||
98
+ (ctx.hasUI
99
+ ? await ctx.ui.input(
100
+ "Total output tokens (thinking + answer)",
101
+ String(read().maxTokens),
102
+ )
103
+ : undefined);
104
+ if (value === undefined) {
105
+ if (!ctx.hasUI) throw Error("Usage: /tokens 65536");
106
+ return;
107
+ }
108
+ await update({ maxTokens: tokenValue(value) }, ctx);
109
+ };
110
+ const selectThinking = async (args, ctx) => {
111
+ idle(ctx);
112
+ const value =
113
+ args ||
114
+ (await choose(ctx, "Thinking effort", [
115
+ "off",
116
+ "low",
117
+ "medium",
118
+ "xhigh",
119
+ ]));
120
+ if (value === undefined) return;
121
+ const setting = value.toLowerCase();
122
+ if (!["on", "off", "low", "medium", "high", "xhigh"].includes(setting))
123
+ throw Error("Usage: /think off|on|low|medium|xhigh");
124
+ await update(
125
+ setting === "off"
126
+ ? { thinking: false }
127
+ : {
128
+ thinking: true,
129
+ reasoningEffort:
130
+ setting === "on"
131
+ ? read().reasoningEffort
132
+ : setting === "high"
133
+ ? "xhigh"
134
+ : setting,
135
+ },
136
+ ctx,
137
+ );
138
+ };
139
+ const selectBudget = async (args, ctx) => {
140
+ idle(ctx);
141
+ const value =
142
+ args ||
143
+ (ctx.hasUI
144
+ ? await ctx.ui.input(
145
+ "Thinking token budget (auto, or a count below the total limit)",
146
+ read().thinkingBudget ? String(read().thinkingBudget) : "auto",
147
+ )
148
+ : undefined);
149
+ if (value === undefined) {
150
+ if (!ctx.hasUI) throw Error("Usage: /thinking-budget auto|8192");
151
+ return;
152
+ }
153
+ await update({ thinkingBudget: tokenValue(value, true) }, ctx);
154
+ };
155
+ const save = (ctx) => {
156
+ idle(ctx);
157
+ // Merge only generation controls into fresh defaults; preserve another terminal's connection and model settings.
158
+ saveConfig({ ...loadConfig(home), ...pick(read()) }, home);
159
+ inform(
160
+ ctx,
161
+ "Generation defaults saved for future launches.\n" +
162
+ generationSummary(read()),
163
+ );
164
+ };
165
+ register(
166
+ "profile",
167
+ "Generation profile: fast (32K), balanced (64K), extended (131K)",
168
+ ["fast", "balanced", "extended"],
169
+ selectProfile,
170
+ );
171
+ register(
172
+ "tokens",
173
+ "Set the total output limit, including thinking",
174
+ ["32768", "65536", "131072"],
175
+ selectTokens,
176
+ );
177
+ // Pi already owns /thinking. Keep it available, with /think as the Strata xhigh/on/off control.
178
+ register(
179
+ "think",
180
+ "Set Strata thinking: off, low, medium or xhigh",
181
+ ["off", "on", "low", "medium", "xhigh"],
182
+ selectThinking,
183
+ );
184
+ register(
185
+ "thinking-budget",
186
+ "Set a thinking-token ceiling, or auto",
187
+ ["auto", "4096", "8192", "16384"],
188
+ selectBudget,
189
+ );
190
+ register(
191
+ "limits",
192
+ "Generation settings menu; show, save or reset defaults",
193
+ ["show", "save", "reset"],
194
+ async (args, ctx) => {
195
+ if (args === "show") return inform(ctx, generationSummary(read()));
196
+ if (args === "save") return save(ctx);
197
+ if (args === "reset") return update(pick(loadConfig(home)), ctx);
198
+ if (args) throw Error("Usage: /limits [show|save|reset]");
199
+ idle(ctx);
200
+ const c = read();
201
+ const actions = [
202
+ "Choose profile",
203
+ `Total output: ${number(c.maxTokens)}`,
204
+ `Thinking: ${c.thinking ? c.reasoningEffort : "off"}`,
205
+ `Thinking budget: ${c.thinkingBudget ? number(c.thinkingBudget) : "automatic"}`,
206
+ "Show current settings",
207
+ "Save as defaults",
208
+ "Restore saved defaults",
209
+ ];
210
+ const selected = await choose(
211
+ ctx,
212
+ "HermesDesk generation settings",
213
+ actions,
214
+ );
215
+ if (selected === undefined) return;
216
+ switch (actions.indexOf(selected)) {
217
+ case 0:
218
+ return selectProfile("", ctx);
219
+ case 1:
220
+ return selectTokens("", ctx);
221
+ case 2:
222
+ return selectThinking("", ctx);
223
+ case 3:
224
+ return selectBudget("", ctx);
225
+ case 4:
226
+ return inform(ctx, generationSummary(read()));
227
+ case 5:
228
+ return save(ctx);
229
+ case 6:
230
+ return update(pick(loadConfig(home)), ctx);
231
+ }
232
+ },
233
+ );
234
+ pi.on("session_start", (_event, ctx) => status(ctx));
235
+ pi.on("thinking_level_select", (_event, ctx) => status(ctx));
236
+ };
237
+ }
package/src/config.js CHANGED
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import crypto from "node:crypto";
5
- export const VERSION = "0.1.0-alpha.4";
5
+ export const VERSION = "0.1.0-alpha.5";
6
6
  export const DEFAULTS = {
7
7
  baseUrl: null,
8
8
  model: null,
package/src/policy.js CHANGED
@@ -146,6 +146,7 @@ export function policyExtension({
146
146
  render: () => [
147
147
  `HermesDesk Agent ${VERSION} | powered by Pi`,
148
148
  "Strata models run remotely. File tools act in this workspace.",
149
+ "Use /limits for output and thinking settings; /profile extended selects 131K.",
149
150
  ],
150
151
  invalidate() {},
151
152
  }));