@awebai/oats 0.51.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 +3 -1
- package/bin/oats.mjs +407 -123
- package/docs/capabilities.md +75 -6
- package/docs/configuration.md +200 -91
- package/docs/desktop-cli-api.md +1563 -113
- package/docs/desktop-instance-start.md +69 -0
- package/docs/desktop.md +10 -7
- package/docs/execution-targets.md +145 -58
- package/docs/first-team.md +3 -1
- package/docs/harness-trust.md +50 -2
- package/docs/implementation.md +238 -17
- package/docs/integrations.md +13 -9
- package/docs/knowledge-reference/acceptance.md +1 -0
- package/docs/knowledge-reference/harvester.md +5 -3
- package/docs/knowledge-reference/model.md +5 -3
- package/docs/knowledge-theory.md +1 -1
- package/docs/knowledge.md +25 -2
- package/docs/launch-prompt-completion.md +50 -48
- package/docs/macos-test-runs.md +246 -0
- package/docs/oats-local.schema.json +4 -3
- package/docs/official-catalog.md +5 -5
- package/docs/packages.md +14 -14
- package/docs/release-lane.md +225 -11
- package/docs/release-notes/v0.44.0.md +1 -1
- package/docs/release-notes/v0.52.0.md +933 -0
- package/docs/release-notes/v0.53.0.md +1274 -0
- package/docs/schedules.md +97 -4
- package/docs/souls-and-instances.md +332 -40
- package/docs/tui.md +584 -0
- package/docs/upgrading.md +298 -0
- package/docs/workspaces.md +3 -3
- package/lib/automations.mjs +22 -22
- package/lib/claim.mjs +278 -49
- package/lib/config-data.mjs +4 -1
- package/lib/core.mjs +1282 -289
- package/lib/errors.mjs +170 -0
- package/lib/harness-trust-write.mjs +68 -27
- package/lib/harness-trust.mjs +34 -16
- package/lib/instance-events.mjs +19 -1
- package/lib/instance-git.mjs +39 -3
- package/lib/instance-inspect.mjs +45 -17
- package/lib/instance-lifecycle.mjs +306 -57
- package/lib/instance-resolution.mjs +59 -6
- package/lib/launch-preference.mjs +236 -9
- package/lib/launch-prompt-completion.mjs +7 -43
- package/lib/launch-prompt-evidence.mjs +14 -7
- package/lib/launch-prompt-fixtures/README.md +86 -152
- package/lib/launch-prompt-fixtures/dev-channel-confirmation.json +50 -0
- package/lib/launch-prompt-fixtures.mjs +122 -109
- package/lib/launch-prompt-transport.mjs +2 -56
- package/lib/launch-prompts.mjs +102 -100
- 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 +125 -22
- package/lib/schedule.mjs +73 -24
- package/lib/shell-word.mjs +13 -0
- package/lib/soul-launch-verbs.mjs +153 -0
- package/lib/stable-node.mjs +62 -0
- package/lib/system-tools.mjs +39 -0
- package/lib/teams-verbs.mjs +18 -46
- package/lib/tmux-server-scope.mjs +62 -0
- package/lib/triggers.mjs +4 -4
- package/lib/workspace.mjs +54 -30
- package/lib/worktree-hooks.mjs +98 -20
- package/lib/worktree.mjs +83 -24
- package/package-catalog.json +4 -4
- package/package.json +8 -2
- package/packages/client/attach-exit.mjs +25 -0
- package/packages/client/capability-show-contract.mjs +230 -0
- package/packages/client/capability-warnings-contract.mjs +57 -0
- package/packages/client/cli-adapter.mjs +561 -0
- package/packages/client/cli-environment.mjs +53 -0
- package/packages/client/cli-locator.mjs +253 -0
- package/packages/client/cli-probe-contract.mjs +47 -0
- package/packages/client/client-terms.mjs +60 -0
- package/packages/client/deployment-contract.mjs +72 -0
- package/packages/client/deployment-data.mjs +483 -0
- package/packages/client/deployment-facts.mjs +95 -0
- package/packages/client/deployment-label.mjs +76 -0
- package/packages/client/deployment-observer.mjs +89 -0
- package/packages/client/deployment-panel.mjs +180 -0
- package/packages/client/deployment-read-cli.mjs +57 -0
- package/packages/client/display-text.mjs +50 -0
- package/packages/client/harness-names.mjs +30 -0
- package/packages/client/inspect-contract.mjs +62 -0
- package/packages/client/instance-acts.mjs +90 -0
- package/packages/client/instance-admission.mjs +45 -0
- package/packages/client/instance-events-contract.mjs +76 -0
- package/packages/client/instance-git-contract.mjs +80 -0
- package/packages/client/instance-presentation.mjs +86 -0
- package/packages/client/instance-tree.mjs +462 -0
- package/packages/client/kernel-environment.mjs +11 -0
- package/packages/client/kernel-lines.mjs +31 -0
- package/packages/client/kernel-made.mjs +23 -0
- package/packages/client/launch-contract.mjs +51 -0
- package/packages/client/launch-prompt-outcome.mjs +200 -0
- package/packages/client/lifecycle-cli.mjs +61 -0
- package/packages/client/lifecycle-contract.mjs +413 -0
- package/packages/client/liveness-main.mjs +10 -0
- package/packages/client/liveness.mjs +48 -0
- package/packages/client/machine-contract.mjs +123 -0
- package/packages/client/own-codes.mjs +31 -0
- package/packages/client/own-environment.mjs +22 -0
- package/packages/client/panel-views.mjs +293 -0
- package/packages/client/readiness-contract.mjs +174 -0
- package/packages/client/refresh-loop.mjs +52 -0
- package/packages/client/remote-address.mjs +151 -0
- package/packages/client/remote-identity-memory.mjs +94 -0
- package/packages/client/remote-roster.mjs +153 -0
- package/packages/client/roster-sections.mjs +80 -0
- package/packages/client/session-attach.mjs +175 -0
- package/packages/client/spawn-apply-cli.mjs +104 -0
- package/packages/client/spawn-apply-contract.mjs +195 -0
- package/packages/client/spawn-decision.mjs +46 -0
- package/packages/client/spawn-messages.mjs +142 -0
- package/packages/client/spawn-preview-cli.mjs +38 -0
- package/packages/client/spawn-preview-contract.mjs +318 -0
- package/packages/client/team-members.mjs +41 -0
- package/packages/client/team-rows.mjs +45 -0
- package/packages/client/terminal-contract.mjs +57 -0
- package/packages/client/terminal-exec.mjs +21 -0
- package/packages/client/tmux-status.mjs +66 -0
- package/packages/client/waiting-on-you.mjs +88 -0
- package/packages/client/workspace-admission.mjs +45 -0
- package/packages/client/workspace-choices.mjs +95 -0
- package/packages/client/workspace-cli.mjs +142 -0
- package/packages/client/workspace-views.mjs +183 -0
- package/packages/record/README.md +21 -0
- package/packages/record/bin/setup.mjs +108 -15
- package/packages/tui/README.md +64 -0
- package/packages/tui/bin/tui.mjs +7 -0
- package/packages/tui/lib/actions.mjs +44 -0
- package/packages/tui/lib/client.mjs +35 -0
- package/packages/tui/lib/config.mjs +151 -0
- package/packages/tui/lib/main.mjs +176 -0
- 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 +367 -0
- package/packages/tui/lib/term/screen.mjs +134 -0
- package/packages/tui/lib/term/style.mjs +43 -0
- package/packages/tui/lib/term/text.mjs +109 -0
- package/packages/tui/lib/term/tty.mjs +178 -0
- package/packages/tui/lib/term/width.mjs +124 -0
- package/packages/tui/lib/views/detail.mjs +46 -0
- package/packages/tui/lib/views/frame.mjs +256 -0
- package/packages/tui/lib/views/help.mjs +140 -0
- 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/packages/tui/package.json +8 -0
- package/skills/oats-getting-started/SKILL.md +30 -23
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-05-channel-seeded.txt +0 -35
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-06-first-after-channel.txt +0 -35
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-07-after-channel-200ms.txt +0 -35
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-08-installed-after-channel-200ms.txt +0 -35
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/manifest.json +0 -77
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/max-bypass-source.json +0 -88
- package/lib/launch-prompt-fixtures/structural-completion.json +0 -205
- package/lib/launch-prompt-policy.mjs +0 -87
package/bin/oats.mjs
CHANGED
|
@@ -24,22 +24,25 @@ import { execFileSync, spawnSync } from "node:child_process";
|
|
|
24
24
|
import { constants as osConstants, homedir, tmpdir } from "node:os";
|
|
25
25
|
import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
26
26
|
import { fileURLToPath } from "node:url";
|
|
27
|
+
import { performance } from "node:perf_hooks";
|
|
27
28
|
import { runtimeNameWarning, noteRuntimeName } from "../lib/deprecation.mjs";
|
|
28
|
-
import { herdrSettingRemoved } from "../lib/errors.mjs";
|
|
29
|
+
import { errorCause, herdrSettingRemoved, isAnswerCode, kernelCode, OWN_NAME_FAILURES, reportDefect } from "../lib/errors.mjs";
|
|
29
30
|
import {
|
|
30
31
|
LAYERS, OATS_VERSION, manifestOperations, upgradeHomeMeta,
|
|
31
32
|
capabilityManifests, capabilityTrust, capabilityExecutablePath,
|
|
32
33
|
officialPackageCatalog, officialCatalogFile, officialCapabilityAliases, resolvedFromHome, resolvedFromPrepared, teamEnv, isWorkspaceHome, preWorkspaceHome, isCapturedHome, capturedHomeRefusal, composeInstanceAgentsMd, parseYamlNested, withConfigFile,
|
|
33
|
-
findInstanceHome, findInstanceHomes, processScanInformation, enclosingInstanceHome, logicalCwd, readableInstanceHomes, workspaceOf, ensureRoot, findRoot, findAgent, findAgentAt, legacyLocalAgents, legacyCapturedHomes, listAgents, listInstances, servedIdentityLine, spawnInstanceAsync, instanceSoulDir, stableSoulId, preparedSoulIdOf, recordedKernelBin, launchConfigsAt,
|
|
34
|
+
findInstanceHome, findInstanceHomes, homeLaunchLayers, processScanInformation, enclosingInstanceHome, logicalCwd, readableInstanceHomes, workspaceOf, ensureRoot, findRoot, findAgent, findAgentAt, legacyLocalAgents, legacyCapturedHomes, listAgents, listInstances, servedIdentityLine, spawnInstanceAsync, instanceSoulDir, stableSoulId, preparedSoulIdOf, recordedKernelBin, launchConfigsAt, launchStartNotices, launchReportFor, explicitInstanceName, retireInstance, RETIRE_SELECTED_HOME, RETIRE_UNDER_CLAIM, inspectInstanceSession, inputInstanceSession, attachInstanceSession, startInstanceSession, defaultRepo, RELATIONS, validateLaunchConfig, validateLaunchConfigDefaults, renderLaunchRecipe, describeLaunchCommand, redactLaunchRecipe, withSafeTaskPrompt, LAUNCH_HARNESSES, planLaunch, redactLaunchCommand, restartInstanceSession,
|
|
34
35
|
FAILED_SPAWN_BRANCH_LEFT, RETIRE_DELETE_BRANCH_REFUSED,
|
|
35
36
|
} from "../lib/core.mjs";
|
|
36
37
|
import {
|
|
37
38
|
writeFileAtomic, LOCK_FILE, canonicalLock, readLock, readLockIfPresent, writeLock, resolvePackages, memoizedRemote,
|
|
38
39
|
classifyPackageValue, parsePackageRequest } from "../lib/packages.mjs";
|
|
39
40
|
import { harnessTrust } from "../lib/harness-trust-write.mjs";
|
|
40
|
-
import {
|
|
41
|
+
import { PI_BRIDGE, piBridgeFolders, piBridgeSkewWarnings, planPiBridges, piBridgePlanLines, piBridgeStepProblem, piBridgeFailure, kernelLookup, kernelLookupResult, planCliUpdate, bridgeLookup, bridgeLookupProblem } from "../lib/pi-bridge.mjs";
|
|
42
|
+
import { loadLocal, validateWorkspace, validateLocal, discoverPackageSouls, unlockedPackages, workspaceWarnings, memberRowByKey } from "../lib/workspace.mjs";
|
|
41
43
|
import { discoveredTeamKeys, isTeamRefusal, localTeamsClosedProblem, recordedTeams, reportRows, soulKeyOf, soulTeams, teamKeyOf, teamModel } from "../lib/teams.mjs";
|
|
42
|
-
import { launchLayers } from "../lib/launch-preference.mjs";
|
|
44
|
+
import { LAUNCH_KEY_UNCHECKED, LAUNCH_PREFERENCE_UNMATCHED, launchKeyQuoted, launchKeysUnmatched, launchLayers, soulLaunchCommand, unmatchedKeyMessage } from "../lib/launch-preference.mjs";
|
|
45
|
+
import { soulsOffered } from "../lib/instance-resolution.mjs";
|
|
43
46
|
import { parseConfigData } from "../lib/config-data.mjs";
|
|
44
47
|
import * as remoteModule from "../lib/remote.mjs";
|
|
45
48
|
import { activateLocalInputs, localRevision } from "../lib/local-inputs.mjs";
|
|
@@ -49,12 +52,13 @@ import { spawnSync as spawnSyncProc } from "node:child_process";
|
|
|
49
52
|
import { tickTriggers } from "../lib/triggers.mjs";
|
|
50
53
|
import * as A from "../lib/automations.mjs";
|
|
51
54
|
import { parseEnvelopeText, unresolvedScheduleAttempts, scheduleScopeOf, listSchedules, describe as describeSchedule, testSchedule, addSchedule, updateSchedule, updateScheduleDescription, setEnabled as setScheduleEnabled, removeSchedule, runNow as runScheduleNow, reconcile as reconcileSchedule, tickHost, tickWorkspace, scopeAutomations, scheduleKind, registerWorkspace, unregisterWorkspace, readRegistry, schedulerStatus, saveWakeForHome, removeWakeForHome, wakeFromFlags, withHostLock, scheduleError, SCHEDULE_API } from "../lib/schedule.mjs";
|
|
52
|
-
import { hostUnitStatus, installHostUnit, uninstallHostUnit } from "../lib/schedule-host.mjs";
|
|
55
|
+
import { hostUnitFiles, hostUnitStatus, installHostUnit, uninstallHostUnit } from "../lib/schedule-host.mjs";
|
|
56
|
+
import { kernelNode, stableNode } from "../lib/stable-node.mjs";
|
|
53
57
|
import { receiveAttachment, uploadAttachment, readStreamBounded, MAX_ATTACHMENT_BYTES } from "../lib/attachments.mjs";
|
|
54
58
|
|
|
55
59
|
import { observeInstanceGit, diffInstanceFile } from "../lib/instance-git.mjs";
|
|
56
|
-
import { planStop, applyStop, planRetire, descendantsOf, resolveInstance as resolveInstanceForCli } from "../lib/instance-lifecycle.mjs";
|
|
57
|
-
import { extraWorktreeLines, formatBytes, workRecoveryLines } from "../lib/retire-output.mjs";
|
|
60
|
+
import { planStop, applyStop, planRetire, retireDefaultsLine, stopClosingLine, descendantsOf, resolveInstance as resolveInstanceForCli, STOP_WARNINGS } from "../lib/instance-lifecycle.mjs";
|
|
61
|
+
import { extraWorktreeLines, formatBytes, warningLines, workRecoveryLines } from "../lib/retire-output.mjs";
|
|
58
62
|
import { retainedRecoveryLines, retainedWorktreeLines, retainedWorktrees } from "../lib/retained-after-retire.mjs";
|
|
59
63
|
const await_import_lifecycle = () => ({ resolveInstance: resolveInstanceForCli });
|
|
60
64
|
import { homeTarget, soulTarget, isWorkspaceContext, inspectDocument, withComposedInstructions, readinessDocument, policyOf, policySoul, manifestMissingRequires, INSPECT_OPERATIONS_API } from "../lib/instance-inspect.mjs";
|
|
@@ -91,14 +95,14 @@ function expandInlineValues(argv) {
|
|
|
91
95
|
const { argv: args, problem: argvProblem, inline: inlineValues } = expandInlineValues(rawArgs);
|
|
92
96
|
let cmd = args[0];
|
|
93
97
|
const HELP_WORDS = new Set(["help", "--help", "-h"]);
|
|
94
|
-
const KERNEL_COMMANDS = new Set(["harness", "automations", "trigger", "capture", "capabilities", "doctor", "inspect", "instance", "operation", "package", "readiness", "souls", "soul", "teams", "launch-config", "experimental", "onboard", "pane", "recall", "retire", "root", "schedule", "server", "session", "setup", "spawn", "status", "sync", "update", "version", "workspace", "worktree"]);
|
|
95
|
-
/** Commands whose argv another parser reads (packages/record and packages/
|
|
96
|
-
const OWN_ARGV_COMMANDS = new Set(["capture", "recall", "setup", "experimental"]);
|
|
98
|
+
const KERNEL_COMMANDS = new Set(["harness", "automations", "trigger", "capture", "capabilities", "doctor", "inspect", "instance", "operation", "package", "readiness", "souls", "soul", "teams", "launch-config", "experimental", "onboard", "pane", "recall", "retire", "root", "schedule", "server", "session", "setup", "spawn", "status", "sync", "tui", "update", "version", "workspace", "worktree"]);
|
|
99
|
+
/** Commands whose argv another parser reads (packages/record, packages/experimental and packages/tui parse process.argv). */
|
|
100
|
+
const OWN_ARGV_COMMANDS = new Set(["capture", "recall", "setup", "experimental", "tui"]);
|
|
97
101
|
/** The kernel features this binary implements: `features` in `version --json` (the Desktop API v1
|
|
98
102
|
* probe) and in `status --json`, which a remote roster relays as the host's (feature
|
|
99
103
|
* server-probe-features, lib/servers.mjs hostFeatures). ONE list for both, emitted at output
|
|
100
104
|
* time, never stored. A name must pass hostFeatures's check (test/cli-json-contract.test.mjs). */
|
|
101
|
-
const KERNEL_FEATURES = ["retire-home", "session-start", "session-restart", "launch-config", "schedule", "schedule-host-caps", "session-upload", "operations", "instance-git", "instance-git-remote", "souls-declarations", "lifecycle-plans", "retire-retention", "readiness", "spawn-preview", "instance-events", "instance-events-2", "schedule-history", "schedule-read-2", "spawn-preview-2", "spawn-idempotency", "spawn-idempotency-2", "spawn-apply-2", "workspace-v2", "instance-modules", "spawn-provider-payload", "served-identity", "packages-no-approval", "spawn-name", "settings-origins", "team-model-3", "settings-declared", "capabilities-private", "layers-from", "harness", "package-souls", "triggers", "automations", "desktop-facts", "launch-preference", "preview-composed-from", "observe-max-age", "spawn-preview-max-age", "launch-config-default", "capability-show", "capture-file", "workspace-identity", "server-connect", "capability-route", "servers-per-workspace", "operator-default-soul", "waiting-on-you", "automation-descriptions", "souls-capabilities", "soul-composed-instructions", "teams-conditional-default", "server-probe-features", "worktree-event", "trigger-sources", "session-attach-detach-key"];
|
|
105
|
+
const KERNEL_FEATURES = ["retire-home", "session-start", "session-restart", "launch-config", "schedule", "schedule-host-caps", "session-upload", "operations", "instance-git", "instance-git-remote", "souls-declarations", "lifecycle-plans", "retire-retention", "readiness", "spawn-preview", "instance-events", "instance-events-2", "schedule-history", "schedule-read-2", "spawn-preview-2", "spawn-idempotency", "spawn-idempotency-2", "spawn-apply-2", "workspace-v2", "instance-modules", "spawn-provider-payload", "served-identity", "packages-no-approval", "spawn-name", "settings-origins", "team-model-3", "settings-declared", "capabilities-private", "layers-from", "harness", "package-souls", "triggers", "automations", "desktop-facts", "launch-preference", "preview-composed-from", "observe-max-age", "spawn-preview-max-age", "launch-config-default", "capability-show", "capture-file", "workspace-identity", "server-connect", "capability-route", "servers-per-workspace", "operator-default-soul", "waiting-on-you", "automation-descriptions", "souls-capabilities", "soul-composed-instructions", "teams-conditional-default", "server-probe-features", "worktree-event", "trigger-sources", "session-attach-detach-key", "lifecycle-kernel-codes", "schedule-run-warnings", "lifecycle-claim-stop", "launch-prompt-dev-channel", "soul-launch", "retire-plan-own-worktree"];
|
|
102
106
|
/** Commands `--server <id>` runs on a registered server. */
|
|
103
107
|
const ROUTED_COMMANDS = new Set(["spawn", "retire", "status", "session", "okf", "schedule", "inspect", "operation", "launch-config", "readiness", "instance"]);
|
|
104
108
|
const flag = (name) => {
|
|
@@ -177,6 +181,23 @@ const withLocalWarnings = (envelope) => {
|
|
|
177
181
|
return { ...envelope, warnings: theirs.map((w) => (w === same ? { ...mine, sources, message: mine.message.replace(/\(.*\)/, `(${sources.join("; ")})`) } : w)) };
|
|
178
182
|
};
|
|
179
183
|
const jsonFail = (code, message, details, exit = 1) => { console.log(JSON.stringify({ schemaVersion: 1, ok: false, error: { code, message: String(message), ...(details !== undefined ? { details } : {}) }, ...envelopeWarnings() })); process.exit(exit); };
|
|
184
|
+
/** The door of the lifecycle verbs (retire, instance stop, session, worktree; awebai/oats#892): the
|
|
185
|
+
* answer to an error `e` of one of them. Its code is the error's own only when that is a kernel
|
|
186
|
+
* code (lib/errors.mjs isKernelCode); any other error is answered as `fallback`. One that has a
|
|
187
|
+
* code (the system's, Node's) and a defect (isDefect: a TypeError and its kind) get
|
|
188
|
+
* `details.cause` beside the command's `details`, and a defect's stack goes to stderr, in both
|
|
189
|
+
* modes: the answer must not swallow it. A plain Error without a code is a refusal the kernel
|
|
190
|
+
* wrote without one, or a child process that failed: the fallback and its message, nothing more.
|
|
191
|
+
* A typed failure that is not a code (TYPED_CLI_FAILURES) keeps its name, as before. Text mode
|
|
192
|
+
* prints the same message, with the same exit status. */
|
|
193
|
+
const lifecycleFail = (e, fallback, details, exit) => {
|
|
194
|
+
const message = String(e?.message ?? e);
|
|
195
|
+
if (TYPED_CLI_FAILURES.has(e?.code)) return JSON_MODE ? jsonFail(e.code, message, details, exit) : die(message, exit);
|
|
196
|
+
reportDefect(e);
|
|
197
|
+
const cause = isAnswerCode(e?.code) ? undefined : errorCause(e);
|
|
198
|
+
const all = cause ? { ...details, cause } : details;
|
|
199
|
+
return JSON_MODE ? jsonFail(kernelCode(e, fallback), message, all, exit) : die(message, exit);
|
|
200
|
+
};
|
|
180
201
|
const jsonOk = (result) => { console.log(JSON.stringify({ schemaVersion: 1, ok: true, result, ...envelopeWarnings() })); };
|
|
181
202
|
// Text mode (or a JSON answer printed before the read): the warning goes to stderr, never stdout.
|
|
182
203
|
process.on("exit", () => { const w = runtimeNameWarning(); if (w && !warningDelivered) process.stderr.write(`oats: warning: ${w.message}\n`); });
|
|
@@ -280,6 +301,38 @@ async function doctorOperator(ws) {
|
|
|
280
301
|
return { problems: found.map(({ code, label, message, remedy }) => ({ code, ...(label ? { label } : {}), message, remedy })), information: [] };
|
|
281
302
|
}
|
|
282
303
|
|
|
304
|
+
/** The keys of oats-local.yaml souls.launch that name no soul (awebai/oats#989), in doctor, OFFLINE like
|
|
305
|
+
* doctorOperator: the souls are discovered from this machine's cache only, and the one function
|
|
306
|
+
* (launchKeysUnmatched) decides. A problem per unmatched key, which speaks about this machine's last
|
|
307
|
+
* read of the souls: a spawn reads the workspace itself and is the authority. A key that could not be
|
|
308
|
+
* checked, or a cache that cannot answer, is an information line (`launch-preference-unchecked`),
|
|
309
|
+
* never silence and never a failure of doctor. "*" is never reported.
|
|
310
|
+
* → { problems: [{ code, key, at, value, suggestions, message, remedy }], information: [string] } */
|
|
311
|
+
async function doctorLaunchPreferences(ws) {
|
|
312
|
+
const local = ws.local.value;
|
|
313
|
+
const entries = local?.souls?.launch && typeof local.souls.launch === "object" && !Array.isArray(local.souls.launch) ? local.souls.launch : {};
|
|
314
|
+
const keys = Object.keys(entries).filter((k) => k !== "*").sort();
|
|
315
|
+
if (!keys.length) return { problems: [], information: [] };
|
|
316
|
+
const shown = (list) => (list.length > 3 ? `${list.slice(0, 3).map(launchKeyQuoted).join(", ")} and ${list.length - 3} more` : list.map(launchKeyQuoted).join(", "));
|
|
317
|
+
let found;
|
|
318
|
+
try {
|
|
319
|
+
const { cacheOnlyRemote } = await import("../lib/operator-coverage.mjs");
|
|
320
|
+
const { discoverOrStandalone } = await import("../lib/instance-resolution.mjs");
|
|
321
|
+
const deployment = dirname(ws.local.path);
|
|
322
|
+
const discovery = await discoverOrStandalone(local, { lock: readLockIfPresent(deployment), deployment, remoteOptions: remoteOptionsFromEnv(), remote: cacheOnlyRemote() });
|
|
323
|
+
found = launchKeysUnmatched({ local, offered: soulsOffered(discovery) });
|
|
324
|
+
} catch (e) {
|
|
325
|
+
const why = e?.code === "E_REMOTE_UNREADABLE" ? `this machine's cache cannot answer (${e.message})` : `${e?.code ? `${e.code}: ` : ""}${e?.message ?? e}`;
|
|
326
|
+
return { problems: [], information: [`launch-preference-unchecked: the keys of oats-local.yaml souls.launch (${shown(keys)}) were not checked against the souls this workspace offers: ${why}; oats sync, then oats souls, then run doctor again (a spawn reads the workspace itself and refuses a key that names no soul)`] };
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
problems: found.unmatched.map((row) => ({ code: LAUNCH_PREFERENCE_UNMATCHED, key: row.key, at: row.at, value: row.value, suggestions: row.suggestions,
|
|
330
|
+
message: unmatchedKeyMessage(row, { lastRead: true }),
|
|
331
|
+
remedy: `pin the soul it was meant for (${soulLaunchCommand("set")}), then: ${soulLaunchCommand("remove", { key: row.key })}` })),
|
|
332
|
+
information: found.unchecked.map((row) => `launch-preference-unchecked: oats-local.yaml souls.launch ${launchKeyQuoted(row.key)} was not checked against the souls this workspace offers: ${LAUNCH_KEY_UNCHECKED[row.reason] ?? row.reason}; this is this machine's last read, and a spawn reads the workspace itself`),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
283
336
|
/** What the deployment's capabilities declare and this kernel ignores (an unknown hook event), for
|
|
284
337
|
* doctor without --soul, OFFLINE like doctorOperator, from this machine's parsed cache: each member's
|
|
285
338
|
* capabilities as `oats sync` enumerated them (the workspace's members confirmed by the cached
|
|
@@ -576,6 +629,19 @@ async function homeLiveTeams(home) {
|
|
|
576
629
|
return Array.isArray(teams) ? { teams, defaultTeam, teamsSource: source } : {};
|
|
577
630
|
}
|
|
578
631
|
|
|
632
|
+
/** For `--reselect-launch`: what the home's launch layers need of the workspace to say which keys of
|
|
633
|
+
* souls.launch name no soul (lib/core.mjs homeLaunchLayers), read only when they need it and the layers
|
|
634
|
+
* decide (`named`: --harness names the launch, so no key is consulted). A home the start will refuse
|
|
635
|
+
* anyway (no record, no deployment) asks for nothing here: the start says why. A read that fails is
|
|
636
|
+
* this command's answer, before anything is stopped or started. */
|
|
637
|
+
async function homeLaunchOffered(home, { named = false } = {}) {
|
|
638
|
+
if (named) return null;
|
|
639
|
+
let needed = false;
|
|
640
|
+
try { needed = homeLaunchLayers(realpathSync(home), JSON.parse(readFileSync(join(home, "instance.json"), "utf8"))).needsOffered; } catch { return null; }
|
|
641
|
+
const { homeSoulsOffered } = await import("../lib/instance-resolution.mjs");
|
|
642
|
+
return homeSoulsOffered(realpathSync(home), { needed, remoteOptions: remoteOptionsFromEnv() });
|
|
643
|
+
}
|
|
644
|
+
|
|
579
645
|
// ---------- operation run: generic invoke through the capability engine ----------
|
|
580
646
|
/** `oats operation run <layer>:<name>`: resolve the provider that fills
|
|
581
647
|
* <layer> for a running home (its snapshot) or for a soul in a scope (the
|
|
@@ -741,25 +807,29 @@ async function doctorWorkspaceJson(ctx, soulName, ws) {
|
|
|
741
807
|
const localTeams = doctorLocalTeams(ws.local.value);
|
|
742
808
|
const schedules = unresolvedScheduleAttempts(dirname(ws.local.path));
|
|
743
809
|
const operator = await doctorOperator(ws);
|
|
810
|
+
const launchPreferences = await doctorLaunchPreferences(ws);
|
|
744
811
|
// With --soul, the soul's composition; without, the deployment's capabilities (doctorHookWarnings).
|
|
745
812
|
const hookEvents = composition ? { warnings: composition.warnings, information: [] } : await doctorHookWarnings(ws);
|
|
746
|
-
const problems = [...legacyLayoutProblems(agentsRoot), readableInstanceHomes(agentsRoot), ...localTeams.problems, ...schedules.problems, ...operator.problems].filter(Boolean);
|
|
813
|
+
const problems = [...legacyLayoutProblems(agentsRoot), readableInstanceHomes(agentsRoot), ...localTeams.problems, ...schedules.problems, ...operator.problems, ...launchPreferences.problems].filter(Boolean);
|
|
747
814
|
return {
|
|
748
815
|
schemaVersion: 1, workspaceApi: 2, context: ctx,
|
|
749
816
|
workspace: { file: ws.local.path, ref: ws.local.workspace },
|
|
750
817
|
workspaceError: ws.localError, lockFile: ws.lockFile, packages: ws.packages, lockError: ws.lockError,
|
|
751
|
-
information: [...(operationalKnowledgeNote(composition, soulName) ? [operationalKnowledgeNote(composition, soulName)] : []), ...localTeams.information, ...schedules.information, ...operator.information, ...hookEvents.information, ...processScanInformation(), ...doctorRetained(ws).flat()],
|
|
818
|
+
information: [...(operationalKnowledgeNote(composition, soulName) ? [operationalKnowledgeNote(composition, soulName)] : []), ...localTeams.information, ...schedules.information, ...operator.information, ...launchPreferences.information, ...hookEvents.information, ...processScanInformation(), ...doctorRetained(ws).flat()],
|
|
752
819
|
composedInstructions: composition?.text, instructionBlocks: composition?.blocks,
|
|
753
820
|
...(problems.length ? { problems } : {}),
|
|
754
821
|
warnings: hookEvents.warnings,
|
|
755
822
|
};
|
|
756
823
|
}
|
|
757
|
-
/** Kernel/bridge version skew (published in lockstep from one tag)
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
824
|
+
/** Kernel/bridge version skew (published in lockstep from one tag), in every pi folder a launch
|
|
825
|
+
* of the deployment uses (lib/pi-bridge.mjs): one warning per folder. Text output only. */
|
|
826
|
+
function doctorVersionSkew(deployment) {
|
|
827
|
+
let launchConfigs = {}, unread = null;
|
|
828
|
+
try { launchConfigs = launchConfigsAt(deployment); } catch (e) { unread = e.message; }
|
|
829
|
+
const warnings = piBridgeSkewWarnings(piBridgeFolders({ launchConfigs }), OATS_VERSION);
|
|
830
|
+
if (unread) warnings.push(`pi bridge — the launch configurations could not be read, so only the default pi folder and this shell's were looked at: ${unread}`);
|
|
831
|
+
for (const warning of warnings) console.log(`WARNING: ${warning}`);
|
|
832
|
+
if (warnings.length) console.log("");
|
|
763
833
|
}
|
|
764
834
|
/** The "Workspace (v2, offline view)" + "Locked packages" sections, shared by both doctor shapes. */
|
|
765
835
|
function printDoctorWorkspace(ws) {
|
|
@@ -780,7 +850,7 @@ async function doctor(dir) {
|
|
|
780
850
|
const { ctx, ws } = doctorDeployment(dir);
|
|
781
851
|
const soulName = flag("soul");
|
|
782
852
|
console.log(`oats doctor — resolved from ${shortPath(ctx)}\n`);
|
|
783
|
-
doctorVersionSkew();
|
|
853
|
+
doctorVersionSkew(dirname(ws.local.path));
|
|
784
854
|
const composition = await doctorComposition(ctx, soulName, ws, (code, msg) => die(`${msg} [${code}]`));
|
|
785
855
|
printDoctorWorkspace(ws);
|
|
786
856
|
const agentsRoot = join(dirname(ws.local.path), "agents");
|
|
@@ -791,9 +861,11 @@ async function doctor(dir) {
|
|
|
791
861
|
for (const p of schedules.problems) console.log(`\n! ${p.code}: ${p.message}`);
|
|
792
862
|
const operator = await doctorOperator(ws);
|
|
793
863
|
for (const p of operator.problems) console.log(`\n! ${p.code}: ${p.message}\n ${p.remedy}`);
|
|
864
|
+
const launchPreferences = await doctorLaunchPreferences(ws);
|
|
865
|
+
for (const p of launchPreferences.problems) console.log(`\n! ${p.code}: ${p.message}\n ${p.remedy}`);
|
|
794
866
|
const hookEvents = composition ? { warnings: composition.warnings, information: [] } : await doctorHookWarnings(ws);
|
|
795
867
|
for (const w of hookEvents.warnings) console.log(`\nwarning ${w.code} ${w.message}`);
|
|
796
|
-
for (const line of [...localTeams.information, ...schedules.information, ...operator.information, ...hookEvents.information, ...processScanInformation()]) console.log(`\nINFO: ${line}`);
|
|
868
|
+
for (const line of [...localTeams.information, ...schedules.information, ...operator.information, ...launchPreferences.information, ...hookEvents.information, ...processScanInformation()]) console.log(`\nINFO: ${line}`);
|
|
797
869
|
for (const block of doctorRetained(ws)) console.log(`\n${block.map((line) => `INFO: ${line}`).join("\n")}`);
|
|
798
870
|
if (soulName) {
|
|
799
871
|
const information = operationalKnowledgeNote(composition, soulName);
|
|
@@ -945,8 +1017,8 @@ function launchPreview(bail) {
|
|
|
945
1017
|
// selection the planner refuses it (E_LAUNCH_LEGACY: re-spawn it from the deployment).
|
|
946
1018
|
let d, frozen;
|
|
947
1019
|
try { frozen = withSafeTaskPrompt(meta.command, meta.harness); d = describeLaunchCommand(frozen); } catch (e) { bail(e.code || "E_LAUNCH_COMMAND_UNSUPPORTED", e.message); }
|
|
948
|
-
const
|
|
949
|
-
jsonOk({ context, selected,
|
|
1020
|
+
const notices = launchStartNotices(dirname(dirname(dirname(dirname(home)))), meta.harness, frozen);
|
|
1021
|
+
jsonOk({ context, selected, ...(notices.length ? { warnings: notices } : {}), selection: { source: "frozen-command", launchConfig: null, harness: null, model: null, yolo: null }, harness: meta.harness, model: meta.model || null, modelSource: meta.model ? "recorded" : "native default", yolo: meta.yolo ?? null, launchConfig: null, launchConfigSource: null, launchConfigDefault: false, executable: { path: d.executable, declared: null, resolvedFrom: "recorded" }, argv: d.argv, environment: d.environment, command: redactLaunchCommand(frozen), prompt: { kind: "task-file", file: "TASK.md" }, hooks: null, preflight: [{ check: "recipe", ok: true, detail: "frozen command; a selection is refused (E_LAUNCH_LEGACY): re-spawn it" }], ok: true });
|
|
950
1022
|
return;
|
|
951
1023
|
}
|
|
952
1024
|
const agentsRoot = agentsRootOfHome(home);
|
|
@@ -968,7 +1040,7 @@ function launchPreview(bail) {
|
|
|
968
1040
|
const command = renderLaunchRecipe(recipe, { home, instance, redact: true, trustHome: plan.trustHome });
|
|
969
1041
|
const d = describeLaunchCommand(command);
|
|
970
1042
|
const environment = d.environment.map((e) => e.reference && recipe.env[e.name]?.fromEnv ? { name: e.name, fromEnv: recipe.env[e.name].fromEnv } : e);
|
|
971
|
-
jsonOk({ context, selected,
|
|
1043
|
+
jsonOk({ context, selected, ...(plan.warnings?.length ? { warnings: plan.warnings } : {}), selection: { source: plan.selectionSource, launchConfig: recipe.launchConfig, harness: sel.harness ?? null, model: sel.model ?? null, yolo: sel.yolo ?? null }, harness: plan.harness, model: recipe.model, modelSource: plan.modelSource, yolo: recipe.yolo ?? null, launchConfig: recipe.launchConfig, launchConfigSource: recipe.launchConfigSource, launchConfigDefault: recipe.launchConfigDefault === true, executable: { path: plan.executable.path, declared: plan.executable.declared ?? null, resolvedFrom: plan.executable.resolvedFrom }, argv: d.argv, environment, command, prompt: recipe.prompt, hooks: redactLaunchRecipe(recipe).hooks, preflight: plan.preflight, ok: plan.ok });
|
|
972
1044
|
}
|
|
973
1045
|
async function launchConfigCmd() {
|
|
974
1046
|
const bail = (code, msg, details) => (JSON_MODE ? jsonFail(code, msg, details) : die(msg));
|
|
@@ -1004,18 +1076,13 @@ async function launchConfigCmd() {
|
|
|
1004
1076
|
if (!file) bail("E_LOCAL_MISSING", `launch-config ${sub} writes the deployment's oats-local.yaml, and none is in reach of ${dir} — run it from the deployment (\`oats onboard\` creates one)`);
|
|
1005
1077
|
const name = args[2];
|
|
1006
1078
|
if (!name || name.startsWith("--")) bail("E_BAD_ARGS", `launch-config ${sub} needs a configuration name`);
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
if (!declaredHere) bail("E_LAUNCH_CONFIG_UNKNOWN", `${name} is not declared in ${shortPath(file)}`);
|
|
1014
|
-
delete model[name];
|
|
1015
|
-
} else {
|
|
1016
|
-
const f = flag("file");
|
|
1079
|
+
// What needs only the arguments is read and refused here, before the lock is taken: the definition
|
|
1080
|
+
// (stdin is read asynchronously, and the edit below is synchronous) and its own validity.
|
|
1081
|
+
let entry, f;
|
|
1082
|
+
const keepEnv = sub === "set" && args.includes("--keep-env");
|
|
1083
|
+
if (sub === "set") {
|
|
1084
|
+
f = flag("file");
|
|
1017
1085
|
if (!f || f === true) bail("E_BAD_ARGS", "launch-config set needs --file <json> (an object with harness and optional executable, args, env, model, yolo)");
|
|
1018
|
-
let entry;
|
|
1019
1086
|
// A parse error is reported without the parser's text: its message can
|
|
1020
1087
|
// quote the document, and a definition may carry environment literals.
|
|
1021
1088
|
let raw;
|
|
@@ -1028,34 +1095,59 @@ async function launchConfigCmd() {
|
|
|
1028
1095
|
try { raw = readFileSync(f, "utf8"); } catch (e) { bail("E_BAD_ARGS", `--file ${f}: ${e.code === "ENOENT" ? "no such file" : e.code || "cannot read"}`); }
|
|
1029
1096
|
}
|
|
1030
1097
|
try { entry = JSON.parse(raw); } catch { bail("E_BAD_ARGS", `--file ${f} is not valid JSON (one object with harness and optional executable, args, env, model, yolo)`); }
|
|
1031
|
-
if (
|
|
1032
|
-
|
|
1033
|
-
// declared definition of that name: a one-time copy into the complete
|
|
1034
|
-
// replacement entry.
|
|
1035
|
-
if (entry && typeof entry === "object" && entry.env !== undefined) bail("E_BAD_ARGS", "--keep-env keeps the environment of the declared definition; omit env from --file");
|
|
1036
|
-
const current = declaredHere ? model[name] : undefined;
|
|
1037
|
-
if (!current) bail("E_LAUNCH_CONFIG_UNKNOWN", `--keep-env: no launch configuration ${name} is declared in ${shortPath(file)}, so there is no environment to keep; declare it with env`);
|
|
1038
|
-
if (entry && typeof entry === "object" && Object.keys(current.env || {}).length) entry.env = { ...current.env };
|
|
1039
|
-
}
|
|
1098
|
+
if (keepEnv && entry && typeof entry === "object" && entry.env !== undefined) bail("E_BAD_ARGS", "--keep-env keeps the environment of the declared definition; omit env from --file");
|
|
1099
|
+
// As given. With --keep-env it is judged again under the lock, with the environment it keeps.
|
|
1040
1100
|
try { validateLaunchConfig(name, entry, `--file ${f}`); } catch (e) { bail(e.code || "E_LAUNCH_CONFIG_INVALID", e.message); }
|
|
1041
1101
|
if (!Object.hasOwn(entry, "harness")) noteRuntimeName(`runtime in the --file definition (written as harness)`);
|
|
1042
|
-
model[name] = normalizeLaunchConfig(entry);
|
|
1043
|
-
// One default per harness, over the file as it would be written (no automatic move).
|
|
1044
|
-
try { validateLaunchConfigDefaults(model, shortPath(file)); } catch (e) { bail(e.code || "E_LAUNCH_CONFIG_INVALID", e.message, e.details); }
|
|
1045
1102
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
//
|
|
1049
|
-
//
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1103
|
+
// The write goes through the one path that rewrites oats-local.yaml (lib/local-edit.mjs editLocal): the
|
|
1104
|
+
// deployment's local lock, and the file as it is under it. Everything this command derives from the
|
|
1105
|
+
// file, it derives there: whether the name is declared, `before`, the environment --keep-env keeps and
|
|
1106
|
+
// the one default per harness. The edit runs with the lock held, so it never ends the process: a
|
|
1107
|
+
// refusal is thrown with the code, the text and the details it is answered with, and answered below,
|
|
1108
|
+
// once the lock is released.
|
|
1109
|
+
const refusal = (code, message, details) => Object.assign(new Error(message), { code, details });
|
|
1110
|
+
let model, before;
|
|
1111
|
+
const { editLocal } = await import("../lib/local-edit.mjs");
|
|
1112
|
+
try {
|
|
1113
|
+
editLocal({ deployment: level, localPath: file }, { verb: `oats launch-config ${sub}` }, ({ text, local }) => {
|
|
1114
|
+
try { model = readLaunchConfigsModel(local); } catch (e) { throw refusal(e.code || "E_LAUNCH_CONFIG_INVALID", e.message); }
|
|
1115
|
+
const declaredHere = Object.hasOwn(model, name);
|
|
1116
|
+
before = declaredHere ? publicLaunchConfig(model[name]) : null;
|
|
1117
|
+
if (sub === "remove") {
|
|
1118
|
+
if (!declaredHere) throw refusal("E_LAUNCH_CONFIG_UNKNOWN", `${name} is not declared in ${shortPath(file)}`);
|
|
1119
|
+
delete model[name];
|
|
1120
|
+
} else {
|
|
1121
|
+
let written = entry;
|
|
1122
|
+
if (keepEnv) {
|
|
1123
|
+
// An editor that saw only redacted values keeps the environment of the
|
|
1124
|
+
// declared definition of that name: a one-time copy into the complete
|
|
1125
|
+
// replacement entry.
|
|
1126
|
+
const current = declaredHere ? model[name] : undefined;
|
|
1127
|
+
if (!current) throw refusal("E_LAUNCH_CONFIG_UNKNOWN", `--keep-env: no launch configuration ${name} is declared in ${shortPath(file)}, so there is no environment to keep; declare it with env`);
|
|
1128
|
+
if (Object.keys(current.env || {}).length) written = { ...entry, env: { ...current.env } };
|
|
1129
|
+
try { validateLaunchConfig(name, written, `--file ${f}`); } catch (e) { throw refusal(e.code || "E_LAUNCH_CONFIG_INVALID", e.message); }
|
|
1130
|
+
}
|
|
1131
|
+
model[name] = normalizeLaunchConfig(written);
|
|
1132
|
+
// One default per harness, over the file as it would be written (no automatic move).
|
|
1133
|
+
try { validateLaunchConfigDefaults(model, shortPath(file)); } catch (e) { throw refusal(e.code || "E_LAUNCH_CONFIG_INVALID", e.message, e.details); }
|
|
1134
|
+
}
|
|
1135
|
+
let next;
|
|
1136
|
+
try { next = replaceLaunchConfigsBlock(text, serializeLaunchConfigs(model)); } catch (e) { throw refusal(e.code || "E_CONFIG_BROKEN", `${e.message}; nothing was written`); }
|
|
1137
|
+
// What is written must read back as exactly what was asked, by the kernel's
|
|
1138
|
+
// own reader, before a byte of the file changes. These refusals are this command's, with its
|
|
1139
|
+
// code: editLocal's own look at the text (E_WORKSPACE_SCHEMA) then finds nothing to refuse.
|
|
1140
|
+
let readBack;
|
|
1141
|
+
let nextLocal;
|
|
1142
|
+
try { nextLocal = parseConfigData(next, { origin: { kind: "local", path: file } }).value; readBack = nextLocal["launch-configs"] || {}; } catch (e) { throw refusal("E_LAUNCH_CONFIG_INVALID", `the rewritten block does not parse: ${e.message}; nothing was written`); }
|
|
1143
|
+
const schemaProblems = validateLocal(nextLocal);
|
|
1144
|
+
if (schemaProblems.length) throw refusal("E_LAUNCH_CONFIG_INVALID", `the rewritten oats-local.yaml would be invalid (${schemaProblems.map((p) => `${p.path || "/"}: ${p.message}`).join("; ")}); nothing was written`);
|
|
1145
|
+
const canonical = (m) => JSON.stringify(Object.keys(m).sort().map((n) => [n, normalizeLaunchConfig(m[n])]));
|
|
1146
|
+
const same = canonical(readBack) === canonical(model);
|
|
1147
|
+
if (!same) throw refusal("E_LAUNCH_CONFIG_INVALID", `${name} would not read back as written; nothing was written`);
|
|
1148
|
+
return { text: next };
|
|
1149
|
+
});
|
|
1150
|
+
} catch (e) { if (typeof e?.code === "string" && e.code.startsWith("E_")) return bail(e.code, e.message, e.details); throw e; }
|
|
1059
1151
|
let eff = null;
|
|
1060
1152
|
try { eff = effective().find((c) => c.name === name) || null; } catch (e) { eff = { error: e.message }; }
|
|
1061
1153
|
const receipt = { name, action: sub, level, file, before, after: Object.hasOwn(model, name) ? publicLaunchConfig(model[name]) : null, effective: eff };
|
|
@@ -1163,8 +1255,8 @@ async function worktreeCmd() {
|
|
|
1163
1255
|
console.log(r.resumed ? `${r.path} is already made (branch ${r.branch} from ${r.base} @ ${String(r.baseOid).slice(0, 12)}); nothing was run` : `made ${r.path}: branch ${r.branch} from origin's ${r.base} @ ${String(r.baseOid).slice(0, 12)}${r.hooks.length ? `; worktree hooks: ${r.hooks.map((h) => `${h.capability} ${h.ok ? "ok" : "FAILED"}`).join(", ")}` : ""}`);
|
|
1164
1256
|
for (const w of r.warnings || []) console.error(`oats: warning: ${w}`);
|
|
1165
1257
|
} catch (e) {
|
|
1166
|
-
if (
|
|
1167
|
-
|
|
1258
|
+
if (TYPED_CLI_FAILURES.has(e?.code)) throw e;
|
|
1259
|
+
return lifecycleFail(e, "E_LIFECYCLE_FAILED", e.details, e.exitStatus);
|
|
1168
1260
|
}
|
|
1169
1261
|
}
|
|
1170
1262
|
|
|
@@ -1244,7 +1336,7 @@ function instanceCmd() {
|
|
|
1244
1336
|
// its revision back and refuses if reality moved.
|
|
1245
1337
|
const homeOpt = flag("home");
|
|
1246
1338
|
if (homeOpt === true || (homeOpt !== undefined && !isAbsolute(homeOpt))) return bail("E_BAD_ARGS", "--home needs an absolute instance home");
|
|
1247
|
-
let root; try { root = ensureRoot(dirFlag()); } catch (e) { return
|
|
1339
|
+
let root; try { root = ensureRoot(dirFlag()); } catch (e) { return lifecycleFail(e, "E_NO_ROOT"); }
|
|
1248
1340
|
const recursive = !args.includes("--no-recursive");
|
|
1249
1341
|
const wantPlan = args.includes("--plan"), wantApply = args.includes("--apply");
|
|
1250
1342
|
if (wantPlan === wantApply) return bail("E_BAD_ARGS", "stop needs exactly one of --plan or --apply");
|
|
@@ -1261,12 +1353,18 @@ function instanceCmd() {
|
|
|
1261
1353
|
const rev = flag("plan-revision"), key = flag("idempotency-key"), grace = flag("grace-ms");
|
|
1262
1354
|
if (rev === true || key === true || grace === true) return bail("E_BAD_ARGS", usage);
|
|
1263
1355
|
const receipt = applyStop(dirFlag(), root, name, { home: homeOpt, recursive, planRevision: rev, idempotencyKey: key, ...(grace !== undefined ? { graceMs: Number(grace) } : {}) });
|
|
1356
|
+
// Not part of the receipt, whose shape is contract: on stderr in both modes.
|
|
1357
|
+
for (const w of receipt[STOP_WARNINGS] || []) console.error(`oats: warning: ${w}`);
|
|
1264
1358
|
if (JSON_MODE) { jsonOk(receipt); return; }
|
|
1265
1359
|
for (const r of receipt.results) console.log(` ${r.instance}: ${r.ok ? (r.stopped ? "stopped" : `already ${r.state}`) : `${r.code} — ${r.message}`}`);
|
|
1266
|
-
console.log(
|
|
1360
|
+
console.log(stopClosingLine(receipt));
|
|
1267
1361
|
if (!receipt.ok) process.exit(1);
|
|
1268
1362
|
return;
|
|
1269
|
-
} catch (e) {
|
|
1363
|
+
} catch (e) {
|
|
1364
|
+
// The error's own details (a claim's holder; a defect's cause) beside the plan it was refused with.
|
|
1365
|
+
const details = { ...e.details, ...(e.plan ? { plan: e.plan } : {}), ...(e.candidates ? { candidates: e.candidates } : {}) };
|
|
1366
|
+
return lifecycleFail(e, "E_LIFECYCLE_FAILED", Object.keys(details).length ? details : undefined);
|
|
1367
|
+
}
|
|
1270
1368
|
}
|
|
1271
1369
|
let home = flag("home");
|
|
1272
1370
|
if (home === true) return bail("E_BAD_ARGS", "--home needs an absolute instance home");
|
|
@@ -1386,7 +1484,8 @@ function maxAgeRefusal(command, head) {
|
|
|
1386
1484
|
case "workspace": return word(1) === "status" ? null : refuse(["workspace", word(1)].filter(Boolean).join(" "));
|
|
1387
1485
|
case "teams": return word(1) === undefined ? null : refuse(`teams ${word(1)}`);
|
|
1388
1486
|
// `soul teams` only reads (its edit flags were removed in 0.38.0, and refuse as such).
|
|
1389
|
-
|
|
1487
|
+
// `soul launch set|remove` writes, and names its soul from what the workspace offers now: it reads live.
|
|
1488
|
+
case "soul": return word(1) === "teams" ? null : refuse(["soul", word(1), word(1) === "launch" ? word(2) : undefined].filter(Boolean).join(" "));
|
|
1390
1489
|
// A capability source's poll resolves its soul as a read (the tick's child passes --max-age 600).
|
|
1391
1490
|
case "trigger": return word(1) === "poll" ? null : refuse(["trigger", word(1)].filter(Boolean).join(" "));
|
|
1392
1491
|
default: {
|
|
@@ -1435,13 +1534,19 @@ function harnessTrustCmd() {
|
|
|
1435
1534
|
const context = workspaceContext(cmdFail);
|
|
1436
1535
|
const show = (result, log = console.log) => {
|
|
1437
1536
|
log(`${result.mode}: native harness trust for ${result.root}`);
|
|
1438
|
-
|
|
1537
|
+
const used = (entry) => [...(entry.ambient ? ["ambient"] : []), ...entry.launchConfigs.map((n) => `launch configuration ${n}`)].join(", ");
|
|
1538
|
+
for (const entry of result.entries) {
|
|
1539
|
+
log(`${entry.harness}: ${entry.status} ${entry.file ?? "unresolved file"} ${JSON.stringify(entry.key)} ${JSON.stringify(entry.current)} -> ${JSON.stringify(entry.desired)} (${entry.beforeDigest ?? "missing"} -> ${entry.afterDigest ?? "unknown/absent"}) (${used(entry)})`);
|
|
1540
|
+
if (entry.problem) log(`problem: ${entry.problem}`);
|
|
1541
|
+
if (entry.reason) log(`skipped: ${entry.reason}`);
|
|
1542
|
+
}
|
|
1439
1543
|
if (result.audit) log(`audit: ${result.audit.status} ${result.audit.path} ${result.audit.operationId}`);
|
|
1440
1544
|
for (const warning of result.warnings) log(`warning: ${warning}`);
|
|
1441
1545
|
if (result.reason) log(`reason: ${result.reason}; native configuration may have changed: ${result.mayHaveChanged}`);
|
|
1442
1546
|
};
|
|
1443
1547
|
try {
|
|
1444
|
-
|
|
1548
|
+
// Every configuration file a launch of this deployment reads: its launch configurations' too.
|
|
1549
|
+
const result = harnessTrust(context.deploymentDir, { harness: selected, plan: args.includes("--plan"), launchConfigs: launchConfigsAt(context.deploymentDir) });
|
|
1445
1550
|
if (JSON_MODE) jsonOk(result);
|
|
1446
1551
|
else show(result);
|
|
1447
1552
|
} catch (e) {
|
|
@@ -1500,8 +1605,8 @@ const originOf = (item) => (item.package ? `package ${item.package} v${item.vers
|
|
|
1500
1605
|
/** A soul's launch here (feature launch-preference): the `Launch` report a spawn with no flags would decide
|
|
1501
1606
|
* (souls.launch, the soul's own launch, the host default), and the desktop-facts `harness`, `model`,
|
|
1502
1607
|
* `harnessFrom` equal to its effective launch (`harnessFrom` "kernel-default" for the host default). */
|
|
1503
|
-
function soulLaunchFacts(entry, local, { launchConfigs, contextDir }) {
|
|
1504
|
-
const launch = launchReportFor({ layers: launchLayers({ definition: entry.definition, entry, key: soulKeyOf(entry), local }), launchConfigs, contextDir });
|
|
1608
|
+
function soulLaunchFacts(entry, local, { launchConfigs, contextDir, offered }) {
|
|
1609
|
+
const launch = launchReportFor({ layers: launchLayers({ definition: entry.definition, entry, key: soulKeyOf(entry), local, offered }), launchConfigs, contextDir });
|
|
1505
1610
|
return { harness: launch.effective.harness, model: launch.effective.model, harnessFrom: launch.from === "host" ? "kernel-default" : launch.from, launch };
|
|
1506
1611
|
}
|
|
1507
1612
|
|
|
@@ -1514,7 +1619,9 @@ function workspaceItems(discovery, lock, local, deploymentDir) {
|
|
|
1514
1619
|
const souls = [];
|
|
1515
1620
|
let launchConfigs = {};
|
|
1516
1621
|
try { launchConfigs = deploymentDir ? launchConfigsAt(deploymentDir) : {}; } catch { launchConfigs = {}; }
|
|
1517
|
-
|
|
1622
|
+
// One description of this read for every soul's launch: which keys of souls.launch name no soul.
|
|
1623
|
+
const offered = soulsOffered(discovery);
|
|
1624
|
+
const soulDefaults = (entry) => soulLaunchFacts(entry, local, { launchConfigs, contextDir: deploymentDir, offered });
|
|
1518
1625
|
const capabilities = [];
|
|
1519
1626
|
const model = teamModel(discovery.standalone === true ? null : discovery.workspace, local, { workspaceKey: discovery.key ?? null });
|
|
1520
1627
|
const teamsHere = (entry) => {
|
|
@@ -1603,6 +1710,7 @@ async function performSync(ctx, bail, { onDiscovered, plan = false } = {}) {
|
|
|
1603
1710
|
catch (e) { if (typeof e?.code === "string" && e.code.startsWith("E_")) return bail(e.code, e.message, e.details ?? e.provenance); throw e; }
|
|
1604
1711
|
const kept = (list) => list.filter((p) => typeof p.package !== "string");
|
|
1605
1712
|
discovery.packageSouls = pkg.souls;
|
|
1713
|
+
discovery.soulsUnread = { ...discovery.soulsUnread, packages: pkg.skipped, unlocked: unlockedPackages(discovery.workspace, lock) };
|
|
1606
1714
|
discovery.problems = [...kept(discovery.problems), ...pkg.problems];
|
|
1607
1715
|
discovery.warnings = workspaceWarnings(discovery.workspace, discovery.members, discovery.external || [], pkg.souls);
|
|
1608
1716
|
problems.splice(0, problems.length, ...kept(problems), ...pkg.problems);
|
|
@@ -1749,7 +1857,7 @@ const printWorkspaceAdd = (r) => r.written
|
|
|
1749
1857
|
* `triggers.disabled` / `schedules.disabled`. */
|
|
1750
1858
|
function setDisabledHereCli(ws, kind, qid, enabled) {
|
|
1751
1859
|
const { path } = loadLocal(ws);
|
|
1752
|
-
return A.setDisabledHere(path, kind, qid, !enabled
|
|
1860
|
+
return A.setDisabledHere({ deployment: dirname(path), localPath: path }, kind, qid, !enabled);
|
|
1753
1861
|
}
|
|
1754
1862
|
|
|
1755
1863
|
const SYNC_USAGE = "usage: oats sync [--dir <deployment>] [--plan] [--json]";
|
|
@@ -2038,7 +2146,8 @@ const SOUL_TEAMS_REPLACEMENT = "souls: in oats-workspace.yaml (a PR to the works
|
|
|
2038
2146
|
* model 3: the workspace's `souls:`, and the local teams it allows). Config only, read only. */
|
|
2039
2147
|
async function soulCmd() {
|
|
2040
2148
|
const bail = (code, msg, details) => (JSON_MODE ? jsonFail(code, msg, details) : die(msg));
|
|
2041
|
-
const usage =
|
|
2149
|
+
const usage = `usage: oats soul teams <soul>|'*' [--dir <deployment>] [--max-age <s>] [--json] | ${SOUL_LAUNCH_USAGE}`;
|
|
2150
|
+
if (positional(1) === "launch") return soulLaunchCmd(bail, usage);
|
|
2042
2151
|
const removed = SOUL_TEAMS_REMOVED_FLAGS.find((f) => args.some((a) => a === f || a.startsWith(`${f}=`)));
|
|
2043
2152
|
if (removed) bail("E_BAD_ARGS", `oats soul teams ${removed} was removed in 0.38.0 (team model 3): which teams a soul may join, and its default, are ${SOUL_TEAMS_REPLACEMENT}`, { flag: removed, replacement: SOUL_TEAMS_REPLACEMENT });
|
|
2044
2153
|
if (positional(1) !== "teams") bail("E_USAGE", usage);
|
|
@@ -2070,6 +2179,70 @@ async function soulCmd() {
|
|
|
2070
2179
|
if (doc.teams.length) printTable(["team", "id", "from", "why"], doc.teams.map((t) => [t.default ? `${t.label} (default)` : t.label, t.team ?? "(no id yet)", t.from, t.via.join(",")]));
|
|
2071
2180
|
}
|
|
2072
2181
|
|
|
2182
|
+
const SOUL_LAUNCH_USAGE = "oats soul launch set <soul>|'*' (--launch-config <name>|none | --harness pi|claude|codex [--model <id>]) [--plan] [--dir <deployment>] [--json] | oats soul launch remove <soul>|'*'|<exact key> [--plan] [--dir <deployment>] [--json]";
|
|
2183
|
+
/** The flags each `oats soul launch` form takes (value flags → true). Anything else is refused, never
|
|
2184
|
+
* ignored: `--home` and `--soul` among them, since the soul is the argument and the file the deployment's. */
|
|
2185
|
+
const SOUL_LAUNCH_FLAGS = {
|
|
2186
|
+
set: { "--launch-config": true, "--harness": true, "--model": true },
|
|
2187
|
+
remove: {},
|
|
2188
|
+
};
|
|
2189
|
+
/** A souls.launch entry in words: a launch configuration's name, or the inline harness and model. */
|
|
2190
|
+
const launchEntryText = (v) => (v === null ? "no entry" : typeof v === "string" ? (v === "none" ? "none (the bare harness)" : `launch configuration ${v}`) : `${v.harness}${v.model ? ` with model ${v.model}` : ""}`);
|
|
2191
|
+
|
|
2192
|
+
/** `oats soul launch set <soul>|'*' (--launch-config <name>|none | --harness <h> [--model <id>]) |
|
|
2193
|
+
* remove <soul>|'*'|<exact key> [--plan] [--dir <deployment>] [--json]` (feature soul-launch): the
|
|
2194
|
+
* writer of oats-local.yaml souls.launch (lib/soul-launch-verbs.mjs). It reads the workspace live. */
|
|
2195
|
+
async function soulLaunchCmd(bail, usage) {
|
|
2196
|
+
const sub = positional(2);
|
|
2197
|
+
if (!["set", "remove"].includes(sub)) bail("E_USAGE", usage);
|
|
2198
|
+
// Every argument is accounted for before anything is read or written: a flag the form does not take, a
|
|
2199
|
+
// value flag with no value at ANY of its occurrences (`--harness codex --harness`), a value flag given
|
|
2200
|
+
// twice (flag() would read the first and drop the second) and a second name are refused, never ignored.
|
|
2201
|
+
const takes = { "--dir": true, "--json": false, "--plan": false, ...SOUL_LAUNCH_FLAGS[sub] };
|
|
2202
|
+
const names = [], given = new Set();
|
|
2203
|
+
for (let i = 3; i < args.length; i++) {
|
|
2204
|
+
const a = args[i];
|
|
2205
|
+
if (!a.startsWith("-")) { names.push(a); continue; }
|
|
2206
|
+
if (!Object.hasOwn(takes, a)) bail("E_USAGE", `oats soul launch ${sub} does not take ${a} (nothing was changed) — usage: ${SOUL_LAUNCH_USAGE}`, { flag: a });
|
|
2207
|
+
if (!takes[a]) continue;
|
|
2208
|
+
if (args[i + 1] === undefined || args[i + 1].startsWith("--")) bail("E_BAD_ARGS", `${a} needs a value`);
|
|
2209
|
+
if (given.has(a)) bail("E_BAD_ARGS", `oats soul launch ${sub} takes ${a} once (nothing was changed)`);
|
|
2210
|
+
given.add(a);
|
|
2211
|
+
i++;
|
|
2212
|
+
}
|
|
2213
|
+
if (names.length === 0) bail("E_BAD_ARGS", `oats soul launch ${sub} needs ${sub === "set" ? "a soul (or '*')" : "a soul, '*' or the exact text of a key in souls.launch"} — usage: ${SOUL_LAUNCH_USAGE}`);
|
|
2214
|
+
if (names.length > 1) bail("E_BAD_ARGS", `oats soul launch ${sub} takes one ${sub === "set" ? "soul" : "soul or key"}, and got ${names.length}: ${names.map((n) => JSON.stringify(n)).join(", ")} (nothing was changed) — usage: ${SOUL_LAUNCH_USAGE}`);
|
|
2215
|
+
const name = names[0];
|
|
2216
|
+
const V = await import("../lib/soul-launch-verbs.mjs");
|
|
2217
|
+
let value = null;
|
|
2218
|
+
if (sub === "set") {
|
|
2219
|
+
try { value = V.soulLaunchValue({ launchConfig: valueFlag("launch-config"), harness: valueFlag("harness"), model: valueFlag("model") }); }
|
|
2220
|
+
catch (e) { if (typeof e?.code === "string" && e.code.startsWith("E_")) return bail(e.code, e.message, e.details); throw e; }
|
|
2221
|
+
}
|
|
2222
|
+
const ctx = workspaceContext(bail);
|
|
2223
|
+
const readSouls = async () => {
|
|
2224
|
+
const { discoverOrStandalone } = await import("../lib/instance-resolution.mjs");
|
|
2225
|
+
return discoverOrStandalone(ctx.local, { lock: readLockIfPresent(ctx.deploymentDir), deployment: ctx.deploymentDir, remoteOptions: ctx.remoteOptions });
|
|
2226
|
+
};
|
|
2227
|
+
let r;
|
|
2228
|
+
try { r = await V.soulLaunch({ deployment: ctx.deploymentDir, localPath: ctx.localPath }, { action: sub, name, value, plan: args.includes("--plan") }, { readSouls }); }
|
|
2229
|
+
catch (e) { if (typeof e?.code === "string" && e.code.startsWith("E_")) return bail(e.code, e.message, e.details ?? e.provenance); throw e; }
|
|
2230
|
+
if (JSON_MODE) { jsonOk(r); return; }
|
|
2231
|
+
const key = JSON.stringify(r.key), file = shortPath(r.file);
|
|
2232
|
+
if (!r.changed) console.log(`souls.launch ${key} is already ${launchEntryText(r.after)} in ${file}: nothing to change`);
|
|
2233
|
+
else if (r.action === "set") console.log(`${r.plan ? "Would set" : "Set"} souls.launch ${key} to ${launchEntryText(r.after)} in ${file}${r.before === null ? "" : ` (it was ${launchEntryText(r.before)})`}${r.plan ? "; nothing was written" : ""}`);
|
|
2234
|
+
else console.log(`${r.plan ? "Would remove" : "Removed"} souls.launch ${key} (${launchEntryText(r.before)}) from ${file}${r.plan ? "; nothing was written" : ""}`);
|
|
2235
|
+
if (r.unread) { console.log(`The workspace's souls could not be read (${r.unread.code}: ${r.unread.message}), so this says nothing about which soul the key applied to or which keys still match none`); return; }
|
|
2236
|
+
if (r.souls && r.souls.length > 1) console.log(`This entry applies to ${r.souls.length} souls: ${r.souls.join(", ")} (a member's soul is keyed by its bare name)`);
|
|
2237
|
+
if (r.key === "*") console.log(`"*" is the launch of every soul without an entry of its own`);
|
|
2238
|
+
else if (r.launch === null) console.log(`${key} is the key of no soul this workspace offers`);
|
|
2239
|
+
else {
|
|
2240
|
+
const e = r.launch.effective;
|
|
2241
|
+
console.log(`The next spawn of ${r.souls.length > 1 && name !== r.key ? name : r.souls[0]} selects ${e.harness}${e.model ? ` with model ${e.model}` : ""}${e.launchConfig ? ` (launch configuration ${e.launchConfig})` : ""}, from ${r.launch.at ?? "the host default"}${r.launch.problem ? `, and would be refused: ${r.launch.problem.code}: ${r.launch.problem.message}` : ""}`);
|
|
2242
|
+
}
|
|
2243
|
+
for (const u of r.unmatched) console.log(`souls.launch ${launchKeyQuoted(u.key)} is the key of no soul this workspace offers${u.suggestions.length ? ` (nearest: ${u.suggestions.join(", ")})` : ""}: ${soulLaunchCommand("remove", { key: u.key })}`);
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2073
2246
|
/** The catalog's rows of `kind` ("capabilities" | "souls") as `oats capabilities` / `oats souls` list them:
|
|
2074
2247
|
* one discovery (honouring --max-age), the lock, workspaceItems. → { ctx, discovery, lock, items }. */
|
|
2075
2248
|
async function catalogRows(kind, bail) {
|
|
@@ -2094,13 +2267,23 @@ async function itemsCmd(kind) {
|
|
|
2094
2267
|
if (kind === "capabilities") await capabilityFacts(items, discovery, lock, ctx, remote);
|
|
2095
2268
|
if (kind === "souls") await soulFacts(items, discovery, lock, ctx, remote);
|
|
2096
2269
|
const standalone = discovery.standalone === true;
|
|
2097
|
-
|
|
2270
|
+
// `oats souls` reads souls.launch for every soul it lists: a key that names none of them is a problem
|
|
2271
|
+
// of this read, one row per key (the souls a spawn would refuse carry it as launch.problem).
|
|
2272
|
+
const unmatched = kind === "souls" ? launchKeysUnmatched({ local: ctx.local, offered: soulsOffered(discovery) }).unmatched.map(unmatchedProblemRow) : [];
|
|
2273
|
+
if (JSON_MODE) { jsonOk(withObservation({ [`${kind}Api`]: 1, standalone: standalone || undefined, workspace: { name: workspaceName(discovery), key: discovery.key, commit: discovery.commit }, [kind]: items, problems: [...discovery.problems, ...unmatched] })); return; }
|
|
2098
2274
|
console.log(`${kind} of workspace ${workspaceName(discovery)} (${discovery.key} @ ${short(discovery.commit)})${standalone ? ` — ${standaloneNote(discovery)}` : ""}\n`);
|
|
2099
2275
|
if (!items.length) console.log(" (none)");
|
|
2100
2276
|
else if (kind === "souls") printTable(["name", "origin", "teams here", "work"], items.map((s) => [s.name, s.origin, s.teams === null ? "(invalid: oats teams)" : s.teams.map((t) => (t.default ? `${t.label}*` : t.label)).join(",") || "—", s.work ?? "—"]));
|
|
2101
2277
|
else printTable(["name", "origin", "layer"], items.map((c) => [c.private ? `${c.name} (repo-owned)` : c.name, c.origin, c.layer ?? "—"]));
|
|
2102
2278
|
const unsynced = Object.keys(discovery.workspace?.packages || {}).filter((id) => !lock.packages[id]);
|
|
2103
2279
|
if (kind === "capabilities" && unsynced.length) console.log(`\n package capabilities of ${unsynced.join(", ")} appear after \`oats sync\``);
|
|
2280
|
+
for (const p of unmatched) console.log(`\n! ${p.code}: ${p.message}`);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
/** A key of souls.launch that names no soul (lib/launch-preference.mjs launchKeysUnmatched's row) as a
|
|
2284
|
+
* row of `oats souls --json` `problems`: `path` is where the key is. */
|
|
2285
|
+
function unmatchedProblemRow(row) {
|
|
2286
|
+
return { code: LAUNCH_PREFERENCE_UNMATCHED, path: row.at, message: unmatchedKeyMessage(row), key: row.key, value: row.value, suggestions: row.suggestions };
|
|
2104
2287
|
}
|
|
2105
2288
|
|
|
2106
2289
|
/** `oats capabilities` argv after the command: its words (the subcommand first) with every flag and a value
|
|
@@ -2797,6 +2980,8 @@ async function spawnCmd() {
|
|
|
2797
2980
|
jsonOk({
|
|
2798
2981
|
instance: r.instance, agent: r.agent, home: r.home, work: r.work,
|
|
2799
2982
|
branch: r.branch || null, base: r.base ?? null, launched: r.launched, warnings: r.warnings || [],
|
|
2983
|
+
// #917: what this spawn's start did with Claude's development-channel prompt, as a start answers it.
|
|
2984
|
+
...(r.launchPrompts ? { launchPrompts: r.launchPrompts } : {}),
|
|
2800
2985
|
...(wakeSchedule ? { wakeSchedule } : {}), ...(wakeScheduleError ? { wakeScheduleError } : {}),
|
|
2801
2986
|
tmux: r.tmux || null, backend: "tmux", repo: r.repo || null, harness: r.harness || null,
|
|
2802
2987
|
model: r.model || null, parent: r.parentInstance || null,
|
|
@@ -2834,6 +3019,8 @@ function failedSpawnBranchLine(r, items, { local = false, host } = {}) {
|
|
|
2834
3019
|
return r.retainedHome ? ` branch: the "branch" recorded in ${join(r.retainedHome, "instance.json")}${host ? ` on ${host}` : ""}` : null;
|
|
2835
3020
|
}
|
|
2836
3021
|
|
|
3022
|
+
/** Whether this process's retire (retireCmd) has returned from the kernel: set once, read by the dispatch. */
|
|
3023
|
+
let retireReturned = false;
|
|
2837
3024
|
function retireCmd() {
|
|
2838
3025
|
const name = args[1];
|
|
2839
3026
|
// Refused before anything else: before --plan, a replay, a plan revision or a recorded child is stopped.
|
|
@@ -2844,16 +3031,16 @@ function retireCmd() {
|
|
|
2844
3031
|
if (args.includes("--plan")) {
|
|
2845
3032
|
// K3: what retirement would touch, with the design's defaults — read-only.
|
|
2846
3033
|
dropAmbientRoot();
|
|
2847
|
-
let root; try { root = ensureRoot(dirFlag()); } catch (e) { return
|
|
3034
|
+
let root; try { root = ensureRoot(dirFlag()); } catch (e) { return lifecycleFail(e, "E_NO_ROOT"); }
|
|
2848
3035
|
try {
|
|
2849
3036
|
const plan = planRetire(dirFlag(), root, name, { home: homeFlag });
|
|
2850
3037
|
if (args.includes("--json")) { jsonOk(plan); return; }
|
|
2851
3038
|
console.log(`retire ${name} — plan ${plan.planRevision}`);
|
|
2852
3039
|
console.log(` session ${plan.facts.session.state}; work ${plan.facts.work.observed ? `${plan.facts.work.changed} changed / ${plan.facts.work.untracked} untracked on ${plan.facts.work.branch ?? (plan.facts.work.detached ? "detached" : "a ref OATS carries no branch name for")}` : `not observed (${plan.facts.work.reason})`}; children ${plan.facts.children.length}; pull request ${plan.facts.pullRequest}`);
|
|
2853
|
-
console.log(`
|
|
3040
|
+
console.log(` ${retireDefaultsLine(plan)}`);
|
|
2854
3041
|
for (const n of plan.notes) console.log(` note: ${n}`);
|
|
2855
3042
|
return;
|
|
2856
|
-
} catch (e) { return
|
|
3043
|
+
} catch (e) { return lifecycleFail(e, "E_LIFECYCLE_FAILED", e.candidates ? { ...e.details, candidates: e.candidates } : e.details); }
|
|
2857
3044
|
}
|
|
2858
3045
|
// The calling instance knows its own home: self-retire never needs to
|
|
2859
3046
|
// disambiguate a same-named twin by hand.
|
|
@@ -2884,7 +3071,7 @@ function retireCmd() {
|
|
|
2884
3071
|
// Before the claim, only the home: where the receipt goes, and the answers of a name that
|
|
2885
3072
|
// resolves to no home, to several or to another one.
|
|
2886
3073
|
let target;
|
|
2887
|
-
try { target = resolveInstanceForCli(dirFlag(), root, name, { home: homeFlag }); } catch (e) { return
|
|
3074
|
+
try { target = resolveInstanceForCli(dirFlag(), root, name, { home: homeFlag }); } catch (e) { return lifecycleFail(e, "E_LIFECYCLE_FAILED", e.details); }
|
|
2888
3075
|
replayPath = join(dirname(target.home), `.oats-retire-receipt.${idemKey}.json`);
|
|
2889
3076
|
// The plan the revision is checked against is read once, by retireInstance, when it holds the
|
|
2890
3077
|
// home's claim (RETIRE_UNDER_CLAIM): nobody else is retiring the home by then, so the plan is
|
|
@@ -2908,17 +3095,21 @@ function retireCmd() {
|
|
|
2908
3095
|
try { r = retireInstance(root, name, { home: homeFlag, self: isSelf, discardWorktree: args.includes("--discard-worktree"), keepDir: args.includes("--keep-dir"), force: args.includes("--force"), [RETIRE_UNDER_CLAIM]: revalidate }); }
|
|
2909
3096
|
catch (e) {
|
|
2910
3097
|
// The plan could not be read, or its revision is not the one shown: the answers they always had.
|
|
2911
|
-
if (e === planFailure) return
|
|
3098
|
+
if (e === planFailure) return lifecycleFail(e, "E_LIFECYCLE_FAILED", e.details);
|
|
2912
3099
|
if (e === stalePlan) return args.includes("--json") ? jsonFail(e.code, e.message, e.details) : die(`the retire plan changed since it was shown; re-run oats retire ${name} --plan`);
|
|
2913
|
-
if (!e?.code) throw e;
|
|
2914
3100
|
// A child still running (or whose stop could not be established) refused the retirement: the
|
|
2915
3101
|
// guarded apply returns the plan it acted on, and the text names each child's reason.
|
|
2916
|
-
if (e
|
|
3102
|
+
if (e?.code === "E_CHILDREN_RUNNING") {
|
|
2917
3103
|
const running = e.details.childrenStopped.filter((k) => !k.ok);
|
|
2918
3104
|
return args.includes("--json") ? jsonFail(e.code, e.message, { ...e.details, ...(planRev !== undefined ? { plan: fresh } : {}) }) : die(`children still running: ${running.map((k) => `${k.instance} (${k.code})`).join(", ")}; nothing retired`);
|
|
2919
3105
|
}
|
|
2920
|
-
|
|
3106
|
+
// Whatever else the retire answers: retireInstance gives every error a kernel code, and what the
|
|
3107
|
+
// retire had done by then (`details.reached`).
|
|
3108
|
+
return lifecycleFail(e, "E_LIFECYCLE_FAILED", e.candidates ? { ...e.details, candidates: e.candidates } : e.details);
|
|
2921
3109
|
}
|
|
3110
|
+
// The retire has answered. Whatever throws from here on is not an answer of the retire and is
|
|
3111
|
+
// not given one (the dispatch): an error envelope without `reached` would say that nothing was done.
|
|
3112
|
+
retireReturned = true;
|
|
2922
3113
|
if (replayPath) { r.planRevision = planRev; r.idempotencyKey = idemKey; r.replayed = false; try { writeFileAtomic(replayPath, JSON.stringify(r, null, 2)); } catch { /* receipt is evidence, not authority */ } }
|
|
2923
3114
|
// A retired home's wake jobs are forgotten (definitions only; nothing is
|
|
2924
3115
|
// stopped by this); a deferred self-retire keeps them until the home is gone.
|
|
@@ -2964,7 +3155,7 @@ function retireCmd() {
|
|
|
2964
3155
|
// which is most of the harm of deleting it. Name the classes and the path.
|
|
2965
3156
|
for (const line of workRecoveryLines(r)) console.log(line);
|
|
2966
3157
|
for (const line of extraWorktreeLines(r)) console.log(line);
|
|
2967
|
-
for (const
|
|
3158
|
+
for (const line of warningLines(r)) console.log(line);
|
|
2968
3159
|
if (isSelf) console.log("This window dies in ~8s — say any goodbyes now.");
|
|
2969
3160
|
}
|
|
2970
3161
|
|
|
@@ -3033,14 +3224,26 @@ async function scheduleCmd() {
|
|
|
3033
3224
|
case "reconcile": return out(reconcileSchedule(ws(), needId(), { io, clear: args.includes("--clear"), ctx: ctx() }));
|
|
3034
3225
|
case "tick": {
|
|
3035
3226
|
const dryRun = args.includes("--dry-run");
|
|
3036
|
-
|
|
3227
|
+
// The minute the timer fired this tick for: this process's start, read before any work.
|
|
3228
|
+
const firedAt = new Date(Math.floor(performance.timeOrigin));
|
|
3229
|
+
if (args.includes("--host")) return out(tickHost({ firedAt, io, dryRun }));
|
|
3037
3230
|
const reg = readRegistry();
|
|
3038
3231
|
const tctx = scopeAutomations(ws(), { io, refresh: !dryRun });
|
|
3039
|
-
const considered = withHostLock(() => [...(tctx.refresh && !tctx.refresh.ok ? [{ workspace: ws(), action: "error", error: `automations refresh: ${tctx.refresh.error}` }] : []), ...tickWorkspace(ws(), { io, reg, wsList: reg.workspaces.includes(ws()) ? reg.workspaces : [...reg.workspaces, ws()], dryRun, ctx: tctx }), ...tickTriggers(ws(), { io, dryRun, ctx: tctx, reg, wsList: reg.workspaces.includes(ws()) ? reg.workspaces : [...reg.workspaces, ws()] })]);
|
|
3232
|
+
const considered = withHostLock(() => [...(tctx.refresh && !tctx.refresh.ok ? [{ workspace: ws(), action: "error", error: `automations refresh: ${tctx.refresh.error}` }] : []), ...tickWorkspace(ws(), { firedAt, io, reg, wsList: reg.workspaces.includes(ws()) ? reg.workspaces : [...reg.workspaces, ws()], dryRun, ctx: tctx }), ...tickTriggers(ws(), { io, dryRun, ctx: tctx, reg, wsList: reg.workspaces.includes(ws()) ? reg.workspaces : [...reg.workspaces, ws()] })]);
|
|
3040
3233
|
return out({ tickedAt: new Date().toISOString(), considered, scheduler: schedulerStatus(ws(), io) });
|
|
3041
3234
|
}
|
|
3042
3235
|
case "host": {
|
|
3043
3236
|
const op = args[2];
|
|
3237
|
+
const os = flag("os");
|
|
3238
|
+
if (os !== undefined && !(op === "install" && args.includes("--print"))) throw scheduleError("E_BAD_ARGS", "--os is for oats schedule host install --print");
|
|
3239
|
+
if (op === "install" && args.includes("--print")) {
|
|
3240
|
+
// What install would write, rendered from this environment; nothing is written or loaded.
|
|
3241
|
+
if (os !== undefined && os !== "darwin" && os !== "linux") throw scheduleError("E_BAD_ARGS", "--os darwin|linux");
|
|
3242
|
+
if (flag("max-concurrent") !== undefined || flag("triggers-max-concurrent") !== undefined) throw scheduleError("E_BAD_ARGS", "--print writes nothing: run install without --print to set a cap");
|
|
3243
|
+
const r = hostUnitFiles(os ? { os } : {});
|
|
3244
|
+
if (!JSON_MODE) for (const w of r.warnings) console.error(`warning: ${w}`);
|
|
3245
|
+
return out(r, (x) => Object.entries(x.files).map(([path, content]) => `==> ${path} <==\n${content}`).join("\n").replace(/\n$/, ""));
|
|
3246
|
+
}
|
|
3044
3247
|
if (op === "install") {
|
|
3045
3248
|
const cap = (name, reset) => {
|
|
3046
3249
|
const occurrences = args.filter((arg) => arg === `--${name}`);
|
|
@@ -3054,14 +3257,14 @@ async function scheduleCmd() {
|
|
|
3054
3257
|
};
|
|
3055
3258
|
const caps = { maxConcurrent: cap("max-concurrent", "default"), triggersMaxConcurrent: cap("triggers-max-concurrent", "none") };
|
|
3056
3259
|
registerWorkspace(ws(), caps);
|
|
3057
|
-
installHostUnit();
|
|
3058
|
-
return out({ scheduler: schedulerStatus(ws(), io) });
|
|
3260
|
+
const { warnings } = installHostUnit();
|
|
3261
|
+
return out({ scheduler: schedulerStatus(ws(), io), warnings });
|
|
3059
3262
|
}
|
|
3060
3263
|
if (op === "uninstall") { unregisterWorkspace(ws()); if (!readRegistry().workspaces.length) uninstallHostUnit(); return out({ scheduler: schedulerStatus(ws(), io) }); }
|
|
3061
3264
|
if (op === "status") return out({ scheduler: schedulerStatus(ws(), io) });
|
|
3062
|
-
throw scheduleError("E_BAD_ARGS", "oats schedule host install|uninstall|status");
|
|
3265
|
+
throw scheduleError("E_BAD_ARGS", "oats schedule host install [--print [--os darwin|linux]]|uninstall|status");
|
|
3063
3266
|
}
|
|
3064
|
-
default: throw scheduleError("E_BAD_ARGS", "usage: oats schedule list|show <id>|test <id>|add <id> --file <spec.json> [--description=<text>] [--workspace <member> --runs-on <host> --owner <host>/<login>]|update <id> (--file <spec.json> [--description=<text>] | --description=<text>)|enable <id>|disable <id>|run <id> [--force]|remove <id> [--force]|reconcile <id> [--clear]|tick [--dry-run] [--host]|host install [--max-concurrent <N|default>] [--triggers-max-concurrent <N|none>]|uninstall|status [--dir <workspace>|--server <id>] [--json]");
|
|
3267
|
+
default: throw scheduleError("E_BAD_ARGS", "usage: oats schedule list|show <id>|test <id>|add <id> --file <spec.json> [--description=<text>] [--workspace <member> --runs-on <host> --owner <host>/<login>]|update <id> (--file <spec.json> [--description=<text>] | --description=<text>)|enable <id>|disable <id>|run <id> [--force]|remove <id> [--force]|reconcile <id> [--clear]|tick [--dry-run] [--host]|host install [--max-concurrent <N|default>] [--triggers-max-concurrent <N|none>] | host install --print [--os darwin|linux]|uninstall|status [--dir <workspace>|--server <id>] [--json]");
|
|
3065
3268
|
}
|
|
3066
3269
|
} catch (e) {
|
|
3067
3270
|
// K8b: typed refusal details travel (identity mismatch: key/declared; a refused file: its integrity source).
|
|
@@ -3258,7 +3461,7 @@ async function sessionCmd() {
|
|
|
3258
3461
|
// recorded launch stays frozen (a changed preference never reaches an existing home on its own).
|
|
3259
3462
|
const reselectLaunch = args.includes("--reselect-launch");
|
|
3260
3463
|
if (reselectLaunch && launchConfig !== undefined) bad("--reselect-launch applies the launch preferences; --launch-config names one explicitly — choose one");
|
|
3261
|
-
const opts = { model: model || undefined, launchConfig, harness, yolo: yoloFlag(), ...(reselectLaunch ? { reselectLaunch: true } : {}), env: process.env, ...(await homeLiveTeams(home)) };
|
|
3464
|
+
const opts = { model: model || undefined, launchConfig, harness, yolo: yoloFlag(), ...(reselectLaunch ? { reselectLaunch: true, launchOffered: await homeLaunchOffered(home, { named: harness !== undefined }) } : {}), env: process.env, ...(await homeLiveTeams(home)) };
|
|
3262
3465
|
if (args[1] === "restart") {
|
|
3263
3466
|
const grace = flag("stop-grace");
|
|
3264
3467
|
if (grace !== undefined) { if (grace === true || !/^\d+$/.test(String(grace)) || Number(grace) < 1 || Number(grace) > 300) bad("--stop-grace needs a number of seconds (1..300) to wait for the harness after SIGTERM"); opts.stopGraceMs = Number(grace) * 1000; }
|
|
@@ -3288,11 +3491,22 @@ async function sessionCmd() {
|
|
|
3288
3491
|
// A start's launch-hook warnings, as spawn prints its own (stderr keeps stdout one JSON document).
|
|
3289
3492
|
for (const w of result?.warnings || []) console.error(` WARNING: ${w}`);
|
|
3290
3493
|
}
|
|
3291
|
-
} catch (e) {
|
|
3494
|
+
} catch (e) { lifecycleFail(e, "E_SESSION_FAILED", e.details); }
|
|
3292
3495
|
}
|
|
3293
3496
|
|
|
3294
3497
|
async function paneCmd() {
|
|
3295
|
-
die("`oats pane` has been retired — the OATS Desktop app (packages/desktop) is the control panel now.");
|
|
3498
|
+
die("`oats pane` has been retired — the OATS Desktop app (packages/desktop) is the control panel now; in a terminal, `oats tui` (preview).");
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3501
|
+
/** `oats tui` (preview, docs/tui.md): the terminal client, shipped inside this package as
|
|
3502
|
+
* packages/tui. It is interactive, so `--json` is refused here, before anything is loaded.
|
|
3503
|
+
* This is the ONLY import of packages/tui in the kernel and the CLI, and it is dynamic: a broken
|
|
3504
|
+
* TUI cannot break another word, and no other word pays for loading it (test/tui-boundary.test.mjs).
|
|
3505
|
+
* packages/tui parses process.argv itself, so the word is spliced out first, as for the record. */
|
|
3506
|
+
async function tuiCmd() {
|
|
3507
|
+
if (args.includes("--json")) return cmdFail("E_BAD_ARGS", "oats tui is interactive and has no --json form; `oats status --json` is the machine view");
|
|
3508
|
+
process.argv.splice(2, 1);
|
|
3509
|
+
await import(new URL("../packages/tui/bin/tui.mjs", import.meta.url));
|
|
3296
3510
|
}
|
|
3297
3511
|
|
|
3298
3512
|
/** `oats onboard [<dir>] --workspace <repo ref> [--json]` — workspace model v2 (decision 9).
|
|
@@ -3681,6 +3895,8 @@ async function capabilityCommand() {
|
|
|
3681
3895
|
// canonical absolute executable of THIS CLI; official consumers execFile
|
|
3682
3896
|
// it directly and never resolve `oats` from PATH or a shell.
|
|
3683
3897
|
OATS_CLI_BIN: CLI_BIN,
|
|
3898
|
+
// The node a command writes into anything that outlives it (lib/stable-node.mjs).
|
|
3899
|
+
OATS_NODE_BIN: kernelNode().node,
|
|
3684
3900
|
...teamEnv(null), ...(teamCtx || {}),
|
|
3685
3901
|
// The soul the command acts for (an instance home's recorded soul directory):
|
|
3686
3902
|
// homes carry no soul link, so providers read it here.
|
|
@@ -3702,40 +3918,70 @@ async function capabilityCommand() {
|
|
|
3702
3918
|
// ---------- update ----------
|
|
3703
3919
|
function updateCmd() {
|
|
3704
3920
|
const checkOnly = args.includes("--check");
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3921
|
+
// The deployment whose launch configurations name pi folders: at or above the working
|
|
3922
|
+
// directory, or --dir. Without one, or with one that does not load, the update still runs on
|
|
3923
|
+
// the default folder and this shell's, and says so first and last: an operator reads the end.
|
|
3924
|
+
let deployment = null, launchConfigs = {}, notLookedAt = null;
|
|
3925
|
+
try { deployment = dirname(loadLocal(dirFlag()).path); launchConfigs = launchConfigsAt(deployment); }
|
|
3926
|
+
catch (e) {
|
|
3927
|
+
// An explicit --dir with no deployment at or above it is refused, a 0.25 configuration there included.
|
|
3928
|
+
if (e?.code === "E_LOCAL_MISSING" && flag("dir") !== undefined) die(e.message);
|
|
3929
|
+
if (e?.code !== "E_LOCAL_MISSING" || e.details?.legacy) notLookedAt = `No launch configuration was looked at: ${deployment ? `the launch configurations of ${deployment} do` : "the deployment does"} not load (${e.message}). Run \`oats doctor\` there, then \`oats update\` again.`;
|
|
3930
|
+
else notLookedAt = `No launch configuration was looked at: no deployment at or above ${process.cwd()}. Run \`oats update\` in each deployment, or with --dir <deployment>.`;
|
|
3931
|
+
launchConfigs = {};
|
|
3932
|
+
}
|
|
3933
|
+
const end = (text) => { console.log(text); if (notLookedAt) console.log(`\n${notLookedAt}`); };
|
|
3934
|
+
const fail = (text) => die(notLookedAt ? `${text}\n${notLookedAt}` : text);
|
|
3935
|
+
// What npm printed is checked to be one version before it reaches a step, an argument or the
|
|
3936
|
+
// screen (awebai/oats#1011). Both streams are captured: spawnSync forwards neither.
|
|
3937
|
+
const asked = kernelLookup();
|
|
3938
|
+
const { version: latest, problem: notChecked } = kernelLookupResult(spawnSync(asked[0], asked.slice(1), { encoding: "utf8", timeout: 30000 }));
|
|
3939
|
+
if (notChecked) fail(notChecked);
|
|
3708
3940
|
console.log(`@awebai/oats installed: ${OATS_VERSION} latest: ${latest}`);
|
|
3709
|
-
//
|
|
3710
|
-
|
|
3711
|
-
const
|
|
3712
|
-
if (
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
if (
|
|
3941
|
+
// Forward only: the CLI moves to a newer version of the registry, never back to an older one.
|
|
3942
|
+
// `target` is the version the kernel has after the run, which the bridges are brought to.
|
|
3943
|
+
const cli = planCliUpdate(OATS_VERSION, latest), { target } = cli;
|
|
3944
|
+
if (cli.note) console.log(cli.note);
|
|
3945
|
+
// The pi bridge, in every pi folder a launch of the deployment uses (lib/pi-bridge.mjs).
|
|
3946
|
+
const plan = planPiBridges(piBridgeFolders({ launchConfigs }), target);
|
|
3947
|
+
console.log(`\n${PI_BRIDGE} ${target} (published in lockstep), by pi folder${deployment && !notLookedAt ? ` of ${deployment}` : ""}:`);
|
|
3948
|
+
for (const line of piBridgePlanLines(plan, cli)) console.log(line);
|
|
3949
|
+
if (notLookedAt) console.log(` ${notLookedAt}`);
|
|
3950
|
+
const moves = plan.filter((entry) => entry.step);
|
|
3951
|
+
const untouched = plan.filter((entry) => entry.action === "skip").length;
|
|
3952
|
+
const untouchedNote = untouched ? ` ${untouched} pi folder${untouched > 1 ? "s were" : " was"} not touched: see above for what to run there.` : "";
|
|
3953
|
+
const steps = [...(cli.step ? [cli.step] : []), ...moves.map((entry) => ({ ...entry.step, entry }))];
|
|
3954
|
+
// "Up to date" is not said over a folder it does not touch, nor over a CLI or a bridge ahead.
|
|
3955
|
+
const ahead = cli.ahead || plan.some((entry) => entry.ahead);
|
|
3956
|
+
if (!steps.length) return end(untouched || ahead ? `\nNothing for \`oats update\` to run.${untouchedNote}` : "\nUp to date.");
|
|
3718
3957
|
console.log("\nUpdate steps:");
|
|
3719
|
-
for (const s of steps) console.log(` ${s}`);
|
|
3720
|
-
if (checkOnly)
|
|
3958
|
+
for (const s of steps) console.log(` ${s.display}`);
|
|
3959
|
+
if (checkOnly) return end("\n(--check: not executing)");
|
|
3721
3960
|
const interactive = process.stdin.isTTY && process.stdout.isTTY;
|
|
3722
3961
|
if (interactive) {
|
|
3723
3962
|
process.stdout.write("\nRun these now? [y/N] ");
|
|
3724
3963
|
const buf = Buffer.alloc(16);
|
|
3725
3964
|
let answer = "";
|
|
3726
3965
|
try { answer = buf.toString("utf8", 0, readSync(0, buf, 0, 16)).trim().toLowerCase(); } catch { /* no input */ }
|
|
3727
|
-
if (answer !== "y" && answer !== "yes")
|
|
3728
|
-
} else if (!args.includes("--yes"))
|
|
3729
|
-
|
|
3730
|
-
|
|
3966
|
+
if (answer !== "y" && answer !== "yes") return end("Not updating.");
|
|
3967
|
+
} else if (!args.includes("--yes")) return end("\nNon-interactive: pass --yes to execute, or run the steps yourself.");
|
|
3968
|
+
// Before any step, the CLI's included: the bridge's exact version is seen on the registry by a
|
|
3969
|
+
// lookup that revalidates npm's cache (awebai/oats#852). A version is listed a while after it
|
|
3970
|
+
// is published, and the kernel's "latest" says nothing about the bridge's.
|
|
3971
|
+
if (moves.length) {
|
|
3972
|
+
const lookup = bridgeLookup(target);
|
|
3973
|
+
console.log(`\n$ ${lookup.join(" ")}`);
|
|
3974
|
+
const notSeen = bridgeLookupProblem(spawnSync(lookup[0], lookup.slice(1), { encoding: "utf8", timeout: 30000 }), cli);
|
|
3975
|
+
if (notSeen) fail(notSeen);
|
|
3731
3976
|
}
|
|
3732
|
-
for (const s of steps) {
|
|
3733
|
-
console.log(`\n$ ${s}`);
|
|
3734
|
-
const [
|
|
3735
|
-
const
|
|
3736
|
-
|
|
3977
|
+
for (const [i, s] of steps.entries()) {
|
|
3978
|
+
console.log(`\n$ ${s.display}`);
|
|
3979
|
+
const r = spawnSync(s.argv[0], s.argv.slice(1), { stdio: "inherit", env: { ...process.env, ...s.env } });
|
|
3980
|
+
const ran = r.error ? `${s.argv[0]}: ${r.error.message}` : r.status !== 0 ? (r.signal ? `killed by ${r.signal}` : `exit ${r.status}`) : null;
|
|
3981
|
+
const problem = s.entry ? piBridgeStepProblem(s.entry, target, ran) : ran;
|
|
3982
|
+
if (problem) fail(piBridgeFailure({ entry: s.entry, display: s.display, problem, notReached: steps.slice(i + 1).filter((next) => next.entry).map((next) => next.entry) }));
|
|
3737
3983
|
}
|
|
3738
|
-
|
|
3984
|
+
end(`\nUpdated to ${target}.${untouchedNote} Now verify each deployment: run \`oats doctor\` at your workspace/repo scopes — it reports config spellings this version rejects, version skew, and missing requirements. Restart running pi sessions to pick up the new bridge.`);
|
|
3739
3985
|
}
|
|
3740
3986
|
|
|
3741
3987
|
// ---------- version (Desktop CLI API v1 probe) ----------
|
|
@@ -3770,6 +4016,16 @@ function versionCmd() {
|
|
|
3770
4016
|
const EXPERIMENTAL_CMDS = new Set(["dress", "spawn", "segments", "mind"]);
|
|
3771
4017
|
async function recordCmd(sub) {
|
|
3772
4018
|
process.argv.splice(2, 1);
|
|
4019
|
+
if (sub === "setup") {
|
|
4020
|
+
// setup writes a node into the user's Claude settings and into the capture watcher's unit,
|
|
4021
|
+
// and nothing rewrites them but setup run again: it is handed the rule's answer for the node
|
|
4022
|
+
// running this kernel (docs/capabilities.md, "The node a hook writes down"). The script is
|
|
4023
|
+
// imported into this process, so the variable is set here, over whatever the caller's
|
|
4024
|
+
// environment held; packages/record imports nothing of the kernel.
|
|
4025
|
+
const { node, warning } = stableNode({ consequence: "the capture hooks and the capture watcher stop when it goes away", remedy: "run `oats setup` again" });
|
|
4026
|
+
if (warning) console.error(`oats: warning: ${warning}`);
|
|
4027
|
+
process.env.OATS_NODE_BIN = node;
|
|
4028
|
+
}
|
|
3773
4029
|
await import(new URL(`../packages/record/bin/${sub}.mjs`, import.meta.url));
|
|
3774
4030
|
}
|
|
3775
4031
|
async function experimentalCmd() {
|
|
@@ -4239,7 +4495,7 @@ async function serverRouteCmd() {
|
|
|
4239
4495
|
// keeping it at column 0 makes the whole command table one reviewable diff of
|
|
4240
4496
|
// added lines rather than ~150 lines of pure whitespace churn, and keeps `git
|
|
4241
4497
|
// blame` pointing at the commit that last changed each command.
|
|
4242
|
-
const TYPED_CLI_FAILURES =
|
|
4498
|
+
const TYPED_CLI_FAILURES = OWN_NAME_FAILURES; // one list: lib/errors.mjs
|
|
4243
4499
|
/** Removed 0.24 verbs → their v2 replacement (workspace model v2, decision 5). Checked before capability dispatch. */
|
|
4244
4500
|
const REMOVED_VERBS = { prepare: "`oats onboard` / `oats sync` to set up a workspace, and `oats spawn <soul> --preview` to see what a spawn would resolve (the captured/portable path was removed in 0.26)", create: "author souls/<name>/soul.yaml + AGENTS.md in a member repository, then `oats sync`", type: "the soul's own soul.yaml in its member repository (agent types were a classic config block)", install: "oats sync", restore: "oats sync", init: "oats-local.yaml + oats sync", use: "soul.yaml capabilities: { <cap>: { from } } + workspace defaults", trust: "declaring the package in packages: (package approval was removed; oats sync locks commit + integrity)", list: "oats workspace status | oats capabilities", catalog: "oats package add <id> <version> (bare versions resolve through package-catalog.json)", remove: "oats package remove <id>", migrate: "a rebuild (no migration: docs/design/2026-09-23-workspace-module-contracts.md)", config: "oats-local.yaml (host settings) and oats-workspace.yaml (shared)", inject: "injection overrides are not part of the workspace model yet; edit the capability inject in its member repo" };
|
|
4245
4501
|
try {
|
|
@@ -4318,6 +4574,7 @@ else if (cmd === "teams") await teamsCmd();
|
|
|
4318
4574
|
else if (cmd === "soul") await soulCmd();
|
|
4319
4575
|
else if (cmd === "status") await status();
|
|
4320
4576
|
else if (cmd === "pane") await paneCmd();
|
|
4577
|
+
else if (cmd === "tui") await tuiCmd();
|
|
4321
4578
|
else if (cmd === "version" || cmd === "--version" || cmd === "-v") versionCmd();
|
|
4322
4579
|
// Same rule as the inner catch: a typed CLI failure surfaces with its own code
|
|
4323
4580
|
// through the shared boundary, never re-badged as a spawn-mechanism failure.
|
|
@@ -4326,7 +4583,11 @@ else if (cmd === "schedule") await scheduleCmd();
|
|
|
4326
4583
|
else if (cmd === "trigger") await triggerCmd();
|
|
4327
4584
|
else if (cmd === "automations") await automationsCmd();
|
|
4328
4585
|
else if (cmd === "spawn") { try { await spawnCmd(); } catch (e) { if (TYPED_CLI_FAILURES.has(e?.code)) throw e; if (JSON_MODE) jsonFail("E_SPAWN_FAILED", e.message || e, e.details?.unconfirmed === true ? e.details : undefined); throw e; } }
|
|
4329
|
-
|
|
4586
|
+
// What a retire throws outside its own answers (the root, a replay's read) goes through the same door.
|
|
4587
|
+
// An exception after the retire has returned (retireReturned) is rethrown, here and by the handler
|
|
4588
|
+
// of typed failures below: a crash is read as "not confirmed", which is the truth, where an error
|
|
4589
|
+
// answer without `reached` would read as "nothing was done".
|
|
4590
|
+
else if (cmd === "retire") { try { retireCmd(); } catch (e) { if (retireReturned || TYPED_CLI_FAILURES.has(e?.code)) throw e; lifecycleFail(e, "E_LIFECYCLE_FAILED", e.details); } }
|
|
4330
4591
|
else if (cmd === "capture" || cmd === "recall" || cmd === "setup") await recordCmd(cmd);
|
|
4331
4592
|
else if (cmd === "experimental") await experimentalCmd();
|
|
4332
4593
|
// `!HELP_WORDS.has(cmd)`: usage NEVER depends on deployment state. `help` is a
|
|
@@ -4380,6 +4641,12 @@ Usage:
|
|
|
4380
4641
|
Desktop CLI API v1 probe payload
|
|
4381
4642
|
oats status [--json] agents, souls, running instances
|
|
4382
4643
|
[--max-age <s>] reuse head observations up to <s> s old (below)
|
|
4644
|
+
oats tui [--dir <path>] [--ascii] PREVIEW: the full-screen terminal client (docs/tui.md):
|
|
4645
|
+
the instances of the workspace of the deployment at or
|
|
4646
|
+
above <path> (default: where you are), on this machine
|
|
4647
|
+
and on the machines registered here; it changes nothing.
|
|
4648
|
+
? help, w workspaces, q quit. Needs a terminal on stdin and
|
|
4649
|
+
stdout and has no --json form; --ascii = ASCII rules and marks
|
|
4383
4650
|
oats server add <id> --ssh <alias> register another machine's OATS (OpenSSH alias,
|
|
4384
4651
|
--workspace </abs/path> [--oats <p>] remote workspace, remote oats path; no keys stored;
|
|
4385
4652
|
[--path <dir:dir>] --path = dirs prepended to the remote PATH, e.g. ~/.local/bin)
|
|
@@ -4526,8 +4793,10 @@ Usage:
|
|
|
4526
4793
|
own command run in the home or scope, envelope
|
|
4527
4794
|
relayed; a view answers {documents: [...]}
|
|
4528
4795
|
oats harness trust [--dir <deployment>] explicitly trust one canonical deployment root
|
|
4529
|
-
[--harness claude|codex|all] in native
|
|
4530
|
-
[--plan] [--json]
|
|
4796
|
+
[--harness claude|codex|all] in every native configuration file a launch reads
|
|
4797
|
+
[--plan] [--json] (the ambient one and each launch configuration's
|
|
4798
|
+
CLAUDE_CONFIG_DIR / CODEX_HOME); --plan reads only,
|
|
4799
|
+
bare command applies with a durable audit
|
|
4531
4800
|
oats launch-config list [--dir <scope> named launch configurations effective at a scope,
|
|
4532
4801
|
| --home <abs> | --soul <name>] a home's recorded context or a soul's own scope:
|
|
4533
4802
|
[--agents-root <abs>] [--json] harness, executable, args, env (values redacted,
|
|
@@ -4545,8 +4814,9 @@ Usage:
|
|
|
4545
4814
|
[--yolo | --no-yolo] --json a disagreeing --harness is refused
|
|
4546
4815
|
oats doctor [dir] [--soul <name>] [--json] resolved targets, trust, requirements;
|
|
4547
4816
|
--soul shows final composed AGENTS.md
|
|
4548
|
-
oats update [--check] [--yes] check npm for a newer kernel
|
|
4549
|
-
|
|
4817
|
+
oats update [--check] [--yes] check npm for a newer kernel and move the pi bridge
|
|
4818
|
+
[--dir <deployment>] in every pi folder the deployment's launches use
|
|
4819
|
+
(docs/upgrading.md); then run oats doctor
|
|
4550
4820
|
oats sync [--dir <d>] [--plan] [--json] workspace model v2: observe the workspace named by
|
|
4551
4821
|
oats-local.yaml over its Git remote, confirm every
|
|
4552
4822
|
member (reciprocal oats-membership.yaml), resolve
|
|
@@ -4582,6 +4852,19 @@ Usage:
|
|
|
4582
4852
|
where there is none / it is <label>
|
|
4583
4853
|
oats soul teams <soul>|'*' [--dir <d>] which teams a soul may join here, its default, and
|
|
4584
4854
|
[--max-age <s>] [--json] why (the workspace's souls: and local teams)
|
|
4855
|
+
oats soul launch set <soul>|'*' (--launch-config <name>|none | --harness pi|claude|codex [--model <id>])
|
|
4856
|
+
[--plan] [--dir <d>] [--json] pin a soul's launch on this machine: writes its key
|
|
4857
|
+
(its bare name, or <package>/<soul>; '*' = every soul
|
|
4858
|
+
without an entry) in oats-local.yaml souls.launch.
|
|
4859
|
+
The file is rewritten; every other entry keeps its
|
|
4860
|
+
value and its comments. --plan: every check, nothing
|
|
4861
|
+
written. It reads the workspace live (no --max-age)
|
|
4862
|
+
oats soul launch remove <soul>|'*'|<exact key> [--plan] [--dir <d>] [--json]
|
|
4863
|
+
remove one entry of souls.launch: a soul's, '*', or
|
|
4864
|
+
the exact text of a key in the file (that form works
|
|
4865
|
+
when the workspace's souls cannot be read, and is how
|
|
4866
|
+
a key that names no soul is removed); no such entry is
|
|
4867
|
+
E_LAUNCH_PREFERENCE_UNKNOWN
|
|
4585
4868
|
oats instance git <instance> [--home <abs>] [--dir <d>] [--json]
|
|
4586
4869
|
read-only Git observation of the instance's work
|
|
4587
4870
|
tree: branch, status (renames kept), ahead/behind
|
|
@@ -4671,7 +4954,8 @@ Observation reuse (feature observe-max-age):
|
|
|
4671
4954
|
Layers: ${LAYERS.join(", ")}. Workspace model v2: docs/design/2026-09-23-workspace-module-contracts.md.`;
|
|
4672
4955
|
}
|
|
4673
4956
|
} catch (e) {
|
|
4674
|
-
|
|
4957
|
+
// After a retire has returned, nothing is answered as an error, a typed failure included (the dispatch).
|
|
4958
|
+
if (retireReturned || !TYPED_CLI_FAILURES.has(e?.code)) throw e;
|
|
4675
4959
|
// Same two renderings as every other typed failure: one envelope on stdout in
|
|
4676
4960
|
// --json mode, one `oats: <message>` line on stderr otherwise. The message
|
|
4677
4961
|
// already names the offending file — the readers re-raise it with one.
|