hermesdesk-agent 0.1.0-alpha.3 → 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.3.** 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.3.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,20 +55,53 @@ 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
61
80
  hermesdesk.cmd config
81
+ hermesdesk.cmd config preset extended
62
82
  hermesdesk.cmd config set thinking true
63
- hermesdesk.cmd config set context 131072
64
- hermesdesk.cmd config set maxTokens 4096
83
+ hermesdesk.cmd config set reasoningEffort xhigh
84
+ hermesdesk.cmd config set thinkingBudget 16384
85
+ hermesdesk.cmd config set context 262144
86
+ hermesdesk.cmd config set maxTokens 131072
65
87
  hermesdesk.cmd config set temperature 0.7
66
88
  hermesdesk.cmd config set topP 0.95
67
89
  hermesdesk.cmd config set topK 20
68
90
  hermesdesk.cmd config set maxRequests 64
69
91
  ```
70
92
 
71
- Changes apply to the next launch. Context is client metadata, not a request to allocate more server context: keep it at or below the server's configured capacity. Output is capped at 8192 by the gateway. The default request budget is 64 per message and can be set from 1 to 512. Pi's in-chat settings are session-only in this version. Change the server using `hermesdesk connect --url https://your-server/v1`. HTTP is accepted only on loopback addresses.
93
+ Profiles: `fast` uses 32K with thinking off; `balanced` uses 64K with xhigh thinking; `extended` uses 131K with xhigh thinking. Thinking profiles use Qwen's recommended sampling (temperature 1, top-p .95, top-k 20). `thinkingBudget 0` is automatic. A positive budget is a ceiling, must be below `maxTokens`, and Strata may reduce it to preserve answer space. `maxTokens` includes **thinking plus the final answer**; the model can stop earlier.
94
+
95
+ For a single launch, without changing saved settings:
96
+
97
+ ```powershell
98
+ hermesdesk.cmd chat --profile extended
99
+ hermesdesk.cmd run "Review this repository" --read-only --max-tokens 65536 --thinking on --reasoning-effort medium --thinking-budget 8192
100
+ ```
101
+
102
+ Fresh installations default to a 131K total cap with thinking off. Existing saved values are retained: use `config preset extended` to switch to the tested thinking profile. The server must support these limits; older gateways capped output at 8K. Pi's compaction reserves space for the configured output budget.
103
+
104
+ Changes apply to the next launch. Context is client metadata, not a request to allocate more server context: keep it at or below the server's configured capacity. The updated gateway allows up to 131072 combined output tokens. Input, thinking and answer share the server context; the full 262K-thinking plus 131K-answer allowance in Qwen documentation assumes an extended 1M context. The default request budget is 64 per message and can be set from 1 to 512. Pi's in-chat settings are session-only in this version. Change the server using `hermesdesk connect --url https://your-server/v1`. HTTP is accepted only on loopback addresses.
72
105
 
73
106
  Windows uses its built-in `curl.exe` for model HTTP requests because the retained Cloudflare bot filter challenged Node fetch and a native Node follow-up request during testing. TLS verification stays enabled, redirects are not followed, credentials are sent through stdin rather than command-line arguments, and disconnects cancel the request. `doctor` checks the connection without loading the model. A browser challenge from zone-wide Bot Fight Mode cannot be solved by an API client; the server owner must configure API-compatible protection. Transport compatibility alone does not guarantee that every computer will be accepted. Cold Strata startup can still take minutes; the client cannot remove server warm-up costs. A Cloudflare 403 is a connection failure, not a model error.
74
107
 
package/bin/hermesdesk.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from "node:fs";
3
+ import { profile } from "../src/generation.js";
3
4
  import path from "node:path";
4
5
  import readline from "node:readline/promises";
5
6
  import { parseArgs } from "node:util";
@@ -42,18 +43,26 @@ const help = `HermesDesk Agent ${VERSION} (Pi-based, Windows first)
42
43
  hermesdesk chat [--cwd PATH] [--continue | --session ID] [--read-only]
43
44
  hermesdesk run "REQUEST" [--cwd PATH] [--json] [--read-only]
44
45
  hermesdesk sessions [--cwd PATH]
45
- hermesdesk config [set KEY VALUE]
46
+ hermesdesk config [set KEY VALUE | preset fast|balanced|extended]
46
47
  hermesdesk logout
47
48
 
48
49
  Edits and shell commands ask for approval in interactive chat.
49
50
  One-shot runs deny changes by default; --approve-writes permits workspace file edits.
50
51
  Shell commands always require interactive approval. This is not an OS sandbox.
51
- Settings: model, context, maxTokens, thinking, temperature, topP, topK, maxRequests.
52
+ Settings: model, context, maxTokens (total thinking + answer), thinking,
53
+ reasoningEffort (low|medium|xhigh), thinkingBudget (0=automatic), temperature, topP, topK, maxRequests.
54
+ Run overrides: --profile fast|balanced|extended --max-tokens N --thinking on|off
55
+ --reasoning-effort low|medium|xhigh --thinking-budget N
52
56
  `;
53
57
  async function main() {
54
58
  const { values: v, positionals: p } = parseArgs({
55
59
  allowPositionals: true,
56
60
  options: {
61
+ profile: { type: "string" },
62
+ "max-tokens": { type: "string" },
63
+ thinking: { type: "string" },
64
+ "reasoning-effort": { type: "string" },
65
+ "thinking-budget": { type: "string" },
57
66
  url: { type: "string" },
58
67
  code: { type: "boolean" },
59
68
  manual: { type: "boolean" },
@@ -178,7 +187,9 @@ async function main() {
178
187
  return;
179
188
  }
180
189
  if (command === "config") {
181
- if (p[0] === "set") {
190
+ if (p[0] === "preset") {
191
+ config = saveConfig({ ...config, ...profile(p[1]) }, home);
192
+ } else if (p[0] === "set") {
182
193
  const key = p[1];
183
194
  if (!Object.hasOwn(config, key) || key === "baseUrl")
184
195
  throw Error(
@@ -187,7 +198,7 @@ async function main() {
187
198
  const raw = p.slice(2).join(" ");
188
199
  if (!raw) throw Error("Provide a setting value.");
189
200
  let value = raw;
190
- if (key !== "model") {
201
+ if (!["model", "reasoningEffort"].includes(key)) {
191
202
  try {
192
203
  value = JSON.parse(raw);
193
204
  } catch {
@@ -251,6 +262,20 @@ async function main() {
251
262
  if (!models.includes(config.model)) process.exitCode = 1;
252
263
  return;
253
264
  }
265
+ const overrides = {};
266
+ if (v.profile) Object.assign(overrides, profile(v.profile));
267
+ if (v["max-tokens"] !== undefined)
268
+ overrides.maxTokens = Number(v["max-tokens"]);
269
+ if (v["thinking-budget"] !== undefined)
270
+ overrides.thinkingBudget = Number(v["thinking-budget"]);
271
+ if (v["reasoning-effort"] !== undefined)
272
+ overrides.reasoningEffort = v["reasoning-effort"];
273
+ if (v.thinking !== undefined) {
274
+ if (!["on", "off"].includes(v.thinking))
275
+ throw Error("Use --thinking on or --thinking off.");
276
+ overrides.thinking = v.thinking === "on";
277
+ }
278
+ config = validateConfig({ ...config, ...overrides });
254
279
  const cwd = fs.realpathSync.native(v.cwd || process.cwd());
255
280
  if (command === "chat" && (!process.stdin.isTTY || !process.stdout.isTTY))
256
281
  throw Error(
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hermesdesk-agent",
3
- "version": "0.1.0-alpha.3",
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.3",
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.3",
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,6 +1,8 @@
1
1
  import fs from "node:fs";
2
+ import { generationPayload } from "./generation.js";
3
+ import { generationCommands } from "./commands.js";
2
4
  import path from "node:path";
3
- import { projectSessionDir } from "./config.js";
5
+ import { projectSessionDir, validateConfig } from "./config.js";
4
6
  import { searchTool } from "./search.js";
5
7
  import { modelFetch } from "./transport.js";
6
8
  import { policyExtension, workspacePath } from "./policy.js";
@@ -15,6 +17,22 @@ export async function createRuntime({
15
17
  continueSession = false,
16
18
  sessionId,
17
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
+ };
18
36
  const agentDir = path.join(home, "pi");
19
37
  fs.mkdirSync(agentDir, { recursive: true });
20
38
  process.env.PI_CODING_AGENT_DIR = agentDir;
@@ -53,7 +71,7 @@ export async function createRuntime({
53
71
  id: config.model,
54
72
  name: config.model,
55
73
  input: ["text"],
56
- reasoning: config.thinking,
74
+ reasoning: true,
57
75
  contextWindow: config.context,
58
76
  maxTokens: config.maxTokens,
59
77
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
@@ -66,6 +84,7 @@ export async function createRuntime({
66
84
  },
67
85
  ],
68
86
  streamSimple: (model, context, options) => {
87
+ syncThinking();
69
88
  if (++requestCount > config.maxRequests)
70
89
  throw Error(
71
90
  "Request budget reached. Send another message to continue.",
@@ -79,12 +98,7 @@ export async function createRuntime({
79
98
  onPayload: async (payload, m) => {
80
99
  const p = (await options?.onPayload?.(payload, m)) ?? payload;
81
100
  delete p.store;
82
- delete p.reasoning_effort;
83
- p.max_tokens = config.maxTokens;
84
- p.temperature = config.temperature;
85
- p.top_p = config.topP;
86
- p.top_k = config.topK;
87
- p.chat_template_kwargs = { enable_thinking: config.thinking };
101
+ Object.assign(p, generationPayload(config));
88
102
  return p;
89
103
  },
90
104
  });
@@ -107,7 +121,10 @@ export async function createRuntime({
107
121
  providerRetry: { maxRetries: 0, timeoutMs: 1800000 },
108
122
  compaction: {
109
123
  enabled: true,
110
- reserveTokens: Math.min(16384, Math.floor(config.context / 4)),
124
+ reserveTokens: Math.min(
125
+ config.context - 1024,
126
+ Math.max(config.maxTokens + 2048, 16384),
127
+ ),
111
128
  keepRecentTokens: Math.min(12000, Math.floor(config.context / 4)),
112
129
  },
113
130
  });
@@ -135,6 +152,45 @@ export async function createRuntime({
135
152
  ...instructions,
136
153
  ],
137
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
+ }),
138
194
  policyExtension({
139
195
  root: target,
140
196
  readOnly,
@@ -152,7 +208,11 @@ export async function createRuntime({
152
208
  sessionManager,
153
209
  sessionStartEvent,
154
210
  model,
155
- thinkingLevel: config.thinking ? "medium" : "off",
211
+ thinkingLevel: config.thinking
212
+ ? config.reasoningEffort === "xhigh"
213
+ ? "high"
214
+ : config.reasoningEffort
215
+ : "off",
156
216
  customTools: [searchTool(target)],
157
217
  tools: readOnly
158
218
  ? ["read", "ls", "search"]
@@ -165,6 +225,7 @@ export async function createRuntime({
165
225
  process.platform === "win32" ? "powershell" : "bash",
166
226
  ],
167
227
  });
228
+ activeSession = result.session;
168
229
  return { ...result, services, diagnostics: services.diagnostics };
169
230
  };
170
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,12 +2,14 @@ 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.3";
5
+ export const VERSION = "0.1.0-alpha.5";
6
6
  export const DEFAULTS = {
7
7
  baseUrl: null,
8
8
  model: null,
9
9
  context: 262144,
10
- maxTokens: 8192,
10
+ maxTokens: 131072,
11
+ reasoningEffort: "xhigh",
12
+ thinkingBudget: 0,
11
13
  thinking: false,
12
14
  temperature: 0.7,
13
15
  topP: 0.95,
@@ -53,14 +55,21 @@ export function validateConfig(input) {
53
55
  throw Error("Invalid model ID.");
54
56
  for (const [k, min, max] of [
55
57
  ["context", 8192, 1048576],
56
- ["maxTokens", 1, 8192],
58
+ ["maxTokens", 1, 131072],
59
+ ["thinkingBudget", 0, 131071],
57
60
  ["topK", 0, 1000],
58
61
  ["maxRequests", 1, 512],
59
62
  ])
60
63
  if (!Number.isInteger(c[k]) || c[k] < min || c[k] > max)
61
64
  throw Error(k + " must be an integer from " + min + " to " + max + ".");
62
- if (c.maxTokens >= c.context)
63
- throw Error("Output tokens must be below context size.");
65
+ if (!["low", "medium", "xhigh"].includes(c.reasoningEffort))
66
+ throw Error("reasoningEffort must be low, medium or xhigh.");
67
+ if (c.thinkingBudget && c.thinkingBudget >= c.maxTokens)
68
+ throw Error("Thinking budget must be below the total output limit.");
69
+ if (c.maxTokens + 1024 >= c.context)
70
+ throw Error(
71
+ "Total output must leave at least 1024 context tokens for input.",
72
+ );
64
73
  if (typeof c.thinking !== "boolean")
65
74
  throw Error("thinking must be true or false.");
66
75
  for (const [k, max] of [
@@ -0,0 +1,48 @@
1
+ export const PROFILES = Object.freeze({
2
+ fast: {
3
+ maxTokens: 32768,
4
+ thinking: false,
5
+ reasoningEffort: "xhigh",
6
+ thinkingBudget: 0,
7
+ temperature: 0.7,
8
+ topP: 0.8,
9
+ topK: 20,
10
+ },
11
+ balanced: {
12
+ maxTokens: 65536,
13
+ thinking: true,
14
+ reasoningEffort: "xhigh",
15
+ thinkingBudget: 0,
16
+ temperature: 1,
17
+ topP: 0.95,
18
+ topK: 20,
19
+ },
20
+ extended: {
21
+ maxTokens: 131072,
22
+ thinking: true,
23
+ reasoningEffort: "xhigh",
24
+ thinkingBudget: 0,
25
+ temperature: 1,
26
+ topP: 0.95,
27
+ topK: 20,
28
+ },
29
+ });
30
+ export function profile(name) {
31
+ if (!Object.hasOwn(PROFILES, name))
32
+ throw Error("Choose profile fast, balanced or extended.");
33
+ return PROFILES[name];
34
+ }
35
+ export function generationPayload(config) {
36
+ return {
37
+ max_tokens: config.maxTokens,
38
+ temperature: config.temperature,
39
+ top_p: config.topP,
40
+ top_k: config.topK,
41
+ reasoning_effort: config.thinking ? config.reasoningEffort : "none",
42
+ reasoning_budget_tokens: config.thinking ? config.thinkingBudget : 0,
43
+ min_p: 0,
44
+ presence_penalty: config.thinking ? 0 : 1.5,
45
+ repetition_penalty: 1,
46
+ chat_template_kwargs: { enable_thinking: config.thinking },
47
+ };
48
+ }
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
  }));