@awebai/oats 0.69.19 → 0.69.21

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 (46) hide show
  1. package/bin/oats.mjs +28 -5
  2. package/docs/capabilities.md +27 -14
  3. package/docs/capability-manifest.schema.json +1 -1
  4. package/docs/container.md +218 -18
  5. package/docs/desktop-cli-api.md +105 -11
  6. package/docs/desktop.md +122 -65
  7. package/docs/implementation.md +3 -2
  8. package/docs/integrations.md +2 -2
  9. package/docs/knowledge.md +5 -5
  10. package/docs/official-catalog.md +5 -5
  11. package/docs/packages.md +13 -13
  12. package/docs/release-notes/v0.69.20.md +325 -0
  13. package/docs/release-notes/v0.69.21.md +155 -0
  14. package/docs/servers.md +9 -3
  15. package/docs/souls-and-instances.md +15 -2
  16. package/docs/upgrading.md +17 -5
  17. package/docs/workspaces.md +13 -7
  18. package/lib/capability-contract.mjs +2 -2
  19. package/lib/command-flags.mjs +1 -0
  20. package/lib/core.mjs +36 -198
  21. package/lib/hook-outcome.mjs +6 -0
  22. package/lib/instance-inspect.mjs +3 -0
  23. package/lib/instance-lifecycle.mjs +19 -1
  24. package/lib/instance-listing.mjs +11 -6
  25. package/lib/instance-pin.mjs +59 -0
  26. package/lib/kernel-features.mjs +1 -1
  27. package/lib/launch-prompt-fixtures/README.md +6 -0
  28. package/lib/retire-admission.mjs +215 -0
  29. package/lib/servers.mjs +11 -3
  30. package/package-catalog.json +3 -3
  31. package/package.json +1 -1
  32. package/packages/client/attributed-human.mjs +13 -0
  33. package/packages/client/deployment-data.mjs +4 -0
  34. package/packages/client/deployment-panel.mjs +2 -0
  35. package/packages/client/instance-lifecycle.mjs +6 -4
  36. package/packages/client/lifecycle-confirmation.mjs +4 -2
  37. package/packages/client/lifecycle-contract.mjs +11 -6
  38. package/packages/client/remote-roster.mjs +4 -0
  39. package/packages/client/roster-row-facts.mjs +50 -0
  40. package/packages/record/README.md +15 -2
  41. package/packages/record/docs/capture-service.md +14 -0
  42. package/packages/record/lib/canonical.mjs +2 -70
  43. package/packages/record/lib/capture-aw-unit.mjs +14 -3
  44. package/packages/record/lib/capture-aw.mjs +11 -5
  45. package/packages/record/lib/capture-health.mjs +16 -5
  46. package/skills/oats-getting-started/SKILL.md +211 -28
@@ -0,0 +1,50 @@
1
+ /** The two text facts of an instance row in a sidebar roster (the Desktop UI rework, slice 1), shared so the
2
+ * Terminal UI can draw the same row: line 1 the display name, line 2 `<soul> · <machine>`.
3
+ *
4
+ * rosterRowFacts(row, terms, { deployments, here }) -> { name, detail, soul, machine }
5
+ *
6
+ * name the instance name as words (instance-display-name.mjs), else the name as reported, else ''
7
+ * soul the row's soul (`agent`), one display line, else null (a forgotten or malformed row)
8
+ * machine where the row runs: the machine of the deployment the row is tagged with (`deployment.id` among
9
+ * `deployments`, a view's), else a remote server row's label (remote-address.mjs `serverLabel`), else
10
+ * this machine: its own name when the caller knows it (`here`, the host name the kernel reports for this
11
+ * machine), else `terms.thisMachine` (client-terms.mjs). A row of this machine's own deployment is this
12
+ * machine's too, whatever label the deployment carries. A view's row may carry `server` and a repository
13
+ * in `repoName`, so its deployment's machine comes first. Always a label: a row that names no machine is
14
+ * this machine's
15
+ * detail `soul · machine`, or the machine alone when no soul is known
16
+ *
17
+ * The facts only: no state, no reason, no repository, no harness. A row whose machine didn't answer keeps both
18
+ * lines; its state is the dot's and its reason the row's description. Display only, never an identity: the real
19
+ * name stays wherever it identifies the instance. Pure: no DOM, no IO. */
20
+ import { instanceDisplayName } from './instance-display-name.mjs';
21
+ import { serverLabel } from './remote-address.mjs';
22
+ import { displayLine, DETAIL_WITHHELD } from './display-text.mjs';
23
+ import { requireTerms } from './client-terms.mjs';
24
+
25
+ /** One display line, or null for nothing to show (absent, not text, withheld). */
26
+ const shown = (value) => {
27
+ const line = typeof value === 'string' ? displayLine(value) : null;
28
+ return line && line !== DETAIL_WITHHELD ? line : null;
29
+ };
30
+
31
+ /** The machine label of `row`, in `terms` (see the module's comment). */
32
+ export function rowMachine(row, terms, { deployments = [], here = null } = {}) {
33
+ requireTerms(terms, 'rowMachine');
34
+ const id = typeof row?.deployment?.id === 'string' ? row.deployment.id : null;
35
+ const deployment = id && Array.isArray(deployments) ? deployments.find((d) => d?.id === id) : null;
36
+ const server = typeof row?.server === 'string' && row.server ? shown(serverLabel(row)) ?? shown(row.server) : null;
37
+ const thisMachine = shown(here) ?? terms.thisMachine;
38
+ if (deployment?.local === true) return thisMachine;
39
+ return shown(deployment?.machine) ?? server ?? thisMachine;
40
+ }
41
+
42
+ /** The row's two lines and their parts. */
43
+ export function rosterRowFacts(row, terms, { deployments = [], here = null } = {}) {
44
+ requireTerms(terms, 'rosterRowFacts');
45
+ const instance = typeof row?.instance === 'string' ? row.instance : '';
46
+ const name = instanceDisplayName(instance) || instance;
47
+ const soul = shown(row?.agent);
48
+ const machine = rowMachine(row, terms, { deployments, here });
49
+ return { name, detail: [soul, machine].filter(Boolean).join(' · '), soul, machine };
50
+ }
@@ -19,8 +19,9 @@ the oats repo and run as `oats experimental <cmd>`. They are deliberately not
19
19
  part of this package.
20
20
 
21
21
  - **`lib/canonical.mjs`** — canonical JSON (integers only in the core),
22
- `t1:` content ids, did:key Ed25519 verification. Byte-compatible with awid
23
- message signing.
22
+ `t1:` content ids, and consistency checks for duplicated signed fields.
23
+ Byte-compatible with awid message signing; capture preserves source signatures
24
+ verbatim and does not verify them.
24
25
  - **`lib/store.mjs`** — the store: `streams/<owner>~<source>/journal.jsonl`
25
26
  (owner-only append, torn-tail tolerant), `objects/sha256/` (immutable
26
27
  blobs), `index/` (derived, never replicated). Merge is prefix extension
@@ -497,3 +498,15 @@ Anything that binds nothing is an error,
497
498
  See [capture algorithms and recovery](docs/capture-service.md) for the shared
498
499
  append-only input assumption, reset/retry commands, bounded status inventory,
499
500
  resource accounting and v0.53.0 downgrade/re-upgrade contract.
501
+
502
+ ### Sealed aw logs
503
+
504
+ A sealed client-log envelope (`v`, `key_id`, `enc`, `ct`, with optional `tag`) contains
505
+ ciphertext this recorder cannot read. Capture stops before that line and
506
+ reports a separate `sealed` count, without counting it as a projection failure
507
+ or advancing its cursor. Later lines wait too. Command capture sets the input
508
+ aside with reason “sealed, not readable by this recorder”; status reports it
509
+ under the set-aside count. Supply a readable source and explicitly retry the
510
+ set-aside input, or ignore that source. Resetting a cursor cannot decrypt it.
511
+ Readable lines that fail projection retain their existing consume-and-count
512
+ behaviour.
@@ -81,6 +81,20 @@ For a conflicting native prefix, either:
81
81
  input from active set-aside entries. Removing the ignore rule later does not
82
82
  authorize the conflict.
83
83
 
84
+ **Sealed aw logs.** Capture stops before a sealed client-log envelope (`v`,
85
+ `key_id`, `enc`, `ct`, optional `tag`) and leaves its cursor at the line's
86
+ start. It reports a distinct `sealed` count, and command capture sets the input
87
+ aside with reason `sealed, not readable by this recorder`. Later lines wait.
88
+ The owner can export readable JSONL with `aw log read <file>... --json`,
89
+ using the keychain and passphrase where the sealing key was created. The
90
+ recorder has no unattended decryption authority or passphrase transport. The
91
+ native reader may emit a readable prefix before failing, so partial stdout
92
+ does not prove the whole source was read.
93
+
94
+ Supply a readable source and run `capture --retry-set-aside`, or ignore the
95
+ source; retry and cursor reset cannot decrypt ciphertext. Readable projection
96
+ errors retain their existing consume-and-count behaviour.
97
+
84
98
  **Oversized records.** The 8 MiB raw-record limit applies to capture beyond
85
99
  the captured prefix. The supervised worker never allocates, captures or
86
100
  modifies a new raw source record larger than 8 MiB. It appends and checkpoints
@@ -1,9 +1,9 @@
1
- // Canonical JSON, turn ids, and signature verification for turn.jsonl v1.
1
+ // Canonical JSON, turn ids, and signed-field consistency for turn.jsonl v1.
2
2
  // Contract: docs/turn-record-sot.md in this package. The byte rules intentionally
3
3
  // match awid message signing (sorted keys, minimal separators, no HTML
4
4
  // escaping, ensure_ascii=false) so the same canonical form serves both.
5
5
 
6
- import { createHash, createPublicKey, verify as edVerify } from "node:crypto";
6
+ import { createHash } from "node:crypto";
7
7
 
8
8
  export class CanonicalError extends Error {}
9
9
 
@@ -57,74 +57,6 @@ export function verifyTurnId(turn) {
57
57
  return typeof turn.id === "string" && turnId(turn) === turn.id;
58
58
  }
59
59
 
60
- // --------------------------------------------------------------- did:key
61
-
62
- const B58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
63
-
64
- export function base58Decode(s) {
65
- let n = 0n;
66
- for (const c of s) {
67
- const i = B58_ALPHABET.indexOf(c);
68
- if (i < 0) throw new CanonicalError(`invalid base58 character ${JSON.stringify(c)}`);
69
- n = n * 58n + BigInt(i);
70
- }
71
- const bytes = [];
72
- while (n > 0n) {
73
- bytes.push(Number(n & 0xffn));
74
- n >>= 8n;
75
- }
76
- bytes.reverse();
77
- for (const c of s) {
78
- if (c === "1") bytes.unshift(0);
79
- else break;
80
- }
81
- return Uint8Array.from(bytes);
82
- }
83
-
84
- const ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
85
-
86
- export function publicKeyFromDidKey(did) {
87
- if (!did.startsWith("did:key:z")) throw new CanonicalError(`unsupported did ${did}`);
88
- const decoded = base58Decode(did.slice("did:key:z".length));
89
- if (decoded.length !== 34 || decoded[0] !== 0xed || decoded[1] !== 0x01) {
90
- throw new CanonicalError(`not an ed25519 did:key: ${did}`);
91
- }
92
- return createPublicKey({
93
- key: Buffer.concat([ED25519_SPKI_PREFIX, Buffer.from(decoded.subarray(2))]),
94
- format: "der",
95
- type: "spki",
96
- });
97
- }
98
-
99
- // Base64 signatures arrive unpadded, in either the standard or URL-safe
100
- // alphabet (awid accepts both; so do we).
101
- export function base64DecodeLoose(s) {
102
- const normalized = s.replaceAll("-", "+").replaceAll("_", "/");
103
- const padded = normalized + "=".repeat((4 - (normalized.length % 4)) % 4);
104
- return Buffer.from(padded, "base64");
105
- }
106
-
107
- // Verify an Ed25519 signature by a did:key over utf-8 payload text.
108
- // Returns boolean; malformed inputs are a failed verification, not a throw.
109
- export function verifyDidKeySignature(did, payloadText, signatureB64) {
110
- try {
111
- return edVerify(
112
- null,
113
- Buffer.from(payloadText, "utf8"),
114
- publicKeyFromDidKey(did),
115
- base64DecodeLoose(signatureB64),
116
- );
117
- } catch {
118
- return false;
119
- }
120
- }
121
-
122
- // Verify a turn's envelope signature (`sig` over the canonical core).
123
- export function verifyTurnSig(turn) {
124
- if (!turn.sig) return false;
125
- return verifyDidKeySignature(turn.sig.by, coreString(turn), turn.sig.sig);
126
- }
127
-
128
60
  // Value equality via canonical bytes — `to` may legally be an array, so a
129
61
  // reference compare would flag every multi-recipient turn read from disk.
130
62
  function sameValue(a, b) {
@@ -2,7 +2,7 @@
2
2
  // Explicit per-file public APIs keep their full-reprojection defaults.
3
3
  import { closeSync, constants, fstatSync, openSync } from "node:fs";
4
4
  import { basename } from "node:path";
5
- import { awBoundaryWitness, awLogLines, awStream } from "./capture-aw.mjs";
5
+ import { awBoundaryWitness, awLogLines, awStream, SEALED_AW_LOG_REASON } from "./capture-aw.mjs";
6
6
  import { captureContext } from "./capture-context.mjs";
7
7
  import { CAPTURE_POLICY } from "./capture-budget.mjs";
8
8
  import { fileVersion, statVersion, sameVersion } from "./derived-state.mjs";
@@ -27,7 +27,8 @@ export function captureAwUnit(store, { owner, path, kind = "comm", selfName, wor
27
27
  return { ...result, ignored: true, complete: true };
28
28
  }
29
29
  const blocked = state.get("set-aside", key);
30
- if (blocked && !blocked.retry) return { ...result, setAside: blocked };
30
+ if (blocked && !blocked.retry) return { ...result, setAside: blocked,
31
+ ...(blocked.reason === SEALED_AW_LOG_REASON ? { sealed: 1 } : {}) };
31
32
  const fd = openSync(path, constants.O_RDONLY | constants.O_NONBLOCK);
32
33
  try {
33
34
  const observe = () => {
@@ -85,7 +86,7 @@ export function captureAwUnit(store, { owner, path, kind = "comm", selfName, wor
85
86
  };
86
87
  const project = kind === "comm" ? entry => projectCommLogEntry(entry, { selfName: account }) :
87
88
  entry => projectInteractionLogEntry(entry, { selfName, workspace });
88
- let bytes = 0, records = 0, scanned = false, oversized = null;
89
+ let bytes = 0, records = 0, scanned = false, oversized = null, sealed = null;
89
90
  const turns = [], iterator = awLogLines(chunks(), { start: unitStart, maxBytes: maxRecordBytes, frontier: job.frontier ?? 0 });
90
91
  try {
91
92
  while (records < maxRecords && bytes < maxBytes && !stopped()) {
@@ -93,6 +94,11 @@ export function captureAwUnit(store, { owner, path, kind = "comm", selfName, wor
93
94
  if (next.done) { scanned = true; break; }
94
95
  const record = next.value;
95
96
  if (records && bytes + record.bytes > maxBytes) break;
97
+ if (record.sealed) {
98
+ result.entries++; result.sealed = 1; sealed = record.start;
99
+ if (work) work.sourceRecords = (work.sourceRecords ?? 0) + 1;
100
+ break;
101
+ }
96
102
  records++; bytes += record.bytes; job.bytes = record.end;
97
103
  if (work) work.sourceRecords = (work.sourceRecords ?? 0) + 1;
98
104
  if (record.skipped) result.skipped++;
@@ -125,6 +131,11 @@ export function captureAwUnit(store, { owner, path, kind = "comm", selfName, wor
125
131
  if (blocked && (job.bytes > blocked.offset || atEnd)) state.delete("set-aside", key);
126
132
  if (scanned || atEnd) state.delete("aw-unit", key);
127
133
  else state.set("aw-unit", key, job);
134
+ if (sealed !== null) {
135
+ const row = { owner, source: "aw", path, offset: sealed, reason: SEALED_AW_LOG_REASON, retry: false };
136
+ state.set("set-aside", key, row);
137
+ return { ...result, setAside: row };
138
+ }
128
139
  if (oversized !== null) {
129
140
  // Not captured past its exact start. Later records wait for an edited
130
141
  // source or an ignore of the whole input.
@@ -29,6 +29,8 @@ import {
29
29
  import { loadIgnore } from "./ignore.mjs";
30
30
  import { bufferLines, fileChunks } from "./file-lines.mjs";
31
31
 
32
+ export const SEALED_AW_LOG_REASON = "sealed, not readable by this recorder";
33
+
32
34
  export function defaultCommLogDir(home = homedir()) {
33
35
  return join(home, ".config", "aw", "logs");
34
36
  }
@@ -52,7 +54,7 @@ export function listCommLogs(dir = defaultCommLogDir()) {
52
54
  // interior bad line is skipped and counted (`onSkipped`), never fatal.
53
55
  function* logEntries(fd, start, end, onSkipped, onConsumed) {
54
56
  for (const record of awLogLines(fileChunks(fd, { start, end, size: 65536 }), { start })) {
55
- if (!record.final) onConsumed(record.end);
57
+ if (!record.final && !record.sealed) onConsumed(record.end);
56
58
  if (record.skipped) onSkipped();
57
59
  if (record.parsed) yield record;
58
60
  }
@@ -74,7 +76,10 @@ export function* awLogLines(chunks, { start = 0, maxBytes = Infinity, frontier =
74
76
  const text = line.toString("utf8");
75
77
  if (text.trim() === "") { yield record; continue; }
76
78
  const entry = JSON.parse(text);
77
- yield { ...record, entry, parsed: true };
79
+ // Sealed aw client-log envelopes are ciphertext, not projection errors.
80
+ const sealed = entry !== null && typeof entry === "object" &&
81
+ ["v", "key_id", "enc", "ct"].every(key => Object.hasOwn(entry, key));
82
+ yield { ...record, entry, parsed: true, ...(sealed ? { sealed: true } : {}) };
78
83
  } catch {
79
84
  yield { ...record, skipped: !final };
80
85
  }
@@ -117,7 +122,7 @@ function captureLogFile(store, { streamId, path, project, knownIds, incremental
117
122
  if (old.dev === version.dev && old.ino === version.ino && (version.size > old.size || sameVersion(old, version)) &&
118
123
  previous.bytes <= end && boundaryWitness(fd, previous.bytes) === previous.witness) start = previous.bytes;
119
124
  }
120
- let entries = 0, skipped = 0, failed = 0, appended = 0, batch = [], batchBytes = 0, consumed = start, complete = false;
125
+ let entries = 0, skipped = 0, failed = 0, appended = 0, batch = [], batchBytes = 0, consumed = start, complete = false, sealed = 0;
121
126
  const checkpoint = () => {
122
127
  if (!incremental) return;
123
128
  const bytes = consumed;
@@ -141,6 +146,7 @@ function captureLogFile(store, { streamId, path, project, knownIds, incremental
141
146
  flush(); consumed = scanned;
142
147
  }
143
148
  entries++;
149
+ if (record.sealed) { consumed = record.start; sealed++; break; }
144
150
  let turn;
145
151
  // Projection refusal consumes this complete entry just like a skipped
146
152
  // malformed line. Resetting source cursors is the explicit retry path;
@@ -154,9 +160,9 @@ function captureLogFile(store, { streamId, path, project, knownIds, incremental
154
160
  }
155
161
  // Complete refused/malformed/blank lines are consumed; an unfinished final
156
162
  // fragment keeps its starting boundary so later growth can finish it.
157
- complete = true;
163
+ complete = sealed === 0;
158
164
  flush();
159
- return { entries, appended, skipped, failed };
165
+ return { entries, appended, skipped, failed, ...(sealed ? { sealed } : {}) };
160
166
  } finally { try { if (!captureContext(store)) state?.close(); } finally { closeSync(fd); } }
161
167
  }
162
168
 
@@ -1,5 +1,6 @@
1
1
  // Package-owned offline diagnosis. No writable DB/store, lock acquisition,
2
2
  // manager, repair or capture; warnings never publish new run evidence.
3
+ import { SEALED_AW_LOG_REASON } from "./capture-aw.mjs";
3
4
  import { homedir, hostname, platform as hostPlatform } from "node:os";
4
5
  import { join } from "node:path";
5
6
  import { readCaptureStatus } from "./capture-status.mjs";
@@ -14,6 +15,7 @@ export const SET_ASIDE_REMEDY = setAsideRemedy("turn-record", "<root>");
14
15
  // Retry re-reads an unchanged oversized record and sets it aside again: only an
15
16
  // edited source or an ignore of the whole input moves past it.
16
17
  const oversizedRemedy = (command, root) => `Edit the source so no record exceeds 8 MiB, leaving its captured prefix unchanged, then run ${command} capture --retry-set-aside; or add the whole input to ${root}/ignore, which discards the whole input, its records after the oversized one included, and later turns from that session.`;
18
+ const sealedRemedy = (command, root) => `supply a readable source and run ${command} capture --retry-set-aside, or add the source to ${join(root, "ignore")}; retry cannot decrypt ciphertext.`;
17
19
  // The one rule for remedy wording: the kernel's own entry points say `oats`,
18
20
  // the standalone package says `turn-record`. Each entry point states which it is.
19
21
  export const captureRemedyCommand = viaKernel => viaKernel ? "oats" : "turn-record";
@@ -77,11 +79,20 @@ function diagnose(root, { home = homedir(), platform = hostPlatform(), now = Dat
77
79
  // Remedies follow each listed entry's reason. Reasons beyond the bounded
78
80
  // sample are unknown here, so a truncated list says so rather than guess.
79
81
  const oversized = backlog.setAside.filter(entry => entry.reason === "record-too-large").length;
80
- const others = backlog.setAsideCount - oversized, general = setAsideRemedy(command, root);
81
- const message = !oversized ? general + (backlog.truncated ? ` Unlisted entries: see each entry's reason; record-too-large entries need: ${oversizedRemedy(command, root)}` : "") :
82
- `${oversized} listed as record-too-large: ${oversizedRemedy(command, root)}` + (!others ? "" : backlog.truncated ?
83
- ` The other ${others}, including unlisted entries: see each entry's reason; record-too-large entries need the edit-or-ignore remedy above. Otherwise: ${general}` :
84
- ` The other ${others}: ${general}`);
82
+ const sealed = backlog.setAside.filter(entry => entry.reason === SEALED_AW_LOG_REASON).length;
83
+ const others = backlog.setAsideCount - oversized - sealed;
84
+ const general = setAsideRemedy(command, root), parts = [];
85
+ if (oversized) parts.push(`${oversized} listed as record-too-large: ${oversizedRemedy(command, root)}`);
86
+ if (sealed) parts.push(`${sealed} listed as ${SEALED_AW_LOG_REASON}: ${sealedRemedy(command, root)}`);
87
+ if (!parts.length) parts.push(general);
88
+ else if (others) {
89
+ if (backlog.truncated) {
90
+ const oversizedNote = oversized ? "record-too-large entries need the edit-or-ignore remedy above. " : "";
91
+ parts.push(`The other ${others}, including unlisted entries: see each entry's reason; ${oversizedNote}Otherwise: ${general}`);
92
+ } else parts.push(`The other ${others}: ${general}`);
93
+ }
94
+ if (backlog.truncated) parts.push(`Unlisted entries: see each entry's reason; record-too-large entries need: ${oversizedRemedy(command, root)} Sealed entries (${SEALED_AW_LOG_REASON}) need: ${sealedRemedy(command, root)}`);
95
+ const message = parts.join(" ");
85
96
  rows.push({ code: "capture-input-set-aside", message: `${backlog.setAsideCount} capture inputs set aside. ${message}` });
86
97
  }
87
98