@bastani/atomic 0.5.12 → 0.5.13
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/dist/lib/path-root-guard.d.ts +4 -0
- package/dist/lib/path-root-guard.d.ts.map +1 -0
- package/dist/sdk/components/color-utils.d.ts +4 -0
- package/dist/sdk/components/color-utils.d.ts.map +1 -0
- package/dist/sdk/components/compact-switcher.d.ts +10 -0
- package/dist/sdk/components/compact-switcher.d.ts.map +1 -0
- package/dist/sdk/components/connectors.d.ts +15 -0
- package/dist/sdk/components/connectors.d.ts.map +1 -0
- package/dist/sdk/components/edge.d.ts +4 -0
- package/dist/sdk/components/edge.d.ts.map +1 -0
- package/dist/sdk/components/error-boundary.d.ts +23 -0
- package/dist/sdk/components/error-boundary.d.ts.map +1 -0
- package/dist/sdk/components/graph-theme.d.ts +17 -0
- package/dist/sdk/components/graph-theme.d.ts.map +1 -0
- package/dist/sdk/components/header.d.ts +3 -0
- package/dist/sdk/components/header.d.ts.map +1 -0
- package/dist/sdk/components/hooks.d.ts +15 -0
- package/dist/sdk/components/hooks.d.ts.map +1 -0
- package/dist/sdk/components/layout.d.ts +27 -0
- package/dist/sdk/components/layout.d.ts.map +1 -0
- package/dist/sdk/components/node-card.d.ts +10 -0
- package/dist/sdk/components/node-card.d.ts.map +1 -0
- package/dist/sdk/components/orchestrator-panel-contexts.d.ts +16 -0
- package/dist/sdk/components/orchestrator-panel-contexts.d.ts.map +1 -0
- package/dist/sdk/components/orchestrator-panel-store.d.ts +50 -0
- package/dist/sdk/components/orchestrator-panel-store.d.ts.map +1 -0
- package/dist/sdk/components/orchestrator-panel-types.d.ts +18 -0
- package/dist/sdk/components/orchestrator-panel-types.d.ts.map +1 -0
- package/dist/sdk/components/orchestrator-panel.d.ts +56 -0
- package/dist/sdk/components/orchestrator-panel.d.ts.map +1 -0
- package/dist/sdk/components/session-graph-panel.d.ts +7 -0
- package/dist/sdk/components/session-graph-panel.d.ts.map +1 -0
- package/dist/sdk/components/status-helpers.d.ts +6 -0
- package/dist/sdk/components/status-helpers.d.ts.map +1 -0
- package/dist/sdk/components/statusline.d.ts +7 -0
- package/dist/sdk/components/statusline.d.ts.map +1 -0
- package/dist/sdk/components/workflow-picker-panel.d.ts +128 -0
- package/dist/sdk/components/workflow-picker-panel.d.ts.map +1 -0
- package/dist/sdk/define-workflow.d.ts +91 -0
- package/dist/sdk/define-workflow.d.ts.map +1 -0
- package/dist/sdk/errors.d.ts +24 -0
- package/dist/sdk/errors.d.ts.map +1 -0
- package/dist/sdk/index.d.ts +13 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/providers/claude.d.ts +187 -0
- package/dist/sdk/providers/claude.d.ts.map +1 -0
- package/dist/sdk/providers/copilot.d.ts +11 -0
- package/dist/sdk/providers/copilot.d.ts.map +1 -0
- package/dist/sdk/providers/opencode.d.ts +11 -0
- package/dist/sdk/providers/opencode.d.ts.map +1 -0
- package/dist/sdk/runtime/discovery.d.ts +86 -0
- package/dist/sdk/runtime/discovery.d.ts.map +1 -0
- package/dist/sdk/runtime/executor-entry.d.ts +11 -0
- package/dist/sdk/runtime/executor-entry.d.ts.map +1 -0
- package/dist/sdk/runtime/executor.d.ts +72 -0
- package/dist/sdk/runtime/executor.d.ts.map +1 -0
- package/dist/sdk/runtime/graph-inference.d.ts +35 -0
- package/dist/sdk/runtime/graph-inference.d.ts.map +1 -0
- package/dist/sdk/runtime/loader.d.ts +70 -0
- package/dist/sdk/runtime/loader.d.ts.map +1 -0
- package/dist/sdk/runtime/panel.d.ts +9 -0
- package/dist/sdk/runtime/panel.d.ts.map +1 -0
- package/dist/sdk/runtime/theme.d.ts +28 -0
- package/dist/sdk/runtime/theme.d.ts.map +1 -0
- package/dist/sdk/runtime/tmux.d.ts +297 -0
- package/dist/sdk/runtime/tmux.d.ts.map +1 -0
- package/dist/sdk/types.d.ts +309 -0
- package/dist/sdk/types.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/claude/index.d.ts +62 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/claude/index.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/copilot/index.d.ts +46 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/copilot/index.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/heuristic.d.ts +26 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/heuristic.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/prompts.d.ts +92 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/prompts.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/scout.d.ts +57 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/scout.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/opencode/index.d.ts +49 -0
- package/dist/sdk/workflows/builtin/deep-research-codebase/opencode/index.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/ralph/claude/index.d.ts +18 -0
- package/dist/sdk/workflows/builtin/ralph/claude/index.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/ralph/copilot/index.d.ts +19 -0
- package/dist/sdk/workflows/builtin/ralph/copilot/index.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/ralph/helpers/git.d.ts +69 -0
- package/dist/sdk/workflows/builtin/ralph/helpers/git.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/ralph/helpers/prompts.d.ts +240 -0
- package/dist/sdk/workflows/builtin/ralph/helpers/prompts.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/ralph/helpers/review.d.ts +20 -0
- package/dist/sdk/workflows/builtin/ralph/helpers/review.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin/ralph/opencode/index.d.ts +18 -0
- package/dist/sdk/workflows/builtin/ralph/opencode/index.d.ts.map +1 -0
- package/dist/sdk/workflows/index.d.ts +24 -0
- package/dist/sdk/workflows/index.d.ts.map +1 -0
- package/dist/services/config/definitions.d.ts +85 -0
- package/dist/services/config/definitions.d.ts.map +1 -0
- package/dist/services/system/copy.d.ts +77 -0
- package/dist/services/system/copy.d.ts.map +1 -0
- package/dist/services/system/detect.d.ts +75 -0
- package/dist/services/system/detect.d.ts.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tmux session and pane management utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides low-level tmux operations for the workflow runtime:
|
|
5
|
+
* creating sessions, splitting panes, spawning commands, capturing output,
|
|
6
|
+
* sending keystrokes, and pane state detection.
|
|
7
|
+
*/
|
|
8
|
+
import type { Subprocess } from "bun";
|
|
9
|
+
/** Dedicated tmux socket name — isolates Atomic sessions from the user's default server. */
|
|
10
|
+
export declare const SOCKET_NAME = "atomic";
|
|
11
|
+
/** Discriminated result from a tmux command execution. */
|
|
12
|
+
export type TmuxResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
stdout: string;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
stderr: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const TMUX_DEFAULT_STATUS_LEFT = " ";
|
|
20
|
+
export declare const TMUX_DEFAULT_STATUS_LEFT_LENGTH = "10";
|
|
21
|
+
export declare const TMUX_DEFAULT_STATUS_RIGHT = " #{session_name} | %H:%M ";
|
|
22
|
+
export declare const TMUX_DEFAULT_STATUS_RIGHT_LENGTH = "60";
|
|
23
|
+
export declare const TMUX_ATTACHED_STATUS_RIGHT = "#[fg=#cdd6f4]ctrl+g #[fg=#6c7086]graph #[fg=#585b70]\u00B7 #[fg=#cdd6f4]ctrl+\\ #[fg=#6c7086]next ";
|
|
24
|
+
export declare const TMUX_ATTACHED_STATUS_RIGHT_LENGTH = "40";
|
|
25
|
+
export declare const TMUX_ATTACHED_WINDOW_FMT = "#{?#{==:#{window_index},0},, #W }";
|
|
26
|
+
export declare const TMUX_ATTACHED_WINDOW_STYLE = "fg=#6c7086";
|
|
27
|
+
export declare const TMUX_ATTACHED_WINDOW_CURRENT_STYLE = "fg=#cdd6f4,bold";
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the terminal multiplexer binary for the current platform.
|
|
30
|
+
*
|
|
31
|
+
* On Windows, tries psmux → pmux → tmux (psmux ships all three as aliases).
|
|
32
|
+
* On Unix/macOS, uses tmux directly.
|
|
33
|
+
*
|
|
34
|
+
* Returns the binary name (not the full path) or null if none is found.
|
|
35
|
+
* The result is cached after the first call.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getMuxBinary(): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Reset the cached multiplexer binary resolution.
|
|
40
|
+
* Call after installing tmux/psmux to force re-detection.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resetMuxBinaryCache(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Check if tmux is installed and available.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isTmuxInstalled(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Check if we're currently inside a tmux session.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isInsideTmux(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Check if we're inside the atomic tmux socket specifically.
|
|
53
|
+
*
|
|
54
|
+
* The `TMUX` env var has the format `<socket_path>,<pid>,<index>`.
|
|
55
|
+
* On Unix this looks like `/tmp/tmux-1000/atomic,12345,0` when the
|
|
56
|
+
* socket name is "atomic".
|
|
57
|
+
*/
|
|
58
|
+
export declare function isInsideAtomicSocket(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Run a tmux command and return a result object.
|
|
61
|
+
* Prefers this over the throwing `tmux()` for cases where callers
|
|
62
|
+
* need to handle failure gracefully.
|
|
63
|
+
*/
|
|
64
|
+
export declare function tmuxRun(args: string[]): TmuxResult;
|
|
65
|
+
/**
|
|
66
|
+
* Create a new tmux session with the given name.
|
|
67
|
+
* The session starts detached with an initial command in the first pane.
|
|
68
|
+
*
|
|
69
|
+
* @param sessionName - Unique session name
|
|
70
|
+
* @param initialCommand - Shell command to run in the initial pane
|
|
71
|
+
* @param windowName - Optional name for the initial window
|
|
72
|
+
* @param cwd - Optional working directory for the initial pane
|
|
73
|
+
* @param envVars - Optional environment variables for the initial pane
|
|
74
|
+
* @returns The pane ID of the initial pane (e.g., "%0")
|
|
75
|
+
*/
|
|
76
|
+
export declare function createSession(sessionName: string, initialCommand: string, windowName?: string, cwd?: string, envVars?: Record<string, string>): string;
|
|
77
|
+
/**
|
|
78
|
+
* Create a new window in an existing session without switching focus.
|
|
79
|
+
*
|
|
80
|
+
* @param sessionName - Target session name
|
|
81
|
+
* @param windowName - Name for the new window
|
|
82
|
+
* @param command - Shell command to run in the new window
|
|
83
|
+
* @param cwd - Optional working directory for the new window
|
|
84
|
+
* @param envVars - Optional environment variables for the new window
|
|
85
|
+
* @returns The pane ID of the new window's pane
|
|
86
|
+
*/
|
|
87
|
+
export declare function createWindow(sessionName: string, windowName: string, command: string, cwd?: string, envVars?: Record<string, string>): string;
|
|
88
|
+
/**
|
|
89
|
+
* Create a new pane in an existing session by splitting.
|
|
90
|
+
*
|
|
91
|
+
* @returns The pane ID of the new pane
|
|
92
|
+
*/
|
|
93
|
+
export declare function createPane(sessionName: string, command: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Send literal text to a tmux pane using `-l` flag (no special key interpretation).
|
|
96
|
+
* Uses `--` to prevent text starting with `-` from being parsed as flags.
|
|
97
|
+
*
|
|
98
|
+
* For large text payloads, prefer {@link sendViaPasteBuffer} which bypasses
|
|
99
|
+
* tmux's ~16 KB internal message buffer limit.
|
|
100
|
+
*/
|
|
101
|
+
export declare function sendLiteralText(paneId: string, text: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* Send text to a tmux pane via the paste buffer.
|
|
104
|
+
*
|
|
105
|
+
* More reliable than `send-keys -l` for large text:
|
|
106
|
+
* - No OS ARG_MAX / MAX_ARG_STRLEN limits (text goes through a temp file)
|
|
107
|
+
* - Atomic delivery — the entire text is pasted at once
|
|
108
|
+
* - No chunking needed
|
|
109
|
+
*
|
|
110
|
+
* Newlines are normalized to spaces to prevent premature submission,
|
|
111
|
+
* matching `sendLiteralText`'s behavior.
|
|
112
|
+
*/
|
|
113
|
+
export declare function sendViaPasteBuffer(paneId: string, text: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Send a special key (C-m, C-c, C-u, Tab, etc.) to a tmux pane.
|
|
116
|
+
*/
|
|
117
|
+
export declare function sendSpecialKey(paneId: string, key: string): void;
|
|
118
|
+
/**
|
|
119
|
+
* Send literal text and submit with C-m (carriage return).
|
|
120
|
+
* Uses C-m instead of Enter for raw-mode TUI compatibility.
|
|
121
|
+
*
|
|
122
|
+
* @param presses - Number of C-m presses (default: 1)
|
|
123
|
+
* @param delayMs - Delay between presses in ms (default: 100)
|
|
124
|
+
*/
|
|
125
|
+
export declare function sendKeysAndSubmit(paneId: string, text: string, presses?: number, delayMs?: number): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Capture the visible content of a tmux pane.
|
|
128
|
+
*
|
|
129
|
+
* @param paneId - The pane ID (e.g., "%0")
|
|
130
|
+
* @param start - Start line (negative = from bottom, default: capture visible only)
|
|
131
|
+
*/
|
|
132
|
+
export declare function capturePane(paneId: string, start?: number): string;
|
|
133
|
+
/**
|
|
134
|
+
* Capture only the visible portion of a pane (no scrollback).
|
|
135
|
+
* Preferred for state detection (ready/busy) to avoid stale prompt lines
|
|
136
|
+
* or old activity indicators in scrollback triggering false positives.
|
|
137
|
+
* Returns empty string on failure instead of throwing.
|
|
138
|
+
*/
|
|
139
|
+
export declare function capturePaneVisible(paneId: string): string;
|
|
140
|
+
/**
|
|
141
|
+
* Capture last N lines of scrollback from a pane.
|
|
142
|
+
* Preferred for output collection where you need recent history.
|
|
143
|
+
* Returns empty string on failure instead of throwing.
|
|
144
|
+
*/
|
|
145
|
+
export declare function capturePaneScrollback(paneId: string, lines?: number): string;
|
|
146
|
+
/**
|
|
147
|
+
* Kill a tmux session.
|
|
148
|
+
*/
|
|
149
|
+
export declare function killSession(sessionName: string): void;
|
|
150
|
+
/** Kill a specific tmux window within a session. Silences errors if already dead. */
|
|
151
|
+
export declare function killWindow(sessionName: string, windowName: string): void;
|
|
152
|
+
/**
|
|
153
|
+
* Check if a tmux session exists.
|
|
154
|
+
*/
|
|
155
|
+
export declare function sessionExists(sessionName: string): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Set a session-level environment variable.
|
|
158
|
+
* Uses `tmux set-environment -t <session>` so the value is scoped to
|
|
159
|
+
* the individual session, not the global server environment.
|
|
160
|
+
*/
|
|
161
|
+
export declare function setSessionEnv(sessionName: string, key: string, value: string): void;
|
|
162
|
+
/**
|
|
163
|
+
* Read a session-level environment variable.
|
|
164
|
+
* Returns `null` when the session doesn't exist or the variable isn't set.
|
|
165
|
+
*/
|
|
166
|
+
export declare function getSessionEnv(sessionName: string, key: string): string | null;
|
|
167
|
+
/** Session type derived from the session name prefix. */
|
|
168
|
+
export type SessionType = "chat" | "workflow";
|
|
169
|
+
/**
|
|
170
|
+
* Parse a session name into its type and agent.
|
|
171
|
+
*
|
|
172
|
+
* Naming conventions:
|
|
173
|
+
* Chat: atomic-chat-<agent>-<id>
|
|
174
|
+
* Workflow: atomic-wf-<agent>-<name>-<id>
|
|
175
|
+
*
|
|
176
|
+
* Agent names are a known, hyphen-free set (claude, copilot, opencode)
|
|
177
|
+
* so parsing is unambiguous even when the workflow name contains hyphens.
|
|
178
|
+
*/
|
|
179
|
+
export declare function parseSessionName(name: string): {
|
|
180
|
+
type?: SessionType;
|
|
181
|
+
agent?: string;
|
|
182
|
+
};
|
|
183
|
+
/** A single tmux session on the atomic socket. */
|
|
184
|
+
export interface TmuxSession {
|
|
185
|
+
/** Session name (e.g. "atomic-chat-claude-a1b2c3d4") */
|
|
186
|
+
name: string;
|
|
187
|
+
/** Number of windows in the session */
|
|
188
|
+
windows: number;
|
|
189
|
+
/** ISO 8601 creation timestamp */
|
|
190
|
+
created: string;
|
|
191
|
+
/** Whether a client is currently attached */
|
|
192
|
+
attached: boolean;
|
|
193
|
+
/** Session type derived from the name prefix */
|
|
194
|
+
type?: SessionType;
|
|
195
|
+
/** Agent backend that owns this session (e.g. "claude", "copilot", "opencode") */
|
|
196
|
+
agent?: string;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* List all sessions on the atomic tmux socket.
|
|
200
|
+
*
|
|
201
|
+
* Uses a custom format string so output is machine-parseable regardless of
|
|
202
|
+
* locale. Returns an empty array when the server isn't running or has no
|
|
203
|
+
* sessions (tmux exits non-zero in both cases).
|
|
204
|
+
*/
|
|
205
|
+
export declare function listSessions(): TmuxSession[];
|
|
206
|
+
/**
|
|
207
|
+
* Attach to an existing tmux session (takes over the current terminal).
|
|
208
|
+
*/
|
|
209
|
+
export declare function attachSession(sessionName: string): void;
|
|
210
|
+
/**
|
|
211
|
+
* Spawn an interactive attach-session process.
|
|
212
|
+
* Encapsulates binary resolution, config injection, and socket isolation.
|
|
213
|
+
* Used by all async attach call sites (executor, chat).
|
|
214
|
+
*/
|
|
215
|
+
export declare function spawnMuxAttach(sessionName: string): Subprocess;
|
|
216
|
+
/**
|
|
217
|
+
* Switch the current tmux client to a different session.
|
|
218
|
+
* Use this instead of `attachSession` when already inside tmux to avoid
|
|
219
|
+
* creating a nested tmux client.
|
|
220
|
+
*/
|
|
221
|
+
export declare function switchClient(sessionName: string): void;
|
|
222
|
+
/**
|
|
223
|
+
* Get the name of the current tmux session (when running inside tmux).
|
|
224
|
+
* Returns null if not inside tmux or if the query fails.
|
|
225
|
+
*/
|
|
226
|
+
export declare function getCurrentSession(): string | null;
|
|
227
|
+
/**
|
|
228
|
+
* Attach or switch to a tmux session depending on whether we're already
|
|
229
|
+
* inside tmux. Avoids nested tmux clients.
|
|
230
|
+
*
|
|
231
|
+
* - Outside tmux: spawns `attach-session` (blocks until session ends).
|
|
232
|
+
* - Inside tmux: runs `switch-client` (returns immediately).
|
|
233
|
+
*/
|
|
234
|
+
export declare function attachOrSwitch(sessionName: string): void;
|
|
235
|
+
/**
|
|
236
|
+
* Detach from the user's current tmux session and replace the client
|
|
237
|
+
* with an attach to a session on the atomic socket.
|
|
238
|
+
*
|
|
239
|
+
* Uses `detach-client -E` so the user's terminal seamlessly transitions
|
|
240
|
+
* from their tmux session to the atomic session — no nesting.
|
|
241
|
+
* Their original tmux session stays alive; they can re-attach with
|
|
242
|
+
* `tmux attach` after leaving the atomic session.
|
|
243
|
+
*
|
|
244
|
+
* Only call when {@link isInsideTmux} returns `true`.
|
|
245
|
+
*/
|
|
246
|
+
export declare function detachAndAttachAtomic(sessionName: string): void;
|
|
247
|
+
/**
|
|
248
|
+
* Select (switch to) a window within the current tmux session.
|
|
249
|
+
*/
|
|
250
|
+
export declare function selectWindow(target: string): void;
|
|
251
|
+
/**
|
|
252
|
+
* Collapse all whitespace to single spaces for robust capture comparison.
|
|
253
|
+
* Prevents false negatives from tmux inserting/stripping whitespace.
|
|
254
|
+
*/
|
|
255
|
+
export declare function normalizeTmuxCapture(text: string): string;
|
|
256
|
+
/**
|
|
257
|
+
* Normalize captured text preserving line structure (for display output).
|
|
258
|
+
*/
|
|
259
|
+
export declare function normalizeTmuxLines(text: string): string;
|
|
260
|
+
/**
|
|
261
|
+
* Returns true when the pane shows an agent prompt ready for input.
|
|
262
|
+
* Detects Claude Code (❯), Codex (›), and generic (>) prompts.
|
|
263
|
+
*/
|
|
264
|
+
export declare function paneLooksReady(captured: string): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Returns true when the agent has an active task in progress.
|
|
267
|
+
* Checks last 40 lines for known busy indicators.
|
|
268
|
+
*/
|
|
269
|
+
export declare function paneHasActiveTask(captured: string): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Returns true when the pane is idle — showing a prompt and not processing.
|
|
272
|
+
* Uses visible-only capture to avoid stale scrollback matches.
|
|
273
|
+
*/
|
|
274
|
+
export declare function paneIsIdle(paneId: string): boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Wait for the pane to be idle (prompt visible, no active task) with
|
|
277
|
+
* exponential backoff. Returns the time spent waiting (ms).
|
|
278
|
+
*/
|
|
279
|
+
export declare function waitForPaneReady(paneId: string, timeoutMs?: number): Promise<number>;
|
|
280
|
+
/**
|
|
281
|
+
* Attempt to submit by pressing C-m, verifying after each round.
|
|
282
|
+
* Returns true as soon as the trigger text disappears from the visible
|
|
283
|
+
* capture or an active task is detected.
|
|
284
|
+
*/
|
|
285
|
+
export declare function attemptSubmitRounds(paneId: string, normalizedPrompt: string, rounds: number, pressesPerRound?: number): Promise<boolean>;
|
|
286
|
+
/**
|
|
287
|
+
* Wait for a pattern to appear in a tmux pane's output.
|
|
288
|
+
* Polls the pane content at the given interval until the pattern matches
|
|
289
|
+
* or the timeout is reached.
|
|
290
|
+
*
|
|
291
|
+
* @returns The full pane content when the pattern was found
|
|
292
|
+
*/
|
|
293
|
+
export declare function waitForOutput(paneId: string, pattern: RegExp, options?: {
|
|
294
|
+
timeoutMs?: number;
|
|
295
|
+
pollIntervalMs?: number;
|
|
296
|
+
}): Promise<string>;
|
|
297
|
+
//# sourceMappingURL=tmux.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tmux.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/tmux.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAMtC,4FAA4F;AAC5F,eAAO,MAAM,WAAW,WAAW,CAAC;AAKpC,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAWlC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,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AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMvD;AAwBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAWxD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAW3D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGlD;AAMD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,MAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAelG;AAMD;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE,MAAM,EACd,eAAe,GAAE,MAAU,GAC1B,OAAO,CAAC,OAAO,CAAC,CAqBlB;AAMD;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5D,OAAO,CAAC,MAAM,CAAC,CAajB"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow SDK Types
|
|
3
|
+
*
|
|
4
|
+
* Uses native SDK types directly — no re-definitions.
|
|
5
|
+
*/
|
|
6
|
+
import type { SessionEvent } from "@github/copilot-sdk";
|
|
7
|
+
import type { SessionPromptResponse } from "@opencode-ai/sdk/v2";
|
|
8
|
+
import type { SessionMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
9
|
+
import type { CopilotClient, CopilotClientOptions, CopilotSession, SessionConfig as CopilotSessionConfig } from "@github/copilot-sdk";
|
|
10
|
+
import type { OpencodeClient, Session as OpencodeSession } from "@opencode-ai/sdk/v2";
|
|
11
|
+
import type { ClaudeClientWrapper, ClaudeSessionWrapper, ClaudeQueryDefaults } from "./providers/claude.ts";
|
|
12
|
+
/** Supported agent types */
|
|
13
|
+
export type AgentType = "copilot" | "opencode" | "claude";
|
|
14
|
+
/**
|
|
15
|
+
* Maps each agent to the client init options the user passes to `ctx.stage()`.
|
|
16
|
+
* Auto-injected fields (`cliUrl`, `baseUrl`, `paneId`) are omitted.
|
|
17
|
+
*/
|
|
18
|
+
type ClientOptionsMap = {
|
|
19
|
+
opencode: {
|
|
20
|
+
directory?: string;
|
|
21
|
+
experimental_workspaceID?: string;
|
|
22
|
+
};
|
|
23
|
+
copilot: Omit<CopilotClientOptions, "cliUrl">;
|
|
24
|
+
claude: {
|
|
25
|
+
chatFlags?: string[];
|
|
26
|
+
readyTimeoutMs?: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Maps each agent to the session create options the user passes to `ctx.stage()`.
|
|
31
|
+
* - OpenCode: `client.session.create()` body params
|
|
32
|
+
* - Copilot: `client.createSession()` config (onPermissionRequest defaults to approveAll)
|
|
33
|
+
* - Claude: `claudeQuery()` defaults for subsequent queries
|
|
34
|
+
*/
|
|
35
|
+
type SessionOptionsMap = {
|
|
36
|
+
opencode: {
|
|
37
|
+
parentID?: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
workspaceID?: string;
|
|
40
|
+
};
|
|
41
|
+
copilot: Partial<CopilotSessionConfig>;
|
|
42
|
+
claude: ClaudeQueryDefaults;
|
|
43
|
+
};
|
|
44
|
+
/** Maps each agent to the `s.client` type provided in the stage callback. */
|
|
45
|
+
type ClientMap = {
|
|
46
|
+
opencode: OpencodeClient;
|
|
47
|
+
copilot: CopilotClient;
|
|
48
|
+
claude: ClaudeClientWrapper;
|
|
49
|
+
};
|
|
50
|
+
/** Maps each agent to the `s.session` type provided in the stage callback. */
|
|
51
|
+
type SessionMap = {
|
|
52
|
+
opencode: OpencodeSession;
|
|
53
|
+
copilot: CopilotSession;
|
|
54
|
+
claude: ClaudeSessionWrapper;
|
|
55
|
+
};
|
|
56
|
+
/** Client init options for `ctx.stage()`, resolved by agent type. */
|
|
57
|
+
export type StageClientOptions<A extends AgentType> = ClientOptionsMap[A];
|
|
58
|
+
/** Session create options for `ctx.stage()`, resolved by agent type. */
|
|
59
|
+
export type StageSessionOptions<A extends AgentType> = SessionOptionsMap[A];
|
|
60
|
+
/** The `s.client` type in a stage callback, resolved by agent type. */
|
|
61
|
+
export type ProviderClient<A extends AgentType> = ClientMap[A];
|
|
62
|
+
/** The `s.session` type in a stage callback, resolved by agent type. */
|
|
63
|
+
export type ProviderSession<A extends AgentType> = SessionMap[A];
|
|
64
|
+
export type { CopilotClient, CopilotClientOptions, CopilotSession, CopilotSessionConfig, OpencodeClient, OpencodeSession, ClaudeClientWrapper, ClaudeSessionWrapper, ClaudeQueryDefaults, };
|
|
65
|
+
/** A source validation warning emitted by provider-specific workflow validators. */
|
|
66
|
+
export interface ValidationWarning {
|
|
67
|
+
rule: string;
|
|
68
|
+
message: string;
|
|
69
|
+
}
|
|
70
|
+
/** A declarative validation rule: pattern to match + warning to emit. */
|
|
71
|
+
export interface ValidationRule {
|
|
72
|
+
pattern: RegExp;
|
|
73
|
+
rule: string;
|
|
74
|
+
message: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Run a set of regex-based validation rules against workflow source code.
|
|
78
|
+
* Returns a warning for each matching pattern.
|
|
79
|
+
*/
|
|
80
|
+
export declare function validateWorkflowSource(source: string, rules: readonly ValidationRule[]): ValidationWarning[];
|
|
81
|
+
/**
|
|
82
|
+
* Create a provider-specific workflow validator from a set of rules.
|
|
83
|
+
* Eliminates boilerplate — each provider file only needs to declare its rules.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createProviderValidator(rules: readonly ValidationRule[]): (source: string) => ValidationWarning[];
|
|
86
|
+
/**
|
|
87
|
+
* Supported field types for a workflow's declared inputs.
|
|
88
|
+
*
|
|
89
|
+
* - `"string"` — single-line free-form input (short values, identifiers, paths)
|
|
90
|
+
* - `"text"` — multi-line free-form input (long prose, prompts, specs)
|
|
91
|
+
* - `"enum"` — one of a fixed list of allowed `values`
|
|
92
|
+
*/
|
|
93
|
+
export type WorkflowInputType = "string" | "text" | "enum";
|
|
94
|
+
/**
|
|
95
|
+
* A declared input for a workflow. When a workflow provides an `inputs`
|
|
96
|
+
* array, the CLI materialises one `--<name>` flag per input (and the
|
|
97
|
+
* interactive picker renders one field per input) so users can pass
|
|
98
|
+
* structured values rather than a single free-form prompt.
|
|
99
|
+
*
|
|
100
|
+
* Leaving `inputs` unset (or empty) signals that the workflow consumes a
|
|
101
|
+
* single free-form prompt instead — the legacy
|
|
102
|
+
* `atomic workflow -n <name> -a <agent> "prompt"` form.
|
|
103
|
+
*/
|
|
104
|
+
export interface WorkflowInput {
|
|
105
|
+
/** Field name — also the CLI flag (`--<name>`) and form field identifier. */
|
|
106
|
+
name: string;
|
|
107
|
+
/** Input kind — see {@link WorkflowInputType}. */
|
|
108
|
+
type: WorkflowInputType;
|
|
109
|
+
/** Whether the field must be non-empty before the workflow can run. */
|
|
110
|
+
required?: boolean;
|
|
111
|
+
/** Short human description shown as the field caption. */
|
|
112
|
+
description?: string;
|
|
113
|
+
/** Placeholder text shown when the field is empty. */
|
|
114
|
+
placeholder?: string;
|
|
115
|
+
/** Default value pre-filled into the field. Enums use this to pick their initial value. */
|
|
116
|
+
default?: string;
|
|
117
|
+
/** Allowed values — required when `type` is `"enum"`. */
|
|
118
|
+
values?: readonly string[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A transcript from a completed session.
|
|
122
|
+
* Provides both the file path and rendered text content.
|
|
123
|
+
*/
|
|
124
|
+
export interface Transcript {
|
|
125
|
+
/** Absolute path to the transcript file on disk */
|
|
126
|
+
path: string;
|
|
127
|
+
/** The transcript content (assistant text extracted from messages) */
|
|
128
|
+
content: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A saved message from any provider, stored as JSON.
|
|
132
|
+
* Uses native SDK types directly.
|
|
133
|
+
*/
|
|
134
|
+
export type SavedMessage = {
|
|
135
|
+
provider: "copilot";
|
|
136
|
+
data: SessionEvent;
|
|
137
|
+
} | {
|
|
138
|
+
provider: "opencode";
|
|
139
|
+
data: SessionPromptResponse;
|
|
140
|
+
} | {
|
|
141
|
+
provider: "claude";
|
|
142
|
+
data: SessionMessage;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Save native message objects from the provider SDK.
|
|
146
|
+
*
|
|
147
|
+
* - **Copilot**: `s.save(await s.session.getMessages())`
|
|
148
|
+
* - **OpenCode**: `s.save(result.data)` — the full `{ info, parts }` response
|
|
149
|
+
* - **Claude**: `s.save(sessionId)` — auto-reads via `getSessionMessages()`
|
|
150
|
+
*/
|
|
151
|
+
export interface SaveTranscript {
|
|
152
|
+
/** Save Copilot SessionEvent[] from session.getMessages() */
|
|
153
|
+
(messages: SessionEvent[]): Promise<void>;
|
|
154
|
+
/** Save OpenCode prompt response `{ info, parts }` from session.prompt().data */
|
|
155
|
+
(response: SessionPromptResponse): Promise<void>;
|
|
156
|
+
/** Save Claude messages — pass the session ID to auto-read transcript */
|
|
157
|
+
(claudeSessionId: string): Promise<void>;
|
|
158
|
+
}
|
|
159
|
+
/** A reference to a completed session — either a handle or a session name string. */
|
|
160
|
+
export type SessionRef = string | SessionHandle<unknown>;
|
|
161
|
+
/**
|
|
162
|
+
* Handle returned by `ctx.stage()`. Used for type-safe transcript references
|
|
163
|
+
* and carries the callback's return value.
|
|
164
|
+
*/
|
|
165
|
+
export interface SessionHandle<T = void> {
|
|
166
|
+
/** The session's unique name */
|
|
167
|
+
readonly name: string;
|
|
168
|
+
/** The session's generated UUID */
|
|
169
|
+
readonly id: string;
|
|
170
|
+
/** The value returned by the session callback */
|
|
171
|
+
readonly result: T;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Options for spawning a session via `ctx.stage()`.
|
|
175
|
+
*/
|
|
176
|
+
export interface SessionRunOptions {
|
|
177
|
+
/** Unique name for this session (used for transcript references and graph display) */
|
|
178
|
+
name: string;
|
|
179
|
+
/** Human-readable description */
|
|
180
|
+
description?: string;
|
|
181
|
+
/**
|
|
182
|
+
* When true, spawn the CLI server as a background child process (Bun.spawn)
|
|
183
|
+
* instead of creating a tmux window. The provider client/session are still
|
|
184
|
+
* auto-created but the stage is invisible in the graph. Useful for
|
|
185
|
+
* Copilot/OpenCode SDKs that need a server but don't need a visible TUI.
|
|
186
|
+
*/
|
|
187
|
+
headless?: boolean;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Context provided to each session's callback.
|
|
191
|
+
* Created by `ctx.stage(opts, clientOpts, sessionOpts, fn)` — the callback
|
|
192
|
+
* receives this as its argument with pre-initialized `client` and `session`.
|
|
193
|
+
*/
|
|
194
|
+
export interface SessionContext<A extends AgentType = AgentType, N extends string = string> {
|
|
195
|
+
/** Provider-specific SDK client (auto-created by runtime) */
|
|
196
|
+
client: ProviderClient<A>;
|
|
197
|
+
/** Provider-specific session (auto-created by runtime) */
|
|
198
|
+
session: ProviderSession<A>;
|
|
199
|
+
/**
|
|
200
|
+
* Structured inputs for this workflow run. Populated from CLI flags
|
|
201
|
+
* (`--<name>=<value>`) or the interactive picker.
|
|
202
|
+
*
|
|
203
|
+
* When the workflow declares an `inputs` schema, only the declared
|
|
204
|
+
* field names are valid keys — accessing undeclared fields is a
|
|
205
|
+
* compile-time error. Free-form workflows (no declared schema)
|
|
206
|
+
* allow any key, including the conventional `prompt` key.
|
|
207
|
+
*/
|
|
208
|
+
inputs: {
|
|
209
|
+
[K in N]?: string;
|
|
210
|
+
};
|
|
211
|
+
/** Which agent is running */
|
|
212
|
+
agent: A;
|
|
213
|
+
/**
|
|
214
|
+
* Get a completed session's transcript as rendered text.
|
|
215
|
+
* Accepts a SessionHandle (recommended) or session name string.
|
|
216
|
+
*/
|
|
217
|
+
transcript(ref: SessionRef): Promise<Transcript>;
|
|
218
|
+
/**
|
|
219
|
+
* Get a completed session's raw native messages.
|
|
220
|
+
* Accepts a SessionHandle (recommended) or session name string.
|
|
221
|
+
*/
|
|
222
|
+
getMessages(ref: SessionRef): Promise<SavedMessage[]>;
|
|
223
|
+
/**
|
|
224
|
+
* Save this session's output for subsequent sessions.
|
|
225
|
+
* Accepts native SDK message objects only.
|
|
226
|
+
*/
|
|
227
|
+
save: SaveTranscript;
|
|
228
|
+
/** Path to this session's storage directory on disk */
|
|
229
|
+
sessionDir: string;
|
|
230
|
+
/** tmux pane ID for this session */
|
|
231
|
+
paneId: string;
|
|
232
|
+
/** Session UUID */
|
|
233
|
+
sessionId: string;
|
|
234
|
+
/**
|
|
235
|
+
* Spawn a nested sub-session with its own tmux window and graph node.
|
|
236
|
+
* The sub-session is a child of this session in the graph.
|
|
237
|
+
* The callback's return value is available as `handle.result`.
|
|
238
|
+
*/
|
|
239
|
+
stage<T = void>(options: SessionRunOptions, clientOpts: StageClientOptions<A>, sessionOpts: StageSessionOptions<A>, run: (ctx: SessionContext<A, N>) => Promise<T>): Promise<SessionHandle<T>>;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Top-level context provided to the workflow's `.run()` callback.
|
|
243
|
+
* Does not have session-specific fields (paneId, save, etc.).
|
|
244
|
+
*/
|
|
245
|
+
export interface WorkflowContext<A extends AgentType = AgentType, N extends string = string> {
|
|
246
|
+
/**
|
|
247
|
+
* Structured inputs for this workflow run. Populated from CLI flags
|
|
248
|
+
* (`--<name>=<value>`) or the interactive picker.
|
|
249
|
+
*
|
|
250
|
+
* When the workflow declares an `inputs` schema, only the declared
|
|
251
|
+
* field names are valid keys — accessing undeclared fields is a
|
|
252
|
+
* compile-time error. Free-form workflows (no declared schema)
|
|
253
|
+
* allow any key, including the conventional `prompt` key.
|
|
254
|
+
*/
|
|
255
|
+
inputs: {
|
|
256
|
+
[K in N]?: string;
|
|
257
|
+
};
|
|
258
|
+
/** Which agent is running */
|
|
259
|
+
agent: A;
|
|
260
|
+
/**
|
|
261
|
+
* Spawn a session with its own tmux window and graph node.
|
|
262
|
+
* The runtime manages the full lifecycle: create client → create session →
|
|
263
|
+
* run callback → cleanup. The callback's return value is available as
|
|
264
|
+
* `handle.result`.
|
|
265
|
+
*/
|
|
266
|
+
stage<T = void>(options: SessionRunOptions, clientOpts: StageClientOptions<A>, sessionOpts: StageSessionOptions<A>, run: (ctx: SessionContext<A, N>) => Promise<T>): Promise<SessionHandle<T>>;
|
|
267
|
+
/**
|
|
268
|
+
* Get a completed session's transcript as rendered text.
|
|
269
|
+
* Accepts a SessionHandle (recommended) or session name string.
|
|
270
|
+
*/
|
|
271
|
+
transcript(ref: SessionRef): Promise<Transcript>;
|
|
272
|
+
/**
|
|
273
|
+
* Get a completed session's raw native messages.
|
|
274
|
+
* Accepts a SessionHandle (recommended) or session name string.
|
|
275
|
+
*/
|
|
276
|
+
getMessages(ref: SessionRef): Promise<SavedMessage[]>;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Options for defining a workflow.
|
|
280
|
+
*/
|
|
281
|
+
export interface WorkflowOptions<I extends readonly WorkflowInput[] = readonly WorkflowInput[]> {
|
|
282
|
+
/** Unique workflow name */
|
|
283
|
+
name: string;
|
|
284
|
+
/** Human-readable description */
|
|
285
|
+
description?: string;
|
|
286
|
+
/**
|
|
287
|
+
* Optional declared inputs. When provided, the CLI materialises one
|
|
288
|
+
* `--<name>` flag per entry and the interactive picker renders one form
|
|
289
|
+
* field per entry. Leave unset to keep the workflow free-form (a single
|
|
290
|
+
* positional prompt argument).
|
|
291
|
+
*
|
|
292
|
+
* Write the array inline so TypeScript can infer literal input names
|
|
293
|
+
* and enforce them on `ctx.inputs`.
|
|
294
|
+
*/
|
|
295
|
+
inputs?: I;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* A compiled workflow definition — the sealed output of defineWorkflow().compile().
|
|
299
|
+
*/
|
|
300
|
+
export interface WorkflowDefinition<A extends AgentType = AgentType, N extends string = string> {
|
|
301
|
+
readonly __brand: "WorkflowDefinition";
|
|
302
|
+
readonly name: string;
|
|
303
|
+
readonly description: string;
|
|
304
|
+
/** Declared input schema — empty array for free-form workflows. */
|
|
305
|
+
readonly inputs: readonly WorkflowInput[];
|
|
306
|
+
/** The workflow's entry point. Called by the executor with a WorkflowContext. */
|
|
307
|
+
readonly run: (ctx: WorkflowContext<A, N>) => Promise<void>;
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sdk/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,aAAa,IAAI,oBAAoB,EACtC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,cAAc,EACd,OAAO,IAAI,eAAe,EAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAE/B,4BAA4B;AAC5B,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAI1D;;;GAGG;AACH,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,wBAAwB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IAC9C,MAAM,EAAE;QAAE,SAAS,CAAC,EA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