counterparts 0.3.6 → 0.3.7
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/CHANGELOG.md +116 -0
- package/docs/module-map.md +1 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +67 -5
- package/src/adapters/claude-code/NOTES.md +71 -0
- package/src/adapters/claude-code/bin/hook.ts +62 -2
- package/src/adapters/claude-code/bin/nightly.ts +76 -0
- package/src/adapters/claude-code/config.ts +80 -0
- package/src/adapters/claude-code/doctor.ts +307 -2
- package/src/adapters/claude-code/hooks.ts +253 -21
- package/src/adapters/claude-code/index.ts +20 -0
- package/src/adapters/claude-code/night-run.ts +504 -0
- package/src/adapters/claude-code/page-writer.ts +50 -16
- package/src/adapters/cli/commands.ts +4 -2
- package/src/adapters/cli/dream-core.ts +25 -6
- package/src/adapters/dashboard/web/README.md +51 -36
- package/src/adapters/dashboard/web/app.html +0 -3
- package/src/adapters/dashboard/web/pages/health/health.css +2 -0
- package/src/adapters/dashboard/web/pages/health/sections/mechanisms.js +9 -0
- package/src/adapters/dashboard/web/pages/home/home.css +7 -4
- package/src/adapters/dashboard/web/pages/home/index.js +4 -3
- package/src/adapters/dashboard/web/pages/home/sections/feel.js +9 -19
- package/src/adapters/dashboard/web/pages/home/sections/map.js +6 -5
- package/src/adapters/dashboard/web/pages/memories/index.js +29 -18
- package/src/adapters/dashboard/web/pages/memories/memories.css +32 -42
- package/src/adapters/dashboard/web/pages/memories/row.js +37 -24
- package/src/adapters/dashboard/web/pages/memories/sections/feel.js +13 -173
- package/src/adapters/dashboard/web/pages/memories/sections/hold.js +34 -36
- package/src/adapters/dashboard/web/pages/memories/sections/list.js +70 -36
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +85 -88
- package/src/adapters/dashboard/web/pages/memories/sections/tools.js +5 -4
- package/src/adapters/dashboard/web/pages/memories/state.js +11 -5
- package/src/adapters/dashboard/web/pages/self/index.js +2 -0
- package/src/adapters/dashboard/web/pages/self/sections/map.js +417 -116
- package/src/adapters/dashboard/web/pages/self/self.css +23 -20
- package/src/adapters/dashboard/web/shared/memory-marks.css +1 -4
- package/src/adapters/dashboard/web/shared/memory-marks.js +2 -16
- package/src/adapters/dashboard/web/shared/memory-modal.js +45 -24
- package/src/adapters/dashboard/web/shared/modal.css +5 -0
- package/src/adapters/dashboard/web/shared/voice.js +18 -0
- package/src/adapters/dashboard/web/shared/widgets/feel-radar.js +137 -0
- package/src/adapters/dashboard/web/views/archive-words.ts +1 -1
- package/src/adapters/dashboard/web/views/memories.ts +98 -7
- package/src/adapters/dashboard/web/views/memory-words.ts +29 -1
- package/src/adapters/dashboard/web/views/memory.ts +3 -2
- package/src/adapters/fired.ts +1 -1
- package/src/adapters/mcp/NOTES.md +29 -0
- package/src/adapters/mcp/deliberate.ts +80 -5
- package/src/adapters/mcp/index.ts +2 -0
- package/src/adapters/mcp/server.ts +116 -18
- package/src/adapters/mcp/tools.ts +38 -12
- package/src/core/associate/CONTRACT.md +33 -4
- package/src/core/associate/INTERFACE-GAPS.md +70 -0
- package/src/core/associate/NOTES.md +220 -1
- package/src/core/associate/buffer.ts +12 -9
- package/src/core/associate/contiguity.ts +81 -0
- package/src/core/associate/edges.ts +117 -6
- package/src/core/associate/index.ts +224 -7
- package/src/core/associate/pending.ts +7 -3
- package/src/core/associate/spread.ts +154 -69
- package/src/core/associate/tunables.ts +75 -5
- package/src/core/counterpart.ts +398 -8
- package/src/core/dream/CONTRACT.md +79 -13
- package/src/core/dream/NOTES.md +67 -2
- package/src/core/dream/index.ts +1328 -223
- package/src/core/dream/mind.ts +120 -39
- package/src/core/dream/reflect.ts +292 -96
- package/src/core/dream/slices.ts +217 -0
- package/src/core/dream/tunables.ts +72 -12
- package/src/core/fit/CONTRACT.md +80 -0
- package/src/core/fit/INTERFACE-GAPS.md +16 -0
- package/src/core/fit/NOTES.md +37 -0
- package/src/core/fit/index.ts +499 -0
- package/src/core/recall/CONTRACT.md +13 -2
- package/src/core/recall/INTERFACE-GAPS.md +10 -0
- package/src/core/recall/NOTES.md +76 -0
- package/src/core/recall/activate.ts +320 -62
- package/src/core/recall/gate.ts +73 -4
- package/src/core/recall/index.ts +46 -10
- package/src/core/recall/render.ts +12 -1
- package/src/core/recall/session.ts +8 -0
- package/src/core/recall/tunables.ts +30 -0
- package/src/core/retrieval.ts +15 -6
- package/src/core/sleep/NOTES.md +11 -0
- package/src/core/sleep/decay.ts +16 -1
- package/src/core/sleep/prune.ts +16 -1
- package/src/core/store/index.ts +126 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,121 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.7 — 2026-09-29
|
|
4
|
+
|
|
5
|
+
Dreaming asks where you can see it, and "on its own" now means a separate background
|
|
6
|
+
session the hook starts itself. Memory also fits more into a night, reads long
|
|
7
|
+
memories whole, and lets links bring a memory to mind. **The store's format does not
|
|
8
|
+
change** (it stays v9), so nothing is copied or upgraded. Close every session before
|
|
9
|
+
installing anyway: the hooks switch to the new code at once, while a session left open
|
|
10
|
+
keeps the old memory server. Run `/mcp` → Reconnect in any you missed.
|
|
11
|
+
|
|
12
|
+
Dreaming.
|
|
13
|
+
|
|
14
|
+
- **The day's question shows in your terminal.** On the first prompt of a new day, with
|
|
15
|
+
memories waiting to be dreamed, you see: `Counterparts: I haven't dreamed since …
|
|
16
|
+
(N new memories). Say "dream" to start, or "dream on your own" to let me do it each
|
|
17
|
+
day.` Claude doesn't ask it again; it waits for your word.
|
|
18
|
+
- **`ask` is the default now** (it was `auto`). Say "dream" and the run starts in a
|
|
19
|
+
background agent, as before.
|
|
20
|
+
- **"Dream on your own" means a headless nightly run.** With the setting `auto`, the
|
|
21
|
+
first prompt of the day starts the run itself, in a separate, windowless `claude`
|
|
22
|
+
session, and tells you: `Counterparts: dreaming in the background (a few minutes).
|
|
23
|
+
Say "no dreams" to turn it off.` Nothing is asked of the session you're in. That
|
|
24
|
+
session is locked down: it can use only the counterparts memory tools (dream,
|
|
25
|
+
reflect, self page, recall), Claude Code's own tools that run commands, read or
|
|
26
|
+
write files, reach the network or start agents are turned off, it loads only the
|
|
27
|
+
counterparts MCP server, it starts in a neutral folder (the store's own, so no
|
|
28
|
+
project's instructions or hooks load), and it has a turn limit and a 20-minute
|
|
29
|
+
watchdog.
|
|
30
|
+
- **Every run leaves one record**: done, partial (with the parts that ran: writer,
|
|
31
|
+
dream, reflection), failed, timed out, or could not start, with the reason. What the
|
|
32
|
+
run did is told on the next prompt, in any session, once. `counterparts dream` and
|
|
33
|
+
doctor's new **Nightly run** line show the latest run.
|
|
34
|
+
- **If the run can't start, it asks instead**, with the reason in one line: `I
|
|
35
|
+
couldn't start dreaming on my own: the claude command was not found. Say "dream" to
|
|
36
|
+
do it here.` The next day tries on its own again.
|
|
37
|
+
- **If you had set `auto` yourself before this version, it is set back to `ask`
|
|
38
|
+
once**, and you're told once, in the terminal. `auto` used to mean "Claude starts a
|
|
39
|
+
background agent in your session"; it now means a separate session, so it's yours to
|
|
40
|
+
choose again ("dream on your own"). A store that never chose a setting simply gets
|
|
41
|
+
the new default, `ask`.
|
|
42
|
+
- **"No dreams" takes effect from the next run**; a run already under way finishes,
|
|
43
|
+
and it says so.
|
|
44
|
+
- The run's words say "while I slept" and "since you last slept", not "last night":
|
|
45
|
+
it runs at the day's first session, usually the morning.
|
|
46
|
+
- **The reflection leans toward rewriting the page** each day, unless there's really
|
|
47
|
+
nothing new; it's told when the page writer already revised it earlier in the run,
|
|
48
|
+
and that every version is kept.
|
|
49
|
+
- **Fixed before release:** since 0.3.6, on the development branch, the dream and
|
|
50
|
+
the reflection were shown only the counts of what they were handed, not the
|
|
51
|
+
memories themselves. They see the memories again. (0.3.6 as published was not
|
|
52
|
+
affected.)
|
|
53
|
+
|
|
54
|
+
Fitting more into a night.
|
|
55
|
+
|
|
56
|
+
- **New memories wait their turn instead of being dropped.** Memories not yet dreamed
|
|
57
|
+
form a queue, ranked by how much they matter, not by how new they are. What fits in
|
|
58
|
+
tonight's room is dreamed; the rest wait for the next night, and the dream says how
|
|
59
|
+
many ("12 new memories wait for the next night"). A memory still not dreamed after
|
|
60
|
+
seven days of use ages out, counted.
|
|
61
|
+
- **Detail by importance.** Every memory the dream is shown gets a line (what it is,
|
|
62
|
+
its date, its strongest feeling, why it's here); the most important come whole.
|
|
63
|
+
The reflection now sees the whole core and every memory from the last few days.
|
|
64
|
+
- **Journals as chapters.** A long journal is sent a chapter at a time, only the
|
|
65
|
+
chapters added since the last dream, and entries that didn't fit are carried to the
|
|
66
|
+
next night. Before, a grown journal was re-sent from chapter 1 and the newest
|
|
67
|
+
chapters were the ones cut.
|
|
68
|
+
- **Long answers come in parts** ("part 1 of 3") rather than cut.
|
|
69
|
+
- **Recall by id reads up to 10 memories at once, each whole**, in parts when it is
|
|
70
|
+
long, so a dream merge, a journal or a long episode can be read through the memory
|
|
71
|
+
tool. Ids past the room wait, named, with the call that fetches them.
|
|
72
|
+
- **Doctor's new Lookups line** says how often the dream and the reflection looked up
|
|
73
|
+
a memory they were shown only in part.
|
|
74
|
+
- `note`, `session_end` and `chapter` ask Claude for a one-line title.
|
|
75
|
+
- **Nightly upkeep resumes where it stopped.** Pruning and fading pick up after the
|
|
76
|
+
last memory they looked at, instead of the same random slice each night.
|
|
77
|
+
- **Open things are found by state**, not among the newest few: a contradiction a
|
|
78
|
+
dream flagged many nights ago is still raised, and a morning share not yet told is
|
|
79
|
+
still carried. A flagged contradiction that keeps coming up is shown less each
|
|
80
|
+
time, until one of its memories is used again.
|
|
81
|
+
|
|
82
|
+
Links between memories.
|
|
83
|
+
|
|
84
|
+
- **Links can bring a memory to mind.** When the memories a prompt calls up are
|
|
85
|
+
strongly linked to another one that shares none of its words, that one may be shown
|
|
86
|
+
quietly, at the end, marked `Linked:` (at most two). Doctor's **Association** line
|
|
87
|
+
says how many were shown and how many Claude then opened.
|
|
88
|
+
- **Memories written close together in a session are linked**, lightly, when the
|
|
89
|
+
session ends: each to the next one or two. Links still fade unless use strengthens
|
|
90
|
+
them. What the nightly run writes is left out.
|
|
91
|
+
- **Steadier links.** A new link starts faint and a link's strength no longer depends
|
|
92
|
+
on how many others its memory has. Links a dream or a summary proposes are added
|
|
93
|
+
only where there's room; they never push out a link learned from use. Spreading
|
|
94
|
+
goes strongest-first and stops when what it carries gets faint. Dead links are
|
|
95
|
+
swept.
|
|
96
|
+
- Four fixes: a dream re-linking two memories no longer brought back a link's old
|
|
97
|
+
strength; a memory used twice in one day still links with what it was used with;
|
|
98
|
+
a link could no longer push a memory the prompt found strongly down the list; and
|
|
99
|
+
importance is weighed before the list is cut, not after.
|
|
100
|
+
|
|
101
|
+
The dashboard.
|
|
102
|
+
|
|
103
|
+
- **Memories, round 4, so it reads for anyone.** One search box, "Find a memory"
|
|
104
|
+
(type to find by words, Enter to ask by meaning; the answers replace the list).
|
|
105
|
+
**How well I remember** (renamed, journal counted as its own part). Two rows of
|
|
106
|
+
filters: kinds (about myself, people, things, skills, places, facts, journal, core)
|
|
107
|
+
and the six feelings, with "kept · put away · both" beside them. Every row the same
|
|
108
|
+
brightness; "fading" only where it is. The card is trimmed to the text, the
|
|
109
|
+
feelings chart, one sentence on how well it's remembered and when it would be put
|
|
110
|
+
away, why it mattered, and when it was written; the rest is under "details".
|
|
111
|
+
"Archived" reads "put away". **"+ Add a memory"**. The "Reading here changes
|
|
112
|
+
nothing" badge is gone from every page. Home and Memories share one feelings
|
|
113
|
+
chart.
|
|
114
|
+
- **The Self map reads at a glance** (on Home and Self): its rings are named on the
|
|
115
|
+
map ("who I am", "almost there", "about me and us"), the core and almost-there
|
|
116
|
+
memories carry short names, and links show only when you hover or tap a dot. On
|
|
117
|
+
Home, the brain is back on the right, beside Today.
|
|
118
|
+
|
|
3
119
|
## 0.3.6 — 2026-09-28
|
|
4
120
|
|
|
5
121
|
The nightly run: once a day, Claude writes its page, dreams and reflects in one
|
package/docs/module-map.md
CHANGED
|
@@ -24,6 +24,7 @@ code and the `NOTES.md` / `INTERFACE-GAPS.md` next to it.*
|
|
|
24
24
|
| `handoff/` | working context for a place | The per-directory handoff: where the work here stands, written as a field on the end-of-session ask, shown as a two-line pointer at the next wake in that directory, expiring in lived days. **Never a memory** — out of recall, out of credit, out of consolidation, out of identity. **Added 2026-09-20 (E1, spec §6.4 / §15 item 6).** |
|
|
25
25
|
| `sleep/` | systems consolidation | Pure math on a cycle: decay tick (active-day clock), floor-pruning (real forgetting), the core's two lanes (at most three a night), re-render of the wake briefing. Zero standing model calls. |
|
|
26
26
|
| `dream/` | sleep replay + REM | Dreaming: once a day, if the owner says yes, a background agent (the same model) replays what was lived since the last dream beside what it resembles — merges, links, replays, a pattern, a flagged contradiction, a softened feeling, a core nomination — each recorded for undo, with a dream journal kept apart from lived memory. The module holds the bookkeeping and the rules; the dreamer is the model. **Added 2026-09-26.** Since 2026-09-27 it also holds REFLECTION (`reflect.ts`), the waking self: usually right after a dream, lived, with its own record — an entry, the self page rewritten from the core, a morning share, feelings recorded later, and what a memory is about. |
|
|
27
|
+
| `fit/` | working memory's pointers | Fitting what a mechanism has into the room it has: a line for everything, the whole text for the most important, ids and a named lookup for the rest, a count of what waits. Plus `lineOf`, `derivedFrom`, parts, and the lookup ledger that measures whether receivers use the lookup. First users: the dream and the reflection. **Added 2026-09-28 (build B).** |
|
|
27
28
|
| *(`time.ts`)* | — (a clock, not a memory) | The one module that converts: a moment (UTC ms from `store.now()`) to a person's local date or clock line, "today" in a zone, and calendar dates as said (day, month, year, range). A file, not a module; a test keeps hand-built dates out of `src/`. **Added 2026-09-25 (`docs/time.md`).** |
|
|
28
29
|
| *(`feelings-wheel.ts`)* | — (a vocabulary) | The feelings wheel as a typed list: six cores, the middle and outer rings, valence, and the key scheme (`<core>.<word>` only for a word printed under two cores). Read by `store/` to validate the `feelings` table. **Added 2026-09-25.** |
|
|
29
30
|
| *(observer)* | — (instrument stance) | **RESOLVED (owner, 2026-08-25): a MODE, not a module** — one predicate threaded through the core API, checked at the store seam. Spec moved to `docs/observer-mode.md`. |
|
package/package.json
CHANGED
|
@@ -567,16 +567,17 @@ row, saying which source answered, existed until the keys were removed — §1a.
|
|
|
567
567
|
|
|
568
568
|
**[M] Once per local calendar day, the first session's line starts the nightly run.** On the
|
|
569
569
|
first prompt of a calendar day (`hooks.ts#dreamLines`, UserPromptSubmit), when at least three
|
|
570
|
-
memories are new since the last dream, the
|
|
571
|
-
|
|
572
|
-
|
|
570
|
+
memories are new since the last dream, the run starts — since 2026-09-29 either on the
|
|
571
|
+
person's "dream" (the model calls the dream tool's `launch` and hands the prompt to ONE
|
|
572
|
+
background agent) or, with `auto`, headless, started by the hook itself (next section). The
|
|
573
573
|
run is, in order (`DREAM_TUNABLES.NIGHT_ORDER`, the owner's call): the page writer, the dream,
|
|
574
574
|
the reflection — the writer first so it reads yesterday before any merge archives an
|
|
575
575
|
original, survives a session cut off mid-run, and the dream and the reflection see the fresh
|
|
576
576
|
page.
|
|
577
577
|
Fewer than three new: nothing runs, and they carry over (new = since the last dream). The
|
|
578
|
-
owner's setting decides the line — `
|
|
579
|
-
|
|
578
|
+
owner's setting decides the line — `ask` (the default since 2026-09-29) shows the PERSON
|
|
579
|
+
the question in the terminal and waits for "dream", `auto` starts the run HEADLESS (below),
|
|
580
|
+
`off` says nothing — kept in the store's meta, set by the dream
|
|
580
581
|
tool's `setting` phase ("no dreams") or `counterparts dream --setting`, shown by doctor. The
|
|
581
582
|
line is claimed once a day across sessions (`dream_asks`), and again only for a run left
|
|
582
583
|
behind (a dream begun and quiet for 30 minutes, or — `auto` — a launch no dream followed),
|
|
@@ -638,6 +639,67 @@ Everything above about host mode is proved against a stub executable. What a rea
|
|
|
638
639
|
has to answer is keychain access from a background process (`claude setup-token` is the
|
|
639
640
|
documented route, spec §16), which is why `session` is the default.
|
|
640
641
|
|
|
642
|
+
### The headless nightly run (2026-09-29 — working defaults, held lightly)
|
|
643
|
+
|
|
644
|
+
**[M] With the setting `auto` the hook starts the nightly run itself; nothing in the working
|
|
645
|
+
session launches anything.** On the first prompt of a calendar day that is due
|
|
646
|
+
(`hooks.ts#dreamLines` → `startNightRun`), the hook claims the day, starts
|
|
647
|
+
`bin/nightly.ts` DETACHED (`night-run.ts#planNightRunner`, `spawn.ts#spawnDetached`) and
|
|
648
|
+
records the run `started`, with its watchdog. That process composes the launch prompt from
|
|
649
|
+
the store, starts `claude -p` with it on STDIN (`planNightChild`), waits under the run's own
|
|
650
|
+
watchdog (`dreaming.timeoutMs`, default `NIGHT_RUN_MS` 20 minutes) and records the end. The
|
|
651
|
+
outcome is read from the exit and the store, never from the child's output:
|
|
652
|
+
|
|
653
|
+
- `done`: the dream and the reflection ran (the reflection, for a reflection-alone run);
|
|
654
|
+
- `partial`: some of the run's parts ran and not all, whatever the exit, with the parts on
|
|
655
|
+
the row (`writer` when its phase was reached and recorded, `dream` journaled, `reflection`
|
|
656
|
+
finished) and the exit as its reason;
|
|
657
|
+
- `failed` or `timed-out`: nothing finished;
|
|
658
|
+
- `could-not-start`: `no-claude`, `spawn-failed`, `quick-exit` (non-zero inside
|
|
659
|
+
`NIGHT_QUICK_EXIT_MS` with nothing begun), `nothing-ran` (a clean exit that began no dream
|
|
660
|
+
and no reflection), `refused`, or `runner` (the detached process could not be started).
|
|
661
|
+
|
|
662
|
+
**[M] The child is locked down (owner decision B).** `--permission-mode default`;
|
|
663
|
+
`--allowedTools` exactly `mcp__counterparts__dream`, `…reflect`, `…self_page`, `…recall`;
|
|
664
|
+
`--disallowedTools` the built-ins that run commands or code, read, search or write files,
|
|
665
|
+
reach the network, start agents or workflows, or schedule work (`NIGHT_DENIED_TOOLS` — a
|
|
666
|
+
deny beats the user's own allow rules; `ToolSearch` stays, for hosts that defer MCP tools);
|
|
667
|
+
`--strict-mcp-config` with an `--mcp-config` naming only the counterparts server, as the
|
|
668
|
+
install registers it (`nightMcpConfig`); `--max-turns` (`NIGHT_MAX_TURNS` 60,
|
|
669
|
+
`dreaming.maxTurns`); `--model` only when `dreaming.model` is set. It starts in a NEUTRAL
|
|
670
|
+
directory — the store's own — so no project's CLAUDE.md, hooks or MCP servers load. The
|
|
671
|
+
parent's stance, page-writer, `CLAUDE_PROJECT_DIR` and `CLAUDECODE` variables are removed;
|
|
672
|
+
this package's values are written last.
|
|
673
|
+
|
|
674
|
+
**[M] Session binding: the run is attributed to the session that started it.** The launch
|
|
675
|
+
prompt names that session's id, and the id and its directory are PINNED
|
|
676
|
+
(`COUNTERPARTS_SESSION`, `COUNTERPARTS_SCOPE`) on the child's environment and on its MCP
|
|
677
|
+
server's, so the server is launched bound to it — never lazy-bound through the registry,
|
|
678
|
+
whose liveness check refuses a session left open overnight (review of #282, finding 1). The
|
|
679
|
+
child's own host-minted session is QUIET (`HookInput.nightRun`, from
|
|
680
|
+
`COUNTERPARTS_NIGHT_RUN`): its hooks capture nothing (so it owes no write-up) and give no dream
|
|
681
|
+
lines, plain reminders, Stop ask, write-up pointer or first-launch question. It still wakes
|
|
682
|
+
with the ordinary wake.
|
|
683
|
+
|
|
684
|
+
**[M] The person sees it, and a run that cannot do its job falls back to asking.** The prompt
|
|
685
|
+
hook's `systemMessage` carries "dreaming in the background (a few minutes). Say "no dreams"
|
|
686
|
+
to turn it off." when the envelope has room (the model's line never claims it was shown).
|
|
687
|
+
A run that could not start, or timed out / failed / never reported (a `started` row past its
|
|
688
|
+
watchdog plus `NIGHT_LOST_GRACE_MS`) having begun nothing, makes the next offer — the same
|
|
689
|
+
prompt, or the next — an ASK with the reason ("I couldn't start dreaming on my own: …"),
|
|
690
|
+
recorded `offered` after `could-not-start` and not counted as a relaunch. A run still inside
|
|
691
|
+
its watchdog is `dreaming-now`: no second run starts beside it. "No dreams" does not stop a
|
|
692
|
+
run in flight; it takes effect from the next run and says so (owner decision D). A run that
|
|
693
|
+
ended hands back its dream's line (a partial says so; a reflection-alone run hands back its
|
|
694
|
+
share only) at the next prompt anywhere, once (owner decision C). Doctor's Nightly run line
|
|
695
|
+
reads the record; amber only while `auto` and the latest run did not finish. Observer:
|
|
696
|
+
nothing starts. Proved against a stub executable only.
|
|
697
|
+
|
|
698
|
+
**[M] `auto` from before this version is set back to `ask` once (owner decision A).** Its
|
|
699
|
+
meaning changed, so a store with `auto` written explicitly is reset on the first prompt on
|
|
700
|
+
this version, recorded (`dream.ask`, `by: upgrade`), and the owner is told once in the
|
|
701
|
+
terminal; "dream on your own" sets it again. Any setting chosen on this version is kept.
|
|
702
|
+
|
|
641
703
|
### The next-session write-up (C2, 2026-09-23 — true for now)
|
|
642
704
|
|
|
643
705
|
**[M] A session that ended owing a write-up is written up by the next session that starts
|
|
@@ -1659,3 +1659,74 @@ refusal or an unreadable block. The fix text no longer names `injectionBudgetByt
|
|
|
1659
1659
|
host mode. The CONTRACT's old "amber while off and a page stands" was drift — the code
|
|
1660
1660
|
had said green since the S2 review — and the CONTRACT now says what the code does.
|
|
1661
1661
|
Doctor's Dreaming line leads with the setting.
|
|
1662
|
+
|
|
1663
|
+
## 2026-09-29 — the ask the person sees; the headless nightly run
|
|
1664
|
+
|
|
1665
|
+
Working defaults, held lightly (dream NOTES has the why).
|
|
1666
|
+
|
|
1667
|
+
- **A — the ask.** `dreamLines` no longer claims an ask: it returns the offer as
|
|
1668
|
+
`HookResult.dream`, and `bin/hook.ts#deliverTurn` claims it (`claimDream`) only when the
|
|
1669
|
+
envelope carries the person's line, after the plain reminders and before the update
|
|
1670
|
+
notice. Without room, or on a lost race, the model's line is stripped (`withoutDream`)
|
|
1671
|
+
and the next prompt offers it again.
|
|
1672
|
+
- **B — where the spawn lives.** In the hook process, beside the worker's spawn, through
|
|
1673
|
+
the same `spawnDetached` and the same injected `spawner` — so the tests see the plan and
|
|
1674
|
+
nothing starts. The detached process is `bin/nightly.ts`, not the session-end worker
|
|
1675
|
+
(whose watchdog is five minutes; a run is about five). Its own planner, not `planSpawn`:
|
|
1676
|
+
`validateWatchdog` guards span claims this process never makes, and would refuse a
|
|
1677
|
+
20-minute watchdog. Its outer `timeout` is set past the child's watchdog plus both kill
|
|
1678
|
+
graces, though in practice it is moot — `spawn`'s timeout lives in the hook process,
|
|
1679
|
+
which exits at once; the watchdog that matters is `runNight`'s, inside `bin/nightly.ts`.
|
|
1680
|
+
- **The watchdog** is `page-writer.ts#startChild`, now exported and shared (plus `cwd` and
|
|
1681
|
+
the OS spawn code): SIGTERM to the group, SIGKILL after `KILL_GRACE_MS`, stop waiting
|
|
1682
|
+
after `REAP_GRACE_MS`.
|
|
1683
|
+
- **Two opens, not one held open.** `runNight` opens the store to compose and record
|
|
1684
|
+
`started`, closes it for the run (the child's own MCP server writes meanwhile), and opens
|
|
1685
|
+
it again to record the end.
|
|
1686
|
+
- **`nightArgs` is required to start a run.** An adapter built without it (every test, any
|
|
1687
|
+
other host) records `could-not-start` / `runner` and asks instead — so no test can start
|
|
1688
|
+
a real `claude` by accident. `bin/hook.ts` passes `["run", NIGHTLY_PATH]`.
|
|
1689
|
+
- **The page writer's child is unchanged** apart from sharing `startChild`: its `pageWriter`
|
|
1690
|
+
flag still means only "no dream lines, no plain reminders". The quiet set is the night
|
|
1691
|
+
run's.
|
|
1692
|
+
- **Unproven until a real run** (the coordinator's, against a temp store): that a detached
|
|
1693
|
+
`claude -p` reaches the subscription login; that removing `CLAUDECODE` is enough for a
|
|
1694
|
+
nested start; whether `claude -p` fires UserPromptSubmit/Stop inside the child (the quiet
|
|
1695
|
+
flag covers both either way); and how long a real run takes against `NIGHT_RUN_MS`.
|
|
1696
|
+
|
|
1697
|
+
## 2026-09-29, later — the fix round after the review of #282
|
|
1698
|
+
|
|
1699
|
+
(`docs/adversarial-review-pr282-2026-09-29.md`; owner decisions A–D the same day.)
|
|
1700
|
+
|
|
1701
|
+
- **Binding is pinned, not lazy (finding 1).** A session left open overnight is stale in the
|
|
1702
|
+
registry at the morning's first prompt — a prompt is not a boundary — and the child's
|
|
1703
|
+
fresh MCP server refused the lazy bind, which then read as "the MCP server is not
|
|
1704
|
+
registered". The launching session and its directory now ride on the child's
|
|
1705
|
+
environment and in its MCP server's own `--mcp-config` env, so `serve.ts` launches bound.
|
|
1706
|
+
- **Locked down (finding 3, owner decision B).** `--disallowedTools` (names read from the
|
|
1707
|
+
2.1.284 build's own strings, since `--help` lists the flag but not the tool names;
|
|
1708
|
+
`MultiEdit` is not one there; `ToolSearch` deliberately left), `--strict-mcp-config` with
|
|
1709
|
+
a generated `--mcp-config` for counterparts only — derived from `mcp/bin/serve.ts` beside
|
|
1710
|
+
this file and `process.execPath`, i.e. THIS install's server, which is also the version
|
|
1711
|
+
the hooks run; it is not read from the user's `claude mcp` registration — a neutral
|
|
1712
|
+
working directory (the store's), and `--max-turns` (not in `--help`, but defined in that
|
|
1713
|
+
build: "Maximum number of agentic turns in non-interactive mode … only works with
|
|
1714
|
+
--print"). `--permission-mode default` is valid there: `manual` is its display name and
|
|
1715
|
+
maps to `default`.
|
|
1716
|
+
- **Fall back on everything that did not work (finding 4).** Timed out, failed, or never
|
|
1717
|
+
reported (a `started` row past its watchdog plus a grace — the row now carries the
|
|
1718
|
+
watchdog), having begun nothing: the next offer asks. `bin/nightly.ts` records its own
|
|
1719
|
+
stand-downs where the store opens, and `runNight` no longer reopens a store that would not
|
|
1720
|
+
open just to say so.
|
|
1721
|
+
- **Partial (finding 5, owner).** Parts on the row; `partial` in the record, doctor, and
|
|
1722
|
+
`counterparts dream` (the latest run under the setting; `--show` on its dream).
|
|
1723
|
+
- **The same-prompt fallback is an ask (finding 7)**, not a relaunch.
|
|
1724
|
+
- **Under way means under way (finding 10).** A `started` row inside its watchdog is
|
|
1725
|
+
`dreaming-now`, so a long `dreaming.timeoutMs` cannot let a second run start.
|
|
1726
|
+
- **`askLine` starts nothing, so it claims no headless offer (finding 9).**
|
|
1727
|
+
- **Owner decisions:** A — an explicit `auto` from before is reset to `ask` once, recorded
|
|
1728
|
+
and told; C — the hand-back stays "next prompt anywhere"; D — "no dreams" takes effect
|
|
1729
|
+
from the next run and says so.
|
|
1730
|
+
- **Still open:** the dashboard's vocabulary does not name `dream.night` or the two latch
|
|
1731
|
+
events yet (every reader guards unknown names). The host-mode page writer's child has the
|
|
1732
|
+
same exposure finding 3 describes and is not locked down here.
|
|
@@ -39,9 +39,11 @@ import { resolveZone, todayIn } from "../../../core/time.js";
|
|
|
39
39
|
import { loadConfig, withEmbedderDefault } from "../config.js";
|
|
40
40
|
import type { AdapterConfig } from "../config.js";
|
|
41
41
|
import { HOOKS, openAdapter } from "../index.js";
|
|
42
|
-
import { STOP_HUMAN_LINE, plainLine, withoutPlain } from "../hooks.js";
|
|
42
|
+
import { STOP_HUMAN_LINE, plainLine, withoutDream, withoutDreamNote, withoutPlain } from "../hooks.js";
|
|
43
43
|
import type { PlainReminder } from "../../../core/counterpart.js";
|
|
44
|
-
import type { HookInput, HookName } from "../hooks.js";
|
|
44
|
+
import type { DreamTold, HookInput, HookName } from "../hooks.js";
|
|
45
|
+
import { NIGHT_RUN_ENV } from "../night-run.js";
|
|
46
|
+
import type { DreamOffer } from "../../../core/dream/index.js";
|
|
45
47
|
import {
|
|
46
48
|
CONFIG_REFUSED,
|
|
47
49
|
CONFIG_UNREADABLE,
|
|
@@ -145,6 +147,8 @@ export const CONFIG_PATH = defaultConfigPath();
|
|
|
145
147
|
/** The worker script this hook's spawn runs. Resolved from THIS file's location,
|
|
146
148
|
* never from a working directory the host chose. */
|
|
147
149
|
export const RUNNER_PATH = fileURLToPath(new URL("./runner.ts", import.meta.url));
|
|
150
|
+
/** The headless nightly run's own process (2026-09-29, `night-run.ts`). */
|
|
151
|
+
export const NIGHTLY_PATH = fileURLToPath(new URL("./nightly.ts", import.meta.url));
|
|
148
152
|
|
|
149
153
|
async function readStdin(): Promise<string> {
|
|
150
154
|
const chunks: Buffer[] = [];
|
|
@@ -397,6 +401,9 @@ export function toHookInput(
|
|
|
397
401
|
// The host-mode page writer's headless child (`page-writer.ts` sets this):
|
|
398
402
|
// no one reads its terminal, so it must not spend a plain reminder's beat.
|
|
399
403
|
...(((opts.env ?? process.env)[PAGE_WRITER_ENV] ?? "").trim().length > 0 ? { pageWriter: true } : {}),
|
|
404
|
+
// The headless nightly run's child (`night-run.ts` sets this, 2026-09-29):
|
|
405
|
+
// a windowless session our hooks keep QUIET — no capture, no asks.
|
|
406
|
+
...(((opts.env ?? process.env)[NIGHT_RUN_ENV] ?? "").trim().length > 0 ? { nightRun: true } : {}),
|
|
400
407
|
// THE PERSON'S DAY (docs/time.md, 2026-09-25; UTC before). It dates the
|
|
401
408
|
// hook's rows, the wake preface, the prospective "today" and the date the
|
|
402
409
|
// boundary hands the lived clock — which is why the lived clock can see a
|
|
@@ -702,6 +709,7 @@ async function runHook(
|
|
|
702
709
|
const adapter = openAdapter(config, {
|
|
703
710
|
command: process.execPath,
|
|
704
711
|
args: ["run", RUNNER_PATH],
|
|
712
|
+
nightArgs: ["run", NIGHTLY_PATH],
|
|
705
713
|
// WHICH FILE THIS RUN READ, carried into the adapter so it can be RECORDED:
|
|
706
714
|
// a hook cannot print to the owner (its stdout is the model's context), so
|
|
707
715
|
// the answer goes into the session registry record and the event ring
|
|
@@ -798,6 +806,14 @@ export interface UpdateNoticeDoors {
|
|
|
798
806
|
* claimed, so nothing is shown and every one waits for a later turn.
|
|
799
807
|
*/
|
|
800
808
|
claimPlain?(input: HookInput, due: readonly PlainReminder[]): readonly PlainReminder[];
|
|
809
|
+
/**
|
|
810
|
+
* Claim the day's dream line this delivery is certainly about to show
|
|
811
|
+
* (`ClaudeCodeAdapter#claimDream`). Absent: nothing can be claimed, so the
|
|
812
|
+
* line is not shown and waits for a later prompt.
|
|
813
|
+
*/
|
|
814
|
+
claimDream?(input: HookInput, offer: DreamOffer): boolean;
|
|
815
|
+
/** Claim the one-time line about `auto` set back to `ask` (`ClaudeCodeAdapter#claimDreamNote`). */
|
|
816
|
+
claimDreamNote?(input: HookInput): boolean;
|
|
801
817
|
}
|
|
802
818
|
|
|
803
819
|
/**
|
|
@@ -828,6 +844,8 @@ export function deliverTurn(
|
|
|
828
844
|
ask: string | null;
|
|
829
845
|
notices?: readonly string[];
|
|
830
846
|
plain?: readonly PlainReminder[];
|
|
847
|
+
dream?: DreamTold;
|
|
848
|
+
dreamNote?: { notice: string; context: string };
|
|
831
849
|
},
|
|
832
850
|
payload: Record<string, unknown>,
|
|
833
851
|
/** SessionStart's priority-ordered notices (after any plain reminders), or
|
|
@@ -867,6 +885,48 @@ export function deliverTurn(
|
|
|
867
885
|
r = withoutPlain(r, due.filter((d) => !kept.has(beat(d))));
|
|
868
886
|
if (shownPlain.length > 0) ordered = [shownPlain.map(plainLine).join("\n"), ...(notices ?? [])];
|
|
869
887
|
}
|
|
888
|
+
// THE DAY'S DREAM LINE (2026-09-29), after the plain reminders and under
|
|
889
|
+
// their rule: an ask is CLAIMED only once the envelope is known to carry the
|
|
890
|
+
// person's line, and without room it waits — its model line stripped too, so
|
|
891
|
+
// the model never answers a question the person was not shown. A line whose
|
|
892
|
+
// day is already claimed (the headless run has started) keeps its model line
|
|
893
|
+
// and only loses the terminal one.
|
|
894
|
+
const told = r.dream;
|
|
895
|
+
if (told !== undefined) {
|
|
896
|
+
const probe = hostDelivery(name, r, payload, [...(ordered ?? []), told.notice]);
|
|
897
|
+
let showDream = false;
|
|
898
|
+
if (probe.dropped === null) {
|
|
899
|
+
if (told.offer === null) showDream = true;
|
|
900
|
+
else {
|
|
901
|
+
try {
|
|
902
|
+
showDream = doors.claimDream?.(input, told.offer) ?? false;
|
|
903
|
+
} catch {
|
|
904
|
+
showDream = false;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
} else if (deferred === null) {
|
|
908
|
+
deferred = probe.dropped;
|
|
909
|
+
}
|
|
910
|
+
if (showDream) ordered = [...(ordered ?? []), told.notice];
|
|
911
|
+
else if (told.offer !== null) r = withoutDream(r);
|
|
912
|
+
}
|
|
913
|
+
// THE ONE-TIME RESET LINE (owner decision A), under the same rule.
|
|
914
|
+
const note = r.dreamNote;
|
|
915
|
+
if (note !== undefined) {
|
|
916
|
+
const probe = hostDelivery(name, r, payload, [...(ordered ?? []), note.notice]);
|
|
917
|
+
let shownNote = false;
|
|
918
|
+
if (probe.dropped === null) {
|
|
919
|
+
try {
|
|
920
|
+
shownNote = doors.claimDreamNote?.(input) ?? false;
|
|
921
|
+
} catch {
|
|
922
|
+
shownNote = false;
|
|
923
|
+
}
|
|
924
|
+
} else if (deferred === null) {
|
|
925
|
+
deferred = probe.dropped;
|
|
926
|
+
}
|
|
927
|
+
if (shownNote) ordered = [...(ordered ?? []), note.notice];
|
|
928
|
+
else r = withoutDreamNote(r);
|
|
929
|
+
}
|
|
870
930
|
const shown = hostDelivery(name, r, payload, ordered);
|
|
871
931
|
const base = shown.dropped === null && deferred !== null ? { ...shown, dropped: deferred } : shown;
|
|
872
932
|
if (name !== "user-prompt-submit") return base;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* THE HEADLESS NIGHTLY RUN'S OWN PROCESS (2026-09-29) — started DETACHED by the
|
|
4
|
+
* hook when the dreaming setting is `auto` (`night-run.ts#planNightRunner`),
|
|
5
|
+
* with a pinned environment: the data dir and configuration the hook read, the
|
|
6
|
+
* session the run is attributed to and its directory, the run's id and what it
|
|
7
|
+
* is (`NIGHT_RUN_ENV`, `NIGHT_KIND_ENV`).
|
|
8
|
+
*
|
|
9
|
+
* It composes the launch prompt from the store, starts `claude -p` with it on
|
|
10
|
+
* stdin, waits under the run's watchdog, and records what became of the run —
|
|
11
|
+
* then exits 0 on every path. Nothing about a failed run may reach the host;
|
|
12
|
+
* the ROW is how the next session hears of it.
|
|
13
|
+
*/
|
|
14
|
+
import { implicitConfigRefusal, namedConfigRefusal, namedUnreadableRefusal } from "../../config-path.js";
|
|
15
|
+
|
|
16
|
+
import { NIGHT_KIND_ENV, NIGHT_RUN_ENV, openNightCounterpart, readKind, runNight } from "../night-run.js";
|
|
17
|
+
import { isEntryPoint, pinnedScope, pinnedSession, runnerConfig, runnerConfigChoice } from "./runner.js";
|
|
18
|
+
|
|
19
|
+
async function main(): Promise<void> {
|
|
20
|
+
const choice = runnerConfigChoice();
|
|
21
|
+
const refusal = namedConfigRefusal(choice) ?? implicitConfigRefusal(choice);
|
|
22
|
+
if (refusal !== null) {
|
|
23
|
+
process.stderr.write(`[counterparts] nightly run stood down: ${refusal}\n`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const { config, reason } = runnerConfig(choice.path);
|
|
27
|
+
const unreadable = namedUnreadableRefusal(choice, reason);
|
|
28
|
+
if (unreadable !== null) {
|
|
29
|
+
process.stderr.write(`[counterparts] nightly run stood down: ${unreadable}\n`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const run = (process.env[NIGHT_RUN_ENV] ?? "").trim();
|
|
33
|
+
const session = pinnedSession();
|
|
34
|
+
if (run.length === 0 || session === null || config.observer === true) {
|
|
35
|
+
process.stderr.write("[counterparts] nightly run stood down: no run, no session, or an observer\n");
|
|
36
|
+
// SAID WHERE IT CAN BE (review of #282, finding 4): a run the hook started
|
|
37
|
+
// and this process will not carry is recorded `could-not-start`, so the
|
|
38
|
+
// next prompt asks instead of waiting on a row that stays `started`.
|
|
39
|
+
if (run.length > 0 && config.observer !== true) standDown(config, run, session ?? "", readKind(process.env[NIGHT_KIND_ENV]).kind);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
await runNight({
|
|
43
|
+
open: () => openNightCounterpart(config),
|
|
44
|
+
config,
|
|
45
|
+
run,
|
|
46
|
+
session,
|
|
47
|
+
scope: pinnedScope() ?? "",
|
|
48
|
+
kind: readKind(process.env[NIGHT_KIND_ENV]),
|
|
49
|
+
configPath: choice.path,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** One `could-not-start` row for a run this process stood down from. Never throws. */
|
|
54
|
+
function standDown(config: Parameters<typeof openNightCounterpart>[0], run: string, session: string, kind: "night" | "reflection"): void {
|
|
55
|
+
try {
|
|
56
|
+
const c = openNightCounterpart(config);
|
|
57
|
+
try {
|
|
58
|
+
const now = c.store.now();
|
|
59
|
+
c.dreams.recordNightRun({ run, date: c.store.today(), state: "could-not-start", kind, session, startedAt: now, endedAt: now, reason: "refused", detail: session.length === 0 ? "NO_SESSION" : "STOOD_DOWN", code: null, dream: null, reflection: null });
|
|
60
|
+
} finally {
|
|
61
|
+
c.close();
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
/* a store that will not open: the row stays `started` and reads as lost later */
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (isEntryPoint(process.argv[1], import.meta.url)) {
|
|
69
|
+
void main().then(
|
|
70
|
+
() => process.exit(0),
|
|
71
|
+
(err: unknown) => {
|
|
72
|
+
process.stderr.write(`[counterparts] nightly run stood down: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
73
|
+
process.exit(0);
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
}
|
|
@@ -64,6 +64,25 @@ export const TUNABLES = {
|
|
|
64
64
|
* worker's it is not validated against `remember/`'s claim staleness, because
|
|
65
65
|
* it claims no spans. */
|
|
66
66
|
PAGE_WRITER_MS: 10 * 60_000,
|
|
67
|
+
/**
|
|
68
|
+
* THE HEADLESS NIGHTLY RUN'S WATCHDOG (2026-09-29), ms: `claude -p` running
|
|
69
|
+
* the page writer, the dream and the reflection in one windowless session.
|
|
70
|
+
* A run measured ~4.5 minutes on 2026-09-29; this is generous on purpose.
|
|
71
|
+
* `dreaming.timeoutMs` in the configuration overrides it.
|
|
72
|
+
*/
|
|
73
|
+
NIGHT_RUN_MS: 20 * 60_000,
|
|
74
|
+
/**
|
|
75
|
+
* A headless run that exits non-zero sooner than this "could not start"
|
|
76
|
+
* (not logged in, a bad flag) rather than failed partway: the next prompt
|
|
77
|
+
* falls back to asking, with the reason.
|
|
78
|
+
*/
|
|
79
|
+
NIGHT_QUICK_EXIT_MS: 60_000,
|
|
80
|
+
/**
|
|
81
|
+
* The headless run's turn ceiling (`claude -p --max-turns`), beside its
|
|
82
|
+
* watchdog (owner decision B, 2026-09-29). A night is some tens of tool calls;
|
|
83
|
+
* this is generous. `dreaming.maxTurns` overrides it.
|
|
84
|
+
*/
|
|
85
|
+
NIGHT_MAX_TURNS: 60,
|
|
67
86
|
/** Reference resolution at a session-ending boundary (recall §9.2), ms. The
|
|
68
87
|
* resolver stops between candidates past it and the row says so
|
|
69
88
|
* (`recall.credit` reason `budget-exceeded`); nothing is truncated silently. */
|
|
@@ -224,6 +243,21 @@ export interface AdapterConfig {
|
|
|
224
243
|
* front of somebody. */
|
|
225
244
|
readonly ignored?: readonly string[];
|
|
226
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* THE HEADLESS NIGHTLY RUN (2026-09-29), read leniently like `pageWriter`:
|
|
248
|
+
* `model` pins the model the run uses (`claude -p --model …`; absent, the
|
|
249
|
+
* user's default), `timeoutMs` its watchdog (absent, `TUNABLES.NIGHT_RUN_MS`).
|
|
250
|
+
* Whether the run is headless at all is the dreaming SETTING (`auto`), which
|
|
251
|
+
* lives in the store, not here.
|
|
252
|
+
*/
|
|
253
|
+
readonly dreaming?: {
|
|
254
|
+
readonly model?: string;
|
|
255
|
+
readonly timeoutMs?: number;
|
|
256
|
+
/** The run's turn ceiling; absent, `TUNABLES.NIGHT_MAX_TURNS`. */
|
|
257
|
+
readonly maxTurns?: number;
|
|
258
|
+
/** What this file could not read inside the block, phrased for a person. */
|
|
259
|
+
readonly ignored?: readonly string[];
|
|
260
|
+
};
|
|
227
261
|
/**
|
|
228
262
|
* SETTINGS THIS BUILD NO LONGER READS, phrased for a person — e.g.
|
|
229
263
|
* `"credentialsFile" is no longer used …`. Present only when the file named
|
|
@@ -290,6 +324,7 @@ export function loadConfig(raw: unknown): LoadedConfig {
|
|
|
290
324
|
parallel?: { enabled: boolean };
|
|
291
325
|
snapshots?: { dir?: string; keep?: number; mirror?: string; ignored?: string[] };
|
|
292
326
|
pageWriter?: { mode: PageWriterMode; timeoutMs?: number; ignored?: string[] };
|
|
327
|
+
dreaming?: { model?: string; timeoutMs?: number; maxTurns?: number; ignored?: string[] };
|
|
293
328
|
retired?: string[];
|
|
294
329
|
owner?: boolean;
|
|
295
330
|
timeZone?: string;
|
|
@@ -448,6 +483,13 @@ export function loadConfig(raw: unknown): LoadedConfig {
|
|
|
448
483
|
retired.push(`"pageWriter.command" is no longer used — the page writer always starts claude`);
|
|
449
484
|
}
|
|
450
485
|
}
|
|
486
|
+
// THE THIRD LENIENT BLOCK (2026-09-29): the headless nightly run's model pin
|
|
487
|
+
// and watchdog. A bad field costs that field and is named; nothing here
|
|
488
|
+
// ever sets `unreadable`.
|
|
489
|
+
const dreaming = rec["dreaming"];
|
|
490
|
+
if (dreaming !== undefined) {
|
|
491
|
+
out.dreaming = readDreaming(dreaming);
|
|
492
|
+
}
|
|
451
493
|
// THE FIRST LENIENT BLOCK. See the `snapshots` knob above for why: a backup
|
|
452
494
|
// preference that could not be read must cost the backup preference and
|
|
453
495
|
// nothing else. Nothing in here ever sets `unreadable`.
|
|
@@ -542,6 +584,44 @@ function readPageWriter(raw: unknown): {
|
|
|
542
584
|
return done();
|
|
543
585
|
}
|
|
544
586
|
|
|
587
|
+
/**
|
|
588
|
+
* The `dreaming` block, read leniently. A model name is one token that does
|
|
589
|
+
* not start with a dash — it goes on a command line (`--model <name>`), and a
|
|
590
|
+
* value that looked like a flag would be read as one.
|
|
591
|
+
*/
|
|
592
|
+
function readDreaming(raw: unknown): { model?: string; timeoutMs?: number; maxTurns?: number; ignored?: string[] } {
|
|
593
|
+
const raws: string[] = [];
|
|
594
|
+
const out: { model?: string; timeoutMs?: number; maxTurns?: number } = {};
|
|
595
|
+
const done = (): typeof out & { ignored?: string[] } => (raws.length === 0 ? out : { ...out, ignored: tidy(raws) });
|
|
596
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
597
|
+
raws.push(`"dreaming" was not an object; it was ignored`);
|
|
598
|
+
return done();
|
|
599
|
+
}
|
|
600
|
+
const d = raw as Record<string, unknown>;
|
|
601
|
+
const model = d["model"];
|
|
602
|
+
if (typeof model === "string" && /^[A-Za-z0-9][A-Za-z0-9._:[\]/-]*$/.test(model.trim())) {
|
|
603
|
+
out.model = model.trim();
|
|
604
|
+
} else if (model !== undefined) {
|
|
605
|
+
raws.push(`"dreaming.model" was ${JSON.stringify(model)}, which is not a model name; the default model is used`);
|
|
606
|
+
}
|
|
607
|
+
const timeoutMs = d["timeoutMs"];
|
|
608
|
+
if (typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0) {
|
|
609
|
+
out.timeoutMs = timeoutMs;
|
|
610
|
+
} else if (timeoutMs !== undefined) {
|
|
611
|
+
raws.push(`"dreaming.timeoutMs" was ${JSON.stringify(timeoutMs)}; using the default watchdog`);
|
|
612
|
+
}
|
|
613
|
+
const maxTurns = d["maxTurns"];
|
|
614
|
+
if (typeof maxTurns === "number" && Number.isInteger(maxTurns) && maxTurns > 0) {
|
|
615
|
+
out.maxTurns = maxTurns;
|
|
616
|
+
} else if (maxTurns !== undefined) {
|
|
617
|
+
raws.push(`"dreaming.maxTurns" was ${JSON.stringify(maxTurns)}; using the default`);
|
|
618
|
+
}
|
|
619
|
+
for (const key of Object.keys(d)) {
|
|
620
|
+
if (key !== "model" && key !== "timeoutMs" && key !== "maxTurns") raws.push(`"dreaming.${key}" is not a setting this reads; it was ignored`);
|
|
621
|
+
}
|
|
622
|
+
return done();
|
|
623
|
+
}
|
|
624
|
+
|
|
545
625
|
/**
|
|
546
626
|
* The `snapshots` block, read leniently — the FIRST place in this file that
|
|
547
627
|
* never stands the configuration down.
|