@awebai/oats 0.52.0 → 0.53.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.
- package/README.md +2 -1
- package/bin/oats.mjs +304 -92
- package/docs/capabilities.md +66 -4
- package/docs/configuration.md +66 -3
- package/docs/desktop-cli-api.md +673 -58
- package/docs/desktop-instance-start.md +25 -12
- package/docs/execution-targets.md +1 -0
- package/docs/implementation.md +175 -11
- package/docs/integrations.md +6 -3
- package/docs/knowledge.md +2 -2
- package/docs/macos-test-runs.md +246 -0
- package/docs/official-catalog.md +5 -5
- package/docs/packages.md +14 -14
- package/docs/release-lane.md +210 -6
- package/docs/release-notes/v0.53.0.md +1274 -0
- package/docs/schedules.md +7 -1
- package/docs/souls-and-instances.md +237 -15
- package/docs/tui.md +453 -21
- package/docs/upgrading.md +298 -0
- package/docs/workspaces.md +3 -3
- package/lib/automations.mjs +22 -22
- package/lib/claim.mjs +93 -4
- package/lib/config-data.mjs +4 -1
- package/lib/core.mjs +569 -121
- package/lib/instance-events.mjs +19 -1
- package/lib/instance-git.mjs +39 -3
- package/lib/instance-inspect.mjs +5 -6
- package/lib/instance-lifecycle.mjs +145 -18
- package/lib/instance-resolution.mjs +59 -6
- package/lib/launch-preference.mjs +226 -15
- package/lib/local-edit.mjs +118 -0
- package/lib/packages.mjs +13 -4
- package/lib/pi-bridge.mjs +308 -0
- package/lib/refused-text.mjs +11 -0
- package/lib/remote.mjs +190 -25
- package/lib/resolve.mjs +2 -1
- package/lib/retained-after-retire.mjs +2 -2
- package/lib/retire-output.mjs +12 -1
- package/lib/schedule-host.mjs +6 -35
- package/lib/shell-word.mjs +13 -0
- package/lib/soul-launch-verbs.mjs +153 -0
- package/lib/stable-node.mjs +62 -0
- package/lib/teams-verbs.mjs +18 -46
- package/lib/workspace.mjs +49 -19
- package/package-catalog.json +4 -4
- package/package.json +2 -1
- package/packages/client/attach-exit.mjs +25 -0
- package/packages/client/cli-adapter.mjs +16 -3
- package/packages/client/cli-locator.mjs +2 -2
- package/packages/client/deployment-contract.mjs +4 -0
- package/packages/client/deployment-facts.mjs +71 -10
- package/packages/client/deployment-panel.mjs +49 -11
- package/packages/client/deployment-read-cli.mjs +7 -3
- package/packages/client/display-text.mjs +8 -2
- package/packages/client/instance-acts.mjs +46 -10
- package/packages/client/instance-events-contract.mjs +4 -2
- package/packages/client/instance-presentation.mjs +66 -2
- package/packages/client/instance-tree.mjs +23 -14
- package/packages/client/kernel-lines.mjs +31 -0
- package/packages/client/kernel-made.mjs +23 -0
- package/packages/client/launch-prompt-outcome.mjs +51 -16
- package/packages/client/lifecycle-contract.mjs +45 -4
- package/packages/client/liveness.mjs +14 -1
- package/packages/client/own-codes.mjs +31 -0
- package/packages/client/panel-views.mjs +18 -11
- package/packages/client/readiness-contract.mjs +3 -1
- package/packages/client/remote-address.mjs +34 -9
- package/packages/client/remote-identity-memory.mjs +94 -0
- package/packages/client/remote-roster.mjs +92 -6
- package/packages/client/session-attach.mjs +175 -0
- package/packages/client/spawn-apply-contract.mjs +16 -4
- package/packages/client/spawn-messages.mjs +26 -3
- package/packages/client/spawn-preview-cli.mjs +8 -2
- package/packages/client/spawn-preview-contract.mjs +5 -1
- package/packages/client/terminal-exec.mjs +21 -0
- package/packages/client/workspace-choices.mjs +95 -0
- package/packages/client/workspace-views.mjs +39 -3
- package/packages/record/README.md +21 -0
- package/packages/record/bin/setup.mjs +108 -15
- package/packages/tui/README.md +30 -12
- package/packages/tui/lib/actions.mjs +16 -1
- package/packages/tui/lib/client.mjs +32 -1
- package/packages/tui/lib/config.mjs +151 -0
- package/packages/tui/lib/main.mjs +117 -46
- package/packages/tui/lib/model.mjs +392 -0
- package/packages/tui/lib/read.mjs +473 -0
- package/packages/tui/lib/store.mjs +364 -0
- package/packages/tui/lib/term/keys.mjs +44 -0
- package/packages/tui/lib/term/screen.mjs +16 -4
- package/packages/tui/lib/term/text.mjs +60 -0
- package/packages/tui/lib/term/tty.mjs +13 -3
- package/packages/tui/lib/views/detail.mjs +46 -0
- package/packages/tui/lib/views/frame.mjs +230 -36
- package/packages/tui/lib/views/help.mjs +125 -13
- package/packages/tui/lib/views/instances.mjs +137 -0
- package/packages/tui/lib/views/scroll.mjs +19 -0
- package/packages/tui/lib/views/switcher.mjs +97 -0
- package/skills/oats-getting-started/SKILL.md +2 -2
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Remote terminal addressing is an installed-CLI operation, never a renderer
|
|
2
|
+
// supplied SSH command, executable path, socket or server registration.
|
|
3
|
+
//
|
|
4
|
+
// Opening an agent's terminal with the kernel's own viewer (`oats session attach`): the arguments
|
|
5
|
+
// of the viewer for this machine and for another, whether its detach key can be used, and, for
|
|
6
|
+
// another machine, the preflight (`oats session inspect`) that runs before the viewer starts.
|
|
7
|
+
//
|
|
8
|
+
// A failed `prepareRemoteTerm` throws one of these, and `preflightFailure` reads any of them:
|
|
9
|
+
//
|
|
10
|
+
// code E_TERM_CONTEXT_CHANGED the caller's `signal` aborted or its `current()` turned false
|
|
11
|
+
// code E_TERM_REMOTE_NO_SSH, the preflight's own outcomes: terminal-contract.mjs has a
|
|
12
|
+
// E_TERM_REMOTE_UNREACHABLE, sentence for each
|
|
13
|
+
// E_TERM_PREPARE_TIMEOUT,
|
|
14
|
+
// E_TERM_REMOTE_NO_ANSWER,
|
|
15
|
+
// E_TERM_REMOTE_GONE, E_HERDR_REMOVED
|
|
16
|
+
// any other refusal envelope the kernel's refusal, or a host's relayed by it, with its
|
|
17
|
+
// `code` and `message` as given (E_TERM_OPEN_FAILED and a
|
|
18
|
+
// fixed message where it gave none)
|
|
19
|
+
// code unsupported-remote-operation, the installed CLI cannot do it: decided before any process
|
|
20
|
+
// unsupported-detach-key
|
|
21
|
+
// no code, or one that is not a string the target was invalid, the CLI did not start, or it
|
|
22
|
+
// answered no envelope
|
|
23
|
+
//
|
|
24
|
+
// Not loadable by a page: it reaches `node:` builtins through its runner.
|
|
25
|
+
import { requireRemoteSupport } from "./cli-locator.mjs";
|
|
26
|
+
import { runTerminalCommand } from './terminal-exec.mjs';
|
|
27
|
+
import { HERDR_REMOVED, terminalFailure, terminalMessage } from './terminal-contract.mjs';
|
|
28
|
+
|
|
29
|
+
/** The kernel feature of `session attach --detach-key` (docs/desktop-cli-api.md). */
|
|
30
|
+
export const DETACH_KEY_FEATURE = "session-attach-detach-key";
|
|
31
|
+
/** The kernel feature under which a roster group's `probe.features` is the host's own list
|
|
32
|
+
* (docs/desktop-cli-api.md, `probe.features`). Without it that key says nothing. */
|
|
33
|
+
const PROBE_FEATURES_FEATURE = "server-probe-features";
|
|
34
|
+
// Array.isArray, as in requireRemoteSupport: a string must not pass a gate that exists to fail closed.
|
|
35
|
+
const lists = (cli, feature) => cli?.ok === true && Array.isArray(cli.features) && cli.features.includes(feature);
|
|
36
|
+
|
|
37
|
+
/** This machine's CLI takes the key: an accepted probe (`cli.ok === true`) whose `features` is an
|
|
38
|
+
* array naming the feature. */
|
|
39
|
+
export function detachKeySupported(cli) {
|
|
40
|
+
return lists(cli, DETACH_KEY_FEATURE);
|
|
41
|
+
}
|
|
42
|
+
/** The key can be offered for a row on another machine: this machine's CLI takes it and relays what
|
|
43
|
+
* each host lists about itself, the group's last roster read succeeded, and the host's own list
|
|
44
|
+
* names the feature. `group` is a group of `oats server roster --json` as read. `features: null`,
|
|
45
|
+
* a missing key and a failed read are unknown, and unknown is not supported; nothing is decided
|
|
46
|
+
* from a refusal and nothing probes. For what a client offers only: `sessionAttachArgv` does not
|
|
47
|
+
* ask it, because the kernel refuses a host without the feature and starts no viewer. */
|
|
48
|
+
export function hostDetachKeySupported(cli, group) {
|
|
49
|
+
const probe = group?.probe;
|
|
50
|
+
return detachKeySupported(cli) && lists(cli, PROBE_FEATURES_FEATURE)
|
|
51
|
+
&& probe?.ok === true && Array.isArray(probe.features) && probe.features.includes(DETACH_KEY_FEATURE);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const coded = (code, message) => Object.assign(new Error(message), { code });
|
|
55
|
+
const herdrRemoved = message => coded('E_HERDR_REMOVED', message);
|
|
56
|
+
const unreachable = () => coded('E_TERM_REMOTE_UNREACHABLE', 'the remote server could not be reached');
|
|
57
|
+
/** The CLI's JSON envelope, or null when it printed none. */
|
|
58
|
+
function envelopeOf(stdout) {
|
|
59
|
+
let envelope;
|
|
60
|
+
try { envelope = JSON.parse(stdout); } catch { return null; }
|
|
61
|
+
return envelope?.schemaVersion === 1 && typeof envelope.ok === 'boolean' ? envelope : null;
|
|
62
|
+
}
|
|
63
|
+
/** What a refusal said, for each error `refusal` returns from its last line: the envelope's own
|
|
64
|
+
* `code`, `message` and `details.fix`, each null where it gave no string. Kept beside the error and
|
|
65
|
+
* not on it, so the error thrown has the properties it always had; read by `preflightFailure` only. */
|
|
66
|
+
const keptRefusals = new WeakMap();
|
|
67
|
+
const stringOrNull = value => (typeof value === 'string' ? value : null);
|
|
68
|
+
/** A refusal envelope as a coded error. The CLI reports ssh's own failure as E_SSH: a transport
|
|
69
|
+
* failure, unless its details say ssh never started on this computer (nothing to retry); a 0.31
|
|
70
|
+
* kernel's E_HERDR_REMOVED keeps its message; any other refusal keeps the host's code. */
|
|
71
|
+
function refusal(envelope) {
|
|
72
|
+
const { code, message, details } = envelope.error || {};
|
|
73
|
+
if (code === 'E_SSH' && details?.sshStarted === false) return coded('E_TERM_REMOTE_NO_SSH', 'ssh is not available on this computer');
|
|
74
|
+
if (code === 'E_SSH') return unreachable();
|
|
75
|
+
if (code === 'E_HERDR_REMOVED') return herdrRemoved(typeof message === 'string' && message ? message : HERDR_REMOVED);
|
|
76
|
+
const error = coded(typeof code === 'string' && code ? code : 'E_TERM_OPEN_FAILED', message || 'remote session inspection failed');
|
|
77
|
+
keptRefusals.set(error, { code: stringOrNull(code), message: stringOrNull(message), fix: stringOrNull(details?.fix) });
|
|
78
|
+
return error;
|
|
79
|
+
}
|
|
80
|
+
/** What a failed preflight says. `error` is what `prepareRemoteTerm` threw; `server` is the label a
|
|
81
|
+
* sentence names.
|
|
82
|
+
*
|
|
83
|
+
* code the terminal table's code for it (E_TERM_OPEN_FAILED for anything the table does not know)
|
|
84
|
+
* sentence the table's sentence, naming `server` where it has a place for one
|
|
85
|
+
* said null, or { code, message, fix }: what the kernel said (this machine's, or another
|
|
86
|
+
* host's relayed by it), only for a refusal kept as it came for which the table has no
|
|
87
|
+
* sentence of its own. Each is the envelope's own string or null, and `said` is null
|
|
88
|
+
* when all three are. Text from outside: a client draws `message` and `fix` with
|
|
89
|
+
* kernel-lines.mjs `kernelLines` and nothing else.
|
|
90
|
+
*
|
|
91
|
+
* Any other error has `said: null`, also one made by hand with a refusal's code and message: the
|
|
92
|
+
* message of a CLI that did not start holds a path and is never shown. */
|
|
93
|
+
export function preflightFailure(error, server) {
|
|
94
|
+
const code = terminalFailure(error?.code).code;
|
|
95
|
+
const kept = code === 'E_TERM_OPEN_FAILED' ? keptRefusals.get(error) : undefined;
|
|
96
|
+
const said = kept && (kept.code !== null || kept.message !== null || kept.fix !== null) ? { ...kept } : null;
|
|
97
|
+
return { code, sentence: terminalMessage(error?.code, server), said };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** A remote terminal is its server and its absolute home: routed as `--server S --home H`, never by a bare name. */
|
|
101
|
+
export function remoteTargetKey(remote) {
|
|
102
|
+
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(remote?.serverId || "")
|
|
103
|
+
|| !/^[a-z0-9][a-z0-9-]*$/.test(remote?.instance || "")) throw new Error("invalid remote terminal target");
|
|
104
|
+
if (typeof remote.home !== "string" || !remote.home.startsWith("/") || remote.home.includes("\0")) throw new Error("invalid remote terminal home");
|
|
105
|
+
return JSON.stringify(["remote", remote.serverId, remote.home]);
|
|
106
|
+
}
|
|
107
|
+
/** The arguments of the kernel's viewer (the binary is `cli.bin`), a new array each call.
|
|
108
|
+
*
|
|
109
|
+
* target { home } on this machine; { serverId, instance, home } on another (what
|
|
110
|
+
* `remoteTargetKey` admits, and it refuses as it always did)
|
|
111
|
+
* detachKey undefined for none; else a non-empty string, appended as `--detach-key <key>`
|
|
112
|
+
*
|
|
113
|
+
* The client holds no copy of the kernel's key grammar: a key the kernel does not accept is the
|
|
114
|
+
* kernel's refusal. A key for a CLI that does not take one throws `unsupported-detach-key`: a
|
|
115
|
+
* kernel without the feature ignores the flag and opens a viewer with no exit, so the flag is
|
|
116
|
+
* never tried (docs/desktop-cli-api.md). Its message is for a developer; a client decides what it
|
|
117
|
+
* offers with `detachKeySupported`. */
|
|
118
|
+
export function sessionAttachArgv(cli, target, { detachKey } = {}) {
|
|
119
|
+
let address;
|
|
120
|
+
if (target?.serverId !== undefined) {
|
|
121
|
+
remoteTargetKey(target);
|
|
122
|
+
address = ["--server", target.serverId, "--home", target.home];
|
|
123
|
+
} else {
|
|
124
|
+
if (typeof target?.home !== "string" || !target.home.startsWith("/") || target.home.includes("\0")) throw new Error("invalid session home");
|
|
125
|
+
address = ["--home", target.home];
|
|
126
|
+
}
|
|
127
|
+
if (detachKey === undefined) return ["session", "attach", ...address];
|
|
128
|
+
if (typeof detachKey !== "string" || !detachKey) throw new TypeError("a detach key is a non-empty string");
|
|
129
|
+
if (!detachKeySupported(cli)) throw Object.assign(new Error(`installed oats ${cli?.version || "unknown"} does not support session attach --detach-key; update the CLI`), { code: "unsupported-detach-key" });
|
|
130
|
+
return ["session", "attach", ...address, "--detach-key", detachKey];
|
|
131
|
+
}
|
|
132
|
+
/** The preflight of an attach on another machine, and the viewer to start after it: { binary, args }.
|
|
133
|
+
*
|
|
134
|
+
* run the whole run of the CLI, in the shape of terminal-exec.mjs `runTerminalCommand`; a
|
|
135
|
+
* caller that passes it owns the run, and `exec` is then not used
|
|
136
|
+
* exec what the default runner starts the CLI with, in `execFile`'s signature
|
|
137
|
+
* detachKey as `sessionAttachArgv` takes it. The viewer's arguments are built before the
|
|
138
|
+
* inspect runs, so a key that cannot be used starts no process; the inspect never
|
|
139
|
+
* carries the key. */
|
|
140
|
+
export async function prepareRemoteTerm(cli, remote, { exec, run = (binary, args, options) => runTerminalCommand(binary, args, options, exec), signal, current = () => true, detachKey } = {}) {
|
|
141
|
+
const check = () => { if (signal?.aborted || !current()) throw Object.assign(new Error('Terminal context changed'), { code: 'E_TERM_CONTEXT_CHANGED' }); };
|
|
142
|
+
check();
|
|
143
|
+
requireRemoteSupport(cli, "session");
|
|
144
|
+
const bin = cli.bin;
|
|
145
|
+
remoteTargetKey(remote);
|
|
146
|
+
const address = ["--server", remote.serverId, "--home", remote.home];
|
|
147
|
+
const args = sessionAttachArgv(cli, remote, { detachKey });
|
|
148
|
+
check(); // actual execution owner, not only IPC admission
|
|
149
|
+
let stdout;
|
|
150
|
+
try {
|
|
151
|
+
({ stdout } = await run(bin, ["session", "inspect", ...address, "--json"], {
|
|
152
|
+
encoding: "utf8", timeout: 20000, maxBuffer: 1024 * 1024, shell: false, ...(signal ? { signal } : {}),
|
|
153
|
+
}));
|
|
154
|
+
} catch (error) {
|
|
155
|
+
check();
|
|
156
|
+
const envelope = typeof error?.stdout === 'string' ? envelopeOf(error.stdout) : null;
|
|
157
|
+
if (envelope && !envelope.ok) throw refusal(envelope);
|
|
158
|
+
// Killed by execFile at the deadline: a stalled link outlives ssh's keepalives (about 45 s),
|
|
159
|
+
// so it is a timeout. A CLI that ended without a refusal, by a nonzero exit (255 included) or
|
|
160
|
+
// a signal of its own, gave no answer: ssh's own failures arrive as E_SSH, so this is more
|
|
161
|
+
// likely the local CLI. A CLI that never started keeps its own error.
|
|
162
|
+
if (error?.killed) throw coded('E_TERM_PREPARE_TIMEOUT', 'remote session inspection timed out');
|
|
163
|
+
if (Number.isInteger(error?.code) || error?.signal) throw coded('E_TERM_REMOTE_NO_ANSWER', 'the local oats gave no answer');
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
check();
|
|
167
|
+
const envelope = envelopeOf(stdout);
|
|
168
|
+
if (!envelope) throw new Error("remote session inspection answered no envelope");
|
|
169
|
+
if (!envelope.ok) throw refusal(envelope);
|
|
170
|
+
// A 0.31 kernel refuses a Herdr-recorded instance; an older one still reports its live Herdr
|
|
171
|
+
// session. Neither is attached: the refusal keeps its code so the broker reports it.
|
|
172
|
+
if (envelope.result?.backend === 'herdr') throw herdrRemoved(HERDR_REMOVED);
|
|
173
|
+
if (envelope.result?.present !== true) throw coded('E_TERM_REMOTE_GONE', "remote terminal no longer exists");
|
|
174
|
+
return { binary: bin, args };
|
|
175
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Confirmed K6d input/data boundary. No kernel resolution or renderer key authority. */
|
|
2
|
-
import { retainedSpawnDetails } from './launch-prompt-outcome.mjs';
|
|
2
|
+
import { retainedSpawnDetails, launchFlagIgnored, flagIgnoredFact } from './launch-prompt-outcome.mjs';
|
|
3
3
|
import { harnessOf } from './harness-names.mjs';
|
|
4
4
|
import { record, previewSupported, previewSelector, previewChoices, previewTarget, previewData, previewFailure, MAX_HOOKS } from './spawn-preview-contract.mjs';
|
|
5
5
|
import { spawnDecision, sameSpawnDecision } from './spawn-decision.mjs';
|
|
@@ -74,7 +74,13 @@ export function spawnWakeOutcome(value, requested) {
|
|
|
74
74
|
if (value.saved === false && !error) return null;
|
|
75
75
|
return { requested: value.requested, saved: value.saved, error };
|
|
76
76
|
}
|
|
77
|
-
/** A qualified creation receipt, not executable terminal/session instructions.
|
|
77
|
+
/** A qualified creation receipt, not executable terminal/session instructions.
|
|
78
|
+
*
|
|
79
|
+
* `flagIgnored` (optional) is the one fact of the kernel's answer the receipt carries as text: a launched
|
|
80
|
+
* spawn where Claude Code ignored the channel option (launchFlagIgnored: `launchPrompts.status`
|
|
81
|
+
* "flag-ignored", with the answer's warnings as bounded display lines). Absent for any other status, for
|
|
82
|
+
* an answer without `launchPrompts`, and for a spawn that was not launched. It holds facts and no sentence.
|
|
83
|
+
* Every other warning of an apply stays a count (`warningCount`). */
|
|
78
84
|
export function spawnCreationReceipt(v, { target, preview, wakeRequested = false } = {}) {
|
|
79
85
|
const selected = previewTarget(target), expected = spawnDecision(preview?.decision, { effectiveRequired: true });
|
|
80
86
|
const decision = spawnDecision(v?.decision, { effectiveRequired: true });
|
|
@@ -93,10 +99,11 @@ export function spawnCreationReceipt(v, { target, preview, wakeRequested = false
|
|
|
93
99
|
wake = spawnWakeOutcome({ requested: true, saved: false, error: v.wakeScheduleError }, true);
|
|
94
100
|
}
|
|
95
101
|
if (!wake) return null;
|
|
102
|
+
const flagIgnored = v.launched ? launchFlagIgnored(v) : null;
|
|
96
103
|
return { instance: v.instance, agent: v.agent, home: v.home, agentsRoot: selected.selector.agentsRoot,
|
|
97
104
|
workspace: selected.workspace, server: null, repo: v.repo, work: v.work, branch: v.branch,
|
|
98
105
|
harness: harnessOf(v), model: v.model, launched: v.launched, replayed: v.replayed, decision,
|
|
99
|
-
warningCount: v.warnings.length, wake };
|
|
106
|
+
warningCount: v.warnings.length, wake, ...(flagIgnored ? { flagIgnored } : {}) };
|
|
100
107
|
}
|
|
101
108
|
/** Project the Desktop HTTP view again at the main/renderer trust boundaries. */
|
|
102
109
|
export function spawnApplyView(v, expected = {}) {
|
|
@@ -122,8 +129,13 @@ export function spawnApplyView(v, expected = {}) {
|
|
|
122
129
|
if (['complete', 'partial'].includes(v.status)) {
|
|
123
130
|
if (!record(v.receipt) || !Number.isInteger(v.receipt.warningCount) || v.receipt.warningCount < 0 || v.receipt.warningCount > 512
|
|
124
131
|
|| v.receipt.workspace !== target.workspace || v.receipt.agentsRoot !== target.selector.agentsRoot || v.receipt.server !== null) return null;
|
|
125
|
-
receipt
|
|
132
|
+
// The receipt is rebuilt from its own keys: the warnings are a count here, so `flagIgnored` is read from
|
|
133
|
+
// the receipt's key through the reader's decoder, never composed again. Tolerant: a value that does not
|
|
134
|
+
// decode is dropped, and the receipt stands.
|
|
135
|
+
receipt = spawnCreationReceipt({ ...v.receipt, warnings: Array(v.receipt.warningCount).fill(''), launchPrompts: undefined }, { target, preview, wakeRequested: v.wakeRequested });
|
|
126
136
|
if (!receipt) return null;
|
|
137
|
+
const flagIgnored = receipt.launched ? flagIgnoredFact(v.receipt.flagIgnored) : undefined;
|
|
138
|
+
if (flagIgnored) receipt.flagIgnored = flagIgnored;
|
|
127
139
|
const partial = v.wakeRequested && receipt.wake.saved !== true;
|
|
128
140
|
if ((v.status === 'partial') !== partial) return null;
|
|
129
141
|
if (partial) reason = receipt.wake.error ?? { code: 'E_WAKE_OUTCOME_UNKNOWN', message: WAKE_OUTCOME_UNKNOWN };
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import { displayLine } from './display-text.mjs';
|
|
9
9
|
import { ROLLED_BACK_CODES } from './spawn-apply-contract.mjs';
|
|
10
10
|
|
|
11
|
+
const UNMATCHED = 'E_LAUNCH_PREFERENCE_UNMATCHED';
|
|
12
|
+
|
|
11
13
|
const COMMON = {
|
|
12
14
|
E_BAD_ARGS: 'Some of these values can’t be used. Check the name and Developer settings.',
|
|
13
15
|
E_BUSY: 'Another spawn is in progress. Try again in a moment.',
|
|
@@ -27,7 +29,6 @@ const COMMON = {
|
|
|
27
29
|
E_BRANCH_EXISTS: 'That branch already exists. Choose another branch in Developer settings.',
|
|
28
30
|
E_BASE_UNKNOWN: 'That base isn’t a branch, tag or commit in this soul’s repository. Check it in Developer settings.',
|
|
29
31
|
E_CLONE_MISSING: 'This soul’s repository isn’t cloned on this machine yet. Clone it, then try again — Details shows how.',
|
|
30
|
-
E_REQUIREMENT_INACTIVE: 'Something this soul needs isn’t set up yet. Check the soul in the Workspace view.',
|
|
31
32
|
E_LAUNCH_ENV_MISSING: 'The chosen launch configuration can’t start on this machine. Choose another in Developer settings.',
|
|
32
33
|
E_LAUNCH_EXECUTABLE: 'The chosen launch configuration can’t start on this machine. Choose another in Developer settings.',
|
|
33
34
|
E_LAUNCH_PROBE_UNSUPPORTED: 'The chosen launch configuration can’t be checked safely. Choose another in Developer settings.',
|
|
@@ -39,6 +40,11 @@ const COMMON = {
|
|
|
39
40
|
// 0.30 launch preferences: shown in the kernel's own words when it sends them (spawnProblem: the
|
|
40
41
|
// message, then the reason's flat `fix`), which name the harness and where it was chosen; this is the fallback.
|
|
41
42
|
E_HARNESS_UNAVAILABLE: 'The harness this soul would run isn’t installed on this machine. Install it, or pick another harness above.',
|
|
43
|
+
// 0.53.0: the kernel refuses a spawn that names no launch while `souls.launch` holds a key that names no
|
|
44
|
+
// soul. This sentence points at the controls above it and at Details, so it is read only where both are
|
|
45
|
+
// there: at the preview, with the kernel's message and fix quoted under Details (spawnProblem's `kernel`
|
|
46
|
+
// parts). Everywhere else the shorter one of SPAWN is read.
|
|
47
|
+
[UNMATCHED]: 'This machine’s launch preferences name a soul this workspace doesn’t offer, so OATS won’t choose a launch for this soul. To spawn now, pick a harness above, or a launch configuration in Developer settings. To fix it for every spawn, correct the preference (Details).',
|
|
42
48
|
E_MODEL_UNKNOWN: 'That model isn’t available for this harness. Pick another model, or keep the default.',
|
|
43
49
|
E_INSTANCE_NAME_INVALID: 'Use lowercase letters, numbers and dashes, at most 64 characters, and don’t reuse a soul’s name.',
|
|
44
50
|
E_INSTANCE_NAME_TAKEN: 'An instance with this name already exists. Choose another name.',
|
|
@@ -71,16 +77,33 @@ const SPAWN = {
|
|
|
71
77
|
E_CLI_OUTPUT_LIMIT: 'OATS couldn’t confirm the spawn. Use Check result before spawning again.',
|
|
72
78
|
E_CLI_PROTOCOL: 'OATS couldn’t complete the spawn. Try again, or see Details.',
|
|
73
79
|
E_CLI_FAILED: 'OATS couldn’t complete the spawn. Try again, or see Details.',
|
|
80
|
+
// An unmatched launch preference where nothing is above the sentence and Details hold no kernel text: the
|
|
81
|
+
// notice after a press has left the dialog, and a preview whose reason carries no `fix`.
|
|
82
|
+
[UNMATCHED]: 'This machine’s launch preferences name a soul this workspace doesn’t offer, so OATS won’t choose a launch for this soul. To spawn now, pick a harness or a launch configuration for this spawn. To fix it for every spawn, correct the preference.',
|
|
74
83
|
};
|
|
75
84
|
|
|
76
|
-
/** { text, detail } for a { code, message } reason. `stage` is 'preview'
|
|
77
|
-
* (reading defaults) or 'spawn' (after the operator pressed Spawn).
|
|
85
|
+
/** { text, code, detail } for a { code, message } reason. `stage` is 'preview'
|
|
86
|
+
* (reading defaults) or 'spawn' (after the operator pressed Spawn).
|
|
87
|
+
*
|
|
88
|
+
* For an unmatched launch preference whose reason carries the kernel's `fix`, the answer also has
|
|
89
|
+
* `kernel: { message, fix }`: the kernel's two texts, the strings as they came, for the client to quote
|
|
90
|
+
* under the kernel's name (the lead is the client's, `originLead` with its terms). `detail` is then the
|
|
91
|
+
* code alone, so that no reader of `detail` shows a kernel text without its speaker. A `fix` decides it
|
|
92
|
+
* because `previewFailure` keeps one only beside the kernel's own message, never beside a table's sentence:
|
|
93
|
+
* a reason without one (a press, a kernel that sent none, a message that did not travel) reads
|
|
94
|
+
* `code · message` as every other code does. */
|
|
78
95
|
export function spawnProblem(reason, stage = 'preview') {
|
|
79
96
|
const code = typeof reason?.code === 'string' ? reason.code : 'E_CLI_FAILED';
|
|
80
97
|
const own = stage === 'spawn' ? SPAWN : PREVIEW;
|
|
81
98
|
const message = typeof reason?.message === 'string' ? reason.message.trim() : '';
|
|
82
99
|
// A missing harness is said as the kernel words it, with its fix (launch preferences, 0.30).
|
|
83
100
|
const fix = typeof reason?.fix === 'string' ? reason.fix.trim() : '';
|
|
101
|
+
if (code === UNMATCHED) {
|
|
102
|
+
const kernel = fix ? { message: typeof reason.message === 'string' ? reason.message : '', fix: reason.fix } : null;
|
|
103
|
+
// The sentence that says "above" and "(Details)" is read only where Details hold the kernel's texts.
|
|
104
|
+
if (kernel) return { text: stage === 'preview' ? COMMON[UNMATCHED] : SPAWN[UNMATCHED], code, detail: code, kernel };
|
|
105
|
+
return { text: SPAWN[UNMATCHED], code, detail: message ? `${code} · ${message}` : code };
|
|
106
|
+
}
|
|
84
107
|
// The kernel's message usually already ends with its fix: said once.
|
|
85
108
|
const kernelWords = code === 'E_HARNESS_UNAVAILABLE' && message ? (fix && !message.includes(fix) ? `${message.replace(/[.\s]+$/, '')}: ${fix}` : message) : null;
|
|
86
109
|
const text = kernelWords ?? own[code] ?? COMMON[code] ?? (stage === 'spawn' ? SPAWN.E_CLI_FAILED : PREVIEW.E_CLI_FAILED);
|
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
import { execFile } from 'node:child_process';
|
|
3
3
|
import { parseEnvelope } from './cli-adapter.mjs';
|
|
4
4
|
import { previewChoices, previewTarget, previewSupported, previewFailure, choiceArgv } from './spawn-preview-contract.mjs';
|
|
5
|
-
|
|
5
|
+
/** A refusal, in the kernel's own shape (`{ code, message, details: { fix } }`). `previewFailure` decides what of the
|
|
6
|
+
* kernel's travels: its message when that is printable and within the bound, and its `fix` only beside that message.
|
|
7
|
+
* No other key of `details` travels. */
|
|
8
|
+
function failure(code, message, kernelFix) {
|
|
9
|
+
const { fix, ...error } = previewFailure(code, null, message, kernelFix).reason;
|
|
10
|
+
return { schemaVersion: 1, ok: false, error: fix === undefined ? error : { ...error, details: { fix } } };
|
|
11
|
+
}
|
|
6
12
|
/** `io.exec` is a client's own `execFile` (the rule is at cli-adapter.mjs `runJson`). */
|
|
7
13
|
export function cliSpawnPreview(cli, options = {}, io = {}) {
|
|
8
14
|
// Defense at the actual exec owner as well as at HTTP admission.
|
|
@@ -23,7 +29,7 @@ export function cliSpawnPreview(cli, options = {}, io = {}) {
|
|
|
23
29
|
if (err?.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') return resolve(failure('E_CLI_OUTPUT_LIMIT'));
|
|
24
30
|
if (err?.killed) return resolve(failure('E_CLI_TIMEOUT'));
|
|
25
31
|
const doc = parseEnvelope(stdout);
|
|
26
|
-
if (doc?.ok === false) return resolve(failure(doc.error?.code, doc.error?.message));
|
|
32
|
+
if (doc?.ok === false) return resolve(failure(doc.error?.code, doc.error?.message, doc.error?.details?.fix));
|
|
27
33
|
if (err) return resolve(failure('E_CLI_FAILED'));
|
|
28
34
|
resolve(doc?.ok === true ? doc : failure('E_CLI_PROTOCOL'));
|
|
29
35
|
});
|
|
@@ -213,12 +213,16 @@ const errors = {
|
|
|
213
213
|
E_UNSUPPORTED_OPTION: 'A chosen option is not supported for this soul or installed CLI.',
|
|
214
214
|
E_BRANCH_EXISTS: 'The proposed branch already exists. Choose another branch and preview again.',
|
|
215
215
|
E_BASE_UNKNOWN: 'The proposed base does not resolve to a commit.', E_CHILD_SPAWNS_DISABLED: 'The selected parent does not allow child spawns.',
|
|
216
|
-
|
|
216
|
+
E_LAUNCH_ENV_MISSING: 'Required launch environment references are unavailable.',
|
|
217
217
|
E_LAUNCH_EXECUTABLE: 'The selected launch executable is unavailable.', E_LAUNCH_PROBE_UNSUPPORTED: 'The selected launch cannot be preflighted safely.',
|
|
218
218
|
E_LAUNCH_CONFIG_UNKNOWN: 'The selected launch configuration is unavailable.', E_MODEL_UNKNOWN: 'The selected model could not be resolved.',
|
|
219
219
|
// 0.52.0: several launch configurations for the harness, no default, and the spawn names none. Listed so the
|
|
220
220
|
// code survives where the kernel's own message cannot travel (the apply's reason; a message over the bound).
|
|
221
221
|
E_LAUNCH_CONFIG_AMBIGUOUS: 'More than one launch configuration is declared for this harness and none is the default.',
|
|
222
|
+
// 0.53.0: `souls.launch` holds a key that names no soul, and the spawn names no launch. Listed for the same
|
|
223
|
+
// reason: the code survives where the kernel's own message cannot travel (the apply's reason, after the
|
|
224
|
+
// server's own preview before a dispatch was refused; a message the bound or the filter here does not pass).
|
|
225
|
+
E_LAUNCH_PREFERENCE_UNMATCHED: 'A launch preference on this machine names a soul the workspace does not offer, and this spawn names no launch.',
|
|
222
226
|
E_CLONE_MISSING: 'This soul works in a member repository that is not cloned on this machine.',
|
|
223
227
|
E_INSTANCE_NAME_INVALID: 'That name is not a valid instance name (a lowercase slug of at most 64 characters that is not a soul name).',
|
|
224
228
|
E_INSTANCE_NAME_TAKEN: 'An instance with that name already exists in this deployment.',
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Cancellation is a request, not process-exit evidence. In particular Node's
|
|
2
|
+
// AbortError can precede child close. Hold the caller's reservation until BOTH
|
|
3
|
+
// execFile's bounded result and the owned child's close have arrived. A failed
|
|
4
|
+
// command keeps its bounded stdout on the rejection: the CLI prints its JSON
|
|
5
|
+
// refusal and exits nonzero.
|
|
6
|
+
import { execFile } from 'node:child_process';
|
|
7
|
+
export function runTerminalCommand(binary, args, options, exec = execFile) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
let result, closed = false;
|
|
10
|
+
const settle = () => {
|
|
11
|
+
if (!closed || !result) return;
|
|
12
|
+
if (result.error) reject(Object.assign(result.error, { stdout: result.stdout })); else resolve({ stdout: result.stdout, stderr: result.stderr });
|
|
13
|
+
};
|
|
14
|
+
try {
|
|
15
|
+
const child = exec(binary, args, { ...options, shell: false }, (error, stdout, stderr) => {
|
|
16
|
+
result = { error, stdout, stderr }; settle();
|
|
17
|
+
});
|
|
18
|
+
child.once('close', () => { closed = true; settle(); });
|
|
19
|
+
} catch (error) { reject(error); } // spawn did not return an owned child
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** The words a workspace switcher shows for a view (UI spec, #482; #855, 3a): its name, its one muted
|
|
2
|
+
* line, how many of its deployments are not live, its tooltip, and whether a typed filter keeps it.
|
|
3
|
+
* From what panel-views.mjs `workspaceChoices` answers. Words only: a client draws them (the Desktop's
|
|
4
|
+
* menu is packages/desktop/renderer/workspace-switcher.mjs).
|
|
5
|
+
*
|
|
6
|
+
* No state: arguments in, values out, and no argument is changed.
|
|
7
|
+
* A page loads this module: it imports no Node builtin, and must not. */
|
|
8
|
+
import { pathTail } from "./deployment-label.mjs";
|
|
9
|
+
|
|
10
|
+
/** A choice id that is this computer's folder (a deployment from an older server, an unattached
|
|
11
|
+
* one): its path may be shown, as a tooltip. Any other id (a view's `ws:…`, a remote's `remote:…`)
|
|
12
|
+
* is never shown (#482). */
|
|
13
|
+
export const isLocalPath = (id) => typeof id === "string" && id.startsWith("/");
|
|
14
|
+
const short = (value, max = 256) => typeof value === "string" && value.length > 0 && value.length <= max ? value : "";
|
|
15
|
+
|
|
16
|
+
const machinesOf = (choice) => Array.isArray(choice?.machines) ? choice.machines.filter((m) => short(m)) : [];
|
|
17
|
+
|
|
18
|
+
/** The machines a choice's deployments are on, as one line (UI spec, #482): "This Mac · altair", from
|
|
19
|
+
* the server's `machines`. Never a path or an id: without `machines` (an older server), nothing. */
|
|
20
|
+
export function workspaceChoicePlace(choice) {
|
|
21
|
+
return machinesOf(choice).join(" · ");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Each choice's name, in order. Two choices of one name are told apart by a suffix. */
|
|
25
|
+
export function workspaceChoiceLabels(choices) {
|
|
26
|
+
const base = choices.map((choice) => choice.name
|
|
27
|
+
|| (isLocalPath(choice.id) ? String(choice.id).split("/").filter(Boolean).at(-1) : "")
|
|
28
|
+
|| "Workspace");
|
|
29
|
+
const counts = new Map();
|
|
30
|
+
for (const name of base) counts.set(name, (counts.get(name) || 0) + 1);
|
|
31
|
+
return choices.map((choice, index) => {
|
|
32
|
+
if (counts.get(base[index]) === 1) return base[index];
|
|
33
|
+
// Two choices of one name: their workspace keys tell them apart, else a folder's last two
|
|
34
|
+
// segments or the machines; never a ws: or remote: id, never a full path.
|
|
35
|
+
const which = short(choice.key, 512) || (isLocalPath(choice.id) ? pathTail(choice.id, 2) : workspaceChoicePlace(choice));
|
|
36
|
+
const suffix = [short(choice.team?.name), which].filter(Boolean).join(" · ");
|
|
37
|
+
return suffix ? `${base[index]} — ${suffix}` : base[index];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The tooltip of a choice: its deployments' labels (machine and short path) when the server sends
|
|
42
|
+
* them, else a local folder's path; never an id. */
|
|
43
|
+
function choiceTooltip(choice) {
|
|
44
|
+
const deployments = Array.isArray(choice?.deployments) ? choice.deployments : [];
|
|
45
|
+
const labels = Array.isArray(choice?.deploymentLabels) && choice.deploymentLabels.length === deployments.length
|
|
46
|
+
&& choice.deploymentLabels.every((l) => short(l, 512)) ? choice.deploymentLabels : [];
|
|
47
|
+
return labels.join(", ") || (isLocalPath(choice?.id) ? choice.id : "");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The section a switcher lists unattached views under (#482, expert decision Q4). */
|
|
51
|
+
export const UNMATCHED_SECTION = "Not matched to a workspace";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* What a switcher says for each choice, in the same order. Every entry is its name and ONE muted line
|
|
55
|
+
* (UI spec, #482): a view's machines, an unattached view's machine and short reason.
|
|
56
|
+
*
|
|
57
|
+
* id the choice's id
|
|
58
|
+
* label its name (`workspaceChoiceLabels`)
|
|
59
|
+
* place the muted line. A matched view: its machines, joined by " · ". An unattached one: its
|
|
60
|
+
* machine, unless the label already is that machine (a remote group is named by its
|
|
61
|
+
* server), then its short reason, joined the same way
|
|
62
|
+
* notLive for a matched view, how many of its deployments are not live when that is a positive
|
|
63
|
+
* integer; else 0
|
|
64
|
+
* notLiveText "1 deployment not live", "N deployments not live", or ""
|
|
65
|
+
* unattached whether no workspace identity matched it: such a view goes under UNMATCHED_SECTION
|
|
66
|
+
* tooltip its deployments' labels when there is one label per deployment, else a local folder's
|
|
67
|
+
* path, else ""
|
|
68
|
+
* deployment for an unattached view, its first deployment's id (where its full reason and its fix
|
|
69
|
+
* are shown); else null
|
|
70
|
+
*
|
|
71
|
+
* @param {Array<object>} choices what `workspaceChoices` (panel-views.mjs) answers
|
|
72
|
+
*/
|
|
73
|
+
export function workspaceChoiceRows(choices) {
|
|
74
|
+
const labels = workspaceChoiceLabels(choices);
|
|
75
|
+
return choices.map((choice, index) => {
|
|
76
|
+
const label = labels[index], unattached = !!choice.unattached;
|
|
77
|
+
const place = unattached
|
|
78
|
+
// The machine, unless the entry is already named by it (a remote group is named by its server).
|
|
79
|
+
? [machinesOf(choice)[0] === label ? "" : machinesOf(choice)[0] || "", short(choice.short)].filter(Boolean).join(" · ")
|
|
80
|
+
: workspaceChoicePlace(choice);
|
|
81
|
+
const notLive = !unattached && Number.isInteger(choice.notLive) && choice.notLive > 0 ? choice.notLive : 0;
|
|
82
|
+
return { id: choice.id, label, place, notLive,
|
|
83
|
+
notLiveText: notLive ? `${notLive} ${notLive === 1 ? "deployment" : "deployments"} not live` : "",
|
|
84
|
+
unattached, tooltip: choiceTooltip(choice),
|
|
85
|
+
deployment: (unattached && Array.isArray(choice.deployments) ? choice.deployments[0] : null) || null };
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** A switcher's filter: whether a row is kept for what was typed. The query is trimmed and lower-cased
|
|
90
|
+
* here; it is looked for in the row's label and place, joined by a space and lower-cased, so what is not
|
|
91
|
+
* shown (a tooltip, a full reason) is never matched. No query keeps every row. */
|
|
92
|
+
export function choiceMatches(row, query) {
|
|
93
|
+
const wanted = String(query ?? "").trim().toLocaleLowerCase();
|
|
94
|
+
return !wanted || `${row.label} ${row.place}`.toLocaleLowerCase().includes(wanted);
|
|
95
|
+
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* derived from a path, a ref or a host name, and `ref` is never compared. */
|
|
7
7
|
import { createHash } from 'node:crypto';
|
|
8
8
|
import { requireTerms } from './client-terms.mjs';
|
|
9
|
+
import { displayLine, DETAIL_WITHHELD } from './display-text.mjs';
|
|
10
|
+
import { originLead } from './instance-presentation.mjs';
|
|
9
11
|
|
|
10
12
|
const TEXT_MAX = 2048;
|
|
11
13
|
const text = v => typeof v === 'string' && v.length > 0 && v.length <= TEXT_MAX && !v.includes('\0');
|
|
@@ -62,11 +64,45 @@ const REASONS = {
|
|
|
62
64
|
* as E_SSH with ssh's stderr and no code of its own, so ssh's text is the only signal (a documented limit). */
|
|
63
65
|
const TIMED_OUT = /timed out|timeout/i;
|
|
64
66
|
|
|
67
|
+
/** The client's own sentence for a deployment whose last read failed and whose last observation is kept. */
|
|
68
|
+
const LAST_READ_FAILED = 'This deployment\'s last read failed. It shows what was last observed.';
|
|
69
|
+
|
|
70
|
+
/** The reason of a kept failure, in parts and joined. `message` is the failure's text and `origin` its
|
|
71
|
+
* speaker ("kernel" when the installed CLI printed it; deployment-facts.mjs `keptFailure`). The message
|
|
72
|
+
* is one display line in every form (display-text.mjs `displayLine`), whole or withheld whole:
|
|
73
|
+
*
|
|
74
|
+
* origin the line detail
|
|
75
|
+
* "kernel" a line "<own sentence> OATS says: <line>"
|
|
76
|
+
* "kernel" "[Detail withheld]" "<own sentence> [Detail withheld]"
|
|
77
|
+
* "kernel" nothing to show "<own sentence>"
|
|
78
|
+
* none a line "This deployment's last read failed: <line>. It shows what was last observed."
|
|
79
|
+
* none "[Detail withheld]" "This deployment's last read failed: [Detail withheld]. It shows what was last observed."
|
|
80
|
+
* none nothing to show "<own sentence>"
|
|
81
|
+
*
|
|
82
|
+
* The kernel's words stand apart, after the client's sentence and the speaker's lead
|
|
83
|
+
* (instance-presentation.mjs `originLead`); a withheld or missing message is never introduced by the
|
|
84
|
+
* lead. A message with no origin keeps the words a client always showed, inside its own sentence.
|
|
85
|
+
* The parts, as deployment-facts.mjs `deploymentUnavailableParts` answers them: `headline` the client's
|
|
86
|
+
* sentence, `lead` the speaker's words or null, `sentence` the kernel's line or null; `detail` is those
|
|
87
|
+
* that are there, joined by one space. With no origin the whole detail is the headline. */
|
|
88
|
+
function lastReadFailed(message, origin, terms) {
|
|
89
|
+
const line = displayLine(message);
|
|
90
|
+
if (origin !== 'kernel') {
|
|
91
|
+
const detail = line === null ? LAST_READ_FAILED : `This deployment's last read failed: ${line}. It shows what was last observed.`;
|
|
92
|
+
return { headline: detail, lead: null, sentence: null, detail };
|
|
93
|
+
}
|
|
94
|
+
const lead = line === null || line === DETAIL_WITHHELD ? null : originLead('kernel', terms);
|
|
95
|
+
return { headline: LAST_READ_FAILED, lead, sentence: line, detail: [LAST_READ_FAILED, lead, line].filter(part => part !== null).join(' ') };
|
|
96
|
+
}
|
|
97
|
+
|
|
65
98
|
/** Why a deployment is not live or not matched, or null: `{ short, detail, fix }`. `short` is a few
|
|
66
99
|
* words for a heading or the switcher ("OATS too old to report its workspace"); `detail` the one full
|
|
67
100
|
* sentence; `fix` the plain steps (possibly none: the detail then says what happens next). The steps
|
|
68
101
|
* carry every fact the sentence has (a host, a reference): with steps, a heading shows only them.
|
|
69
|
-
* `d`: `{ local, machine, sshHost?, probe?, identityStatus, attach, ref, cliReadsRemotes, rosterError?, unavailable?, readError? }`.
|
|
102
|
+
* `d`: `{ local, machine, sshHost?, probe?, identityStatus, attach, ref, cliReadsRemotes, rosterError?, unavailable?, readError?, readErrorOrigin? }`.
|
|
103
|
+
* `readError` is a kept failure's message and `readErrorOrigin` its speaker (deployment-facts.mjs
|
|
104
|
+
* `keptFailure`): a string, possibly empty, says the last read failed, whatever it holds. That answer
|
|
105
|
+
* alone also carries `headline`, `lead` and `sentence`, the parts `detail` joins (`lastReadFailed`).
|
|
70
106
|
* `terms`: the client's own (client-terms.mjs): its name where a sentence names it, and the label of its
|
|
71
107
|
* machine where `d` names none. */
|
|
72
108
|
export function deploymentReasonParts(d, terms) {
|
|
@@ -75,8 +111,8 @@ export function deploymentReasonParts(d, terms) {
|
|
|
75
111
|
const updateHere = ['Update OATS on this computer.'];
|
|
76
112
|
if (d.local) {
|
|
77
113
|
if (d.unavailable) return { short: 'Not observed', detail: d.unavailable, fix: [] };
|
|
78
|
-
// A re-read failed and the last observation was kept (
|
|
79
|
-
if (d.readError) return { short: 'Last read failed',
|
|
114
|
+
// A re-read failed and the last observation was kept (deployment-panel.mjs `failedEntry`): a string, whatever it holds.
|
|
115
|
+
if (typeof d.readError === 'string') return { short: 'Last read failed', ...lastReadFailed(d.readError, d.readErrorOrigin, terms), fix: [] };
|
|
80
116
|
if (d.identityStatus === 'feature') return { short: 'OATS here too old to report workspaces', detail: 'This computer\'s OATS is too old to report its workspace; update OATS here.', fix: updateHere };
|
|
81
117
|
if (d.identityStatus === 'old' || d.identityStatus === 'none') return { short: 'Reports no workspace', detail: 'This deployment reports no workspace identity.', fix: [] };
|
|
82
118
|
} else {
|
|
@@ -78,6 +78,27 @@ turn-record recall --reindex # full rebuild of the derived in
|
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
Store root: `--root`, else `$TURN_RECORD_ROOT`, else `~/.turn-record`.
|
|
81
|
+
|
|
82
|
+
**The `node` that `setup` writes down.** The hooks and the watcher's unit name
|
|
83
|
+
a `node` by its path, and only `setup` run again rewrites them. Which path
|
|
84
|
+
depends on how it is run:
|
|
85
|
+
|
|
86
|
+
- **`oats setup`** records a path that survives an upgrade of Node where there
|
|
87
|
+
is one (on Homebrew the `opt` link, not the versioned keg), and warns when
|
|
88
|
+
there is none. The kernel works it out and hands it in as `OATS_NODE_BIN`.
|
|
89
|
+
- **`turn-record setup`**, run alone, has no such rule. It records
|
|
90
|
+
`OATS_NODE_BIN` when that is set to an absolute path, else the `node` it runs
|
|
91
|
+
under (`process.execPath`). On Homebrew that is the versioned keg, which
|
|
92
|
+
`brew upgrade node` removes: run `setup` again after an upgrade.
|
|
93
|
+
|
|
94
|
+
`--dry-run` prints the `node` it would record. The first capture pass always
|
|
95
|
+
runs under the `node` that runs `setup`.
|
|
96
|
+
|
|
97
|
+
Each path is written for what reads it: a shell word in the hook's command,
|
|
98
|
+
systemd's quoting in `ExecStart`, XML text in the launchd plist. A path of
|
|
99
|
+
plain characters is written bare. A run finds the hooks of an earlier run by
|
|
100
|
+
their shape, quoted or not, and replaces their command; a command it cannot
|
|
101
|
+
read as its own is left alone and a new hook is added beside it.
|
|
81
102
|
Stream owner: `--owner`, else `$TURN_RECORD_OWNER`, else the short hostname.
|
|
82
103
|
|
|
83
104
|
## Ignoring sessions and paths (privacy)
|