@phnx-labs/agents-cli 1.20.43 → 1.20.45
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/CHANGELOG.md +18 -0
- package/README.md +4 -3
- package/dist/commands/exec.js +84 -13
- package/dist/commands/hosts.js +5 -4
- package/dist/commands/logs.d.ts +4 -0
- package/dist/commands/logs.js +19 -13
- package/dist/commands/routines.d.ts +6 -0
- package/dist/commands/routines.js +70 -12
- package/dist/commands/secrets.d.ts +18 -0
- package/dist/commands/secrets.js +105 -30
- package/dist/commands/sessions.d.ts +6 -5
- package/dist/commands/sessions.js +50 -22
- package/dist/commands/teams.js +104 -8
- package/dist/lib/daemon.js +34 -9
- package/dist/lib/exec.d.ts +8 -0
- package/dist/lib/exec.js +70 -6
- package/dist/lib/hosts/dispatch.d.ts +29 -0
- package/dist/lib/hosts/dispatch.js +46 -1
- package/dist/lib/hosts/logs.d.ts +14 -5
- package/dist/lib/hosts/logs.js +39 -13
- package/dist/lib/hosts/remote-cmd.d.ts +17 -0
- package/dist/lib/hosts/remote-cmd.js +27 -0
- package/dist/lib/hosts/session-index.d.ts +15 -0
- package/dist/lib/hosts/session-index.js +28 -2
- package/dist/lib/redact.js +1 -0
- package/dist/lib/rotate.d.ts +33 -0
- package/dist/lib/rotate.js +37 -0
- package/dist/lib/secrets/remote.d.ts +14 -0
- package/dist/lib/secrets/remote.js +18 -1
- package/dist/lib/session/active.d.ts +10 -0
- package/dist/lib/session/active.js +12 -1
- package/dist/lib/session/db.d.ts +16 -9
- package/dist/lib/session/db.js +66 -44
- package/dist/lib/session/discover.d.ts +4 -0
- package/dist/lib/session/discover.js +84 -13
- package/dist/lib/session/run-names.d.ts +9 -7
- package/dist/lib/session/run-names.js +9 -7
- package/dist/lib/session/state.d.ts +29 -3
- package/dist/lib/session/state.js +84 -5
- package/dist/lib/session/types.d.ts +19 -8
- package/dist/lib/shims.d.ts +1 -1
- package/dist/lib/shims.js +17 -3
- package/dist/lib/teams/agents.js +25 -7
- package/dist/lib/tmux/session.d.ts +40 -0
- package/dist/lib/tmux/session.js +92 -0
- package/dist/lib/versions.d.ts +54 -1
- package/dist/lib/versions.js +138 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.20.45
|
|
6
|
+
|
|
7
|
+
- **NEW: `agents run <agent> --host <name>` without a prompt forwards your TTY over SSH and runs the agent interactively on the remote host.** Previously `--host` runs required a prompt and were always headless (`agents run <agent> "<task>" --host <name>`). Now, omitting the prompt takes the interactive path: when local stdin is a TTY, the local CLI SSHes with `-tt`, runs `agents run <agent>` on the host, and lets the remote machine's `agents` start its normal tmux wrapper. The tmux session lives on the remote box, so detaching (`Ctrl-b d`) ends the SSH connection but keeps the agent running; you can reattach from the host or resume by session id. Session ids for Claude are still minted up front so `agents sessions` can surface and resolve the remote run. `--no-follow` is rejected for interactive host runs (it is meaningless for an attached TTY), and `--mode`, `--model`, `--name`, passthrough args after `--`, and `--raw`/`--no-tmux` are forwarded to the remote invocation. Source: `apps/cli/src/commands/exec.ts`, `apps/cli/src/lib/hosts/dispatch.ts`, `apps/cli/src/lib/hosts/session-index.ts`, `apps/cli/docs/hosts.md`.
|
|
8
|
+
|
|
9
|
+
- **`agents secrets export --host` now works against Windows targets, and a new `agents secrets unlock --host` unlocks a bundle on a remote machine.** The export push was POSIX-only (`bash -lc`, `--from /dev/stdin`, `create … || true`, `IFS= read`), so a Windows remote died with `'true' is not recognized … cannot find the path specified`. Two changes fix it: `agents secrets import` now accepts **`--from -`** (read the `.env` from stdin, replacing the POSIX-only `/dev/stdin`), and the push is **platform-aware** — `bash -lc` on POSIX, `powershell -EncodedCommand` on Windows, with the target's OS taken from the device registry. Because the npm `agents.ps1` shim does **not** forward ssh-piped stdin to the underlying node process (a raw `--from -` read hangs), the Windows keychain push bridges the piped `.env` through PowerShell into a temp file and imports `--from <file>` (deleted afterwards). File-backend export to a Windows target is refused cleanly rather than emitting broken PowerShell. Verified end-to-end: `agents secrets export linear.app --host win-mini` imported all 13 keys. Separately, **`agents secrets unlock --host <machine> <bundle>`** runs the unlock ON the remote over `ssh -tt`, so a **file-backed** bundle's passphrase prompt surfaces on your terminal — the "unlock the Mac from the road with its password" path; keychain/biometry bundles are GUI-only (a local Touch-ID/passcode sheet can't cross SSH) and can't be remote-unlocked. `unlock`'s `--host` is single-valued so it never swallows the positional bundle name. Source: `apps/cli/src/commands/secrets.ts`, `apps/cli/src/lib/hosts/remote-cmd.ts`.
|
|
10
|
+
- **A session now has ONE name, not two. `--name` seeds the session label instead of a parallel column.** Shipping `agents run --name` (1.20.43) as a separate immutable `name` column created two look-alike fields — an unshown, frozen `name` and the shown, searchable `label` — that both resolved `agents sessions <ref>` and forced tie-break bookkeeping nobody could keep straight. They unify into one field. `--name` is now the universal way to *seed* the `label` at launch — the same field an agent-generated title (Claude's `/rename`) later refines and `agents sessions` displays and searches — and it works consistently across interactive, headless, `--host`, and teams teammate runs (a teammate's friendly name now seeds its session label; before, teammate sessions had no name at all). Priority is a plain fallback chain resolved at scan time, no stored winner: an agent-generated title wins, else the `--name` seed, else the listing falls back to `topic`. So a Claude run's `--name` shows until Claude titles it (your seed, then refined); a non-Claude run keeps its `--name` as the label (it has no auto-title). The seeded name is now fuzzy-searchable in FTS (the old `name` column was not). `agents hosts logs <name>` is unchanged — it resolves against the host-task sidecar, not the session column. Schema v10 folds any existing `name` into `label` (where the label was empty), mirrors it into the FTS row, then drops the `name` column; the run-name sidecars re-seed every scan (`seedLabelsFromNames`), so no rescan is needed. Reworks the 1.20.43 `--name` design (partly reverts its separate-column approach). Source: `apps/cli/src/lib/session/{db,discover,run-names,types}.ts`, `apps/cli/src/lib/hosts/session-index.ts`, `apps/cli/src/lib/teams/agents.ts`, `apps/cli/src/commands/exec.ts`, `apps/cli/docs/{05-sessions,hosts}.md`.
|
|
11
|
+
- **NEW: `agents teams add`/`start` warns when a *version-pinned* teammate is on a throttled or signed-out account.** The 1.20.43 `balanced`-default fix keeps *bare* teammates off rate-limited accounts (they route through bare `agents run`, which rotates), but a **version-pinned** (`claude@2.1.112`) or **profile** teammate spawns `agents run <agent>@<version>` / `agents run <profile>`, and a pin/profile deliberately *bypasses* rotation — so it would launch straight onto a maxed account and 429 on the first request, with no mid-run failover either (that only arms when a non-pinned strategy actually rotated). `agents teams add` (at add time) and `agents teams start` (per staged teammate, deduped by `agent@version`) now pre-check a **version-pinned** teammate's account and print an advisory when it's rate-limited, out of credits, or not signed in — reusing the router's *exact* eligibility gate (`checkRunAccountReadiness` → `hasUsageAvailable`, the same session-inclusive signal the `agents view` badge uses), so the warning can never disagree with what the spawn would actually do. It **warns, never blocks** (mirroring the existing "may not be signed in" advisory); `--force` silences it. Scoped to version-pinned teammates on purpose: bare teammates are already handled by rotation, and a profile injects its own auth (a different account than the version home carries) that isn't locally checkable — so no unreliable profile warning is emitted. Source: `apps/cli/src/lib/rotate.ts` (`readinessFromCandidate`, `checkRunAccountReadiness`, `rotate.test.ts`), `apps/cli/src/commands/teams.ts`.
|
|
12
|
+
|
|
13
|
+
## 1.20.44
|
|
14
|
+
- **Every `logs` command is concise by default; the token-heavy raw dump is now opt-in behind `--full`.** Agents that spin up agents on other machines or add teammates were pulling whole transcripts just to glance at status — `agents logs <session>` printed the full markdown transcript, and `agents hosts logs` / `agents teams logs` / `agents routines logs` each `cat`'d their entire captured stdout, because each subsystem had hand-rolled its own "cat the log" verb over its own storage. All four now default to a bounded, concise view, with `-m/--full` for the raw log: `agents logs <session>` renders the same summary digest as `agents sessions <id>` (a real session shrank 92% — 29.9 KB → 2.6 KB); `agents routines logs <name>` shows a status header + the extracted report (a real run shrank 99.5% — 386 KB → 1.8 KB), falling back to a bounded stdout tail when no report was extracted; `agents teams logs <teammate>` renders the teammate's session summary (its agentId **is** the session id), with `-n <lines>` / `--full` for raw stdout; `agents hosts logs <id>` shows a bounded tail of the captured stdout (`tailLines`, with a "… N earlier lines hidden — pass --full" note) instead of the whole log. `renderSessionLog` now takes a mode and defaults to `'summary'`; `agents sessions <id>` was already summary-by-default and is unchanged. Regression-tested: `tailLines` truncation/elision math (`hosts/logs.test.ts`) and `formatRunDuration` human-time formatting (`routines-logs.test.ts`). Source: `apps/cli/src/commands/{logs,sessions,hosts,teams,routines}.ts`, `apps/cli/src/lib/hosts/logs.ts`. Scoped follow-up (not in this PR): host-task and sandboxed-routine runs write their real transcript on the remote / in an overlay HOME, so `logs` can't yet resolve them to the full `renderSummary` — making those runs discoverable is a separate change; until then the bounded tail / extracted report is the safe concise default.
|
|
15
|
+
- **The daemon now self-heals the `pane-died` hook on already-running `agents run` sessions.** The v1.20.42 fix that stops exiting a split from kicking you out of tmux is installed once, at session creation — so sessions already alive under the long-lived shared tmux server keep the old, unconditional `detach-client` hook until they exit or the server is recycled. On a machine that's never "between sessions," that meant hand-repairing live sessions. The daemon now runs `reconcileSessionHooks()` ~20s after startup and every ~5 min: it walks the managed `ag-` sessions on the shared socket and retrofits the `#{hook_pane}`-guarded hook onto any whose hook predates the current schema. It is strictly **non-destructive — `set-hook` only, never a `kill-pane` or `detach-client`** — so it is safe to run against sessions you're attached to; a per-session `@ag_hook_schema` marker makes steady-state a no-op. The hook string is now built in one place (`agentPaneDiedHook`) shared by the spawn-wrap and the reconcile so they can't drift. Source: `apps/cli/src/lib/tmux/session.ts`, `apps/cli/src/lib/daemon.ts`, `apps/cli/src/lib/exec.ts`.
|
|
16
|
+
- **NEW: `agents run` self-heals a gutted install instead of crashing with `ENOENT`.** The recurring failure: an npm agent whose native binary ships as an optional per-arch dependency (codex → `@openai/codex-<platform>`) can have that tarball extract **partially** — the platform package's `package.json` lands, its `vendor/<triple>/…/codex` binary does not (an interrupted or concurrently-raced `agents add` into the same version dir). The CLI's wrapper `require.resolve`s the platform package, finds the `package.json`, and sails straight past its own "missing optional dependency" guard into a `spawn(binaryPath)` that dies with a raw `ENOENT`. `agents run` now probes the version it's about to launch and, if the binary can't run, **repairs it in place** (a *clean* reinstall — the partial `node_modules` is wiped first, because npm treats the present-but-gutted platform package as already installed and would otherwise skip re-fetching it), then falls back to another installed version that launches (re-pinning it as the default so the shim path heals too), then to installing `latest` — only erroring if nothing can be made runnable. `installVersion` gained a `{ clean }` option for the wipe-then-reinstall. Source: `apps/cli/src/lib/versions.ts` (`ensureAgentRunnable`), `apps/cli/src/commands/exec.ts`.
|
|
17
|
+
- **Fix: a broken agent install no longer launches into a silent `[detached]` — the real crash is surfaced.** When an interactive `ag run <agent>` wrapped the agent in tmux and the agent died the instant it spawned (e.g. a gutted install crashing with `spawn … ENOENT`, a bad flag, a startup crash), the `pane-died` hook detached the client before you could read anything — you got a bare `[detached (from session …)]` with zero indication of why. `runInTmux` now recaps the dead pane's last output (read from scrollback via `capture-pane -S -200`, since the pane's visible screen is just the "Pane is dead" banner) plus the exit code to stderr, and points you at `--no-tmux`. Fast failures (dead before attach) always recap; a post-attach nonzero exit recaps too (a clean exit or a manual detach stays quiet). Source: `apps/cli/src/lib/exec.ts`, `apps/cli/src/lib/tmux/session.test.ts`.
|
|
18
|
+
- **NEW: `--no-tmux` / `--disable-tmux` on `agents run`.** The interactive tmux wrapper (which gives `%pane` addressing + re-attach) already had an opt-out, but it was hidden behind the opaquely-named `--raw`. `--no-tmux` (and its alias `--disable-tmux`) spawn the agent directly with full stdio inherited — the fastest way to see an agent's real startup output when a launch is failing. Same effect as `--raw` and `AGENTS_NO_TMUX=1`. Source: `apps/cli/src/commands/exec.ts`.
|
|
19
|
+
- **Fix: `agents add <agent>@<version>` no longer records a gutted install as healthy (root cause of the ENOENT crash + a broken default pin).** npm packages that ship their native binary via an optional per-arch dependency (e.g. codex → `@openai/codex-<platform>`) can land the JS wrapper at `node_modules/.bin/<cli>` while the real platform binary is missing (interrupted install, omitted optional dep, `--ignore-scripts`). `getBinaryPath()` only checked the wrapper, so the broken version read as installed, got pinned as the default, and got picked to run — then died with ENOENT. `installVersion` now probes `<binary> --version` (under the version's isolated HOME) after install and **fails the install** if the binary can't launch, so a broken version is never silently pinned. The check is deliberately narrow — only the missing-binary signature (`ENOENT`/"no such file"/"command not found") fails it; a plain nonzero exit or a timeout is treated as healthy, so a well-behaved agent that dislikes `--version` is never false-failed. Source: `apps/cli/src/lib/versions.ts`, `apps/cli/src/lib/versions-integrity.test.ts`.
|
|
20
|
+
- **Security fix: the routines daemon log no longer leaks GitHub / AWS / npm tokens.** `daemon.ts` carried its own private `redactSecrets` (used by every `log()` write to `logs.jsonl`) that predated and diverged from the canonical `redact.ts` — it caught `sk-`, `eyJ…`, `Bearer …`, and a narrow `NAME=value` list, but **not** `ghp_` (GitHub PAT), `AKIA…` (AWS access key), or `npm_` (npm token), so any of those appearing in a daemon message (a git push URL, a bundle-env dump, an error string) was written to the log in the clear. The private copy is deleted; `log()` now routes through the canonical `redactSecrets` in `redact.ts`, which covers all of those classes with a stronger quote-aware `NAME=value` pattern. The one pattern the daemon copy had and the canonical lacked — `Bearer <token>` — is added to `redact.ts`, so the shared redactor (also used by session-transcript export in `session/render.ts`) is now a strict superset. New `redact.test.ts` pins every token class as a regression guard. Source: `apps/cli/src/lib/daemon.ts`, `apps/cli/src/lib/redact.ts`, `apps/cli/src/lib/redact.test.ts`.
|
|
21
|
+
- **Fix: `agents teams doctor` tells the truth, a version fallback never spawns an unspawnable literal, and shims survive a vanished dispatcher (completing this release's self-heal series).** Three gaps remained after the `agents run` self-heal above. (1) **`agents teams doctor` lied** — it reported `installed: true` whenever a *shim file* existed, never checking the real binary, so a stub or gutted-native install (the exact codex/kimi failure) showed "ready" and then `ENOENT`'d at spawn. `checkCliAvailable` now verifies the resolved default version is actually installed, and doctor additionally **launch-probes** each installed agent (`verifyInstalledBinaryLaunches`) and flips a gutted-native one to not-installed with a repair hint. (2) **A version fallback spawned an unspawnable literal** — when a specific version was requested (`agents run kimi@0.19.2`, the path every version-pinned teammate takes) and no versioned shim existed on disk, the launch left the bare `<agent>@<version>` name as `argv[0]`, which is not on PATH, so it died with `spawn kimi@0.19.2 ENOENT`; it now resolves the version's real binary (`getBinaryPath`) instead, falling back to the literal only when no binary exists at all. (3) **A shim couldn't survive its dispatcher vanishing** — when the baked `AGENTS_BIN` (often a dev build under `~/.local/agents-cli-dev`) was removed, moved, or went stale, the shim exited 127 and bricked *every* managed launch; it now **self-recovers** to whatever `agents` resolves to on PATH before erroring (`SHIM_SCHEMA_VERSION` → 25). Also drops a stale, npm-unrecoverable `codex 0.116.0` pin from the repo's own `agents.yaml` so codex resolves to the machine default instead of self-healing on every run. Source: `apps/cli/src/lib/{exec,shims}.ts`, `apps/cli/src/lib/teams/agents.ts`, `apps/cli/src/commands/teams.ts`, `agents.yaml`.
|
|
22
|
+
|
|
5
23
|
## 1.20.43
|
|
6
24
|
|
|
7
25
|
- **NEW: `agents run --name <slug>` — a durable, human/agent-friendly handle for any run.** An agent that dispatches another agent had no cheap status handle: the host-task id was never even printed (the `--no-follow` tip showed a literal `<id>` placeholder), and only Claude's session id is known up front (pre-minted `--session-id`) — every other agent's id is discovered later by scanning transcripts, so callers fell back to `agents logs`, which dumps the raw, token-heavy transcript. `--name` is chosen at launch, agent-agnostic, and stored on the structures that already back these views: a first-class `name` column on `sessions.db` (schema v9, additive, no rescan) parallel to `label` — `agents sessions <ref>` resolves against **both** name and label; the HostTask sidecar (forwarded to the remote run, so `agents hosts ps` gains a NAME column and `agents hosts logs <name>` resolves by name); and a run-name sidecar (`~/.agents/.cache/run-names/`) that joins a local run's name onto the index by id every scan via `syncNames` — the same idempotent pattern as `/rename` label sync. The `name` column is deliberately left out of the upsert `ON CONFLICT … SET` clause, so a discovery rescan can never null an existing name (regression-tested in `db.names.test.ts`). Omitting `--name` is a strict no-op: `name` stays unset and every id-based path is unchanged. The `--no-follow` dispatch tip now prints the real handle and steers to the compact `agents sessions` digest over the raw log. Source: `apps/cli/src/commands/exec.ts`, `apps/cli/src/lib/session/{db,run-names,discover}.ts`, `apps/cli/src/lib/hosts/{dispatch,tasks}.ts`.
|
package/README.md
CHANGED
|
@@ -243,7 +243,8 @@ agents hosts check gpu-box # reachable? which agents-cli version?
|
|
|
243
243
|
|
|
244
244
|
# Run there instead of locally
|
|
245
245
|
agents run claude --host gpu-box "profile this build" # follows live by default
|
|
246
|
-
agents logs --host gpu-box # pick a dispatched run
|
|
246
|
+
agents logs --host gpu-box # pick a dispatched run — concise summary by default
|
|
247
|
+
agents logs <id> --full # the full raw transcript / stdout (token-heavy)
|
|
247
248
|
agents logs <id> -f # re-attach to a running one and follow
|
|
248
249
|
agents view claude --host gpu-box # inspect the remote install
|
|
249
250
|
agents sync --host gpu-box # make the remote machine current
|
|
@@ -274,7 +275,7 @@ agents teams start auth-feature # Fires teammates whose deps are done
|
|
|
274
275
|
agents teams status auth-feature # Who's working, what they changed, what they said
|
|
275
276
|
```
|
|
276
277
|
|
|
277
|
-
Teammates run detached -- close your terminal, they keep working. Check in with `teams status`,
|
|
278
|
+
Teammates run detached -- close your terminal, they keep working. Check in with `teams status`, glance at a teammate's summary with `teams logs <name>` (add `--full` for the raw output), clean up with `teams disband`.
|
|
278
279
|
|
|
279
280
|
Team state is observable via `agents teams list --json` / `agents teams status --json` (compact by default; add `--verbose` for the full per-teammate shape). External tools join it with `sessions --json` (teammates get `isTeamOrigin: true`) and `cloud list --json` (for `--cloud` teammates) to build a unified fleet view. See [docs/06-observability.md](docs/06-observability.md).
|
|
280
281
|
|
|
@@ -534,7 +535,7 @@ agents routines add daily-digest \
|
|
|
534
535
|
|
|
535
536
|
agents routines list # All jobs + next run times
|
|
536
537
|
agents routines run daily-digest # Test it now, ignore the schedule
|
|
537
|
-
agents routines logs daily-digest #
|
|
538
|
+
agents routines logs daily-digest # Last execution — status + report (add --full for raw stdout)
|
|
538
539
|
```
|
|
539
540
|
|
|
540
541
|
Jobs run sandboxed -- agents only see directories and tools you explicitly allow.
|
package/dist/commands/exec.js
CHANGED
|
@@ -218,9 +218,11 @@ export function registerRunCommand(program) {
|
|
|
218
218
|
.option('-i, --interactive', 'Force interactive mode even when a prompt is provided. Mutually exclusive with --headless.')
|
|
219
219
|
.option('--resume [id]', 'Resume a previous conversation. Accepts a full or partial session id (prefix-matched against the index); omit the id to pick from recent sessions interactively. Resumes under the version that started the session. claude/codex resume natively; other agents replay via a /continue first message. Pair with a prompt to continue headlessly.')
|
|
220
220
|
.option('--session-id <id>', 'Force a NEW conversation to use this exact session UUID (Claude only). This CREATES a session — to resume an existing one, use --resume.')
|
|
221
|
-
.option('--name <slug>', '
|
|
221
|
+
.option('--name <slug>', 'Name the run — seeds the session label so it shows up as `<name>` in `agents sessions` and resolves by it (and `agents hosts logs <name>` for --host runs) instead of an opaque id. An agent-generated title later refines the label; your name shows until then. Optional.')
|
|
222
222
|
.option('--verbose', 'Show detailed execution logs')
|
|
223
223
|
.option('--raw', 'Interactive runs on macOS/Linux launch inside a shared tmux session (for %pane addressing + re-attach). Pass --raw to spawn the agent directly instead. Also disabled by AGENTS_NO_TMUX=1.')
|
|
224
|
+
.option('--no-tmux', 'Spawn the agent directly instead of wrapping it in the shared tmux session. Same effect as --raw / AGENTS_NO_TMUX=1. Use this to see the agent\'s full startup output when a launch is failing.')
|
|
225
|
+
.option('--disable-tmux', 'Alias for --no-tmux.')
|
|
224
226
|
.option('--timeout <duration>', 'Kill the agent after this duration (e.g., 30m, 1h, 2h30m)')
|
|
225
227
|
.option('--fallback <agents>', 'Comma-separated agents to try on rate-limit failure. Each entry accepts an optional @version pin (e.g., codex@0.116.0,gemini). The primary runs first; if it exits with a rate-limit error, the next agent picks up via /continue handoff.')
|
|
226
228
|
.option('-b, --balanced', 'Shortcut for --strategy balanced. Ignored when @version is pinned.')
|
|
@@ -357,13 +359,9 @@ export function registerRunCommand(program) {
|
|
|
357
359
|
process.exit(1);
|
|
358
360
|
}
|
|
359
361
|
const hostName = hostGiven[0];
|
|
360
|
-
if (prompt === undefined) {
|
|
361
|
-
console.error(chalk.red('A prompt is required for host runs: agents run <agent> "<task>" --host <name>'));
|
|
362
|
-
process.exit(1);
|
|
363
|
-
}
|
|
364
362
|
const { resolveHost, resolveHostByCap } = await import('../lib/hosts/registry.js');
|
|
365
|
-
const { dispatchToHost } = await import('../lib/hosts/dispatch.js');
|
|
366
|
-
const { registerHostSession } = await import('../lib/hosts/session-index.js');
|
|
363
|
+
const { dispatchToHost, runInteractiveOnHost } = await import('../lib/hosts/dispatch.js');
|
|
364
|
+
const { registerHostSession, registerInteractiveHostSession } = await import('../lib/hosts/session-index.js');
|
|
367
365
|
// A password-auth device throws DeviceOffloadUnsupportedError here; it's
|
|
368
366
|
// printed cleanly by the top-level catch in index.ts (covers every
|
|
369
367
|
// resolveHost caller), so it never falls through to capability routing.
|
|
@@ -394,10 +392,57 @@ export function registerRunCommand(program) {
|
|
|
394
392
|
// which can't run over a detached remote dispatch — only forward a
|
|
395
393
|
// concrete id.
|
|
396
394
|
const resumeId = typeof options.resume === 'string' ? options.resume : undefined;
|
|
397
|
-
//
|
|
398
|
-
//
|
|
399
|
-
//
|
|
400
|
-
//
|
|
395
|
+
// Decide whether this host run is interactive. No prompt always means
|
|
396
|
+
// interactive (matching local resolveInteractive); --interactive forces
|
|
397
|
+
// interactive even when a prompt is provided; --headless forces headless
|
|
398
|
+
// and therefore requires a prompt.
|
|
399
|
+
if (options.interactive && options.headless) {
|
|
400
|
+
console.error(chalk.red('--interactive and --headless are mutually exclusive. Pass one, or neither (mode is inferred from prompt presence).'));
|
|
401
|
+
process.exit(1);
|
|
402
|
+
}
|
|
403
|
+
const interactiveHost = options.interactive === true || (prompt === undefined && options.headless !== true);
|
|
404
|
+
if (interactiveHost) {
|
|
405
|
+
// Interactive host run: forward the local TTY over SSH and let the
|
|
406
|
+
// remote agent start its normal interactive UI (tmux on the host).
|
|
407
|
+
if (options.follow === false) {
|
|
408
|
+
console.error(chalk.red('--no-follow is not compatible with interactive host runs. Interactive runs are attached by definition.'));
|
|
409
|
+
process.exit(1);
|
|
410
|
+
}
|
|
411
|
+
// Mirror the local path (lib/exec.ts): only Claude accepts a forced
|
|
412
|
+
// `--session-id`. Generating it here lets us register the run in the
|
|
413
|
+
// local index and makes it resumable by id. On resume the remote
|
|
414
|
+
// session keeps its existing id — don't mint a new one.
|
|
415
|
+
const hostSessionId = runAgent === 'claude' && !resumeId ? randomUUID() : undefined;
|
|
416
|
+
if (hostSessionId) {
|
|
417
|
+
registerInteractiveHostSession({
|
|
418
|
+
cwd: process.cwd(),
|
|
419
|
+
host: host.name,
|
|
420
|
+
agent: runAgent,
|
|
421
|
+
sessionId: hostSessionId,
|
|
422
|
+
name: options.name,
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
const exitCode = await runInteractiveOnHost(host, {
|
|
426
|
+
agent: runAgent,
|
|
427
|
+
prompt,
|
|
428
|
+
mode: options.mode,
|
|
429
|
+
model: options.model,
|
|
430
|
+
remoteCwd: options.remoteCwd,
|
|
431
|
+
sessionId: hostSessionId,
|
|
432
|
+
name: options.name,
|
|
433
|
+
resume: resumeId,
|
|
434
|
+
passthroughArgs,
|
|
435
|
+
raw: options.raw || options.tmux === false || options.disableTmux === true,
|
|
436
|
+
forceInteractive: options.interactive,
|
|
437
|
+
});
|
|
438
|
+
process.exit(exitCode);
|
|
439
|
+
}
|
|
440
|
+
// Headless host run: launch detached, tail the remote log, and follow
|
|
441
|
+
// until the remote process exits.
|
|
442
|
+
if (prompt === undefined) {
|
|
443
|
+
console.error(chalk.red('A prompt is required for headless host runs: agents run <agent> "<task>" --host <name>'));
|
|
444
|
+
process.exit(1);
|
|
445
|
+
}
|
|
401
446
|
const hostSessionId = runAgent === 'claude' && !resumeId ? randomUUID() : undefined;
|
|
402
447
|
const { task, exitCode } = await dispatchToHost(host, {
|
|
403
448
|
agent: runAgent,
|
|
@@ -525,7 +570,7 @@ export function registerRunCommand(program) {
|
|
|
525
570
|
});
|
|
526
571
|
process.exit(resumeExit);
|
|
527
572
|
}
|
|
528
|
-
const [{ buildExecCommand, parseExecEnv, execAgent, runWithFallback, normalizeMode, resolveMode, defaultModeFor, headlessPlanStallCommand, nativeResume, resolveInteractive }, { ALL_AGENT_IDS }, { profileExists, resolveProfileForRun }, { readAndResolveBundleEnv, describeBundle, assertRemoteBundleFlagsUnsupported }, { splitBundleRef, resolveSshTarget, remoteResolveEnv }, { getConfiguredRunStrategy, normalizeRunStrategy, resolveRunVersion, rotationFailoverChain, shouldArmRotationFailover, RUN_STRATEGIES }, { getGlobalDefault, getVersionHomePath, resolveVersion, resolveVersionAlias }, { buildDiscoveredPlugin, loadPluginManifest, syncPluginToVersion }, { parseWorkflowFrontmatter, resolveWorkflowRef, resolveAllowedSubagents, pruneStaleWorkflowSubagents }, { resolveRunDefaults }, { getMcpServersByName, buildWorkflowMcpConfig }, { supports },] = await Promise.all([
|
|
573
|
+
const [{ buildExecCommand, parseExecEnv, execAgent, runWithFallback, normalizeMode, resolveMode, defaultModeFor, headlessPlanStallCommand, nativeResume, resolveInteractive }, { ALL_AGENT_IDS }, { profileExists, resolveProfileForRun }, { readAndResolveBundleEnv, describeBundle, assertRemoteBundleFlagsUnsupported }, { splitBundleRef, resolveSshTarget, remoteResolveEnv }, { getConfiguredRunStrategy, normalizeRunStrategy, resolveRunVersion, rotationFailoverChain, shouldArmRotationFailover, RUN_STRATEGIES }, { getGlobalDefault, getVersionHomePath, resolveVersion, resolveVersionAlias, ensureAgentRunnable }, { buildDiscoveredPlugin, loadPluginManifest, syncPluginToVersion }, { parseWorkflowFrontmatter, resolveWorkflowRef, resolveAllowedSubagents, pruneStaleWorkflowSubagents }, { resolveRunDefaults }, { getMcpServersByName, buildWorkflowMcpConfig }, { supports },] = await Promise.all([
|
|
529
574
|
import('../lib/exec.js'),
|
|
530
575
|
import('../lib/agents.js'),
|
|
531
576
|
import('../lib/profiles.js'),
|
|
@@ -933,6 +978,29 @@ export function registerRunCommand(program) {
|
|
|
933
978
|
}
|
|
934
979
|
}
|
|
935
980
|
}
|
|
981
|
+
// Self-heal the launch target. A gutted install (JS wrapper present,
|
|
982
|
+
// native binary missing — a partial/raced npm extraction of the optional
|
|
983
|
+
// per-arch dependency) would otherwise spawn and die with a raw ENOENT
|
|
984
|
+
// inside the agent's own wrapper. Repair it in place (or fall back to a
|
|
985
|
+
// runnable version, re-pinning it) BEFORE we build the launch command.
|
|
986
|
+
// Skipped for headless resume-native/acp/loop paths only if it errored;
|
|
987
|
+
// here it runs for every normal dispatch. Best-effort log to stderr.
|
|
988
|
+
{
|
|
989
|
+
const launchTarget = version ?? resolveVersion(agent, cwd) ?? undefined;
|
|
990
|
+
if (launchTarget) {
|
|
991
|
+
const healed = await ensureAgentRunnable(agent, launchTarget, options.quiet ? undefined : (m) => process.stderr.write(chalk.yellow(`[agents] ${m}\n`)));
|
|
992
|
+
if (healed === null) {
|
|
993
|
+
console.error(chalk.red(`agents: ${agent}@${launchTarget} is not runnable and could not be repaired. Try: agents add ${agent}@latest`));
|
|
994
|
+
process.exit(1);
|
|
995
|
+
}
|
|
996
|
+
// Always adopt the healed version explicitly. In the version-undefined
|
|
997
|
+
// path a fallback re-pins the GLOBAL default, but `resolveVersion`
|
|
998
|
+
// prefers a PROJECT pin — so leaving `version` undefined would let the
|
|
999
|
+
// shim re-resolve the still-broken project pin and crash anyway. Pinning
|
|
1000
|
+
// the runnable version here is a no-op when nothing changed.
|
|
1001
|
+
version = healed;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
936
1004
|
const defaultVersion = version ?? resolveVersion(agent, cwd);
|
|
937
1005
|
const runDefaults = fromProfile
|
|
938
1006
|
? { sources: {} }
|
|
@@ -1074,7 +1142,10 @@ export function registerRunCommand(program) {
|
|
|
1074
1142
|
name: options.name,
|
|
1075
1143
|
resume: resumeNative,
|
|
1076
1144
|
verbose: options.verbose,
|
|
1077
|
-
raw
|
|
1145
|
+
// --raw, --no-tmux (commander negation → options.tmux === false), and
|
|
1146
|
+
// --disable-tmux all bypass the interactive tmux wrapper. AGENTS_NO_TMUX=1
|
|
1147
|
+
// does the same via the env check in exec.ts.
|
|
1148
|
+
raw: options.raw || options.tmux === false || options.disableTmux === true,
|
|
1078
1149
|
timeout: options.timeout,
|
|
1079
1150
|
env,
|
|
1080
1151
|
toolsRestrict: workflowToolsRestrict,
|
package/dist/commands/hosts.js
CHANGED
|
@@ -188,11 +188,11 @@ async function doPs(json) {
|
|
|
188
188
|
console.log(t.id.padEnd(11) + nameCol + t.host.padEnd(16) + t.agent.padEnd(10) + status.padEnd(11) + promptCol);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
async function doLogs(ref, follow) {
|
|
191
|
+
async function doLogs(ref, follow, full) {
|
|
192
192
|
// Resolve the ref as a task id first, then fall back to a `--name` handle so
|
|
193
193
|
// `agents hosts logs <name>` works, not just the opaque id.
|
|
194
194
|
const id = loadTask(ref) ? ref : (findTaskByName(ref)?.id ?? findTaskBySessionId(ref)?.id ?? ref);
|
|
195
|
-
const res = await showHostTaskLog(id, follow);
|
|
195
|
+
const res = await showHostTaskLog(id, follow, full);
|
|
196
196
|
if (!res.found) {
|
|
197
197
|
console.log(chalk.red(`Unknown task "${ref}".`));
|
|
198
198
|
process.exitCode = 1;
|
|
@@ -235,7 +235,8 @@ export function registerHostsCommand(program) {
|
|
|
235
235
|
.action((opts) => doPs(!!opts.json));
|
|
236
236
|
hosts
|
|
237
237
|
.command('logs <id>')
|
|
238
|
-
.description('Show a host task
|
|
238
|
+
.description('Show a host task’s concise summary; --full for the raw log, -f to follow a running one.')
|
|
239
239
|
.option('-f, --follow', 'Follow live output')
|
|
240
|
-
.
|
|
240
|
+
.option('-m, --full', 'Show the full raw combined-stdout log instead of the concise summary')
|
|
241
|
+
.action((id, opts) => doLogs(id, !!opts.follow, !!opts.full));
|
|
241
242
|
}
|
package/dist/commands/logs.d.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* - host-dispatch tasks (`agents run --host`) → combined-stdout log, offset-tailed
|
|
6
6
|
* - sessions (the local index) → transcript, tailed via the sessions tailer
|
|
7
7
|
*
|
|
8
|
+
* Concise by default: a bare `agents logs <id>` prints the same summary digest as
|
|
9
|
+
* `agents sessions <id>` — cheap for an agent to glance at. The token-heavy full
|
|
10
|
+
* transcript / raw stdout is opt-in behind `--full` (alias `-m/--markdown`).
|
|
11
|
+
*
|
|
8
12
|
* `[id]`/`--session` load directly (host task tried first, then session). With no
|
|
9
13
|
* id, `--host`/`--agent`/`--version` filter a merged candidate list; one match is
|
|
10
14
|
* shown, several open the fuzzy picker (or, non-TTY, print the list).
|
package/dist/commands/logs.js
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* - host-dispatch tasks (`agents run --host`) → combined-stdout log, offset-tailed
|
|
6
6
|
* - sessions (the local index) → transcript, tailed via the sessions tailer
|
|
7
7
|
*
|
|
8
|
+
* Concise by default: a bare `agents logs <id>` prints the same summary digest as
|
|
9
|
+
* `agents sessions <id>` — cheap for an agent to glance at. The token-heavy full
|
|
10
|
+
* transcript / raw stdout is opt-in behind `--full` (alias `-m/--markdown`).
|
|
11
|
+
*
|
|
8
12
|
* `[id]`/`--session` load directly (host task tried first, then session). With no
|
|
9
13
|
* id, `--host`/`--agent`/`--version` filter a merged candidate list; one match is
|
|
10
14
|
* shown, several open the fuzzy picker (or, non-TTY, print the list).
|
|
@@ -33,8 +37,8 @@ function candidateLabel(c) {
|
|
|
33
37
|
const title = s.label || s.topic || '';
|
|
34
38
|
return `${chalk.gray('sess')} ${s.shortId.padEnd(9)} ${(s.agent + ver).padEnd(14)} ${chalk.gray(s.timestamp.slice(0, 16))} ${title.slice(0, 40)}`;
|
|
35
39
|
}
|
|
36
|
-
/** Show a resolved session — follow (tail) or
|
|
37
|
-
async function showSession(session, follow) {
|
|
40
|
+
/** Show a resolved session — follow (tail), concise summary, or (`full`) transcript. */
|
|
41
|
+
async function showSession(session, follow, full) {
|
|
38
42
|
if (follow) {
|
|
39
43
|
if (!isTailable(session.agent)) {
|
|
40
44
|
console.error(chalk.red(`Tailing is supported for claude and codex sessions only (got ${session.agent}).`));
|
|
@@ -43,20 +47,20 @@ async function showSession(session, follow) {
|
|
|
43
47
|
await streamSessionTail(session, {});
|
|
44
48
|
return;
|
|
45
49
|
}
|
|
46
|
-
await renderSessionLog(session);
|
|
50
|
+
await renderSessionLog(session, full ? 'markdown' : 'summary');
|
|
47
51
|
}
|
|
48
|
-
async function showCandidate(c, follow) {
|
|
52
|
+
async function showCandidate(c, follow, full) {
|
|
49
53
|
if (c.kind === 'task') {
|
|
50
|
-
const res = await showHostTaskLog(c.task.id, follow);
|
|
54
|
+
const res = await showHostTaskLog(c.task.id, follow, full);
|
|
51
55
|
if (res.exitCode !== undefined)
|
|
52
56
|
process.exitCode = res.exitCode;
|
|
53
57
|
return;
|
|
54
58
|
}
|
|
55
|
-
await showSession(c.session, follow);
|
|
59
|
+
await showSession(c.session, follow, full);
|
|
56
60
|
}
|
|
57
61
|
/** Resolve an explicit id/--session: host task first, then a session. */
|
|
58
|
-
async function showById(id, follow) {
|
|
59
|
-
const hostRes = await showHostTaskLog(id, follow);
|
|
62
|
+
async function showById(id, follow, full) {
|
|
63
|
+
const hostRes = await showHostTaskLog(id, follow, full);
|
|
60
64
|
if (hostRes.found) {
|
|
61
65
|
if (hostRes.exitCode !== undefined)
|
|
62
66
|
process.exitCode = hostRes.exitCode;
|
|
@@ -68,13 +72,14 @@ async function showById(id, follow) {
|
|
|
68
72
|
console.error(chalk.red(`No run or session found matching "${id}".`));
|
|
69
73
|
process.exit(1);
|
|
70
74
|
}
|
|
71
|
-
await showSession(matches[0], follow);
|
|
75
|
+
await showSession(matches[0], follow, full);
|
|
72
76
|
}
|
|
73
77
|
async function runLogs(id, opts) {
|
|
74
78
|
const follow = !!opts.follow;
|
|
79
|
+
const full = !!opts.full;
|
|
75
80
|
const directId = opts.session ?? id;
|
|
76
81
|
if (directId) {
|
|
77
|
-
await showById(directId, follow);
|
|
82
|
+
await showById(directId, follow, full);
|
|
78
83
|
return;
|
|
79
84
|
}
|
|
80
85
|
const { agent, version } = parseAgentFilter(opts.agent);
|
|
@@ -99,7 +104,7 @@ async function runLogs(id, opts) {
|
|
|
99
104
|
process.exit(1);
|
|
100
105
|
}
|
|
101
106
|
if (candidates.length === 1) {
|
|
102
|
-
await showCandidate(candidates[0], follow);
|
|
107
|
+
await showCandidate(candidates[0], follow, full);
|
|
103
108
|
return;
|
|
104
109
|
}
|
|
105
110
|
// Multiple sessions matched → picker if interactive, else a list to pick from.
|
|
@@ -123,17 +128,18 @@ async function runLogs(id, opts) {
|
|
|
123
128
|
});
|
|
124
129
|
if (!picked)
|
|
125
130
|
return;
|
|
126
|
-
await showCandidate(picked.item, follow);
|
|
131
|
+
await showCandidate(picked.item, follow, full);
|
|
127
132
|
}
|
|
128
133
|
/** Register the top-level `agents logs` command. */
|
|
129
134
|
export function registerLogsCommand(program) {
|
|
130
135
|
program
|
|
131
136
|
.command('logs [id]')
|
|
132
|
-
.description('Show a run’s
|
|
137
|
+
.description('Show a run’s concise summary — a host-dispatch task or a session. --full for the raw transcript, -f to follow a live one.')
|
|
133
138
|
.option('--host <name>', 'Scope to runs dispatched to a host')
|
|
134
139
|
.option('-a, --agent <agent>', 'Filter by agent (e.g. claude, codex@0.116.0)')
|
|
135
140
|
.option('--version <version>', 'Filter by agent version')
|
|
136
141
|
.option('--session <id>', 'Select a session/run by id (same as the positional id)')
|
|
137
142
|
.option('-f, --follow', 'Follow live output')
|
|
143
|
+
.option('-m, --full', 'Show the full raw transcript / stdout instead of the concise summary')
|
|
138
144
|
.action((id, opts) => runLogs(id, opts));
|
|
139
145
|
}
|
|
@@ -6,5 +6,11 @@
|
|
|
6
6
|
* Also exposes scheduler lifecycle controls (start/stop/status/logs).
|
|
7
7
|
*/
|
|
8
8
|
import type { Command } from 'commander';
|
|
9
|
+
/**
|
|
10
|
+
* Human-friendly wall-clock a run took (e.g. " · 3 min", " · 45 sec"), or ""
|
|
11
|
+
* when it hasn't completed or timestamps are unparseable. Leading separator lets
|
|
12
|
+
* callers drop it straight into a status line.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatRunDuration(startedAt: string, completedAt: string | null): string;
|
|
9
15
|
/** Register the `agents routines` command tree. */
|
|
10
16
|
export declare function registerRoutinesCommands(program: Command): void;
|
|
@@ -22,6 +22,27 @@ import { JobScheduler } from '../lib/scheduler.js';
|
|
|
22
22
|
import { detectOverdueJobs } from '../lib/overdue.js';
|
|
23
23
|
import { isInteractiveTerminal, requireInteractiveSelection } from './utils.js';
|
|
24
24
|
import { setHelpSections } from '../lib/help.js';
|
|
25
|
+
/**
|
|
26
|
+
* Human-friendly wall-clock a run took (e.g. " · 3 min", " · 45 sec"), or ""
|
|
27
|
+
* when it hasn't completed or timestamps are unparseable. Leading separator lets
|
|
28
|
+
* callers drop it straight into a status line.
|
|
29
|
+
*/
|
|
30
|
+
export function formatRunDuration(startedAt, completedAt) {
|
|
31
|
+
if (!completedAt)
|
|
32
|
+
return '';
|
|
33
|
+
const ms = Date.parse(completedAt) - Date.parse(startedAt);
|
|
34
|
+
if (!Number.isFinite(ms) || ms < 0)
|
|
35
|
+
return '';
|
|
36
|
+
const sec = Math.round(ms / 1000);
|
|
37
|
+
if (sec < 60)
|
|
38
|
+
return ` · ${sec} sec`;
|
|
39
|
+
const min = Math.round(sec / 60);
|
|
40
|
+
if (min < 60)
|
|
41
|
+
return ` · ${min} min`;
|
|
42
|
+
const hr = Math.floor(min / 60);
|
|
43
|
+
const rem = min % 60;
|
|
44
|
+
return rem ? ` · ${hr} hr ${rem} min` : ` · ${hr} hr`;
|
|
45
|
+
}
|
|
25
46
|
/**
|
|
26
47
|
* Human label for what fires a job: its cron schedule, or its event trigger
|
|
27
48
|
* for schedule-less (trigger-only) routines.
|
|
@@ -660,30 +681,67 @@ export function registerRoutinesCommands(program) {
|
|
|
660
681
|
});
|
|
661
682
|
routinesCmd
|
|
662
683
|
.command('logs [name]')
|
|
663
|
-
.description('
|
|
684
|
+
.description('Show a run’s concise summary — status + extracted report. --full for the raw stdout stream; --run for a specific past run.')
|
|
664
685
|
.option('-r, --run <runId>', 'Show logs from this run ID instead of the latest')
|
|
686
|
+
.option('-m, --full', 'Show the full raw stdout stream instead of the concise summary')
|
|
665
687
|
.action(async (name, options) => {
|
|
666
688
|
if (!name) {
|
|
667
689
|
name = await pickJob('Select job to view logs', undefined, ['agents routines logs <name>', 'agents routines logs <name> --run <run-id>']) ?? undefined;
|
|
668
690
|
if (!name)
|
|
669
691
|
return;
|
|
670
692
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
693
|
+
// Resolve the run: an explicit --run row, else the latest.
|
|
694
|
+
const run = options.run
|
|
695
|
+
? listRuns(name).find((r) => r.runId === options.run)
|
|
696
|
+
: getLatestRun(name);
|
|
697
|
+
if (!run) {
|
|
698
|
+
console.log(chalk.yellow(options.run ? `No run '${options.run}' for job '${name}'` : `No runs found for job '${name}'`));
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
const runId = run.runId;
|
|
702
|
+
const logPath = path.join(getRunDir(name, runId), 'stdout.log');
|
|
703
|
+
// --full: the raw combined stdout stream (the old default).
|
|
704
|
+
if (options.full) {
|
|
705
|
+
if (!fs.existsSync(logPath)) {
|
|
706
|
+
console.log(chalk.yellow(`Log not found: ${logPath}`));
|
|
676
707
|
return;
|
|
677
708
|
}
|
|
678
|
-
|
|
709
|
+
console.log(chalk.gray(`Run: ${runId}\n`));
|
|
710
|
+
console.log(fs.readFileSync(logPath, 'utf-8'));
|
|
711
|
+
return;
|
|
679
712
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
713
|
+
// Concise by default: a status header + the extracted report (final
|
|
714
|
+
// assistant message). Routine runs are sandboxed (transcript in an overlay
|
|
715
|
+
// HOME, not the session index), so the captured report — not renderSummary —
|
|
716
|
+
// is the concise view. Falls back to a bounded stdout tail when no report
|
|
717
|
+
// was extracted (e.g. the run failed before finishing).
|
|
718
|
+
const statusColor = run.status === 'completed' ? chalk.green
|
|
719
|
+
: run.status === 'failed' || run.status === 'timeout' ? chalk.red
|
|
720
|
+
: chalk.yellow;
|
|
721
|
+
console.log(chalk.bold(name) + chalk.gray(` run ${runId}`));
|
|
722
|
+
console.log(statusColor(run.status) +
|
|
723
|
+
chalk.gray(` ${run.startedAt}`) +
|
|
724
|
+
chalk.gray(formatRunDuration(run.startedAt, run.completedAt)) +
|
|
725
|
+
(run.exitCode !== null && run.exitCode !== undefined ? chalk.gray(` exit ${run.exitCode}`) : ''));
|
|
726
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
727
|
+
const reportPath = path.join(getRunDir(name, runId), 'report.md');
|
|
728
|
+
if (fs.existsSync(reportPath)) {
|
|
729
|
+
console.log(fs.readFileSync(reportPath, 'utf-8').trimEnd());
|
|
730
|
+
console.log(chalk.gray('\n(pass --full for the raw stdout stream)'));
|
|
683
731
|
return;
|
|
684
732
|
}
|
|
685
|
-
|
|
686
|
-
|
|
733
|
+
// No report — show a bounded tail rather than dumping the whole stream.
|
|
734
|
+
if (fs.existsSync(logPath)) {
|
|
735
|
+
const lines = fs.readFileSync(logPath, 'utf-8').split('\n');
|
|
736
|
+
const tail = lines.slice(-40).join('\n').trimEnd();
|
|
737
|
+
console.log(chalk.gray('(no report extracted — showing the last lines of stdout)'));
|
|
738
|
+
if (tail)
|
|
739
|
+
console.log(tail);
|
|
740
|
+
console.log(chalk.gray('\n(pass --full for the raw stdout stream)'));
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
console.log(chalk.gray('(no output captured for this run)'));
|
|
744
|
+
}
|
|
687
745
|
});
|
|
688
746
|
routinesCmd
|
|
689
747
|
.command('report [name]')
|
|
@@ -9,6 +9,24 @@ import { type Command } from 'commander';
|
|
|
9
9
|
import { SSH_TARGET_RE, assertValidSshTarget } from '../lib/ssh-exec.js';
|
|
10
10
|
import { quoteWin32ExecArg } from '../lib/platform/index.js';
|
|
11
11
|
import { type SecretsBundle, type SecretsPolicy } from '../lib/secrets/bundles.js';
|
|
12
|
+
/**
|
|
13
|
+
* Read the raw `.env` text for `import --from <path|->`. A `-` reads the .env
|
|
14
|
+
* from stdin (the SSH push path: `export --host` pipes the resolved dotenv over
|
|
15
|
+
* ssh stdin, which has no `/dev/stdin` on a Windows remote); any other value is
|
|
16
|
+
* a filesystem path.
|
|
17
|
+
*/
|
|
18
|
+
export declare function readImportDotenv(from: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Build the remote `agents secrets unlock` argv for `unlock --host`. `--all`
|
|
21
|
+
* forwards verbatim; otherwise the explicit bundle names. A `--ttl` is passed
|
|
22
|
+
* through as-is so the REMOTE parses its own duration (its platform rules, its
|
|
23
|
+
* defaults). Shared with the command action so the wiring is unit-testable
|
|
24
|
+
* without a live SSH session.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildRemoteUnlockArgs(names: string[], opts: {
|
|
27
|
+
all?: boolean;
|
|
28
|
+
ttl?: string;
|
|
29
|
+
}): string[];
|
|
12
30
|
export { SSH_TARGET_RE, assertValidSshTarget };
|
|
13
31
|
/**
|
|
14
32
|
* Build the child environment for `agents secrets exec`. Strips
|