@awebai/oats 0.60.0 → 0.62.0

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.
Files changed (96) hide show
  1. package/README.md +15 -19
  2. package/bin/oats.mjs +68 -21
  3. package/docs/capabilities.md +1 -1
  4. package/docs/configuration.md +9 -0
  5. package/docs/desktop-cli-api.md +28 -5
  6. package/docs/desktop.md +7 -0
  7. package/docs/execution-targets.md +49 -3
  8. package/docs/first-team.md +8 -0
  9. package/docs/implementation.md +2 -1
  10. package/docs/named-test-runs.md +382 -0
  11. package/docs/official-catalog.md +1 -1
  12. package/docs/packages.md +5 -5
  13. package/docs/release-notes/v0.61.0.md +155 -0
  14. package/docs/release-notes/v0.62.0.md +223 -0
  15. package/docs/tui.md +10 -4
  16. package/docs/upgrading.md +133 -11
  17. package/docs/workspaces.md +1 -1
  18. package/lib/core.mjs +2 -2
  19. package/lib/doctor-capture.mjs +35 -0
  20. package/lib/session-viewer.mjs +86 -7
  21. package/package-catalog.json +1 -1
  22. package/package.json +1 -1
  23. package/packages/client/cli-locator.mjs +2 -2
  24. package/packages/client/instance-presentation.mjs +10 -0
  25. package/packages/client/instance-tree.mjs +48 -6
  26. package/packages/record/README.md +87 -13
  27. package/packages/record/bin/capture-hook.mjs +8 -0
  28. package/packages/record/bin/capture.mjs +143 -124
  29. package/packages/record/bin/recall.mjs +8 -3
  30. package/packages/record/bin/setup.mjs +115 -225
  31. package/packages/record/bin/turn-record.mjs +2 -2
  32. package/packages/record/docs/capture-service.md +1443 -28
  33. package/packages/record/docs/capture-status.schema.json +429 -12
  34. package/packages/record/lib/capture-admission.mjs +82 -0
  35. package/packages/record/lib/capture-aw-unit.mjs +137 -0
  36. package/packages/record/lib/capture-aw.mjs +31 -12
  37. package/packages/record/lib/capture-budget.mjs +31 -0
  38. package/packages/record/lib/capture-cc.mjs +39 -6
  39. package/packages/record/lib/capture-cleanup-queue.mjs +135 -0
  40. package/packages/record/lib/capture-cleanup-work.mjs +77 -0
  41. package/packages/record/lib/capture-command-operation.mjs +37 -0
  42. package/packages/record/lib/capture-command-output.mjs +61 -0
  43. package/packages/record/lib/capture-command-worker.mjs +6 -0
  44. package/packages/record/lib/capture-command.mjs +48 -0
  45. package/packages/record/lib/capture-completion.mjs +152 -0
  46. package/packages/record/lib/capture-context.mjs +50 -0
  47. package/packages/record/lib/capture-default-roots.mjs +30 -0
  48. package/packages/record/lib/capture-discovery.mjs +114 -0
  49. package/packages/record/lib/capture-failures.mjs +45 -0
  50. package/packages/record/lib/capture-health-doctor.mjs +13 -0
  51. package/packages/record/lib/capture-health-installation.mjs +117 -0
  52. package/packages/record/lib/capture-health.mjs +116 -0
  53. package/packages/record/lib/capture-hook-ownership.mjs +58 -0
  54. package/packages/record/lib/capture-hook-runner.mjs +17 -0
  55. package/packages/record/lib/capture-hook.mjs +26 -0
  56. package/packages/record/lib/capture-index-inventory.mjs +205 -0
  57. package/packages/record/lib/capture-index-outcomes.mjs +113 -0
  58. package/packages/record/lib/capture-index-reset.mjs +109 -0
  59. package/packages/record/lib/capture-index-work.mjs +77 -0
  60. package/packages/record/lib/capture-issue-preparation.mjs +73 -0
  61. package/packages/record/lib/capture-issues.mjs +15 -2
  62. package/packages/record/lib/capture-lock.mjs +102 -16
  63. package/packages/record/lib/capture-native-unit.mjs +322 -0
  64. package/packages/record/lib/capture-pass.mjs +102 -0
  65. package/packages/record/lib/capture-recovery-snapshot.mjs +182 -0
  66. package/packages/record/lib/capture-retained-scratch.mjs +213 -0
  67. package/packages/record/lib/capture-retry.mjs +102 -0
  68. package/packages/record/lib/capture-run.mjs +125 -0
  69. package/packages/record/lib/capture-scratch.mjs +12 -3
  70. package/packages/record/lib/capture-service-definition.mjs +104 -0
  71. package/packages/record/lib/capture-service-install.mjs +362 -0
  72. package/packages/record/lib/capture-service-ownership.mjs +137 -0
  73. package/packages/record/lib/capture-service-runner.mjs +18 -0
  74. package/packages/record/lib/capture-small-snapshot.mjs +85 -0
  75. package/packages/record/lib/capture-source-discovery.mjs +319 -0
  76. package/packages/record/lib/capture-source-queue.mjs +199 -0
  77. package/packages/record/lib/capture-source-work.mjs +85 -0
  78. package/packages/record/lib/capture-state.mjs +16 -71
  79. package/packages/record/lib/capture-status.mjs +171 -0
  80. package/packages/record/lib/capture-supervisor.mjs +117 -0
  81. package/packages/record/lib/capture-watch.mjs +32 -0
  82. package/packages/record/lib/capture-work-session.mjs +238 -0
  83. package/packages/record/lib/capture-worker.mjs +58 -0
  84. package/packages/record/lib/derived-state.mjs +28 -15
  85. package/packages/record/lib/file-lines.mjs +22 -6
  86. package/packages/record/lib/formats.mjs +4 -3
  87. package/packages/record/lib/index-capture.mjs +97 -0
  88. package/packages/record/lib/index-db.mjs +3 -17
  89. package/packages/record/lib/index-reset.mjs +19 -0
  90. package/packages/record/lib/store.mjs +36 -11
  91. package/packages/record/lib/transcript-prefix.mjs +125 -0
  92. package/packages/tui/lib/client.mjs +2 -2
  93. package/packages/tui/lib/model.mjs +15 -5
  94. package/packages/tui/lib/views/palette.mjs +7 -3
  95. package/skills/oats-getting-started/SKILL.md +1 -1
  96. package/docs/macos-test-runs.md +0 -246
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "oats.framework": {
45
45
  "url": "https://github.com/awebai/oats.git",
46
- "ref": "oats-framework/v1.12.3",
46
+ "ref": "oats-framework/v1.13.1",
47
47
  "path": "oats-package"
48
48
  }
49
49
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awebai/oats",
3
- "version": "0.60.0",
3
+ "version": "0.62.0",
4
4
  "description": "OATS (Open Agent Team Specification) — durable souls, disposable instances, targetable capability packages, and the runtime-neutral oats CLI/kernel.",
5
5
  "keywords": [
6
6
  "agents",
@@ -13,7 +13,7 @@
13
13
  // Every candidate is canonicalized to an absolute executable and accepted
14
14
  // ONLY if executable and `<bin> version --json` returns the v1 probe:
15
15
  // {"schemaVersion":1,"name":"@awebai/oats","version":"0.24.x","desktopApi":1}
16
- // Desktop accepts desktopApi === 1 and semver >=0.26.0 <0.61.0 (the band is
16
+ // Desktop accepts desktopApi === 1 and semver >=0.26.0 <0.63.0 (the band is
17
17
  // spelled ONCE, in ACCEPT_RANGE below — this line only paraphrases it).
18
18
  // API version — not source adjacency — is authoritative.
19
19
  //
@@ -52,7 +52,7 @@ export const DESKTOP_API = 1;
52
52
  // carry a `description` for every kind and `<kind> update <id> --description`
53
53
  // sets one (feature `automation-descriptions`, which gates the Desktop's
54
54
  // summary writes). The Desktop v1 surface is otherwise unchanged.
55
- export const ACCEPT_RANGE = { min: [0, 26, 0], maxExclusive: [0, 61, 0] };
55
+ export const ACCEPT_RANGE = { min: [0, 26, 0], maxExclusive: [0, 63, 0] };
56
56
  /** The band as humans read it — derived, never hand-spelled, so the probe
57
57
  * rejection reason, the backend's /api status and the degradation card can
58
58
  * never disagree with the numbers actually enforced above. */
@@ -15,6 +15,16 @@ export function byRuntimeState(a, b) {
15
15
  return RUNTIME_ORDER[runtimeState(a)] - RUNTIME_ORDER[runtimeState(b)] || String(a.instance).localeCompare(String(b.instance));
16
16
  }
17
17
 
18
+ /** The words for an instance's siblings (#1312; the list `instanceSiblings` answers, instance-tree.mjs):
19
+ * null for none, else `sibling of a`, `sibling of a and b`, `sibling of a, b and c`, the names in the
20
+ * order given. The same in every client. */
21
+ export function siblingText(siblings) {
22
+ const names = (siblings || []).map((s) => s.instance);
23
+ if (!names.length) return null;
24
+ const list = names.length === 1 ? names[0] : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
25
+ return `sibling of ${list}`;
26
+ }
27
+
18
28
  /** The stand-in `unsupportedSession` writes for an older kernel's Herdr row: the one text of a row that is
19
29
  * this home's own sentence. Not on the stable surface. */
20
30
  export const HERDR_STAND_IN = `E_HERDR_REMOVED: ${HERDR_REMOVED}`;
@@ -11,16 +11,25 @@ export function collapseKey(workspace, instance) {
11
11
  return `${workspace || ""}\u0000${instance}`;
12
12
  }
13
13
 
14
+ /** An instance's explicit sibling link, as an array of instance names: the one reader of the kernel's
15
+ * `siblingInstance` (string | absent, set only when a sibling relation was declared against a ROOT
16
+ * instance — a sibling of a non-root simply shares the anchor's `parentInstance`). Normalized to an
17
+ * array so callers are shape-agnostic; self-links and non-strings are dropped. The sidebar's
18
+ * `instanceLinks`, `instanceSiblings` and the Desktop's Deployments graph all read the field here. */
19
+ export function siblingLinksOf(instance) {
20
+ const raw = instance.siblingInstance;
21
+ if (typeof raw !== "string" || !raw || raw === instance.instance) return [];
22
+ return [raw];
23
+ }
24
+
14
25
  /** Names an instance is directly related to (undirected edge endpoints):
15
- * its spawn parent plus its explicit sibling link. Kernel contract
16
- * (feature/agent-relations, final): `parentInstance` and `siblingInstance`
17
- * (string, only set when a sibling relation was declared against a ROOT
18
- * instance — a sibling of a non-root simply shares the anchor's parent).
19
- * Absent fields contribute no edges. */
26
+ * its spawn parent plus its explicit sibling link (`siblingLinksOf`). Kernel
27
+ * contract (feature/agent-relations, final): `parentInstance` and
28
+ * `siblingInstance`. Absent fields contribute no edges. */
20
29
  export function instanceLinks(instance) {
21
30
  const out = [];
22
31
  if (instance.parentInstance) out.push(instance.parentInstance);
23
- if (instance.siblingInstance) out.push(instance.siblingInstance);
32
+ out.push(...siblingLinksOf(instance));
24
33
  return out.filter((name) => name && name !== instance.instance);
25
34
  }
26
35
 
@@ -65,6 +74,39 @@ function rosterOrder(a, b) {
65
74
  return String(a.instance).localeCompare(String(b.instance)) || (ia < ib ? -1 : ia > ib ? 1 : 0);
66
75
  }
67
76
 
77
+ /** Each instance's siblings by EXPLICIT link (#1312): Y is X's sibling when X's sibling link
78
+ * (`siblingLinksOf`) resolves to Y (`resolveLinkId` over `instances`), or Y's resolves to X. So both
79
+ * ends of a link name each other. Direct links only (a chain C→B→A gives B [A, C], A [B], C [B]; A and
80
+ * C are not inferred), self excluded, de-duplicated by instanceId, each list in the roster's order
81
+ * (`rosterOrder`). Instances that share a parent are not siblings here (their relation is "under
82
+ * <parent>"), and `relation`/`relativeTo` are not read: they record how an instance was spawned, not a
83
+ * current relation. Pass one deployment's FULL roster, never a filtered list: dropping rows can turn an
84
+ * ambiguous name into a false unique one. Returns Map<instanceId, instance[]>; an instance with no
85
+ * sibling is absent from the map. */
86
+ export function instanceSiblings(instances) {
87
+ const byId = new Map(instances.map((i) => [instanceId(i), i]));
88
+ const byName = new Map();
89
+ for (const i of instances) {
90
+ if (!byName.has(i.instance)) byName.set(i.instance, []);
91
+ byName.get(i.instance).push(i);
92
+ }
93
+ const ids = new Map(); // id -> Set of sibling ids
94
+ const add = (a, b) => {
95
+ if (!ids.has(a)) ids.set(a, new Set());
96
+ ids.get(a).add(b);
97
+ };
98
+ for (const i of instances) {
99
+ const id = instanceId(i);
100
+ for (const name of siblingLinksOf(i)) {
101
+ const other = resolveLinkId(i, name, byName);
102
+ if (!other || other === id) continue;
103
+ add(id, other);
104
+ add(other, id);
105
+ }
106
+ }
107
+ return new Map([...ids].map(([id, set]) => [id, [...set].map((s) => byId.get(s)).sort(rosterOrder)]));
108
+ }
109
+
68
110
  /** Group instances into agent CLUSTERS — connected components of the
69
111
  * undirected relation graph (parent/child spawn edges + sibling links).
70
112
  * Unrelated instances are single-node clusters. Within a cluster the
@@ -60,11 +60,11 @@ commands are `oats capture|recall|setup`.
60
60
 
61
61
  ```bash
62
62
  turn-record setup # install Stop/SessionEnd hooks into every
63
- # ~/.claude*/settings.json, install the background
64
- # watcher (launchd on macOS, systemd user unit on
63
+ # ~/.claude*/settings.json, install periodic capture
64
+ # (launchd on macOS, systemd user service + timer on
65
65
  # Linux), then run the first capture pass.
66
66
  # Idempotent; --dry-run previews; --owner overrides
67
- # the machine name.
67
+ # the machine name. --root selects the persisted store.
68
68
 
69
69
  turn-record capture # one reconciliation pass, then index update
70
70
  turn-record capture --watch # pass now, on filesystem change, every 15 min
@@ -77,13 +77,21 @@ turn-record recall --show t1:<hex> # print one turn
77
77
  turn-record recall --reindex # full rebuild of the derived index
78
78
  ```
79
79
 
80
+ `recall --thread <thread> --json` lists a thread in capture sequence.
81
+ For a thread spanning aweb accounts, cross-account sequence under the service
82
+ is unspecified, and an ID window may contain turns from more than one account.
83
+ `--after <id>` excludes its boundary; `--until <id>` includes its boundary.
84
+ `--ids-only` uses the same window and reports IDs and output byte sizes. Later
85
+ appends do not reorder an existing window; existing tombstone visibility rules
86
+ still apply. Text thread listings without a query remain timestamp-sorted.
87
+
80
88
  Store root: `--root`, else `$TURN_RECORD_ROOT`, else `~/.turn-record`.
81
89
 
82
90
  `recall --show` refuses a turn hidden by its author's tombstone, including a
83
91
  session event whose tombstone lives in another stream. It emits no turn payload
84
92
  and exits with status 1, as it does for a missing turn.
85
93
 
86
- **The `node` that `setup` writes down.** The hooks and the watcher's unit name
94
+ **The `node` that `setup` writes down.** The hooks and the service's unit name
87
95
  a `node` by its path, and only `setup` run again rewrites them. Which path
88
96
  depends on how it is run:
89
97
 
@@ -100,16 +108,66 @@ runs under the `node` that runs `setup`.
100
108
 
101
109
  Each path is written for what reads it: a shell word in the hook's command,
102
110
  systemd's quoting in `ExecStart`, XML text in the launchd plist. A path of
103
- plain characters is written bare. A run finds the hooks of an earlier run by
104
- their shape, quoted or not, and replaces their command; a command it cannot
111
+ plain characters stays bare in hook commands. A run finds the hooks of an earlier run by
112
+ their shape, quoted or not, and refreshes command, async and timeout fields; a command it cannot
105
113
  read as its own is left alone and a new hook is added beside it.
106
114
  Stream owner: `--owner`, else `$TURN_RECORD_OWNER`, else the short hostname.
107
115
 
116
+ Ordinary/source-selected capture, explicit retry and foreground watch ticks use
117
+ the fixed supervised worker. Partial passes exit zero with pending work;
118
+ operational failures exit nonzero. `--no-index` never opens or mutates the
119
+ derived search index and supplies no fresh all-stage success. Quiet does not
120
+ imply a hook trigger. Explicit `--hook` launches a detached supervisor and reports
121
+ only “capture launched”, not initialization or completion. Owned Stop/SessionEnd
122
+ settings run the hook entry `bin/capture-hook.mjs` (the same launch as
123
+ `--quiet --hook`, under a file a rolled-back release cannot load, so it can
124
+ never return Claude's blocking exit two), `async:false` and `timeout:10`: the harness waits
125
+ for the launcher, while capture runs detached without its output pipes. Setup
126
+ refreshes these fields even when the owned command already matches, preserving
127
+ foreign hooks and unrelated fields. Hook errors, including usage, exit one,
128
+ never Claude's Stop-blocking exit two. Existing ordinary quiet argv remain
129
+ manual. Setup's first pass awaits the fixed supervisor with explicit `setup`
130
+ attribution and all sources/indexing enabled; `--no-service` still runs it,
131
+ while `--dry-run` starts no pass. Partial and overlap exit zero without claiming
132
+ completion; operational failures remain nonzero. Setup preflights named service
133
+ files, manager state and hook edits before mutation, then converts supported
134
+ legacy watchers to periodic capture, from the next release after 0.61.0;
135
+ 0.56.0–0.61.0 shipped without it.
136
+ See [command routing and receipts](docs/capture-service.md#ordinary-cli-and-foreground-watch).
137
+ See [detached hook launch limits](docs/capture-service.md#detached-hook-launcher).
138
+ The [service migration gate](docs/capture-service.md#setup-service-migration)
139
+ refuses foreign, disabled or masked definitions unless the operator explicitly
140
+ chooses `--replace-service`; `--no-service` bypasses service inspection and
141
+ actions while still installing requested hooks and running the first pass.
142
+ Refusals print that choice as the user-facing command with the selected
143
+ owner/root: `oats setup …` when the kernel environment handed in a node
144
+ (`OATS_NODE_BIN`, also set in instance shells), otherwise `turn-record setup …`.
145
+ Unknown/read errors always refuse, as does a macOS registration of the capture
146
+ label from another plist path, even with `--replace-service`. A refusal
147
+ changes nothing. A service failure after preflight still writes the hooks and
148
+ runs the first pass, then exits 1 with the
149
+ [setup summary](docs/capture-service.md#setup-service-migration) of what changed;
150
+ setup's private pending-activation marker (`<root>/capture-service-pending.json`)
151
+ lets a plain rerun finish its own activation, and `capture --health` reports it
152
+ as `capture-service-pending`.
153
+ Replacement saves nonoverwriting backups under the selected root and rechecks
154
+ file identity. `--dry-run` writes nothing and invokes no manager, so it reports
155
+ manager state as unexamined.
156
+ Healthy unchanged schedules preserve an active pass; successful setup reports
157
+ verified periodic scheduling, not a permanent PID. Real-manager lifecycle
158
+ and full service qualification remain separate gates.
159
+
108
160
  Transcript capture reads 64 KiB chunks and frames complete native records,
109
- including UTF-8 characters split across chunks. It appends batches of at most
110
- 8 MiB of source bytes plus the last record and checkpoints after each batch.
111
- One very large native record can still require memory proportional to that
112
- record; capture does not impose a new record-size policy.
161
+ including UTF-8 characters split across chunks. It flushes before adding a
162
+ record that would exceed an 8 MiB source batch and checkpoints after each batch.
163
+ Public synchronous capture can still process a larger individual record, with
164
+ memory proportional to that record; its resource contract is unchanged. The
165
+ supervised worker separately applies the fixed service policy beyond what is
166
+ already captured: it captures the complete records before a new record over
167
+ 8 MiB, then sets the input aside at that record's start. Records captured
168
+ earlier, of any size, are proved on recovery by streamed digests, not refused. Later records stay pending until the source is edited or the
169
+ whole input is ignored; `--retry-set-aside` cannot pass the oversized record
170
+ ([operator recovery](docs/capture-service.md#operator-recovery)).
113
171
  Final, attributed and protected Pi capture stage the descriptor's snapshot on
114
172
  private scratch under `<root>/.capture-tmp` before the first append, preserving
115
173
  attribution and custody checks without retaining the source in process memory.
@@ -163,8 +221,10 @@ Name-only patterns apply across every capture source: a short or generic
163
221
  pattern meant for one aw account can also catch a session file's basename
164
222
  or id in any format. Prefer path patterns for anything short or generic.
165
223
 
166
- Ignored files are counted in each pass (`N ignored` in capture output;
167
- `capture --status` shows the active pattern count), never skipped silently.
224
+ Ignored inputs are accounted for in worker run counts; exact synchronous
225
+ receipts retain their ignored counts. `capture --status` shows the active
226
+ pattern count. Ordinary text output summarizes confirmed appended turns and
227
+ outcome; `capture --health` exposes active refusals and remedies.
168
228
  The file is per record root and is local policy, not record truth — the
169
229
  sync guidance below replicates only `streams/` and `objects/`, so each
170
230
  machine decides what its own capture refuses to read; sync the `ignore`
@@ -173,6 +233,18 @@ ignore file that exists but cannot be read fails the pass loudly (a privacy
173
233
  control must not fail open), and ignoring is **forward-looking only** —
174
234
  turns already captured stay in the record; hide those with a tombstone.
175
235
 
236
+ `turn-record capture --health [--json]` reads offline installation,
237
+ receipt freshness/failure and current issue evidence without capture, repair,
238
+ root creation or manager calls. Warnings exit zero; unavailable readers fail.
239
+ A recent receipt or definition file does not certify enabled scheduling.
240
+ See [health diagnosis](docs/capture-service.md#offline-installation-and-run-diagnosis)
241
+ for exact installation candidates, nullable history, reader bounds and the
242
+ asleep/off-host caveat. Deployment `oats doctor` delegates once to package health
243
+ with a finite command timeout/output bound and maps its rows into warnings.
244
+ Command, reader or invalid-response failures yield `capture-health-unavailable`;
245
+ `--soul` remains composition-only. Kernel remedies say `oats`; standalone package
246
+ remedies say `turn-record`, without rewriting user paths or receipt data.
247
+
176
248
  ## Multi-machine
177
249
 
178
250
  Replicate `streams/` and `objects/` with any dumb file sync (syncthing,
@@ -301,7 +373,9 @@ output inventories without suppressing error counts.
301
373
 
302
374
  Verified snapshots and prefix comparisons use private record-root scratch, which
303
375
  can expand with source size; journal and derived-index disk space also grow with
304
- captured content. Staging is cleaned on success and failure. No new heap, record
376
+ captured content. Public per-call staging is cleaned on success and failure;
377
+ internal command recovery can retain explicitly owned jobs across workers, as
378
+ described in the [resource model](docs/capture-service.md#resource-model). No new heap, record
305
379
  size, elapsed-time or service policy limit is imposed by these algorithms.
306
380
 
307
381
  ## Known costs, accepted for v1
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ // The capture hook's entry: `capture --hook` under a file name of its own.
3
+ // Claude treats a hook's exit 2 as blocking. A release that predates this file
4
+ // cannot load it, so after a rollback the persisted hook line fails with exit 1
5
+ // ("Cannot find module"), which never blocks Stop or SessionEnd, instead of an
6
+ // older capture.mjs rejecting a flag it does not know with exit 2.
7
+ process.argv.splice(2, 0, "--hook");
8
+ await import("./capture.mjs");