@inbrowser/agent 0.0.0-placeholder → 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/AGENTS.md +270 -0
- package/README.md +117 -2
- package/bin/agent.ts +10 -0
- package/dist/cli/commands/describe.d.ts +14 -0
- package/dist/cli/commands/describe.d.ts.map +1 -0
- package/dist/cli/commands/describe.js +179 -0
- package/dist/cli/commands/describe.js.map +1 -0
- package/dist/cli/commands/events.d.ts +21 -0
- package/dist/cli/commands/events.d.ts.map +1 -0
- package/dist/cli/commands/events.js +59 -0
- package/dist/cli/commands/events.js.map +1 -0
- package/dist/cli/commands/fleet.d.ts +15 -0
- package/dist/cli/commands/fleet.d.ts.map +1 -0
- package/dist/cli/commands/fleet.js +149 -0
- package/dist/cli/commands/fleet.js.map +1 -0
- package/dist/cli/commands/help.d.ts +15 -0
- package/dist/cli/commands/help.d.ts.map +1 -0
- package/dist/cli/commands/help.js +93 -0
- package/dist/cli/commands/help.js.map +1 -0
- package/dist/cli/commands/migrate.d.ts +27 -0
- package/dist/cli/commands/migrate.d.ts.map +1 -0
- package/dist/cli/commands/migrate.js +109 -0
- package/dist/cli/commands/migrate.js.map +1 -0
- package/dist/cli/commands/run.d.ts +38 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +535 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/schema.d.ts +8 -0
- package/dist/cli/commands/schema.d.ts.map +1 -0
- package/dist/cli/commands/schema.js +12 -0
- package/dist/cli/commands/schema.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +39 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +65 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/undo.d.ts +36 -0
- package/dist/cli/commands/undo.d.ts.map +1 -0
- package/dist/cli/commands/undo.js +132 -0
- package/dist/cli/commands/undo.js.map +1 -0
- package/dist/cli/fixtures.d.ts +17 -0
- package/dist/cli/fixtures.d.ts.map +1 -0
- package/dist/cli/fixtures.js +107 -0
- package/dist/cli/fixtures.js.map +1 -0
- package/dist/cli/hardening.d.ts +39 -0
- package/dist/cli/hardening.d.ts.map +1 -0
- package/dist/cli/hardening.js +68 -0
- package/dist/cli/hardening.js.map +1 -0
- package/dist/cli/index.d.ts +28 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +19 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/llm/openrouter.d.ts +33 -0
- package/dist/cli/llm/openrouter.d.ts.map +1 -0
- package/dist/cli/llm/openrouter.js +285 -0
- package/dist/cli/llm/openrouter.js.map +1 -0
- package/dist/cli/main.d.ts +32 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +106 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/output.d.ts +36 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +95 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/parse.d.ts +26 -0
- package/dist/cli/parse.d.ts.map +1 -0
- package/dist/cli/parse.js +160 -0
- package/dist/cli/parse.js.map +1 -0
- package/dist/cli/session-log.d.ts +34 -0
- package/dist/cli/session-log.d.ts.map +1 -0
- package/dist/cli/session-log.js +52 -0
- package/dist/cli/session-log.js.map +1 -0
- package/dist/cli/spec.d.ts +62 -0
- package/dist/cli/spec.d.ts.map +1 -0
- package/dist/cli/spec.js +510 -0
- package/dist/cli/spec.js.map +1 -0
- package/dist/cli/ui/RunView.d.ts +134 -0
- package/dist/cli/ui/RunView.d.ts.map +1 -0
- package/dist/cli/ui/RunView.js +341 -0
- package/dist/cli/ui/RunView.js.map +1 -0
- package/dist/events/codec.d.ts +79 -0
- package/dist/events/codec.d.ts.map +1 -0
- package/dist/events/codec.js +142 -0
- package/dist/events/codec.js.map +1 -0
- package/dist/events/log-core.d.ts +76 -0
- package/dist/events/log-core.d.ts.map +1 -0
- package/dist/events/log-core.js +73 -0
- package/dist/events/log-core.js.map +1 -0
- package/dist/events/log.d.ts +60 -0
- package/dist/events/log.d.ts.map +1 -0
- package/dist/events/log.js +193 -0
- package/dist/events/log.js.map +1 -0
- package/dist/events/replay.d.ts +106 -0
- package/dist/events/replay.d.ts.map +1 -0
- package/dist/events/replay.js +137 -0
- package/dist/events/replay.js.map +1 -0
- package/dist/events/wrap.d.ts +100 -0
- package/dist/events/wrap.d.ts.map +1 -0
- package/dist/events/wrap.js +141 -0
- package/dist/events/wrap.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/llm-adapter.d.ts +96 -0
- package/dist/llm-adapter.d.ts.map +1 -0
- package/dist/llm-adapter.js +132 -0
- package/dist/llm-adapter.js.map +1 -0
- package/dist/mcp/serve.d.ts +70 -0
- package/dist/mcp/serve.d.ts.map +1 -0
- package/dist/mcp/serve.js +154 -0
- package/dist/mcp/serve.js.map +1 -0
- package/dist/metrics/runs.d.ts +58 -0
- package/dist/metrics/runs.d.ts.map +1 -0
- package/dist/metrics/runs.js +99 -0
- package/dist/metrics/runs.js.map +1 -0
- package/dist/metrics.d.ts +38 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +123 -0
- package/dist/metrics.js.map +1 -0
- package/dist/node.d.ts +22 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +22 -0
- package/dist/node.js.map +1 -0
- package/dist/session.d.ts +10 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +179 -0
- package/dist/session.js.map +1 -0
- package/dist/storage.d.ts +14 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +58 -0
- package/dist/storage.js.map +1 -0
- package/dist/strategy.d.ts +26 -0
- package/dist/strategy.d.ts.map +1 -0
- package/dist/strategy.js +200 -0
- package/dist/strategy.js.map +1 -0
- package/dist/tools.d.ts +26 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +129 -0
- package/dist/tools.js.map +1 -0
- package/dist/types/agent.d.ts +94 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +17 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/capabilities.d.ts +17 -0
- package/dist/types/capabilities.d.ts.map +1 -0
- package/dist/types/capabilities.js +13 -0
- package/dist/types/capabilities.js.map +1 -0
- package/dist/types/chat.d.ts +74 -0
- package/dist/types/chat.d.ts.map +1 -0
- package/dist/types/chat.js +10 -0
- package/dist/types/chat.js.map +1 -0
- package/dist/types/events.d.ts +115 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +30 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/llm.d.ts +89 -0
- package/dist/types/llm.d.ts.map +1 -0
- package/dist/types/llm.js +12 -0
- package/dist/types/llm.js.map +1 -0
- package/dist/types/metrics.d.ts +34 -0
- package/dist/types/metrics.d.ts.map +1 -0
- package/dist/types/metrics.js +10 -0
- package/dist/types/metrics.js.map +1 -0
- package/dist/types/observer.d.ts +41 -0
- package/dist/types/observer.d.ts.map +1 -0
- package/dist/types/observer.js +41 -0
- package/dist/types/observer.js.map +1 -0
- package/dist/types/project-context.d.ts +18 -0
- package/dist/types/project-context.d.ts.map +1 -0
- package/dist/types/project-context.js +11 -0
- package/dist/types/project-context.js.map +1 -0
- package/dist/types/runtime.d.ts +71 -0
- package/dist/types/runtime.d.ts.map +1 -0
- package/dist/types/runtime.js +21 -0
- package/dist/types/runtime.js.map +1 -0
- package/dist/types/session.d.ts +103 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +11 -0
- package/dist/types/session.js.map +1 -0
- package/dist/types/storage.d.ts +20 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +41 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/types/strategy.d.ts +76 -0
- package/dist/types/strategy.d.ts.map +1 -0
- package/dist/types/strategy.js +10 -0
- package/dist/types/strategy.js.map +1 -0
- package/dist/types/tools.d.ts +136 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +11 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/trace.d.ts +125 -0
- package/dist/types/trace.d.ts.map +1 -0
- package/dist/types/trace.js +24 -0
- package/dist/types/trace.js.map +1 -0
- package/dist/types/workspace.d.ts +29 -0
- package/dist/types/workspace.d.ts.map +1 -0
- package/dist/types/workspace.js +18 -0
- package/dist/types/workspace.js.map +1 -0
- package/package.json +45 -14
- package/skills/agent-cli.md +218 -0
- package/index.js +0 -2
package/dist/cli/spec.js
ADDED
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for the CLI command schema. Used for:
|
|
3
|
+
*
|
|
4
|
+
* - Runtime arg parsing (`parse.ts` consults this for option types
|
|
5
|
+
* and required-ness).
|
|
6
|
+
* - Schema introspection (`agent describe`, `agent schema`,
|
|
7
|
+
* `--help --json` all surface this verbatim).
|
|
8
|
+
* - Per-axis guarantees in the Agent DX CLI scale rubric:
|
|
9
|
+
* axis 3 (schema introspection): every command + option is here.
|
|
10
|
+
* axis 5 (input hardening): `validate` records the rules the
|
|
11
|
+
* parser must enforce.
|
|
12
|
+
* axis 6 (safety rails): the `mutating` flag marks where
|
|
13
|
+
* `--dry-run` MUST be honored.
|
|
14
|
+
*/
|
|
15
|
+
const OUTPUT_FORMATS = ['ndjson', 'json', 'text'];
|
|
16
|
+
const GLOBAL_OPTIONS = [
|
|
17
|
+
{
|
|
18
|
+
name: '--output',
|
|
19
|
+
short: '-o',
|
|
20
|
+
type: 'enum',
|
|
21
|
+
choices: OUTPUT_FORMATS,
|
|
22
|
+
description: 'Output format. Default: ndjson when stdout is not a TTY, text when it is. ' +
|
|
23
|
+
'Use ndjson for streaming agent consumption.',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: '--fields',
|
|
27
|
+
type: 'string[]',
|
|
28
|
+
description: 'Comma-separated event field allowlist. Applies only to ndjson/json output. ' +
|
|
29
|
+
'Example: --fields ts,type,turn,name,ok',
|
|
30
|
+
validate: { rejectControlChars: true, maxLength: 512 },
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: '--no-color',
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
description: 'Disable ANSI colors in text output. Auto-disabled when not a TTY.',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: '--help',
|
|
39
|
+
short: '-h',
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
description: 'Show help for the (sub)command. Combine with --output json (or pipe to non-TTY) ' +
|
|
42
|
+
'to receive the machine-readable schema.',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
const RUN_OPTIONS = [
|
|
46
|
+
{
|
|
47
|
+
name: '--prompt',
|
|
48
|
+
short: '-p',
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'User prompt for the session. Required unless --json is provided.',
|
|
51
|
+
validate: { rejectControlChars: true, maxLength: 8192 },
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: '--json',
|
|
55
|
+
type: 'json',
|
|
56
|
+
description: 'Read full run payload as JSON from stdin (- or no value) or from the given file ' +
|
|
57
|
+
'path. Schema: { prompt: string, scenario?: string, maxTurns?: number, sessionId?: string, history?: ChatMessage[] }. ' +
|
|
58
|
+
'Maps 1:1 to the run handler signature — no flag translation loss.',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: '--scenario',
|
|
62
|
+
type: 'enum',
|
|
63
|
+
choices: ['echo', 'write-rules'],
|
|
64
|
+
default: 'echo',
|
|
65
|
+
description: 'Scripted LLM fixture used in headless mode. echo: echoes the prompt. ' +
|
|
66
|
+
'write-rules: emits a tool_call → text two-turn flow.',
|
|
67
|
+
validate: {
|
|
68
|
+
rejectControlChars: true,
|
|
69
|
+
rejectPathTraversal: true,
|
|
70
|
+
rejectQueryChars: true,
|
|
71
|
+
maxLength: 64,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: '--max-turns',
|
|
76
|
+
type: 'number',
|
|
77
|
+
default: 8,
|
|
78
|
+
description: 'Hard cap on agent turn count for this session. 1–64.',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: '--session-id',
|
|
82
|
+
type: 'string',
|
|
83
|
+
description: 'Override the auto-generated session id. Used as the basename for the auto session log file.',
|
|
84
|
+
validate: {
|
|
85
|
+
rejectControlChars: true,
|
|
86
|
+
rejectPathTraversal: true,
|
|
87
|
+
rejectQueryChars: true,
|
|
88
|
+
maxLength: 64,
|
|
89
|
+
pattern: '^[a-zA-Z0-9_.-]+$',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: '--log-dir',
|
|
94
|
+
type: 'path',
|
|
95
|
+
description: 'Directory for the auto session log file. Default: ~/.pyric/sessions/. ' +
|
|
96
|
+
'Each run writes <log-dir>/<sessionId>.ndjson with the full event stream + metrics summary.',
|
|
97
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 1024 },
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: '--no-log',
|
|
101
|
+
type: 'boolean',
|
|
102
|
+
description: 'Disable auto session log file writing. Stdout output is unaffected.',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: '--dry-run',
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
description: 'Validate inputs (parsing, hardening, file resolution) and emit a single ' +
|
|
108
|
+
'plan event without invoking the LLM or running any tools.',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: '--llm',
|
|
112
|
+
type: 'enum',
|
|
113
|
+
choices: ['auto', 'scripted', 'openrouter'],
|
|
114
|
+
default: 'auto',
|
|
115
|
+
description: 'LLM backend. `scripted` uses the fixture LLM (echo / write-rules) for ' +
|
|
116
|
+
'headless CI. `openrouter` requires OPENROUTER_API_KEY in env. `auto` ' +
|
|
117
|
+
'(default) picks openrouter when the key is set, scripted otherwise.',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: '--model',
|
|
121
|
+
type: 'string',
|
|
122
|
+
description: 'OpenRouter model id (e.g. `z-ai/glm-4.6`). Ignored for --llm scripted. ' +
|
|
123
|
+
'Falls back to OPENROUTER_MODEL env var, then `z-ai/glm-4.6` default.',
|
|
124
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 128 },
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: '--reasoning',
|
|
128
|
+
type: 'enum',
|
|
129
|
+
choices: ['off', 'low', 'medium', 'high'],
|
|
130
|
+
description: 'Forward extended-thinking budget to models that support it (GLM, ' +
|
|
131
|
+
'DeepSeek-R1, Claude with thinking, GPT-5 reasoning). Off by default ' +
|
|
132
|
+
'to keep request shape lean.',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: '--no-tui',
|
|
136
|
+
type: 'boolean',
|
|
137
|
+
description: 'Disable the OpenTUI run view even when stdout is a TTY. Falls ' +
|
|
138
|
+
'back to the per-event prose emitter (the previous default). ' +
|
|
139
|
+
'Useful when piping `--output text` through a pager or debugging ' +
|
|
140
|
+
'the stream without the alt-screen.',
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
const FLEET_OPTIONS = [
|
|
144
|
+
{
|
|
145
|
+
name: '--size',
|
|
146
|
+
short: '-n',
|
|
147
|
+
type: 'number',
|
|
148
|
+
default: 3,
|
|
149
|
+
description: 'Number of concurrent sessions to launch. 1–64.',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: '--scenario',
|
|
153
|
+
type: 'enum',
|
|
154
|
+
choices: ['write-rules'],
|
|
155
|
+
default: 'write-rules',
|
|
156
|
+
description: 'Scripted scenario each fleet member runs.',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: '--log-dir',
|
|
160
|
+
type: 'path',
|
|
161
|
+
description: 'Directory for per-session log files. Default: ~/.pyric/sessions/.',
|
|
162
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 1024 },
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: '--no-log',
|
|
166
|
+
type: 'boolean',
|
|
167
|
+
description: 'Disable auto session log file writing.',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: '--dry-run',
|
|
171
|
+
type: 'boolean',
|
|
172
|
+
description: 'Print the planned fleet (size, member ids, scenario) without launching sessions.',
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
const EVENTS_OPTIONS = [
|
|
176
|
+
{
|
|
177
|
+
name: '--project',
|
|
178
|
+
short: '-p',
|
|
179
|
+
type: 'string',
|
|
180
|
+
required: true,
|
|
181
|
+
description: 'Firebase project id. The log lives at <events-dir>/<project>/events.ndjson.',
|
|
182
|
+
validate: {
|
|
183
|
+
rejectControlChars: true,
|
|
184
|
+
rejectPathTraversal: true,
|
|
185
|
+
rejectQueryChars: true,
|
|
186
|
+
maxLength: 64,
|
|
187
|
+
pattern: '^[a-zA-Z0-9_.-]+$',
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: '--events-dir',
|
|
192
|
+
type: 'path',
|
|
193
|
+
description: 'Override the events root. Default: ~/.pyric/projects. The full log path is <events-dir>/<project>/events.ndjson.',
|
|
194
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 1024 },
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: '--session',
|
|
198
|
+
type: 'string',
|
|
199
|
+
description: 'Restrict to events from a single agent session.',
|
|
200
|
+
validate: {
|
|
201
|
+
rejectControlChars: true,
|
|
202
|
+
rejectPathTraversal: true,
|
|
203
|
+
rejectQueryChars: true,
|
|
204
|
+
maxLength: 64,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: '--tool',
|
|
209
|
+
type: 'string',
|
|
210
|
+
description: 'Restrict to events from one tool name.',
|
|
211
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 64 },
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: '--agent',
|
|
215
|
+
type: 'string',
|
|
216
|
+
description: "Restrict to events emitted by a single agent (e.g. 'firestore-data-modeling'). Default emitter is 'host'.",
|
|
217
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 64 },
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: '--phase',
|
|
221
|
+
type: 'enum',
|
|
222
|
+
choices: ['plan', 'commit', 'rollback'],
|
|
223
|
+
description: 'Restrict to one lifecycle phase.',
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: '--since',
|
|
227
|
+
type: 'string',
|
|
228
|
+
description: 'ISO-8601 lower bound (inclusive). Example: 2026-05-11T00:00:00Z.',
|
|
229
|
+
validate: { rejectControlChars: true, maxLength: 40 },
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: '--until',
|
|
233
|
+
type: 'string',
|
|
234
|
+
description: 'ISO-8601 upper bound (exclusive).',
|
|
235
|
+
validate: { rejectControlChars: true, maxLength: 40 },
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: '--include-bookkeeping',
|
|
239
|
+
type: 'boolean',
|
|
240
|
+
description: 'Include bookkeeping markers (migrate_applied, migrate_intent) in the output. Hidden by default so "what changed?" queries return real mutations.',
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
const UNDO_OPTIONS = [
|
|
244
|
+
{
|
|
245
|
+
name: '--project',
|
|
246
|
+
short: '-p',
|
|
247
|
+
type: 'string',
|
|
248
|
+
required: true,
|
|
249
|
+
description: 'Firebase project id whose log holds the event.',
|
|
250
|
+
validate: {
|
|
251
|
+
rejectControlChars: true,
|
|
252
|
+
rejectPathTraversal: true,
|
|
253
|
+
rejectQueryChars: true,
|
|
254
|
+
maxLength: 64,
|
|
255
|
+
pattern: '^[a-zA-Z0-9_.-]+$',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: '--event',
|
|
260
|
+
short: '-e',
|
|
261
|
+
type: 'string',
|
|
262
|
+
required: true,
|
|
263
|
+
description: 'Event id to undo. Must reference a `commit`-phase event with `reversible: true`. Use `agent events` to find ids.',
|
|
264
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 64 },
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: '--events-dir',
|
|
268
|
+
type: 'path',
|
|
269
|
+
description: 'Override the events root. Default: ~/.pyric/projects.',
|
|
270
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 1024 },
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: '--dry-run',
|
|
274
|
+
type: 'boolean',
|
|
275
|
+
description: 'Show the rollback plan (target, reverseOp tool+args, irreversible-flag check) without invoking the reverse op.',
|
|
276
|
+
},
|
|
277
|
+
];
|
|
278
|
+
const SERVE_OPTIONS = [
|
|
279
|
+
{
|
|
280
|
+
name: '--project',
|
|
281
|
+
short: '-p',
|
|
282
|
+
type: 'string',
|
|
283
|
+
required: true,
|
|
284
|
+
description: 'Firebase project id. Routes the event log + run log to ~/.pyric/projects/<project>/.',
|
|
285
|
+
validate: {
|
|
286
|
+
rejectControlChars: true,
|
|
287
|
+
rejectPathTraversal: true,
|
|
288
|
+
rejectQueryChars: true,
|
|
289
|
+
maxLength: 64,
|
|
290
|
+
pattern: '^[a-zA-Z0-9_.-]+$',
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: '--events-dir',
|
|
295
|
+
type: 'path',
|
|
296
|
+
description: 'Override the events + runs root. Default: ~/.pyric/projects. Tests use this.',
|
|
297
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 1024 },
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: '--dry-run',
|
|
301
|
+
type: 'boolean',
|
|
302
|
+
description: 'Print the catalog (agent + tool list) without binding stdio. Exit 0.',
|
|
303
|
+
},
|
|
304
|
+
];
|
|
305
|
+
const MIGRATE_OPTIONS = [
|
|
306
|
+
{
|
|
307
|
+
name: '--project',
|
|
308
|
+
short: '-p',
|
|
309
|
+
type: 'string',
|
|
310
|
+
required: true,
|
|
311
|
+
description: 'Firebase project id whose log holds the events to replay.',
|
|
312
|
+
validate: {
|
|
313
|
+
rejectControlChars: true,
|
|
314
|
+
rejectPathTraversal: true,
|
|
315
|
+
rejectQueryChars: true,
|
|
316
|
+
maxLength: 64,
|
|
317
|
+
pattern: '^[a-zA-Z0-9_.-]+$',
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: '--events-dir',
|
|
322
|
+
type: 'path',
|
|
323
|
+
description: 'Override the events root. Default: ~/.pyric/projects.',
|
|
324
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 1024 },
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: '--since-event',
|
|
328
|
+
type: 'string',
|
|
329
|
+
description: 'Replay only events with id >= this id. Use `agent events --project … --phase commit | head -1 | jq -r .id` to get an anchor.',
|
|
330
|
+
validate: { rejectControlChars: true, rejectQueryChars: true, maxLength: 64 },
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: '--tools',
|
|
334
|
+
type: 'string[]',
|
|
335
|
+
description: 'Comma-separated tool allowlist. Only events for these tools are planned.',
|
|
336
|
+
validate: { rejectControlChars: true, maxLength: 512 },
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: '--record',
|
|
340
|
+
type: 'boolean',
|
|
341
|
+
description: 'Append a `migrate_intent` event to the log for host pickup. Without --record, the command is a pure plan (no log mutation).',
|
|
342
|
+
},
|
|
343
|
+
];
|
|
344
|
+
const DESCRIBE_OPTIONS = [
|
|
345
|
+
{
|
|
346
|
+
name: '--target',
|
|
347
|
+
short: '-t',
|
|
348
|
+
type: 'enum',
|
|
349
|
+
choices: ['commands', 'scenarios', 'events', 'all'],
|
|
350
|
+
default: 'all',
|
|
351
|
+
description: 'Which subject to describe. commands: subcommand tree. scenarios: scripted LLM fixtures. ' +
|
|
352
|
+
'events: NDJSON event types. all: a single combined object.',
|
|
353
|
+
},
|
|
354
|
+
];
|
|
355
|
+
export const CLI_SPEC = {
|
|
356
|
+
name: 'agent',
|
|
357
|
+
version: '0.0.0',
|
|
358
|
+
description: 'Headless runner for @inbrowser/agent sessions. NDJSON-by-default in non-TTY contexts, ' +
|
|
359
|
+
'JSON stdin payloads, schema introspection, automatic per-session NDJSON logs, ' +
|
|
360
|
+
'observability totals. See AGENTS.md for invariants.',
|
|
361
|
+
globalOptions: GLOBAL_OPTIONS,
|
|
362
|
+
commands: [
|
|
363
|
+
{
|
|
364
|
+
name: 'run',
|
|
365
|
+
description: 'Run a single agent session against a scripted LLM and a fake sandbox.',
|
|
366
|
+
mutating: true,
|
|
367
|
+
options: RUN_OPTIONS,
|
|
368
|
+
positional: {
|
|
369
|
+
name: 'prompt',
|
|
370
|
+
description: 'Free-form prompt text. Equivalent to --prompt. Ignored when --json is supplied.',
|
|
371
|
+
},
|
|
372
|
+
examples: [
|
|
373
|
+
{
|
|
374
|
+
input: 'agent run "build a chess board"',
|
|
375
|
+
description: 'Echo scenario, text output to TTY, NDJSON log to ~/.pyric/sessions/.',
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
input: 'echo \'{"prompt":"reset rules","scenario":"write-rules"}\' | agent run --json -',
|
|
379
|
+
description: 'Raw JSON payload from stdin. Output streams as NDJSON.',
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
input: 'agent run --prompt "hi" --dry-run',
|
|
383
|
+
description: 'Validates the run plan without invoking the LLM.',
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
name: 'fleet',
|
|
389
|
+
description: 'Launch N concurrent agent sessions for isolation testing.',
|
|
390
|
+
mutating: true,
|
|
391
|
+
options: FLEET_OPTIONS,
|
|
392
|
+
examples: [
|
|
393
|
+
{
|
|
394
|
+
input: 'agent fleet --size 10',
|
|
395
|
+
description: '10 isolated sessions, NDJSON event stream, summary table at end.',
|
|
396
|
+
},
|
|
397
|
+
{ input: 'agent fleet --size 3 --dry-run', description: 'Print the fleet plan only.' },
|
|
398
|
+
],
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: 'describe',
|
|
402
|
+
description: 'Emit machine-readable descriptions of CLI subjects (commands, scenarios, events).',
|
|
403
|
+
mutating: false,
|
|
404
|
+
options: DESCRIBE_OPTIONS,
|
|
405
|
+
examples: [
|
|
406
|
+
{ input: 'agent describe', description: 'Combined description as JSON.' },
|
|
407
|
+
{ input: 'agent describe --target events', description: 'NDJSON event-type catalog.' },
|
|
408
|
+
],
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: 'events',
|
|
412
|
+
description: 'Stream the per-project mutation event log (~/.pyric/projects/<project>/events.ndjson). Each event is one NDJSON line. Supports filtering by session / tool / agent / phase / time.',
|
|
413
|
+
mutating: false,
|
|
414
|
+
options: EVENTS_OPTIONS,
|
|
415
|
+
examples: [
|
|
416
|
+
{ input: 'agent events --project my-app', description: 'Full log as NDJSON.' },
|
|
417
|
+
{
|
|
418
|
+
input: 'agent events --project my-app --phase commit --tool writeRules',
|
|
419
|
+
description: 'Just the committed writeRules events.',
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
input: 'agent events --project my-app --session sess-123',
|
|
423
|
+
description: 'Audit one session end-to-end.',
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
name: 'undo',
|
|
429
|
+
description: 'Reverse a previously-committed mutation by invoking its recorded reverseOp. Refuses on `reversible: false` events. `--dry-run` shows the plan.',
|
|
430
|
+
mutating: true,
|
|
431
|
+
options: UNDO_OPTIONS,
|
|
432
|
+
examples: [
|
|
433
|
+
{
|
|
434
|
+
input: 'agent undo --project my-app --event abc123-xyz --dry-run',
|
|
435
|
+
description: 'Plan the rollback only.',
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
input: 'agent undo --project my-app --event abc123-xyz',
|
|
439
|
+
description: 'Execute the recorded reverseOp; appends a `rollback` event to the log.',
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
name: 'serve',
|
|
445
|
+
description: 'Inverse-mode MCP server. Exposes the named AgentDefinition(s) over stdio MCP so an external host (Claude Code, Claude Desktop, Cursor) can call their behavior-named tools. Process holds stdin/stdout for the transport; do not pipe through it.',
|
|
446
|
+
mutating: true,
|
|
447
|
+
options: SERVE_OPTIONS,
|
|
448
|
+
examples: [
|
|
449
|
+
{
|
|
450
|
+
input: 'agent serve --project demo --dry-run',
|
|
451
|
+
description: 'Print the tool catalog without binding stdio.',
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
input: 'agent serve --project demo',
|
|
455
|
+
description: "Boot the MCP server. Exposes every built-in agent's tools flat. " +
|
|
456
|
+
'Wire via Claude Code mcpServers config.',
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
name: 'migrate',
|
|
462
|
+
description: 'Plan the forward replay of a project event log against a production dispatch. The CLI emits one `migrate_plan` per replayable commit; `--record` appends a `migrate_intent` marker for host pickup. Like `undo`, the CLI does not invoke tools — call `replayEvents()` from `@inbrowser/agent` against your prod registry. ' +
|
|
463
|
+
'Marked `mutating: true` because `--record` appends to the log; without `--record` the command is pure plan-only (no log mutation), which is the implicit dry-run shape.',
|
|
464
|
+
mutating: true,
|
|
465
|
+
options: MIGRATE_OPTIONS,
|
|
466
|
+
examples: [
|
|
467
|
+
{
|
|
468
|
+
input: 'agent migrate --project my-app',
|
|
469
|
+
description: 'Plan every replayable commit (NDJSON).',
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
input: 'agent migrate --project my-app --since-event ksx91m3-0001-a4f --tools setDoc,writeRules',
|
|
473
|
+
description: 'Filtered plan.',
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
input: 'agent migrate --project my-app --record',
|
|
477
|
+
description: 'Plan + append `migrate_intent` for host pickup.',
|
|
478
|
+
},
|
|
479
|
+
],
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
name: 'schema',
|
|
483
|
+
description: 'Dump the full CLI command-and-option schema as JSON.',
|
|
484
|
+
mutating: false,
|
|
485
|
+
options: [],
|
|
486
|
+
examples: [
|
|
487
|
+
{
|
|
488
|
+
input: 'agent schema',
|
|
489
|
+
description: 'Full schema. Stable contract for agent integrations.',
|
|
490
|
+
},
|
|
491
|
+
],
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
name: 'version',
|
|
495
|
+
description: 'Print the package version.',
|
|
496
|
+
mutating: false,
|
|
497
|
+
options: [],
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
name: 'help',
|
|
501
|
+
description: 'Show top-level help. Add a subcommand name to scope it.',
|
|
502
|
+
mutating: false,
|
|
503
|
+
options: [],
|
|
504
|
+
},
|
|
505
|
+
],
|
|
506
|
+
};
|
|
507
|
+
export function findCommand(name) {
|
|
508
|
+
return CLI_SPEC.commands.find((c) => c.name === name);
|
|
509
|
+
}
|
|
510
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/cli/spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA6CH,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAE3D,MAAM,cAAc,GAA0B;IAC5C;QACE,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,cAAc;QACvB,WAAW,EACT,4EAA4E;YAC5E,6CAA6C;KAChD;IACD;QACE,IAAI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cAAc;oBACrB,WAAW,EAAE,sDAAsD;iBACpE;aACF;SACF;QACD;YACE,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,EAAE;SACZ;QACD;YACE,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,EAAE;SACZ;KACF;CACF,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run view — OpenTUI/React renderer for `agent run` when stdout is a
|
|
3
|
+
* TTY. Subscribes to the `AgentSession` event stream and projects it
|
|
4
|
+
* into a four-section layout: header (run metadata) → thinking
|
|
5
|
+
* (scrollable trace) → output (markdown) → tool cards → footer
|
|
6
|
+
* (token/cost/elapsed).
|
|
7
|
+
*
|
|
8
|
+
* Wiring lives in `cli/commands/run.ts` — the runCommand picks this
|
|
9
|
+
* over the NDJSON emitter when `pickMode()` resolves to `text` AND
|
|
10
|
+
* stdout.isTTY. NDJSON / piped / `--output ndjson` keep the existing
|
|
11
|
+
* emitter behavior; agent integrations + tests rely on it.
|
|
12
|
+
*
|
|
13
|
+
* v0 scaffold (this file): state machine + placeholder layout. The
|
|
14
|
+
* scrollbox / markdown / code components plug in over the next two
|
|
15
|
+
* phases.
|
|
16
|
+
*/
|
|
17
|
+
import type { SessionEvent } from '../../types/session.js';
|
|
18
|
+
type Status = 'idle' | 'thinking' | 'streaming' | 'tool' | 'done' | 'error';
|
|
19
|
+
export interface ToolCard {
|
|
20
|
+
callId: string;
|
|
21
|
+
name: string;
|
|
22
|
+
args: unknown;
|
|
23
|
+
result?: {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
summary?: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface ViewState {
|
|
29
|
+
sessionId: string;
|
|
30
|
+
scenario: string;
|
|
31
|
+
llmLabel: string;
|
|
32
|
+
llmFallbackReason?: string;
|
|
33
|
+
promptPreview: string;
|
|
34
|
+
logPath?: string;
|
|
35
|
+
currentTurn: number;
|
|
36
|
+
thinking: string;
|
|
37
|
+
output: string;
|
|
38
|
+
tools: ToolCard[];
|
|
39
|
+
status: Status;
|
|
40
|
+
tokensIn: number;
|
|
41
|
+
tokensOut: number;
|
|
42
|
+
tokensCached: number;
|
|
43
|
+
tokensReasoning: number;
|
|
44
|
+
costUsd: number;
|
|
45
|
+
startedAtMs: number;
|
|
46
|
+
elapsedMs: number;
|
|
47
|
+
errorMessage?: string;
|
|
48
|
+
thinkingCollapsed: boolean;
|
|
49
|
+
}
|
|
50
|
+
type Action = {
|
|
51
|
+
type: 'session_start';
|
|
52
|
+
sessionId: string;
|
|
53
|
+
scenario: string;
|
|
54
|
+
promptPreview: string;
|
|
55
|
+
} | {
|
|
56
|
+
type: 'llm_selected';
|
|
57
|
+
label: string;
|
|
58
|
+
fallbackReason?: string;
|
|
59
|
+
} | {
|
|
60
|
+
type: 'turn_started';
|
|
61
|
+
turnNo: number;
|
|
62
|
+
} | {
|
|
63
|
+
type: 'thinking';
|
|
64
|
+
chunk: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'text';
|
|
67
|
+
chunk: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: 'tool_started';
|
|
70
|
+
callId: string;
|
|
71
|
+
name: string;
|
|
72
|
+
args: unknown;
|
|
73
|
+
} | {
|
|
74
|
+
type: 'tool_finished';
|
|
75
|
+
callId: string;
|
|
76
|
+
ok: boolean;
|
|
77
|
+
summary?: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'turn_completed';
|
|
80
|
+
tokensIn: number;
|
|
81
|
+
tokensOut: number;
|
|
82
|
+
tokensCached: number;
|
|
83
|
+
tokensReasoning: number;
|
|
84
|
+
costUsd: number;
|
|
85
|
+
} | {
|
|
86
|
+
type: 'session_end';
|
|
87
|
+
} | {
|
|
88
|
+
type: 'error';
|
|
89
|
+
message: string;
|
|
90
|
+
} | {
|
|
91
|
+
type: 'tick';
|
|
92
|
+
nowMs: number;
|
|
93
|
+
} | {
|
|
94
|
+
type: 'toggle_thinking';
|
|
95
|
+
};
|
|
96
|
+
export declare const initialState: ViewState;
|
|
97
|
+
export declare function reduce(s: ViewState, a: Action): ViewState;
|
|
98
|
+
export interface RunViewProps {
|
|
99
|
+
/** Stream of events produced by `session.submit(prompt, signal)`. */
|
|
100
|
+
events: AsyncIterable<SessionEvent>;
|
|
101
|
+
/**
|
|
102
|
+
* Header data the CLI already has at startup. Pushed in once rather
|
|
103
|
+
* than discovered via the event stream — `session_start` event has
|
|
104
|
+
* a subset of this anyway, so the bootstrap props avoid a flash of
|
|
105
|
+
* empty-header content.
|
|
106
|
+
*/
|
|
107
|
+
bootstrap: {
|
|
108
|
+
sessionId: string;
|
|
109
|
+
scenario: string;
|
|
110
|
+
llmLabel: string;
|
|
111
|
+
llmFallbackReason?: string;
|
|
112
|
+
promptPreview: string;
|
|
113
|
+
/** Per-session NDJSON log destination, surfaced in FinalSummary. */
|
|
114
|
+
logPath?: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Fires when the user is ready to exit — after the session has
|
|
118
|
+
* ended (status `done` / `error`) AND they pressed `q` or
|
|
119
|
+
* `Escape`. The renderer should be destroyed after this fires.
|
|
120
|
+
* If the user hits `q` while the session is still running, the
|
|
121
|
+
* keypress is ignored (we don't have a cancellation handle from
|
|
122
|
+
* inside the view).
|
|
123
|
+
*/
|
|
124
|
+
onQuit?: () => void;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* v0 stub. Phase 4 fills in the actual layout (header, scrollbox of
|
|
128
|
+
* thinking, markdown output, tool cards, footer). For now this just
|
|
129
|
+
* proves the pipe works — reducer dispatch, async-iterable pump, and
|
|
130
|
+
* a single `<box>` showing live status.
|
|
131
|
+
*/
|
|
132
|
+
export declare function RunView({ events, bootstrap, onQuit }: RunViewProps): import("react").ReactNode;
|
|
133
|
+
export {};
|
|
134
|
+
//# sourceMappingURL=RunView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunView.d.ts","sourceRoot":"","sources":["../../../src/cli/ui/RunView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAgC3D,KAAK,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5E,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C;AAED,MAAM,WAAW,SAAS;IAIxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,EAAE,CAAC;IAGlB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,E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