@awebai/oats 0.69.21 → 0.69.23

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 (73) hide show
  1. package/bin/oats.mjs +131 -23
  2. package/docs/capabilities.md +12 -2
  3. package/docs/capability-manifest.schema.json +1 -1
  4. package/docs/container.md +290 -5
  5. package/docs/design/2026-11-18-kernel-test-ownership.md +82 -0
  6. package/docs/design/2026-11-19-aweb-suite-retirement.md +123 -0
  7. package/docs/design/2026-11-19-sandboxes.md +878 -0
  8. package/docs/design/README.md +3 -0
  9. package/docs/desktop-cli-api.md +416 -72
  10. package/docs/desktop.md +377 -148
  11. package/docs/implementation.md +15 -2
  12. package/docs/integrations.md +3 -3
  13. package/docs/knowledge-capability-authoring.md +10 -7
  14. package/docs/knowledge-reference/acceptance.md +21 -19
  15. package/docs/knowledge-reference/adoption.md +18 -4
  16. package/docs/knowledge-reference/model.md +11 -9
  17. package/docs/knowledge-reference/package-craft.md +2 -2
  18. package/docs/knowledge-reference/proposal.md +117 -0
  19. package/docs/knowledge-reference/provider-mapping.md +10 -10
  20. package/docs/knowledge-reference/reader-capture.md +26 -22
  21. package/docs/knowledge-theory.md +1 -1
  22. package/docs/knowledge.md +5 -5
  23. package/docs/official-catalog.md +47 -4
  24. package/docs/packages.md +13 -13
  25. package/docs/release-lane.md +8 -6
  26. package/docs/release-notes/v0.69.22.md +221 -0
  27. package/docs/release-notes/v0.69.23.md +231 -0
  28. package/docs/servers.md +10 -6
  29. package/docs/souls-and-instances.md +51 -22
  30. package/docs/tui.md +48 -7
  31. package/docs/upgrading.md +17 -5
  32. package/docs/workspaces.md +2 -2
  33. package/lib/argv.mjs +6 -2
  34. package/lib/capability-contract.mjs +2 -2
  35. package/lib/command-flags.mjs +39 -2
  36. package/lib/core.mjs +25 -14
  37. package/lib/instance-board.mjs +337 -0
  38. package/lib/instance-events.mjs +48 -10
  39. package/lib/instance-lifecycle.mjs +19 -15
  40. package/lib/instance-listing.mjs +18 -10
  41. package/lib/instance-related-work.mjs +143 -0
  42. package/lib/kernel-features.mjs +4 -1
  43. package/lib/servers.mjs +123 -13
  44. package/package-catalog.json +3 -3
  45. package/package.json +1 -1
  46. package/packages/client/above-tested.mjs +3 -2
  47. package/packages/client/capability-list.mjs +69 -0
  48. package/packages/client/capability-origin.mjs +54 -0
  49. package/packages/client/cli-adapter.mjs +9 -1
  50. package/packages/client/deployment-data.mjs +7 -2
  51. package/packages/client/deployment-panel.mjs +4 -1
  52. package/packages/client/home-board.mjs +50 -0
  53. package/packages/client/instance-pin.mjs +28 -0
  54. package/packages/client/instance-record-outcome.mjs +31 -0
  55. package/packages/client/instance-tree.mjs +96 -24
  56. package/packages/client/keymap.mjs +16 -3
  57. package/packages/client/mail-contract.mjs +130 -0
  58. package/packages/client/panel-views.mjs +7 -7
  59. package/packages/client/related-work.mjs +84 -0
  60. package/packages/client/remote-roster.mjs +11 -3
  61. package/packages/client/roster-sections.mjs +10 -7
  62. package/packages/client/soul-role.mjs +44 -0
  63. package/packages/client/waiting-on-you.mjs +10 -0
  64. package/packages/client/workspace-cli.mjs +13 -2
  65. package/packages/tui/lib/actions.mjs +11 -4
  66. package/packages/tui/lib/client.mjs +3 -1
  67. package/packages/tui/lib/main.mjs +16 -2
  68. package/packages/tui/lib/model.mjs +48 -5
  69. package/packages/tui/lib/store.mjs +28 -2
  70. package/skills/oats-getting-started/SKILL.md +97 -24
  71. package/docs/knowledge-reference/harvester.md +0 -109
  72. package/lib/instance-same-work.mjs +0 -67
  73. package/packages/client/same-work.mjs +0 -49
package/lib/servers.mjs CHANGED
@@ -28,6 +28,7 @@ import { readWaitingClaim, validWaitingMessage } from "./instance-events.mjs";
28
28
  import { readRetireState } from "./retire-state.mjs";
29
29
  import { SESSION_END } from "./session-resume-contract.mjs";
30
30
  import { paletteColor } from "./instance-color.mjs";
31
+ import { relatedWorkBinding } from "./instance-related-work.mjs";
31
32
  import { readSpawnedBy } from "./spawned-by.mjs";
32
33
  import { withDirLock } from "./dir-lock.mjs";
33
34
  import { shellWord } from "./shell-word.mjs";
@@ -37,6 +38,7 @@ import { compareSemver } from "./semver.mjs";
37
38
  import { SPAWN_TASK_STDIN_FEATURE } from "./kernel-features.mjs";
38
39
  import { sameRepo } from "./repo-moves.mjs";
39
40
  import { OATS_PACKAGE_NAME } from "./version.mjs";
41
+ import { readRemoteBoard } from "./instance-board.mjs";
40
42
  export { compareSemver } from "./semver.mjs";
41
43
 
42
44
  const OATS_HOME_DIR = () => process.env.OATS_HOME_DIR || join(homedir(), ".oats");
@@ -744,8 +746,9 @@ export function routeCommand(serverId, cmd, oatsArgs, io = {}) {
744
746
  // Feature instance-background: an older host would refuse the flag as unknown, or place the instance
745
747
  // in the main list; either is said here, before anything is sent.
746
748
  if (oatsArgs.includes("--background") || oatsArgs.includes("--no-background")) requireRemoteFeature(remote, target, "instance-background");
747
- // A host without instance-same-work would refuse the flag as unknown: it is never sent there.
748
- if (oatsArgs.includes("--same-work")) requireRemoteFeature(remote, target, "instance-same-work");
749
+ // Feature instance-related-work: the flag as this host takes it (relatedWorkSpawnArgs), or refused here,
750
+ // before anything is sent; never dropped.
751
+ if (oatsArgs.includes("--related-work") || oatsArgs.includes("--same-work")) oatsArgs = relatedWorkSpawnArgs(remote, target, oatsArgs, status.result);
749
752
  const spawnOnHost = (args) => runRemote(target, json(withScope(["spawn", ...hostHarnessArgs(remote, args)])), { ...io, input: task });
750
753
  // A spawn that brings neither a decision nor a key is bound here: the host's preview decides, and
751
754
  // the apply carries that decision and a key of this request, so the same spawn sent again with
@@ -884,7 +887,7 @@ export function routeCommand(serverId, cmd, oatsArgs, io = {}) {
884
887
  }
885
888
  if (cmd === "status") {
886
889
  const { envelope, stderr } = runRemote(target, json(withScope(["status", ...oatsArgs])), io);
887
- return { envelope: envelope.ok ? { ...envelope, result: { ...envelope.result, server: serverId, target, snapshots: listSnapshots(serverId) } } : envelope, stderr };
890
+ return { envelope: envelope.ok ? { ...envelope, result: { ...relatedWorkRows(envelope.result), server: serverId, target, snapshots: listSnapshots(serverId) } } : envelope, stderr };
888
891
  }
889
892
  if (OPERATIONS_COMMANDS.has(cmd)) {
890
893
  // The operations contract (inspect, operation run): the
@@ -914,6 +917,8 @@ export function routeCommand(serverId, cmd, oatsArgs, io = {}) {
914
917
  if (cmd === "inspect" && args.includes("--instructions")) requireRemoteFeature(remote, target, "soul-composed-instructions");
915
918
  // `inspect --skills` (feature soul-skills): the same, for the soul's own skills.
916
919
  if (cmd === "inspect" && args.includes("--skills")) requireRemoteFeature(remote, target, "soul-skills");
920
+ // `inspect --board` (feature instance-board): the same, for the board's history and context.
921
+ if (cmd === "inspect" && args.includes("--board")) requireRemoteFeature(remote, target, "instance-board");
917
922
  // `inspect --composed-skills` (feature soul-composed-skills): the same, for every skill a spawn would give.
918
923
  if (cmd === "inspect" && args.includes("--composed-skills")) requireRemoteFeature(remote, target, "soul-composed-skills");
919
924
  const scoped = args.includes("--dir") || args.includes("--home") ? args : [...args, "--dir", target.workspace];
@@ -923,6 +928,94 @@ export function routeCommand(serverId, cmd, oatsArgs, io = {}) {
923
928
  throw serverError("E_USAGE", `--server routes spawn, retire, status, session, okf harvest, schedule, inspect, operation, readiness and instance only (not ${cmd})`);
924
929
  }
925
930
 
931
+ // ------------------------------------------------- related work on an older host
932
+
933
+ /** Whether a host's `features` say it is a kernel from before the related-work rename: it advertises
934
+ * instance-same-work (the flag by its old name, a parent binding only) and not instance-related-work. Only
935
+ * there is the flag sent by its old spelling, and a sibling binding refused. */
936
+ export function sameWorkOnly(features) {
937
+ return Array.isArray(features) && features.includes("instance-same-work") && !features.includes("instance-related-work");
938
+ }
939
+
940
+ /** The binding a routed spawn of `oatsArgs` would record, read from its arguments and the host's roster
941
+ * `roster` (its `status --json`): "parent" for `--parent`, `--relation child` and an attached spawn; for
942
+ * `--relation sibling|parent`, the binding the anchor's row gives (relatedWorkBinding, as the host's kernel
943
+ * chooses it): "sibling" when any row of that name gives a sibling, so that a sibling binding is never sent
944
+ * as a parent one; null when nothing here says (no relation, an anchor the roster does not list): the host
945
+ * answers that spawn itself. */
946
+ function routedSpawnBinding(oatsArgs, roster) {
947
+ const valueOf = (flag) => { const i = oatsArgs.indexOf(flag); return i >= 0 && oatsArgs[i + 1] && !oatsArgs[i + 1].startsWith("--") ? oatsArgs[i + 1] : undefined; };
948
+ const relation = valueOf("--relation"), relativeTo = valueOf("--relative-to");
949
+ if (valueOf("--parent") !== undefined || relation === "child") return "parent";
950
+ if ((relation === "sibling" || relation === "parent") && relativeTo) {
951
+ const anchors = (roster?.agents || []).flatMap((a) => a.instances || []).filter((i) => i?.instance === relativeTo);
952
+ // A sibling shares the anchor's parent, else links to the anchor; a new parent takes the anchor's slot.
953
+ const kinds = anchors.map((a) => relatedWorkBinding(relation === "sibling" ? { parentInstance: a.parentInstance, siblingInstance: a.instance } : a));
954
+ if (kinds.some((b) => b?.sibling)) return "sibling";
955
+ return kinds.some((b) => b?.parent) ? "parent" : null;
956
+ }
957
+ return !relation && valueOf("--work") === "attached" ? "parent" : null;
958
+ }
959
+
960
+ /** `oatsArgs` of a routed spawn that carries `--related-work` or its deprecated alias `--same-work`, as the
961
+ * host takes it: by a host that advertises instance-related-work, as `--related-work` (so that it says no
962
+ * deprecation of its own); by a host with only instance-same-work (sameWorkOnly), as `--same-work` when
963
+ * the spawn's binding is a parent or not known here (the host then refuses a spawn that records no parent
964
+ * itself), and refused with E_REMOTE_INCOMPATIBLE for a sibling binding, which that kernel cannot record;
965
+ * any other host refuses it (E_REMOTE_INCOMPATIBLE). */
966
+ function relatedWorkSpawnArgs(remote, target, oatsArgs, roster) {
967
+ const spelled = (flag) => oatsArgs.map((a) => (a === "--related-work" || a === "--same-work" ? flag : a)).filter((a, i, all) => a !== flag || all.indexOf(flag) === i);
968
+ if (remote.features.includes("instance-related-work")) return spelled("--related-work");
969
+ if (!sameWorkOnly(remote.features)) requireRemoteFeature(remote, target, "instance-related-work");
970
+ if (routedSpawnBinding(oatsArgs, roster) === "sibling") throw siblingNeedsRelatedWork(remote, target);
971
+ return spelled("--same-work");
972
+ }
973
+
974
+ const siblingNeedsRelatedWork = (remote, target) => serverError("E_REMOTE_INCOMPATIBLE", `remote oats ${remote.version} at ${target.sshHost} does not advertise instance-related-work, which a sibling binding needs (its instance-same-work binds a parent only); upgrade it there; nothing was sent`);
975
+
976
+ /** `args` of `instance related-work <instance> on|off …` (after `instance`, the route's --home pushed) for a
977
+ * host with only instance-same-work: the verb by its old name. `on` for an instance whose row on the host
978
+ * records no parent and a sibling is refused (E_REMOTE_INCOMPATIBLE): that kernel binds a parent only.
979
+ * `off`, and `on` for a row with a parent or none the roster lists, go as asked: the host answers them. */
980
+ function relatedWorkSurfaceArgs(remote, target, args, io) {
981
+ // The state is the one word after the instance that is no flag and no flag's value (as bin reads it).
982
+ const words = [];
983
+ for (let i = 2; i < args.length; i++) { if (args[i] === "--home" || args[i] === "--dir") i++; else if (!args[i].startsWith("--")) words.push(args[i]); }
984
+ if (words.length === 1 && words[0] === "on") {
985
+ const valueOf = (flag) => { const i = args.indexOf(flag); return i >= 0 && args[i + 1] !== undefined && !args[i + 1].startsWith("--") ? args[i + 1] : undefined; };
986
+ const home = valueOf("--home");
987
+ // The lineage is read in the scope the verb is sent to: its explicit --dir, else the registered workspace.
988
+ const status = runRemote(target, ["status", "--json", "--dir", valueOf("--dir") ?? target.workspace], { ...io, input: undefined }).envelope;
989
+ if (!status.ok) throw serverError(status.error?.code || "E_REMOTE", `cannot read ${args[1]} on ${target.sshHost} before setting its related work: ${status.error?.message || "status failed"}`);
990
+ const row = (status.result?.agents || []).flatMap((a) => a.instances || []).find((i) => i?.home && resolve(i.home) === resolve(home));
991
+ if (row && relatedWorkBinding(row)?.sibling) throw siblingNeedsRelatedWork(remote, target);
992
+ }
993
+ return ["same-work"];
994
+ }
995
+
996
+ /** A host's `status --json` result with each instance row's flag in this kernel's words, as rowRelatedWork
997
+ * reads it (the roster's rule): `relatedWork: true` or no key, and `sameWork: true` only beside it.
998
+ * Everything else is the host's answer as it gave it. */
999
+ function relatedWorkRows(result) {
1000
+ if (!result || typeof result !== "object" || !Array.isArray(result.agents)) return result;
1001
+ const features = hostFeatures(result);
1002
+ const row = (i) => {
1003
+ if (!i || typeof i !== "object") return i;
1004
+ const { sameWork: _sameWork, relatedWork: _relatedWork, ...rest } = i;
1005
+ return { ...rest, ...rowRelatedWork(i, features) };
1006
+ };
1007
+ return { ...result, agents: result.agents.map((a) => (a && typeof a === "object" && Array.isArray(a.instances) ? { ...a, instances: a.instances.map(row) } : a)) };
1008
+ }
1009
+
1010
+ /** The answer of an older host's `instance same-work`, `{ instance, sameWork }`, in this kernel's words, as
1011
+ * this kernel's verb answers: `relatedWork` beside its `sameWork` (an older host binds a parent only). A
1012
+ * refusal is relayed as is. */
1013
+ function relatedWorkAnswer(envelope) {
1014
+ if (!envelope?.ok || !envelope.result || typeof envelope.result !== "object" || !Object.hasOwn(envelope.result, "sameWork")) return envelope;
1015
+ const on = envelope.result.sameWork === true;
1016
+ return { ...envelope, result: { ...envelope.result, relatedWork: on, sameWork: on } };
1017
+ }
1018
+
926
1019
  /** The Desktop's per-instance reads and lifecycle plans, as the host's kernel
927
1020
  * answers them: the feature and API number the host must advertise first. */
928
1021
  const HOST_SURFACES = {
@@ -938,8 +1031,9 @@ const HOST_SURFACES = {
938
1031
  "instance background": { feature: "instance-background" },
939
1032
  // Feature instance-pin: the feature alone, as instance background.
940
1033
  "instance pin": { feature: "instance-pin" },
941
- // Feature instance-same-work: the feature alone, as instance color.
942
- "instance same-work": { feature: "instance-same-work" },
1034
+ // Feature instance-related-work: the feature alone, as instance color; a host with only instance-same-work
1035
+ // is asked by the old name (relatedWorkSurfaceArgs).
1036
+ "instance related-work": { feature: "instance-related-work" },
943
1037
  };
944
1038
 
945
1039
  function requireSurface(remote, target, surface) {
@@ -948,16 +1042,18 @@ function requireSurface(remote, target, surface) {
948
1042
  }
949
1043
  }
950
1044
 
951
- /** `readiness`, `instance events|git|diff|stop|color|background|pin|same-work` and `retire --plan` on the
1045
+ /** `readiness`, `instance events|git|diff|stop|color|background|pin|related-work` and `retire --plan` on the
952
1046
  * host: the instance is addressed as every routed session command addresses
953
1047
  * it (its name through a saved route or the host's roster, or an exact
954
1048
  * --home), the scope is an explicit --dir on the host or the registered
955
1049
  * workspace (readiness of a home is its own context), and the host's
956
1050
  * envelope is relayed unchanged. */
957
1051
  function routeHostSurface(serverId, cmd, oatsArgs, io) {
1052
+ // `instance same-work` is the deprecated alias of `instance related-work` (the dispatch said so): one route.
1053
+ if (cmd === "instance" && oatsArgs[0] === "same-work") oatsArgs = ["related-work", ...oatsArgs.slice(1)];
958
1054
  const key = cmd === "instance" ? `instance ${oatsArgs[0]}` : cmd === "retire" ? "retire plan" : cmd;
959
1055
  const surface = HOST_SURFACES[key];
960
- if (!surface) throw serverError("E_USAGE", `--server routes instance events, git, diff, stop, color, background, pin and same-work only (not ${key})`);
1056
+ if (!surface) throw serverError("E_USAGE", `--server routes instance events, git, diff, stop, color, background, pin and related-work only (not ${key})`);
961
1057
  const args = [...oatsArgs];
962
1058
  const valueOf = (flag) => { const i = args.indexOf(flag); return i >= 0 && args[i + 1] !== undefined && !args[i + 1].startsWith("--") ? args[i + 1] : undefined; };
963
1059
  const name = cmd === "readiness" ? undefined : args[cmd === "instance" ? 1 : 0];
@@ -970,10 +1066,14 @@ function routeHostSurface(serverId, cmd, oatsArgs, io) {
970
1066
  target = route.target;
971
1067
  if (home === undefined) args.push("--home", route.home);
972
1068
  } else target = targetOf(io.server || getServer(serverId));
973
- requireSurface(checkRemote(target, io), target, surface);
1069
+ const remote = checkRemote(target, io);
1070
+ // An older host knows `instance related-work` by its old name only: asked by that name, or refused.
1071
+ const oldName = key === "instance related-work" && sameWorkOnly(remote.features);
1072
+ if (oldName) args.splice(0, 1, ...relatedWorkSurfaceArgs(remote, target, args, io));
1073
+ else requireSurface(remote, target, surface);
974
1074
  if (!args.includes("--dir") && !(cmd === "readiness" && home !== undefined)) args.push("--dir", target.workspace);
975
1075
  const { envelope, stderr } = runRemote(target, [cmd, ...args, "--json"], io);
976
- return { envelope, stderr };
1076
+ return { envelope: oldName ? relatedWorkAnswer(envelope) : envelope, stderr };
977
1077
  }
978
1078
 
979
1079
  // ------------------------------------------------------------------- roster
@@ -1021,6 +1121,11 @@ const rowBackground = (i) => (i.background === true ? { background: true } : {})
1021
1121
  /** `pinned` (feature instance-pin) as `background`: relayed ONLY when the host's row says exactly `true`;
1022
1122
  * absent is the only reading of "not pinned", so any other value (`"true"`, `1`) is dropped, never false. */
1023
1123
  const rowPinned = (i) => (i.pinned === true ? { pinned: true } : {});
1124
+ /** `board` (feature instance-board) as the host's row says it, read by this kernel's own rule
1125
+ * (lib/instance-board.mjs readRemoteBoard: every fact and question within its rules and the whole within
1126
+ * the row bound, else an empty board): relayed ONLY when the host's row has the key, so a host whose
1127
+ * kernel predates the feature says nothing. */
1128
+ const rowBoard = (i) => (Object.hasOwn(i, "board") ? { board: readRemoteBoard(i.board) } : {});
1024
1129
  /** `retire` (feature status-retire-state) as `waitingOnYou` is, relayed ONLY when the host's row has the
1025
1130
  * key: a host whose kernel predates the feature omits it, and its rows say nothing. Absent is the
1026
1131
  * only reading of "no retire", so a value the kernel's own read refuses is dropped, never null. */
@@ -1028,9 +1133,14 @@ const rowRetire = (i) => {
1028
1133
  const retire = Object.hasOwn(i, "retire") ? readRetireState(i.retire) : undefined;
1029
1134
  return retire ? { retire } : {};
1030
1135
  };
1031
- /** `sameWork` (feature instance-same-work) as `background`: relayed ONLY when the host's row says
1032
- * `sameWork: true`, the one value a row carries; anything else, and a host that omits it, is absent. */
1033
- const rowSameWork = (i) => (i.sameWork === true ? { sameWork: true } : {});
1136
+ /** `relatedWork` (feature instance-related-work) as `background`: relayed ONLY as `true`, when the host's row
1137
+ * says `relatedWork: true`, or, from a host whose `features` (hostFeatures) have instance-same-work and not
1138
+ * instance-related-work, `sameWork: true`: that older kernel's flag, a parent binding by the old name. Anything
1139
+ * else, and a host that omits it, is absent. Beside it, `sameWork: true` (feature instance-same-work, the
1140
+ * compatibility layer) when the host's row says exactly that: a parent binding, which every host reports by
1141
+ * both names; never without `relatedWork`. The one rule of both keys, for the roster and the routed status. */
1142
+ const rowRelatedWork = (i, features) => (i.relatedWork === true || (sameWorkOnly(features) && i.sameWork === true)
1143
+ ? { relatedWork: true, ...(i.sameWork === true ? { sameWork: true } : {}) } : {});
1034
1144
  /** `sessionEnd` (feature session-resume, #1628) as `retire` is: relayed ONLY when the host's row has the
1035
1145
  * key, which a host whose kernel predates the feature never sends, so its rows say nothing. A value that
1036
1146
  * is not one of the contract's (lib/session-resume-contract.mjs SESSION_END) drops the key. */
@@ -1139,7 +1249,7 @@ export async function rosterGroups({ server, workspaceKeys, io = {} } = {}) {
1139
1249
  harness: i.harness || i.runtime || null, backend: i.tmux ? "tmux" : null,
1140
1250
  ...(i.sessionTarget ? { sessionTarget: i.sessionTarget } : {}), ...(i.tmux ? { tmux: i.tmux } : {}),
1141
1251
  running: typeof i.running === "boolean" ? i.running : null, ...(i.runtimeError ? { runtimeError: i.runtimeError } : {}),
1142
- ...rowFacts(i), ...rowWaiting(i), ...rowRetire(i), ...rowBackground(i), ...rowPinned(i), ...rowSameWork(i), ...rowSessionEnd(i),
1252
+ ...rowFacts(i), ...rowWaiting(i), ...rowRetire(i), ...rowBackground(i), ...rowPinned(i), ...rowBoard(i), ...rowRelatedWork(i, g.probe.features), ...rowSessionEnd(i),
1143
1253
  // Every row the host reports is addressed by its home, saved
1144
1254
  // route or not; savedRoute says only that it was spawned from here.
1145
1255
  retirePending: !!i.retirePending, rollbackIncomplete: !!i.rollbackIncomplete, savedRoute: !!snap, addressable: true, missingRemotely: false,
@@ -3,12 +3,12 @@
3
3
  "packages": {
4
4
  "oats.okf": {
5
5
  "url": "https://github.com/awebai/oats-okf.git",
6
- "ref": "v6.2.0",
6
+ "ref": "v6.3.0",
7
7
  "path": "oats-package"
8
8
  },
9
9
  "oats.aweb": {
10
10
  "url": "https://github.com/awebai/oats-aweb.git",
11
- "ref": "v1.43.0",
11
+ "ref": "v1.46.0",
12
12
  "path": "oats-package"
13
13
  },
14
14
  "oats.jira": {
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "oats.framework": {
50
50
  "url": "https://github.com/awebai/oats.git",
51
- "ref": "oats-framework/v1.26.0",
51
+ "ref": "oats-framework/v1.27.0",
52
52
  "path": "oats-package"
53
53
  }
54
54
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awebai/oats",
3
- "version": "0.69.21",
3
+ "version": "0.69.23",
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",
@@ -9,8 +9,8 @@
9
9
  Why these and not others: the four traced cases on #1879 (schedule edit at 0.40, Remove at 0.49 and
10
10
  0.53, the Stop outcome at 0.52) all sit where the Desktop words a consequence itself or writes a whole
11
11
  definition. What stays on is a read, a terminal, or a change fenced by the kernel's own answer: Spawn
12
- applies only the decision its preview showed (`--expect-decision`), and Start, Restart, colour and
13
- background report only an answer the Desktop reads in full (each fails closed on a shape it does not
12
+ applies only the decision its preview showed (`--expect-decision`), and Start, Restart, colour,
13
+ background and pin report only an answer the Desktop reads in full (each fails closed on a shape it does not
14
14
  know).
15
15
 
16
16
  Enforcement is not the renderer's. Every place an operation enters the backend asks
@@ -65,6 +65,7 @@ export const OPERATIONS = Object.freeze({
65
65
  // ── An instance's own record.
66
66
  'POST /api/instance-color': allowed("colour: one field of the instance's own record, the answer read in full"),
67
67
  'POST /api/instance-background': allowed("background: one field of the instance's own record, the answer read in full"),
68
+ 'POST /api/instance-pin': allowed("pin: one field of the instance's own record, the answer read in full"),
68
69
  // ── Reads.
69
70
  'POST /api/instance-git git': read('git'),
70
71
  'POST /api/instance-git diff': read('git'),
@@ -0,0 +1,69 @@
1
+ /** The workspace's capabilities as one flat list, as both clients draw it (the Desktop UI rework, slice 3b: "show
2
+ * core and other ones as really the same"). Core capabilities (a knowledge, messaging or tasks `layer`) come first
3
+ * in that order, then every other one by name. Each entry carries what its row says: its core slot, whether it
4
+ * is one of the workspace's defaults (`oats workspace status` `defaults`), and who made it (capability-origin.mjs).
5
+ * Nothing is inferred: a default is matched to a row only by the name and the source the kernel reports, and
6
+ * with no reported `defaults` no row is called a default. Pure and DOM-free. */
7
+ import { sameRepo } from './repo-moves.mjs';
8
+ import { memberNames, hostKeyOf, matchCapabilities } from './capability-rows.mjs';
9
+ import { capabilityOrigin } from './capability-origin.mjs';
10
+
11
+ /** The core slots, in the one order every surface shows them. */
12
+ export const CORE_LAYERS = Object.freeze(['knowledge', 'messaging', 'tasks']);
13
+
14
+ const record = v => !!v && typeof v === 'object' && !Array.isArray(v);
15
+ const text = v => typeof v === 'string' && v ? v : null;
16
+ const list = v => Array.isArray(v) ? v : [];
17
+
18
+ /** Whether a declared default (`{ name, from }`: `from` is "package", "here" or a member key) names this row. */
19
+ export function defaultNames(entry, row, hostKey = null) {
20
+ if (!record(entry) || entry.name !== row?.name) return false;
21
+ if (entry.from === 'package') return row.kind === 'package';
22
+ if (entry.from === 'here') return row.kind === 'member' && !!text(hostKey) && sameRepo(row.repoKey, hostKey);
23
+ if (text(entry.from)) return row.kind === 'member' && sameRepo(row.repoKey, entry.from);
24
+ return false;
25
+ }
26
+ /** The row's place in the workspace's defaults: 'on' (every soul starts with it), 'off' (the workspace turns it
27
+ * off), or null (not a default, or no defaults reported). A turned-off entry reports no source: it is matched by
28
+ * name. A slot default fills its core slot (`defaults.slots.<layer>`). */
29
+ export function defaultState(status, row) {
30
+ const defaults = status?.defaults;
31
+ if (!record(defaults) || !row) return null;
32
+ const hostKey = hostKeyOf(status);
33
+ for (const cap of list(defaults.capabilities)) {
34
+ if (!record(cap) || cap.name !== row.name) continue;
35
+ if (cap.off === true) return 'off';
36
+ if (defaultNames(cap, row, hostKey)) return 'on';
37
+ }
38
+ const slot = text(row.layer) && record(defaults.slots) ? defaults.slots[row.layer] : null;
39
+ return record(slot) && defaultNames(slot, row, hostKey) ? 'on' : null;
40
+ }
41
+ /** The rank of a row in the list: a core slot's index, else after every core one. */
42
+ const rank = row => { const at = CORE_LAYERS.indexOf(row?.layer); return at < 0 ? CORE_LAYERS.length : at; };
43
+
44
+ /** The list's entries, in drawn order: `{ row, core, default, origin }`. `core`: the row's core slot or null;
45
+ * `default`: defaultState; `origin`: capabilityOrigin. `query` narrows by name (matchCapabilities). */
46
+ export function capabilityList(rows, status, { query = '' } = {}) {
47
+ const names = memberNames(status);
48
+ return matchCapabilities(list(rows), query)
49
+ .map(row => ({ row, core: CORE_LAYERS.includes(row.layer) ? row.layer : null, default: defaultState(status, row), origin: capabilityOrigin(row, status, names) }))
50
+ .sort((a, b) => rank(a.row) - rank(b.row) || String(a.row.name).localeCompare(String(b.row.name)) || a.origin.by.localeCompare(b.origin.by));
51
+ }
52
+
53
+ /** What the list's lead sentence needs, from the reported defaults: null when the kernel reports none (no claim).
54
+ * `empty`: the workspace sets no default at all. `emptySlots`: the core slots no default fills (by a slot or a
55
+ * named capability of that layer), in CORE_LAYERS order. `unlisted`: the declared defaults no catalog row
56
+ * matches (`{ name, off }`), so the list cannot show them as rows; a turned-off one is unlisted when no row has
57
+ * its name. */
58
+ export function defaultsSummary(status, rows) {
59
+ const defaults = status?.defaults;
60
+ if (!record(defaults)) return null;
61
+ const hostKey = hostKeyOf(status), all = list(rows);
62
+ const slots = CORE_LAYERS.map(layer => [layer, record(defaults.slots) && record(defaults.slots[layer]) && text(defaults.slots[layer].name) ? defaults.slots[layer] : null]);
63
+ const caps = list(defaults.capabilities).filter(cap => record(cap) && text(cap.name));
64
+ const listed = entry => entry.off === true ? all.some(row => row?.name === entry.name) : all.some(row => defaultNames(entry, row, hostKey));
65
+ const filled = new Set(slots.filter(([, value]) => value).map(([layer]) => layer));
66
+ for (const cap of caps) if (cap.off !== true) for (const row of all) if (defaultNames(cap, row, hostKey) && CORE_LAYERS.includes(row.layer)) filled.add(row.layer);
67
+ const unlisted = [...slots.filter(([, value]) => value).map(([, value]) => value), ...caps].filter(entry => !listed(entry)).map(entry => ({ name: entry.name, off: entry.off === true }));
68
+ return { empty: !filled.size && !caps.length, emptySlots: CORE_LAYERS.filter(layer => !filled.has(layer)), unlisted };
69
+ }
@@ -0,0 +1,54 @@
1
+ /** Who made a capability, as both clients say it on a capability row (the Desktop UI rework, D24): "official"
2
+ * (a small ✓ whose words say which fact made it official: "Official: in the OATS catalog" or "Official: from the
3
+ * OATS repository") or "by <source>". The words say only what the rule shows: "verified" or "published by OATS" is a
4
+ * trust claim a client rule can't make (dec-feb06c322c75, "listed is not trusted"); a kernel fact for "official" is
5
+ * oats-project/oats#1981. Decided from facts the kernel
6
+ * already reports, never from a name (an `oats.` prefix proves nothing) and never from a new field:
7
+ *
8
+ * - a **package** capability is official when `oats workspace status` reports its package pinned from the
9
+ * catalog (`packages[].source` is `catalog:<id>`): only the reviewed official catalog makes a package
10
+ * pinnable by id (docs/packages.md, docs/official-catalog.md). Caveat: `OATS_PACKAGE_CATALOG` can point a kernel
11
+ * at another catalog file, and status does not say which one was read. An operator who points it elsewhere gets the
12
+ * ✓ for that catalog's packages: their choice (the effort's lead, 2026-11-19).
13
+ * A package pinned by `git:<repo>@<ref>` is "by <repo>", whatever its id;
14
+ * - a **member** capability is official when its repository is the OATS repository itself
15
+ * (github.com/oats-project/oats, or its old key github.com/awebai/oats: repo-moves.mjs);
16
+ * - anything else (another member, an external source, a package status does not list) is "by <source>".
17
+ *
18
+ * Pure and DOM-free; the words are ORIGIN_COPY so no client writes its own. */
19
+ import { sameRepo } from './repo-moves.mjs';
20
+ import { capabilitySource, memberNames } from './capability-rows.mjs';
21
+
22
+ /** The OATS repository's key (its moved spelling is the same repository: sameRepo). */
23
+ export const OATS_REPO_KEY = 'github.com/oats-project/oats';
24
+
25
+ export const ORIGIN_COPY = Object.freeze({
26
+ official: 'OATS',
27
+ // The mark's words per the fact that made it official (`reason`): its tooltip and its accessible name.
28
+ officialTitle: Object.freeze({ catalog: 'Official: in the OATS catalog', 'oats-repo': 'Official: from the OATS repository' }),
29
+ by: source => `by ${source}`,
30
+ });
31
+
32
+ const text = v => typeof v === 'string' && v ? v : null;
33
+ const list = v => Array.isArray(v) ? v : [];
34
+ /** `git:<repo>@<ref>` → the repository's last path segment, without `.git`; null for anything else. */
35
+ function gitRepoName(source) {
36
+ const m = /^git:(.+)@[^@]*$/.exec(source || '');
37
+ if (!m) return null;
38
+ return m[1].replace(/\.git$/, '').split(/[/:]/).filter(Boolean).pop() || null;
39
+ }
40
+
41
+ /** `{ official, by, reason }` for a catalog row (`oats capabilities`, or a soul's resolved capability in the same
42
+ * shape). `by` is the source as words ("OATS" when official); `reason` is the fact that decided it: 'catalog'
43
+ * (a package pinned from the catalog), 'oats-repo' (a member capability of the OATS repository), else null.
44
+ * `status`: workspace status (packages[] and members[]); `names`: memberNames(status) when the caller holds it. */
45
+ export function capabilityOrigin(row, status, names = memberNames(status)) {
46
+ if (row?.kind === 'package') {
47
+ const pkg = list(status?.packages).find(p => p?.id === row.package);
48
+ const source = text(pkg?.source);
49
+ if (source && source.startsWith('catalog:')) return { official: true, by: ORIGIN_COPY.official, reason: 'catalog' };
50
+ return { official: false, by: gitRepoName(source) || text(row.package) || text(row.name) || 'a package', reason: null };
51
+ }
52
+ if (row?.kind === 'member' && text(row.repoKey) && sameRepo(row.repoKey, OATS_REPO_KEY)) return { official: true, by: ORIGIN_COPY.official, reason: 'oats-repo' };
53
+ return { official: false, by: capabilitySource(row || {}, names).label, reason: null };
54
+ }
@@ -655,7 +655,7 @@ export function operationArgs(args) {
655
655
  }
656
656
  /** A verb that writes one field of an instance's own record: `oats instance <verb> <instance> <values…> --home <home>
657
657
  * (--dir <context> | --server <server>) --json`, addressed as `oats instance stop` is (lifecycle-cli.mjs: a routed
658
- * command never carries --dir). Shared by `instance color` and `instance background` (server/instance-record.mjs);
658
+ * command never carries --dir). Shared by `instance color`, `instance background` and `instance pin` (server/instance-record.mjs);
659
659
  * each checks its own value first. Anything out of shape is refused here and nothing runs. A read's deadline:
660
660
  * 30 s, 45 s routed. The envelope comes back as the kernel printed it; the caller decodes it. */
661
661
  function runInstanceRecord(bin, { instance, home, context, server }, verb, values, io) {
@@ -686,6 +686,14 @@ export async function cliInstanceBackground(bin, args, io = {}) {
686
686
  if (typeof background !== "boolean") return instanceRecordRefused();
687
687
  return runInstanceRecord(bin, args, "background", [background ? "on" : "off"], io);
688
688
  }
689
+ /** Whether an instance is pinned (feature instance-pin): `oats instance pin <instance> (on | off) …`
690
+ * (runInstanceRecord). `pinned` is a boolean; anything else is refused here and nothing runs. Over `--server`, a
691
+ * host without the feature refuses it (E_REMOTE_INCOMPATIBLE). */
692
+ export async function cliInstancePin(bin, args, io = {}) {
693
+ const { pinned } = args;
694
+ if (typeof pinned !== "boolean") return instanceRecordRefused();
695
+ return runInstanceRecord(bin, args, "pin", [pinned ? "on" : "off"], io);
696
+ }
689
697
 
690
698
  /** `maxAge` (feature observe-max-age) is inspect's alone; `features` is the probe's list and
691
699
  * gates the flags (also `instructions`, `skills` and `composedSkills`), so an undeclared kernel gets the flagless argv even when a value is given. */
@@ -227,14 +227,19 @@ export function deploymentStatusData(document, deployment) {
227
227
  // Feature instance-background (#1579): the row is placed in the Background section. Exactly true only; any
228
228
  // other value is dropped, never checked: the row stays in the main tree.
229
229
  if (own(instance, 'background') && instance.background === true) row.background = true;
230
+ // Feature instance-pin: the row is listed first in its machine's list (instance-tree.mjs rowPinned). Exactly
231
+ // true only; any other value is dropped, never checked: the row keeps the roster's order.
232
+ if (own(instance, 'pinned') && instance.pinned === true) row.pinned = true;
230
233
  // #802 (feature worktree-event): a spawn running its worktree hooks, verifiably alive. Boolean true only;
231
234
  // any other value is dropped, never checked: the row stays an ordinary one.
232
235
  if (own(instance, 'spawnInProgress') && instance.spawnInProgress === true) row.spawnInProgress = true;
233
236
  // Session resume: how the instance's last session ended, one of SESSION_ENDS exactly. Any other value is
234
237
  // dropped, never checked: the row reads as one that did not say.
235
238
  if (own(instance, 'sessionEnd') && SESSION_END_VALUES.includes(instance.sessionEnd)) row.sessionEnd = instance.sessionEnd;
236
- // #1577 (feature instance-same-work): the child does its parent's work, so its parent line is drawn
237
- // (same-work.mjs). Boolean true only; any other value is dropped, never checked: the row reads unflagged.
239
+ // Related work (features instance-related-work, and instance-same-work before it): the row's work is
240
+ // related to its parent's, or a top-level row's to its sibling's, so the line between them is drawn
241
+ // (related-work.mjs). Boolean true only; any other value is dropped, never checked: the row reads unflagged.
242
+ if (own(instance, 'relatedWork') && instance.relatedWork === true) row.relatedWork = true;
238
243
  if (own(instance, 'sameWork') && instance.sameWork === true) row.sameWork = true;
239
244
  if (own(instance, 'modules')) row.modules = modules(instance.modules);
240
245
  if (own(instance, 'soul')) row.soul = soulSource(instance.soul);
@@ -127,7 +127,8 @@ export function panelInstance(i) {
127
127
  // Session resume: how the last session ended, as deployment-data.mjs validated it (SESSION_ENDS); absent stays
128
128
  // absent. The resume trigger reads it (session-resume-trigger.mjs lostLocalHomes).
129
129
  ...(i.sessionEnd !== undefined ? { sessionEnd: i.sessionEnd } : {}),
130
- // #1577: the kernel's same-work flag (deployment-data.mjs keeps it as true only); same-work.mjs reads it.
130
+ // The kernel's related-work flags (deployment-data.mjs keeps each as true only); related-work.mjs reads them.
131
+ ...(i.relatedWork === true ? { relatedWork: true } : {}),
131
132
  ...(i.sameWork === true ? { sameWork: true } : {}),
132
133
  ...(i.captured ? { captured: true } : {}),
133
134
  // Needs input (PR K): the validated claim (or null, unknown) as status reported it; absent stays absent.
@@ -139,6 +140,8 @@ export function panelInstance(i) {
139
140
  ...(instanceColor(i) !== null ? { color: instanceColor(i) } : {}),
140
141
  // Feature instance-background (#1579): exactly true, else absent (instance-tree.mjs backgroundPlacement).
141
142
  ...(i.background === true ? { background: true } : {}),
143
+ // Feature instance-pin: exactly true, else absent (instance-tree.mjs rowPinned).
144
+ ...(i.pinned === true ? { pinned: true } : {}),
142
145
  team: i.team || null,
143
146
  };
144
147
  }
@@ -0,0 +1,50 @@
1
+ /** Home's board and its flat list of agents (Desktop UI rework, slice 2): the groupings both clients draw, so the
2
+ * TUI can render the same Home later. Pure, no DOM, never throws. Rows are `oats status --json` instance rows as
3
+ * the roster holds them; nothing here reorders the roster (needs-input-preserves-liveness-and-recognition: the
4
+ * urgency order lives on Home only).
5
+ *
6
+ * homeBoard(rows, { stale }) -> { needsYou: [{ row, claim }], running: [row] }
7
+ * needsYou: every row with a claim it may show (waiting-on-you.mjs `waitingClaim`, the one liveness gate,
8
+ * `stale(row)` the roster's held-stale rule), newest claim first (its `since`), then the roster's
9
+ * order. running: every other live row (`running === true`, no reported state but `running`, a
10
+ * reached server), newest spawn first (instance-tree.mjs `rosterOrder`). There is no working/idle
11
+ * fact yet (the activity contract is not built), and none is inferred
12
+ * (instance-activity-is-reported-not-inferred): a live row is "running". Stopped and unknown rows
13
+ * aren't on the board (D11). The "New" group (stopped or finished since you last looked) has no
14
+ * fact to read, so it isn't here.
15
+ * homeAgents(rows) -> rows: every agent, running or stopped, in the roster's order (newest spawn first).
16
+ * startedBy(row) -> string | null: who started it, the row's attributed human (attributed-human.mjs), else
17
+ * its parent's name (`parentInstance`), else null. */
18
+ import { waitingClaim } from './waiting-on-you.mjs';
19
+ import { rosterOrder } from './instance-tree.mjs';
20
+ import { attributedHumanData } from './attributed-human.mjs';
21
+ import { instanceDisplayName } from './instance-display-name.mjs';
22
+
23
+ const record = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
24
+ const rowsOf = (rows) => (Array.isArray(rows) ? rows.filter((row) => record(row) && typeof row.instance === 'string' && row.instance) : []);
25
+ const since = (claim) => { const t = Date.parse(claim.since); return Number.isFinite(t) ? t : -Infinity; };
26
+ const live = (row) => row.running === true && row.serverUnreached !== true && (row.runtimeState == null || row.runtimeState === 'running');
27
+
28
+ export function homeBoard(rows, { stale = () => false } = {}) {
29
+ const needsYou = [], running = [];
30
+ for (const row of rowsOf(rows)) {
31
+ const claim = waitingClaim(row, { stale: stale(row) === true });
32
+ if (claim) needsYou.push({ row, claim });
33
+ else if (live(row)) running.push(row);
34
+ }
35
+ needsYou.sort((a, b) => since(b.claim) - since(a.claim) || rosterOrder(a.row, b.row));
36
+ running.sort(rosterOrder);
37
+ return { needsYou, running };
38
+ }
39
+
40
+ export function homeAgents(rows) {
41
+ return rowsOf(rows).sort(rosterOrder);
42
+ }
43
+
44
+ export function startedBy(row) {
45
+ const human = attributedHumanData(row?.attributedHuman);
46
+ if (human) return human;
47
+ const parent = typeof row?.parentInstance === 'string' && row.parentInstance ? row.parentInstance : null;
48
+ if (!parent) return null;
49
+ return instanceDisplayName(parent) || parent;
50
+ }
@@ -0,0 +1,28 @@
1
+ /** Pinned instances (feature instance-pin; docs/desktop-cli-api.md "Pinned instances"): the one reading of the
2
+ * kernel's answer to `oats instance pin`, for both clients. The Desktop's backend route reads it through its record
3
+ * boundary (packages/desktop/server/instance-pin.mjs); the TUI's pin key runs the verb here (`pinInstance`).
4
+ *
5
+ * The kernel's answer is `{ instancePinApi: 1, instance, home, pinned, changed }`: one for another instance or
6
+ * another home, or of another shape, is an unknown outcome, never a success. */
7
+ import { cliInstancePin } from './cli-adapter.mjs';
8
+ import { recordOutcome } from './instance-record-outcome.mjs';
9
+
10
+ /** The kernel's success for exactly the asked instance and home, as `{ status: 'ok', instance, pinned, changed }`;
11
+ * else null. `asked`: `{ instance, home }`. */
12
+ export const pinAnswer = (r, asked) => r?.instancePinApi === 1 && r.instance === asked.instance && r.home === asked.home
13
+ && typeof r.pinned === 'boolean' && typeof r.changed === 'boolean'
14
+ ? { status: 'ok', instance: r.instance, pinned: r.pinned, changed: r.changed } : null;
15
+
16
+ /** What the command answered (instance-record-outcome.mjs): ok (pinAnswer), refused (an error the CLI printed) or
17
+ * unknown. */
18
+ export const pinOutcome = (envelope, asked) => recordOutcome(envelope, result => pinAnswer(result, asked));
19
+
20
+ /** Pin or unpin one instance and read the answer: `oats instance pin <instance> on|off --home <home> (--dir <context>
21
+ * | --server <server>) --json` (cli-adapter.mjs cliInstancePin, which refuses anything out of shape and runs
22
+ * nothing). `args`: `{ instance, home, pinned, context | server }`; `io` as cliInstancePin's (`exec`, `cwd`). A call
23
+ * that throws is an unknown outcome. */
24
+ export async function pinInstance(bin, args, io = {}) {
25
+ let envelope;
26
+ try { envelope = await cliInstancePin(bin, args, io); } catch { return { status: 'unknown', reason: { code: 'E_OUTCOME_UNKNOWN' } }; }
27
+ return pinOutcome(envelope, args);
28
+ }
@@ -0,0 +1,31 @@
1
+ /** What a kernel verb that writes one field of an instance's own record answered (`oats instance color`,
2
+ * `oats instance background`, `oats instance pin`), as a client reads it: the Desktop's backend boundary
3
+ * (packages/desktop/server/instance-record.mjs) and the TUI's pin key (instance-pin.mjs) read it here, once. Only
4
+ * an error the installed CLI printed is a refusal (kernel-made.mjs); one the adapter wrote (a timeout, no envelope,
5
+ * a nonzero exit) is an unknown outcome, as is a success the verb's `answer(result)` does not read as the
6
+ * contract's (it returns the ok answer, or null).
7
+ *
8
+ * Answers: `{ status: 'ok', … }` (the verb's own), `{ status: 'refused', reason: { code, message } }`, or
9
+ * `{ status: 'unknown', reason: { code } }` (the record may have changed: read the roster again). */
10
+ import { madeByKernel } from './kernel-made.mjs';
11
+
12
+ const CODE = /^E_[A-Z0-9_]{1,62}$/;
13
+ const record = v => v !== null && typeof v === 'object' && !Array.isArray(v);
14
+ const text = (v, max) => typeof v === 'string' && v.length > 0 && v.length <= max && !/[\x00-\x1f\x7f]/.test(v);
15
+
16
+ /** The codes this client's CLI runner gives a run that ended without an answer (own-codes.mjs): such a run's outcome
17
+ * is unknown, and its code says why. Any other code there reads as E_OUTCOME_UNKNOWN. */
18
+ const CLI_RUN_CODES = new Set(['E_CLI_FAILED', 'E_CLI_OUTPUT_LIMIT', 'E_CLI_PROTOCOL', 'E_CLI_TIMEOUT', 'E_CLI_UNAVAILABLE']);
19
+
20
+ export function recordOutcome(envelope, answer) {
21
+ if (envelope?.ok === true) {
22
+ let ok = null;
23
+ try { ok = record(envelope.result) ? answer(envelope.result) : null; } catch { ok = null; }
24
+ return ok ?? { status: 'unknown', reason: { code: 'E_OUTCOME_UNKNOWN' } };
25
+ }
26
+ const error = envelope?.ok === false ? envelope.error : null;
27
+ if (madeByKernel(error) && typeof error.code === 'string' && CODE.test(error.code)) {
28
+ return { status: 'refused', reason: { code: error.code, message: text(error.message, 512) ? error.message : '' } };
29
+ }
30
+ return { status: 'unknown', reason: { code: CLI_RUN_CODES.has(error?.code) ? error.code : 'E_OUTCOME_UNKNOWN' } };
31
+ }