somora 2026.1004.4 → 2026.1007.2
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 +27 -23
- package/config.example.yaml +27 -0
- package/docs/api.md +57 -9
- package/docs/cache-strategy.md +24 -5
- package/docs/compaction.md +45 -0
- package/docs/display.md +14 -6
- package/docs/files.md +54 -12
- package/docs/imagegen.md +10 -1
- package/docs/memory.md +28 -0
- package/docs/mobile.md +29 -1
- package/docs/models.md +44 -4
- package/docs/resources.md +22 -0
- package/docs/setup.md +35 -3
- package/docs/thinking.md +37 -9
- package/docs/web.md +14 -5
- package/package.json +2 -1
- package/src/attachments/store.ts +19 -1
- package/src/browser/session.ts +2 -2
- package/src/cli/auth.ts +22 -0
- package/src/cli/claude-bin.ts +48 -0
- package/src/cli/config.ts +47 -0
- package/src/cli/setup.ts +11 -7
- package/src/cli/somora.ts +6 -1
- package/src/cli/tui/api.ts +44 -2
- package/src/cli/tui/app.tsx +62 -8
- package/src/cli/tui/commands.ts +109 -12
- package/src/cli/tui/header.tsx +20 -0
- package/src/cli/tui/stream.ts +2 -0
- package/src/cli/tui/types.ts +10 -1
- package/src/compaction/summarize.ts +4 -0
- package/src/compaction/template.ts +15 -0
- package/src/compaction/types.ts +3 -0
- package/src/config/loader.ts +75 -10
- package/src/config/types.ts +40 -7
- package/src/engine/a2a.ts +1 -1
- package/src/engine/claude-cli.ts +136 -4
- package/src/engine/codex-cli.ts +74 -0
- package/src/engine/engine-meta-labels.ts +2 -0
- package/src/engine/openai-compatible.ts +142 -29
- package/src/engine/types.ts +7 -0
- package/src/imagegen/generate.ts +30 -5
- package/src/imagegen/types.ts +6 -0
- package/src/media/capabilities.ts +8 -0
- package/src/memory/inject.ts +66 -7
- package/src/multimodal/blocks.ts +14 -0
- package/src/multimodal/load.ts +21 -2
- package/src/multimodal/model-image.ts +127 -0
- package/src/server/index.ts +118 -39
- package/src/server/run-turn.ts +65 -16
- package/src/server/session-compact.ts +138 -0
- package/src/server/thinking-resolve.ts +30 -0
- package/src/ssh/exec.ts +55 -22
- package/src/storage/sessions.ts +40 -15
- package/src/tools/exec/tools.ts +3 -0
- package/src/tools/file/analyze.ts +46 -7
- package/src/tools/file/remote.ts +31 -10
- package/src/tools/file/tools.ts +86 -19
- package/src/tools/image/tools.ts +6 -0
- package/src/tools/registry.ts +14 -0
- package/src/types/events.ts +23 -2
- package/web/dist/assets/{index-Cl1xtY5g.js → index-40x__Izy.js} +96 -96
- package/web/dist/assets/index-40x__Izy.js.map +1 -0
- package/web/dist/assets/index-CZFgQRsq.css +32 -0
- package/web/dist/index.html +2 -2
- package/web-mobile/dist/assets/index-CxILeHfe.js +88 -0
- package/web-mobile/dist/assets/{index-BpsX8_mX.js.map → index-CxILeHfe.js.map} +1 -1
- package/web-mobile/dist/assets/{index-DZXivrMo.css → index-Cyr13VGR.css} +1 -1
- package/web-mobile/dist/index.html +2 -2
- package/web/dist/assets/index-Cl1xtY5g.js.map +0 -1
- package/web/dist/assets/index-D0q6NZer.css +0 -32
- package/web-mobile/dist/assets/index-BpsX8_mX.js +0 -88
package/docs/memory.md
CHANGED
|
@@ -108,6 +108,31 @@ rather than answering from these notes.
|
|
|
108
108
|
Up to 5 hits with a score of at least 0.35 are included, capped at 1500
|
|
109
109
|
tokens. All three limits are settings.
|
|
110
110
|
|
|
111
|
+
### No repeats in one session
|
|
112
|
+
|
|
113
|
+
Each block stays in the conversation, so a section shown in an earlier
|
|
114
|
+
turn is still in front of the model. It is not injected again: its
|
|
115
|
+
place goes to the next hit, and when every hit is a repeat no block is
|
|
116
|
+
added at all. Sections count as shown until the session is compacted,
|
|
117
|
+
or until their blocks are dropped after a pause (see below).
|
|
118
|
+
`memory.autoInject.skipRepeats: false` brings back the full block on
|
|
119
|
+
every turn.
|
|
120
|
+
|
|
121
|
+
### Old blocks after a pause
|
|
122
|
+
|
|
123
|
+
On an `openai-compatible` provider, somora rebuilds the conversation for
|
|
124
|
+
every request, with each earlier turn's block, so the provider's prompt
|
|
125
|
+
cache keeps hitting. That cache expires after some idle time anyway.
|
|
126
|
+
When a session was silent longer than
|
|
127
|
+
`dropMemoryBlocksAfterIdleMinutes` of its provider (60 by default),
|
|
128
|
+
the earlier blocks are dropped from the conversation, once, and the
|
|
129
|
+
session goes on without them. The rest of each turn stays.
|
|
130
|
+
|
|
131
|
+
Set the minutes to the cache lifetime of the provider: around 60 for a
|
|
132
|
+
paid API, a few minutes for your own server, `0` to keep the blocks.
|
|
133
|
+
The Claude and ChatGPT subscriptions keep the conversation themselves,
|
|
134
|
+
so there the old blocks leave only when the session is compacted.
|
|
135
|
+
|
|
111
136
|
> **Note:** The wording of the block header matters. It calls the notes
|
|
112
137
|
> recollection, not observation, and says they never replace a tool.
|
|
113
138
|
> Wording such as "no tool call required" makes smaller models stop
|
|
@@ -289,6 +314,7 @@ memory:
|
|
|
289
314
|
historyWeightEmpty: 0.8
|
|
290
315
|
historyTurnChars: 800
|
|
291
316
|
shortQueryBm25Weight: 0.5
|
|
317
|
+
skipRepeats: true
|
|
292
318
|
rescanMinutes: 10
|
|
293
319
|
hybrid:
|
|
294
320
|
vectorWeight: 0.7
|
|
@@ -318,6 +344,8 @@ wiki:
|
|
|
318
344
|
| `memory.autoInject.historyWeightEmpty` | The same for a message with none. |
|
|
319
345
|
| `memory.autoInject.historyTurnChars` | How much of each earlier turn is used. |
|
|
320
346
|
| `memory.autoInject.shortQueryBm25Weight` | Share of the word search for a one- or two-word question. `null` uses `bm25Weight`. |
|
|
347
|
+
| `memory.autoInject.skipRepeats` | Leave out sections the model still has in context from an earlier turn of the session. |
|
|
348
|
+
| `providers.<name>.dropMemoryBlocksAfterIdleMinutes` | `openai-compatible` only: after this many idle minutes the earlier blocks leave the replayed conversation (default 60, `0` keeps them). |
|
|
321
349
|
| `memory.rescanMinutes` | Full sweep of vault and wiki every N minutes. `0` switches it off. Unchanged files are skipped. |
|
|
322
350
|
| `memory.hybrid.vectorWeight` | Share of the meaning search. |
|
|
323
351
|
| `memory.hybrid.bm25Weight` | Share of the word search. |
|
package/docs/mobile.md
CHANGED
|
@@ -60,11 +60,27 @@ switch. **+ New** asks for a name and opens the new session. If the
|
|
|
60
60
|
name exists already, that session opens. A dot marks a session with
|
|
61
61
|
something unread, `running` one that is working right now.
|
|
62
62
|
|
|
63
|
+
**Archived.** The last row of the list. Tap it to see the agent's
|
|
64
|
+
archived sessions, newest first, each with the time it was archived.
|
|
65
|
+
**Restore** brings one back as a normal session and opens it, with its
|
|
66
|
+
whole history. A session `/reset` archived comes back as
|
|
67
|
+
`<name>-archive`. Several archives can share that name, for example one
|
|
68
|
+
per reset of `main`: the time tells them apart.
|
|
69
|
+
|
|
70
|
+
**Compact this conversation.** Shortens the session right away: the
|
|
71
|
+
earlier conversation is summarised and you keep talking. Greyed out
|
|
72
|
+
while a turn runs. See [Compact by hand](compaction.md#compact-by-hand).
|
|
73
|
+
|
|
63
74
|
**Model for this session.** Tap a model to use it for this session
|
|
64
75
|
only. The agent's own model is tagged `default`. Choosing it again
|
|
65
76
|
removes the session's own choice. A model somora cannot reach at the
|
|
66
77
|
moment is tagged `unreachable`.
|
|
67
78
|
|
|
79
|
+
Above the models, a reasoning model shows its thinking level and where
|
|
80
|
+
it comes from: `set for this session`, `agent's default`,
|
|
81
|
+
`model's default`, or `model decides` with `nothing set`. The
|
|
82
|
+
[thinking guide](thinking.md) explains the order.
|
|
83
|
+
|
|
68
84
|
Good to know:
|
|
69
85
|
|
|
70
86
|
- Each agent reopens in the session you left it in on this phone.
|
|
@@ -75,6 +91,7 @@ Good to know:
|
|
|
75
91
|
model with `⇄` in the warning colour.
|
|
76
92
|
|
|
77
93
|
Renaming, archiving and resetting a session are done in the web client.
|
|
94
|
+
Restoring an archived one works here too.
|
|
78
95
|
|
|
79
96
|
## Sending messages
|
|
80
97
|
|
|
@@ -161,6 +178,13 @@ screen. The session sheet shows which session it is. Opening the session
|
|
|
161
178
|
clears the dot on all your clients, the web client and the TUI included.
|
|
162
179
|
The state survives a server restart.
|
|
163
180
|
|
|
181
|
+
## When config.yaml has a mistake
|
|
182
|
+
|
|
183
|
+
A red banner at the top says that `config.yaml` does not validate.
|
|
184
|
+
somora keeps running on the last valid version until the file is
|
|
185
|
+
fixed, then the banner goes away. See
|
|
186
|
+
[A broken config file](setup.md#a-broken-config-file).
|
|
187
|
+
|
|
164
188
|
## When the connection drops
|
|
165
189
|
|
|
166
190
|
A banner appears while the live connection is down. The app reconnects
|
|
@@ -180,12 +204,16 @@ Use the [web client](web.md) for these:
|
|
|
180
204
|
- File viewer and pin-note windows
|
|
181
205
|
- Several windows side by side
|
|
182
206
|
- Renaming, archiving or resetting a session
|
|
183
|
-
- Starting REM, Deep or Lucid by hand
|
|
184
207
|
- Switching the project of a session
|
|
185
208
|
- A builder's task panel: plan, Go, task list and questions. You can
|
|
186
209
|
chat with a builder from the phone, but its plan is approved and its
|
|
187
210
|
questions are answered in the web client.
|
|
188
211
|
|
|
212
|
+
REM, Deep and Lucid have no button in any client. Ask the agent to run
|
|
213
|
+
one, for example "catch up on your memories": it starts the phase with
|
|
214
|
+
`dream_run`. Over HTTP it is `POST /agents/:agent/dream/run-rem`, see the
|
|
215
|
+
[dream phases](dream-phases.md).
|
|
216
|
+
|
|
189
217
|
## Settings
|
|
190
218
|
|
|
191
219
|
```yaml
|
package/docs/models.md
CHANGED
|
@@ -45,7 +45,7 @@ Each engine section has a table with a **checked** column.
|
|
|
45
45
|
|---|---|
|
|
46
46
|
| full check | The model went through somora's engine check on a live install. |
|
|
47
47
|
| partial | Only the parts named in the row were checked in somora. |
|
|
48
|
-
|
|
|
48
|
+
| in use | Runs in somora on a live install. Not taken through every step of the engine check. |
|
|
49
49
|
|
|
50
50
|
The full check covers: basic tools (`time_now`, `exec`, `file_read`,
|
|
51
51
|
`tmux`, `memory_search`, a deferred tool), tools on an SSH resource
|
|
@@ -308,6 +308,14 @@ providers:
|
|
|
308
308
|
sampling: { temperature: 0.6, top_p: 0.95, top_k: 20, min_p: 0 }
|
|
309
309
|
reasoning:
|
|
310
310
|
levels: { "off": low, high: xhigh }
|
|
311
|
+
- id: kolibri-1 # vLLM with Aleph Alpha's inference plugin, FP8
|
|
312
|
+
alias: kolibri
|
|
313
|
+
contextWindow: 262144 # = --max-model-len (the model is validated up to 1M)
|
|
314
|
+
capabilities: [text, reasoning] # no vision
|
|
315
|
+
sampling: { temperature: 1.0, top_p: 0.97, top_k: 128 } # the model's generation_config.json
|
|
316
|
+
maxTokens: 16384
|
|
317
|
+
reasoning:
|
|
318
|
+
levels: { "off": none } # the other levels pass as they are
|
|
311
319
|
- id: gemma-4-31b-it-8bit # oMLX (Apple Silicon)
|
|
312
320
|
alias: gemma4big
|
|
313
321
|
contextWindow: 131072
|
|
@@ -328,11 +336,12 @@ Sampling is given as temperature / top_p / top_k.
|
|
|
328
336
|
|---|---|---|---|---|
|
|
329
337
|
| **DeepSeek V4 Flash** (284B MoE, 13B active) | SGLang, TP=4 | the server's `--context-length`: 700000 on a two GPU profile, 1M only with the whole box | 1.0 / 0.95 (DeepSeek's recommendation for agents and coding) | full check, image attachment refused as intended |
|
|
330
338
|
| **DeepSeek V4.1 Flash** | SGLang, TP=4, community SM120 runtime, Engram NVMe offload | `--context-length` 700000 | 1.0 / 0.95 (model card; `top_k` and penalties unset) | partial: thinking levels, native image, tools, several turns |
|
|
331
|
-
| **GLM-5.3-Flash** (321B MoE, 18B active) | vLLM, TP=4, native FP8, MTP-4, fp8 KV | `--max-model-len` 700000 (KV pool 1.16M tokens with `--kv-cache-memory` 7.5 GiB) | 1.0 / 0.95 (the model's `generation_config.json`) |
|
|
332
|
-
| **DeepSeek-V4-Flash-Vision-Exp** (284B MoE, 13B active, 0.5B ViT) | SGLang, TP=2, preview image with sm_120 patches | `--context-length` 700000 (pool 859k at mem-fraction 0.90; 0.85 gives only 203k) | 1.0 / 0.95 |
|
|
333
|
-
| **Qwen3.8-Flash-Next** FP8 (176B, 6B active) | vLLM, TP=4 | `--max-model-len`, 524288 with YaRN 2.0 | 0.6 / 0.95 / 20, `min_p` 0 (Qwen's thinking mode defaults) | full check |
|
|
339
|
+
| **GLM-5.3-Flash** (321B MoE, 18B active) | vLLM, TP=4, native FP8, MTP-4, fp8 KV | `--max-model-len` 700000 (KV pool 1.16M tokens with `--kv-cache-memory` 7.5 GiB) | 1.0 / 0.95 (the model's `generation_config.json`) | in use |
|
|
340
|
+
| **DeepSeek-V4-Flash-Vision-Exp** (284B MoE, 13B active, 0.5B ViT) | SGLang, TP=2, preview image with sm_120 patches | `--context-length` 700000 (pool 859k at mem-fraction 0.90; 0.85 gives only 203k) | 1.0 / 0.95 | in use |
|
|
341
|
+
| **Qwen3.8-Flash-Next** FP8 (176B, 6B active) | vLLM, TP=4 | `--max-model-len`, 524288 with YaRN 2.0; 1048576 with YaRN 4.0 on a four GPU server | 0.6 / 0.95 / 20, `min_p` 0 (Qwen's thinking mode defaults) | full check |
|
|
334
342
|
| **Qwen3.5-397B-A17B** AWQ INT4 | vLLM, TP=4 | 262144 (`max_model_len`) | as Qwen3.8-Flash-Next | full check |
|
|
335
343
|
| **Qwen3.8-27B** FP8, dense | vLLM, 1 GPU | 262144 | as Qwen3.8-Flash-Next | full check |
|
|
344
|
+
| **Kolibri-1** FP8 (78B MoE, 3.5B active), German and English | vLLM 0.29 with Aleph Alpha's inference plugin, 1 GPU | `--max-model-len` 262144 (validated up to 1M) | 1.0 / 0.97 / 128 (the model's `generation_config.json`) | in use |
|
|
336
345
|
| **Gemma 4** 31B and 26B-A4B | oMLX | 131072 | 1.0 / 0.95 / 64 (Gemma team recommendation) | full check |
|
|
337
346
|
|
|
338
347
|
### Reasoning levels per family
|
|
@@ -343,6 +352,7 @@ Sampling is given as temperature / top_p / top_k.
|
|
|
343
352
|
| DeepSeek V4.1 Flash | `none`, `low`, `high`, `max` | is ignored | `off: none`, `medium: high`, `high: max` |
|
|
344
353
|
| GLM-5.3-Flash | `low`, `high`, `max` only | silently becomes `max`, also `none` and `medium` | `off: low`, `medium: high`, `high: max` |
|
|
345
354
|
| Qwen 3.x | `none`, `low`, `medium`, `xhigh` | answers 400, so `high` fails unless mapped | `high: xhigh` and `off: low` or `off: none`, see below |
|
|
355
|
+
| Kolibri-1 | `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` | unchecked | `off: none`. `none` gives zero reasoning. |
|
|
346
356
|
| Gemma 4 | none, no `reasoning` capability | not sent | nothing |
|
|
347
357
|
|
|
348
358
|
Details that matter when you pick a mapping:
|
|
@@ -368,6 +378,33 @@ Details that matter when you pick a mapping:
|
|
|
368
378
|
> with a one line prompt: the reasoning must be empty. The `none` that
|
|
369
379
|
> switches Qwen off means full reasoning on GLM.
|
|
370
380
|
|
|
381
|
+
### When no level is set
|
|
382
|
+
|
|
383
|
+
With no level for the session, the agent or the model, somora sends
|
|
384
|
+
nothing and the backend decides. What that means differs per family.
|
|
385
|
+
A `reasoning.default` on the model makes the choice visible in every
|
|
386
|
+
client. Set it to the level that matches what the model does anyway,
|
|
387
|
+
or on purpose to a different one.
|
|
388
|
+
|
|
389
|
+
| Model family | Nothing set | Default worth setting |
|
|
390
|
+
|---|---|---|
|
|
391
|
+
| DeepSeek V4 Flash, Vision-Exp | No reasoning. | Only when the agent should think. `default: medium` sends `high`. |
|
|
392
|
+
| DeepSeek V4.1 Flash | Unchecked. | Leave it unset until you have compared the lengths. |
|
|
393
|
+
| GLM-5.3-Flash | Unchecked. An unknown word becomes `max`, which is expensive. | Compare first. `default: medium` sends `high`. |
|
|
394
|
+
| Qwen3.8-Flash-Next | Reasons as much as with `xhigh`. | `default: high`: the same behaviour, now shown as `high`. |
|
|
395
|
+
| Kolibri-1 | Reasons: its chat template defaults to `high`. | `default: high`: the same behaviour, now shown as `high`. |
|
|
396
|
+
| Gemma 4 | No reasoning capability. | None. |
|
|
397
|
+
|
|
398
|
+
```yaml
|
|
399
|
+
- id: qwen3.8-flash-next
|
|
400
|
+
reasoning:
|
|
401
|
+
levels: { "off": low, high: xhigh }
|
|
402
|
+
default: high # what the model does without a level
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
An agent's `thinking:` in `agent.yaml` and a session's `/thinking` still
|
|
406
|
+
come first. The [thinking guide](thinking.md) lists the order.
|
|
407
|
+
|
|
371
408
|
### Notes per family
|
|
372
409
|
|
|
373
410
|
| Model family | Vision | Tool calls and other notes |
|
|
@@ -379,6 +416,7 @@ Details that matter when you pick a mapping:
|
|
|
379
416
|
| Qwen3.8-Flash-Next | yes | `maxTokens: 16384`, because reasoning otherwise eats short answers. Parsers `qwen3` and `qwen3_xml`. |
|
|
380
417
|
| Qwen3.5-397B-A17B | yes | `hermes` tool parser. |
|
|
381
418
|
| Qwen3.8-27B | yes | `qwen3_coder` tool parser. |
|
|
419
|
+
| Kolibri-1 | no | Tool calls work over many turns, with several tools per turn. Without `off: none` an agent set to `off` still reasons. |
|
|
382
420
|
| Gemma 4 | yes | A prefill memory guard answers 400 on long prompts. somora's reactive compaction handles it. |
|
|
383
421
|
|
|
384
422
|
### What is special about this engine
|
|
@@ -499,6 +537,7 @@ providers:
|
|
|
499
537
|
| `contextWindow` | required | compaction trigger, worker choice, display. Use the server's limit. | worker choice, display. The native window is right. | worker choice, display. Use the Codex session window, 258400. | worker choice, display |
|
|
500
538
|
| `capabilities` | `[text]` | `image` and `pdf` gate attachments, `reasoning` decides whether a thinking level is sent | same | same | same |
|
|
501
539
|
| `alias` | none | short name for `model:` in `agent.yaml`, letters, digits, `-` and `_` | same | same | same |
|
|
540
|
+
| `reasoning.default` | unset | the thinking level used when session and agent set none, in somora's words; sent explicitly and shown as the model's default | same | same | same |
|
|
502
541
|
| `reasoning.levels` | unset | somora level to the word the model gets, for `off`, `low`, `medium`, `high`. `null` leaves the parameter out. | not used | applied, for example `xhigh` and `max` | applied |
|
|
503
542
|
| `reasoning.param` | `reasoning_effort` | where the word goes: `reasoning_effort`, nested `reasoning` for OpenRouter, or `chat_template_kwargs` | not used | not used | not used |
|
|
504
543
|
| `sampling` | unset | sent on every call, dropped once when the server rejects a key | not used | not used | not used |
|
|
@@ -521,6 +560,7 @@ engines take `engine` and `models` and nothing else.
|
|
|
521
560
|
| `pdfMode` | `rasterize` | `rasterize` sends PDF pages as images and works with every vision model. `native` sends the PDF itself: only for a backend that accepts it. |
|
|
522
561
|
| `memoryInjectMode` | `inline-user` | Where recalled notes go: `inline-user` puts them in the user message and keeps the prefix cache, `system` appends them to the system prompt. |
|
|
523
562
|
| `sendUserTag` | `true` | Sends `user` on every request so a gateway can group cost per agent and session. `false` withholds it. |
|
|
563
|
+
| `dropMemoryBlocksAfterIdleMinutes` | `60` | After this many idle minutes the memory blocks of earlier turns leave the rebuilt conversation. Match it to the provider's cache lifetime; `0` keeps them. See [Memory](memory.md#old-blocks-after-a-pause). |
|
|
524
564
|
|
|
525
565
|
The `user` value that `sendUserTag` sends:
|
|
526
566
|
|
package/docs/resources.md
CHANGED
|
@@ -102,6 +102,28 @@ somora keeps one connection per resource and reuses it.
|
|
|
102
102
|
| Config change | a new `host`, `port`, `user`, `keyPath` or `hostKey` reconnects on the next call |
|
|
103
103
|
| Server stop | all connections are closed |
|
|
104
104
|
|
|
105
|
+
## Commands that start something in the background
|
|
106
|
+
|
|
107
|
+
A command sent with `exec` (without `background: true`) returns when the
|
|
108
|
+
remote shell has finished and its output is closed. A process the
|
|
109
|
+
command starts with a bare `&` inherits that output and keeps it open.
|
|
110
|
+
|
|
111
|
+
| Case | What happens |
|
|
112
|
+
|---|---|
|
|
113
|
+
| The command ends normally | The result comes back at once. |
|
|
114
|
+
| It exits, but a process it started still holds the output | The result comes back about 3 seconds after the exit, with the exit code and a note. That process keeps running. |
|
|
115
|
+
| It is still running at the time limit | It is stopped, the channel is closed, and the result says so with the real duration. Processes it started may keep running. |
|
|
116
|
+
|
|
117
|
+
To leave something running on the remote machine, detach all three
|
|
118
|
+
streams:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
nohup my-server </dev/null >/tmp/my-server.log 2>&1 &
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
For long work you want to follow, use `exec` with `background: true`
|
|
125
|
+
instead. It returns a job id, and `process` reads its output later.
|
|
126
|
+
|
|
105
127
|
## Allowing blocked commands
|
|
106
128
|
|
|
107
129
|
`exec` refuses a short list of dangerous commands on every target:
|
package/docs/setup.md
CHANGED
|
@@ -82,7 +82,7 @@ somora setup access # one step only
|
|
|
82
82
|
|
|
83
83
|
| Step | What it does |
|
|
84
84
|
|---|---|
|
|
85
|
-
| `models` | Connects a Claude subscription (
|
|
85
|
+
| `models` | Connects a Claude subscription (runs the login of the Claude Code bundled with somora), a ChatGPT subscription (the bundled Codex login, in the browser or with a device code), or your own server. For a server it asks the address and key, lists the models and asks each one's context window. |
|
|
86
86
|
| `search` | Asks for a Brave Search API key, checks it with one real search and stores it as `web.brave.apiKey`. That gives the agents the `web_search` tool. |
|
|
87
87
|
| `agent` | Creates an agent: name, what it calls you, answer language, model and backup model. On an existing install it lists the agents and offers to repair one whose model is gone. |
|
|
88
88
|
| `memory` | Turns on REM per agent with a model and a backup model, offers the duplicate check for new notes, and sets up the shared wiki with Deep and Lucid, their model and a backup model. The wiki goes into a new folder or your Obsidian vault. |
|
|
@@ -198,7 +198,7 @@ blocks for you. By hand, edit `providers` in `~/.somora/config.yaml`.
|
|
|
198
198
|
|
|
199
199
|
| Kind | Engine | Login |
|
|
200
200
|
|---|---|---|
|
|
201
|
-
| Claude subscription | `claude-cli` |
|
|
201
|
+
| Claude subscription | `claude-cli` | `somora auth login`. Claude Code is bundled with somora. A Claude Code you installed yourself, and its login, is used instead when present. No API key. |
|
|
202
202
|
| ChatGPT subscription | `codex-cli` | `somora codex login`. Codex is bundled with somora. A login made with a global Codex is picked up too. |
|
|
203
203
|
| Grok subscription | `grok-cli` | Install the Grok CLI with `curl -fsSL https://x.ai/cli/install.sh \| bash`, then `grok login`. |
|
|
204
204
|
| Own server or API key | `openai-compatible` | Ollama, LM Studio, vLLM, oMLX, OpenRouter or any other server with a `/v1/chat/completions` endpoint. |
|
|
@@ -405,6 +405,35 @@ apply after a restart. These sections are read once at start:
|
|
|
405
405
|
Everything else, such as `providers`, `compaction`, `agentLoop` or
|
|
406
406
|
`fallback`, applies with the reload.
|
|
407
407
|
|
|
408
|
+
### A broken config file
|
|
409
|
+
|
|
410
|
+
somora also picks up an edited `config.yaml` by itself on the next
|
|
411
|
+
turn. When the edited file has a mistake, somora keeps running on the
|
|
412
|
+
last valid version. No turn fails because of it. Your edit is simply
|
|
413
|
+
not in effect until the file is fixed.
|
|
414
|
+
|
|
415
|
+
| Where | What you see |
|
|
416
|
+
|---|---|
|
|
417
|
+
| Web client | The gear in the taskbar turns red, and its menu lists the problems. |
|
|
418
|
+
| Mobile app | A red banner at the top. |
|
|
419
|
+
| TUI | One error line with the problems. |
|
|
420
|
+
| Agent | One note in its next turn, so the agent that made the edit can fix it. |
|
|
421
|
+
| Agent writing the file | `file_write` and `file_patch` report the problems in their result as `config_invalid`. |
|
|
422
|
+
| Server log | `config.invalid_kept_last_good`, and `config.valid_again` once it is fixed. |
|
|
423
|
+
|
|
424
|
+
Check a file before you rely on it:
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
somora config check # ~/.somora/config.yaml
|
|
428
|
+
somora config check ./draft.yaml # any file
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
The exit code is 0 for a valid file, 1 for an invalid one and 2 when
|
|
432
|
+
the file cannot be read. The check is the same the server runs.
|
|
433
|
+
|
|
434
|
+
> **Note:** At server start there is no last valid version yet. A
|
|
435
|
+
> broken file then stops the start, with the problems printed.
|
|
436
|
+
|
|
408
437
|
### Restart
|
|
409
438
|
|
|
410
439
|
| Where | How |
|
|
@@ -693,7 +722,10 @@ in the agents guide.
|
|
|
693
722
|
| `somora server status` | Shows the running server, a waiting update and the service state. |
|
|
694
723
|
| `somora tui` | Opens the terminal client against the running server. |
|
|
695
724
|
| `somora update [<version>] [--edge] [--force] [--no-reinit]` | Installs a version from npm, refreshes the service and restarts it. |
|
|
725
|
+
| `somora config check [file]` | Validates `config.yaml` (or another file) exactly as the server does. Exit code 0 valid, 1 invalid, 2 unreadable. |
|
|
726
|
+
| `somora config path` | Prints the path of the config file. |
|
|
696
727
|
| `somora telemetry show [--json]` | Shows what the daily update check sends and when it last ran. |
|
|
728
|
+
| `somora auth login` | Logs in with a Claude subscription, through the bundled Claude Code or your own. |
|
|
697
729
|
| `somora auth status` | Shows both Claude credential stores. |
|
|
698
730
|
| `somora auth sync` | Reconciles the two stores now. |
|
|
699
731
|
| `somora codex <args>` | Runs the bundled Codex: `login`, `logout`, `debug models`, `features list`, `--version`. |
|
|
@@ -775,7 +807,7 @@ service's environment.
|
|
|
775
807
|
| `SOMORA_LOG_LEVEL` | `info` | Log level. |
|
|
776
808
|
| `SOMORA_ENV_FILE` | `~/.somora/somora.env` | Another env file to load at start. |
|
|
777
809
|
| `DO_NOT_TRACK` | unset | `1` turns the daily update check off. A set `CI` does the same. |
|
|
778
|
-
| `SOMORA_CLAUDE_BIN` | `~/.local/bin/claude
|
|
810
|
+
| `SOMORA_CLAUDE_BIN` | `~/.local/bin/claude`, else the bundled one | Path of the Claude Code binary. |
|
|
779
811
|
| `CLAUDE_CONFIG_DIR` | `~/.somora/claude-home` | Config folder of the Claude engine. |
|
|
780
812
|
| `SOMORA_CODEX_BIN` | unset | Uses another Codex binary instead of the bundled one. For debugging. |
|
|
781
813
|
| `SOMORA_GROK_BIN` | `~/.local/bin/grok`, else `grok` on `PATH` | Path of the Grok CLI. |
|
package/docs/thinking.md
CHANGED
|
@@ -46,13 +46,36 @@ The first source that has a value wins.
|
|
|
46
46
|
|---|---|---|
|
|
47
47
|
| 1 | The session | `/thinking <level>`, or the THINKING section of the `•••` session menu in the web client |
|
|
48
48
|
| 2 | The agent | `thinking:` in `agent.yaml` |
|
|
49
|
-
| 3 |
|
|
49
|
+
| 3 | The model | `reasoning.default` of the model in `config.yaml` |
|
|
50
|
+
| 4 | Nothing set | somora sends no level and the model uses its own default |
|
|
50
51
|
|
|
51
|
-
In the TUI, `/thinking -` does the same as `/thinking default
|
|
52
|
+
In the TUI, `/thinking -` does the same as `/thinking default`: it
|
|
53
|
+
removes the session's level, and the next source applies.
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
"Nothing set" is not "off". Many reasoning models think by default,
|
|
56
|
+
Qwen 3.x among them, so an agent without a level runs them
|
|
57
|
+
at full depth. Every client shows this state as **model decides**,
|
|
58
|
+
never as off. What "nothing set" means per model family, and which
|
|
59
|
+
default fits, is listed under
|
|
60
|
+
[When no level is set](models.md#when-no-level-is-set). To make "off"
|
|
61
|
+
(or any level) the rule for a model, give it a default:
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
providers:
|
|
65
|
+
gpu-box:
|
|
66
|
+
models:
|
|
67
|
+
- id: my-thinking-model
|
|
68
|
+
alias: thinker
|
|
69
|
+
capabilities: [text, reasoning]
|
|
70
|
+
reasoning:
|
|
71
|
+
default: "off" # sent when session and agent set nothing
|
|
72
|
+
levels: { "off": none, high: high }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The default is written in somora's words (`off`, `low`, `medium`,
|
|
76
|
+
`high`) and goes through the model's `levels` like any other level. It
|
|
77
|
+
applies on every engine. The session menu, `/thinking` and the phone's
|
|
78
|
+
model sheet name it as the model's default.
|
|
56
79
|
|
|
57
80
|
## The reasoning capability
|
|
58
81
|
|
|
@@ -250,13 +273,15 @@ Lucid work on the wiki that all agents share, so they are set once.
|
|
|
250
273
|
| `🧠 medium` | The level is applied. |
|
|
251
274
|
| `🧠 high→xhigh` | Applied, and the model receives a different word than the level. `🧠 high→off` means the parameter is omitted. |
|
|
252
275
|
| `thinking=medium (dormant)` | A level is stored, but the model has no `reasoning` capability. It has no effect. |
|
|
276
|
+
| `🧠 auto` | Web client: nothing is set on a reasoning model, so the model decides. |
|
|
253
277
|
| `thinking` with a spinner | TUI only: the turn runs and no reply text has arrived yet. |
|
|
254
278
|
| `↓ 412 (1.2k 🧠)` | Reasoning tokens of the turn, next to the output tokens. |
|
|
255
279
|
| `(~1.2k 🧠)` | The same as an estimate, see below. |
|
|
256
280
|
|
|
257
|
-
The TUI and the web client show the same badges.
|
|
258
|
-
web client hides the badge when the level is `off`,
|
|
259
|
-
|
|
281
|
+
The TUI and the web client show the same badges. Three differences: the
|
|
282
|
+
web client hides the badge when the level is `off`, shows `🧠 auto`
|
|
283
|
+
when nothing is set, and the TUI shows the arrow only on
|
|
284
|
+
`openai-compatible` models. Dream runs are background
|
|
260
285
|
work and have no badge.
|
|
261
286
|
|
|
262
287
|
## Reasoning tokens
|
|
@@ -337,6 +362,7 @@ Where a level is set:
|
|
|
337
362
|
| `thinking` | `agent.yaml` | `off`, `low`, `medium`, `high`. Unset: nothing is sent. |
|
|
338
363
|
| `rem.thinking` | `agent.yaml` | the same |
|
|
339
364
|
| `rem.dedup.judge.thinking`, `wiki.deep.thinking`, `wiki.lucid.thinking` | `config.yaml` | the same |
|
|
365
|
+
| `reasoning.default` | per model in `config.yaml` | `off`, `low`, `medium`, `high`. Used when session and agent set nothing. Unset: nothing is sent. |
|
|
340
366
|
| `reasoning.param`, `reasoning.levels` | per model in `config.yaml` | see [Mapping levels per model](#mapping-levels-per-model) |
|
|
341
367
|
|
|
342
368
|
## Commands
|
|
@@ -365,6 +391,7 @@ All three answer 404 for an unknown agent or session. A GET response:
|
|
|
365
391
|
"effective": "high",
|
|
366
392
|
"override": "high",
|
|
367
393
|
"personaDefault": "medium",
|
|
394
|
+
"modelDefault": "off",
|
|
368
395
|
"source": "session-override",
|
|
369
396
|
"modelSupportsReasoning": true,
|
|
370
397
|
"wire": "xhigh"
|
|
@@ -376,7 +403,8 @@ All three answer 404 for an unknown agent or session. A GET response:
|
|
|
376
403
|
| `effective` | The level in effect, or `null` when nothing is set. |
|
|
377
404
|
| `override` | The session's level, or `null`. |
|
|
378
405
|
| `personaDefault` | The agent's level, or `null`. |
|
|
379
|
-
| `
|
|
406
|
+
| `modelDefault` | The active model's `reasoning.default`, or `null`. |
|
|
407
|
+
| `source` | `session-override`, `persona-default`, `model-default`, or `engine-default` (nothing set: nothing is sent, the model decides). |
|
|
380
408
|
| `modelSupportsReasoning` | `false` means the level is dormant. |
|
|
381
409
|
| `wire` | The word the engine sends when it differs from `effective`, else `null`. `"off"` means the parameter is omitted. Reported for `openai-compatible` and `codex-cli`. |
|
|
382
410
|
|
package/docs/web.md
CHANGED
|
@@ -157,7 +157,12 @@ The entry reads `changed on disk` when the file is newer than what the
|
|
|
157
157
|
server loaded. Restart is greyed out when somora does not run as a
|
|
158
158
|
background service (the systemd user unit on Linux, the LaunchAgent on
|
|
159
159
|
macOS). `agent.yaml` needs neither: it is read on every
|
|
160
|
-
turn.
|
|
160
|
+
turn.
|
|
161
|
+
|
|
162
|
+
When `config.yaml` has a mistake, the gear turns red with a `!` and
|
|
163
|
+
its menu lists the problems. somora keeps running on the last valid
|
|
164
|
+
version until the file is fixed. See
|
|
165
|
+
[A broken config file](setup.md#a-broken-config-file). The terminal client has the same actions as `/reload` and
|
|
161
166
|
`/restart YES`.
|
|
162
167
|
|
|
163
168
|
### When an agent restarts somora
|
|
@@ -189,9 +194,11 @@ turn runs and the work badge. The second line reads from left to right:
|
|
|
189
194
|
|---|---|
|
|
190
195
|
| Session | The session name, with the full id beside it in grey when the two differ. |
|
|
191
196
|
| Model | The model the next turn uses. |
|
|
197
|
+
| `(next turn · now <model>)` | The model was switched while a turn runs. The running turn finishes on the model it started with, the menu says the same. |
|
|
192
198
|
| `⇄ <model>` | The last turn was answered by a backup model, the agent's `fallback:` in `agent.yaml`. The tooltip says why. |
|
|
193
|
-
| `🧠 <level>` | The thinking level. `(dormant)` means the model cannot reason, so the level has no effect. |
|
|
194
|
-
|
|
|
199
|
+
| `🧠 <level>` | The thinking level. `(dormant)` means the model cannot reason, so the level has no effect. Hidden at `off`. |
|
|
200
|
+
| `🧠 auto` | No level is set for the session, the agent or the model. Nothing is sent and the model decides: reasoning models usually think. See the [thinking guide](thinking.md). |
|
|
201
|
+
| **tools** | Shows or hides tool calls, tool results and the engine's own plan rows. somora's own notes, such as `model switched` or `context compacted`, stay visible. |
|
|
195
202
|
| **memory** | Shows or hides the line that lists the notes recalled for a turn. |
|
|
196
203
|
| **voice** | Spoken replies on or off. Only when text-to-speech is configured. |
|
|
197
204
|
| `▣ 21%` | How full the context window was on the turn's last request. Amber above 75 %, red above 90 %. |
|
|
@@ -355,6 +362,7 @@ closes. Commands are not available while a turn is running.
|
|
|
355
362
|
| `/temp <0–2>\|default` | Short for `/sampling temperature=<n>`. |
|
|
356
363
|
| `/verbose thinking on\|off` | Shows or hides the thinking block in this session. Display only. |
|
|
357
364
|
| `/projekt <slug>` | Pins a project to this session. `/projekt unlink` clears it. `/project` is an alias. Only with `projects.enabled`. |
|
|
365
|
+
| `/compact [what to keep]` | Compacts this session now and the conversation goes on. The sentence is the focus of the summary. See [Compact by hand](compaction.md#compact-by-hand). |
|
|
358
366
|
| `/reset YES` | Archives this session and starts fresh. `YES` is the confirmation. |
|
|
359
367
|
|
|
360
368
|
There is no `/agent` command. To talk to another agent, open its
|
|
@@ -362,13 +370,14 @@ window.
|
|
|
362
370
|
|
|
363
371
|
### The session menu
|
|
364
372
|
|
|
365
|
-
The `•••` button opens a menu with
|
|
373
|
+
The `•••` button opens a menu with four parts. Click outside or press
|
|
366
374
|
Esc to close it.
|
|
367
375
|
|
|
368
376
|
| Part | What it does |
|
|
369
377
|
|---|---|
|
|
370
378
|
| **Model** | Shows the current model, its engine and context window. **Switch model…** opens a filterable list. A click sets the model for this session, like `/model`. |
|
|
371
379
|
| **Thinking** | Shows the level and where it comes from. Buttons set off, low, medium or high for this session. **Reset to default** removes the override. **Show thinking in replies** is the same switch as `/verbose thinking`. |
|
|
380
|
+
| **Conversation** | **Compact now** compacts this session, like `/compact` without a focus. The header shows `compacting…` while it runs. Greyed out while a turn runs. |
|
|
372
381
|
| **Danger zone** | **Reset session** archives the conversation as `<timestamp>_<session>-archive` and starts fresh, after a second click to confirm. With REM enabled for the agent, REM reads the archived part. |
|
|
373
382
|
|
|
374
383
|
## The Sessions window
|
|
@@ -397,7 +406,7 @@ run.
|
|
|
397
406
|
| Filters | Agent, engine, REM state (`dreamed`, `partial`, `never`) and a text search over slug, agent and id. |
|
|
398
407
|
| Column headers | Agent, Last activity, Msgs and Size sort. Click again to reverse. |
|
|
399
408
|
| Click a row | Opens the chat window of that session. |
|
|
400
|
-
| Archive button | Archives or unarchives the session. Not offered for `main`: use `/reset` there. |
|
|
409
|
+
| Archive button | Archives or unarchives the session. Not offered for `main`: use `/reset` there. A session `/reset` archived comes back as `<name>-archive`, with its whole history, ready to continue. |
|
|
401
410
|
| Checkboxes | Select several sessions and archive them together. |
|
|
402
411
|
| Two download buttons | Export as a readable Markdown transcript or as the raw JSONL file. Works for archived sessions too. |
|
|
403
412
|
| Reload and auto-refresh | Reload by hand. The list also refreshes every 60 seconds unless you switch that off. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "somora",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1007.2",
|
|
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",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"pino-roll": "^4.0.0",
|
|
87
87
|
"playwright-core": "^1.63.0",
|
|
88
88
|
"react": "^19.2.5",
|
|
89
|
+
"sharp": "^0.35.5",
|
|
89
90
|
"sqlite-vec": "^0.1.9",
|
|
90
91
|
"ssh2": "^1.17.0",
|
|
91
92
|
"tsx": "^4.21.0",
|
package/src/attachments/store.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// existing magic-bytes sniffer (multimodal/mime.ts) — extensions are
|
|
10
10
|
// untrusted (a `screenshot.txt` could be a renamed PNG).
|
|
11
11
|
|
|
12
|
+
import { fitImageFileForModel, imageSourceCap } from '../multimodal/model-image.ts';
|
|
12
13
|
import { createHash } from 'node:crypto';
|
|
13
14
|
import {
|
|
14
15
|
createWriteStream,
|
|
@@ -56,7 +57,9 @@ function extForMime(mime: DetectedMime): string {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
function capForKind(mime: DetectedMime, config: AttachmentsConfig): number {
|
|
59
|
-
|
|
60
|
+
// With scaling on, a big screenshot is accepted and scaled before it
|
|
61
|
+
// reaches a model (src/multimodal/model-image.ts).
|
|
62
|
+
if (mime.kind === 'image') return imageSourceCap(config);
|
|
60
63
|
if (mime.kind === 'pdf') return config.maxPdfBytes;
|
|
61
64
|
if (mime.kind === 'text') return config.maxTextBytes;
|
|
62
65
|
// unknown → reject at caller side; use the smallest cap as a
|
|
@@ -189,6 +192,21 @@ export async function resolveAttachmentByHash(args: {
|
|
|
189
192
|
throw new Error(`attachment ${args.hash} not found in ~/.somora/attachments/`);
|
|
190
193
|
}
|
|
191
194
|
|
|
195
|
+
/** resolveAttachmentByHash for an attachment that goes to a model: an
|
|
196
|
+
* image is swapped for its scaled copy (attachments.maxImageEdge), made
|
|
197
|
+
* once next to the original and reused by every later replay. */
|
|
198
|
+
export async function resolveAttachmentForModel(args: {
|
|
199
|
+
hash: string;
|
|
200
|
+
expectedMime: string;
|
|
201
|
+
maxImageEdge: number;
|
|
202
|
+
}): Promise<{ path: string; mime: DetectedMime; size: number }> {
|
|
203
|
+
const r = await resolveAttachmentByHash(args);
|
|
204
|
+
if (r.mime.kind !== 'image') return r;
|
|
205
|
+
const fitted = await fitImageFileForModel(r.path, r.mime.mimeType, args.maxImageEdge);
|
|
206
|
+
if (!fitted.resized) return r;
|
|
207
|
+
return { path: fitted.path, mime: { ...r.mime, mimeType: fitted.mimeType }, size: fitted.size };
|
|
208
|
+
}
|
|
209
|
+
|
|
192
210
|
async function listCandidatePaths(hash: string): Promise<string[]> {
|
|
193
211
|
// Try the common extensions; cheap because we only stat-existsSync.
|
|
194
212
|
const exts = ['png', 'jpg', 'gif', 'webp', 'pdf', 'txt', 'bin'];
|
package/src/browser/session.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveSessionId, sessionMetaStore } from '../storage/sessions.ts';
|
|
1
|
+
import { isSessionArchived, resolveSessionId, sessionMetaStore } from '../storage/sessions.ts';
|
|
2
2
|
import { loadPersona } from '../persona/loader.ts';
|
|
3
3
|
import { BrowserOpError } from './service.ts';
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ export async function resolveBrowserSession(agent: string, ref: string): Promise
|
|
|
8
8
|
const session = await resolveSessionId(agent, ref);
|
|
9
9
|
if (!session) throw new BrowserOpError('BROWSER_ACTION_FAILED', `session '${ref}' not found — create it first`);
|
|
10
10
|
const meta = await sessionMetaStore.get(agent, session);
|
|
11
|
-
if (meta
|
|
11
|
+
if (isSessionArchived(session, meta)) {
|
|
12
12
|
throw new BrowserOpError('BROWSER_ACTION_FAILED', `session '${session}' is archived — restore it before continuing`);
|
|
13
13
|
}
|
|
14
14
|
return session;
|
package/src/cli/auth.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// `somora auth` — visibility + manual control for the shared claude-cli
|
|
2
2
|
// login (see src/server/claude-credential-sync.ts for the mechanism).
|
|
3
3
|
//
|
|
4
|
+
// somora auth login log in with the Claude subscription (the
|
|
5
|
+
// bundled Claude Code, or your own when installed)
|
|
4
6
|
// somora auth status read-only view of both credential stores
|
|
5
7
|
// somora auth sync one-shot reconcile (what the running server's
|
|
6
8
|
// watcher does continuously)
|
|
@@ -10,6 +12,8 @@
|
|
|
10
12
|
// bootstrap) just for the sharedUserCredentials gate.
|
|
11
13
|
|
|
12
14
|
import { readFileSync } from 'node:fs';
|
|
15
|
+
import { spawnSync } from 'node:child_process';
|
|
16
|
+
import { claudeBinaryForLogin } from './claude-bin.ts';
|
|
13
17
|
import { homedir } from 'node:os';
|
|
14
18
|
import { join } from 'node:path';
|
|
15
19
|
import { load as parseYaml } from 'js-yaml';
|
|
@@ -40,6 +44,7 @@ function usage(): string {
|
|
|
40
44
|
return `somora auth — shared claude-cli login utilities
|
|
41
45
|
|
|
42
46
|
Usage:
|
|
47
|
+
somora auth login log in with your Claude subscription (uses the bundled Claude Code)
|
|
43
48
|
somora auth status show both credential stores (mtime, OAuth expiry, divergence)
|
|
44
49
|
somora auth sync reconcile now (newest OAuth chain wins, other side is overwritten)
|
|
45
50
|
`;
|
|
@@ -61,6 +66,23 @@ export function runAuthCli(args: string[]): number {
|
|
|
61
66
|
},
|
|
62
67
|
});
|
|
63
68
|
|
|
69
|
+
if (cmd === 'login') {
|
|
70
|
+
const bin = claudeBinaryForLogin();
|
|
71
|
+
if (!bin) {
|
|
72
|
+
process.stderr.write('no Claude Code binary found — the bundled one is missing; reinstall somora, or install Claude Code: curl -fsSL https://claude.ai/install.sh | bash\n');
|
|
73
|
+
return 1;
|
|
74
|
+
}
|
|
75
|
+
process.stdout.write(`Claude Code ${bin.bundled ? '(bundled with somora)' : `at ${bin.path}`} — it shows a link: open it in any browser, approve, paste the code back here.\n`);
|
|
76
|
+
const r = spawnSync(bin.path, ['auth', 'login'], { stdio: 'inherit' });
|
|
77
|
+
if (r.status !== 0) return r.status ?? 1;
|
|
78
|
+
if (enabled) {
|
|
79
|
+
const result = reconcileClaudeCredentials();
|
|
80
|
+
if (result === 'unavailable') return 1;
|
|
81
|
+
}
|
|
82
|
+
process.stdout.write('logged in. somora uses this login for the claude-cli engine.\n');
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
64
86
|
if (cmd === 'status') {
|
|
65
87
|
const s = credentialSyncStatus();
|
|
66
88
|
const now = Date.now();
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Which Claude Code binary the CLI hands a login to.
|
|
2
|
+
//
|
|
3
|
+
// somora ships Claude Code: the Agent SDK depends on a native package
|
|
4
|
+
// per platform (`@anthropic-ai/claude-agent-sdk-<platform>-<arch>`, a
|
|
5
|
+
// `-musl` variant on Alpine-like Linux) that holds the full `claude`
|
|
6
|
+
// binary. The engine runs that binary unless a separately installed one
|
|
7
|
+
// exists at ~/.local/bin/claude (or SOMORA_CLAUDE_BIN), so a login needs
|
|
8
|
+
// no extra install either.
|
|
9
|
+
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
import { homedir } from 'node:os';
|
|
13
|
+
import { dirname, join } from 'node:path';
|
|
14
|
+
import { spawnSync } from 'node:child_process';
|
|
15
|
+
|
|
16
|
+
/** A Claude Code the person installed themselves, if any. */
|
|
17
|
+
export function installedClaudeBinary(): string | null {
|
|
18
|
+
if (process.env.SOMORA_CLAUDE_BIN && existsSync(process.env.SOMORA_CLAUDE_BIN)) return process.env.SOMORA_CLAUDE_BIN;
|
|
19
|
+
const local = join(homedir(), '.local', 'bin', 'claude');
|
|
20
|
+
if (existsSync(local)) return local;
|
|
21
|
+
const r = spawnSync('sh', ['-c', 'command -v claude'], { encoding: 'utf8' });
|
|
22
|
+
return r.status === 0 && r.stdout.trim() ? r.stdout.trim() : null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The Claude Code that comes with somora's Agent SDK dependency. */
|
|
26
|
+
export function bundledClaudeBinary(): string | null {
|
|
27
|
+
const req = createRequire(import.meta.url);
|
|
28
|
+
const exe = process.platform === 'win32' ? 'claude.exe' : 'claude';
|
|
29
|
+
for (const variant of [`${process.platform}-${process.arch}`, `${process.platform}-${process.arch}-musl`]) {
|
|
30
|
+
try {
|
|
31
|
+
const pkg = req.resolve(`@anthropic-ai/claude-agent-sdk-${variant}/package.json`);
|
|
32
|
+
const bin = join(dirname(pkg), exe);
|
|
33
|
+
if (existsSync(bin)) return bin;
|
|
34
|
+
} catch {
|
|
35
|
+
// that variant is not installed on this machine
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The binary to log in with: the person's own when present (the engine
|
|
42
|
+
* prefers it too), else the bundled one. */
|
|
43
|
+
export function claudeBinaryForLogin(): { path: string; bundled: boolean } | null {
|
|
44
|
+
const own = installedClaudeBinary();
|
|
45
|
+
if (own) return { path: own, bundled: false };
|
|
46
|
+
const bundled = bundledClaudeBinary();
|
|
47
|
+
return bundled ? { path: bundled, bundled: true } : null;
|
|
48
|
+
}
|