@cohortapp/agent-sdk 2.11.15 → 2.13.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/.env.example +37 -22
- package/README.md +2 -0
- package/bin/maestro.mjs +117 -39
- package/bin/maestro.test.mjs +175 -5
- package/docs/guides/front-door-session.md +313 -0
- package/docs/guides/mac-mini.md +100 -28
- package/docs/guides/org-onboarding.md +1 -1
- package/docs/guides/setup-wizard.md +9 -5
- package/docs/runbooks/cohort-cutover.md +11 -1
- package/docs/runbooks/mac-mini-bootstrap.md +38 -63
- package/lib/cadence-bus-requeue.test.mjs +83 -0
- package/lib/cadence-bus.mjs +43 -7
- package/lib/channels/inbox-item.mjs +59 -2
- package/lib/cli/board.mjs +285 -0
- package/lib/cli/board.test.mjs +227 -0
- package/lib/cli/design.mjs +185 -0
- package/lib/cli/design.test.mjs +270 -0
- package/lib/cli/doctor-checks.mjs +441 -0
- package/lib/cli/doctor-checks.test.mjs +336 -0
- package/lib/cli/global-setup-extras.mjs +454 -0
- package/lib/cli/global-setup-extras.test.mjs +462 -0
- package/lib/cli/inbox.mjs +304 -0
- package/lib/cli/inbox.test.mjs +230 -0
- package/lib/cli/session-ack.mjs +63 -0
- package/lib/cli/session-ack.test.mjs +63 -0
- package/lib/cli/session.mjs +760 -0
- package/lib/cli/session.test.mjs +613 -0
- package/lib/collective/global-config.mjs +209 -6
- package/lib/collective/global-config.test.mjs +145 -0
- package/lib/collective/global-skills.mjs +145 -0
- package/lib/collective/global-skills.test.mjs +126 -0
- package/lib/collective/presence.mjs +4 -3
- package/lib/collective/vendor-skills.mjs +305 -0
- package/lib/collective/vendor-skills.test.mjs +306 -0
- package/lib/comms/send-gate.mjs +115 -0
- package/lib/comms/send-gate.test.mjs +113 -0
- package/lib/design/design-md.mjs +793 -0
- package/lib/design/design-md.test.mjs +318 -0
- package/lib/design/fixtures/DESIGN.golden.md +238 -0
- package/lib/design/fixtures/PRODUCT.golden.md +67 -0
- package/lib/design/fixtures/foundation.json +133 -0
- package/lib/design/refresh-gate.mjs +154 -0
- package/lib/design/refresh-gate.test.mjs +144 -0
- package/lib/design/write.mjs +275 -0
- package/lib/design/write.test.mjs +241 -0
- package/lib/feature-init.mjs +2 -2
- package/lib/mcp/server.test.mjs +9 -4
- package/lib/model-router/spawn.test.mjs +21 -0
- package/lib/org/board-mine-cache.mjs +99 -0
- package/lib/org/board-mine-cache.test.mjs +53 -0
- package/lib/org/board.mjs +11 -0
- package/lib/org/board.test.mjs +11 -1
- package/lib/org/client.mjs +36 -0
- package/lib/org/client.test.mjs +46 -0
- package/lib/org/inbound/directedness.mjs +18 -2
- package/lib/org/inbound/directedness.test.mjs +58 -0
- package/lib/org/inbound/index.mjs +8 -1
- package/lib/org/inbound/index.test.mjs +22 -0
- package/lib/org/mesh-directives.test.mjs +110 -0
- package/lib/org/mesh.mjs +61 -1
- package/lib/org/protocol.checksum +1 -1
- package/lib/org/protocol.mjs +52 -0
- package/lib/org/protocol.test.mjs +12 -1
- package/lib/org/registry.mjs +3 -2
- package/lib/org/tool-surface.mjs +120 -0
- package/lib/org/tool-surface.test.mjs +118 -5
- package/lib/prompts/parallelism.mjs +79 -0
- package/lib/prompts/parallelism.test.mjs +177 -0
- package/lib/security/external-content.mjs +1 -1
- package/lib/security/external-content.test.mjs +17 -0
- package/lib/session/config.mjs +137 -0
- package/lib/session/config.test.mjs +92 -0
- package/lib/session/feed-core.mjs +229 -0
- package/lib/session/feed-core.test.mjs +198 -0
- package/lib/session/first-run.mjs +126 -0
- package/lib/session/first-run.test.mjs +121 -0
- package/lib/session/frontdoor.mjs +266 -0
- package/lib/session/frontdoor.test.mjs +205 -0
- package/lib/session/handoffs.mjs +295 -0
- package/lib/session/handoffs.test.mjs +183 -0
- package/lib/session/identity.mjs +220 -0
- package/lib/session/identity.test.mjs +180 -0
- package/lib/session/inbox-claims.mjs +434 -0
- package/lib/session/inbox-claims.test.mjs +286 -0
- package/lib/session/launch-args.mjs +161 -0
- package/lib/session/launch-args.test.mjs +157 -0
- package/lib/session/liveness.mjs +174 -0
- package/lib/session/liveness.test.mjs +100 -0
- package/lib/session/status-summary.mjs +172 -0
- package/lib/session/status-summary.test.mjs +118 -0
- package/lib/session-permissions.mjs +39 -3
- package/lib/session-permissions.test.mjs +20 -0
- package/lib/setup/claude-probe.mjs +161 -24
- package/lib/setup/claude-probe.test.mjs +187 -0
- package/lib/setup/sections/learning.mjs +2 -1
- package/lib/setup/sections/model.mjs +104 -24
- package/lib/setup/sections/model.test.mjs +240 -0
- package/lib/setup/sections/org.mjs +27 -2
- package/lib/setup/sections/org.test.mjs +35 -2
- package/lib/setup/sections/verify.mjs +5 -0
- package/lib/setup/state.mjs +30 -10
- package/lib/setup/state.test.mjs +24 -1
- package/lib/singleton.js +11 -3
- package/lib/singleton.test.mjs +16 -0
- package/lib/subagents/lock.mjs +1 -1
- package/lib/telemetry/collect.mjs +270 -6
- package/lib/telemetry/collect.test.mjs +196 -1
- package/lib/upgrade/global-refresh.mjs +108 -0
- package/lib/upgrade/global-refresh.test.mjs +65 -0
- package/lib/upgrade/launchd-reconcile.mjs +327 -0
- package/lib/upgrade/launchd-reconcile.test.mjs +272 -0
- package/lib/upgrade/post-steps.mjs +151 -0
- package/lib/upgrade/post-steps.test.mjs +200 -0
- package/lib/upgrade/verify.mjs +215 -0
- package/lib/upgrade/verify.test.mjs +164 -0
- package/lib/voice/outbound.mjs +3 -2
- package/lib/voice/post-call-brief.mjs +2 -1
- package/lib/voice/session-rotation.mjs +6 -1
- package/lib/voice/session-rotation.test.mjs +114 -0
- package/package.json +3 -3
- package/plugins/maestro-skills/plugin.json +25 -1
- package/plugins/maestro-skills/skills/board-work.md +63 -0
- package/plugins/maestro-skills/skills/cohort-design.md +153 -0
- package/plugins/maestro-skills/skills/inbound-triage.md +80 -0
- package/plugins/maestro-skills/skills/main-session.md +102 -0
- package/plugins/maestro-skills/skills/peer-sessions.md +65 -0
- package/plugins/maestro-skills/skills/persona-discipline.md +75 -0
- package/plugins/maestro-skills/vendor/emilkowalski/LICENSE +21 -0
- package/plugins/maestro-skills/vendor/emilkowalski/UPSTREAM.json +70 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/animate/RECIPES.md +324 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/animate/SKILL.md +199 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/animation-vocabulary/SKILL.md +173 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/apple-design/SKILL.md +282 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/emil-design-eng/SKILL.md +674 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/find-animation-opportunities/SKILL.md +132 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/improve-animations/AUDIT.md +115 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/improve-animations/PLAN-TEMPLATE.md +73 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/improve-animations/SKILL.md +101 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/prototype/PICKER.md +197 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/prototype/SKILL.md +90 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/review-animations/SKILL.md +112 -0
- package/plugins/maestro-skills/vendor/emilkowalski/skills/review-animations/STANDARDS.md +187 -0
- package/plugins/maestro-skills/vendor/impeccable/LICENSE +191 -0
- package/plugins/maestro-skills/vendor/impeccable/NOTICE.md +11 -0
- package/plugins/maestro-skills/vendor/impeccable/SKILL.md +86 -0
- package/plugins/maestro-skills/vendor/impeccable/UPSTREAM.json +201 -0
- package/plugins/maestro-skills/vendor/impeccable/agents/impeccable-asset-producer.md +42 -0
- package/plugins/maestro-skills/vendor/impeccable/agents/impeccable-documenter.md +29 -0
- package/plugins/maestro-skills/vendor/impeccable/agents/impeccable-finish-reviewer.md +43 -0
- package/plugins/maestro-skills/vendor/impeccable/agents/impeccable-manual-edit-applier.md +97 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/adapt.md +312 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/adapt.native.md +58 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/android.md +46 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/animate.md +89 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/audit.md +136 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/audit.native.md +139 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/bolder.md +33 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/clarify.md +94 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/colorize.md +86 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/craft-floor.md +44 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/craft.md +5 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/critique.md +806 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/degraded/asset-producer.md +37 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/degraded/documenter.md +24 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/degraded/finish-reviewer.md +38 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/degraded/manual-edit-applier.md +92 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/delight.md +70 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/distill.md +111 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/doctor.md +54 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/document.md +416 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/extract.md +69 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/harden.md +336 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/hooks.md +111 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/init.md +131 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/ios.md +51 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/layout.md +84 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/live-setup.md +104 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/live.md +325 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/new-work.md +147 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/onboard.md +234 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/operate.md +61 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/optimize.md +258 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/overdrive.md +127 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/polish.md +105 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/quieter.md +99 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/routing.md +24 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/shape.md +59 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/typeset.md +80 -0
- package/plugins/maestro-skills/vendor/impeccable/reference/visualize.md +46 -0
- package/plugins/maestro-skills/vendor/taste-skill/LICENSE +21 -0
- package/plugins/maestro-skills/vendor/taste-skill/UPSTREAM.json +37 -0
- package/plugins/maestro-skills/vendor/taste-skill/skills/minimalist-skill/SKILL.md +85 -0
- package/plugins/maestro-skills/vendor/taste-skill/skills/redesign-skill/SKILL.md +178 -0
- package/plugins/maestro-skills/vendor/taste-skill/skills/soft-skill/SKILL.md +98 -0
- package/plugins/maestro-skills/vendor/taste-skill/skills/taste-skill/SKILL.md +1206 -0
- package/plugins/maestro-skills/vendor/unlazy/LICENSE +21 -0
- package/plugins/maestro-skills/vendor/unlazy/SECURITY.md +72 -0
- package/plugins/maestro-skills/vendor/unlazy/SKILL.md +104 -0
- package/plugins/maestro-skills/vendor/unlazy/UPSTREAM.json +94 -0
- package/plugins/maestro-skills/vendor/unlazy/references/dispatch.md +82 -0
- package/plugins/maestro-skills/vendor/unlazy/references/gates.md +149 -0
- package/plugins/maestro-skills/vendor/unlazy/references/method.md +49 -0
- package/plugins/maestro-skills/vendor/unlazy/references/orchestration.md +107 -0
- package/plugins/maestro-skills/vendor/unlazy/references/parallel.md +133 -0
- package/plugins/maestro-skills/vendor/unlazy/references/token-economy.md +48 -0
- package/plugins/maestro-skills/vendor/unlazy/scripts/dispatch-check.mjs +139 -0
- package/plugins/maestro-skills/vendor/unlazy/scripts/gate-check.mjs +960 -0
- package/plugins/maestro-skills/vendor/unlazy/scripts/gate-lint.mjs +245 -0
- package/plugins/maestro-skills/vendor/unlazy/scripts/lib/check-supervisor.mjs +46 -0
- package/plugins/maestro-skills/vendor/unlazy/scripts/lib/dispatch.mjs +293 -0
- package/plugins/maestro-skills/vendor/unlazy/scripts/lib/gates.mjs +953 -0
- package/plugins/maestro-skills/vendor/unlazy/scripts/lib/process-tree.mjs +161 -0
- package/plugins/maestro-skills/vendor/unlazy/scripts/lib/regex-worker.mjs +9 -0
- package/plugins/maestro-skills/vendor/unlazy/templates/PLAN.md +116 -0
- package/plugins/maestro-skills/vendor/unlazy/templates/gates-leaf.md +51 -0
- package/plugins/maestro-skills/vendor/unlazy/templates/gates-node.md +51 -0
- package/scaffold/CLAUDE.md +24 -0
- package/scripts/ci/check-durable-write-seam.mjs +147 -0
- package/scripts/ci/check-durable-write-seam.test.mjs +90 -0
- package/scripts/ci/check-skill-packs.mjs +388 -0
- package/scripts/ci/check-skill-packs.test.mjs +495 -0
- package/scripts/ci/check.mjs +6 -0
- package/scripts/collective/hook-runner.mjs +39 -4
- package/scripts/collective/hook-runner.test.mjs +85 -2
- package/scripts/daemon/agent-daemon-board-mine.test.mjs +96 -0
- package/scripts/daemon/agent-daemon-design.test.mjs +238 -0
- package/scripts/daemon/agent-daemon-frontdoor.test.mjs +60 -0
- package/scripts/daemon/agent-daemon.mjs +249 -10
- package/scripts/daemon/agent-daemon.test.mjs +73 -0
- package/scripts/daemon/assurance-e2e.test.mjs +141 -6
- package/scripts/daemon/assurance.mjs +461 -37
- package/scripts/daemon/assurance.test.mjs +408 -43
- package/scripts/daemon/cadence-consumer-frontdoor.test.mjs +393 -0
- package/scripts/daemon/cadence-consumer.mjs +289 -89
- package/scripts/daemon/cadence-handlers.mjs +53 -0
- package/scripts/daemon/classifier.mjs +1 -1
- package/scripts/daemon/dispatcher-resume.test.mjs +166 -0
- package/scripts/daemon/dispatcher.mjs +127 -19
- package/scripts/daemon/health.mjs +12 -1
- package/scripts/daemon/inbox-deferral-session.test.mjs +49 -0
- package/scripts/daemon/inbox-deferral.mjs +6 -0
- package/scripts/daemon/lib/self-echo.mjs +201 -0
- package/scripts/daemon/lib/self-echo.test.mjs +153 -0
- package/scripts/daemon/maestro-daemon.mjs +3 -0
- package/scripts/daemon/prompt-builder.mjs +19 -3
- package/scripts/daemon/responder.mjs +51 -40
- package/scripts/daemon/sdk-version.mjs +51 -0
- package/scripts/daemon/sdk-version.test.mjs +31 -0
- package/scripts/hooks/pre-send-audit.sh +97 -4
- package/scripts/hooks/pre-send-audit.test.mjs +140 -1
- package/scripts/local-triggers/autoupdate.sh +243 -19
- package/scripts/local-triggers/autoupdate.test.mjs +518 -0
- package/scripts/local-triggers/generate-plists.sh +24 -1
- package/scripts/local-triggers/generate-plists.test.mjs +49 -11
- package/scripts/org/send-orgmail.first-contact.test.mjs +102 -0
- package/scripts/org/send-orgmail.mjs +27 -3
- package/scripts/poller/inbox-privilege-injection.test.mjs +167 -0
- package/scripts/poller/slack-poller.mjs +13 -1
- package/scripts/poller/utils.mjs +46 -1
- package/scripts/poller-launchd/install.sh +19 -11
- package/scripts/poller-launchd/install.test.mjs +243 -0
- package/scripts/poller-launchd/launchd-poller-wrapper.sh +92 -0
- package/scripts/poller-launchd/migrate.sh +66 -0
- package/scripts/poller-launchd/poller.plist.template +4 -2
- package/scripts/session/feed.mjs +237 -0
- package/scripts/session/feed.test.mjs +196 -0
- package/scripts/session/supervisor-sh.test.mjs +218 -0
- package/scripts/session/supervisor.mjs +328 -0
- package/scripts/session/supervisor.sh +141 -0
- package/scripts/session/supervisor.test.mjs +482 -0
- package/scripts/setup/configure-macos.sh +250 -55
- package/scripts/setup/configure-macos.test.mjs +306 -0
- package/scripts/setup/init-agent.sh +112 -7
- package/scripts/setup/init-agent.test.mjs +220 -1
- package/scripts/vendor/skill-packs.mjs +354 -0
- package/scripts/vendor/sync-skill-packs.mjs +242 -0
- package/scripts/vendor/sync-skill-packs.test.mjs +103 -0
- package/scripts/watchdog/memory-watchdog.sh +37 -1
- package/scripts/watchdog/memory-watchdog.test.mjs +64 -0
- package/scripts/setup/boot-claude-session.sh +0 -94
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* configure-macos.test.mjs — scripts/setup/configure-macos.sh
|
|
3
|
+
*
|
|
4
|
+
* Covers the 2026-09-08 front-door-session changes (design §6 WP-M3):
|
|
5
|
+
* - the Terminal.app `ai.maestro.boot-claude-session` job is RETIRED: the
|
|
6
|
+
* script unloads + removes it if present and never writes it again;
|
|
7
|
+
* - `--tailscale-ssh` advertises Tailscale SSH and turns Remote Login on,
|
|
8
|
+
* then prints the tailnet ACL reminder (audit F4: 0/41 peers reachable);
|
|
9
|
+
* - `--check` reports both Tailscale SSH and Remote Login.
|
|
10
|
+
*
|
|
11
|
+
* The script talks to real macOS tooling (launchctl, tailscale, systemsetup,
|
|
12
|
+
* pmset, defaults …), so every test runs it with a PATH of STUB binaries that
|
|
13
|
+
* append their argv to a log file. Nothing here touches the real machine.
|
|
14
|
+
* Functions are exercised by sourcing the script with
|
|
15
|
+
* MAESTRO_CONFIGURE_MACOS_NO_MAIN=1 (main() is skipped), the same seam the
|
|
16
|
+
* script exposes for exactly this purpose.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { test } from "node:test";
|
|
20
|
+
import assert from "node:assert/strict";
|
|
21
|
+
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, chmodSync, rmSync } from "node:fs";
|
|
22
|
+
import { spawnSync } from "node:child_process";
|
|
23
|
+
import { join, dirname } from "node:path";
|
|
24
|
+
import { tmpdir } from "node:os";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
|
|
27
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
const SCRIPT = join(__dirname, "configure-macos.sh");
|
|
29
|
+
const scriptSrc = readFileSync(SCRIPT, "utf8");
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Build a stub-binary directory. Every named stub appends `<name> <argv>` to
|
|
33
|
+
* `calls.log` and prints `stdoutByName[name]` (if any), exiting 0. `sudo` is
|
|
34
|
+
* special: it logs then re-execs the rest of its argv so `sudo systemsetup …`
|
|
35
|
+
* still reaches the systemsetup stub.
|
|
36
|
+
*/
|
|
37
|
+
function makeStubs(dir, names, stdoutByName = {}) {
|
|
38
|
+
const bin = join(dir, "bin");
|
|
39
|
+
mkdirSync(bin, { recursive: true });
|
|
40
|
+
const log = join(dir, "calls.log");
|
|
41
|
+
// osascript is ALWAYS stubbed: the real one can pop a System Events
|
|
42
|
+
// permission prompt or edit the developer's Login Items.
|
|
43
|
+
for (const name of new Set([...names, "osascript"])) {
|
|
44
|
+
const out = stdoutByName[name] ? `printf '%s\\n' ${JSON.stringify(stdoutByName[name])}\n` : "";
|
|
45
|
+
const body = name === "sudo"
|
|
46
|
+
? `#!/bin/bash\necho "sudo $*" >> "${log}"\n# drop sudo flags (-n, -u user) then exec the real command (a sibling stub)\nwhile [ "$1" = "-n" ] || [ "$1" = "-u" ]; do if [ "$1" = "-u" ]; then shift 2; else shift; fi; done\nexec "$@"\n`
|
|
47
|
+
: `#!/bin/bash\necho "${name} $*" >> "${log}"\n${out}exit 0\n`;
|
|
48
|
+
writeFileSync(join(bin, name), body);
|
|
49
|
+
chmodSync(join(bin, name), 0o755);
|
|
50
|
+
}
|
|
51
|
+
return { bin, log };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function fixture() {
|
|
55
|
+
const root = mkdtempSync(join(tmpdir(), "configure-macos-test-"));
|
|
56
|
+
const home = join(root, "home");
|
|
57
|
+
mkdirSync(join(home, "Library", "LaunchAgents"), { recursive: true });
|
|
58
|
+
// The script derives AGENT_DIR from its own location (scripts/setup/../..),
|
|
59
|
+
// so copy it into a fixture agent dir.
|
|
60
|
+
const agent = join(root, "agent");
|
|
61
|
+
mkdirSync(join(agent, "scripts", "setup"), { recursive: true });
|
|
62
|
+
writeFileSync(join(agent, "scripts", "setup", "configure-macos.sh"), scriptSrc);
|
|
63
|
+
chmodSync(join(agent, "scripts", "setup", "configure-macos.sh"), 0o755);
|
|
64
|
+
return { root, home, agent, script: join(agent, "scripts", "setup", "configure-macos.sh") };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function run(fx, stubs, args, extraEnv = {}) {
|
|
68
|
+
return spawnSync("/bin/bash", [fx.script, ...args], {
|
|
69
|
+
encoding: "utf8",
|
|
70
|
+
cwd: fx.agent,
|
|
71
|
+
env: {
|
|
72
|
+
HOME: fx.home,
|
|
73
|
+
// Stubs FIRST so the script can never reach the real launchctl/tailscale.
|
|
74
|
+
PATH: `${stubs.bin}:/usr/bin:/bin`,
|
|
75
|
+
TERM: "dumb",
|
|
76
|
+
...extraEnv,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Source the script without running main(), then run `snippet` in that shell. */
|
|
82
|
+
function runFn(fx, stubs, snippet, extraEnv = {}) {
|
|
83
|
+
return spawnSync("/bin/bash", ["-c", `source "${fx.script}" && ${snippet}`], {
|
|
84
|
+
encoding: "utf8",
|
|
85
|
+
cwd: fx.agent,
|
|
86
|
+
env: {
|
|
87
|
+
HOME: fx.home,
|
|
88
|
+
PATH: `${stubs.bin}:/usr/bin:/bin`,
|
|
89
|
+
MAESTRO_CONFIGURE_MACOS_NO_MAIN: "1",
|
|
90
|
+
TERM: "dumb",
|
|
91
|
+
...extraEnv,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const calls = (stubs) => (existsSync(stubs.log) ? readFileSync(stubs.log, "utf8") : "");
|
|
97
|
+
|
|
98
|
+
// --- static guards on the script source ------------------------------------
|
|
99
|
+
|
|
100
|
+
test("configure-macos.sh never writes the boot-claude-session plist again", () => {
|
|
101
|
+
// The Terminal.app boot job (F15: no KeepAlive, no lock, needs a GUI) is
|
|
102
|
+
// replaced by the launchd `ai.maestro.<first>-session` supervisor job that
|
|
103
|
+
// generate-plists.sh emits. This script must only ever REMOVE it.
|
|
104
|
+
assert.ok(!/boot-claude-session\.sh/.test(scriptSrc),
|
|
105
|
+
"must not reference boot-claude-session.sh at all (the script is retired)");
|
|
106
|
+
assert.ok(!/<string>\$\{BOOT_SCRIPT\}<\/string>/.test(scriptSrc),
|
|
107
|
+
"the boot-claude-session plist heredoc must be gone");
|
|
108
|
+
assert.ok(/retire_boot_claude_session\(\)/.test(scriptSrc), "a retire function must exist");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("configure-macos.sh exposes a source-only seam and documents --tailscale-ssh", () => {
|
|
112
|
+
assert.ok(scriptSrc.includes("MAESTRO_CONFIGURE_MACOS_NO_MAIN"), "sourcing seam missing");
|
|
113
|
+
assert.ok(/--tailscale-ssh/.test(scriptSrc), "--tailscale-ssh flag missing");
|
|
114
|
+
assert.match(scriptSrc, /tailscale set --ssh/, "must advertise SSH via `tailscale set --ssh`");
|
|
115
|
+
assert.match(scriptSrc, /systemsetup -setremotelogin on/, "must turn Remote Login on");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// --- retire the legacy boot session job -------------------------------------
|
|
119
|
+
|
|
120
|
+
test("retire_boot_claude_session unloads and removes a present legacy plist", () => {
|
|
121
|
+
const fx = fixture();
|
|
122
|
+
const stubs = makeStubs(fx.root, ["launchctl"]);
|
|
123
|
+
const plist = join(fx.home, "Library", "LaunchAgents", "ai.maestro.boot-claude-session.plist");
|
|
124
|
+
writeFileSync(plist, "<plist/>");
|
|
125
|
+
try {
|
|
126
|
+
const r = runFn(fx, stubs, "retire_boot_claude_session");
|
|
127
|
+
assert.equal(r.status, 0, r.stderr + r.stdout);
|
|
128
|
+
assert.ok(!existsSync(plist), "legacy plist must be removed");
|
|
129
|
+
const c = calls(stubs);
|
|
130
|
+
assert.match(c, /launchctl (unload|bootout) .*boot-claude-session/, `expected an unload; calls:\n${c}`);
|
|
131
|
+
assert.match(r.stdout, /boot-claude-session/);
|
|
132
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("retire_boot_claude_session is a no-op when the legacy plist is absent (idempotent)", () => {
|
|
136
|
+
const fx = fixture();
|
|
137
|
+
const stubs = makeStubs(fx.root, ["launchctl"]);
|
|
138
|
+
try {
|
|
139
|
+
const r = runFn(fx, stubs, "retire_boot_claude_session");
|
|
140
|
+
assert.equal(r.status, 0, r.stderr + r.stdout);
|
|
141
|
+
// Second run identical.
|
|
142
|
+
const r2 = runFn(fx, stubs, "retire_boot_claude_session");
|
|
143
|
+
assert.equal(r2.status, 0, r2.stderr + r2.stdout);
|
|
144
|
+
assert.ok(!existsSync(join(fx.home, "Library", "LaunchAgents", "ai.maestro.boot-claude-session.plist")));
|
|
145
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// --- --tailscale-ssh ---------------------------------------------------------
|
|
149
|
+
|
|
150
|
+
test("--tailscale-ssh advertises SSH, enables Remote Login and prints the ACL reminder", () => {
|
|
151
|
+
const fx = fixture();
|
|
152
|
+
const stubs = makeStubs(fx.root, ["tailscale", "sudo", "systemsetup", "launchctl"]);
|
|
153
|
+
try {
|
|
154
|
+
const r = run(fx, stubs, ["--tailscale-ssh"]);
|
|
155
|
+
assert.equal(r.status, 0, r.stderr + r.stdout);
|
|
156
|
+
const c = calls(stubs);
|
|
157
|
+
assert.match(c, /^tailscale set --ssh$/m, `expected tailscale set --ssh; calls:\n${c}`);
|
|
158
|
+
assert.match(c, /^sudo (-n )?systemsetup -setremotelogin on$/m, `expected sudo systemsetup -setremotelogin on; calls:\n${c}`);
|
|
159
|
+
assert.match(c, /^systemsetup -setremotelogin on$/m, "sudo must pass through to systemsetup");
|
|
160
|
+
// The ACL reminder: SSH is only reachable once the tailnet ACL grants it.
|
|
161
|
+
assert.match(r.stdout, /ACL/i, "must print the tailnet ACL reminder");
|
|
162
|
+
assert.match(r.stdout, /"ssh"/, "the reminder should show the ACL `ssh` rule shape");
|
|
163
|
+
assert.match(r.stdout, /login\.tailscale\.com\/admin\/acls|admin\/acls/, "the reminder should point at the ACL editor");
|
|
164
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("--tailscale-ssh fails clearly when the tailscale CLI is absent", () => {
|
|
168
|
+
const fx = fixture();
|
|
169
|
+
const stubs = makeStubs(fx.root, ["sudo", "systemsetup", "launchctl"]);
|
|
170
|
+
try {
|
|
171
|
+
const r = run(fx, stubs, ["--tailscale-ssh"], { MAESTRO_TAILSCALE_BIN: "/nonexistent/tailscale" });
|
|
172
|
+
assert.notEqual(r.status, 0, "must exit non-zero without tailscale");
|
|
173
|
+
assert.match(r.stdout + r.stderr, /tailscale/i);
|
|
174
|
+
const c = calls(stubs);
|
|
175
|
+
assert.ok(!/setremotelogin/.test(c), "must not touch Remote Login when tailscale is missing");
|
|
176
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// --- --check reports both ----------------------------------------------------
|
|
180
|
+
|
|
181
|
+
test("--check reports Tailscale SSH and Remote Login state", () => {
|
|
182
|
+
const fx = fixture();
|
|
183
|
+
const stubs = makeStubs(
|
|
184
|
+
fx.root,
|
|
185
|
+
["tailscale", "sudo", "systemsetup", "launchctl", "pmset", "defaults", "pgrep", "curl", "fdesetup", "sysadminctl"],
|
|
186
|
+
{
|
|
187
|
+
tailscale: '{"RunSSH": true}',
|
|
188
|
+
systemsetup: "Remote Login: On",
|
|
189
|
+
launchctl: "-\t0\tai.maestro.ivy-session",
|
|
190
|
+
},
|
|
191
|
+
);
|
|
192
|
+
try {
|
|
193
|
+
const r = run(fx, stubs, ["--check"]);
|
|
194
|
+
// verify_all returns the issue count; other checks (Parsec etc.) will
|
|
195
|
+
// legitimately fail under stubs, so only the report lines matter here.
|
|
196
|
+
assert.match(r.stdout, /Tailscale SSH: (on|advertised)/i, `stdout:\n${r.stdout}`);
|
|
197
|
+
assert.match(r.stdout, /Remote Login: on/i, `stdout:\n${r.stdout}`);
|
|
198
|
+
assert.match(r.stdout, /session/i, "the check should mention the front-door session job");
|
|
199
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("--check flags Tailscale SSH off and Remote Login off", () => {
|
|
203
|
+
const fx = fixture();
|
|
204
|
+
const stubs = makeStubs(
|
|
205
|
+
fx.root,
|
|
206
|
+
["tailscale", "sudo", "systemsetup", "launchctl", "pmset", "defaults", "pgrep", "curl", "fdesetup", "sysadminctl"],
|
|
207
|
+
{ tailscale: '{"RunSSH": false}', systemsetup: "Remote Login: Off" },
|
|
208
|
+
);
|
|
209
|
+
try {
|
|
210
|
+
const r = run(fx, stubs, ["--check"]);
|
|
211
|
+
assert.match(r.stdout, /Tailscale SSH: off/i, `stdout:\n${r.stdout}`);
|
|
212
|
+
assert.match(r.stdout, /Remote Login: off/i, `stdout:\n${r.stdout}`);
|
|
213
|
+
assert.match(r.stdout, /--tailscale-ssh/, "must point the operator at the fix");
|
|
214
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// --- Tailscale variant (review: F4 on the GUI app) ---------------------------
|
|
218
|
+
//
|
|
219
|
+
// The Tailscale SSH server exists only in the open-source `tailscaled` variant.
|
|
220
|
+
// The fleet runs Tailscale.app (GUI), whose /usr/local/bin/tailscale is a
|
|
221
|
+
// 68-byte shim onto /Applications/Tailscale.app/Contents/MacOS/tailscale and
|
|
222
|
+
// whose daemon cannot honour RunSSH. `--tailscale-ssh` must say so and print
|
|
223
|
+
// the real remedy instead of `tailscale up --ssh`.
|
|
224
|
+
|
|
225
|
+
function guiShim(fx) {
|
|
226
|
+
// Same shape as the real shim: a two-line sh script naming Tailscale.app.
|
|
227
|
+
const shim = join(fx.root, "gui-tailscale");
|
|
228
|
+
writeFileSync(shim, '#!/bin/sh\n/Applications/Tailscale.app/Contents/MacOS/tailscale "$@"\n');
|
|
229
|
+
chmodSync(shim, 0o755);
|
|
230
|
+
return shim;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
test("tailscale_variant: GUI shim / Tailscale.app path → gui; tailscaled on PATH → open-source; else unknown", () => {
|
|
234
|
+
const fx = fixture();
|
|
235
|
+
const stubs = makeStubs(fx.root, ["tailscale", "launchctl"]);
|
|
236
|
+
try {
|
|
237
|
+
const shim = guiShim(fx);
|
|
238
|
+
assert.equal(runFn(fx, stubs, `tailscale_variant "${shim}"`).stdout.trim(), "gui");
|
|
239
|
+
assert.equal(runFn(fx, stubs, 'tailscale_variant "/Applications/Tailscale.app/Contents/MacOS/Tailscale"').stdout.trim(), "gui");
|
|
240
|
+
assert.equal(runFn(fx, stubs, `tailscale_variant "${join(stubs.bin, "tailscale")}"`).stdout.trim(), "unknown");
|
|
241
|
+
// With a tailscaled next to it, the CLI is the open-source variant.
|
|
242
|
+
writeFileSync(join(stubs.bin, "tailscaled"), "#!/bin/bash\nexit 0\n"); chmodSync(join(stubs.bin, "tailscaled"), 0o755);
|
|
243
|
+
assert.equal(runFn(fx, stubs, `tailscale_variant "${join(stubs.bin, "tailscale")}"`).stdout.trim(), "open-source");
|
|
244
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("--tailscale-ssh on the GUI app: no `tailscale set --ssh`, the real remedy is printed, Remote Login is still enabled", () => {
|
|
248
|
+
const fx = fixture();
|
|
249
|
+
const stubs = makeStubs(fx.root, ["tailscale", "sudo", "systemsetup", "launchctl"], { tailscale: "100.95.116.68" });
|
|
250
|
+
try {
|
|
251
|
+
const r = run(fx, stubs, ["--tailscale-ssh"], { MAESTRO_TAILSCALE_BIN: guiShim(fx) });
|
|
252
|
+
const c = calls(stubs);
|
|
253
|
+
assert.ok(!/tailscale (set|up) --ssh/.test(c), `must not try to enable SSH on the GUI daemon; calls:\n${c}`);
|
|
254
|
+
assert.match(r.stdout, /GUI|Tailscale\.app/i, "must name the variant");
|
|
255
|
+
assert.match(r.stdout, /brew install tailscale/, "must print the open-source remedy");
|
|
256
|
+
assert.match(r.stdout, /tailscaled/, "must name the daemon that carries the SSH server");
|
|
257
|
+
assert.match(r.stdout, /Remote Login|ssh .*@100\.95\.116\.68/, "must offer the sshd-over-tailnet-IP fallback");
|
|
258
|
+
assert.ok(!/is the node up and signed in/.test(r.stdout), "the misleading 'is the node up? try tailscale up --ssh' hint must be gone");
|
|
259
|
+
assert.match(c, /^systemsetup -setremotelogin on$/m, "Remote Login is the fallback access path and must still be enabled");
|
|
260
|
+
assert.equal(r.status, 0, "an honest limitation is not a script failure");
|
|
261
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test("--check on the GUI app reports Tailscale SSH as unavailable (not a fail-forever 'off') when Remote Login is on", () => {
|
|
265
|
+
const fx = fixture();
|
|
266
|
+
const stubs = makeStubs(
|
|
267
|
+
fx.root,
|
|
268
|
+
["tailscale", "sudo", "systemsetup", "launchctl", "pmset", "defaults", "pgrep", "curl", "fdesetup", "sysadminctl"],
|
|
269
|
+
{ tailscale: '{"RunSSH": false}', systemsetup: "Remote Login: On" },
|
|
270
|
+
);
|
|
271
|
+
try {
|
|
272
|
+
const r = run(fx, stubs, ["--check"], { MAESTRO_TAILSCALE_BIN: guiShim(fx) });
|
|
273
|
+
assert.match(r.stdout, /Tailscale SSH: unavailable/i, `stdout:\n${r.stdout}`);
|
|
274
|
+
assert.match(r.stdout, /brew install tailscale/, "the check must carry the real remedy too");
|
|
275
|
+
assert.ok(!/Tailscale SSH: off/.test(r.stdout));
|
|
276
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// --- --check under sudo: launchctl must look in the user's gui domain ---------
|
|
280
|
+
|
|
281
|
+
test("gui_launchctl_list uses the caller's domain as a user and `launchctl asuser <uid>` under sudo", () => {
|
|
282
|
+
const fx = fixture();
|
|
283
|
+
const stubs = makeStubs(fx.root, ["launchctl"], { launchctl: "-\t0\tai.maestro.ivy-session" });
|
|
284
|
+
try {
|
|
285
|
+
// Not root: plain `launchctl list`.
|
|
286
|
+
const asUser = runFn(fx, stubs, "gui_launchctl_list");
|
|
287
|
+
assert.match(asUser.stdout, /ai\.maestro\.ivy-session/);
|
|
288
|
+
assert.match(calls(stubs), /^launchctl list$/m);
|
|
289
|
+
rmSync(stubs.log, { force: true });
|
|
290
|
+
// Root via sudo: `id -u` → 0, `id -u <SUDO_USER>` → 501. Stub `id` so the
|
|
291
|
+
// test never needs real root.
|
|
292
|
+
writeFileSync(join(stubs.bin, "id"), '#!/bin/bash\nif [ "$1" = "-u" ] && [ -n "$2" ]; then echo 501; else echo 0; fi\n');
|
|
293
|
+
chmodSync(join(stubs.bin, "id"), 0o755);
|
|
294
|
+
const asRoot = runFn(fx, stubs, "gui_launchctl_list", { SUDO_USER: "ivy" });
|
|
295
|
+
assert.match(asRoot.stdout, /ai\.maestro\.ivy-session/);
|
|
296
|
+
assert.match(calls(stubs), /^launchctl asuser 501 launchctl list$/m, `calls:\n${calls(stubs)}`);
|
|
297
|
+
} finally { rmSync(fx.root, { recursive: true, force: true }); }
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test("--check probes the session and daemon jobs through gui_launchctl_list (never a bare `launchctl list`)", () => {
|
|
301
|
+
const verify = scriptSrc.slice(scriptSrc.indexOf("verify_all()"), scriptSrc.indexOf("main()"));
|
|
302
|
+
assert.ok(!/(^|[^_])launchctl list/m.test(verify.replace(/gui_launchctl_list/g, "")),
|
|
303
|
+
"verify_all must go through gui_launchctl_list so `sudo … --check` sees gui/<uid> jobs");
|
|
304
|
+
const status = scriptSrc.slice(scriptSrc.indexOf("show_status()"), scriptSrc.indexOf("verify_all()"));
|
|
305
|
+
assert.ok(!/(^|[^_])launchctl list/m.test(status.replace(/gui_launchctl_list/g, "")), "same for show_status");
|
|
306
|
+
});
|
|
@@ -114,6 +114,67 @@ else
|
|
|
114
114
|
ok "jq $(jq --version 2>/dev/null)"
|
|
115
115
|
fi
|
|
116
116
|
|
|
117
|
+
# --- BEGIN maestro global-sdk check (kept testable; do not edit markers) ---
|
|
118
|
+
# Front-door session prerequisites (design §3.7 / audit F17): every Claude Code
|
|
119
|
+
# session on this machine — not just the daemon's children — must find
|
|
120
|
+
# `maestro` and `cohort-mcp` on PATH, so the SDK is installed GLOBALLY and kept
|
|
121
|
+
# at @latest. MAESTRO_SKIP_GLOBAL_INSTALL=1 verifies only (tests, air-gapped
|
|
122
|
+
# seats). A failed install is a warning: the agent-local copy still works.
|
|
123
|
+
# init-agent.test.mjs extracts and exercises this exact block.
|
|
124
|
+
SDK_PKG="@cohortapp/agent-sdk"
|
|
125
|
+
SDK_GLOBAL="$(npm ls -g "$SDK_PKG" --depth=0 2>/dev/null | grep -o "$SDK_PKG@[0-9][^[:space:]]*" | head -1 || true)"
|
|
126
|
+
SDK_GLOBAL_VER="${SDK_GLOBAL#*@*@}"
|
|
127
|
+
SDK_WANT_INSTALL=""
|
|
128
|
+
if [ -z "$SDK_GLOBAL" ]; then
|
|
129
|
+
SDK_WANT_INSTALL="missing"
|
|
130
|
+
else
|
|
131
|
+
# Compare against npm latest; a failed `npm view` (offline) means "keep it".
|
|
132
|
+
# Bounded: an offline seat must not sit in npm's default retry/backoff for minutes.
|
|
133
|
+
SDK_LATEST="$(npm view "$SDK_PKG" version --fetch-timeout=15000 --fetch-retries=1 2>/dev/null || true)"
|
|
134
|
+
if [ -n "$SDK_LATEST" ] && [ "$SDK_GLOBAL_VER" != "$SDK_LATEST" ] \
|
|
135
|
+
&& [ "$(printf '%s\n%s\n' "$SDK_GLOBAL_VER" "$SDK_LATEST" | sort -V | tail -1)" = "$SDK_LATEST" ]; then
|
|
136
|
+
SDK_WANT_INSTALL="outdated ($SDK_GLOBAL_VER < $SDK_LATEST)"
|
|
137
|
+
fi
|
|
138
|
+
fi
|
|
139
|
+
if [ -z "$SDK_WANT_INSTALL" ]; then
|
|
140
|
+
ok "Global SDK: $SDK_GLOBAL (current)"
|
|
141
|
+
elif [ "${MAESTRO_SKIP_GLOBAL_INSTALL:-0}" = "1" ]; then
|
|
142
|
+
warn "Global SDK $SDK_WANT_INSTALL — MAESTRO_SKIP_GLOBAL_INSTALL=1, not running: npm install -g $SDK_PKG@latest"
|
|
143
|
+
else
|
|
144
|
+
log "Global SDK $SDK_WANT_INSTALL — installing: npm install -g $SDK_PKG@latest"
|
|
145
|
+
if npm install -g "$SDK_PKG@latest" >/dev/null 2>&1; then
|
|
146
|
+
ok "Global SDK installed ($SDK_PKG@latest)"
|
|
147
|
+
else
|
|
148
|
+
warn "npm install -g $SDK_PKG@latest failed — run it by hand (sudo may be needed for the global prefix)"
|
|
149
|
+
fi
|
|
150
|
+
fi
|
|
151
|
+
|
|
152
|
+
# A global install is only useful if its bins resolve from a bare session's
|
|
153
|
+
# PATH (design §3.7(6)): the `cohort` MCP server is registered by the bare name
|
|
154
|
+
# `cohort-mcp`, and the SessionStart primer calls `maestro`. An install into a
|
|
155
|
+
# prefix that launchd/zsh never see (an nvm shim, a custom prefix) passes
|
|
156
|
+
# `npm ls -g` and still ENOENTs at session start.
|
|
157
|
+
SDK_GLOBAL_BIN="$(npm prefix -g 2>/dev/null)/bin"
|
|
158
|
+
for sdk_bin in maestro cohort-mcp; do
|
|
159
|
+
if command -v "$sdk_bin" >/dev/null 2>&1; then
|
|
160
|
+
ok "$sdk_bin on PATH: $(command -v "$sdk_bin")"
|
|
161
|
+
else
|
|
162
|
+
warn "$sdk_bin not on PATH — add the global npm bin dir ($SDK_GLOBAL_BIN) to PATH in ~/.zprofile so every session finds it"
|
|
163
|
+
fi
|
|
164
|
+
done
|
|
165
|
+
|
|
166
|
+
# Terminal multiplexer for the front-door session supervisor: tmux when
|
|
167
|
+
# present, else /usr/bin/screen (ships with macOS). Neither is fatal — the
|
|
168
|
+
# supervisor reports it — but say what to install.
|
|
169
|
+
if command -v tmux >/dev/null 2>&1; then
|
|
170
|
+
ok "Multiplexer: tmux ($(tmux -V 2>/dev/null))"
|
|
171
|
+
elif [ -x "${MAESTRO_SCREEN_BIN:-/usr/bin/screen}" ]; then
|
|
172
|
+
ok "Multiplexer: screen (${MAESTRO_SCREEN_BIN:-/usr/bin/screen})"
|
|
173
|
+
else
|
|
174
|
+
warn "No terminal multiplexer found — the front-door session needs one: brew install tmux"
|
|
175
|
+
fi
|
|
176
|
+
# --- END maestro global-sdk check ---
|
|
177
|
+
|
|
117
178
|
echo ""
|
|
118
179
|
|
|
119
180
|
# ---------------------------------------------------------------------------
|
|
@@ -253,6 +314,8 @@ DIRS=(
|
|
|
253
314
|
"state/indexes"
|
|
254
315
|
"state/rag"
|
|
255
316
|
"state/sessions"
|
|
317
|
+
"state/session"
|
|
318
|
+
"state/session/handoffs/done"
|
|
256
319
|
"state/slack-responded"
|
|
257
320
|
"state/slack-thread-tracker"
|
|
258
321
|
"state/tmp"
|
|
@@ -270,6 +333,7 @@ DIRS=(
|
|
|
270
333
|
"logs/evolution"
|
|
271
334
|
"logs/huddle"
|
|
272
335
|
"logs/daemon"
|
|
336
|
+
"logs/session"
|
|
273
337
|
"logs/infra"
|
|
274
338
|
"logs/monitor"
|
|
275
339
|
"logs/phone"
|
|
@@ -444,24 +508,65 @@ else
|
|
|
444
508
|
warn "Plist generator not found at $PLIST_GENERATOR — using existing plists"
|
|
445
509
|
fi
|
|
446
510
|
|
|
511
|
+
# --- BEGIN maestro launchd install (kept testable; do not edit markers) ---
|
|
512
|
+
# Re-running init-agent must never kill the live front-door session or the
|
|
513
|
+
# daemon: `launchctl unload` SIGTERMs the supervisor, the multiplexer and the
|
|
514
|
+
# interactive session mid-turn (in-flight work and unacked handoffs are lost),
|
|
515
|
+
# and `maestro session status` itself points operators at this command. So
|
|
516
|
+
# the -session and -daemon labels are only REWRITTEN when loaded and loaded
|
|
517
|
+
# only when they are not (the WP-M6 reconcile rule: never bootout). Every
|
|
518
|
+
# other job keeps today's unload + load — its script may have changed and a
|
|
519
|
+
# trigger has no state to lose. init-agent.test.mjs extracts this block.
|
|
447
520
|
if [ -d "$PLIST_DIR" ] && ls "$PLIST_DIR"/*.plist &>/dev/null; then
|
|
448
521
|
for plist in "$PLIST_DIR"/*.plist; do
|
|
449
522
|
PLIST_NAME=$(basename "$plist")
|
|
450
523
|
LABEL=$(basename "$plist" .plist)
|
|
451
524
|
DST="$LAUNCH_AGENTS_DIR/$PLIST_NAME"
|
|
452
525
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
526
|
+
case "$LABEL" in
|
|
527
|
+
*-session)
|
|
528
|
+
# The supervisor ships with the SDK (WP-M1). A KeepAlive plist
|
|
529
|
+
# whose program is missing makes launchd retry every 30 s into
|
|
530
|
+
# logs/session/launchd-stderr.log forever — do not install it.
|
|
531
|
+
if [ ! -f "$AGENT_DIR/scripts/session/supervisor.sh" ]; then
|
|
532
|
+
warn "Skipped $LABEL — scripts/session/supervisor.sh is not present (upgrade the SDK, then re-run)"
|
|
533
|
+
continue
|
|
534
|
+
fi
|
|
535
|
+
;;
|
|
536
|
+
esac
|
|
537
|
+
|
|
538
|
+
case "$LABEL" in
|
|
539
|
+
*-session|*-daemon)
|
|
540
|
+
cp "$plist" "$DST"
|
|
541
|
+
chmod 600 "$DST"
|
|
542
|
+
if launchctl list "$LABEL" >/dev/null 2>&1; then
|
|
543
|
+
ok "Updated (kept running): $LABEL — launchd keeps the loaded definition; reload when convenient: launchctl bootout gui/$(id -u)/$LABEL && launchctl bootstrap gui/$(id -u) $DST"
|
|
544
|
+
else
|
|
545
|
+
launchctl load "$DST"
|
|
546
|
+
ok "Loaded: $LABEL"
|
|
547
|
+
fi
|
|
548
|
+
;;
|
|
549
|
+
*)
|
|
550
|
+
# Unload if already loaded, then copy and load
|
|
551
|
+
launchctl unload "$DST" 2>/dev/null || true
|
|
552
|
+
cp "$plist" "$DST"
|
|
553
|
+
launchctl load "$DST"
|
|
554
|
+
ok "Loaded: $LABEL"
|
|
555
|
+
;;
|
|
556
|
+
esac
|
|
460
557
|
done
|
|
461
558
|
else
|
|
462
559
|
warn "No plist files found in $PLIST_DIR — skipping launchd setup"
|
|
463
560
|
fi
|
|
464
561
|
|
|
562
|
+
# Audit F6 follow-through: a poller plist installed by an older install.sh
|
|
563
|
+
# carries SLACK_USER_TOKEN inline at mode 644. Nothing else ever rewrites it,
|
|
564
|
+
# so the migration runs here (and after every autoupdate). No-op when clean.
|
|
565
|
+
if [ -f "$AGENT_DIR/scripts/poller-launchd/migrate.sh" ]; then
|
|
566
|
+
bash "$AGENT_DIR/scripts/poller-launchd/migrate.sh" || warn "poller plist migration reported a problem (see above)"
|
|
567
|
+
fi
|
|
568
|
+
# --- END maestro launchd install ---
|
|
569
|
+
|
|
465
570
|
echo ""
|
|
466
571
|
|
|
467
572
|
# ---------------------------------------------------------------------------
|