@hexdecimal16/nexo 0.4.5 → 0.4.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/cli/src/common.js CHANGED
@@ -9,8 +9,9 @@ export const USAGE = `Usage:
9
9
  nexo sessions [--limit <n>]
10
10
  nexo --version print the installed version
11
11
  nexo settings open the settings screen (needs a terminal)
12
+ nexo settings list every editable setting by group, with its value and source
12
13
  nexo settings get <key>
13
- nexo settings set <key> <value> keys: models.s1|s2|judge|reflector|embedding, budgets.*, tools.policy.*, tools.webSearch.count, tools.autoApprove, tools.nonInteractiveAsk, models.approver, scoring.judge, learning.*, memory.*, optimize.minCases|patience|minJudgeKappa|noveltySimilarity|offspringAlpha|reflectionTier|maxCaseDrop, loop.maxToolCalls|repeatLimit
14
+ nexo settings set <key> <value> keys as shown by nexo settings list; auto mode: tools.autoApprove, tools.nonInteractiveAsk, models.approver
14
15
  nexo settings reset <key> remove it from the user config
15
16
  nexo settings set-key <provider> reads the key from a hidden prompt, or from stdin when piped; playwright-<profile> stores a Chrome profile's browser token
16
17
  (brave or tavily turns on the web_search tool)
@@ -1,4 +1,4 @@
1
- import { createSettings, keyStatusLabel, nexoModels } from "../../core/src/index.js";
1
+ import { createSettings, keyStatusLabel, nexoModels, SETTING_GROUPS } from "../../core/src/index.js";
2
2
  import { ensureNexoDirs, resolveNexoPaths } from "../../store/src/index.js";
3
3
  import { NexoError, toErrorPayload } from "../../telemetry/src/index.js";
4
4
  import { EXIT_SIGINT, exitCodeFor, printError, usageError } from "./common.js";
@@ -90,7 +90,7 @@ export function readHiddenKey(stdin, stderr, provider, signal) {
90
90
  function show(view) {
91
91
  return view.value === null ? "unset" : String(view.value);
92
92
  }
93
- /** `nexo settings get|set|reset|set-key`: no TUI, for scripts. Invalid keys and values are usage errors (exit 2). */
93
+ /** `nexo settings list|get|set|reset|keys|set-key|remove-key`: no TUI, for scripts. Invalid keys and values are usage errors (exit 2). */
94
94
  export async function settingsCommand(args, io, options, stdio) {
95
95
  const [sub, ...rest] = args;
96
96
  const env = options.env ?? process.env;
@@ -131,6 +131,22 @@ export async function settingsCommand(args, io, options, stdio) {
131
131
  io.stderr.write(`note: ${view.notice}\n`);
132
132
  return 0;
133
133
  }
134
+ case "list": {
135
+ if (rest.length !== 0)
136
+ throw usageError("nexo settings list takes no arguments");
137
+ const views = build().settings();
138
+ for (const group of SETTING_GROUPS) {
139
+ const inGroup = views.filter((v) => v.group === group.id);
140
+ if (inGroup.length === 0)
141
+ continue;
142
+ io.stdout.write(`${group.label}\n`);
143
+ for (const view of inGroup) {
144
+ const source = view.source === "unset" ? "" : ` (${view.source})`;
145
+ io.stdout.write(` ${view.key} = ${show(view)}${source}\n`);
146
+ }
147
+ }
148
+ return 0;
149
+ }
134
150
  case "keys": {
135
151
  if (rest.length !== 0)
136
152
  throw usageError("nexo settings keys takes no arguments");
@@ -177,7 +193,7 @@ export async function settingsCommand(args, io, options, stdio) {
177
193
  return 0;
178
194
  }
179
195
  default:
180
- throw usageError(sub === undefined ? "nexo settings needs get, set, reset, keys, set-key or remove-key (or a terminal for the screen)" : `Unknown settings command "${sub}"`);
196
+ throw usageError(sub === undefined ? "nexo settings needs list, get, set, reset, keys, set-key or remove-key (or a terminal for the screen)" : `Unknown settings command "${sub}"`);
181
197
  }
182
198
  }
183
199
  catch (error) {
@@ -4,6 +4,36 @@ import { EFFORTS } from "../../../router/src/index.js";
4
4
  import { NexoError } from "../../../telemetry/src/index.js";
5
5
  import { configErrors, deepMerge, projectConfigPath, readConfigFile } from "../config/load.js";
6
6
  import { DEFAULT_CONFIG } from "../config/schema.js";
7
+ /** Setting groups in display order. */
8
+ export const SETTING_GROUPS = [
9
+ { id: "models", label: "Models" },
10
+ { id: "budgets", label: "Budgets" },
11
+ { id: "tools", label: "Tools & permissions" },
12
+ { id: "runs", label: "Runs & sessions" },
13
+ { id: "memory", label: "Memory & learning" },
14
+ { id: "scoring", label: "Scoring" },
15
+ { id: "optimize", label: "Optimization" },
16
+ ];
17
+ export function settingGroupLabel(id) {
18
+ return SETTING_GROUPS.find((g) => g.id === id)?.label ?? id;
19
+ }
20
+ function groupOf(key) {
21
+ if (key === "budgets.optimDefaultUsd" || key.startsWith("optimize."))
22
+ return "optimize";
23
+ if (key === "models.judge" || key.startsWith("scoring."))
24
+ return "scoring";
25
+ if (key.startsWith("models."))
26
+ return "models";
27
+ if (key.startsWith("budgets."))
28
+ return "budgets";
29
+ if (key.startsWith("tools."))
30
+ return "tools";
31
+ if (key.startsWith("memory.") || key.startsWith("learning."))
32
+ return "memory";
33
+ if (key.startsWith("session.") || key.startsWith("loop.") || key.startsWith("spawn."))
34
+ return "runs";
35
+ throw new Error(`No settings group for ${key}`);
36
+ }
7
37
  /** Values of `boolean` and `scorerToggle` settings as shown and picked. */
8
38
  export const ON_OFF = ["on", "off"];
9
39
  export const PROJECT_OVERRIDE_NOTICE = "overridden by project config";
@@ -19,8 +49,7 @@ const POLICY_DESCRIPTIONS = {
19
49
  load_skill: "load a skill's instructions",
20
50
  spawn: "start subagents",
21
51
  };
22
- /** Every setting the settings screen and `nexo settings` can edit, in display order. */
23
- export const EDITABLE_SETTINGS = [
52
+ const SETTING_LIST = [
24
53
  { key: "models.s1", label: "Model s1", description: "Default model for most work (provider/model-id)", type: { kind: "model" } },
25
54
  { key: "models.s2", label: "Model s2", description: "Stronger model the router escalates to (provider/model-id)", type: { kind: "model" } },
26
55
  { key: "models.s1.effort", label: "Effort s1", description: "Default reasoning effort for s1", type: { kind: "enum", values: EFFORTS } },
@@ -172,6 +201,11 @@ export const EDITABLE_SETTINGS = [
172
201
  type: { kind: "number", integer: false, min: 0, max: 10 },
173
202
  },
174
203
  ];
204
+ /** Every setting the settings screen and `nexo settings` can edit: group by group (SETTING_GROUPS), listed order within a group. */
205
+ export const EDITABLE_SETTINGS = (() => {
206
+ const grouped = SETTING_LIST.map((def) => ({ ...def, group: groupOf(def.key) }));
207
+ return SETTING_GROUPS.flatMap((g) => grouped.filter((def) => def.group === g.id));
208
+ })();
175
209
  function isPlainObject(value) {
176
210
  return typeof value === "object" && value !== null && !Array.isArray(value);
177
211
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexdecimal16/nexo",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "nexo agent engine",
5
5
  "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "repository": {
package/sdk/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { checkSetup, createNexo } from "./nexo.js";
2
+ export { SETTING_GROUPS, settingGroupLabel } from "../../core/src/index.js";
2
3
  export { parseSkillInvocation } from "../../skills/src/index.js";
3
4
  export { allowAllPrompter, nonInteractivePrompter } from "../../tools/src/index.js";
4
5
  export { createRuntime, openLogger } from "./runtime.js";
package/sdk/src/nexo.js CHANGED
@@ -110,6 +110,20 @@ export function createNexo(options = {}) {
110
110
  live();
111
111
  return runtime.settings.removeKey(provider);
112
112
  },
113
+ settings() {
114
+ return runtime.settings.settings();
115
+ },
116
+ getSetting(key) {
117
+ return runtime.settings.getSetting(key);
118
+ },
119
+ setSetting(key, value) {
120
+ live();
121
+ return runtime.settings.setSetting(key, value);
122
+ },
123
+ resetSetting(key) {
124
+ live();
125
+ return runtime.settings.resetSetting(key);
126
+ },
113
127
  async close() {
114
128
  if (closed)
115
129
  return;
@@ -1,5 +1,5 @@
1
1
  import { Input, truncateToWidth } from "@earendil-works/pi-tui";
2
- import { keyStatusLabel, ON_OFF } from "../../core/src/index.js";
2
+ import { keyStatusLabel, ON_OFF, SETTING_GROUPS } from "../../core/src/index.js";
3
3
  import { toErrorPayload } from "../../telemetry/src/index.js";
4
4
  import { isSearchProvider, SEARCH_PROVIDERS } from "../../tools/src/index.js";
5
5
  import { fitLines, MaskedInput } from "./components.js";
@@ -8,6 +8,8 @@ import { escapeControl, formatError } from "./text.js";
8
8
  import { style } from "./theme.js";
9
9
  const RESET = "\u0000reset";
10
10
  const BACK = "\u0000back";
11
+ /** Value prefix of a group heading row in the menu; picking one does nothing. */
12
+ const GROUP = "\u0000group:";
11
13
  /** A single-line text entry (plain or masked). */
12
14
  class EntryView {
13
15
  title;
@@ -105,7 +107,15 @@ export class SettingsScreen {
105
107
  description: escapeControl(keyStatusLabel(k)),
106
108
  })),
107
109
  { value: "browser:add", label: "Add browser profile", description: "store a Chrome profile token from the Playwright Extension for the browser skill" },
108
- ...views.map((v) => ({ value: `set:${v.key}`, label: escapeControl(v.label), description: settingDescription(v) })),
110
+ ...SETTING_GROUPS.flatMap((group) => {
111
+ const inGroup = views.filter((v) => v.group === group.id);
112
+ if (inGroup.length === 0)
113
+ return [];
114
+ return [
115
+ { value: `${GROUP}${group.id}`, label: style.bold(`── ${group.label}`), description: "" },
116
+ ...inGroup.map((v) => ({ value: `set:${v.key}`, label: escapeControl(v.label), description: settingDescription(v) })),
117
+ ];
118
+ }),
109
119
  ];
110
120
  return new PickerView({
111
121
  title: "Settings",
@@ -114,6 +124,8 @@ export class SettingsScreen {
114
124
  hint: "type to filter · ↑↓ move · enter edit · esc close",
115
125
  onPick: (value) => {
116
126
  this.status = null;
127
+ if (value.startsWith(GROUP))
128
+ return;
117
129
  if (value === "browser:add")
118
130
  this.show(this.browserProfileView(() => this.backToMenu(), () => this.backToMenu()));
119
131
  else if (value.startsWith("key:"))