@phnx-labs/agents-cli 1.23.39 → 1.23.40
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 +14 -0
- package/README.md +7 -20
- package/dist/cli/command-registry.js +0 -2
- package/dist/commands/config.js +0 -4
- package/dist/commands/daemon.js +5 -5
- package/dist/commands/events.js +1 -1
- package/dist/commands/lead.js +4 -3
- package/dist/commands/setup.d.ts +1 -1
- package/dist/commands/setup.js +1 -9
- package/dist/commands/ssh.js +4 -5
- package/dist/lib/accounting/usage.d.ts +1 -1
- package/dist/lib/answer-router.d.ts +1 -1
- package/dist/lib/answer-router.js +16 -6
- package/dist/lib/channels/providers/session.js +13 -0
- package/dist/lib/channels/registry.d.ts +1 -1
- package/dist/lib/config-keys.d.ts +1 -1
- package/dist/lib/config-keys.js +1 -4
- package/dist/lib/daemon/daemon.js +1 -6
- package/dist/lib/daemon-services.d.ts +1 -1
- package/dist/lib/daemon-services.js +0 -5
- package/dist/lib/device-config.js +2 -11
- package/dist/lib/feed/answer.js +25 -1
- package/dist/lib/feed/attention.d.ts +8 -0
- package/dist/lib/feed/attention.js +39 -0
- package/dist/lib/feed/tab-delivery.d.ts +27 -0
- package/dist/lib/feed/tab-delivery.js +102 -0
- package/dist/lib/feed/watch.d.ts +3 -0
- package/dist/lib/feed/watch.js +63 -13
- package/dist/lib/hosts/passthrough.js +0 -1
- package/dist/lib/installations/migrate.d.ts +0 -1
- package/dist/lib/installations/migrate.js +0 -17
- package/dist/lib/lead/drafts.d.ts +11 -0
- package/dist/lib/lead/drafts.js +34 -0
- package/dist/lib/lead/host.d.ts +5 -0
- package/dist/lib/lead/host.js +52 -1
- package/dist/lib/lead/paths.js +1 -1
- package/dist/lib/lead/tools.d.ts +1 -0
- package/dist/lib/lead/tools.js +22 -0
- package/dist/lib/menubar/snapshot.d.ts +0 -6
- package/dist/lib/menubar/snapshot.js +0 -18
- package/dist/lib/session/active.d.ts +2 -1
- package/dist/lib/session/active.js +10 -6
- package/dist/lib/session/hook-sessions.d.ts +10 -0
- package/dist/lib/session/hook-sessions.js +22 -10
- package/dist/lib/session/inject-target.d.ts +1 -0
- package/dist/lib/session/inject-target.js +2 -1
- package/dist/lib/session/pid-registry.d.ts +1 -0
- package/dist/lib/session/remote/watch.d.ts +1 -0
- package/dist/lib/startup/command-registry.js +2 -1
- package/dist/lib/state.js +0 -1
- package/dist/lib/terminal/index.d.ts +1 -1
- package/dist/lib/terminal/index.js +1 -1
- package/dist/lib/terminal/inject.d.ts +0 -15
- package/dist/lib/terminal/inject.js +2 -16
- package/dist/lib/terminal/resolve.d.ts +2 -1
- package/dist/lib/terminal/resolve.js +13 -18
- package/dist/lib/types.d.ts +0 -3
- package/package.json +1 -1
- package/dist/commands/setup-watchdog.d.ts +0 -3
- package/dist/commands/setup-watchdog.js +0 -49
- package/dist/commands/watchdog.d.ts +0 -4
- package/dist/commands/watchdog.js +0 -361
- package/dist/lib/daemon/watchdog-service.d.ts +0 -10
- package/dist/lib/daemon/watchdog-service.js +0 -27
- package/dist/lib/session/presence.d.ts +0 -47
- package/dist/lib/session/presence.js +0 -100
- package/dist/lib/watchdog/history.d.ts +0 -20
- package/dist/lib/watchdog/history.js +0 -43
- package/dist/lib/watchdog/log.d.ts +0 -33
- package/dist/lib/watchdog/log.js +0 -117
- package/dist/lib/watchdog/read.d.ts +0 -8
- package/dist/lib/watchdog/read.js +0 -93
- package/dist/lib/watchdog/rotate.d.ts +0 -55
- package/dist/lib/watchdog/rotate.js +0 -220
- package/dist/lib/watchdog/runner.d.ts +0 -100
- package/dist/lib/watchdog/runner.js +0 -727
- package/dist/lib/watchdog/service.d.ts +0 -15
- package/dist/lib/watchdog/service.js +0 -36
- package/dist/lib/watchdog/watchdog-agent.d.ts +0 -8
- package/dist/lib/watchdog/watchdog-agent.js +0 -32
- package/dist/lib/watchdog/watchdog.d.ts +0 -43
- package/dist/lib/watchdog/watchdog.js +0 -116
- package/dist/lib/watchdog/watchdogTail.d.ts +0 -6
- package/dist/lib/watchdog/watchdogTail.js +0 -116
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.23.40
|
|
4
|
+
|
|
5
|
+
- **The stall watchdog is gone (PHNX-4439).** `agents watchdog`, `agents setup watchdog`, the
|
|
6
|
+
daemon's `watchdog` service, the `watchdog.enabled` device key and the menubar snapshot's
|
|
7
|
+
`watchdog` block are deleted. It was off by default, typed a generic "Continue." into a stalled
|
|
8
|
+
split, and never confirmed that a VSCodium tab received it. Its replacement is the Stop-hook done
|
|
9
|
+
check, which decides whose move it is, and the project Lead's drafted reply, which you send from the
|
|
10
|
+
card. A leftover `watchdog: false` in `~/.agents/daemon/services.yaml` or `watchdogEnabled` in a
|
|
11
|
+
device's `agents.yaml` is left in place and ignored, and `agents watchdog` is an unknown command
|
|
12
|
+
that never autocorrects to a live one.
|
|
13
|
+
Source: `cli/src/lib/daemon/daemon.ts`, `cli/src/lib/device-config.ts`.
|
|
14
|
+
|
|
15
|
+
- **Asks come from the Stop hook's judge, and replies reach editor tabs with a receipt (PHNX-4439).** A Claude session's card now asks when the Stop hook's model judge says the turn handed the owner something (`turnVerdict` on the row, with the agent's own sentence and choices), and says Not done when it stopped waiting on nothing live. Neither expires on a clock; once the judge has judged a session, the last-line question regex no longer applies to it. `agents feed answer` and `agents send --channel session` hand text for a VSCodium tab, or an agent started from an editor on another machine, to the AGI EXT window that binds it (`delivery` on the row) and report delivered only when the agent takes it (and release the answer for another try when nothing reached it); the `codium --open-url` rail, which could not confirm and missed the 31 of 42 sessions running on other machines, is removed. The project Lead drafts a reply for each new ask in its project (shown on the card as `draft`; Send is the ordinary `agents feed answer`), and `agents lead tool roster --session <id>` gives it a session's last two turns. Source: `cli/src/lib/feed/attention.ts`, `cli/src/lib/feed/tab-delivery.ts`, `cli/src/lib/answer-router.ts`, `cli/src/lib/lead/host.ts`, `cli/src/lib/lead/drafts.ts`.
|
|
16
|
+
|
|
3
17
|
## 1.23.39
|
|
4
18
|
|
|
5
19
|
- **`agents run --device auto` places from a snapshot instead of probing the fleet on every launch.** Each placement probe's load stats and readiness answer are now kept in `~/.agents/.cache/.fleet-stats.json`, and the daemon's `device-probe` tick refreshes them every 3 minutes while placement was used in the last day. A launch uses a device's entry when it is at most 5 minutes old and probes live only the devices whose entry is missing or older (stats and readiness now in parallel). The picked device is confirmed with one `ssh … true` that the dispatch then reuses, and `ensureHostReady` reads the same fresh entry instead of its own `agents view` round trip. On yosemite-s1 a headless `--device auto` launch reached its dispatch ssh in 0.6 to 0.9 s instead of 6.1 s. A pick that no longer answers is marked and the next best is taken; when only the snapshot says no device is ready, placement probes live before refusing. Source: cli/src/lib/teams/placement-probe.ts, cli/src/lib/devices/stats-cache.ts, cli/src/lib/hosts/ready.ts, cli/src/lib/smart-launch.ts, cli/src/lib/daemon/device-probe-service.ts
|
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ agents setup tools # install/upgrade the standalone sessions
|
|
|
56
56
|
agents run claude "explain this repo" # run any agent on your existing subscription
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Everything here — and every other command in this README — is free and needs no account; the optional `agents auth login` unlocks the hosted surfaces — [team spaces](#sign-in) and owner notifications. `agents setup` is interactive and idempotent -- safe to re-run on any machine. Once core setup exists, it opens a status-aware menu for browser, computer, secrets, term, fleet,
|
|
59
|
+
Everything here — and every other command in this README — is free and needs no account; the optional `agents auth login` unlocks the hosted surfaces — [team spaces](#sign-in) and owner notifications. `agents setup` is interactive and idempotent -- safe to re-run on any machine. Once core setup exists, it opens a status-aware menu for browser, computer, secrets, term, fleet, and device preferences; each choice delegates to the same wizard available under `agents setup <capability>`. In CI or another non-TTY, bare setup prints the checklist without prompting. The `agi-cli.sh` one-liner installs this same canonical `@phnx-labs/agents-cli` package. Prefer bun? `bun install -g @phnx-labs/agents-cli` works too.
|
|
60
60
|
|
|
61
61
|
The command surface teaches setup through `agents setup` and group-level `--help`.
|
|
62
62
|
The durable system model starts at [`cli/docs/README.md`](cli/docs/README.md).
|
|
@@ -495,7 +495,7 @@ Both are agent-agnostic -- they route through the same `agents run <agent> --res
|
|
|
495
495
|
Running agents aren't fire-and-forget. Steer them mid-run without opening their terminals.
|
|
496
496
|
|
|
497
497
|
<p align="center">
|
|
498
|
-
<img src="assets/fleet-control.svg" alt="agents ps infers live state (working, waiting, idle);
|
|
498
|
+
<img src="assets/fleet-control.svg" alt="agents ps infers live state (working, waiting, idle); feed answer replies to an open ask; message reaches a running agent at its next tool call" width="100%" />
|
|
499
499
|
</p>
|
|
500
500
|
|
|
501
501
|
### Message a running agent
|
|
@@ -564,19 +564,6 @@ start, send, stop, linear, remember). It cannot edit files, and a stop runs only
|
|
|
564
564
|
follow-up turn skips the harness boot. `--json` streams the NDJSON events the AGI EXT and bubble
|
|
565
565
|
clients render. Reference: [cli/docs/lead.md](cli/docs/lead.md).
|
|
566
566
|
|
|
567
|
-
### Auto-nudge stalls
|
|
568
|
-
|
|
569
|
-
```bash
|
|
570
|
-
agents watchdog # one tick, dry run — reports what it WOULD nudge and why
|
|
571
|
-
agents watchdog --verbose # include healthy/non-actionable session inspections
|
|
572
|
-
agents watchdog --nudge # actually inject "Continue." into the stalled split
|
|
573
|
-
agents watchdog --watch # daemon loop: a tick every --interval
|
|
574
|
-
```
|
|
575
|
-
|
|
576
|
-
`agents watchdog` detects a stalled session, resolves the *exact* terminal split it lives in (tmux, iTerm, VSCodium, or a raw pty), and injects a nudge -- `Continue.` by default, or set `--text`. Its timestamped default output shows attention-worthy sessions with their agent, host app, machine, project, activity, age, path, latest preview, and decision reason; `--verbose` restores healthy/non-actionable inspections. It's dry by default; `--nudge` acts on a single tick. `agents watchdog enable|disable` controls the device-local daemon pass, which runs once every three minutes. Steer a single run with `agents watchdog policy <id> off | keep | handsoff`.
|
|
577
|
-
|
|
578
|
-
A stalled session whose tail shows a hard account limit ("You've hit your weekly limit · resets …") is **rotated in place** instead of nudged: the watchdog gates on the same healthy-account selection `agents run auto` makes (zero healthy → one skip event per cooldown window, terminal untouched), injects the harness's exit sequence, relaunches `agents run auto --interactive --session-id <uuid>` in the *same* tab, then replays the old session's resume once the new TUI is live. Default on; `agents watchdog rotate off` disables it (nudging stays on).
|
|
579
|
-
|
|
580
567
|
---
|
|
581
568
|
|
|
582
569
|
## Sync the fleet
|
|
@@ -1316,7 +1303,7 @@ secrets list # EXPIRING column flags secrets due in the next 30 days
|
|
|
1316
1303
|
|
|
1317
1304
|
## Daemon
|
|
1318
1305
|
|
|
1319
|
-
The
|
|
1306
|
+
The session index, the feed stream, and usage/auth sync all run
|
|
1320
1307
|
inside one always-on daemon per device. `agents daemon` is its runtime surface:
|
|
1321
1308
|
|
|
1322
1309
|
```bash
|
|
@@ -1331,10 +1318,10 @@ agents daemon disable # persist daemon.enabled: false -- nothing auto-sta
|
|
|
1331
1318
|
agents daemon enable # clear the kill switch
|
|
1332
1319
|
|
|
1333
1320
|
agents daemon reload # SIGHUP -- reload service toggles and the log level, no restart
|
|
1334
|
-
agents daemon services # health of every hosted service (
|
|
1321
|
+
agents daemon services # health of every hosted service (session-index, feed-stream, ...)
|
|
1335
1322
|
agents daemon services list # every toggleable service and its current on/off state
|
|
1336
1323
|
agents daemon services enable recordings
|
|
1337
|
-
agents daemon services disable
|
|
1324
|
+
agents daemon services disable device-probe # stop the device probe without stopping the daemon
|
|
1338
1325
|
agents daemon logs -f --level warn --since 1h
|
|
1339
1326
|
agents daemon logs --level error --since 1h # each restart, with what was running when it happened
|
|
1340
1327
|
agents daemon logs level debug # trace every tick and slow section, live; `level info` turns it off
|
|
@@ -1348,7 +1335,7 @@ agents daemon index backfill tools --fleet # one-shot historical parse (also: r
|
|
|
1348
1335
|
`agents daemon index` is foreground maintenance of the index the daemon's
|
|
1349
1336
|
session-index service keeps current; it never starts or restarts the daemon.
|
|
1350
1337
|
|
|
1351
|
-
Each hosted responsibility (
|
|
1338
|
+
Each hosted responsibility (recordings, device probe,
|
|
1352
1339
|
self-heal, self-update, account-state refresh, state-dir checks) is an
|
|
1353
1340
|
independent toggle in `~/.agents/daemon/services.yaml`.
|
|
1354
1341
|
Self-update checks npm on its own schedule, installs + verifies a newer
|
|
@@ -1366,7 +1353,7 @@ the standalone `browser` CLI runs its own (`browser stop --service`).
|
|
|
1366
1353
|
|
|
1367
1354
|
The CLI has no job scheduler: schedule recurring agent work with OS cron, a
|
|
1368
1355
|
systemd timer, or launchd calling `agents run`. `disable` is a device-local kill
|
|
1369
|
-
switch: with it set, `agents feed watch
|
|
1356
|
+
switch: with it set, `agents feed watch` and
|
|
1370
1357
|
`agents recordings` stop auto-starting the daemon, mirroring
|
|
1371
1358
|
`systemctl disable` -- `agents daemon start` still works as the explicit
|
|
1372
1359
|
override.
|
|
@@ -34,7 +34,6 @@ const loadRefreshRules = async () => (await import('../commands/refresh-rules.js
|
|
|
34
34
|
const loadFactory = async () => (await import('../commands/factory.js')).registerFactoryCommands;
|
|
35
35
|
const loadInsights = async () => (await import('../commands/insights.js')).registerInsightsCommand;
|
|
36
36
|
const loadTrace = async () => (await import('../commands/sessions-trace.js')).registerTraceCommand;
|
|
37
|
-
const loadWatchdog = async () => (await import('../commands/watchdog.js')).registerWatchdogCommand;
|
|
38
37
|
const loadEvents = async () => (await import('../commands/events.js')).registerEventsCommand;
|
|
39
38
|
const loadSsh = async () => (await import('../commands/ssh.js')).registerSshCommands;
|
|
40
39
|
const loadRepo = async () => (await import('../commands/repo.js')).registerRepoCommands;
|
|
@@ -94,7 +93,6 @@ export const COMMAND_LOADERS = {
|
|
|
94
93
|
factory: [loadFactory],
|
|
95
94
|
insights: [loadInsights],
|
|
96
95
|
trace: [loadTrace],
|
|
97
|
-
watchdog: [loadWatchdog],
|
|
98
96
|
events: [loadEvents],
|
|
99
97
|
ssh: [loadSsh],
|
|
100
98
|
devices: [loadSsh],
|
package/dist/commands/config.js
CHANGED
|
@@ -78,7 +78,6 @@ function parseValue(key, parsed, raw) {
|
|
|
78
78
|
}
|
|
79
79
|
return Number.parseInt(raw.trim(), 10);
|
|
80
80
|
case 'daemon':
|
|
81
|
-
case 'watchdog':
|
|
82
81
|
case 'tmux':
|
|
83
82
|
case 'browser.remote-control':
|
|
84
83
|
return parseBool(raw, key);
|
|
@@ -380,9 +379,6 @@ function* listDeviceConfigEntries(device) {
|
|
|
380
379
|
case 'daemon.enabled':
|
|
381
380
|
key = `${prefix}daemon`;
|
|
382
381
|
break;
|
|
383
|
-
case 'watchdog.enabled':
|
|
384
|
-
key = `${prefix}watchdog`;
|
|
385
|
-
break;
|
|
386
382
|
case 'tmux.enabled':
|
|
387
383
|
key = `${prefix}tmux`;
|
|
388
384
|
break;
|
package/dist/commands/daemon.js
CHANGED
|
@@ -463,7 +463,7 @@ async function runDoctor(opts) {
|
|
|
463
463
|
export function registerDaemonCommand(program) {
|
|
464
464
|
const cmd = program
|
|
465
465
|
.command('daemon')
|
|
466
|
-
.description('The always-on daemon:
|
|
466
|
+
.description('The always-on daemon: session index, feed stream, session/usage sync, and account health. Bare `agents daemon` shows status.')
|
|
467
467
|
.option('--json', 'Emit as JSON')
|
|
468
468
|
.action(async (opts, command) => {
|
|
469
469
|
await runStatus({ json: command.optsWithGlobals().json === true });
|
|
@@ -493,7 +493,7 @@ export function registerDaemonCommand(program) {
|
|
|
493
493
|
|
|
494
494
|
# Toggle or restart a service live — applies without a daemon restart
|
|
495
495
|
# for supervisor-managed services (account-state, session-index,
|
|
496
|
-
#
|
|
496
|
+
# device-probe, self-heal, state-dir-check)
|
|
497
497
|
agents daemon services disable account-state
|
|
498
498
|
agents daemon services enable account-state
|
|
499
499
|
agents daemon services restart account-state
|
|
@@ -512,8 +512,8 @@ export function registerDaemonCommand(program) {
|
|
|
512
512
|
agents daemon index backfill tools --fleet
|
|
513
513
|
`,
|
|
514
514
|
notes: `
|
|
515
|
-
'disable' is a persisted kill switch: it stops feed watch
|
|
516
|
-
|
|
515
|
+
'disable' is a persisted kill switch: it stops feed watch
|
|
516
|
+
and recordings from auto-starting
|
|
517
517
|
the daemon (daemon.enabled: false in ~/.agents/devices/<host>/agents.yaml).
|
|
518
518
|
'agents daemon start' still starts it explicitly, same as
|
|
519
519
|
'systemctl start' on a disabled unit.
|
|
@@ -601,7 +601,7 @@ export function registerDaemonCommand(program) {
|
|
|
601
601
|
.description('Clear the daemon.enabled kill switch. Does not start the daemon by itself.')
|
|
602
602
|
.action(() => {
|
|
603
603
|
setConfigValue('daemon.enabled', true);
|
|
604
|
-
console.log(chalk.green('daemon.enabled: true') + chalk.gray(' — auto-start surfaces (feed watch,
|
|
604
|
+
console.log(chalk.green('daemon.enabled: true') + chalk.gray(' — auto-start surfaces (feed watch, recordings) may bring the daemon up again'));
|
|
605
605
|
});
|
|
606
606
|
cmd.command('disable')
|
|
607
607
|
.description('Persist daemon.enabled: false — nothing auto-starts the daemon until re-enabled. Does not stop a running daemon.')
|
package/dist/commands/events.js
CHANGED
|
@@ -145,7 +145,7 @@ export function addEventsReadOptions(command) {
|
|
|
145
145
|
command
|
|
146
146
|
.option('--include <families>', `Only these families (comma-sep): ${EVENT_FAMILIES.join(', ')}`)
|
|
147
147
|
.option('--exclude <families>', `Drop these families (comma-sep): ${EVENT_FAMILIES.join(', ')}`)
|
|
148
|
-
.option('--module <name>', 'Only events from this group (e.g. teams, secrets, activity, daemon,
|
|
148
|
+
.option('--module <name>', 'Only events from this group (e.g. teams, secrets, activity, daemon, browser)')
|
|
149
149
|
.option('--command <path>', 'Only this command path — prefix match (e.g. "teams create")')
|
|
150
150
|
.option('--event <type>', 'Only this typed event (repeatable, e.g. secrets.get, run.dispatched, pr.opened)', collect, [])
|
|
151
151
|
.option('--agent <name>', 'Only events tagged with this agent')
|
package/dist/commands/lead.js
CHANGED
|
@@ -9,7 +9,7 @@ import { LeadSpeaker } from '../lib/lead/speak.js';
|
|
|
9
9
|
import { statusFromFiles } from '../lib/lead/host.js';
|
|
10
10
|
import { leadPaths, listLeadProjects } from '../lib/lead/paths.js';
|
|
11
11
|
import { readHistory } from '../lib/lead/store.js';
|
|
12
|
-
import { LINEAR_STATUSES, LeadToolError, MAX_TASKS_LIMIT, PR_VERBS, leadToolContext, parseEditorContext, toolAnswer, toolAttention, toolDispatch, toolLinearCreate, toolLinearTasks, toolLinearView, toolPrAct, toolPrsList, toolRemember, toolRoster, toolSend, toolStart, toolStop, } from '../lib/lead/tools.js';
|
|
12
|
+
import { LINEAR_STATUSES, LeadToolError, MAX_TASKS_LIMIT, PR_VERBS, leadToolContext, parseEditorContext, toolAnswer, toolAttention, toolDispatch, toolLinearCreate, toolLinearTasks, toolLinearView, toolPrAct, toolPrsList, toolRemember, toolRoster, toolRosterSession, toolSend, toolStart, toolStop, } from '../lib/lead/tools.js';
|
|
13
13
|
function toolAction(fn) {
|
|
14
14
|
return async (...args) => {
|
|
15
15
|
try {
|
|
@@ -37,9 +37,10 @@ export function registerLeadToolCommands(lead) {
|
|
|
37
37
|
});
|
|
38
38
|
const strict = (c) => c.allowExcessArguments(false).allowUnknownOption(false);
|
|
39
39
|
strict(tool.command('roster'))
|
|
40
|
-
.description('List live sessions for this project (or --project) from the Lead host\'s live feed')
|
|
40
|
+
.description('List live sessions for this project (or --project) from the Lead host\'s live feed; --session shows one session\'s last two turns')
|
|
41
41
|
.option('--project <name>', 'Another project')
|
|
42
|
-
.
|
|
42
|
+
.option('--session <id>', 'Show this session\'s last two turns of conversation (no tool calls)')
|
|
43
|
+
.action(toolAction(async (opts) => opts.session ? toolRosterSession(leadToolContext(), opts.session) : toolRoster(leadToolContext(), opts.project)));
|
|
43
44
|
strict(tool.command('attention'))
|
|
44
45
|
.description('List every open ask across the fleet from the Lead host\'s live feed: key, session, host, project, age, question, choices')
|
|
45
46
|
.action(toolAction(async () => toolAttention(leadToolContext())));
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ interface RunSetupOptions {
|
|
|
12
12
|
}
|
|
13
13
|
export declare function runSetup(program: Command, options?: RunSetupOptions): Promise<void>;
|
|
14
14
|
export declare function ensureInitialized(program: Command): Promise<void>;
|
|
15
|
-
type SetupPhase = 'browser' | 'computer' | 'secrets' | 'term' | 'accounts' | 'fleet' | '
|
|
15
|
+
type SetupPhase = 'browser' | 'computer' | 'secrets' | 'term' | 'accounts' | 'fleet' | 'preferences';
|
|
16
16
|
type SetupStatusState = 'ready' | 'missing' | 'n/a';
|
|
17
17
|
interface SetupStatusRow {
|
|
18
18
|
phase: 'core' | SetupPhase;
|
package/dist/commands/setup.js
CHANGED
|
@@ -20,7 +20,6 @@ import { registerSetupToolsCommand } from './setup-tools.js';
|
|
|
20
20
|
import { registerSetupTermCommand, runTermWizard, isTermCliInstalled } from './setup-term.js';
|
|
21
21
|
import { registerSetupFleetCommand } from './setup-fleet.js';
|
|
22
22
|
import { registerSetupAccountsCommand, runAccountsSetupWizard } from './setup-accounts.js';
|
|
23
|
-
import { registerSetupWatchdogCommand, runWatchdogSetupWizard } from './setup-watchdog.js';
|
|
24
23
|
import { registerSetupSessionBackupCommand } from './setup-session-backup.js';
|
|
25
24
|
import { hasMintedSetupToken } from '../lib/auth-mint.js';
|
|
26
25
|
import { registerAliasCommand } from './alias.js';
|
|
@@ -235,7 +234,6 @@ export async function getSetupStatus() {
|
|
|
235
234
|
const secretsReady = fs.existsSync(setupSecretsPrefsPath());
|
|
236
235
|
const termReady = isTermCliInstalled();
|
|
237
236
|
const minted = hasMintedSetupToken();
|
|
238
|
-
const watchdogEnabled = getConfigValue('watchdog.enabled').value === true;
|
|
239
237
|
const interactiveHost = getConfigValue('interactive.host').value;
|
|
240
238
|
const defaultBrowser = getConfigValue('browser.profile').value;
|
|
241
239
|
return [
|
|
@@ -246,7 +244,6 @@ export async function getSetupStatus() {
|
|
|
246
244
|
{ phase: 'term', state: termReady ? 'ready' : 'missing', detail: termReady ? 'installed' : 'not installed (accounts add/login spawn it)' },
|
|
247
245
|
{ phase: 'accounts', state: minted.ready ? 'ready' : 'missing', detail: minted.detail },
|
|
248
246
|
{ phase: 'fleet', state: Object.keys(devices).length ? 'ready' : 'missing', detail: Object.keys(devices).length ? `${Object.keys(devices).length} device${Object.keys(devices).length === 1 ? '' : 's'} registered` : 'no devices registered' },
|
|
249
|
-
{ phase: 'watchdog', state: watchdogEnabled ? 'ready' : 'missing', detail: watchdogEnabled ? 'enabled on this device' : 'disabled on this device' },
|
|
250
247
|
{ phase: 'preferences', state: interactiveHost || defaultBrowser ? 'ready' : 'missing', detail: [interactiveHost && `host ${interactiveHost}`, defaultBrowser && `browser ${defaultBrowser}`].filter(Boolean).join(' · ') || 'interactive host and browser unset' },
|
|
251
248
|
];
|
|
252
249
|
}
|
|
@@ -271,8 +268,6 @@ async function runSetupPhase(phase) {
|
|
|
271
268
|
await runAccountsSetupWizard();
|
|
272
269
|
else if (phase === 'fleet')
|
|
273
270
|
await import('./setup-fleet.js').then((m) => m.runFleetSetupWizard());
|
|
274
|
-
else if (phase === 'watchdog')
|
|
275
|
-
await runWatchdogSetupWizard();
|
|
276
271
|
else
|
|
277
272
|
await runPreferencesStep();
|
|
278
273
|
}
|
|
@@ -332,7 +327,6 @@ export function registerSetupCommand(program) {
|
|
|
332
327
|
registerSetupSecretsCommand(setupCmd);
|
|
333
328
|
registerSetupAccountsCommand(setupCmd);
|
|
334
329
|
registerSetupFleetCommand(setupCmd);
|
|
335
|
-
registerSetupWatchdogCommand(setupCmd);
|
|
336
330
|
registerSetupSessionBackupCommand(setupCmd);
|
|
337
331
|
registerAliasCommand(setupCmd);
|
|
338
332
|
registerBetaCommands(setupCmd);
|
|
@@ -353,7 +347,7 @@ export function registerSetupCommand(program) {
|
|
|
353
347
|
`,
|
|
354
348
|
});
|
|
355
349
|
setupCmd.command('status')
|
|
356
|
-
.description('Show setup readiness for core, browser, computer, secrets, term, accounts, fleet,
|
|
350
|
+
.description('Show setup readiness for core, browser, computer, secrets, term, accounts, fleet, and preferences.')
|
|
357
351
|
.option('--json', 'print machine-readable JSON')
|
|
358
352
|
.option('--tool <name>', 'Read cached standalone tool status: browser, computer, secrets, term, or all')
|
|
359
353
|
.option('--refresh', 'Explicitly refresh only the selected standalone tool health checks')
|
|
@@ -396,7 +390,6 @@ export function registerSetupCommand(program) {
|
|
|
396
390
|
agents setup tools
|
|
397
391
|
agents setup accounts
|
|
398
392
|
agents setup fleet
|
|
399
|
-
agents setup watchdog
|
|
400
393
|
agents setup alias add teams
|
|
401
394
|
agents setup beta enable factory
|
|
402
395
|
`,
|
|
@@ -414,7 +407,6 @@ export function registerSetupCommand(program) {
|
|
|
414
407
|
agents setup term # install the standalone term CLI (PTY engine agents accounts add/login spawn)
|
|
415
408
|
agents setup accounts # mint a Claude setup-token for unattended usage/probe
|
|
416
409
|
agents setup fleet # discover Tailscale devices + configure SSH access
|
|
417
|
-
agents setup watchdog # choose which devices run the daemon watchdog pass
|
|
418
410
|
agents setup alias add teams # PATH shorthand: teams runs agents teams
|
|
419
411
|
agents setup beta enable factory # opt into preview features
|
|
420
412
|
|
package/dist/commands/ssh.js
CHANGED
|
@@ -1240,10 +1240,9 @@ function registerDevicesCommands(program) {
|
|
|
1240
1240
|
examples: `
|
|
1241
1241
|
agents devices config mac-mini # settings menu (TTY) / print config (piped)
|
|
1242
1242
|
agents devices config mac-mini agents.max-concurrent 4 # cap concurrent agents on mac-mini
|
|
1243
|
-
agents devices config mac-mini
|
|
1244
|
-
agents devices config mac-mini
|
|
1245
|
-
agents devices config
|
|
1246
|
-
agents devices config --fleet watchdog.enabled on # fleet-wide default (all devices)
|
|
1243
|
+
agents devices config mac-mini auto-launch.enabled # read the effective value back
|
|
1244
|
+
agents devices config mac-mini auto-launch.enabled --unset # inherit the fleet default again
|
|
1245
|
+
agents devices config --fleet auto-launch.enabled off # fleet-wide default (all devices)
|
|
1247
1246
|
agents devices config --fleet agents.max-concurrent 2 # every box caps at 2 unless it overrides
|
|
1248
1247
|
agents devices config --fleet # print the fleet defaults layer
|
|
1249
1248
|
agents devices config mac-mini notes "runs the releases" # append an operator note
|
|
@@ -1261,7 +1260,7 @@ function registerDevicesCommands(program) {
|
|
|
1261
1260
|
description (one line saying what the box is for — see
|
|
1262
1261
|
'agents devices describe'; renders in the devices list tail),
|
|
1263
1262
|
agents.max-concurrent, daemon.enabled,
|
|
1264
|
-
|
|
1263
|
+
tmux.enabled, browser.remote-control,
|
|
1265
1264
|
browser.task-idle-minutes, browser.profile,
|
|
1266
1265
|
notes, ssh.user, ssh.auth (key|password), ssh.bundle, ssh.bundle-key,
|
|
1267
1266
|
ssh.identity-file, platform (windows|linux|macos|unknown),
|
|
@@ -85,7 +85,7 @@ interface UsageOptions {
|
|
|
85
85
|
* `user:profile`, which `/api/oauth/usage` requires). OFF by default and set
|
|
86
86
|
* ONLY by a foreground human `agents view` on a headed device (personal or
|
|
87
87
|
* desktop; see USAGE-READ-2). Every background caller — daemon usage warm, auth-health
|
|
88
|
-
* probe
|
|
88
|
+
* probe — leaves it unset, preserving the RUSH-1822 guarantee that
|
|
89
89
|
* an unattended loop never transmits the interactive login to Anthropic.
|
|
90
90
|
*/
|
|
91
91
|
allowInteractiveLogin?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type OpenBlock, type BlockOption } from './feed/feed.js';
|
|
2
2
|
import type { ActiveSession } from './session/active.js';
|
|
3
3
|
import type { InjectTarget } from './terminal/index.js';
|
|
4
|
-
export type AnswerRouteKind = 'mailbox' | 'tmux' | 'iterm' | '
|
|
4
|
+
export type AnswerRouteKind = 'mailbox' | 'tmux' | 'iterm' | 'tab' | 'resume' | 'refuse';
|
|
5
5
|
export interface AnswerRoute {
|
|
6
6
|
kind: AnswerRouteKind;
|
|
7
7
|
reason: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { deriveBlockState } from './feed/feed.js';
|
|
2
|
-
import { addressabilityRecoveryHint, resolveInjectTargetForSession } from './terminal/resolve.js';
|
|
2
|
+
import { addressabilityRecoveryHint, resolveInjectTargetForSession, typedByEditorTab } from './terminal/resolve.js';
|
|
3
3
|
import { injectTargetFromReplyRail } from './session/inject.js';
|
|
4
|
+
import { currentTurnVerdict } from './feed/attention.js';
|
|
4
5
|
const ESCAPE_KEY = '\u001b';
|
|
5
6
|
export function matchOptionIndex(answer, options) {
|
|
6
7
|
if (!options?.length)
|
|
@@ -44,7 +45,8 @@ export function isParkedOnInput(session) {
|
|
|
44
45
|
if (session.awaitingReason === 'question' || session.awaitingReason === 'plan_review' || session.awaitingReason === 'permission') {
|
|
45
46
|
return true;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
const turn = currentTurnVerdict(session);
|
|
49
|
+
return turn?.kind === 'asks' || turn?.kind === 'not_done';
|
|
48
50
|
}
|
|
49
51
|
export function isOpenQuestionBlock(block) {
|
|
50
52
|
if (!block)
|
|
@@ -72,9 +74,7 @@ export function resolveAnswerRoute(input) {
|
|
|
72
74
|
const inject = injectTargetForSession(session);
|
|
73
75
|
const { payload, matched, enter } = keystrokesForAnswer(answer, options);
|
|
74
76
|
if (inject) {
|
|
75
|
-
const kind = inject.backend === 'iterm' ? 'iterm'
|
|
76
|
-
: inject.backend === 'vscodium' ? 'vscodium'
|
|
77
|
-
: 'tmux';
|
|
77
|
+
const kind = inject.backend === 'iterm' ? 'iterm' : 'tmux';
|
|
78
78
|
return {
|
|
79
79
|
kind,
|
|
80
80
|
reason: `Parked on open question — drive ${inject.backend} selection (${matched}).`,
|
|
@@ -83,6 +83,14 @@ export function resolveAnswerRoute(input) {
|
|
|
83
83
|
...(enter === false ? { enter: false } : {}),
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
+
const tab = {
|
|
87
|
+
kind: 'tab',
|
|
88
|
+
reason: 'Parked in an editor tab (or a terminal this machine cannot address) — the AGI EXT window that binds the session types it.',
|
|
89
|
+
payload,
|
|
90
|
+
...(enter === false ? { enter: false } : {}),
|
|
91
|
+
};
|
|
92
|
+
if (session.host && typedByEditorTab(session))
|
|
93
|
+
return tab;
|
|
86
94
|
if (session.context === 'headless' || session.context === 'teams' || !session.tty) {
|
|
87
95
|
const sid = session.sessionId ?? input.mailboxId;
|
|
88
96
|
if (!sid) {
|
|
@@ -98,9 +106,11 @@ export function resolveAnswerRoute(input) {
|
|
|
98
106
|
resume: { sessionId: sid, agent: session.kind },
|
|
99
107
|
};
|
|
100
108
|
}
|
|
109
|
+
if (typedByEditorTab(session))
|
|
110
|
+
return tab;
|
|
101
111
|
return {
|
|
102
112
|
kind: 'refuse',
|
|
103
|
-
reason: 'Agent is parked on a question but has no addressable terminal (no tmux, iTerm or
|
|
113
|
+
reason: 'Agent is parked on a question but has no addressable terminal (no tmux, iTerm or editor tab). ' +
|
|
104
114
|
addressabilityRecoveryHint(session),
|
|
105
115
|
};
|
|
106
116
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { injectIntoTerminal } from '../../terminal/index.js';
|
|
2
2
|
import { resolveLiveInjectTarget } from '../../session/inject-target.js';
|
|
3
|
+
import { deliverToTab } from '../../feed/tab-delivery.js';
|
|
4
|
+
import { typedByEditorTab } from '../../terminal/resolve.js';
|
|
3
5
|
export const SESSION_CHANNEL = 'session';
|
|
4
6
|
export const sessionProvider = {
|
|
5
7
|
name: SESSION_CHANNEL,
|
|
@@ -19,6 +21,17 @@ export const sessionProvider = {
|
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
23
|
const resolved = await resolveLiveInjectTarget(id);
|
|
24
|
+
const sessionId = resolved.session?.sessionId;
|
|
25
|
+
if (sessionId && !resolved.target && resolved.session && typedByEditorTab(resolved.session)) {
|
|
26
|
+
if (opts.dryRun)
|
|
27
|
+
return { ok: true, channel: SESSION_CHANNEL, id, backend: 'tab', writes: 0, confirmed: false };
|
|
28
|
+
const res = await deliverToTab({
|
|
29
|
+
sessionId, text, enter: terminal.enter !== false, transcript: resolved.session?.sessionFile,
|
|
30
|
+
});
|
|
31
|
+
return res.delivered
|
|
32
|
+
? { ok: true, channel: SESSION_CHANNEL, id, backend: 'tab', writes: 1, confirmed: true }
|
|
33
|
+
: { ...fail(res.reason), backend: 'tab', writes: res.touched ? 1 : 0, confirmed: false };
|
|
34
|
+
}
|
|
22
35
|
if (!resolved.target) {
|
|
23
36
|
return fail(resolved.hint ? `${resolved.reason}\n${resolved.hint}` : resolved.reason ?? 'session not addressable');
|
|
24
37
|
}
|
|
@@ -53,7 +53,7 @@ export interface ParsedMenubarConfigKey {
|
|
|
53
53
|
property: string;
|
|
54
54
|
}
|
|
55
55
|
export type ParsedConfigKey = ParsedRunConfigKey | ParsedInteractiveConfigKey | ParsedAutoConfigKey | ParsedBrowserConfigKey | ParsedProjectConfigKey | ParsedDeviceConfigKey | ParsedSummarizerConfigKey | ParsedUpdatesConfigKey | ParsedMenubarConfigKey | ParsedLeadConfigKey;
|
|
56
|
-
export type DeviceConfigProperty = 'role' | 'max-agents' | 'daemon' | '
|
|
56
|
+
export type DeviceConfigProperty = 'role' | 'max-agents' | 'daemon' | 'tmux' | 'browser.remote-control' | 'browser.task-idle-minutes' | 'notes' | 'browser.profile' | 'browser.viewer' | 'formFactor';
|
|
57
57
|
export declare function formatAgentVersion(agent: AgentId, version: string): string;
|
|
58
58
|
export declare function parseConfigKey(key: string): ParsedConfigKey;
|
|
59
59
|
export declare function formatConfigKey(parsed: ParsedConfigKey): string;
|
package/dist/lib/config-keys.js
CHANGED
|
@@ -54,7 +54,6 @@ const DEVICE_CONFIG_PROPERTIES = [
|
|
|
54
54
|
'role',
|
|
55
55
|
'max-agents',
|
|
56
56
|
'daemon',
|
|
57
|
-
'watchdog',
|
|
58
57
|
'tmux',
|
|
59
58
|
'browser.remote-control',
|
|
60
59
|
'browser.task-idle-minutes',
|
|
@@ -139,7 +138,7 @@ export function parseConfigKey(key) {
|
|
|
139
138
|
}
|
|
140
139
|
return { scope: 'updates', agent: agentPart, property: 'auto' };
|
|
141
140
|
}
|
|
142
|
-
const deviceMatch = raw.match(/^devices\.(.+)\.(role|max-agents|daemon|
|
|
141
|
+
const deviceMatch = raw.match(/^devices\.(.+)\.(role|max-agents|daemon|tmux|notes|formFactor|browser\.remote-control|browser\.task-idle-minutes|browser\.profile|browser\.viewer|computer\.host)$/);
|
|
143
142
|
if (deviceMatch) {
|
|
144
143
|
return {
|
|
145
144
|
scope: 'device',
|
|
@@ -229,8 +228,6 @@ export function devicePropertyToConfigName(property) {
|
|
|
229
228
|
return 'agents.max-concurrent';
|
|
230
229
|
case 'daemon':
|
|
231
230
|
return 'daemon.enabled';
|
|
232
|
-
case 'watchdog':
|
|
233
|
-
return 'watchdog.enabled';
|
|
234
231
|
case 'tmux':
|
|
235
232
|
return 'tmux.enabled';
|
|
236
233
|
case 'browser.remote-control':
|
|
@@ -526,12 +526,11 @@ export function assertTestDaemonHome(daemonDir = getDaemonDir(), testHome = proc
|
|
|
526
526
|
}
|
|
527
527
|
export async function runDaemon() {
|
|
528
528
|
assertTestDaemonHome();
|
|
529
|
-
const [{ SessionIndexService }, { SessionSummarizerService }, { SessionTitleService }, { AccountUsageService, AccountAuthService }, {
|
|
529
|
+
const [{ SessionIndexService }, { SessionSummarizerService }, { SessionTitleService }, { AccountUsageService, AccountAuthService }, { DeviceProbeService }, { SelfHealService }, { SelfUpdateService }, { HarnessUpdateService }, { AuthSyncService }, { UsageSyncService }, { StateDirCheckService }, { SessionStateService }, { FeedStreamService }, { AttentionNotifyService }, { RecordingsService }, { HeartbeatService }, { TmuxReapService },] = await Promise.all([
|
|
530
530
|
import('./session-index-service.js'),
|
|
531
531
|
import('./session-summarizer-service.js'),
|
|
532
532
|
import('./session-title-service.js'),
|
|
533
533
|
import('./account-state-daemon-service.js'),
|
|
534
|
-
import('./watchdog-service.js'),
|
|
535
534
|
import('./device-probe-service.js'),
|
|
536
535
|
import('./self-heal-service.js'),
|
|
537
536
|
import('./self-update-service.js'),
|
|
@@ -653,10 +652,6 @@ export async function runDaemon() {
|
|
|
653
652
|
supervisor.register(new SessionTitleService());
|
|
654
653
|
else
|
|
655
654
|
log('INFO', 'Session-title service disabled');
|
|
656
|
-
if (isEnabled('watchdog'))
|
|
657
|
-
supervisor.register(new WatchdogService());
|
|
658
|
-
else
|
|
659
|
-
log('INFO', 'Watchdog service disabled');
|
|
660
655
|
if (isEnabled('device-probe'))
|
|
661
656
|
supervisor.register(new DeviceProbeService());
|
|
662
657
|
else
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type LogLevel } from './daemon/diagnostics.js';
|
|
2
|
-
export type DaemonServiceId = 'self-heal' | 'self-update' | 'account-state' | 'account-auth' | '
|
|
2
|
+
export type DaemonServiceId = 'self-heal' | 'self-update' | 'account-state' | 'account-auth' | 'device-probe' | 'state-dir-check' | 'session-index' | 'session-title' | 'auth-sync' | 'usage-sync' | 'daemon-heartbeat' | 'tmux-reap' | 'session-state' | 'feed-stream' | 'session-summarizer' | 'attention-notify' | 'recordings' | 'harness-update';
|
|
3
3
|
interface DaemonServiceDef {
|
|
4
4
|
id: DaemonServiceId;
|
|
5
5
|
title: string;
|
|
@@ -25,11 +25,6 @@ export const DAEMON_SERVICES = [
|
|
|
25
25
|
title: 'Account auth refresh',
|
|
26
26
|
description: 'Publishes this host\'s fleet-status row and refreshes auth health on its own slower tick (PHNX-3608: independent circuit breaker from account-state).',
|
|
27
27
|
},
|
|
28
|
-
{
|
|
29
|
-
id: 'watchdog',
|
|
30
|
-
title: 'Watchdog',
|
|
31
|
-
description: 'Nudges stalled agent sessions on this host when opted in via watchdog.enabled.',
|
|
32
|
-
},
|
|
33
28
|
{
|
|
34
29
|
id: 'device-probe',
|
|
35
30
|
title: 'Device probe',
|
|
@@ -172,20 +172,11 @@ export const CONFIG_KEYS = [
|
|
|
172
172
|
visibility: 'machine',
|
|
173
173
|
type: 'bool',
|
|
174
174
|
defaultValue: true,
|
|
175
|
-
description: 'Whether the daemon may run on this device at all (
|
|
175
|
+
description: 'Whether the daemon may run on this device at all (session/usage sync, the feed stream, and the ' +
|
|
176
176
|
'other daemon services). Disabling is the top-level kill switch: nothing auto-starts the daemon while it ' +
|
|
177
|
-
'is set, including `feed watch
|
|
177
|
+
'is set, including `feed watch` and `recordings`. ' +
|
|
178
178
|
'`agents daemon start` still starts it explicitly.',
|
|
179
179
|
},
|
|
180
|
-
{
|
|
181
|
-
name: 'watchdog.enabled',
|
|
182
|
-
yamlKey: 'watchdogEnabled',
|
|
183
|
-
scope: 'device',
|
|
184
|
-
visibility: 'shared',
|
|
185
|
-
type: 'bool',
|
|
186
|
-
defaultValue: false,
|
|
187
|
-
description: 'Whether the daemon runs the watchdog pass on this device.',
|
|
188
|
-
},
|
|
189
180
|
{
|
|
190
181
|
name: 'tmux.enabled',
|
|
191
182
|
yamlKey: 'tmuxEnabled',
|
package/dist/lib/feed/answer.js
CHANGED
|
@@ -9,6 +9,7 @@ import { shellQuote, sshExecAsync, SSH_CONN_FAILURE_CODE, SSH_TIMEOUT_KILL_GRACE
|
|
|
9
9
|
import { blockGeneration, blockIdForSession, confirmAnswerResolution, getAnswerRecord, latestMessageReceipt, publishBlock, readBlock, readResolution, recordAnswer, recordMessageReceipt, rollbackAnswerClaim, } from './feed.js';
|
|
10
10
|
import { reconcileAttention } from './attention.js';
|
|
11
11
|
import { readPullRequestStatus } from './pr-status.js';
|
|
12
|
+
import { deliverToTab } from './tab-delivery.js';
|
|
12
13
|
import { getAgentsInvocation } from '../daemon/daemon.js';
|
|
13
14
|
export const ANSWER_DEADLINE_MS = 20_000;
|
|
14
15
|
export const PR_ENRICHMENT_BUDGET_MS = 4_000;
|
|
@@ -272,11 +273,32 @@ async function deliverInject(route, block, answer, claimedAt, operator, origin,
|
|
|
272
273
|
}
|
|
273
274
|
return { receipt: { msgId: `inject-${block.blockId}-${claimedAt}`, status: 'queued', at: new Date().toISOString(), from: operator.label, ...origin } };
|
|
274
275
|
}
|
|
276
|
+
async function deliverTab(route, block, session, operator, origin, deadline, feedRoot) {
|
|
277
|
+
const result = await deliverToTab({
|
|
278
|
+
sessionId: block.sessionId,
|
|
279
|
+
text: route.payload,
|
|
280
|
+
enter: route.enter ?? true,
|
|
281
|
+
transcript: session?.sessionFile,
|
|
282
|
+
root: feedRoot,
|
|
283
|
+
timeoutMs: Math.max(0, remainingMs(deadline) - 500),
|
|
284
|
+
});
|
|
285
|
+
if (!result.delivered) {
|
|
286
|
+
if (!result.touched)
|
|
287
|
+
throw new AnswerError(`${result.reason} Nothing reached the session, so the answer can be sent again.`, 'rail_failed');
|
|
288
|
+
throw new AnswerUnknownError(result.reason);
|
|
289
|
+
}
|
|
290
|
+
return { receipt: { msgId: result.id, status: 'consumed', at: new Date().toISOString(), from: operator.label, ...origin } };
|
|
291
|
+
}
|
|
275
292
|
function preflightRoute(route, answer, attentionKey) {
|
|
276
293
|
if (route.kind === 'refuse')
|
|
277
294
|
throw new AnswerError(route.reason, 'refused');
|
|
278
295
|
if (route.kind === 'mailbox' || route.kind === 'resume')
|
|
279
296
|
return;
|
|
297
|
+
if (route.kind === 'tab') {
|
|
298
|
+
if (route.payload == null)
|
|
299
|
+
throw new AnswerError(`Incomplete tab reply rail for '${attentionKey}'.`, 'refused');
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
280
302
|
if (!route.inject || route.payload == null)
|
|
281
303
|
throw new AnswerError(`Incomplete ${route.kind} reply rail.`, 'refused');
|
|
282
304
|
if (isMultilineFreeText(route, answer) && !backendCarriesPaste(route.inject.backend)) {
|
|
@@ -366,7 +388,9 @@ export async function claimAndRouteAttentionAnswer(input) {
|
|
|
366
388
|
? deliverMailbox(block, answer, input.operator, outcome.adopted, origin, input.mailboxRoot)
|
|
367
389
|
: route.kind === 'resume'
|
|
368
390
|
? deliverResume(route, block, claim.answeredAt, input.operator, input.attentionKey, deadline, origin)
|
|
369
|
-
:
|
|
391
|
+
: route.kind === 'tab'
|
|
392
|
+
? deliverTab(route, block, session, input.operator, origin, deadline, input.feedRoot)
|
|
393
|
+
: deliverInject(route, block, answer, claim.answeredAt, input.operator, origin, deadline), deadline, `Delivering '${input.attentionKey}' over ${route.kind}`);
|
|
370
394
|
}
|
|
371
395
|
catch (error) {
|
|
372
396
|
if (error instanceof AnswerError) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ActiveSession } from '../session/active.js';
|
|
2
|
+
import type { TurnVerdict } from '../session/hook-sessions.js';
|
|
2
3
|
import { type AttentionResolution, type AttentionSource, type AttentionState, type BlockOption, type BlockQuestion, type OpenBlock, type SourceCursor } from './feed.js';
|
|
3
4
|
export type AttentionKind = 'question' | 'permission' | 'plan_review' | 'declared' | 'failure' | 'stall' | 'review' | 'unverified';
|
|
4
5
|
export type ReplyCapability = 'terminal' | 'tmux' | 'cloud' | 'team' | 'none';
|
|
@@ -26,6 +27,12 @@ export interface AttentionItem {
|
|
|
26
27
|
sourceCursor?: SourceCursor;
|
|
27
28
|
urgency: AttentionUrgency;
|
|
28
29
|
urgencyReason?: string;
|
|
30
|
+
draft?: {
|
|
31
|
+
text?: string;
|
|
32
|
+
choiceId?: string;
|
|
33
|
+
label: string;
|
|
34
|
+
at: string;
|
|
35
|
+
};
|
|
29
36
|
}
|
|
30
37
|
export interface PullRequestAttentionSignal {
|
|
31
38
|
number: number;
|
|
@@ -41,6 +48,7 @@ type UnrankedAttentionItem = Omit<AttentionItem, 'urgency' | 'urgencyReason'>;
|
|
|
41
48
|
export declare function attentionFingerprint(kind: AttentionKind, question?: BlockQuestion): string;
|
|
42
49
|
export declare function harnessOf(session: Partial<Pick<ActiveSession, 'harness' | 'kind'>>): string;
|
|
43
50
|
export declare const UNVERIFIED_PROMPT_AGE_MS: number;
|
|
51
|
+
export declare function currentTurnVerdict(session: ActiveSession): TurnVerdict | undefined;
|
|
44
52
|
export declare function attentionUrgency(item: UnrankedAttentionItem, ticket?: {
|
|
45
53
|
id: string;
|
|
46
54
|
priority?: number;
|