shellpuppet 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -18
- package/dist/agents/agy/index.d.ts +2 -0
- package/dist/agents/agy/index.js +11 -0
- package/dist/agents/agy/index.js.map +1 -0
- package/dist/agents/agy/nudge.d.ts +2 -0
- package/dist/agents/agy/nudge.js +29 -0
- package/dist/agents/agy/nudge.js.map +1 -0
- package/dist/agents/agy/reading.d.ts +2 -0
- package/dist/agents/agy/reading.js +28 -0
- package/dist/agents/agy/reading.js.map +1 -0
- package/dist/agents/barNudge.d.ts +9 -0
- package/dist/agents/barNudge.js +21 -0
- package/dist/agents/barNudge.js.map +1 -0
- package/dist/agents/claude/index.d.ts +2 -0
- package/dist/agents/claude/index.js +31 -0
- package/dist/agents/claude/index.js.map +1 -0
- package/dist/agents/claude/liveResumeId.d.ts +6 -0
- package/dist/agents/claude/liveResumeId.js +101 -0
- package/dist/agents/claude/liveResumeId.js.map +1 -0
- package/dist/agents/claude/nudge.d.ts +2 -0
- package/dist/agents/claude/nudge.js +38 -0
- package/dist/agents/claude/nudge.js.map +1 -0
- package/dist/agents/claude/prompts.d.ts +9 -0
- package/dist/agents/claude/prompts.js +16 -0
- package/dist/agents/claude/prompts.js.map +1 -0
- package/dist/agents/claude/reading.d.ts +2 -0
- package/dist/agents/claude/reading.js +25 -0
- package/dist/agents/claude/reading.js.map +1 -0
- package/dist/agents/codex/draft.d.ts +3 -0
- package/dist/agents/codex/draft.js +88 -0
- package/dist/agents/codex/draft.js.map +1 -0
- package/dist/agents/codex/index.d.ts +2 -0
- package/dist/agents/codex/index.js +30 -0
- package/dist/agents/codex/index.js.map +1 -0
- package/dist/agents/codex/lineBreaks.d.ts +6 -0
- package/dist/agents/codex/lineBreaks.js +105 -0
- package/dist/agents/codex/lineBreaks.js.map +1 -0
- package/dist/agents/codex/nudge.d.ts +2 -0
- package/dist/agents/codex/nudge.js +34 -0
- package/dist/agents/codex/nudge.js.map +1 -0
- package/dist/agents/codex/prompts.d.ts +9 -0
- package/dist/agents/codex/prompts.js +14 -0
- package/dist/agents/codex/prompts.js.map +1 -0
- package/dist/agents/codex/reading.d.ts +2 -0
- package/dist/agents/codex/reading.js +22 -0
- package/dist/agents/codex/reading.js.map +1 -0
- package/dist/agents/generic/index.d.ts +3 -0
- package/dist/agents/generic/index.js +9 -0
- package/dist/agents/generic/index.js.map +1 -0
- package/dist/agents/generic/prompts.d.ts +2 -0
- package/dist/agents/generic/prompts.js +10 -0
- package/dist/agents/generic/prompts.js.map +1 -0
- package/dist/agents/grok/actionBox.d.ts +13 -0
- package/dist/agents/grok/actionBox.js +127 -0
- package/dist/agents/grok/actionBox.js.map +1 -0
- package/dist/agents/grok/index.d.ts +2 -0
- package/dist/agents/grok/index.js +20 -0
- package/dist/agents/grok/index.js.map +1 -0
- package/dist/agents/grok/nudge.d.ts +2 -0
- package/dist/agents/grok/nudge.js +81 -0
- package/dist/agents/grok/nudge.js.map +1 -0
- package/dist/agents/grok/prompts.d.ts +4 -0
- package/dist/agents/grok/prompts.js +89 -0
- package/dist/agents/grok/prompts.js.map +1 -0
- package/dist/agents/grok/reading.d.ts +2 -0
- package/dist/agents/grok/reading.js +49 -0
- package/dist/agents/grok/reading.js.map +1 -0
- package/dist/agents/grok/readingRules.d.ts +2 -0
- package/dist/agents/grok/readingRules.js +44 -0
- package/dist/agents/grok/readingRules.js.map +1 -0
- package/dist/agents/hermes/frame.d.ts +25 -0
- package/dist/agents/hermes/frame.js +145 -0
- package/dist/agents/hermes/frame.js.map +1 -0
- package/dist/agents/hermes/index.d.ts +2 -0
- package/dist/agents/hermes/index.js +20 -0
- package/dist/agents/hermes/index.js.map +1 -0
- package/dist/agents/hermes/nudge.d.ts +5 -0
- package/dist/agents/hermes/nudge.js +76 -0
- package/dist/agents/hermes/nudge.js.map +1 -0
- package/dist/agents/hermes/prompts.d.ts +7 -0
- package/dist/agents/hermes/prompts.js +101 -0
- package/dist/agents/hermes/prompts.js.map +1 -0
- package/dist/agents/hermes/reading.d.ts +7 -0
- package/dist/agents/hermes/reading.js +102 -0
- package/dist/agents/hermes/reading.js.map +1 -0
- package/dist/agents/index.d.ts +28 -0
- package/dist/agents/index.js +48 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/input.d.ts +2 -0
- package/dist/agents/input.js +9 -0
- package/dist/agents/input.js.map +1 -0
- package/dist/agents/mimo/index.d.ts +2 -0
- package/dist/agents/mimo/index.js +13 -0
- package/dist/agents/mimo/index.js.map +1 -0
- package/dist/agents/mimo/nudge.d.ts +3 -0
- package/dist/agents/mimo/nudge.js +60 -0
- package/dist/agents/mimo/nudge.js.map +1 -0
- package/dist/agents/mimo/prompts.d.ts +2 -0
- package/dist/agents/mimo/prompts.js +40 -0
- package/dist/agents/mimo/prompts.js.map +1 -0
- package/dist/agents/mimo/reading.d.ts +2 -0
- package/dist/agents/mimo/reading.js +31 -0
- package/dist/agents/mimo/reading.js.map +1 -0
- package/dist/agents/mimo/readingRules.d.ts +2 -0
- package/dist/agents/mimo/readingRules.js +79 -0
- package/dist/agents/mimo/readingRules.js.map +1 -0
- package/dist/agents/mimo/stalls.d.ts +2 -0
- package/dist/agents/mimo/stalls.js +81 -0
- package/dist/agents/mimo/stalls.js.map +1 -0
- package/dist/agents/muse/index.d.ts +2 -0
- package/dist/agents/muse/index.js +20 -0
- package/dist/agents/muse/index.js.map +1 -0
- package/dist/agents/muse/input.d.ts +3 -0
- package/dist/agents/muse/input.js +7 -0
- package/dist/agents/muse/input.js.map +1 -0
- package/dist/agents/muse/nudge.d.ts +2 -0
- package/dist/agents/muse/nudge.js +33 -0
- package/dist/agents/muse/nudge.js.map +1 -0
- package/dist/agents/muse/prompts.d.ts +14 -0
- package/dist/agents/muse/prompts.js +132 -0
- package/dist/agents/muse/prompts.js.map +1 -0
- package/dist/agents/muse/reading.d.ts +2 -0
- package/dist/agents/muse/reading.js +33 -0
- package/dist/agents/muse/reading.js.map +1 -0
- package/dist/agents/muse/readingRules.d.ts +2 -0
- package/dist/agents/muse/readingRules.js +49 -0
- package/dist/agents/muse/readingRules.js.map +1 -0
- package/dist/agents/nudgeReading.d.ts +74 -0
- package/dist/agents/nudgeReading.js +252 -0
- package/dist/agents/nudgeReading.js.map +1 -0
- package/dist/agents/opencode/index.d.ts +2 -0
- package/dist/agents/opencode/index.js +21 -0
- package/dist/agents/opencode/index.js.map +1 -0
- package/dist/agents/opencode/nudge.d.ts +6 -0
- package/dist/agents/opencode/nudge.js +189 -0
- package/dist/agents/opencode/nudge.js.map +1 -0
- package/dist/agents/opencode/prompts.d.ts +6 -0
- package/dist/agents/opencode/prompts.js +198 -0
- package/dist/agents/opencode/prompts.js.map +1 -0
- package/dist/agents/opencode/reading.d.ts +2 -0
- package/dist/agents/opencode/reading.js +29 -0
- package/dist/agents/opencode/reading.js.map +1 -0
- package/dist/agents/opencode/stalls.d.ts +3 -0
- package/dist/agents/opencode/stalls.js +14 -0
- package/dist/agents/opencode/stalls.js.map +1 -0
- package/dist/agents/qoder/index.d.ts +2 -0
- package/dist/agents/qoder/index.js +12 -0
- package/dist/agents/qoder/index.js.map +1 -0
- package/dist/agents/qoder/nudge.d.ts +2 -0
- package/dist/agents/qoder/nudge.js +16 -0
- package/dist/agents/qoder/nudge.js.map +1 -0
- package/dist/agents/qoder/prompts.d.ts +2 -0
- package/dist/agents/qoder/prompts.js +6 -0
- package/dist/agents/qoder/prompts.js.map +1 -0
- package/dist/agents/qoder/reading.d.ts +2 -0
- package/dist/agents/qoder/reading.js +41 -0
- package/dist/agents/qoder/reading.js.map +1 -0
- package/dist/agents/types.d.ts +202 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/cli/index.js +220 -21
- package/dist/cli/index.js.map +1 -1
- package/dist/client/http.d.ts +8 -2
- package/dist/client/http.js +179 -56
- package/dist/client/http.js.map +1 -1
- package/dist/core/cron.d.ts +6 -0
- package/dist/core/cron.js +63 -0
- package/dist/core/cron.js.map +1 -0
- package/dist/core/dialogs.d.ts +2 -4
- package/dist/core/dialogs.js +6 -12
- package/dist/core/dialogs.js.map +1 -1
- package/dist/core/environment.d.ts +6 -0
- package/dist/core/environment.js +35 -0
- package/dist/core/environment.js.map +1 -0
- package/dist/core/mailbox.d.ts +223 -0
- package/dist/core/mailbox.js +549 -0
- package/dist/core/mailbox.js.map +1 -0
- package/dist/core/manager.d.ts +4 -0
- package/dist/core/manager.js +40 -2
- package/dist/core/manager.js.map +1 -1
- package/dist/core/messageText.d.ts +2 -0
- package/dist/core/messageText.js +6 -0
- package/dist/core/messageText.js.map +1 -0
- package/dist/core/nudge.d.ts +37 -0
- package/dist/core/nudge.js +60 -0
- package/dist/core/nudge.js.map +1 -0
- package/dist/core/promptDetector.d.ts +14 -12
- package/dist/core/promptDetector.js +115 -363
- package/dist/core/promptDetector.js.map +1 -1
- package/dist/core/promptText.d.ts +1 -0
- package/dist/core/promptText.js +4 -0
- package/dist/core/promptText.js.map +1 -0
- package/dist/core/readiness.d.ts +14 -0
- package/dist/core/readiness.js +95 -0
- package/dist/core/readiness.js.map +1 -0
- package/dist/core/reasoning.d.ts +68 -7
- package/dist/core/reasoning.js +584 -328
- package/dist/core/reasoning.js.map +1 -1
- package/dist/core/renderer.d.ts +63 -3
- package/dist/core/renderer.js +370 -42
- package/dist/core/renderer.js.map +1 -1
- package/dist/core/selection.d.ts +1 -1
- package/dist/core/selection.js +3 -3
- package/dist/core/selection.js.map +1 -1
- package/dist/core/session.d.ts +175 -13
- package/dist/core/session.js +1030 -93
- package/dist/core/session.js.map +1 -1
- package/dist/core/stringWidth.d.ts +2 -0
- package/dist/core/stringWidth.js +13 -0
- package/dist/core/stringWidth.js.map +1 -0
- package/dist/core/types.d.ts +62 -4
- package/dist/core/types.js +41 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/waiter.d.ts +9 -2
- package/dist/core/waiter.js +35 -10
- package/dist/core/waiter.js.map +1 -1
- package/dist/daemon/audit.d.ts +1 -1
- package/dist/daemon/audit.js +2 -1
- package/dist/daemon/audit.js.map +1 -1
- package/dist/daemon/config.d.ts +44 -0
- package/dist/daemon/config.js +166 -4
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/folderPicker.js +21 -2
- package/dist/daemon/folderPicker.js.map +1 -1
- package/dist/daemon/homeOwner.d.ts +15 -0
- package/dist/daemon/homeOwner.js +106 -0
- package/dist/daemon/homeOwner.js.map +1 -0
- package/dist/daemon/index.js +14 -6
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/launchProfiles.d.ts +5 -0
- package/dist/daemon/launchProfiles.js +54 -48
- package/dist/daemon/launchProfiles.js.map +1 -1
- package/dist/daemon/logger.js +1 -1
- package/dist/daemon/logger.js.map +1 -1
- package/dist/daemon/nudgeScheduler.d.ts +21 -0
- package/dist/daemon/nudgeScheduler.js +61 -0
- package/dist/daemon/nudgeScheduler.js.map +1 -0
- package/dist/daemon/paths.d.ts +20 -16
- package/dist/daemon/paths.js +181 -50
- package/dist/daemon/paths.js.map +1 -1
- package/dist/daemon/restartHold.js +16 -15
- package/dist/daemon/restartHold.js.map +1 -1
- package/dist/daemon/restartSource.d.ts +7 -0
- package/dist/daemon/restartSource.js +89 -0
- package/dist/daemon/restartSource.js.map +1 -0
- package/dist/daemon/schedules.d.ts +57 -0
- package/dist/daemon/schedules.js +181 -0
- package/dist/daemon/schedules.js.map +1 -0
- package/dist/daemon/screenshot.d.ts +4 -1
- package/dist/daemon/screenshot.js +45 -7
- package/dist/daemon/screenshot.js.map +1 -1
- package/dist/daemon/server.d.ts +82 -13
- package/dist/daemon/server.js +1737 -330
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/sessionFeed.js +4 -1
- package/dist/daemon/sessionFeed.js.map +1 -1
- package/dist/daemon/viewerLauncher.js +3 -2
- package/dist/daemon/viewerLauncher.js.map +1 -1
- package/dist/daemon/wrappedLaunch.d.ts +1 -0
- package/dist/daemon/wrappedLaunch.js +38 -0
- package/dist/daemon/wrappedLaunch.js.map +1 -0
- package/dist/daemon/wrappedStart.d.ts +13 -0
- package/dist/daemon/wrappedStart.js +113 -0
- package/dist/daemon/wrappedStart.js.map +1 -0
- package/dist/daemon/wrappedSupervisor.d.ts +1 -0
- package/dist/daemon/wrappedSupervisor.js +55 -0
- package/dist/daemon/wrappedSupervisor.js.map +1 -0
- package/dist/mcp/config.js +2 -1
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/index.js +28 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +21 -1
- package/dist/mcp/tools.js +216 -29
- package/dist/mcp/tools.js.map +1 -1
- package/dist/viewer/dashboard-folders.js +7 -1
- package/dist/viewer/dashboard-layout.js +6 -52
- package/dist/viewer/dashboard.css +20 -4
- package/dist/viewer/dashboard.html +12 -3
- package/dist/viewer/dashboard.js +549 -382
- package/dist/viewer/pane.js +744 -136
- package/dist/viewer/viewer.css +1 -1
- package/dist/viewer/viewer.js +3 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -11,11 +11,14 @@
|
|
|
11
11
|
* match, or find found nothing.
|
|
12
12
|
*/
|
|
13
13
|
import { writeFile } from 'node:fs/promises';
|
|
14
|
+
import { readFileSync } from 'node:fs';
|
|
14
15
|
import { resolve } from 'node:path';
|
|
15
16
|
import process from 'node:process';
|
|
17
|
+
import { createInterface } from 'node:readline';
|
|
16
18
|
import { DaemonGoneError, daemonStartMode, discoverDaemon, ensureDaemon, request, waitForPendingDaemon, withDaemonStartLock } from '../client/http.js';
|
|
17
19
|
import { assertNodeVersion, packageVersion } from '../daemon/meta.js';
|
|
18
20
|
import { NO_MATCHES } from '../core/find.js';
|
|
21
|
+
import { visibleMessageText } from '../core/messageText.js';
|
|
19
22
|
import { resultRefusal } from '../core/reasoning.js';
|
|
20
23
|
import { inspectDaemonState, readDaemonState, shellpuppetHome } from '../daemon/paths.js';
|
|
21
24
|
import { clearRestartHold, readRestartHold, writeRestartHold } from '../daemon/restartHold.js';
|
|
@@ -23,14 +26,26 @@ import { planPassedEnv } from '../mcp/config.js';
|
|
|
23
26
|
import { isEnvNamesProblem, readDaemonConfig } from '../daemon/config.js';
|
|
24
27
|
import { agentNameFor } from '../core/reasoning.js';
|
|
25
28
|
import { knownKeys } from '../core/keys.js';
|
|
26
|
-
import { listedState } from '../core/types.js';
|
|
29
|
+
import { listedState, stallLine, startReadyLine, SESSION_IDENTITY_ENV_NAMES, SESSION_IDENTITY_ENV_RULE } from '../core/types.js';
|
|
27
30
|
import { installDesktopShortcut, uninstallDesktopShortcut, userShortcutOptions } from './desktopShortcut.js';
|
|
28
31
|
const USAGE = `ShellPuppet: drive a real terminal session; humans watch and type via the viewer.
|
|
29
32
|
|
|
30
33
|
Usage:
|
|
34
|
+
shellpuppet previous [--json] Read sessions saved before a daemon restart
|
|
35
|
+
shellpuppet schedule list [--json] List scheduled prompts and their last outcomes
|
|
36
|
+
shellpuppet launch <profile> [--name NAME] [--folder NAME] [--root-index N] [--folder-path PATH] [--resume-id ID]
|
|
31
37
|
shellpuppet start [options] <command> [args...] Launch a program in a new session
|
|
32
38
|
--label <s> --purpose <s> --cols <n> --rows <n> --cwd <dir>
|
|
33
39
|
--ready-text <s> --ready-quiet <ms> --no-shell --hold --agent <name>
|
|
40
|
+
--wait-ready --ready-timeout <ms>
|
|
41
|
+
Pass --wait-ready when starting an agent CLI to delegate work to. It uses
|
|
42
|
+
its known ready signals, or your --ready-text/--ready-quiet override.
|
|
43
|
+
Returns for readiness, a question needing an answer, exit or timeout.
|
|
44
|
+
--ready-timeout defaults to 30000 ms, capped at 300000. A longer wait
|
|
45
|
+
needs a longer caller budget, including startup overhead. If the caller
|
|
46
|
+
gives up, it may lose the answer; the session still exists in list.
|
|
47
|
+
Readiness is tracked for up to five minutes from start. Unknown programs
|
|
48
|
+
need an explicit condition. Without --wait-ready, start returns without waiting.
|
|
34
49
|
--env-name <NAME> (repeatable) --no-viewer
|
|
35
50
|
--no-viewer opens no dashboard or viewer window, for a short scripted session nobody
|
|
36
51
|
needs to watch; viewer-url still gives a link to it.
|
|
@@ -61,8 +76,11 @@ Usage:
|
|
|
61
76
|
Options go BEFORE the command; everything after the command is passed
|
|
62
77
|
to the daemon unchanged (so its own --flags survive).
|
|
63
78
|
shellpuppet list [--waiting] [--hide-reasoning] List sessions, or only waiting prompts
|
|
64
|
-
shellpuppet snap <id> [--last <n>] [--hide-reasoning]
|
|
79
|
+
shellpuppet snap <id> [--last <n>] [--hide-reasoning] [--wider COLSxROWS] [--wider-timeout <ms>]
|
|
65
80
|
Print the rendered screen
|
|
81
|
+
--wider temporarily enlarges the grid, waits 250 ms of quiet (at most
|
|
82
|
+
1500 ms by default), reads, then restores its size and controller.
|
|
83
|
+
--wider-timeout sets the redraw cap from 250 to 30000 ms.
|
|
66
84
|
--hide-reasoning leaves out an agent CLI's reasoning, each block as one
|
|
67
85
|
"[reasoning hidden: N lines]" line; a session whose agent has no
|
|
68
86
|
signature is refused (exit 2), never printed unfiltered.
|
|
@@ -71,24 +89,29 @@ Usage:
|
|
|
71
89
|
reasoning. --hide-reasoning is accepted but changes nothing: result
|
|
72
90
|
always leaves reasoning out. Exits 3, with the reason on stderr, while
|
|
73
91
|
the agent is still working or when no answer is recognised.
|
|
74
|
-
shellpuppet type <id> <text> [--enter] [--verify] Type text
|
|
75
|
-
for
|
|
92
|
+
shellpuppet type <id> <text> [--enter] [--verify] Type text; --enter sends the text,
|
|
93
|
+
waits for its painted draft and a quiet
|
|
94
|
+
screen, then checks again before Enter.
|
|
95
|
+
If the draft is absent, Enter is not sent.
|
|
96
|
+
--verify re-reads the screen.
|
|
76
97
|
shellpuppet key <id> <name> Press a key (enter, escape, ctrl+c, f1…)
|
|
77
|
-
shellpuppet wait <id> [--text <s>|--regex <r>|--quiet <ms>|--prompt]
|
|
98
|
+
shellpuppet wait <id> [--text <s>|--regex <r>|--quiet <ms>|--prompt|--stalled]
|
|
78
99
|
[--timeout <ms>] [--debounce <ms>] [--match-after-input true|false]
|
|
79
100
|
[--hide-reasoning]
|
|
80
101
|
Wait for a condition, print the screen
|
|
81
102
|
--prompt waits until the session asks a permission question
|
|
82
103
|
(the one you just answered does not count until it has been
|
|
83
104
|
seen to go; --match-after-input false accepts any prompt)
|
|
105
|
+
--stalled waits for a supported idle provider error, with
|
|
106
|
+
fixed reason and since metadata; combine with --prompt
|
|
84
107
|
--match-after-input true ignores text/regex matches at or
|
|
85
108
|
before the echo of what you last typed
|
|
86
109
|
--debounce waits for the condition to hold on every poll
|
|
87
110
|
for this many ms; a missed poll restarts it, while other
|
|
88
111
|
output such as a ticking timer does not; a match on the
|
|
89
112
|
final screen settles at once if the program exits
|
|
90
|
-
shellpuppet wait --prompt [id ...] [--now] [--timeout <ms>] [--hide-reasoning]
|
|
91
|
-
Wait for any listed session's prompt,
|
|
113
|
+
shellpuppet wait [--prompt] [--stalled] [id ...] [--now] [--timeout <ms>] [--hide-reasoning]
|
|
114
|
+
Wait for any listed session's prompt or stall,
|
|
92
115
|
or every live session if no ids are given;
|
|
93
116
|
--now polls once without waiting
|
|
94
117
|
shellpuppet find <id> <pattern> [--hide-reasoning]
|
|
@@ -123,6 +146,10 @@ Usage:
|
|
|
123
146
|
start a daemon: one that has gone is reported as not running.
|
|
124
147
|
stop: --hold [seconds] prevents auto-start for 120 s by default (1 to 600).
|
|
125
148
|
shellpuppet mcp Run the MCP stdio server (long-running)
|
|
149
|
+
shellpuppet msg send <to> <text|-> Send a message; - reads standard input
|
|
150
|
+
shellpuppet msg inbox|outbox|directory|wait Read messages and live names
|
|
151
|
+
shellpuppet msg claim <name>|release|log Manage an outside claim or inspect the log
|
|
152
|
+
shellpuppet inbox Alias for msg inbox
|
|
126
153
|
shellpuppet --version | --help
|
|
127
154
|
|
|
128
155
|
Any verb accepts --json for the raw API response.
|
|
@@ -150,7 +177,10 @@ const VALUE_FLAGS = new Set([
|
|
|
150
177
|
'cwd',
|
|
151
178
|
'ready-text',
|
|
152
179
|
'ready-quiet',
|
|
180
|
+
'ready-timeout',
|
|
153
181
|
'last',
|
|
182
|
+
'wider',
|
|
183
|
+
'wider-timeout',
|
|
154
184
|
'text',
|
|
155
185
|
'regex',
|
|
156
186
|
'quiet',
|
|
@@ -160,6 +190,11 @@ const VALUE_FLAGS = new Set([
|
|
|
160
190
|
'out',
|
|
161
191
|
'width',
|
|
162
192
|
'height',
|
|
193
|
+
'from',
|
|
194
|
+
'limit',
|
|
195
|
+
'participant',
|
|
196
|
+
'folder', 'folder-path', 'root-index', 'resume-id', 'name',
|
|
197
|
+
'mark-read',
|
|
163
198
|
]);
|
|
164
199
|
/**
|
|
165
200
|
* `stopAtFirstPositional` is how `start` avoids eating the target command's
|
|
@@ -246,6 +281,21 @@ async function call(connection, method, path, body, options = {}) {
|
|
|
246
281
|
function printJson(value) {
|
|
247
282
|
console.log(JSON.stringify(value, null, 2));
|
|
248
283
|
}
|
|
284
|
+
function printableMessages(payload) {
|
|
285
|
+
const sanitise = (entry) => {
|
|
286
|
+
if (typeof entry !== 'object' || entry === null)
|
|
287
|
+
return entry;
|
|
288
|
+
const message = entry;
|
|
289
|
+
return typeof message['text'] === 'string'
|
|
290
|
+
? { ...message, text: visibleMessageText(message['text']) } : entry;
|
|
291
|
+
};
|
|
292
|
+
return {
|
|
293
|
+
...payload,
|
|
294
|
+
...(Array.isArray(payload['messages'])
|
|
295
|
+
? { messages: payload['messages'].map(sanitise) } : {}),
|
|
296
|
+
...(Object.hasOwn(payload, 'message') ? { message: sanitise(payload['message']) } : {}),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
249
299
|
async function main() {
|
|
250
300
|
assertNodeVersion();
|
|
251
301
|
const argv = process.argv.slice(2);
|
|
@@ -289,7 +339,90 @@ async function main() {
|
|
|
289
339
|
}
|
|
290
340
|
const connection = await ensureDaemon({ logger: stderrLogger });
|
|
291
341
|
surfaceWarnings(connection);
|
|
342
|
+
if (verb === 'msg' || verb === 'inbox') {
|
|
343
|
+
const sub = verb === 'inbox' ? 'inbox' : parsed.positionals[0];
|
|
344
|
+
const params = new URLSearchParams();
|
|
345
|
+
if (parsed.flags.has('limit'))
|
|
346
|
+
params.set('limit', String(parsed.flags.get('limit')));
|
|
347
|
+
if (parsed.flags.has('from'))
|
|
348
|
+
params.set('from', String(parsed.flags.get('from')));
|
|
349
|
+
if (parsed.flags.has('timeout'))
|
|
350
|
+
params.set('timeoutMs', String(parsed.flags.get('timeout')));
|
|
351
|
+
if (parsed.flags.has('mark-read'))
|
|
352
|
+
params.set('markRead', String(parsed.flags.get('mark-read')));
|
|
353
|
+
if (parsed.flags.has('participant'))
|
|
354
|
+
params.set('participant', String(parsed.flags.get('participant')));
|
|
355
|
+
let payload;
|
|
356
|
+
if (sub === 'send') {
|
|
357
|
+
const to = parsed.positionals[1] ?? fail(2, 'msg send needs a recipient.');
|
|
358
|
+
const input = parsed.positionals[2] ?? fail(2, 'msg send needs text or -.');
|
|
359
|
+
payload = await call(connection, 'POST', '/messages', { to, text: input === '-' ? readFileSync(0, 'utf8') : input });
|
|
360
|
+
}
|
|
361
|
+
else if (sub === 'claim') {
|
|
362
|
+
const name = parsed.positionals[1] ?? fail(2, 'msg claim needs a name.');
|
|
363
|
+
payload = await call(connection, 'POST', '/messages/claims', { name });
|
|
364
|
+
if (!wantJson) {
|
|
365
|
+
const claim = `${String(payload['claimId'])}:${String(payload['secret'])}`;
|
|
366
|
+
console.log(`SHELLPUPPET_CLAIM=${claim}`);
|
|
367
|
+
console.log(`PowerShell: $env:SHELLPUPPET_CLAIM='${claim}'`);
|
|
368
|
+
console.log(`POSIX shell: export SHELLPUPPET_CLAIM='${claim}'`);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
else if (sub === 'release') {
|
|
373
|
+
const match = process.env['SHELLPUPPET_CLAIM']?.match(/^(claim_[a-f0-9]{32}):.+$/);
|
|
374
|
+
if (match === undefined || match === null)
|
|
375
|
+
fail(2, 'Set SHELLPUPPET_CLAIM before release.');
|
|
376
|
+
payload = await call(connection, 'DELETE', `/messages/claims/${match[1]}`);
|
|
377
|
+
}
|
|
378
|
+
else if (['inbox', 'outbox', 'directory', 'wait', 'log'].includes(sub ?? '')) {
|
|
379
|
+
payload = await call(connection, 'GET', `/messages/${sub}?${params.toString()}`);
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
fail(2, 'msg needs send, inbox, outbox, directory, wait, claim, release or log.');
|
|
383
|
+
}
|
|
384
|
+
printJson(['inbox', 'outbox', 'wait', 'log'].includes(sub ?? '') ? printableMessages(payload) : payload);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
292
387
|
switch (verb) {
|
|
388
|
+
case 'schedule': {
|
|
389
|
+
if (parsed.positionals.length !== 1 || parsed.positionals[0] !== 'list' || parsed.lists.size ||
|
|
390
|
+
[...parsed.flags.keys()].some(key => key !== 'json'))
|
|
391
|
+
fail(2, 'Usage: shellpuppet schedule list [--json]');
|
|
392
|
+
const payload = await call(connection, 'GET', '/schedules');
|
|
393
|
+
if (wantJson)
|
|
394
|
+
printJson(payload);
|
|
395
|
+
else {
|
|
396
|
+
const schedules = payload['schedules'];
|
|
397
|
+
if (!schedules.length)
|
|
398
|
+
console.log('No schedules configured.');
|
|
399
|
+
else {
|
|
400
|
+
console.log('Name\tSession\tCron (UTC)\tWhen busy\tEnabled\tNext run (UTC)\tLast outcome');
|
|
401
|
+
for (const row of schedules) {
|
|
402
|
+
const last = row.lastOutcome;
|
|
403
|
+
console.log([row.name, row.session, row.cron, row.whenBusy, row.enabled, row.nextRunUtc ?? '-',
|
|
404
|
+
last ? [last.outcome, last.reason, last.at].filter(Boolean).join(' ') : '-'].join('\t'));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
case 'previous':
|
|
411
|
+
printJson(await call(connection, 'GET', '/launcher/previous'));
|
|
412
|
+
return;
|
|
413
|
+
case 'launch': {
|
|
414
|
+
if (parsed.positionals.length !== 1 || parsed.lists.size || [...parsed.flags.keys()].some(key => !['json', 'name', 'folder', 'folder-path', 'root-index', 'resume-id'].includes(key))) {
|
|
415
|
+
fail(2, 'launch requires one profile and accepts only profile launch options.');
|
|
416
|
+
}
|
|
417
|
+
const payload = await call(connection, 'POST', '/launcher/launch', { profile: parsed.positionals[0],
|
|
418
|
+
name: parsed.flags.get('name'), folder: parsed.flags.get('folder'), folderPath: parsed.flags.get('folder-path'),
|
|
419
|
+
rootIndex: intFlag(parsed, 'root-index'), resumeId: parsed.flags.get('resume-id') });
|
|
420
|
+
if (wantJson)
|
|
421
|
+
printJson(payload);
|
|
422
|
+
else
|
|
423
|
+
console.log(`Started session ${String(payload['id'])} from profile ${String(payload['profile'])}.`);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
293
426
|
case 'start': {
|
|
294
427
|
const command = parsed.positionals[0];
|
|
295
428
|
if (command === undefined)
|
|
@@ -308,6 +441,8 @@ async function main() {
|
|
|
308
441
|
...(parsed.flags.has('ready-text')
|
|
309
442
|
? { readyText: String(parsed.flags.get('ready-text')) }
|
|
310
443
|
: {}),
|
|
444
|
+
...(parsed.flags.get('wait-ready') === true ? { waitReady: true } : {}),
|
|
445
|
+
...(intFlag(parsed, 'ready-timeout') !== undefined ? { readyTimeout: intFlag(parsed, 'ready-timeout') } : {}),
|
|
311
446
|
...(intFlag(parsed, 'ready-quiet') !== undefined
|
|
312
447
|
? { readyQuiet: intFlag(parsed, 'ready-quiet') }
|
|
313
448
|
: {}),
|
|
@@ -320,6 +455,9 @@ async function main() {
|
|
|
320
455
|
const daemonConfig = readDaemonConfig(shellpuppetHome());
|
|
321
456
|
const agent = agentNameFor(parsed.flags.has('agent') ? String(parsed.flags.get('agent')) : undefined, command, daemonConfig.config.agentSignatures ?? []);
|
|
322
457
|
const envNames = parsed.lists.get('env-name') ?? [];
|
|
458
|
+
const reserved = envNames.filter((name) => SESSION_IDENTITY_ENV_NAMES.has(name.toUpperCase()));
|
|
459
|
+
if (reserved.length > 0)
|
|
460
|
+
fail(2, `Not started: ${SESSION_IDENTITY_ENV_RULE} ${reserved.join(', ')}.`);
|
|
323
461
|
if (envNames.length > 0) {
|
|
324
462
|
for (const problem of daemonConfig.problems.filter(isEnvNamesProblem))
|
|
325
463
|
console.error(`warning: ${problem}`);
|
|
@@ -381,7 +519,13 @@ async function main() {
|
|
|
381
519
|
else {
|
|
382
520
|
console.log(`viewer: no window opened (--no-viewer); viewer-url ${String(result['id'])} mints a link`);
|
|
383
521
|
}
|
|
384
|
-
|
|
522
|
+
const readyWait = result['readyWait'];
|
|
523
|
+
if (readyWait !== undefined) {
|
|
524
|
+
console.log(startReadyLine(readyWait, result['exitCode'], result['readyReason']));
|
|
525
|
+
if (readyWait.prompt !== undefined)
|
|
526
|
+
console.log(JSON.stringify(readyWait.prompt, null, 2));
|
|
527
|
+
}
|
|
528
|
+
else if (result['ready'] !== true) {
|
|
385
529
|
console.log('ready: false. First paint is not readiness; wait before typing.');
|
|
386
530
|
}
|
|
387
531
|
}
|
|
@@ -413,8 +557,9 @@ async function main() {
|
|
|
413
557
|
}
|
|
414
558
|
console.log(`${s.id} ${listedState(s)} ` +
|
|
415
559
|
`${String(s.cols)}x${String(s.rows)} watchers:${String(s.watchers)} ` +
|
|
416
|
-
`${s.ready ? 'ready' : 'NOT-READY'} ${s.label}` +
|
|
417
|
-
(s.agent !== null && s.agent !== undefined ? ` agent:${s.agent}` : '')
|
|
560
|
+
`${s.stalled !== undefined ? stallLine(s.stalled) : s.ready ? 'ready' : 'NOT-READY'} ${s.label}` +
|
|
561
|
+
(s.agent !== null && s.agent !== undefined ? ` agent:${s.agent}` : '') +
|
|
562
|
+
(s.parent !== undefined ? ` parent:${s.parent}` : ''));
|
|
418
563
|
const waiting = s.waitingOnPrompt;
|
|
419
564
|
if (waiting !== undefined) {
|
|
420
565
|
console.log(` WAITING ${String(Math.round(waiting.waitingMs / 1000))}s on a prompt` +
|
|
@@ -428,12 +573,19 @@ async function main() {
|
|
|
428
573
|
case 'snap': {
|
|
429
574
|
const id = parsed.positionals[0] ?? fail(2, 'snap needs a session id.');
|
|
430
575
|
const last = intFlag(parsed, 'last');
|
|
576
|
+
const wider = parsed.flags.get('wider');
|
|
577
|
+
if (wider !== undefined && (typeof wider !== 'string' || !/^\d+x\d+$/.test(wider)))
|
|
578
|
+
fail(2, '--wider must be COLSxROWS.');
|
|
431
579
|
const query = [
|
|
432
580
|
...(last !== undefined ? [`lastLines=${String(last)}`] : []),
|
|
433
581
|
...(parsed.flags.get('hide-reasoning') === true ? ['hideReasoning=1'] : []),
|
|
582
|
+
...(wider !== undefined ? [`wider=${String(wider)}`] : []),
|
|
583
|
+
...(intFlag(parsed, 'wider-timeout') !== undefined ? [`widerTimeout=${String(intFlag(parsed, 'wider-timeout'))}`] : []),
|
|
434
584
|
];
|
|
435
585
|
const path = `/sessions/${id}/snapshot${query.length > 0 ? `?${query.join('&')}` : ''}`;
|
|
436
586
|
const result = await call(connection, 'GET', path);
|
|
587
|
+
if (result['restored'] === false)
|
|
588
|
+
console.error('Grid changed during the wider read; the original grid was not restored.');
|
|
437
589
|
if (wantJson)
|
|
438
590
|
printJson(result);
|
|
439
591
|
else if (last !== undefined)
|
|
@@ -474,6 +626,13 @@ async function main() {
|
|
|
474
626
|
});
|
|
475
627
|
if (wantJson)
|
|
476
628
|
printJson(result);
|
|
629
|
+
else if (result['submitted'] === false) {
|
|
630
|
+
console.log(String(result['message']));
|
|
631
|
+
process.exit(1);
|
|
632
|
+
}
|
|
633
|
+
else if (result['submitRetried'] === true) {
|
|
634
|
+
console.log(`typed ${String(result['bytes'])} bytes. ${String(result['message'])}`);
|
|
635
|
+
}
|
|
477
636
|
else if (result['verified'] === false) {
|
|
478
637
|
console.log('typed, but the text did NOT appear on screen. The app may still be ' +
|
|
479
638
|
'loading, a panel may have focus or, commonly with --enter, the app ' +
|
|
@@ -487,7 +646,8 @@ async function main() {
|
|
|
487
646
|
// knowing the keystrokes landed, so say so rather than printing the
|
|
488
647
|
// same line as an unverified type.
|
|
489
648
|
console.log(`typed ${String(result['bytes'])} bytes` +
|
|
490
|
-
(result['verified'] === true ? ' (verified on screen).' : '.')
|
|
649
|
+
(result['verified'] === true ? ' (verified on screen).' : '.') +
|
|
650
|
+
(typeof result['message'] === 'string' ? ` ${result['message']}` : ''));
|
|
491
651
|
}
|
|
492
652
|
break;
|
|
493
653
|
}
|
|
@@ -502,9 +662,17 @@ async function main() {
|
|
|
502
662
|
break;
|
|
503
663
|
}
|
|
504
664
|
case 'wait': {
|
|
505
|
-
const multi = parsed.flags.get('prompt') === true && (parsed.positionals.length !== 1 || parsed.flags.get('now') === true);
|
|
665
|
+
const multi = (parsed.flags.get('prompt') === true || parsed.flags.get('stalled') === true) && (parsed.positionals.length !== 1 || parsed.flags.get('now') === true);
|
|
506
666
|
if (multi) {
|
|
507
|
-
const
|
|
667
|
+
for (const name of ['text', 'regex', 'quiet', 'debounce', 'match-after-input']) {
|
|
668
|
+
if (parsed.flags.has(name))
|
|
669
|
+
fail(2, 'A multi-session wait accepts --prompt and/or --stalled, --timeout, --now and --hide-reasoning only.');
|
|
670
|
+
}
|
|
671
|
+
const params = new URLSearchParams();
|
|
672
|
+
if (parsed.flags.get('prompt') === true)
|
|
673
|
+
params.set('prompt', 'true');
|
|
674
|
+
if (parsed.flags.get('stalled') === true)
|
|
675
|
+
params.set('stalled', 'true');
|
|
508
676
|
for (const id of parsed.positionals)
|
|
509
677
|
params.append('session', id);
|
|
510
678
|
if (parsed.flags.get('now') === true)
|
|
@@ -518,6 +686,10 @@ async function main() {
|
|
|
518
686
|
printJson(result);
|
|
519
687
|
else {
|
|
520
688
|
for (const waiting of result['sessions']) {
|
|
689
|
+
if (waiting.stalled !== undefined) {
|
|
690
|
+
console.log(`${waiting.id} ${waiting.label} ${stallLine(waiting.stalled)}`);
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
521
693
|
console.log(`${waiting.id} ${waiting.label} WAITING ${String(Math.round(waiting.waitingMs / 1000))}s` + (waiting.question === undefined ? '' : `: ${waiting.question}`));
|
|
522
694
|
for (const [index, option] of (waiting.options ?? []).entries())
|
|
523
695
|
console.log(` ${index === waiting.selectedOption ? '* ' : ' '}${option}`);
|
|
@@ -530,7 +702,7 @@ async function main() {
|
|
|
530
702
|
}
|
|
531
703
|
const id = parsed.positionals[0] ?? fail(2, 'wait needs a session id.');
|
|
532
704
|
const params = new URLSearchParams();
|
|
533
|
-
for (const name of ['text', 'regex', 'quiet', 'timeout', 'debounce', 'prompt']) {
|
|
705
|
+
for (const name of ['text', 'regex', 'quiet', 'timeout', 'debounce', 'prompt', 'stalled']) {
|
|
534
706
|
const value = parsed.flags.get(name);
|
|
535
707
|
if (value !== undefined)
|
|
536
708
|
params.set(name, String(value));
|
|
@@ -551,6 +723,8 @@ async function main() {
|
|
|
551
723
|
// line.
|
|
552
724
|
if (typeof result['detail'] === 'string')
|
|
553
725
|
console.error(result['detail']);
|
|
726
|
+
if (result['stalled'] !== undefined)
|
|
727
|
+
console.error(stallLine(result['stalled']));
|
|
554
728
|
const detected = result['prompt'];
|
|
555
729
|
if (detected !== undefined) {
|
|
556
730
|
// stderr, like the outcome line: stdout stays the screen alone, so
|
|
@@ -704,11 +878,13 @@ async function daemonVerb(parsed, wantJson) {
|
|
|
704
878
|
// daemon must never start one, so a daemon that goes between being found
|
|
705
879
|
// and being asked is reported as not running.
|
|
706
880
|
const daemonOnly = { autoStart: false };
|
|
881
|
+
const shutdownWarnings = [];
|
|
882
|
+
const warningFields = () => shutdownWarnings.length ? { warnings: shutdownWarnings } : {};
|
|
707
883
|
/** Stop the daemon, or say false when it had already gone. */
|
|
708
884
|
const stopRunning = async (connection) => {
|
|
709
885
|
let response;
|
|
710
886
|
try {
|
|
711
|
-
response = await request(connection, 'POST', '/daemon/shutdown', { force }, {
|
|
887
|
+
response = await request(connection, 'POST', '/daemon/shutdown', { force, ...(sub === 'restart' || holdSeconds !== undefined ? { restart: true } : {}) }, {
|
|
712
888
|
logger: stderrLogger,
|
|
713
889
|
actor: 'cli',
|
|
714
890
|
...daemonOnly,
|
|
@@ -722,6 +898,20 @@ async function daemonVerb(parsed, wantJson) {
|
|
|
722
898
|
if (response.status === 409) {
|
|
723
899
|
fail(1, `${String(response.body['error'])} (use --force)`);
|
|
724
900
|
}
|
|
901
|
+
if (response.status >= 400) {
|
|
902
|
+
const message = response.body['error'];
|
|
903
|
+
throw new Error(typeof message === 'string' ? message : 'Daemon shutdown failed.');
|
|
904
|
+
}
|
|
905
|
+
const warnings = response.body['warnings'];
|
|
906
|
+
if (Array.isArray(warnings)) {
|
|
907
|
+
for (const warning of warnings) {
|
|
908
|
+
if (typeof warning !== 'string')
|
|
909
|
+
continue;
|
|
910
|
+
shutdownWarnings.push(warning);
|
|
911
|
+
if (!wantJson)
|
|
912
|
+
console.error(warning);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
725
915
|
// Wait for the port to actually go quiet so restart cannot race it.
|
|
726
916
|
const deadline = Date.now() + 10_000;
|
|
727
917
|
while (Date.now() < deadline) {
|
|
@@ -833,7 +1023,7 @@ async function daemonVerb(parsed, wantJson) {
|
|
|
833
1023
|
return didStop;
|
|
834
1024
|
});
|
|
835
1025
|
if (wantJson)
|
|
836
|
-
printJson({ running: false, stopped: true, holdRemainingSeconds: holdSeconds });
|
|
1026
|
+
printJson({ running: false, stopped: true, ...warningFields(), holdRemainingSeconds: holdSeconds });
|
|
837
1027
|
else
|
|
838
1028
|
console.log(stopped ? `stopped; restart hold ends in ${String(holdSeconds)} s` :
|
|
839
1029
|
`not running; restart hold ends in ${String(holdSeconds)} s`);
|
|
@@ -845,13 +1035,13 @@ async function daemonVerb(parsed, wantJson) {
|
|
|
845
1035
|
// Nothing to stop IS the outcome asked for, so it reads the same to a
|
|
846
1036
|
// script as a daemon that was stopped.
|
|
847
1037
|
if (wantJson)
|
|
848
|
-
printJson({ running: false, stopped: true });
|
|
1038
|
+
printJson({ running: false, stopped: true, ...warningFields() });
|
|
849
1039
|
else
|
|
850
1040
|
console.log('not running');
|
|
851
1041
|
return;
|
|
852
1042
|
}
|
|
853
1043
|
if (wantJson)
|
|
854
|
-
printJson({ running: false, stopped: true });
|
|
1044
|
+
printJson({ running: false, stopped: true, ...warningFields() });
|
|
855
1045
|
else
|
|
856
1046
|
console.log('stopped');
|
|
857
1047
|
return;
|
|
@@ -885,7 +1075,7 @@ async function daemonVerb(parsed, wantJson) {
|
|
|
885
1075
|
});
|
|
886
1076
|
surfaceWarnings(connection);
|
|
887
1077
|
if (wantJson) {
|
|
888
|
-
printJson({ running: true, port: connection.port, version: connection.version, startedWrapped: readDaemonState(shellpuppetHome())?.startedWrapped === true });
|
|
1078
|
+
printJson({ running: true, ...warningFields(), port: connection.port, version: connection.version, startedWrapped: readDaemonState(shellpuppetHome())?.startedWrapped === true });
|
|
889
1079
|
}
|
|
890
1080
|
else {
|
|
891
1081
|
console.log(`restarted on port ${String(connection.port)}, version ${connection.version}`);
|
|
@@ -896,7 +1086,16 @@ async function daemonVerb(parsed, wantJson) {
|
|
|
896
1086
|
fail(2, 'daemon needs one of: status, start, stop [--force] [--hold [seconds]], restart [--force]');
|
|
897
1087
|
}
|
|
898
1088
|
}
|
|
899
|
-
main().catch((error) => {
|
|
900
|
-
|
|
1089
|
+
await main().catch(async (error) => {
|
|
1090
|
+
process.exitCode = 1;
|
|
1091
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1092
|
+
if (process.argv[2] === 'desktop' && process.platform === 'win32' && process.stdout.isTTY && process.stdin.isTTY) {
|
|
1093
|
+
const input = createInterface({ input: process.stdin });
|
|
1094
|
+
console.log('See daemon.log in the ShellPuppet home. Press Enter to close.');
|
|
1095
|
+
await new Promise(resolve => {
|
|
1096
|
+
input.once('close', resolve);
|
|
1097
|
+
input.once('line', () => input.close());
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
901
1100
|
});
|
|
902
1101
|
//# sourceMappingURL=index.js.map
|