shellpuppet 0.0.1 → 0.1.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/LICENSE +202 -0
- package/NOTICE +31 -0
- package/README.md +340 -8
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.js +693 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client/http.d.ts +82 -0
- package/dist/client/http.js +225 -0
- package/dist/client/http.js.map +1 -0
- package/dist/core/dialogs.d.ts +88 -0
- package/dist/core/dialogs.js +214 -0
- package/dist/core/dialogs.js.map +1 -0
- package/dist/core/echo.d.ts +71 -0
- package/dist/core/echo.js +249 -0
- package/dist/core/echo.js.map +1 -0
- package/dist/core/find.d.ts +34 -0
- package/dist/core/find.js +41 -0
- package/dist/core/find.js.map +1 -0
- package/dist/core/keys.d.ts +22 -0
- package/dist/core/keys.js +80 -0
- package/dist/core/keys.js.map +1 -0
- package/dist/core/manager.d.ts +66 -0
- package/dist/core/manager.js +158 -0
- package/dist/core/manager.js.map +1 -0
- package/dist/core/nativePty.d.ts +69 -0
- package/dist/core/nativePty.js +156 -0
- package/dist/core/nativePty.js.map +1 -0
- package/dist/core/policy.d.ts +61 -0
- package/dist/core/policy.js +143 -0
- package/dist/core/policy.js.map +1 -0
- package/dist/core/promptDetector.d.ts +75 -0
- package/dist/core/promptDetector.js +606 -0
- package/dist/core/promptDetector.js.map +1 -0
- package/dist/core/reasoning.d.ts +252 -0
- package/dist/core/reasoning.js +740 -0
- package/dist/core/reasoning.js.map +1 -0
- package/dist/core/regexBudget.d.ts +44 -0
- package/dist/core/regexBudget.js +79 -0
- package/dist/core/regexBudget.js.map +1 -0
- package/dist/core/renderer.d.ts +112 -0
- package/dist/core/renderer.js +225 -0
- package/dist/core/renderer.js.map +1 -0
- package/dist/core/session.d.ts +311 -0
- package/dist/core/session.js +966 -0
- package/dist/core/session.js.map +1 -0
- package/dist/core/types.d.ts +281 -0
- package/dist/core/types.js +47 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/waiter.d.ts +86 -0
- package/dist/core/waiter.js +317 -0
- package/dist/core/waiter.js.map +1 -0
- package/dist/core/windowsPtyStart.d.ts +90 -0
- package/dist/core/windowsPtyStart.js +129 -0
- package/dist/core/windowsPtyStart.js.map +1 -0
- package/dist/daemon/audit.d.ts +23 -0
- package/dist/daemon/audit.js +51 -0
- package/dist/daemon/audit.js.map +1 -0
- package/dist/daemon/auth.d.ts +127 -0
- package/dist/daemon/auth.js +241 -0
- package/dist/daemon/auth.js.map +1 -0
- package/dist/daemon/config.d.ts +76 -0
- package/dist/daemon/config.js +301 -0
- package/dist/daemon/config.js.map +1 -0
- package/dist/daemon/index.d.ts +7 -0
- package/dist/daemon/index.js +87 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/liveness.d.ts +36 -0
- package/dist/daemon/liveness.js +71 -0
- package/dist/daemon/liveness.js.map +1 -0
- package/dist/daemon/logger.d.ts +7 -0
- package/dist/daemon/logger.js +29 -0
- package/dist/daemon/logger.js.map +1 -0
- package/dist/daemon/meta.d.ts +9 -0
- package/dist/daemon/meta.js +24 -0
- package/dist/daemon/meta.js.map +1 -0
- package/dist/daemon/paths.d.ts +83 -0
- package/dist/daemon/paths.js +154 -0
- package/dist/daemon/paths.js.map +1 -0
- package/dist/daemon/screenshot.d.ts +87 -0
- package/dist/daemon/screenshot.js +256 -0
- package/dist/daemon/screenshot.js.map +1 -0
- package/dist/daemon/server.d.ts +244 -0
- package/dist/daemon/server.js +2187 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/terminalReports.d.ts +38 -0
- package/dist/daemon/terminalReports.js +84 -0
- package/dist/daemon/terminalReports.js.map +1 -0
- package/dist/daemon/viewerLauncher.d.ts +135 -0
- package/dist/daemon/viewerLauncher.js +280 -0
- package/dist/daemon/viewerLauncher.js.map +1 -0
- package/dist/daemon/viewerSync.d.ts +38 -0
- package/dist/daemon/viewerSync.js +83 -0
- package/dist/daemon/viewerSync.js.map +1 -0
- package/dist/mcp/config.d.ts +57 -0
- package/dist/mcp/config.js +106 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +10 -0
- package/dist/mcp/index.js +69 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools.d.ts +59 -0
- package/dist/mcp/tools.js +537 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/viewer/icon-16.png +0 -0
- package/dist/viewer/icon-180.png +0 -0
- package/dist/viewer/icon-32.png +0 -0
- package/dist/viewer/icon-512.png +0 -0
- package/dist/viewer/icon.svg +66 -0
- package/dist/viewer/index.html +56 -0
- package/dist/viewer/viewer.css +84 -0
- package/dist/viewer/viewer.js +661 -0
- package/package.json +66 -7
- package/index.js +0 -4
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading an agent CLI's screen without its reasoning.
|
|
3
|
+
*
|
|
4
|
+
* Several agent CLIs draw the model's reasoning on screen as they work, and a
|
|
5
|
+
* supervisor reading the screen with `terminal_snapshot` takes all of it into
|
|
6
|
+
* its own context: text it did not need, and another model's reasoning it
|
|
7
|
+
* has no business collecting. This module tells the parts of a screen apart:
|
|
8
|
+
* the reasoning blocks, the answer that ends a turn, the composer and the
|
|
9
|
+
* status lines under it. `terminal_snapshot` and `terminal_find` can then
|
|
10
|
+
* leave the reasoning out (`hideReasoning`), and `terminal_result` returns
|
|
11
|
+
* the answer alone.
|
|
12
|
+
*
|
|
13
|
+
* Each program is described as data, a signature, because each draws its
|
|
14
|
+
* screen its own way. A signature says how to recognise a line by its text
|
|
15
|
+
* and by how it is drawn (bold, dim, italic, colour): reasoning is usually
|
|
16
|
+
* drawn dim or italic, an answer often starts with a bullet in the text
|
|
17
|
+
* colour while tool calls get a grey or coloured one. Every built-in
|
|
18
|
+
* signature is pinned by fixtures captured from the real program's screen
|
|
19
|
+
* (`test/fixtures/reasoning/`), and config `agents.signatures` adds or
|
|
20
|
+
* replaces one without a release.
|
|
21
|
+
*
|
|
22
|
+
* Both readers fail closed. A session whose program has no signature is
|
|
23
|
+
* refused rather than shown unfiltered, and `terminal_result` refuses when it
|
|
24
|
+
* cannot find an answer it recognises, rather than returning something else.
|
|
25
|
+
* What the filter cannot promise: a program that draws its reasoning in a
|
|
26
|
+
* shape its signature does not describe, a new version that changes the
|
|
27
|
+
* shape, or a screen that imitates one, defeats it. Screen content is
|
|
28
|
+
* untrusted input either way (design §4.4).
|
|
29
|
+
*
|
|
30
|
+
* Every pattern runs under the regular-expression time budget
|
|
31
|
+
* (`regexBudget.ts`), as patterns from config are text a person wrote.
|
|
32
|
+
*/
|
|
33
|
+
import type { StyledLine } from './renderer.js';
|
|
34
|
+
/** Conditions on how characters are drawn. Colours as in `CellStyle`, or `default`. */
|
|
35
|
+
export interface StyleTest {
|
|
36
|
+
bold?: boolean;
|
|
37
|
+
dim?: boolean;
|
|
38
|
+
italic?: boolean;
|
|
39
|
+
/** Accepted foreground colours. */
|
|
40
|
+
fg?: string[];
|
|
41
|
+
/** Foreground colours that rule the line out. */
|
|
42
|
+
notFg?: string[];
|
|
43
|
+
}
|
|
44
|
+
/** A test one line must pass. Every condition given must hold. */
|
|
45
|
+
export interface LineTest {
|
|
46
|
+
/** A regular expression the line's text must match. */
|
|
47
|
+
text?: string;
|
|
48
|
+
/** How the first character that is not a space is drawn. */
|
|
49
|
+
lead?: StyleTest;
|
|
50
|
+
/** How every character after the first, other than spaces, is drawn. */
|
|
51
|
+
body?: StyleTest;
|
|
52
|
+
/**
|
|
53
|
+
* How the first character after the lead and the space behind it is drawn:
|
|
54
|
+
* a bold heading after a bullet marks a tool call where plain text marks a
|
|
55
|
+
* message.
|
|
56
|
+
*/
|
|
57
|
+
word?: StyleTest;
|
|
58
|
+
}
|
|
59
|
+
/** A block: its first line, and the lines that belong to it. */
|
|
60
|
+
export interface BlockTest {
|
|
61
|
+
start: LineTest;
|
|
62
|
+
/**
|
|
63
|
+
* A line that continues the block. Without it, the block is its first line
|
|
64
|
+
* alone. A blank line inside a block is kept when the line after it
|
|
65
|
+
* continues the block too.
|
|
66
|
+
*/
|
|
67
|
+
continues?: LineTest;
|
|
68
|
+
/**
|
|
69
|
+
* For an answer whose paragraphs all look alike, with no first line of its
|
|
70
|
+
* own: the block also takes in the lines above that pass `start`, across
|
|
71
|
+
* blank lines, as far as the first line that does not.
|
|
72
|
+
*/
|
|
73
|
+
upward?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/** One program's screen, as data. The shape of an `agents.signatures` entry. */
|
|
76
|
+
export interface AgentSignature {
|
|
77
|
+
/** The agent's name, as `terminal_start`'s `agent` takes it. */
|
|
78
|
+
name: string;
|
|
79
|
+
/** Start commands that select it without an `agent`: `claude`, `codex`. */
|
|
80
|
+
programs: string[];
|
|
81
|
+
/** The program's version the fixtures were captured from, for the reader. */
|
|
82
|
+
measured?: string;
|
|
83
|
+
/** The composer's own line: the last line that passes is the composer. */
|
|
84
|
+
composer: LineTest;
|
|
85
|
+
/**
|
|
86
|
+
* Lines the program draws between its transcript and the composer: borders,
|
|
87
|
+
* a mode line, the line its spinner turns on. Walking up from the composer
|
|
88
|
+
* over these and over blank lines finds where the transcript ends. A walk
|
|
89
|
+
* that tests what it passes cannot swallow the answer, as a fixed count of
|
|
90
|
+
* lines would when a mode line is not drawn.
|
|
91
|
+
*/
|
|
92
|
+
chrome?: LineTest[];
|
|
93
|
+
/** Lines that belong to the frame and carry nothing, dropped from status. */
|
|
94
|
+
frame?: LineTest;
|
|
95
|
+
/** A line present only while a turn is running: an answer is not final. */
|
|
96
|
+
busy?: LineTest[];
|
|
97
|
+
/** Where a turn begins: the person's prompt as the program echoes it. */
|
|
98
|
+
turn?: LineTest;
|
|
99
|
+
/** The program's reasoning blocks. */
|
|
100
|
+
reasoning?: BlockTest[];
|
|
101
|
+
/** The answer that ends a turn. */
|
|
102
|
+
answer: BlockTest;
|
|
103
|
+
/** Lines after the answer, above the composer, that go with it: a turn summary. */
|
|
104
|
+
trailer?: LineTest;
|
|
105
|
+
/**
|
|
106
|
+
* The program always closes a finished turn with a trailer line, so a turn
|
|
107
|
+
* without one has not finished (it was interrupted, or ended without an
|
|
108
|
+
* answer): no result is given, rather than the last message before it.
|
|
109
|
+
*/
|
|
110
|
+
requireTrailer?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The composer holding text the person or an agent typed and has not sent
|
|
113
|
+
* (as opposed to its placeholder): the latest turn is about to change, so no
|
|
114
|
+
* result is given.
|
|
115
|
+
*/
|
|
116
|
+
typed?: LineTest;
|
|
117
|
+
/**
|
|
118
|
+
* A regular expression for what the program draws on the same row as its
|
|
119
|
+
* text but is not part of it, such as a right-aligned timestamp or a
|
|
120
|
+
* sidebar: removed from the lines `terminal_result` returns.
|
|
121
|
+
*/
|
|
122
|
+
tidy?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Built-in signatures. Each comment names the screens its fixtures come from.
|
|
126
|
+
*/
|
|
127
|
+
export declare const BUILT_IN_SIGNATURES: readonly AgentSignature[];
|
|
128
|
+
interface CompiledStyle {
|
|
129
|
+
bold?: boolean;
|
|
130
|
+
dim?: boolean;
|
|
131
|
+
italic?: boolean;
|
|
132
|
+
fg?: Set<string>;
|
|
133
|
+
notFg?: Set<string>;
|
|
134
|
+
}
|
|
135
|
+
interface CompiledLine {
|
|
136
|
+
text?: RegExp;
|
|
137
|
+
word?: CompiledStyle;
|
|
138
|
+
lead?: CompiledStyle;
|
|
139
|
+
body?: CompiledStyle;
|
|
140
|
+
}
|
|
141
|
+
interface CompiledBlock {
|
|
142
|
+
start: CompiledLine;
|
|
143
|
+
continues?: CompiledLine;
|
|
144
|
+
upward: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface CompiledSignature {
|
|
147
|
+
name: string;
|
|
148
|
+
programs: string[];
|
|
149
|
+
measured?: string;
|
|
150
|
+
source: string;
|
|
151
|
+
composer: CompiledLine;
|
|
152
|
+
chrome: CompiledLine[];
|
|
153
|
+
frame?: CompiledLine;
|
|
154
|
+
busy: CompiledLine[];
|
|
155
|
+
turn?: CompiledLine;
|
|
156
|
+
reasoning: CompiledBlock[];
|
|
157
|
+
answer: CompiledBlock;
|
|
158
|
+
trailer?: CompiledLine;
|
|
159
|
+
requireTrailer: boolean;
|
|
160
|
+
typed?: CompiledLine;
|
|
161
|
+
tidy?: RegExp;
|
|
162
|
+
/**
|
|
163
|
+
* When a pattern last ran past its budget. The signature is set aside for
|
|
164
|
+
* `SET_ASIDE_MS` after that, then tried again: a wall-clock budget can trip
|
|
165
|
+
* once on a loaded machine without the signature being at fault.
|
|
166
|
+
*/
|
|
167
|
+
overBudgetAt: number | null;
|
|
168
|
+
}
|
|
169
|
+
/** How long a signature that ran past its time budget is set aside. */
|
|
170
|
+
export declare const SET_ASIDE_MS = 60000;
|
|
171
|
+
/** Whether a signature is set aside for running past its time budget just now. */
|
|
172
|
+
export declare function setAside(signature: CompiledSignature, now?: number): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Compile signatures, setting aside any that cannot be used and saying why,
|
|
175
|
+
* in words a person can act on.
|
|
176
|
+
*/
|
|
177
|
+
export declare function compileSignatures(list: readonly unknown[], where?: string): {
|
|
178
|
+
signatures: CompiledSignature[];
|
|
179
|
+
problems: string[];
|
|
180
|
+
usable: number[];
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Use the built-in signatures plus `extra`, the entries from config; an entry
|
|
184
|
+
* named like a built-in one replaces it. Returns what was wrong with `extra`.
|
|
185
|
+
*/
|
|
186
|
+
export declare function useAgentSignatures(extra: readonly unknown[], onOverBudget?: (name: string) => void): string[];
|
|
187
|
+
/** The names `terminal_start`'s `agent` accepts. */
|
|
188
|
+
export declare function agentNames(): string[];
|
|
189
|
+
/** A program's name from its start command: `C:\x\Claude.EXE` is `claude`. */
|
|
190
|
+
export declare function programName(command: string): string;
|
|
191
|
+
/**
|
|
192
|
+
* The agent a session runs as, by name: the one it was started as, or the one
|
|
193
|
+
* whose programs include its start command. The signatures are compiled and
|
|
194
|
+
* ordered exactly as `useAgentSignatures` orders the daemon's (the built-ins
|
|
195
|
+
* a config entry does not replace, then the config's entries in order, first
|
|
196
|
+
* match), so a client and the daemon name the same agent. Null when neither
|
|
197
|
+
* names one. For a client, which has no signature registry of its own; the
|
|
198
|
+
* daemon reads screens with `signatureFor`.
|
|
199
|
+
*/
|
|
200
|
+
export declare function agentNameFor(agent: string | undefined, command: string, extra?: readonly unknown[]): string | null;
|
|
201
|
+
/**
|
|
202
|
+
* The signature for a session: the agent it was started as, or the one whose
|
|
203
|
+
* programs include its start command. Null when neither names one.
|
|
204
|
+
*/
|
|
205
|
+
export declare function signatureFor(agent: string | undefined, command: string): CompiledSignature | null;
|
|
206
|
+
/** What `hideReasoning` gives back: the lines kept, where each came from, and how much went. */
|
|
207
|
+
export interface FilteredLines {
|
|
208
|
+
lines: string[];
|
|
209
|
+
/** For each kept line, its index in the input; a marker line has its block's first index. */
|
|
210
|
+
rows: number[];
|
|
211
|
+
/** Which kept lines are markers standing in for a hidden block. */
|
|
212
|
+
markers: boolean[];
|
|
213
|
+
hiddenLines: number;
|
|
214
|
+
hiddenBlocks: number;
|
|
215
|
+
}
|
|
216
|
+
/** The line that stands in for a hidden block. */
|
|
217
|
+
export declare function hiddenMarker(count: number): string;
|
|
218
|
+
/**
|
|
219
|
+
* The lines from `firstVisible` on, with every reasoning block above the
|
|
220
|
+
* composer replaced by one marker line. The lines before `firstVisible` are
|
|
221
|
+
* context only: a block whose first line is among them is still recognised
|
|
222
|
+
* where it carries on into what is returned. `rows` count from
|
|
223
|
+
* `firstVisible`. Null when the signature was set aside for running past its
|
|
224
|
+
* time budget, which the caller must treat as "cannot filter".
|
|
225
|
+
*/
|
|
226
|
+
export declare function hideReasoning(lines: readonly StyledLine[], signature: CompiledSignature, firstVisible?: number): FilteredLines | null;
|
|
227
|
+
/** What the CLI and the MCP tool say when there is no result to give. */
|
|
228
|
+
export declare function resultRefusal(reason: string): string;
|
|
229
|
+
/** What `terminal_result` gives back. */
|
|
230
|
+
export type AgentResult = {
|
|
231
|
+
found: true;
|
|
232
|
+
/** The answer that ends the latest turn, as drawn. */
|
|
233
|
+
answer: string[];
|
|
234
|
+
/** A turn summary drawn after the answer, when the program draws one. */
|
|
235
|
+
trailer: string[];
|
|
236
|
+
/** The status lines under the composer. */
|
|
237
|
+
status: string[];
|
|
238
|
+
/** The echo of the prompt the answer follows, so a caller can check it is the one it sent. */
|
|
239
|
+
prompt: string | null;
|
|
240
|
+
} | {
|
|
241
|
+
found: false;
|
|
242
|
+
reason: 'busy' | 'no-composer' | 'no-answer' | 'over-budget' | 'unfinished' | 'prompt-typed';
|
|
243
|
+
/** The status lines under the composer, when there is one. */
|
|
244
|
+
status: string[];
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* The answer that ends the latest turn. It has to start below the latest
|
|
248
|
+
* prompt the person typed, sit above the composer, and lie outside every
|
|
249
|
+
* reasoning block; nothing else is ever returned in its place.
|
|
250
|
+
*/
|
|
251
|
+
export declare function latestResult(lines: readonly StyledLine[], signature: CompiledSignature): AgentResult;
|
|
252
|
+
export {};
|