somora 2026.930.1 → 2026.930.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/README.md CHANGED
@@ -24,8 +24,13 @@ curl -fsSL https://somora.ai/install.sh | bash
24
24
  Linux or macOS, as a normal user. Brings everything that is missing
25
25
  (Node.js included), registers the background service and walks you through
26
26
  models, your first agent, memory and HTTPS — details under
27
- [Quickstart](#quickstart). Already have Node ≥22.13?
28
- `npm install -g somora && somora setup`. Update later: `somora update`.
27
+ [Quickstart](#quickstart). Update later: `somora update`.
28
+
29
+ | | |
30
+ |---|---|
31
+ | **One line** (recommended) | `curl -fsSL https://somora.ai/install.sh \| bash` |
32
+ | **npm** — you already have Node ≥22.13 | `npm install -g somora && somora setup` |
33
+ | **From source** — you want to work on somora itself | [docs/setup.md → Develop from a checkout](docs/setup.md#develop-from-a-checkout-contributors) |
29
34
 
30
35
  ## See it
31
36
 
@@ -253,8 +258,8 @@ somora codex login # ChatGPT subscription; Codex is bundl
253
258
  # ~/.somora/config.yaml after step 4
254
259
 
255
260
  # 4. First-run setup + start
256
- somora init # creates ~/.somora/ and registers the systemd unit
257
- somora server start # starts the unit (and enables it at boot)
261
+ somora init # creates ~/.somora/ and registers the background service
262
+ somora server start # starts it (and from then on at boot / login)
258
263
  somora tui # the default agent is created on first run
259
264
  ```
260
265
 
@@ -49,7 +49,7 @@ providers:
49
49
  anthropic:
50
50
  engine: claude-cli
51
51
  models:
52
- - id: claude-opus-5
52
+ - id: claude-opus-5-5
53
53
  alias: opus
54
54
  contextWindow: 1000000
55
55
  capabilities: [text, image, pdf, reasoning]
package/docs/models.md CHANGED
@@ -46,7 +46,7 @@ providers:
46
46
  alias: fable
47
47
  contextWindow: 1000000
48
48
  capabilities: [text, image, pdf, reasoning]
49
- - id: claude-opus-5
49
+ - id: claude-opus-5-5
50
50
  alias: opus
51
51
  contextWindow: 1000000
52
52
  capabilities: [text, image, pdf, reasoning]
@@ -63,7 +63,7 @@ providers:
63
63
  | model | contextWindow | notes | verified |
64
64
  |---|---|---|---|
65
65
  | `claude-fable-5-1` | 1000000 | Frontier model, adaptive thinking always on. The SDK discloses **no thinking text** for it — somora shows a placeholder row that the model thought ([thinking.md](thinking.md#thinking-content--seeing-what-the-model-thought)). No separate reasoning-token count (rolled into `tokens_out`). | 2026-09-03 |
66
- | `claude-opus-5` | 1000000 | Anthropic's recommendation for most workloads. Thinking text: placeholder, as above. | 2026-09-03 |
66
+ | `claude-opus-5-5` | 1000000 | Opus 5.5 — Anthropic's recommendation for most workloads; replaces `claude-opus-5` (keep your alias, change the `id`). Thinking text: placeholder, as above. | 2026-09-30 |
67
67
  | `claude-sonnet-5` | 1000000 | Same surface as Opus, cheaper on the subscription budget. | 2026-09-03 |
68
68
  | `claude-haiku-4-5` | 200000 | Does support extended thinking — keep `reasoning` in `capabilities`, it is missing from most example configs. | 2026-09-03 |
69
69
 
package/docs/setup.md CHANGED
@@ -22,7 +22,7 @@ place:
22
22
  | Node.js | kept when ≥22.13; otherwise Node 24 system-wide (NodeSource / Homebrew) or, without admin rights, the official build into `~/.local/share/somora/node` (checksum-verified) | only for the system-wide variant |
23
23
  | npm folder | when npm's global folder is not writable for you, it moves to `~/.npm-global` and is added to your `PATH` | no |
24
24
  | somora | `npm install -g somora` | no |
25
- | Service | `somora init`, enabled at boot, lingering on so it survives logout | no (lingering may ask) |
25
+ | Service | Linux: systemd user unit, enabled at boot, lingering on so it survives logout. macOS: LaunchAgent, starts at every login | no (lingering may ask) |
26
26
  | Assistant | `somora setup` | no |
27
27
 
28
28
  Options go after `bash -s --`, or as environment variables:
@@ -164,7 +164,16 @@ somora server status
164
164
  journalctl --user -u somora -f # tail logs
165
165
  ```
166
166
 
167
- If you don't want systemd (e.g. on macOS, in a container, or while
167
+ **macOS** has no systemd; the same three commands work there through a
168
+ per-user LaunchAgent (`~/Library/LaunchAgents/ai.somora.server.plist`,
169
+ written by `somora init`). `somora server start` loads it, and from then
170
+ on macOS starts somora at every login and brings it back if it crashes;
171
+ `somora server stop` unloads it until the next login or `start`. Its
172
+ output goes to `~/.somora/logs/launchd.log`. A LaunchAgent never runs
173
+ before its user has logged in — on a Mac used as a server, turn on
174
+ automatic login (System Settings → Users & Groups).
175
+
176
+ If you don't want a background service (in a container, or while
168
177
  debugging):
169
178
 
170
179
  ```bash
@@ -272,7 +281,7 @@ providers:
272
281
  anthropic:
273
282
  engine: claude-cli
274
283
  models:
275
- - id: claude-opus-5
284
+ - id: claude-opus-5-5
276
285
  alias: opus
277
286
  contextWindow: 1000000
278
287
  capabilities: [text, image, pdf, reasoning]
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "somora",
3
- "version": "2026.930.1",
3
+ "version": "2026.930.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "somora",
9
- "version": "2026.930.1",
9
+ "version": "2026.930.4",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/claude-agent-sdk": "^0.3.152",
@@ -30,6 +30,7 @@
30
30
  "openai": "^6.39.0",
31
31
  "pdf-to-img": "^7.0.0",
32
32
  "pino": "^10.3.1",
33
+ "pino-pretty": "^13.1.3",
33
34
  "pino-roll": "^4.0.0",
34
35
  "playwright-core": "^1.63.0",
35
36
  "react": "^19.2.5",
@@ -54,7 +55,6 @@
54
55
  "@types/ssh2": "^1.15.5",
55
56
  "@types/turndown": "^5.0.6",
56
57
  "@types/ws": "^8.18.1",
57
- "pino-pretty": "^13.1.3",
58
58
  "typescript": "^6.0.3"
59
59
  },
60
60
  "engines": {
@@ -2516,7 +2516,6 @@
2516
2516
  "version": "2.0.20",
2517
2517
  "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz",
2518
2518
  "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==",
2519
- "dev": true,
2520
2519
  "license": "MIT"
2521
2520
  },
2522
2521
  "node_modules/content-disposition": {
@@ -2660,7 +2659,6 @@
2660
2659
  "version": "4.6.3",
2661
2660
  "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz",
2662
2661
  "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==",
2663
- "dev": true,
2664
2662
  "license": "MIT",
2665
2663
  "engines": {
2666
2664
  "node": "*"
@@ -3070,7 +3068,6 @@
3070
3068
  "version": "4.1.1",
3071
3069
  "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-4.1.1.tgz",
3072
3070
  "integrity": "sha512-A4QTJmuiztpGtr6AMeJts9R4hbj2ZBUwtOaKrG6rw2y7t6+IaJKjz5M3XDs8BUznxDH43FVc6A0y/gWlMl4UtA==",
3073
- "dev": true,
3074
3071
  "license": "MIT"
3075
3072
  },
3076
3073
  "node_modules/fast-deep-equal": {
@@ -3083,7 +3080,6 @@
3083
3080
  "version": "2.1.1",
3084
3081
  "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz",
3085
3082
  "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==",
3086
- "dev": true,
3087
3083
  "license": "MIT"
3088
3084
  },
3089
3085
  "node_modules/fast-sha256": {
@@ -3377,7 +3373,6 @@
3377
3373
  "version": "5.0.0",
3378
3374
  "resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz",
3379
3375
  "integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==",
3380
- "dev": true,
3381
3376
  "license": "MIT"
3382
3377
  },
3383
3378
  "node_modules/hono": {
@@ -3663,7 +3658,6 @@
3663
3658
  "version": "3.1.1",
3664
3659
  "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",
3665
3660
  "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==",
3666
- "dev": true,
3667
3661
  "license": "MIT",
3668
3662
  "engines": {
3669
3663
  "node": ">=10"
@@ -4234,7 +4228,6 @@
4234
4228
  "version": "13.1.3",
4235
4229
  "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-13.1.3.tgz",
4236
4230
  "integrity": "sha512-ttXRkkOz6WWC95KeY9+xxWL6AtImwbyMHrL1mSwqwW9u+vLp/WIElvHvCSDg0xO/Dzrggz1zv3rN5ovTRVowKg==",
4237
- "dev": true,
4238
4231
  "license": "MIT",
4239
4232
  "dependencies": {
4240
4233
  "colorette": "^2.0.7",
@@ -4658,7 +4651,6 @@
4658
4651
  "version": "4.1.0",
4659
4652
  "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-4.1.0.tgz",
4660
4653
  "integrity": "sha512-l4KnYfEyqYJxDwlNVyRfO2E4NTHfMKAWdUuA8J0yve2Dz/E/PdBepY03RvyJpssIpRFwJoCD55wA+mEDs6ByWA==",
4661
- "dev": true,
4662
4654
  "funding": [
4663
4655
  {
4664
4656
  "type": "github",
@@ -5197,7 +5189,6 @@
5197
5189
  "version": "5.0.3",
5198
5190
  "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz",
5199
5191
  "integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==",
5200
- "dev": true,
5201
5192
  "license": "MIT",
5202
5193
  "engines": {
5203
5194
  "node": ">=14.16"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "somora",
3
- "version": "2026.930.1",
3
+ "version": "2026.930.4",
4
4
  "description": "A self-hosted multi-agent harness: your agents, your models, one server — with memory, a shared wiki, a web desktop, a phone app and a terminal client.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -83,6 +83,7 @@
83
83
  "openai": "^6.39.0",
84
84
  "pdf-to-img": "^7.0.0",
85
85
  "pino": "^10.3.1",
86
+ "pino-pretty": "^13.1.3",
86
87
  "pino-roll": "^4.0.0",
87
88
  "playwright-core": "^1.63.0",
88
89
  "react": "^19.2.5",
@@ -104,7 +105,6 @@
104
105
  "@types/ssh2": "^1.15.5",
105
106
  "@types/turndown": "^5.0.6",
106
107
  "@types/ws": "^8.18.1",
107
- "pino-pretty": "^13.1.3",
108
108
  "typescript": "^6.0.3"
109
109
  },
110
110
  "overrides": {
@@ -0,0 +1,172 @@
1
+ // macOS background service: a per-user LaunchAgent, the counterpart of
2
+ // the systemd user unit on Linux.
3
+ //
4
+ // init writes ~/Library/LaunchAgents/ai.somora.server.plist
5
+ // start launchctl bootstrap (loads it; RunAtLoad starts the server)
6
+ // stop launchctl bootout
7
+ // restart bootout + bootstrap (also picks up a rewritten plist)
8
+ //
9
+ // Once the plist is in LaunchAgents, macOS loads it at every login of
10
+ // that user — that is the autostart. A LaunchAgent never runs before
11
+ // the user has logged in; a Mac used as a server needs automatic login.
12
+
13
+ import { spawnSync } from 'node:child_process';
14
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
15
+ import { homedir, userInfo } from 'node:os';
16
+ import { delimiter, dirname, join } from 'node:path';
17
+
18
+ export const LAUNCHD_LABEL = 'ai.somora.server';
19
+
20
+ export function launchdPlistPath(home: string = homedir()): string {
21
+ return join(home, 'Library', 'LaunchAgents', `${LAUNCHD_LABEL}.plist`);
22
+ }
23
+
24
+ function xml(s: string): string {
25
+ return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
26
+ }
27
+
28
+ export interface PlistOpts {
29
+ binPath: string;
30
+ /** Directories for the service's PATH, most specific first. */
31
+ pathDirs: string[];
32
+ home: string;
33
+ logPath: string;
34
+ }
35
+
36
+ export function buildLaunchdPlist(o: PlistOpts): string {
37
+ const str = (s: string): string => `<string>${xml(s)}</string>`;
38
+ return `<?xml version="1.0" encoding="UTF-8"?>
39
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
40
+ <plist version="1.0">
41
+ <dict>
42
+ <key>Label</key>
43
+ ${str(LAUNCHD_LABEL)}
44
+ <key>ProgramArguments</key>
45
+ <array>
46
+ ${str(o.binPath)}
47
+ <string>server</string>
48
+ <string>start</string>
49
+ <string>--foreground</string>
50
+ </array>
51
+ <key>EnvironmentVariables</key>
52
+ <dict>
53
+ <key>NODE_ENV</key>
54
+ <string>production</string>
55
+ <key>PATH</key>
56
+ ${str(o.pathDirs.join(':'))}
57
+ <key>HOME</key>
58
+ ${str(o.home)}
59
+ </dict>
60
+ <key>WorkingDirectory</key>
61
+ ${str(o.home)}
62
+ <key>RunAtLoad</key>
63
+ <true/>
64
+ <key>KeepAlive</key>
65
+ <dict>
66
+ <key>SuccessfulExit</key>
67
+ <false/>
68
+ </dict>
69
+ <key>ThrottleInterval</key>
70
+ <integer>5</integer>
71
+ <key>StandardOutPath</key>
72
+ ${str(o.logPath)}
73
+ <key>StandardErrorPath</key>
74
+ ${str(o.logPath)}
75
+ </dict>
76
+ </plist>
77
+ `;
78
+ }
79
+
80
+ /** The directory `node` is found in on this PATH — the stable one
81
+ * (`/opt/homebrew/bin`), not the versioned folder process.execPath
82
+ * resolves to, which a `brew upgrade` deletes. */
83
+ export function nodeDirOnPath(envPath: string = process.env.PATH ?? '', exists: (p: string) => boolean = existsSync): string {
84
+ for (const dir of envPath.split(delimiter)) {
85
+ if (dir && exists(join(dir, 'node'))) return dir;
86
+ }
87
+ return dirname(process.execPath);
88
+ }
89
+
90
+ const MAC_SYSTEM_DIRS = ['/opt/homebrew/bin', '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'];
91
+
92
+ export function launchdPathDirs(nodeDir: string, npmBinDir: string | null, home: string): string[] {
93
+ return [nodeDir, ...(npmBinDir ? [npmBinDir] : []), `${home}/.local/bin`, ...MAC_SYSTEM_DIRS].filter((d, i, a) => a.indexOf(d) === i);
94
+ }
95
+
96
+ /** Write the plist when it differs. Returns what happened. */
97
+ export function writeLaunchdPlist(binPath: string, npmBinDir: string | null, somoraHome: string): 'created' | 'updated' | 'kept' {
98
+ const home = homedir();
99
+ const path = launchdPlistPath(home);
100
+ const text = buildLaunchdPlist({
101
+ binPath,
102
+ pathDirs: launchdPathDirs(nodeDirOnPath(), npmBinDir, home),
103
+ home,
104
+ logPath: join(somoraHome, 'logs', 'launchd.log'),
105
+ });
106
+ mkdirSync(dirname(path), { recursive: true });
107
+ mkdirSync(join(somoraHome, 'logs'), { recursive: true });
108
+ const before = existsSync(path) ? readFileSync(path, 'utf8') : null;
109
+ if (before === text) return 'kept';
110
+ writeFileSync(path, text);
111
+ return before === null ? 'created' : 'updated';
112
+ }
113
+
114
+ function launchctl(args: string[]): { code: number; out: string } {
115
+ const r = spawnSync('launchctl', args, { encoding: 'utf8' });
116
+ return { code: r.error ? 127 : (r.status ?? 1), out: `${r.stdout ?? ''}${r.stderr ?? ''}`.trim() };
117
+ }
118
+
119
+ /** `gui/<uid>` when the user has a desktop session (the normal case),
120
+ * else the plain per-user domain (ssh-only login). */
121
+ export function launchdDomain(): string {
122
+ const uid = userInfo().uid;
123
+ return launchctl(['print', `gui/${uid}`]).code === 0 ? `gui/${uid}` : `user/${uid}`;
124
+ }
125
+
126
+ export function launchdAvailable(): boolean {
127
+ return process.platform === 'darwin';
128
+ }
129
+
130
+ export function launchdLoaded(): boolean {
131
+ return launchctl(['print', `${launchdDomain()}/${LAUNCHD_LABEL}`]).code === 0;
132
+ }
133
+
134
+ export function launchdPid(): number | null {
135
+ const r = launchctl(['print', `${launchdDomain()}/${LAUNCHD_LABEL}`]);
136
+ const m = r.code === 0 ? r.out.match(/^\s*pid = (\d+)/m) : null;
137
+ return m ? Number(m[1]) : null;
138
+ }
139
+
140
+ function sleepMs(ms: number): void {
141
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
142
+ }
143
+
144
+ export function launchdStop(): { ok: boolean; detail: string } {
145
+ if (!launchdLoaded()) return { ok: true, detail: 'not loaded' };
146
+ const r = launchctl(['bootout', `${launchdDomain()}/${LAUNCHD_LABEL}`]);
147
+ // bootout returns before the job is gone; wait so a following
148
+ // bootstrap does not hit "operation already in progress".
149
+ for (let i = 0; i < 40 && launchdLoaded(); i++) sleepMs(250);
150
+ return { ok: !launchdLoaded(), detail: r.out };
151
+ }
152
+
153
+ export function launchdStart(): { ok: boolean; detail: string } {
154
+ if (launchdLoaded()) {
155
+ // Loaded but maybe not running (crashed, throttled): kick it.
156
+ const k = launchctl(['kickstart', `${launchdDomain()}/${LAUNCHD_LABEL}`]);
157
+ return { ok: k.code === 0, detail: k.out };
158
+ }
159
+ let r = { code: 1, out: '' };
160
+ for (let i = 0; i < 8; i++) {
161
+ r = launchctl(['bootstrap', launchdDomain(), launchdPlistPath()]);
162
+ if (r.code === 0) return { ok: true, detail: '' };
163
+ sleepMs(500);
164
+ }
165
+ return { ok: false, detail: r.out };
166
+ }
167
+
168
+ export function launchdRestart(): { ok: boolean; detail: string } {
169
+ const s = launchdStop();
170
+ if (!s.ok) return s;
171
+ return launchdStart();
172
+ }
package/src/cli/setup.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  // src/setup/config-edit.ts: comments survive, the old file is kept as a
12
12
  // backup, and a result the server would refuse is never written.
13
13
 
14
- import { chmodSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
14
+ import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
15
15
  import { homedir, networkInterfaces, userInfo } from 'node:os';
16
16
  import { request as httpRequest } from 'node:http';
17
17
  import { request as httpsRequest } from 'node:https';
@@ -29,6 +29,7 @@ import {
29
29
  } from '../setup/prompt.ts';
30
30
  import { isOperatorError, tailscaleState } from '../setup/tailscale.ts';
31
31
  import { SOMORA_VERSION } from '../version.ts';
32
+ import { launchdPlistPath } from './launchd.ts';
32
33
 
33
34
  const HOME = homedir();
34
35
  const SOMORA_HOME = process.env.SOMORA_HOME ?? join(HOME, '.somora');
@@ -161,11 +162,37 @@ async function health(config: YamlFile): Promise<Record<string, unknown> | null>
161
162
  }
162
163
 
163
164
  function serviceAvailable(): boolean {
165
+ if (process.platform === 'darwin') return existsSync(launchdPlistPath());
164
166
  return existsSync(UNIT_PATH) && capture('systemctl', ['--user', 'show-environment']).code === 0;
165
167
  }
166
168
 
169
+ const LOG_HINT = process.platform === 'darwin'
170
+ ? `tail -n 50 ${join(SOMORA_HOME, 'logs', 'launchd.log')}`
171
+ : 'journalctl --user -u somora -n 50';
172
+
167
173
  // ─── step: models ─────────────────────────────────────────────────────
168
174
 
175
+ /** Put `dir` on the PATH of future shells: one marked line in the
176
+ * profile files that exist (plus ~/.profile, which login shells read).
177
+ * Returns the files it changed — none when the directory is already on
178
+ * PATH or already mentioned in every file. */
179
+ export function addToShellPath(dir: string, home: string = HOME, envPath: string = process.env.PATH ?? '', shell: string = process.env.SHELL ?? ''): string[] {
180
+ if (envPath.split(':').includes(dir)) return [];
181
+ const shown = dir.startsWith(`${home}/`) ? `$HOME/${dir.slice(home.length + 1)}` : dir;
182
+ const line = `export PATH="${shown}:$PATH" # added by somora setup`;
183
+ const files = [join(home, '.profile')];
184
+ for (const f of ['.bashrc', '.bash_profile', '.zprofile']) if (existsSync(join(home, f))) files.push(join(home, f));
185
+ if (existsSync(join(home, '.zshrc')) || shell.endsWith('zsh')) files.push(join(home, '.zshrc'));
186
+ const changed: string[] = [];
187
+ for (const f of files) {
188
+ const text = existsSync(f) ? readFileSync(f, 'utf8') : '';
189
+ if (text.includes(shown) || text.includes(dir)) continue;
190
+ appendFileSync(f, `${text === '' || text.endsWith('\n') ? '' : '\n'}\n${line}\n`);
191
+ changed.push(f);
192
+ }
193
+ return changed;
194
+ }
195
+
169
196
  function claudeBinary(): string | null {
170
197
  const local = join(HOME, '.local', 'bin', 'claude');
171
198
  if (existsSync(local)) return local;
@@ -207,6 +234,11 @@ async function setupClaude(ctx: Ctx, config: YamlFile): Promise<void> {
207
234
  return;
208
235
  }
209
236
  ok(`Claude Code installed at ${tildify(bin)}`);
237
+ // Its installer only prints a hint when ~/.local/bin is not on PATH.
238
+ // somora calls the binary by its full path, but the person will want
239
+ // to type `claude` too.
240
+ const added = addToShellPath(join(HOME, '.local', 'bin'));
241
+ if (added.length) ok(`added ~/.local/bin to your PATH ${dim(`(${added.map(tildify).join(', ')} — active in a new terminal)`)}`);
210
242
  }
211
243
  if (claudeLoggedIn()) {
212
244
  ok('Claude login found');
@@ -754,7 +786,7 @@ async function stepStart(ctx: Ctx): Promise<void> {
754
786
  }
755
787
  }
756
788
  if (!up) {
757
- fail('somora does not answer. Look at the log: journalctl --user -u somora -n 50');
789
+ fail(`somora does not answer. Look at the log: ${LOG_HINT}`);
758
790
  return;
759
791
  }
760
792
  ok(`somora ${SOMORA_VERSION} is running`);
@@ -780,7 +812,7 @@ async function stepStart(ctx: Ctx): Promise<void> {
780
812
  }
781
813
  } else {
782
814
  fail(`${agent} did not answer: ${j.error ?? j.outcome_reason ?? j.outcome ?? `HTTP ${r.status}`}`);
783
- explain('Usually the login of the model provider: run `somora setup models`, or see the log with journalctl --user -u somora -n 50');
815
+ explain(`Usually the login of the model provider: run \`somora setup models\`, or see the log with ${LOG_HINT}`);
784
816
  }
785
817
  } catch (err) {
786
818
  fail(`test message failed: ${(err as Error).message}`);
package/src/cli/somora.ts CHANGED
@@ -23,10 +23,24 @@ import { fileURLToPath } from 'node:url';
23
23
 
24
24
  import { SOMORA_VERSION } from '../version.ts';
25
25
  import { buildSystemdUnit, extractCustomEnvLines, nodePathLine } from './systemd-unit.ts';
26
- import { compareVersions, parseUpdateArgs } from './update-args.ts';
26
+ import { allowScriptsArgs, compareVersions, parseUpdateArgs } from './update-args.ts';
27
+ import {
28
+ LAUNCHD_LABEL, launchdAvailable, launchdLoaded, launchdPid, launchdPlistPath, launchdRestart, launchdStart,
29
+ launchdStop, nodeDirOnPath, writeLaunchdPlist,
30
+ } from './launchd.ts';
27
31
  // Plain-ESM helper shared with bin/somora.mjs (must run on the Node we reject).
28
32
  import { nodeUpgradeHint, satisfiesNode } from '../../bin/node-version.mjs';
29
33
 
34
+ // CLI commands talk to the person on this terminal; the logger's pretty
35
+ // stdout lines belong to the foreground server only (it gets the
36
+ // variable removed again, see serverChildEnv).
37
+ process.env.SOMORA_LOG_TTY = '0';
38
+ function serverChildEnv(): NodeJS.ProcessEnv {
39
+ const env = { ...process.env };
40
+ delete env.SOMORA_LOG_TTY;
41
+ return env;
42
+ }
43
+
30
44
  const SOMORA_HOME = process.env.SOMORA_HOME ?? join(homedir(), '.somora');
31
45
  const LOCKFILE_PATH = join(SOMORA_HOME, 'locks', 'server.lock');
32
46
  const SYSTEMD_USER_DIR = join(homedir(), '.config', 'systemd', 'user');
@@ -47,10 +61,11 @@ function usage(): string {
47
61
  Usage:
48
62
  somora setup [step] the guided assistant: models, first agent, memory,
49
63
  team, HTTPS — safe to run again (\`somora setup --help\`)
50
- somora init data dir + systemd unit (idempotent)
51
- somora server start [--foreground] start the server (via systemd, or direct)
64
+ somora init data dir + background service: systemd unit on Linux,
65
+ LaunchAgent on macOS (idempotent)
66
+ somora server start [--foreground] start the server (as a service, or direct)
52
67
  somora server stop stop the running server
53
- somora server restart restart via systemd
68
+ somora server restart restart the service
54
69
  somora server status show server status + lockfile info
55
70
  somora tui launch the TUI against the running server
56
71
  somora skill <subcommand> list/check/add/update/remove skills
@@ -131,6 +146,8 @@ function cmdInit(): number {
131
146
  kept.push(locksDir);
132
147
  }
133
148
 
149
+ if (launchdAvailable()) return cmdInitLaunchd(created, kept);
150
+
134
151
  ensureDir(SYSTEMD_USER_DIR);
135
152
  // Preserve operator-added Environment= / EnvironmentFile= lines across
136
153
  // the rebake — otherwise a `somora update` silently drops e.g.
@@ -140,8 +157,8 @@ function cmdInit(): number {
140
157
  ? readFileSync(SYSTEMD_UNIT_PATH, 'utf8')
141
158
  : null;
142
159
  const preservedEnv = existingUnit ? extractCustomEnvLines(existingUnit) : [];
143
- const npmBinDir = looksLikeGlobalNpmInstall(BIN_PATH) ? resolve(dirname(BIN_PATH), '..', '..', '..', '..', 'bin') : null;
144
- const unitContent = buildSystemdUnit(BIN_PATH, preservedEnv, nodePathLine(dirname(process.execPath), homedir(), npmBinDir));
160
+ const npmBinDir = npmBinDirOf(BIN_PATH);
161
+ const unitContent = buildSystemdUnit(BIN_PATH, preservedEnv, nodePathLine(nodeDirOnPath(), homedir(), npmBinDir));
145
162
  let unitChanged = false;
146
163
  if (existingUnit === null) {
147
164
  writeFileSync(SYSTEMD_UNIT_PATH, unitContent);
@@ -201,6 +218,32 @@ function cmdInit(): number {
201
218
  return 0;
202
219
  }
203
220
 
221
+ function npmBinDirOf(binPath: string): string | null {
222
+ return looksLikeGlobalNpmInstall(binPath) ? resolve(dirname(binPath), '..', '..', '..', '..', 'bin') : null;
223
+ }
224
+
225
+ /** macOS: the LaunchAgent instead of the systemd unit. */
226
+ function cmdInitLaunchd(created: string[], kept: string[]): number {
227
+ const plist = launchdPlistPath();
228
+ const what = writeLaunchdPlist(BIN_PATH, npmBinDirOf(BIN_PATH), SOMORA_HOME);
229
+ if (what === 'created') created.push(plist);
230
+ else kept.push(what === 'updated' ? `${plist} (updated)` : plist);
231
+ process.stdout.write(`somora init: data dir ${SOMORA_HOME}\n`);
232
+ if (created.length) {
233
+ process.stdout.write(' created:\n');
234
+ for (const c of created) process.stdout.write(` ${c}\n`);
235
+ }
236
+ if (kept.length) {
237
+ process.stdout.write(' kept:\n');
238
+ for (const k of kept) process.stdout.write(` ${k}\n`);
239
+ }
240
+ if (what === 'updated' && launchdLoaded()) {
241
+ process.stdout.write(' the service definition changed — `somora server restart` applies it\n');
242
+ }
243
+ process.stdout.write('\nNext: `somora server start` to launch the server (it then starts at every login).\n');
244
+ return 0;
245
+ }
246
+
204
247
  /** Heuristic: does this absolute path look like it came from an npm
205
248
  * global install (or an `npm link` setup that targets one)? The
206
249
  * canonical marker is `/lib/node_modules/somora/` somewhere in the
@@ -216,12 +259,17 @@ function spawnServerForeground(): Promise<number> {
216
259
  const tsxBin = resolve(PKG_ROOT, 'node_modules', '.bin', 'tsx');
217
260
  const tsconfigPath = resolve(PKG_ROOT, 'tsconfig.json');
218
261
  const serverEntry = resolve(PKG_ROOT, 'src', 'server', 'index.ts');
219
- const child = spawn(tsxBin, ['--tsconfig', tsconfigPath, serverEntry], { stdio: 'inherit' });
220
- const fwd = (sig: NodeJS.Signals) => () => child.kill(sig);
262
+ const child = spawn(tsxBin, ['--tsconfig', tsconfigPath, serverEntry], { stdio: 'inherit', env: serverChildEnv() });
263
+ let stopping = false;
264
+ const fwd = (sig: NodeJS.Signals) => () => { stopping = true; child.kill(sig); };
221
265
  process.on('SIGTERM', fwd('SIGTERM'));
222
266
  process.on('SIGINT', fwd('SIGINT'));
223
267
  return new Promise<number>((res) => {
224
- child.on('exit', (code) => res(code ?? 0));
268
+ // A server that was killed (OOM, kill -9) has no exit code. Unless we
269
+ // asked it to stop, that is a failure — reporting 0 would tell
270
+ // systemd (Restart=on-failure) and launchd (KeepAlive) not to bring
271
+ // it back.
272
+ child.on('exit', (code) => res(code ?? (stopping ? 0 : 1)));
225
273
  });
226
274
  }
227
275
 
@@ -232,6 +280,19 @@ async function cmdServerStart(args: string[]): Promise<number> {
232
280
  return await spawnServerForeground();
233
281
  }
234
282
 
283
+ if (launchdAvailable()) {
284
+ if (!existsSync(launchdPlistPath())) {
285
+ process.stderr.write('service not installed. Run: somora init\n');
286
+ return 1;
287
+ }
288
+ const r = launchdStart();
289
+ if (!r.ok) {
290
+ process.stderr.write(`launchctl could not start the service: ${r.detail}\nTry: somora server start --foreground\n`);
291
+ return 1;
292
+ }
293
+ process.stdout.write(`somora server started (launchd: ${LAUNCHD_LABEL}; starts at every login).\n`);
294
+ return 0;
295
+ }
235
296
  if (!isSystemdAvailable()) {
236
297
  process.stderr.write('systemctl --user not available. Try: somora server start --foreground\n');
237
298
  return 1;
@@ -249,6 +310,13 @@ async function cmdServerStart(args: string[]): Promise<number> {
249
310
  }
250
311
 
251
312
  function cmdServerStop(): number {
313
+ if (launchdAvailable() && launchdLoaded()) {
314
+ const r = launchdStop();
315
+ if (r.ok) {
316
+ process.stdout.write('somora server stopped (it starts again at the next login; `somora server start` sooner).\n');
317
+ return 0;
318
+ }
319
+ }
252
320
  if (isSystemdAvailable() && existsSync(SYSTEMD_UNIT_PATH)) {
253
321
  const r = run('systemctl', ['--user', 'stop', SYSTEMD_UNIT_NAME], { stdio: 'inherit' });
254
322
  if (r.code === 0) {
@@ -273,6 +341,19 @@ function cmdServerStop(): number {
273
341
  }
274
342
 
275
343
  function cmdServerRestart(): number {
344
+ if (launchdAvailable()) {
345
+ if (!existsSync(launchdPlistPath())) {
346
+ process.stderr.write('restart needs the service. Run: somora init\n');
347
+ return 1;
348
+ }
349
+ const r = launchdRestart();
350
+ if (!r.ok) {
351
+ process.stderr.write(`launchctl could not restart the service: ${r.detail}\n`);
352
+ return 1;
353
+ }
354
+ process.stdout.write('somora server restarted.\n');
355
+ return 0;
356
+ }
276
357
  if (!isSystemdAvailable() || !existsSync(SYSTEMD_UNIT_PATH)) {
277
358
  process.stderr.write('restart needs systemd unit. Run: somora init\n');
278
359
  return 1;
@@ -296,7 +377,11 @@ function cmdServerStatus(): number {
296
377
  } else {
297
378
  process.stdout.write(`lockfile: ${LOCKFILE_PATH} (none — no server running)\n`);
298
379
  }
299
- if (isSystemdAvailable() && existsSync(SYSTEMD_UNIT_PATH)) {
380
+ if (launchdAvailable()) {
381
+ const installed = existsSync(launchdPlistPath());
382
+ const pid = installed ? launchdPid() : null;
383
+ process.stdout.write(`\nservice (launchd ${LAUNCHD_LABEL}): ${!installed ? 'not installed — run `somora init`' : launchdLoaded() ? `loaded${pid ? `, running as pid ${pid}` : ', not running'}` : 'installed, not loaded — `somora server start`'}\n`);
384
+ } else if (isSystemdAvailable() && existsSync(SYSTEMD_UNIT_PATH)) {
300
385
  process.stdout.write('\n');
301
386
  run('systemctl', ['--user', 'status', SYSTEMD_UNIT_NAME, '--no-pager'], { stdio: 'inherit' });
302
387
  }
@@ -445,7 +530,8 @@ async function cmdUpdate(args: string[]): Promise<number> {
445
530
  // tested with; no in-place re-resolve needed afterwards.
446
531
  const spec = `${SOMORA_NPM_NAME}@${target.version}`;
447
532
  process.stdout.write(` npm install -g ${spec}\n`);
448
- const ri = spawnSync('npm', ['install', '-g', '--no-audit', '--no-fund', spec], { encoding: 'utf8', stdio: ['inherit', 'inherit', 'pipe'] });
533
+ const allow = allowScriptsArgs(run('npm', ['config', 'get', 'allow-scripts']).stdout);
534
+ const ri = spawnSync('npm', ['install', '-g', '--no-audit', '--no-fund', ...allow, spec], { encoding: 'utf8', stdio: ['inherit', 'inherit', 'pipe'] });
449
535
  if (ri.stderr) process.stderr.write(ri.stderr);
450
536
  if (ri.status !== 0) {
451
537
  if (/EACCES/.test(ri.stderr ?? '')) {
@@ -476,6 +562,14 @@ async function cmdUpdate(args: string[]): Promise<number> {
476
562
  }
477
563
  }
478
564
 
565
+ if (launchdAvailable() && existsSync(launchdPlistPath())) {
566
+ if (!launchdLoaded()) {
567
+ process.stdout.write('\ndone. The service is not running — start it with `somora server start`.\n');
568
+ return 0;
569
+ }
570
+ process.stdout.write('\nrestarting the service…\n');
571
+ return cmdServerRestart();
572
+ }
479
573
  if (isSystemdAvailable() && existsSync(SYSTEMD_UNIT_PATH)) {
480
574
  process.stdout.write('\nrestarting systemd service…\n');
481
575
  return cmdServerRestart();
@@ -53,3 +53,17 @@ export function compareVersions(a: string, b: string): number {
53
53
  if (bpre === undefined) return -1;
54
54
  return apre < bpre ? -1 : 1;
55
55
  }
56
+
57
+ /** Dependencies that build or fetch a binary at install time. npm from
58
+ * 11.16 on wants them named on a global install (`--allow-scripts`);
59
+ * today it only warns, a stricter default would leave node-pty and
60
+ * better-sqlite3 unbuilt. update-args.test.mts holds this list against
61
+ * npm-shrinkwrap.json and install.sh. */
62
+ export const ALLOW_SCRIPTS = ['better-sqlite3', 'cpu-features', 'esbuild', 'fsevents', 'node-pty', 'onnxruntime-node', 'protobufjs', 'ssh2'];
63
+
64
+ /** Extra arguments for `npm install -g`, given what `npm config get
65
+ * allow-scripts` printed: an npm that does not know the setting says
66
+ * "undefined" and must not get the flag. */
67
+ export function allowScriptsArgs(configGetOutput: string): string[] {
68
+ return configGetOutput.trim() === 'undefined' ? [] : [`--allow-scripts=${ALLOW_SCRIPTS.join(',')}`];
69
+ }
@@ -33,7 +33,7 @@ providers:
33
33
  anthropic:
34
34
  engine: claude-cli
35
35
  models:
36
- - id: claude-opus-5
36
+ - id: claude-opus-5-5
37
37
  alias: opus
38
38
  contextWindow: 1000000
39
39
  capabilities: [text, image, pdf, reasoning]
@@ -1,5 +1,6 @@
1
1
  import { mkdirSync, mkdtempSync } from 'node:fs';
2
2
  import { homedir, tmpdir } from 'node:os';
3
+ import { createRequire } from 'node:module';
3
4
  import { join } from 'node:path';
4
5
  import pino, { type Logger } from 'pino';
5
6
 
@@ -18,7 +19,20 @@ const LOG_DIR = join(SOMORA_HOME, 'logs');
18
19
  mkdirSync(LOG_DIR, { recursive: true });
19
20
 
20
21
  const level = process.env.SOMORA_LOG_LEVEL ?? 'info';
21
- const isTty = Boolean(process.stdout.isTTY);
22
+ // Pretty lines on the terminal are for someone watching the SERVER in
23
+ // the foreground. The interactive CLI commands (setup, wiki migrate, …)
24
+ // own the terminal themselves and switch this off (SOMORA_LOG_TTY=0);
25
+ // and an install where pino-pretty is missing must never fail to start
26
+ // over it — the file log is the record either way.
27
+ function prettyAvailable(): boolean {
28
+ try {
29
+ createRequire(import.meta.url).resolve('pino-pretty');
30
+ return true;
31
+ } catch {
32
+ return false;
33
+ }
34
+ }
35
+ const isTty = Boolean(process.stdout.isTTY) && process.env.SOMORA_LOG_TTY !== '0' && prettyAvailable();
22
36
 
23
37
  // File target uses `pino-roll` so events after midnight land in the
24
38
  // new day's file even when the server has been running for days.
@@ -27,7 +27,7 @@ export const CLAUDE_PRESET: ProviderPreset = {
27
27
  engine: 'claude-cli',
28
28
  models: [
29
29
  { id: 'claude-fable-5-1', alias: 'fable', contextWindow: 1000000, capabilities: FULL, note: 'frontier model' },
30
- { id: 'claude-opus-5', alias: 'opus', contextWindow: 1000000, capabilities: FULL, note: 'recommended for most work' },
30
+ { id: 'claude-opus-5-5', alias: 'opus', contextWindow: 1000000, capabilities: FULL, note: 'recommended for most work' },
31
31
  { id: 'claude-sonnet-5', alias: 'sonnet', contextWindow: 1000000, capabilities: FULL, note: 'lighter on the subscription budget' },
32
32
  { id: 'claude-haiku-4-5', alias: 'haiku', contextWindow: 200000, capabilities: FULL, note: 'fast and cheap — good for background work' },
33
33
  ],
@@ -82,6 +82,14 @@ export class Prompter {
82
82
  rl.close();
83
83
  resolve(a);
84
84
  });
85
+ // Ctrl-C stops the assistant. Without this listener readline just
86
+ // closes, which would read as "take the default" and carry on.
87
+ rl.on('SIGINT', () => {
88
+ answered = true;
89
+ rl.close();
90
+ process.stdout.write('\n\n stopped — nothing further was changed. Run `somora setup` again to continue.\n');
91
+ process.exit(130);
92
+ });
85
93
  // Ctrl-D: take the default instead of hanging.
86
94
  rl.on('close', () => { if (!answered) resolve(''); });
87
95
  });