@percena/weft 0.4.0-next.1 → 0.4.0-next.3
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/action-bridge.cjs +11 -0
- package/dist/action-bridge.d.cts +2 -12
- package/dist/action-bridge.d.ts +2 -12
- package/dist/action-bridge.js +5 -0
- package/dist/chat.cjs +5 -0
- package/dist/chat.d.cts +1 -0
- package/dist/chat.d.ts +1 -0
- package/dist/chat.js +4 -0
- package/dist/styles/index.css +2 -212
- package/package.json +27 -26
- package/dist/auth.cjs +0 -241
- package/dist/auth.d.cts +0 -1
- package/dist/auth.d.ts +0 -1
- package/dist/auth.js +0 -208
- package/dist/automations.cjs +0 -3044
- package/dist/automations.d.cts +0 -4774
- package/dist/automations.d.ts +0 -4774
- package/dist/automations.js +0 -2965
- package/dist/factory.cjs +0 -5057
- package/dist/factory.d.cts +0 -7909
- package/dist/factory.d.ts +0 -7909
- package/dist/factory.js +0 -5008
- package/dist/providers.cjs +0 -6154
- package/dist/providers.d.cts +0 -6024
- package/dist/providers.d.ts +0 -6024
- package/dist/providers.js +0 -6110
- package/dist/server.cjs +0 -9137
- package/dist/server.d.cts +0 -9868
- package/dist/server.d.ts +0 -9868
- package/dist/server.js +0 -9118
- package/dist/skills.cjs +0 -505
- package/dist/skills.d.cts +0 -218
- package/dist/skills.d.ts +0 -218
- package/dist/skills.js +0 -458
- package/dist/sources.cjs +0 -1710
- package/dist/sources.d.cts +0 -3978
- package/dist/sources.d.ts +0 -3978
- package/dist/sources.js +0 -1675
package/dist/automations.d.cts
DELETED
|
@@ -1,4774 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// ── inlined from @weft/core ──
|
|
4
|
-
// -- @weft/core/index.d.ts --
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Mode Types and Constants
|
|
8
|
-
*
|
|
9
|
-
* Pure types and UI configuration for permission modes.
|
|
10
|
-
* Note: This file imports zod for schema definitions.
|
|
11
|
-
* Type-only imports (PermissionMode, PermissionModeCanonical) have no runtime cost.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Available permission modes (internal storage keys).
|
|
16
|
-
*
|
|
17
|
-
* UI-facing canonical names are:
|
|
18
|
-
* - explore -> safe
|
|
19
|
-
* - ask -> ask
|
|
20
|
-
* - execute -> allow-all
|
|
21
|
-
*/
|
|
22
|
-
type PermissionMode = 'safe' | 'ask' | 'allow-all';
|
|
23
|
-
/**
|
|
24
|
-
* Canonical mode names used in user-facing/session-state surfaces.
|
|
25
|
-
*/
|
|
26
|
-
type PermissionModeCanonical = 'explore' | 'ask' | 'execute';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Thinking Level Configuration
|
|
30
|
-
*
|
|
31
|
-
* Six-tier thinking system for extended reasoning:
|
|
32
|
-
* - OFF: No extended thinking (disabled)
|
|
33
|
-
* - Low: Light reasoning, faster responses
|
|
34
|
-
* - Medium: Balanced speed and reasoning (default)
|
|
35
|
-
* - High: Deep reasoning for complex tasks
|
|
36
|
-
* - XHigh: Extra-high reasoning — Anthropic's recommended level for Opus 4.7 agentic/coding work
|
|
37
|
-
* - Max: Maximum effort reasoning
|
|
38
|
-
*
|
|
39
|
-
* Session-level setting with workspace defaults.
|
|
40
|
-
*
|
|
41
|
-
* Provider mappings:
|
|
42
|
-
* - Anthropic: adaptive thinking + effort levels (Opus 4.7+). On models that
|
|
43
|
-
* don't accept `xhigh`, the Anthropic SDK silently falls back to `high`.
|
|
44
|
-
* - Pi/OpenAI: reasoning_effort via Pi SDK levels. Pi's ceiling is `xhigh`,
|
|
45
|
-
* so Weft's `max` saturates there.
|
|
46
|
-
*/
|
|
47
|
-
/**
|
|
48
|
-
* Ordered list of valid thinking level IDs. Single source of truth — the
|
|
49
|
-
* `ThinkingLevel` type, `THINKING_LEVELS` metadata, the Zod schema in
|
|
50
|
-
* `validators.ts`, and runtime validation/error messages all derive from this.
|
|
51
|
-
*
|
|
52
|
-
* Order is significant: it determines UI ordering (low → max).
|
|
53
|
-
*/
|
|
54
|
-
declare const THINKING_LEVEL_IDS: readonly ["off", "low", "medium", "high", "xhigh", "max"];
|
|
55
|
-
type ThinkingLevel = (typeof THINKING_LEVEL_IDS)[number];
|
|
56
|
-
interface ThinkingLevelDefinition {
|
|
57
|
-
id: ThinkingLevel;
|
|
58
|
-
/** Translation key for the display name (resolve with t() at render site) */
|
|
59
|
-
nameKey: string;
|
|
60
|
-
/** Translation key for the description (resolve with t() at render site) */
|
|
61
|
-
descriptionKey: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Available thinking levels with display metadata.
|
|
65
|
-
* Used in UI dropdowns and for validation.
|
|
66
|
-
*
|
|
67
|
-
* Labels use translation keys — resolve with t(level.nameKey) in components.
|
|
68
|
-
*/
|
|
69
|
-
declare const THINKING_LEVELS: readonly ThinkingLevelDefinition[];
|
|
70
|
-
/**
|
|
71
|
-
* Map ThinkingLevel to Anthropic SDK effort parameter.
|
|
72
|
-
* Used with adaptive thinking (thinking: { type: 'adaptive' }).
|
|
73
|
-
* Returns null for 'off' (thinking should be disabled entirely).
|
|
74
|
-
*/
|
|
75
|
-
declare const THINKING_TO_EFFORT: Record<ThinkingLevel, 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null>;
|
|
76
|
-
/**
|
|
77
|
-
* Get the thinking token budget for a given level and model.
|
|
78
|
-
* Used as fallback for models that don't support adaptive thinking.
|
|
79
|
-
*
|
|
80
|
-
* @param level - The thinking level
|
|
81
|
-
* @param modelId - The model ID (e.g., 'claude-haiku-4-5-20251001')
|
|
82
|
-
* @returns Number of thinking tokens to allocate
|
|
83
|
-
*/
|
|
84
|
-
declare function getThinkingTokens(level: ThinkingLevel, modelId: string): number;
|
|
85
|
-
/**
|
|
86
|
-
* Get the translation key for a thinking level's display name.
|
|
87
|
-
* Resolve with t() or i18n.t() at the call site.
|
|
88
|
-
*/
|
|
89
|
-
declare function getThinkingLevelNameKey(level: ThinkingLevel): string;
|
|
90
|
-
/**
|
|
91
|
-
* Validate that a value is a valid ThinkingLevel.
|
|
92
|
-
*/
|
|
93
|
-
declare function isValidThinkingLevel(value: unknown): value is ThinkingLevel;
|
|
94
|
-
/**
|
|
95
|
-
* Normalize a persisted thinking level value, handling legacy values.
|
|
96
|
-
* Maps the old 'think' value to 'medium' for backward compatibility.
|
|
97
|
-
*
|
|
98
|
-
* TODO: Remove the legacy 'think' compatibility path after old persisted session
|
|
99
|
-
* and workspace data has realistically aged out across upgrades.
|
|
100
|
-
*
|
|
101
|
-
* @returns The normalized ThinkingLevel, or undefined if the value is invalid
|
|
102
|
-
*/
|
|
103
|
-
declare function normalizeThinkingLevel(value: unknown): ThinkingLevel | undefined;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Server DTO types — data shapes used by RPC handlers and SessionManager.
|
|
107
|
-
*
|
|
108
|
-
* Extracted here so handler code in @weft can import
|
|
109
|
-
* from @weft/protocol without reaching into the app.
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Dynamic status ID referencing workspace status config.
|
|
114
|
-
* Validated at runtime via validateSessionStatus().
|
|
115
|
-
* Falls back to 'todo' if status doesn't exist.
|
|
116
|
-
*/
|
|
117
|
-
type SessionStatus = string;
|
|
118
|
-
type BuiltInStatusId = 'todo' | 'in-progress' | 'needs-review' | 'done' | 'cancelled';
|
|
119
|
-
/**
|
|
120
|
-
* Electron-specific Session type (includes runtime state).
|
|
121
|
-
* Extends core Session with messages array and processing state.
|
|
122
|
-
*/
|
|
123
|
-
interface Session {
|
|
124
|
-
id: string;
|
|
125
|
-
workspaceId: string;
|
|
126
|
-
workspaceName: string;
|
|
127
|
-
name?: string;
|
|
128
|
-
/** Preview of first user message (from JSONL header, for lazy-loaded sessions) */
|
|
129
|
-
preview?: string;
|
|
130
|
-
lastMessageAt: number;
|
|
131
|
-
messages: Message[];
|
|
132
|
-
isProcessing: boolean;
|
|
133
|
-
isFlagged?: boolean;
|
|
134
|
-
/** Permission mode for this session ('safe', 'ask', 'allow-all') */
|
|
135
|
-
permissionMode?: PermissionMode;
|
|
136
|
-
sessionStatus?: SessionStatus;
|
|
137
|
-
/** Labels (additive tags, many-per-session — bare IDs or "id::value" entries) */
|
|
138
|
-
labels?: string[];
|
|
139
|
-
lastReadMessageId?: string;
|
|
140
|
-
/**
|
|
141
|
-
* Explicit unread flag - single source of truth for NEW badge.
|
|
142
|
-
* Set to true when assistant message completes while user is NOT viewing.
|
|
143
|
-
* Set to false when user views the session (and not processing).
|
|
144
|
-
*/
|
|
145
|
-
hasUnread?: boolean;
|
|
146
|
-
enabledSourceSlugs?: string[];
|
|
147
|
-
workingDirectory?: string;
|
|
148
|
-
sessionFolderPath?: string;
|
|
149
|
-
sharedUrl?: string;
|
|
150
|
-
sharedId?: string;
|
|
151
|
-
model?: string;
|
|
152
|
-
llmConnection?: string;
|
|
153
|
-
thinkingLevel?: ThinkingLevel;
|
|
154
|
-
lastMessageRole?: 'user' | 'assistant' | 'plan' | 'tool' | 'error';
|
|
155
|
-
lastFinalMessageId?: string;
|
|
156
|
-
isAsyncOperationOngoing?: boolean;
|
|
157
|
-
/** @deprecated Use isAsyncOperationOngoing instead */
|
|
158
|
-
isRegeneratingTitle?: boolean;
|
|
159
|
-
currentStatus?: {
|
|
160
|
-
message: string;
|
|
161
|
-
statusType?: string;
|
|
162
|
-
};
|
|
163
|
-
createdAt?: number;
|
|
164
|
-
messageCount?: number;
|
|
165
|
-
tokenUsage?: {
|
|
166
|
-
inputTokens: number;
|
|
167
|
-
outputTokens: number;
|
|
168
|
-
totalTokens: number;
|
|
169
|
-
contextTokens: number;
|
|
170
|
-
costUsd: number;
|
|
171
|
-
cacheReadTokens?: number;
|
|
172
|
-
cacheCreationTokens?: number;
|
|
173
|
-
/** Model's context window size in tokens (from SDK modelUsage) */
|
|
174
|
-
contextWindow?: number;
|
|
175
|
-
};
|
|
176
|
-
/** When true, session is hidden from session list (e.g., mini edit sessions) */
|
|
177
|
-
hidden?: boolean;
|
|
178
|
-
isArchived?: boolean;
|
|
179
|
-
archivedAt?: number;
|
|
180
|
-
supportsBranching?: boolean;
|
|
181
|
-
}
|
|
182
|
-
interface CreateSessionOptions {
|
|
183
|
-
name?: string;
|
|
184
|
-
permissionMode?: PermissionMode;
|
|
185
|
-
/**
|
|
186
|
-
* Reasoning/thinking level override. When set, takes precedence over workspace
|
|
187
|
-
* and global defaults. Silently ignored by the underlying SDK on non-reasoning
|
|
188
|
-
* models (e.g. gpt-4o) — provider drivers don't attach the reasoning param to
|
|
189
|
-
* the API request for models with `reasoning: false` in the Pi SDK catalog.
|
|
190
|
-
*/
|
|
191
|
-
thinkingLevel?: ThinkingLevel;
|
|
192
|
-
/**
|
|
193
|
-
* Working directory for the session:
|
|
194
|
-
* - 'user_default' or undefined: Use workspace's configured default working directory
|
|
195
|
-
* - 'none': No working directory (session folder only)
|
|
196
|
-
* - Absolute path string: Use this specific path
|
|
197
|
-
*/
|
|
198
|
-
workingDirectory?: string | 'user_default' | 'none';
|
|
199
|
-
model?: string;
|
|
200
|
-
llmConnection?: string;
|
|
201
|
-
systemPromptPreset?: 'default' | 'mini' | string;
|
|
202
|
-
hidden?: boolean;
|
|
203
|
-
sessionStatus?: SessionStatus;
|
|
204
|
-
labels?: string[];
|
|
205
|
-
isFlagged?: boolean;
|
|
206
|
-
enabledSourceSlugs?: string[];
|
|
207
|
-
/**
|
|
208
|
-
* Message ID to branch from. This is a hard context cutoff:
|
|
209
|
-
* the new session must not include model context from later parent messages.
|
|
210
|
-
*/
|
|
211
|
-
branchFromMessageId?: string;
|
|
212
|
-
/** Parent session ID used together with branchFromMessageId. */
|
|
213
|
-
branchFromSessionId?: string;
|
|
214
|
-
}
|
|
215
|
-
interface RemoteSessionTransferPayload {
|
|
216
|
-
sourceSessionId: string;
|
|
217
|
-
name?: string;
|
|
218
|
-
sessionStatus?: SessionStatus;
|
|
219
|
-
labels?: string[];
|
|
220
|
-
permissionMode?: PermissionMode;
|
|
221
|
-
summary: string;
|
|
222
|
-
}
|
|
223
|
-
interface ImportRemoteSessionTransferResult {
|
|
224
|
-
sessionId: string;
|
|
225
|
-
}
|
|
226
|
-
interface PermissionModeState {
|
|
227
|
-
permissionMode: PermissionMode;
|
|
228
|
-
previousPermissionMode?: PermissionMode;
|
|
229
|
-
transitionDisplay?: string;
|
|
230
|
-
modeVersion: number;
|
|
231
|
-
changedAt: string;
|
|
232
|
-
changedBy: 'user' | 'system' | 'restore' | 'automation' | 'unknown';
|
|
233
|
-
}
|
|
234
|
-
type SessionEvent = {
|
|
235
|
-
type: 'text_delta';
|
|
236
|
-
sessionId: string;
|
|
237
|
-
delta: string;
|
|
238
|
-
turnId?: string;
|
|
239
|
-
} | {
|
|
240
|
-
type: 'text_complete';
|
|
241
|
-
sessionId: string;
|
|
242
|
-
text: string;
|
|
243
|
-
isIntermediate?: boolean;
|
|
244
|
-
turnId?: string;
|
|
245
|
-
parentToolUseId?: string;
|
|
246
|
-
timestamp?: number;
|
|
247
|
-
messageId?: string;
|
|
248
|
-
} | {
|
|
249
|
-
type: 'tool_start';
|
|
250
|
-
sessionId: string;
|
|
251
|
-
toolName: string;
|
|
252
|
-
toolUseId: string;
|
|
253
|
-
toolInput: Record<string, unknown>;
|
|
254
|
-
toolIntent?: string;
|
|
255
|
-
toolDisplayName?: string;
|
|
256
|
-
toolDisplayMeta?: ToolDisplayMeta;
|
|
257
|
-
turnId?: string;
|
|
258
|
-
parentToolUseId?: string;
|
|
259
|
-
timestamp?: number;
|
|
260
|
-
} | {
|
|
261
|
-
type: 'tool_result';
|
|
262
|
-
sessionId: string;
|
|
263
|
-
toolUseId: string;
|
|
264
|
-
toolName: string;
|
|
265
|
-
result: string;
|
|
266
|
-
turnId?: string;
|
|
267
|
-
parentToolUseId?: string;
|
|
268
|
-
isError?: boolean;
|
|
269
|
-
timestamp?: number;
|
|
270
|
-
} | {
|
|
271
|
-
type: 'error';
|
|
272
|
-
sessionId: string;
|
|
273
|
-
error: string;
|
|
274
|
-
timestamp?: number;
|
|
275
|
-
} | {
|
|
276
|
-
type: 'typed_error';
|
|
277
|
-
sessionId: string;
|
|
278
|
-
error: TypedError;
|
|
279
|
-
timestamp?: number;
|
|
280
|
-
} | {
|
|
281
|
-
type: 'complete';
|
|
282
|
-
sessionId: string;
|
|
283
|
-
tokenUsage?: Session['tokenUsage'];
|
|
284
|
-
hasUnread?: boolean;
|
|
285
|
-
} | {
|
|
286
|
-
type: 'interrupted';
|
|
287
|
-
sessionId: string;
|
|
288
|
-
message?: Message;
|
|
289
|
-
queuedMessages?: string[];
|
|
290
|
-
} | {
|
|
291
|
-
type: 'status';
|
|
292
|
-
sessionId: string;
|
|
293
|
-
message: string;
|
|
294
|
-
statusType?: 'compacting';
|
|
295
|
-
} | {
|
|
296
|
-
type: 'info';
|
|
297
|
-
sessionId: string;
|
|
298
|
-
message: string;
|
|
299
|
-
statusType?: 'compaction_complete';
|
|
300
|
-
level?: 'info' | 'warning' | 'error' | 'success';
|
|
301
|
-
timestamp?: number;
|
|
302
|
-
} | {
|
|
303
|
-
type: 'title_generated';
|
|
304
|
-
sessionId: string;
|
|
305
|
-
title: string;
|
|
306
|
-
} | {
|
|
307
|
-
type: 'title_regenerating';
|
|
308
|
-
sessionId: string;
|
|
309
|
-
isRegenerating: boolean;
|
|
310
|
-
} | {
|
|
311
|
-
type: 'async_operation';
|
|
312
|
-
sessionId: string;
|
|
313
|
-
isOngoing: boolean;
|
|
314
|
-
} | {
|
|
315
|
-
type: 'working_directory_changed';
|
|
316
|
-
sessionId: string;
|
|
317
|
-
workingDirectory: string;
|
|
318
|
-
} | {
|
|
319
|
-
type: 'permission_request';
|
|
320
|
-
sessionId: string;
|
|
321
|
-
request: PermissionRequest;
|
|
322
|
-
} | {
|
|
323
|
-
type: 'credential_request';
|
|
324
|
-
sessionId: string;
|
|
325
|
-
request: CredentialRequest;
|
|
326
|
-
} | {
|
|
327
|
-
type: 'permission_mode_changed';
|
|
328
|
-
sessionId: string;
|
|
329
|
-
permissionMode: PermissionMode;
|
|
330
|
-
previousPermissionMode?: PermissionMode;
|
|
331
|
-
transitionDisplay?: string;
|
|
332
|
-
modeVersion?: number;
|
|
333
|
-
changedAt?: string;
|
|
334
|
-
changedBy?: PermissionModeState['changedBy'];
|
|
335
|
-
} | {
|
|
336
|
-
type: 'plan_submitted';
|
|
337
|
-
sessionId: string;
|
|
338
|
-
message: Message;
|
|
339
|
-
} | {
|
|
340
|
-
type: 'sources_changed';
|
|
341
|
-
sessionId: string;
|
|
342
|
-
enabledSourceSlugs: string[];
|
|
343
|
-
} | {
|
|
344
|
-
type: 'labels_changed';
|
|
345
|
-
sessionId: string;
|
|
346
|
-
labels: string[];
|
|
347
|
-
} | {
|
|
348
|
-
type: 'connection_changed';
|
|
349
|
-
sessionId: string;
|
|
350
|
-
connectionSlug: string;
|
|
351
|
-
supportsBranching?: boolean;
|
|
352
|
-
} | {
|
|
353
|
-
type: 'task_backgrounded';
|
|
354
|
-
sessionId: string;
|
|
355
|
-
toolUseId: string;
|
|
356
|
-
taskId: string;
|
|
357
|
-
intent?: string;
|
|
358
|
-
turnId?: string;
|
|
359
|
-
} | {
|
|
360
|
-
type: 'shell_backgrounded';
|
|
361
|
-
sessionId: string;
|
|
362
|
-
toolUseId: string;
|
|
363
|
-
shellId: string;
|
|
364
|
-
intent?: string;
|
|
365
|
-
command?: string;
|
|
366
|
-
turnId?: string;
|
|
367
|
-
} | {
|
|
368
|
-
type: 'task_progress';
|
|
369
|
-
sessionId: string;
|
|
370
|
-
toolUseId: string;
|
|
371
|
-
elapsedSeconds: number;
|
|
372
|
-
turnId?: string;
|
|
373
|
-
} | {
|
|
374
|
-
type: 'task_completed';
|
|
375
|
-
sessionId: string;
|
|
376
|
-
taskId: string;
|
|
377
|
-
status: 'completed' | 'failed' | 'stopped';
|
|
378
|
-
outputFile?: string;
|
|
379
|
-
summary?: string;
|
|
380
|
-
turnId?: string;
|
|
381
|
-
} | {
|
|
382
|
-
type: 'shell_killed';
|
|
383
|
-
sessionId: string;
|
|
384
|
-
shellId: string;
|
|
385
|
-
} | {
|
|
386
|
-
type: 'user_message';
|
|
387
|
-
sessionId: string;
|
|
388
|
-
message: Message;
|
|
389
|
-
status: 'accepted' | 'queued' | 'processing';
|
|
390
|
-
optimisticMessageId?: string;
|
|
391
|
-
} | {
|
|
392
|
-
type: 'session_flagged';
|
|
393
|
-
sessionId: string;
|
|
394
|
-
} | {
|
|
395
|
-
type: 'session_unflagged';
|
|
396
|
-
sessionId: string;
|
|
397
|
-
} | {
|
|
398
|
-
type: 'session_archived';
|
|
399
|
-
sessionId: string;
|
|
400
|
-
} | {
|
|
401
|
-
type: 'session_unarchived';
|
|
402
|
-
sessionId: string;
|
|
403
|
-
} | {
|
|
404
|
-
type: 'name_changed';
|
|
405
|
-
sessionId: string;
|
|
406
|
-
name?: string;
|
|
407
|
-
} | {
|
|
408
|
-
type: 'session_model_changed';
|
|
409
|
-
sessionId: string;
|
|
410
|
-
model: string | null;
|
|
411
|
-
} | {
|
|
412
|
-
type: 'session_status_changed';
|
|
413
|
-
sessionId: string;
|
|
414
|
-
sessionStatus: SessionStatus;
|
|
415
|
-
} | {
|
|
416
|
-
type: 'session_deleted';
|
|
417
|
-
sessionId: string;
|
|
418
|
-
} | {
|
|
419
|
-
type: 'session_created';
|
|
420
|
-
sessionId: string;
|
|
421
|
-
} | {
|
|
422
|
-
type: 'session_shared';
|
|
423
|
-
sessionId: string;
|
|
424
|
-
sharedUrl: string;
|
|
425
|
-
} | {
|
|
426
|
-
type: 'session_unshared';
|
|
427
|
-
sessionId: string;
|
|
428
|
-
} | {
|
|
429
|
-
type: 'auth_request';
|
|
430
|
-
sessionId: string;
|
|
431
|
-
message: Message;
|
|
432
|
-
request: AuthRequest;
|
|
433
|
-
} | {
|
|
434
|
-
type: 'auth_completed';
|
|
435
|
-
sessionId: string;
|
|
436
|
-
requestId: string;
|
|
437
|
-
success: boolean;
|
|
438
|
-
cancelled?: boolean;
|
|
439
|
-
error?: string;
|
|
440
|
-
} | {
|
|
441
|
-
type: 'source_activated';
|
|
442
|
-
sessionId: string;
|
|
443
|
-
sourceSlug: string;
|
|
444
|
-
originalMessage: string;
|
|
445
|
-
} | {
|
|
446
|
-
type: 'usage_update';
|
|
447
|
-
sessionId: string;
|
|
448
|
-
tokenUsage: {
|
|
449
|
-
inputTokens: number;
|
|
450
|
-
contextWindow?: number;
|
|
451
|
-
};
|
|
452
|
-
} | {
|
|
453
|
-
type: 'message_annotations_updated';
|
|
454
|
-
sessionId: string;
|
|
455
|
-
messageId: string;
|
|
456
|
-
annotations: AnnotationV1[];
|
|
457
|
-
} | {
|
|
458
|
-
type: 'working_directory_error';
|
|
459
|
-
sessionId: string;
|
|
460
|
-
error: string;
|
|
461
|
-
};
|
|
462
|
-
interface SendMessageOptions {
|
|
463
|
-
skillSlugs?: string[];
|
|
464
|
-
badges?: ContentBadge[];
|
|
465
|
-
optimisticMessageId?: string;
|
|
466
|
-
}
|
|
467
|
-
type SessionCommand = {
|
|
468
|
-
type: 'flag';
|
|
469
|
-
} | {
|
|
470
|
-
type: 'unflag';
|
|
471
|
-
} | {
|
|
472
|
-
type: 'archive';
|
|
473
|
-
} | {
|
|
474
|
-
type: 'unarchive';
|
|
475
|
-
} | {
|
|
476
|
-
type: 'rename';
|
|
477
|
-
name: string;
|
|
478
|
-
} | {
|
|
479
|
-
type: 'setSessionStatus';
|
|
480
|
-
state: SessionStatus;
|
|
481
|
-
} | {
|
|
482
|
-
type: 'markRead';
|
|
483
|
-
} | {
|
|
484
|
-
type: 'markUnread';
|
|
485
|
-
} | {
|
|
486
|
-
type: 'setActiveViewing';
|
|
487
|
-
workspaceId: string;
|
|
488
|
-
} | {
|
|
489
|
-
type: 'setPermissionMode';
|
|
490
|
-
mode: PermissionMode;
|
|
491
|
-
} | {
|
|
492
|
-
type: 'setThinkingLevel';
|
|
493
|
-
level: ThinkingLevel;
|
|
494
|
-
} | {
|
|
495
|
-
type: 'updateWorkingDirectory';
|
|
496
|
-
dir: string;
|
|
497
|
-
} | {
|
|
498
|
-
type: 'setSources';
|
|
499
|
-
sourceSlugs: string[];
|
|
500
|
-
} | {
|
|
501
|
-
type: 'setLabels';
|
|
502
|
-
labels: string[];
|
|
503
|
-
} | {
|
|
504
|
-
type: 'showInFinder';
|
|
505
|
-
} | {
|
|
506
|
-
type: 'copyPath';
|
|
507
|
-
} | {
|
|
508
|
-
type: 'shareToViewer';
|
|
509
|
-
} | {
|
|
510
|
-
type: 'updateShare';
|
|
511
|
-
} | {
|
|
512
|
-
type: 'revokeShare';
|
|
513
|
-
} | {
|
|
514
|
-
type: 'refreshTitle';
|
|
515
|
-
} | {
|
|
516
|
-
type: 'setConnection';
|
|
517
|
-
connectionSlug: string;
|
|
518
|
-
} | {
|
|
519
|
-
type: 'setPendingPlanExecution';
|
|
520
|
-
planPath: string;
|
|
521
|
-
draftInputSnapshot?: string;
|
|
522
|
-
} | {
|
|
523
|
-
type: 'markCompactionComplete';
|
|
524
|
-
} | {
|
|
525
|
-
type: 'markPendingPlanExecutionDispatched';
|
|
526
|
-
} | {
|
|
527
|
-
type: 'clearPendingPlanExecution';
|
|
528
|
-
} | {
|
|
529
|
-
type: 'addAnnotation';
|
|
530
|
-
messageId: string;
|
|
531
|
-
annotation: AnnotationV1;
|
|
532
|
-
} | {
|
|
533
|
-
type: 'removeAnnotation';
|
|
534
|
-
messageId: string;
|
|
535
|
-
annotationId: string;
|
|
536
|
-
} | {
|
|
537
|
-
type: 'updateAnnotation';
|
|
538
|
-
messageId: string;
|
|
539
|
-
annotationId: string;
|
|
540
|
-
patch: Partial<AnnotationV1>;
|
|
541
|
-
};
|
|
542
|
-
interface NewChatActionParams {
|
|
543
|
-
input?: string;
|
|
544
|
-
name?: string;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* Permission request with session context (for multi-session Electron app)
|
|
549
|
-
*/
|
|
550
|
-
interface PermissionRequest extends PermissionRequest$1 {
|
|
551
|
-
sessionId: string;
|
|
552
|
-
}
|
|
553
|
-
interface PermissionResponseOptions {
|
|
554
|
-
rememberForMinutes?: number;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Credential request from agent — prompts user for credentials
|
|
559
|
-
* (e.g., API key, username/password, OAuth token)
|
|
560
|
-
*/
|
|
561
|
-
interface CredentialRequest {
|
|
562
|
-
requestId: string;
|
|
563
|
-
toolName: string;
|
|
564
|
-
description: string;
|
|
565
|
-
credentialMode?: CredentialInputMode;
|
|
566
|
-
headerName?: string;
|
|
567
|
-
headerNames?: string[];
|
|
568
|
-
labels?: {
|
|
569
|
-
credential?: string;
|
|
570
|
-
username?: string;
|
|
571
|
-
password?: string;
|
|
572
|
-
};
|
|
573
|
-
hint?: string;
|
|
574
|
-
sourceUrl?: string;
|
|
575
|
-
passwordRequired?: boolean;
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Auth request — unified auth flow (credential or OAuth)
|
|
579
|
-
*/
|
|
580
|
-
interface AuthRequest {
|
|
581
|
-
requestId: string;
|
|
582
|
-
type: AuthRequestType;
|
|
583
|
-
sourceSlug?: string;
|
|
584
|
-
sourceName?: string;
|
|
585
|
-
description?: string;
|
|
586
|
-
credentialMode?: CredentialInputMode;
|
|
587
|
-
headerName?: string;
|
|
588
|
-
headerNames?: string[];
|
|
589
|
-
labels?: {
|
|
590
|
-
credential?: string;
|
|
591
|
-
username?: string;
|
|
592
|
-
password?: string;
|
|
593
|
-
};
|
|
594
|
-
hint?: string;
|
|
595
|
-
sourceUrl?: string;
|
|
596
|
-
passwordRequired?: boolean;
|
|
597
|
-
}
|
|
598
|
-
interface CredentialResponse {
|
|
599
|
-
type: 'credential';
|
|
600
|
-
value?: string;
|
|
601
|
-
username?: string;
|
|
602
|
-
password?: string;
|
|
603
|
-
headers?: Record<string, string>;
|
|
604
|
-
cancelled: boolean;
|
|
605
|
-
}
|
|
606
|
-
/** Server-side directory listing result (for remote directory browsing). */
|
|
607
|
-
interface DirectoryListingResult {
|
|
608
|
-
/** Normalized absolute path of the listed directory (after resolve(), not symlink-resolved). */
|
|
609
|
-
currentPath: string;
|
|
610
|
-
/** Parent directory path, or null if at root. */
|
|
611
|
-
parentPath: string | null;
|
|
612
|
-
/** Pre-split breadcrumb segments for display (computed server-side). */
|
|
613
|
-
breadcrumbs: Array<{
|
|
614
|
-
name: string;
|
|
615
|
-
path: string;
|
|
616
|
-
}>;
|
|
617
|
-
/** Server platform info. */
|
|
618
|
-
platform: 'win32' | 'darwin' | 'linux';
|
|
619
|
-
/** Whether the server truncated the directory list for safety/performance. */
|
|
620
|
-
truncated: boolean;
|
|
621
|
-
/** Total number of matching child directories before truncation. */
|
|
622
|
-
totalEntries: number;
|
|
623
|
-
/** Child directory entries. */
|
|
624
|
-
entries: Array<{
|
|
625
|
-
name: string;
|
|
626
|
-
path: string;
|
|
627
|
-
isSymlink: boolean;
|
|
628
|
-
}>;
|
|
629
|
-
}
|
|
630
|
-
interface FileAttachment {
|
|
631
|
-
type: 'image' | 'text' | 'pdf' | 'office' | 'audio' | 'unknown';
|
|
632
|
-
path: string;
|
|
633
|
-
name: string;
|
|
634
|
-
mimeType: string;
|
|
635
|
-
base64?: string;
|
|
636
|
-
text?: string;
|
|
637
|
-
size: number;
|
|
638
|
-
thumbnailBase64?: string;
|
|
639
|
-
}
|
|
640
|
-
interface SessionFile {
|
|
641
|
-
name: string;
|
|
642
|
-
path: string;
|
|
643
|
-
type: 'file' | 'directory';
|
|
644
|
-
size?: number;
|
|
645
|
-
children?: SessionFile[];
|
|
646
|
-
}
|
|
647
|
-
interface FileSearchResult {
|
|
648
|
-
name: string;
|
|
649
|
-
path: string;
|
|
650
|
-
type: 'file' | 'directory';
|
|
651
|
-
relativePath: string;
|
|
652
|
-
}
|
|
653
|
-
interface LlmConnectionSetup {
|
|
654
|
-
slug: string;
|
|
655
|
-
credential?: string;
|
|
656
|
-
baseUrl?: string | null;
|
|
657
|
-
defaultModel?: string | null;
|
|
658
|
-
models?: string[] | null;
|
|
659
|
-
piAuthProvider?: string;
|
|
660
|
-
modelSelectionMode?: 'automaticallySyncedFromProvider' | 'userDefined3Tier';
|
|
661
|
-
/** When true, reject setup if the connection doesn't already exist (reauth guard). */
|
|
662
|
-
updateOnly?: boolean;
|
|
663
|
-
/** Custom endpoint protocol for arbitrary OpenAI/Anthropic-compatible APIs */
|
|
664
|
-
customEndpoint?: Record<string, unknown>;
|
|
665
|
-
/** IAM credentials for Pi+Bedrock (piAuthProvider='amazon-bedrock') connections */
|
|
666
|
-
iamCredentials?: {
|
|
667
|
-
accessKeyId: string;
|
|
668
|
-
secretAccessKey: string;
|
|
669
|
-
sessionToken?: string;
|
|
670
|
-
};
|
|
671
|
-
/** AWS region for Pi+Bedrock connections */
|
|
672
|
-
awsRegion?: string;
|
|
673
|
-
/** Bedrock authentication method — determines auth type for Pi+Bedrock connections */
|
|
674
|
-
bedrockAuthMethod?: 'iam_credentials' | 'environment';
|
|
675
|
-
}
|
|
676
|
-
interface TestLlmConnectionParams {
|
|
677
|
-
provider: 'anthropic' | 'pi';
|
|
678
|
-
apiKey: string;
|
|
679
|
-
baseUrl?: string;
|
|
680
|
-
model?: string;
|
|
681
|
-
piAuthProvider?: string;
|
|
682
|
-
/** Optional custom endpoint protocol hint so setup tests mirror runtime routing */
|
|
683
|
-
customEndpoint?: Record<string, unknown>;
|
|
684
|
-
}
|
|
685
|
-
interface TestLlmConnectionResult {
|
|
686
|
-
success: boolean;
|
|
687
|
-
error?: string;
|
|
688
|
-
}
|
|
689
|
-
interface SkillFile {
|
|
690
|
-
name: string;
|
|
691
|
-
type: 'file' | 'directory';
|
|
692
|
-
size?: number;
|
|
693
|
-
children?: SkillFile[];
|
|
694
|
-
}
|
|
695
|
-
interface OAuthResult {
|
|
696
|
-
success: boolean;
|
|
697
|
-
error?: string;
|
|
698
|
-
}
|
|
699
|
-
interface McpValidationResult {
|
|
700
|
-
success: boolean;
|
|
701
|
-
error?: string;
|
|
702
|
-
tools?: string[];
|
|
703
|
-
}
|
|
704
|
-
interface McpToolWithPermission {
|
|
705
|
-
name: string;
|
|
706
|
-
description?: string;
|
|
707
|
-
allowed: boolean;
|
|
708
|
-
}
|
|
709
|
-
interface McpToolsResult {
|
|
710
|
-
success: boolean;
|
|
711
|
-
error?: string;
|
|
712
|
-
tools?: McpToolWithPermission[];
|
|
713
|
-
}
|
|
714
|
-
interface SessionSearchMatch {
|
|
715
|
-
sessionId: string;
|
|
716
|
-
lineNumber: number;
|
|
717
|
-
snippet: string;
|
|
718
|
-
}
|
|
719
|
-
interface SessionSearchResult {
|
|
720
|
-
sessionId: string;
|
|
721
|
-
matchCount: number;
|
|
722
|
-
matches: SessionSearchMatch[];
|
|
723
|
-
}
|
|
724
|
-
interface UnreadSummary {
|
|
725
|
-
totalUnreadSessions: number;
|
|
726
|
-
byWorkspace: Record<string, number>;
|
|
727
|
-
hasUnreadByWorkspace: Record<string, boolean>;
|
|
728
|
-
}
|
|
729
|
-
interface ShareResult {
|
|
730
|
-
success: boolean;
|
|
731
|
-
url?: string;
|
|
732
|
-
error?: string;
|
|
733
|
-
}
|
|
734
|
-
interface RefreshTitleResult {
|
|
735
|
-
success: boolean;
|
|
736
|
-
title?: string;
|
|
737
|
-
error?: string;
|
|
738
|
-
}
|
|
739
|
-
interface PlanStep {
|
|
740
|
-
id: string;
|
|
741
|
-
description: string;
|
|
742
|
-
tools?: string[];
|
|
743
|
-
status?: 'pending' | 'in_progress' | 'completed' | 'failed' | 'skipped';
|
|
744
|
-
}
|
|
745
|
-
interface Plan {
|
|
746
|
-
id: string;
|
|
747
|
-
title: string;
|
|
748
|
-
summary?: string;
|
|
749
|
-
steps: PlanStep[];
|
|
750
|
-
questions?: string[];
|
|
751
|
-
state?: 'creating' | 'refining' | 'ready' | 'executing' | 'completed' | 'cancelled';
|
|
752
|
-
createdAt?: number;
|
|
753
|
-
updatedAt?: number;
|
|
754
|
-
}
|
|
755
|
-
interface GitBashStatus {
|
|
756
|
-
found: boolean;
|
|
757
|
-
path: string | null;
|
|
758
|
-
platform: 'win32' | 'darwin' | 'linux';
|
|
759
|
-
}
|
|
760
|
-
interface UpdateInfo {
|
|
761
|
-
available: boolean;
|
|
762
|
-
currentVersion: string;
|
|
763
|
-
latestVersion: string | null;
|
|
764
|
-
downloadState: 'idle' | 'downloading' | 'ready' | 'installing' | 'error';
|
|
765
|
-
downloadProgress: number;
|
|
766
|
-
error?: string;
|
|
767
|
-
}
|
|
768
|
-
interface WorkspaceSettings {
|
|
769
|
-
name?: string;
|
|
770
|
-
model?: string;
|
|
771
|
-
permissionMode?: PermissionMode;
|
|
772
|
-
cyclablePermissionModes?: PermissionMode[];
|
|
773
|
-
thinkingLevel?: ThinkingLevel;
|
|
774
|
-
workingDirectory?: string;
|
|
775
|
-
localMcpEnabled?: boolean;
|
|
776
|
-
defaultLlmConnection?: string;
|
|
777
|
-
enabledSourceSlugs?: string[];
|
|
778
|
-
}
|
|
779
|
-
interface ClaudeOAuthResult {
|
|
780
|
-
success: boolean;
|
|
781
|
-
token?: string;
|
|
782
|
-
error?: string;
|
|
783
|
-
}
|
|
784
|
-
type TestAutomationAction = {
|
|
785
|
-
type: 'prompt';
|
|
786
|
-
prompt: string;
|
|
787
|
-
llmConnection?: string;
|
|
788
|
-
model?: string;
|
|
789
|
-
thinkingLevel?: ThinkingLevel;
|
|
790
|
-
} | {
|
|
791
|
-
type: 'webhook';
|
|
792
|
-
url: string;
|
|
793
|
-
method?: string;
|
|
794
|
-
headers?: Record<string, string>;
|
|
795
|
-
bodyFormat?: 'json' | 'form' | 'raw';
|
|
796
|
-
body?: unknown;
|
|
797
|
-
captureResponse?: boolean;
|
|
798
|
-
auth?: {
|
|
799
|
-
type: 'basic';
|
|
800
|
-
username: string;
|
|
801
|
-
password: string;
|
|
802
|
-
} | {
|
|
803
|
-
type: 'bearer';
|
|
804
|
-
token: string;
|
|
805
|
-
};
|
|
806
|
-
};
|
|
807
|
-
interface TestAutomationPayload {
|
|
808
|
-
workspaceId: string;
|
|
809
|
-
automationId?: string;
|
|
810
|
-
automationName?: string;
|
|
811
|
-
actions: TestAutomationAction[];
|
|
812
|
-
permissionMode?: PermissionMode;
|
|
813
|
-
labels?: string[];
|
|
814
|
-
/** Forwarded from the matcher; routes test-run sessions into a Telegram topic when paired. */
|
|
815
|
-
telegramTopic?: string;
|
|
816
|
-
}
|
|
817
|
-
type TestAutomationActionResult = {
|
|
818
|
-
type: 'prompt';
|
|
819
|
-
success: boolean;
|
|
820
|
-
stderr?: string;
|
|
821
|
-
sessionId?: string;
|
|
822
|
-
duration: number;
|
|
823
|
-
} | {
|
|
824
|
-
type: 'webhook';
|
|
825
|
-
success: boolean;
|
|
826
|
-
url: string;
|
|
827
|
-
statusCode: number;
|
|
828
|
-
error?: string;
|
|
829
|
-
duration: number;
|
|
830
|
-
};
|
|
831
|
-
interface TestAutomationResult {
|
|
832
|
-
actions: TestAutomationActionResult[];
|
|
833
|
-
}
|
|
834
|
-
type WindowCloseRequestSource = 'keyboard-shortcut' | 'window-button' | 'unknown';
|
|
835
|
-
interface WindowCloseRequest {
|
|
836
|
-
source: WindowCloseRequestSource;
|
|
837
|
-
}
|
|
838
|
-
interface BrowserInstanceInfo {
|
|
839
|
-
id: string;
|
|
840
|
-
url: string;
|
|
841
|
-
title: string;
|
|
842
|
-
favicon: string | null;
|
|
843
|
-
isLoading: boolean;
|
|
844
|
-
canGoBack: boolean;
|
|
845
|
-
canGoForward: boolean;
|
|
846
|
-
boundSessionId: string | null;
|
|
847
|
-
ownerType: 'session' | 'manual';
|
|
848
|
-
ownerSessionId: string | null;
|
|
849
|
-
isVisible: boolean;
|
|
850
|
-
agentControlActive: boolean;
|
|
851
|
-
themeColor: string | null;
|
|
852
|
-
}
|
|
853
|
-
interface DeepLinkNavigation {
|
|
854
|
-
view?: string;
|
|
855
|
-
tabType?: string;
|
|
856
|
-
tabParams?: Record<string, string>;
|
|
857
|
-
action?: string;
|
|
858
|
-
actionParams?: Record<string, string>;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* RPC channel names — organized by domain namespace.
|
|
863
|
-
* Wire-format strings (values) are the stable API contract.
|
|
864
|
-
* Key paths are internal and may be reorganized freely.
|
|
865
|
-
*/
|
|
866
|
-
declare const RPC_CHANNELS: {
|
|
867
|
-
readonly remote: {
|
|
868
|
-
readonly TEST_CONNECTION: "remote:testConnection";
|
|
869
|
-
};
|
|
870
|
-
readonly server: {
|
|
871
|
-
readonly GET_WORKSPACES: "server:getWorkspaces";
|
|
872
|
-
readonly CREATE_WORKSPACE: "server:createWorkspace";
|
|
873
|
-
readonly GET_STATUS: "server:getStatus";
|
|
874
|
-
readonly GET_HEALTH: "server:getHealth";
|
|
875
|
-
readonly GET_ACTIVE_SESSIONS: "server:getActiveSessions";
|
|
876
|
-
readonly SHUTTING_DOWN: "server:shuttingDown";
|
|
877
|
-
readonly STATUS_CHANGED: "server:statusChanged";
|
|
878
|
-
readonly HOME_DIR: "server:homeDir";
|
|
879
|
-
};
|
|
880
|
-
readonly sessions: {
|
|
881
|
-
readonly GET: "sessions:get";
|
|
882
|
-
readonly GET_UNREAD_SUMMARY: "sessions:getUnreadSummary";
|
|
883
|
-
readonly MARK_ALL_READ: "sessions:markAllRead";
|
|
884
|
-
readonly UNREAD_SUMMARY_CHANGED: "sessions:unreadSummaryChanged";
|
|
885
|
-
readonly CREATE: "sessions:create";
|
|
886
|
-
readonly DELETE: "sessions:delete";
|
|
887
|
-
readonly GET_MESSAGES: "sessions:getMessages";
|
|
888
|
-
readonly SEND_MESSAGE: "sessions:sendMessage";
|
|
889
|
-
readonly CANCEL: "sessions:cancel";
|
|
890
|
-
readonly KILL_SHELL: "sessions:killShell";
|
|
891
|
-
readonly RESPOND_TO_PERMISSION: "sessions:respondToPermission";
|
|
892
|
-
readonly RESPOND_TO_CREDENTIAL: "sessions:respondToCredential";
|
|
893
|
-
readonly COMMAND: "sessions:command";
|
|
894
|
-
readonly GET_PENDING_PLAN_EXECUTION: "sessions:getPendingPlanExecution";
|
|
895
|
-
readonly GET_PERMISSION_MODE_STATE: "sessions:getPermissionModeState";
|
|
896
|
-
readonly EVENT: "session:event";
|
|
897
|
-
readonly GET_MODEL: "session:getModel";
|
|
898
|
-
readonly SET_MODEL: "session:setModel";
|
|
899
|
-
readonly GET_FILES: "sessions:getFiles";
|
|
900
|
-
readonly GET_NOTES: "sessions:getNotes";
|
|
901
|
-
readonly SET_NOTES: "sessions:setNotes";
|
|
902
|
-
readonly WATCH_FILES: "sessions:watchFiles";
|
|
903
|
-
readonly UNWATCH_FILES: "sessions:unwatchFiles";
|
|
904
|
-
readonly FILES_CHANGED: "sessions:filesChanged";
|
|
905
|
-
readonly SEARCH_CONTENT: "sessions:searchContent";
|
|
906
|
-
readonly EXPORT: "sessions:export";
|
|
907
|
-
readonly IMPORT: "sessions:import";
|
|
908
|
-
readonly EXPORT_REMOTE_TRANSFER: "sessions:exportRemoteTransfer";
|
|
909
|
-
readonly IMPORT_REMOTE_TRANSFER: "sessions:importRemoteTransfer";
|
|
910
|
-
};
|
|
911
|
-
readonly transfer: {
|
|
912
|
-
readonly START: "transfer:start";
|
|
913
|
-
readonly CHUNK: "transfer:chunk";
|
|
914
|
-
readonly COMMIT: "transfer:commit";
|
|
915
|
-
readonly ABORT: "transfer:abort";
|
|
916
|
-
};
|
|
917
|
-
readonly tasks: {
|
|
918
|
-
readonly GET_OUTPUT: "tasks:getOutput";
|
|
919
|
-
};
|
|
920
|
-
readonly workspaces: {
|
|
921
|
-
readonly GET: "workspaces:get";
|
|
922
|
-
readonly CREATE: "workspaces:create";
|
|
923
|
-
readonly CHECK_SLUG: "workspaces:checkSlug";
|
|
924
|
-
readonly UPDATE_REMOTE: "workspaces:updateRemote";
|
|
925
|
-
};
|
|
926
|
-
readonly window: {
|
|
927
|
-
readonly GET_WORKSPACE: "window:getWorkspace";
|
|
928
|
-
readonly GET_MODE: "window:getMode";
|
|
929
|
-
readonly OPEN_WORKSPACE: "window:openWorkspace";
|
|
930
|
-
readonly OPEN_SESSION_IN_NEW_WINDOW: "window:openSessionInNewWindow";
|
|
931
|
-
readonly SWITCH_WORKSPACE: "window:switchWorkspace";
|
|
932
|
-
readonly CLOSE: "window:close";
|
|
933
|
-
readonly CLOSE_REQUESTED: "window:closeRequested";
|
|
934
|
-
readonly CONFIRM_CLOSE: "window:confirmClose";
|
|
935
|
-
readonly CANCEL_CLOSE: "window:cancelClose";
|
|
936
|
-
readonly SET_TRAFFIC_LIGHTS: "window:setTrafficLights";
|
|
937
|
-
readonly FOCUS_STATE: "window:focusState";
|
|
938
|
-
readonly GET_FOCUS_STATE: "window:getFocusState";
|
|
939
|
-
};
|
|
940
|
-
readonly file: {
|
|
941
|
-
readonly READ: "file:read";
|
|
942
|
-
readonly READ_DATA_URL: "file:readDataUrl";
|
|
943
|
-
readonly READ_PREVIEW_DATA_URL: "file:readPreviewDataUrl";
|
|
944
|
-
readonly READ_BINARY: "file:readBinary";
|
|
945
|
-
readonly OPEN_DIALOG: "file:openDialog";
|
|
946
|
-
readonly READ_ATTACHMENT: "file:readAttachment";
|
|
947
|
-
readonly READ_USER_ATTACHMENT: "file:readUserAttachment";
|
|
948
|
-
readonly STORE_ATTACHMENT: "file:storeAttachment";
|
|
949
|
-
readonly GENERATE_THUMBNAIL: "file:generateThumbnail";
|
|
950
|
-
};
|
|
951
|
-
readonly fs: {
|
|
952
|
-
readonly SEARCH: "fs:search";
|
|
953
|
-
readonly LIST_DIRECTORY: "fs:listDirectory";
|
|
954
|
-
};
|
|
955
|
-
readonly debug: {
|
|
956
|
-
readonly LOG: "debug:log";
|
|
957
|
-
};
|
|
958
|
-
readonly theme: {
|
|
959
|
-
readonly GET_SYSTEM_PREFERENCE: "theme:getSystemPreference";
|
|
960
|
-
readonly SYSTEM_CHANGED: "theme:systemChanged";
|
|
961
|
-
readonly APP_CHANGED: "theme:appChanged";
|
|
962
|
-
readonly GET_APP: "theme:getApp";
|
|
963
|
-
readonly GET_PRESETS: "theme:getPresets";
|
|
964
|
-
readonly LOAD_PRESET: "theme:loadPreset";
|
|
965
|
-
readonly GET_COLOR_THEME: "theme:getColorTheme";
|
|
966
|
-
readonly SET_COLOR_THEME: "theme:setColorTheme";
|
|
967
|
-
readonly BROADCAST_PREFERENCES: "theme:broadcastPreferences";
|
|
968
|
-
readonly PREFERENCES_CHANGED: "theme:preferencesChanged";
|
|
969
|
-
readonly GET_WORKSPACE_COLOR_THEME: "theme:getWorkspaceColorTheme";
|
|
970
|
-
readonly SET_WORKSPACE_COLOR_THEME: "theme:setWorkspaceColorTheme";
|
|
971
|
-
readonly GET_ALL_WORKSPACE_THEMES: "theme:getAllWorkspaceThemes";
|
|
972
|
-
readonly BROADCAST_WORKSPACE_THEME: "theme:broadcastWorkspaceTheme";
|
|
973
|
-
readonly WORKSPACE_THEME_CHANGED: "theme:workspaceThemeChanged";
|
|
974
|
-
};
|
|
975
|
-
readonly system: {
|
|
976
|
-
readonly VERSIONS: "system:versions";
|
|
977
|
-
readonly HOME_DIR: "system:homeDir";
|
|
978
|
-
readonly IS_DEBUG_MODE: "system:isDebugMode";
|
|
979
|
-
};
|
|
980
|
-
readonly update: {
|
|
981
|
-
readonly CHECK: "update:check";
|
|
982
|
-
readonly GET_INFO: "update:getInfo";
|
|
983
|
-
readonly INSTALL: "update:install";
|
|
984
|
-
readonly DISMISS: "update:dismiss";
|
|
985
|
-
readonly GET_DISMISSED: "update:getDismissed";
|
|
986
|
-
readonly AVAILABLE: "update:available";
|
|
987
|
-
readonly DOWNLOAD_PROGRESS: "update:downloadProgress";
|
|
988
|
-
};
|
|
989
|
-
readonly shell: {
|
|
990
|
-
readonly OPEN_URL: "shell:openUrl";
|
|
991
|
-
readonly OPEN_FILE: "shell:openFile";
|
|
992
|
-
readonly SHOW_IN_FOLDER: "shell:showInFolder";
|
|
993
|
-
};
|
|
994
|
-
readonly menu: {
|
|
995
|
-
readonly NEW_CHAT: "menu:newChat";
|
|
996
|
-
readonly NEW_WINDOW: "menu:newWindow";
|
|
997
|
-
readonly OPEN_SETTINGS: "menu:openSettings";
|
|
998
|
-
readonly KEYBOARD_SHORTCUTS: "menu:keyboardShortcuts";
|
|
999
|
-
readonly TOGGLE_FOCUS_MODE: "menu:toggleFocusMode";
|
|
1000
|
-
readonly TOGGLE_SIDEBAR: "menu:toggleSidebar";
|
|
1001
|
-
readonly QUIT: "menu:quit";
|
|
1002
|
-
readonly MINIMIZE: "menu:minimize";
|
|
1003
|
-
readonly MAXIMIZE: "menu:maximize";
|
|
1004
|
-
readonly ZOOM_IN: "menu:zoomIn";
|
|
1005
|
-
readonly ZOOM_OUT: "menu:zoomOut";
|
|
1006
|
-
readonly ZOOM_RESET: "menu:zoomReset";
|
|
1007
|
-
readonly TOGGLE_DEV_TOOLS: "menu:toggleDevTools";
|
|
1008
|
-
readonly UNDO: "menu:undo";
|
|
1009
|
-
readonly REDO: "menu:redo";
|
|
1010
|
-
readonly CUT: "menu:cut";
|
|
1011
|
-
readonly COPY: "menu:copy";
|
|
1012
|
-
readonly PASTE: "menu:paste";
|
|
1013
|
-
readonly SELECT_ALL: "menu:selectAll";
|
|
1014
|
-
};
|
|
1015
|
-
readonly deeplink: {
|
|
1016
|
-
readonly NAVIGATE: "deeplink:navigate";
|
|
1017
|
-
};
|
|
1018
|
-
readonly auth: {
|
|
1019
|
-
readonly LOGOUT: "auth:logout";
|
|
1020
|
-
readonly SHOW_LOGOUT_CONFIRMATION: "auth:showLogoutConfirmation";
|
|
1021
|
-
readonly SHOW_DELETE_SESSION_CONFIRMATION: "auth:showDeleteSessionConfirmation";
|
|
1022
|
-
};
|
|
1023
|
-
readonly credentials: {
|
|
1024
|
-
readonly HEALTH_CHECK: "credentials:healthCheck";
|
|
1025
|
-
};
|
|
1026
|
-
readonly onboarding: {
|
|
1027
|
-
readonly GET_AUTH_STATE: "onboarding:getAuthState";
|
|
1028
|
-
readonly VALIDATE_MCP: "onboarding:validateMcp";
|
|
1029
|
-
readonly START_MCP_OAUTH: "onboarding:startMcpOAuth";
|
|
1030
|
-
readonly START_CLAUDE_OAUTH: "onboarding:startClaudeOAuth";
|
|
1031
|
-
readonly EXCHANGE_CLAUDE_CODE: "onboarding:exchangeClaudeCode";
|
|
1032
|
-
readonly HAS_CLAUDE_OAUTH_STATE: "onboarding:hasClaudeOAuthState";
|
|
1033
|
-
readonly CLEAR_CLAUDE_OAUTH_STATE: "onboarding:clearClaudeOAuthState";
|
|
1034
|
-
readonly DEFER_SETUP: "onboarding:deferSetup";
|
|
1035
|
-
};
|
|
1036
|
-
readonly llmConnections: {
|
|
1037
|
-
readonly LIST: "LLM_Connection:list";
|
|
1038
|
-
readonly LIST_WITH_STATUS: "LLM_Connection:listWithStatus";
|
|
1039
|
-
readonly GET: "LLM_Connection:get";
|
|
1040
|
-
readonly GET_API_KEY: "LLM_Connection:getApiKey";
|
|
1041
|
-
readonly SAVE: "LLM_Connection:save";
|
|
1042
|
-
readonly DELETE: "LLM_Connection:delete";
|
|
1043
|
-
readonly TEST: "LLM_Connection:test";
|
|
1044
|
-
readonly SET_DEFAULT: "LLM_Connection:setDefault";
|
|
1045
|
-
readonly SET_WORKSPACE_DEFAULT: "LLM_Connection:setWorkspaceDefault";
|
|
1046
|
-
readonly REFRESH_MODELS: "LLM_Connection:refreshModels";
|
|
1047
|
-
readonly CHANGED: "LLM_Connection:changed";
|
|
1048
|
-
};
|
|
1049
|
-
readonly chatgpt: {
|
|
1050
|
-
readonly START_OAUTH: "chatgpt:startOAuth";
|
|
1051
|
-
readonly COMPLETE_OAUTH: "chatgpt:completeOAuth";
|
|
1052
|
-
readonly CANCEL_OAUTH: "chatgpt:cancelOAuth";
|
|
1053
|
-
readonly GET_AUTH_STATUS: "chatgpt:getAuthStatus";
|
|
1054
|
-
readonly LOGOUT: "chatgpt:logout";
|
|
1055
|
-
};
|
|
1056
|
-
readonly copilot: {
|
|
1057
|
-
readonly START_OAUTH: "copilot:startOAuth";
|
|
1058
|
-
readonly CANCEL_OAUTH: "copilot:cancelOAuth";
|
|
1059
|
-
readonly GET_AUTH_STATUS: "copilot:getAuthStatus";
|
|
1060
|
-
readonly LOGOUT: "copilot:logout";
|
|
1061
|
-
readonly DEVICE_CODE: "copilot:deviceCode";
|
|
1062
|
-
};
|
|
1063
|
-
readonly settings: {
|
|
1064
|
-
readonly SETUP_LLM_CONNECTION: "settings:setupLlmConnection";
|
|
1065
|
-
readonly TEST_LLM_CONNECTION_SETUP: "settings:testLlmConnectionSetup";
|
|
1066
|
-
readonly GET_DEFAULT_THINKING_LEVEL: "settings:getDefaultThinkingLevel";
|
|
1067
|
-
readonly SET_DEFAULT_THINKING_LEVEL: "settings:setDefaultThinkingLevel";
|
|
1068
|
-
readonly GET_NETWORK_PROXY: "settings:getNetworkProxy";
|
|
1069
|
-
readonly SET_NETWORK_PROXY: "settings:setNetworkProxy";
|
|
1070
|
-
readonly GET_SERVER_CONFIG: "settings:getServerConfig";
|
|
1071
|
-
readonly SET_SERVER_CONFIG: "settings:setServerConfig";
|
|
1072
|
-
readonly GET_SERVER_STATUS: "settings:getServerStatus";
|
|
1073
|
-
};
|
|
1074
|
-
readonly pi: {
|
|
1075
|
-
readonly GET_API_KEY_PROVIDERS: "pi:getApiKeyProviders";
|
|
1076
|
-
readonly GET_PROVIDER_BASE_URL: "pi:getProviderBaseUrl";
|
|
1077
|
-
readonly GET_PROVIDER_MODELS: "pi:getProviderModels";
|
|
1078
|
-
};
|
|
1079
|
-
readonly dialog: {
|
|
1080
|
-
readonly OPEN_FOLDER: "dialog:openFolder";
|
|
1081
|
-
};
|
|
1082
|
-
readonly preferences: {
|
|
1083
|
-
readonly READ: "preferences:read";
|
|
1084
|
-
readonly WRITE: "preferences:write";
|
|
1085
|
-
};
|
|
1086
|
-
readonly drafts: {
|
|
1087
|
-
readonly GET: "drafts:get";
|
|
1088
|
-
readonly SET: "drafts:set";
|
|
1089
|
-
readonly DELETE: "drafts:delete";
|
|
1090
|
-
readonly GET_ALL: "drafts:getAll";
|
|
1091
|
-
};
|
|
1092
|
-
readonly sources: {
|
|
1093
|
-
readonly GET: "sources:get";
|
|
1094
|
-
readonly CREATE: "sources:create";
|
|
1095
|
-
readonly DELETE: "sources:delete";
|
|
1096
|
-
readonly START_OAUTH: "sources:startOAuth";
|
|
1097
|
-
readonly SAVE_CREDENTIALS: "sources:saveCredentials";
|
|
1098
|
-
readonly CHANGED: "sources:changed";
|
|
1099
|
-
readonly GET_PERMISSIONS: "sources:getPermissions";
|
|
1100
|
-
readonly GET_MCP_TOOLS: "sources:getMcpTools";
|
|
1101
|
-
};
|
|
1102
|
-
readonly oauth: {
|
|
1103
|
-
readonly START: "oauth:start";
|
|
1104
|
-
readonly COMPLETE: "oauth:complete";
|
|
1105
|
-
readonly CANCEL: "oauth:cancel";
|
|
1106
|
-
readonly REVOKE: "oauth:revoke";
|
|
1107
|
-
};
|
|
1108
|
-
readonly workspace: {
|
|
1109
|
-
readonly GET_PERMISSIONS: "workspace:getPermissions";
|
|
1110
|
-
readonly READ_IMAGE: "workspace:readImage";
|
|
1111
|
-
readonly WRITE_IMAGE: "workspace:writeImage";
|
|
1112
|
-
readonly SETTINGS_GET: "workspaceSettings:get";
|
|
1113
|
-
readonly SETTINGS_UPDATE: "workspaceSettings:update";
|
|
1114
|
-
};
|
|
1115
|
-
readonly permissions: {
|
|
1116
|
-
readonly GET_DEFAULTS: "permissions:getDefaults";
|
|
1117
|
-
readonly DEFAULTS_CHANGED: "permissions:defaultsChanged";
|
|
1118
|
-
};
|
|
1119
|
-
readonly skills: {
|
|
1120
|
-
readonly GET: "skills:get";
|
|
1121
|
-
readonly GET_FILES: "skills:getFiles";
|
|
1122
|
-
readonly DELETE: "skills:delete";
|
|
1123
|
-
readonly OPEN_EDITOR: "skills:openEditor";
|
|
1124
|
-
readonly OPEN_FINDER: "skills:openFinder";
|
|
1125
|
-
readonly CHANGED: "skills:changed";
|
|
1126
|
-
};
|
|
1127
|
-
readonly statuses: {
|
|
1128
|
-
readonly LIST: "statuses:list";
|
|
1129
|
-
readonly REORDER: "statuses:reorder";
|
|
1130
|
-
readonly CHANGED: "statuses:changed";
|
|
1131
|
-
};
|
|
1132
|
-
readonly labels: {
|
|
1133
|
-
readonly LIST: "labels:list";
|
|
1134
|
-
readonly CREATE: "labels:create";
|
|
1135
|
-
readonly DELETE: "labels:delete";
|
|
1136
|
-
readonly CHANGED: "labels:changed";
|
|
1137
|
-
};
|
|
1138
|
-
readonly views: {
|
|
1139
|
-
readonly LIST: "views:list";
|
|
1140
|
-
readonly SAVE: "views:save";
|
|
1141
|
-
};
|
|
1142
|
-
readonly toolIcons: {
|
|
1143
|
-
readonly GET_MAPPINGS: "toolIcons:getMappings";
|
|
1144
|
-
};
|
|
1145
|
-
readonly logo: {
|
|
1146
|
-
readonly GET_URL: "logo:getUrl";
|
|
1147
|
-
};
|
|
1148
|
-
readonly notification: {
|
|
1149
|
-
readonly SHOW: "notification:show";
|
|
1150
|
-
readonly NAVIGATE: "notification:navigate";
|
|
1151
|
-
readonly GET_ENABLED: "notification:getEnabled";
|
|
1152
|
-
readonly SET_ENABLED: "notification:setEnabled";
|
|
1153
|
-
};
|
|
1154
|
-
readonly input: {
|
|
1155
|
-
readonly GET_AUTO_CAPITALISATION: "input:getAutoCapitalisation";
|
|
1156
|
-
readonly SET_AUTO_CAPITALISATION: "input:setAutoCapitalisation";
|
|
1157
|
-
readonly GET_SEND_MESSAGE_KEY: "input:getSendMessageKey";
|
|
1158
|
-
readonly SET_SEND_MESSAGE_KEY: "input:setSendMessageKey";
|
|
1159
|
-
readonly GET_SPELL_CHECK: "input:getSpellCheck";
|
|
1160
|
-
readonly SET_SPELL_CHECK: "input:setSpellCheck";
|
|
1161
|
-
};
|
|
1162
|
-
readonly power: {
|
|
1163
|
-
readonly GET_KEEP_AWAKE: "power:getKeepAwake";
|
|
1164
|
-
readonly SET_KEEP_AWAKE: "power:setKeepAwake";
|
|
1165
|
-
};
|
|
1166
|
-
readonly appearance: {
|
|
1167
|
-
readonly GET_RICH_TOOL_DESCRIPTIONS: "appearance:getRichToolDescriptions";
|
|
1168
|
-
readonly SET_RICH_TOOL_DESCRIPTIONS: "appearance:setRichToolDescriptions";
|
|
1169
|
-
};
|
|
1170
|
-
readonly tools: {
|
|
1171
|
-
readonly GET_BROWSER_TOOL_ENABLED: "tools:getBrowserToolEnabled";
|
|
1172
|
-
readonly SET_BROWSER_TOOL_ENABLED: "tools:setBrowserToolEnabled";
|
|
1173
|
-
};
|
|
1174
|
-
readonly caching: {
|
|
1175
|
-
readonly GET_EXTENDED_PROMPT_CACHE: "caching:getExtendedPromptCache";
|
|
1176
|
-
readonly SET_EXTENDED_PROMPT_CACHE: "caching:setExtendedPromptCache";
|
|
1177
|
-
readonly GET_ENABLE_1M_CONTEXT: "caching:getEnable1MContext";
|
|
1178
|
-
readonly SET_ENABLE_1M_CONTEXT: "caching:setEnable1MContext";
|
|
1179
|
-
};
|
|
1180
|
-
readonly badge: {
|
|
1181
|
-
readonly REFRESH: "badge:refresh";
|
|
1182
|
-
readonly SET_ICON: "badge:setIcon";
|
|
1183
|
-
readonly DRAW: "badge:draw";
|
|
1184
|
-
readonly DRAW_WINDOWS: "badge:draw-windows";
|
|
1185
|
-
};
|
|
1186
|
-
readonly releaseNotes: {
|
|
1187
|
-
readonly GET: "releaseNotes:get";
|
|
1188
|
-
readonly GET_LATEST_VERSION: "releaseNotes:getLatestVersion";
|
|
1189
|
-
};
|
|
1190
|
-
readonly git: {
|
|
1191
|
-
readonly GET_BRANCH: "git:getBranch";
|
|
1192
|
-
};
|
|
1193
|
-
readonly gitbash: {
|
|
1194
|
-
readonly CHECK: "gitbash:check";
|
|
1195
|
-
readonly BROWSE: "gitbash:browse";
|
|
1196
|
-
readonly SET_PATH: "gitbash:setPath";
|
|
1197
|
-
};
|
|
1198
|
-
readonly browserPane: {
|
|
1199
|
-
readonly CREATE: "browser-pane:create";
|
|
1200
|
-
readonly DESTROY: "browser-pane:destroy";
|
|
1201
|
-
readonly LIST: "browser-pane:list";
|
|
1202
|
-
readonly NAVIGATE: "browser-pane:navigate";
|
|
1203
|
-
readonly GO_BACK: "browser-pane:go-back";
|
|
1204
|
-
readonly GO_FORWARD: "browser-pane:go-forward";
|
|
1205
|
-
readonly RELOAD: "browser-pane:reload";
|
|
1206
|
-
readonly STOP: "browser-pane:stop";
|
|
1207
|
-
readonly FOCUS: "browser-pane:focus";
|
|
1208
|
-
readonly SNAPSHOT: "browser-pane:snapshot";
|
|
1209
|
-
readonly CLICK: "browser-pane:click";
|
|
1210
|
-
readonly FILL: "browser-pane:fill";
|
|
1211
|
-
readonly SELECT: "browser-pane:select";
|
|
1212
|
-
readonly SCREENSHOT: "browser-pane:screenshot";
|
|
1213
|
-
readonly EVALUATE: "browser-pane:evaluate";
|
|
1214
|
-
readonly SCROLL: "browser-pane:scroll";
|
|
1215
|
-
readonly LAUNCH: "browser-empty-state:launch";
|
|
1216
|
-
readonly STATE_CHANGED: "browser-pane:state-changed";
|
|
1217
|
-
readonly REMOVED: "browser-pane:removed";
|
|
1218
|
-
readonly INTERACTED: "browser-pane:interacted";
|
|
1219
|
-
};
|
|
1220
|
-
readonly automations: {
|
|
1221
|
-
readonly GET: "automations:get";
|
|
1222
|
-
readonly TEST: "automations:test";
|
|
1223
|
-
readonly SET_ENABLED: "automations:setEnabled";
|
|
1224
|
-
readonly DUPLICATE: "automations:duplicate";
|
|
1225
|
-
readonly DELETE: "automations:delete";
|
|
1226
|
-
readonly GET_HISTORY: "automations:getHistory";
|
|
1227
|
-
readonly GET_LAST_EXECUTED: "automations:getLastExecuted";
|
|
1228
|
-
readonly REPLAY: "automations:replay";
|
|
1229
|
-
readonly CHANGED: "automations:changed";
|
|
1230
|
-
};
|
|
1231
|
-
readonly resources: {
|
|
1232
|
-
readonly EXPORT: "resources:export";
|
|
1233
|
-
readonly IMPORT: "resources:import";
|
|
1234
|
-
};
|
|
1235
|
-
readonly messaging: {
|
|
1236
|
-
readonly WA_REGISTER: "messaging:wa:register";
|
|
1237
|
-
readonly WA_INCOMING: "messaging:wa:incoming";
|
|
1238
|
-
readonly WA_BUTTON_PRESS: "messaging:wa:buttonPress";
|
|
1239
|
-
readonly WA_STATUS: "messaging:wa:status";
|
|
1240
|
-
readonly WA_QR: "messaging:wa:qr";
|
|
1241
|
-
readonly WA_SEND: "messaging:wa:send";
|
|
1242
|
-
readonly WA_SEND_BUTTONS: "messaging:wa:sendButtons";
|
|
1243
|
-
readonly WA_SEND_TYPING: "messaging:wa:sendTyping";
|
|
1244
|
-
readonly WA_SEND_FILE: "messaging:wa:sendFile";
|
|
1245
|
-
readonly WA_CONNECT: "messaging:wa:connect";
|
|
1246
|
-
readonly WA_DISCONNECT: "messaging:wa:disconnect";
|
|
1247
|
-
readonly BINDING_CHANGED: "messaging:bindingChanged";
|
|
1248
|
-
readonly PLATFORM_STATUS: "messaging:platformStatus";
|
|
1249
|
-
/** Broadcast when the workspace's pending-senders list mutates. */
|
|
1250
|
-
readonly PENDING_CHANGED: "messaging:pendingChanged";
|
|
1251
|
-
readonly GET_CONFIG: "messaging:getConfig";
|
|
1252
|
-
readonly UPDATE_CONFIG: "messaging:updateConfig";
|
|
1253
|
-
readonly TEST_TELEGRAM: "messaging:testTelegram";
|
|
1254
|
-
readonly SAVE_TELEGRAM: "messaging:saveTelegram";
|
|
1255
|
-
readonly TEST_LARK: "messaging:testLark";
|
|
1256
|
-
readonly SAVE_LARK: "messaging:saveLark";
|
|
1257
|
-
readonly DISCONNECT: "messaging:disconnect";
|
|
1258
|
-
readonly FORGET: "messaging:forget";
|
|
1259
|
-
readonly GET_BINDINGS: "messaging:getBindings";
|
|
1260
|
-
readonly GENERATE_CODE: "messaging:generateCode";
|
|
1261
|
-
readonly UNBIND: "messaging:unbind";
|
|
1262
|
-
readonly UNBIND_BINDING: "messaging:unbindBinding";
|
|
1263
|
-
/** Workspace-supergroup pairing (Telegram forum support). UI ↔ Server. */
|
|
1264
|
-
readonly GENERATE_SUPERGROUP_CODE: "messaging:generateSupergroupCode";
|
|
1265
|
-
readonly GET_SUPERGROUP: "messaging:getSupergroup";
|
|
1266
|
-
readonly UNBIND_SUPERGROUP: "messaging:unbindSupergroup";
|
|
1267
|
-
readonly WA_START_CONNECT: "messaging:wa:startConnect";
|
|
1268
|
-
readonly WA_SUBMIT_PHONE: "messaging:wa:submitPhone";
|
|
1269
|
-
/** Broadcast to UI clients: QR string, pairing code, status, unavailable, error. */
|
|
1270
|
-
readonly WA_UI_EVENT: "messaging:wa:uiEvent";
|
|
1271
|
-
readonly GET_PLATFORM_OWNERS: "messaging:access:getOwners";
|
|
1272
|
-
readonly SET_PLATFORM_OWNERS: "messaging:access:setOwners";
|
|
1273
|
-
readonly GET_PLATFORM_ACCESS_MODE: "messaging:access:getMode";
|
|
1274
|
-
readonly SET_PLATFORM_ACCESS_MODE: "messaging:access:setMode";
|
|
1275
|
-
readonly GET_PENDING_SENDERS: "messaging:access:getPending";
|
|
1276
|
-
readonly DISMISS_PENDING_SENDER: "messaging:access:dismissPending";
|
|
1277
|
-
readonly ALLOW_PENDING_SENDER: "messaging:access:allowPending";
|
|
1278
|
-
readonly SET_BINDING_ACCESS: "messaging:access:setBindingAccess";
|
|
1279
|
-
};
|
|
1280
|
-
};
|
|
1281
|
-
|
|
1282
|
-
/**
|
|
1283
|
-
* Typed event map for server → client push channels.
|
|
1284
|
-
* Keys are channel string literals, values are argument tuples.
|
|
1285
|
-
*/
|
|
1286
|
-
|
|
1287
|
-
interface BroadcastEventMap {
|
|
1288
|
-
[RPC_CHANNELS.sessions.EVENT]: [event: SessionEvent];
|
|
1289
|
-
[RPC_CHANNELS.sessions.UNREAD_SUMMARY_CHANGED]: [summary: UnreadSummary];
|
|
1290
|
-
[RPC_CHANNELS.sessions.FILES_CHANGED]: [sessionId: string];
|
|
1291
|
-
[RPC_CHANNELS.sources.CHANGED]: [workspaceId: string, sources: unknown[]];
|
|
1292
|
-
[RPC_CHANNELS.labels.CHANGED]: [workspaceId: string];
|
|
1293
|
-
[RPC_CHANNELS.statuses.CHANGED]: [workspaceId: string];
|
|
1294
|
-
[RPC_CHANNELS.automations.CHANGED]: [workspaceId: string];
|
|
1295
|
-
[RPC_CHANNELS.skills.CHANGED]: [workspaceId: string, skills: unknown[]];
|
|
1296
|
-
[RPC_CHANNELS.llmConnections.CHANGED]: [];
|
|
1297
|
-
[RPC_CHANNELS.permissions.DEFAULTS_CHANGED]: [value: null];
|
|
1298
|
-
[RPC_CHANNELS.theme.APP_CHANGED]: [theme: Record<string, unknown> | null];
|
|
1299
|
-
[RPC_CHANNELS.theme.SYSTEM_CHANGED]: [isDark: boolean];
|
|
1300
|
-
[RPC_CHANNELS.theme.PREFERENCES_CHANGED]: [preferences: {
|
|
1301
|
-
mode: string;
|
|
1302
|
-
colorTheme: string;
|
|
1303
|
-
font: string;
|
|
1304
|
-
}];
|
|
1305
|
-
[RPC_CHANNELS.theme.WORKSPACE_THEME_CHANGED]: [data: {
|
|
1306
|
-
workspaceId: string;
|
|
1307
|
-
themeId: string | null;
|
|
1308
|
-
}];
|
|
1309
|
-
[RPC_CHANNELS.update.AVAILABLE]: [info: UpdateInfo];
|
|
1310
|
-
[RPC_CHANNELS.update.DOWNLOAD_PROGRESS]: [progress: number];
|
|
1311
|
-
[RPC_CHANNELS.badge.DRAW]: [data: {
|
|
1312
|
-
count: number;
|
|
1313
|
-
iconDataUrl: string;
|
|
1314
|
-
}];
|
|
1315
|
-
[RPC_CHANNELS.badge.DRAW_WINDOWS]: [data: {
|
|
1316
|
-
count: number;
|
|
1317
|
-
}];
|
|
1318
|
-
[RPC_CHANNELS.window.FOCUS_STATE]: [isFocused: boolean];
|
|
1319
|
-
[RPC_CHANNELS.window.CLOSE_REQUESTED]: [];
|
|
1320
|
-
[RPC_CHANNELS.browserPane.STATE_CHANGED]: [info: BrowserInstanceInfo];
|
|
1321
|
-
[RPC_CHANNELS.browserPane.REMOVED]: [id: string];
|
|
1322
|
-
[RPC_CHANNELS.browserPane.INTERACTED]: [id: string];
|
|
1323
|
-
[RPC_CHANNELS.notification.NAVIGATE]: [data: {
|
|
1324
|
-
workspaceId: string;
|
|
1325
|
-
sessionId: string;
|
|
1326
|
-
}];
|
|
1327
|
-
[RPC_CHANNELS.deeplink.NAVIGATE]: [navigation: DeepLinkNavigation];
|
|
1328
|
-
[RPC_CHANNELS.copilot.DEVICE_CODE]: [data: {
|
|
1329
|
-
userCode: string;
|
|
1330
|
-
verificationUri: string;
|
|
1331
|
-
}];
|
|
1332
|
-
[RPC_CHANNELS.menu.NEW_CHAT]: [];
|
|
1333
|
-
[RPC_CHANNELS.menu.OPEN_SETTINGS]: [];
|
|
1334
|
-
[RPC_CHANNELS.menu.KEYBOARD_SHORTCUTS]: [];
|
|
1335
|
-
[RPC_CHANNELS.menu.TOGGLE_FOCUS_MODE]: [];
|
|
1336
|
-
[RPC_CHANNELS.menu.TOGGLE_SIDEBAR]: [];
|
|
1337
|
-
[RPC_CHANNELS.messaging.BINDING_CHANGED]: [workspaceId: string];
|
|
1338
|
-
[RPC_CHANNELS.messaging.PLATFORM_STATUS]: [workspaceId: string, platform: string, connected: boolean];
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
interface ParsedMentions {
|
|
1342
|
-
skills: string[];
|
|
1343
|
-
invalidSkills: string[];
|
|
1344
|
-
sources: string[];
|
|
1345
|
-
files: string[];
|
|
1346
|
-
folders: string[];
|
|
1347
|
-
}
|
|
1348
|
-
interface MentionMatch {
|
|
1349
|
-
type: 'skill' | 'source' | 'file' | 'folder';
|
|
1350
|
-
id: string;
|
|
1351
|
-
fullMatch: string;
|
|
1352
|
-
startIndex: number;
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
declare function parseMentions(text: string, availableSkillSlugs: string[], availableSourceSlugs: string[]): ParsedMentions;
|
|
1356
|
-
declare function resolveSkillMentions(text: string, skillNames: Map<string, string>): string;
|
|
1357
|
-
declare function resolveSourceMentions(text: string): string;
|
|
1358
|
-
declare function resolvePathMentions(text: string, workingDirectory?: string): Promise<string>;
|
|
1359
|
-
declare function resolveFileMentions(text: string, workingDirectory?: string): Promise<string>;
|
|
1360
|
-
declare function stripAllMentions(text: string): string;
|
|
1361
|
-
declare function findMentionMatches(text: string, availableSkillSlugs: string[], availableSourceSlugs: string[]): MentionMatch[];
|
|
1362
|
-
|
|
1363
|
-
export { AnnotationV1, type AuthRequest, AuthRequestType, type BroadcastEventMap, type BrowserInstanceInfo, type BuiltInStatusId, type ClaudeOAuthResult, ContentBadge, type CreateSessionOptions, CredentialInputMode, type CredentialRequest, type CredentialResponse, type DeepLinkNavigation, type DirectoryListingResult, type FileAttachment, type FileSearchResult, type GitBashStatus, type ImportRemoteSessionTransferResult, type LlmConnectionSetup, type McpToolWithPermission, type McpToolsResult, type McpValidationResult, type MentionMatch, Message, type NewChatActionParams, type OAuthResult, type ParsedMentions, type PermissionMode, type PermissionModeCanonical, type PermissionModeState, PermissionRequest$1 as PermissionRequest, type PermissionResponseOptions, type Plan, type PlanStep, type Session as ProtocolSession, RPC_CHANNELS, type RefreshTitleResult, type RemoteSessionTransferPayload, type SendMessageOptions, type SessionCommand, type SessionEvent, type SessionFile, type PermissionRequest as SessionPermissionRequest, type SessionSearchMatch, type SessionSearchResult, type ShareResult, type SkillFile, THINKING_LEVELS, THINKING_LEVEL_IDS, THINKING_TO_EFFORT, type TestAutomationAction, type TestAutomationActionResult, type TestAutomationPayload, type TestAutomationResult, type TestLlmConnectionParams, type TestLlmConnectionResult, type ThinkingLevel, ToolDisplayMeta, TypedError, type UnreadSummary, type UpdateInfo, type WindowCloseRequest, type WindowCloseRequestSource, type WorkspaceSettings, findMentionMatches, getThinkingLevelNameKey, getThinkingTokens, isValidThinkingLevel, normalizeThinkingLevel, parseMentions, resolveFileMentions, resolvePathMentions, resolveSkillMentions, resolveSourceMentions, stripAllMentions };
|
|
1364
|
-
|
|
1365
|
-
// -- @weft/core/types/index.d.ts --
|
|
1366
|
-
/**
|
|
1367
|
-
* Workspace and authentication types
|
|
1368
|
-
*/
|
|
1369
|
-
/**
|
|
1370
|
-
* How MCP server should be authenticated (workspace-level)
|
|
1371
|
-
* Note: Different from SourceMcpAuthType which uses 'oauth' | 'bearer' | 'none' for individual sources
|
|
1372
|
-
*/
|
|
1373
|
-
type McpAuthType = 'workspace_oauth' | 'workspace_bearer' | 'public';
|
|
1374
|
-
/**
|
|
1375
|
-
* Configuration for a remote Agent Server.
|
|
1376
|
-
* When set on a workspace, handler calls are proxied over WebSocket.
|
|
1377
|
-
*/
|
|
1378
|
-
interface RemoteServerConfig {
|
|
1379
|
-
url: string;
|
|
1380
|
-
token: string;
|
|
1381
|
-
remoteWorkspaceId: string;
|
|
1382
|
-
}
|
|
1383
|
-
/**
|
|
1384
|
-
* Client-facing workspace DTO — safe to send over RPC to remote clients.
|
|
1385
|
-
* Does not expose server-internal filesystem paths.
|
|
1386
|
-
*/
|
|
1387
|
-
interface WorkspaceInfo {
|
|
1388
|
-
id: string;
|
|
1389
|
-
name: string;
|
|
1390
|
-
slug: string;
|
|
1391
|
-
lastAccessedAt?: number;
|
|
1392
|
-
iconUrl?: string;
|
|
1393
|
-
mcpUrl?: string;
|
|
1394
|
-
mcpAuthType?: McpAuthType;
|
|
1395
|
-
remoteServer?: RemoteServerConfig;
|
|
1396
|
-
}
|
|
1397
|
-
/**
|
|
1398
|
-
* Full workspace with server-internal details.
|
|
1399
|
-
* Used by server code and local Electron renderer (LOCAL_ONLY channels).
|
|
1400
|
-
*/
|
|
1401
|
-
interface Workspace extends WorkspaceInfo {
|
|
1402
|
-
rootPath: string;
|
|
1403
|
-
createdAt: number;
|
|
1404
|
-
}
|
|
1405
|
-
/**
|
|
1406
|
-
* Authentication type for AI provider
|
|
1407
|
-
* - api_key: Anthropic API key
|
|
1408
|
-
* - oauth_token: Claude Max OAuth (Anthropic)
|
|
1409
|
-
* - codex_oauth: ChatGPT Plus OAuth via Codex app-server
|
|
1410
|
-
* - codex_api_key: OpenAI API key via Codex (OpenRouter, Vercel AI Gateway compatible)
|
|
1411
|
-
* - provider_owned: Auth is owned by the provider tool itself
|
|
1412
|
-
* (Claude Code uses `~/.claude`, Codex uses `~/.codex`).
|
|
1413
|
-
* Weft never injects credentials — it detects and delegates.
|
|
1414
|
-
*/
|
|
1415
|
-
type AuthType = 'api_key' | 'oauth_token' | 'codex_oauth' | 'codex_api_key' | 'provider_owned';
|
|
1416
|
-
/**
|
|
1417
|
-
* OAuth credentials from a fresh authentication flow.
|
|
1418
|
-
* Used for temporary state in UI components before saving to credential store.
|
|
1419
|
-
*/
|
|
1420
|
-
interface OAuthCredentials {
|
|
1421
|
-
accessToken: string;
|
|
1422
|
-
refreshToken?: string;
|
|
1423
|
-
expiresAt?: number;
|
|
1424
|
-
clientId: string;
|
|
1425
|
-
tokenType: string;
|
|
1426
|
-
}
|
|
1427
|
-
interface StoredConfig {
|
|
1428
|
-
authType?: AuthType;
|
|
1429
|
-
workspaces: Workspace[];
|
|
1430
|
-
activeWorkspaceId: string | null;
|
|
1431
|
-
activeSessionId: string | null;
|
|
1432
|
-
model?: string;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
/**
|
|
1436
|
-
* Message types for conversations
|
|
1437
|
-
*/
|
|
1438
|
-
/**
|
|
1439
|
-
* Message roles for display (runtime)
|
|
1440
|
-
*/
|
|
1441
|
-
type MessageRole = 'user' | 'assistant' | 'tool' | 'error' | 'status' | 'info' | 'warning' | 'plan' | 'auth-request';
|
|
1442
|
-
/**
|
|
1443
|
-
* Credential input modes for different auth types
|
|
1444
|
-
*/
|
|
1445
|
-
type CredentialInputMode = 'bearer' | 'basic' | 'header' | 'query' | 'multi-header';
|
|
1446
|
-
/**
|
|
1447
|
-
* Auth request types
|
|
1448
|
-
*/
|
|
1449
|
-
type AuthRequestType = 'credential' | 'oauth' | 'oauth-google' | 'oauth-slack' | 'oauth-microsoft';
|
|
1450
|
-
/**
|
|
1451
|
-
* Auth request status
|
|
1452
|
-
*/
|
|
1453
|
-
type AuthStatus = 'pending' | 'completed' | 'cancelled' | 'failed';
|
|
1454
|
-
/**
|
|
1455
|
-
* Tool execution status
|
|
1456
|
-
*/
|
|
1457
|
-
type ToolStatus = 'pending' | 'executing' | 'completed' | 'error' | 'backgrounded';
|
|
1458
|
-
/**
|
|
1459
|
-
* Tool display metadata - embedded at storage time for viewer compatibility
|
|
1460
|
-
* Icons are base64-encoded to work in both Electron and web viewer
|
|
1461
|
-
*/
|
|
1462
|
-
interface ToolDisplayMeta {
|
|
1463
|
-
/** Display name for the tool (e.g., "Commit", "Linear") */
|
|
1464
|
-
displayName: string;
|
|
1465
|
-
/** Base64-encoded icon as data URL (e.g., "data:image/png;base64,...") - 32x32px */
|
|
1466
|
-
iconDataUrl?: string;
|
|
1467
|
-
/** Description of what this tool does */
|
|
1468
|
-
description?: string;
|
|
1469
|
-
/** Category for grouping/styling */
|
|
1470
|
-
category?: 'skill' | 'source' | 'native' | 'mcp';
|
|
1471
|
-
}
|
|
1472
|
-
/**
|
|
1473
|
-
* Attachment type categories
|
|
1474
|
-
*/
|
|
1475
|
-
type AttachmentType = 'image' | 'text' | 'pdf' | 'office' | 'audio' | 'unknown';
|
|
1476
|
-
/**
|
|
1477
|
-
* Attachment preview for display in user messages (runtime, before storage)
|
|
1478
|
-
*/
|
|
1479
|
-
interface MessageAttachment {
|
|
1480
|
-
type: AttachmentType;
|
|
1481
|
-
name: string;
|
|
1482
|
-
mimeType: string;
|
|
1483
|
-
size: number;
|
|
1484
|
-
base64?: string;
|
|
1485
|
-
}
|
|
1486
|
-
/**
|
|
1487
|
-
* Content badge for inline display in user messages
|
|
1488
|
-
* Badges are self-contained with all display data (label, icon)
|
|
1489
|
-
*/
|
|
1490
|
-
interface ContentBadge {
|
|
1491
|
-
/** Badge type - used for fallback icon if iconBase64 not available */
|
|
1492
|
-
type: 'source' | 'skill' | 'context' | 'command' | 'file' | 'folder';
|
|
1493
|
-
/** Display label (e.g., "Linear", "Commit") */
|
|
1494
|
-
label: string;
|
|
1495
|
-
/** Original text pattern (e.g., "@linear", "@commit") */
|
|
1496
|
-
rawText: string;
|
|
1497
|
-
/** Icon as data URL (e.g., "data:image/png;base64,...") - preserves mime type */
|
|
1498
|
-
iconDataUrl?: string;
|
|
1499
|
-
/** Start position in content string */
|
|
1500
|
-
start: number;
|
|
1501
|
-
/** End position in content string */
|
|
1502
|
-
end: number;
|
|
1503
|
-
/**
|
|
1504
|
-
* Collapsed label for context badges (e.g., "Edit: Permissions")
|
|
1505
|
-
* When set, the badge replaces the entire marked range with this label
|
|
1506
|
-
* and hides the original content
|
|
1507
|
-
*/
|
|
1508
|
-
collapsedLabel?: string;
|
|
1509
|
-
/**
|
|
1510
|
-
* File path for file badges - stores the full path for click handler
|
|
1511
|
-
* Used when the badge represents a clickable file reference
|
|
1512
|
-
*/
|
|
1513
|
-
filePath?: string;
|
|
1514
|
-
}
|
|
1515
|
-
/**
|
|
1516
|
-
* Author metadata for annotations
|
|
1517
|
-
*/
|
|
1518
|
-
interface AnnotationAuthor {
|
|
1519
|
-
id: string;
|
|
1520
|
-
name?: string;
|
|
1521
|
-
type?: 'user' | 'agent' | 'system';
|
|
1522
|
-
}
|
|
1523
|
-
/**
|
|
1524
|
-
* Annotation body payloads (extensible)
|
|
1525
|
-
*/
|
|
1526
|
-
type AnnotationBody = {
|
|
1527
|
-
type: 'highlight';
|
|
1528
|
-
} | {
|
|
1529
|
-
type: 'note';
|
|
1530
|
-
text: string;
|
|
1531
|
-
format?: 'plain' | 'markdown';
|
|
1532
|
-
} | {
|
|
1533
|
-
type: 'tag';
|
|
1534
|
-
value: string;
|
|
1535
|
-
};
|
|
1536
|
-
/**
|
|
1537
|
-
* Annotation intent (tight v1 semantics).
|
|
1538
|
-
*/
|
|
1539
|
-
type AnnotationIntent = 'highlight' | 'comment' | 'question';
|
|
1540
|
-
/**
|
|
1541
|
-
* Optional lifecycle status for annotation workflows.
|
|
1542
|
-
*/
|
|
1543
|
-
type AnnotationStatus = 'pending' | 'acknowledged' | 'resolved' | 'dismissed';
|
|
1544
|
-
/**
|
|
1545
|
-
* Block types for block selectors.
|
|
1546
|
-
*/
|
|
1547
|
-
type AnnotationBlockType = 'paragraph' | 'code' | 'latex' | 'mermaid' | 'datatable' | 'spreadsheet' | 'image-preview' | 'pdf-preview' | 'html-preview';
|
|
1548
|
-
/**
|
|
1549
|
-
* Selector union used to anchor an annotation target.
|
|
1550
|
-
* Multiple selectors can be stored for robust fallback resolution.
|
|
1551
|
-
*/
|
|
1552
|
-
type AnnotationSelector = {
|
|
1553
|
-
type: 'text-quote';
|
|
1554
|
-
exact: string;
|
|
1555
|
-
prefix?: string;
|
|
1556
|
-
suffix?: string;
|
|
1557
|
-
} | {
|
|
1558
|
-
type: 'text-position';
|
|
1559
|
-
start: number;
|
|
1560
|
-
end: number;
|
|
1561
|
-
textVersion?: string;
|
|
1562
|
-
} | {
|
|
1563
|
-
type: 'block';
|
|
1564
|
-
blockType: AnnotationBlockType;
|
|
1565
|
-
path: string;
|
|
1566
|
-
blockId?: string;
|
|
1567
|
-
} | {
|
|
1568
|
-
type: 'xywh';
|
|
1569
|
-
unit: 'pixel' | 'percent';
|
|
1570
|
-
x: number;
|
|
1571
|
-
y: number;
|
|
1572
|
-
w: number;
|
|
1573
|
-
h: number;
|
|
1574
|
-
page?: number;
|
|
1575
|
-
rotation?: number;
|
|
1576
|
-
} | {
|
|
1577
|
-
type: 'table-cell';
|
|
1578
|
-
rowKey: string | number;
|
|
1579
|
-
columnKey: string;
|
|
1580
|
-
};
|
|
1581
|
-
/**
|
|
1582
|
-
* Annotation target definition.
|
|
1583
|
-
*/
|
|
1584
|
-
interface AnnotationTarget {
|
|
1585
|
-
source: {
|
|
1586
|
-
sessionId: string;
|
|
1587
|
-
messageId: string;
|
|
1588
|
-
};
|
|
1589
|
-
selectors: AnnotationSelector[];
|
|
1590
|
-
}
|
|
1591
|
-
/**
|
|
1592
|
-
* Persisted annotation payload (schema-versioned for migration safety).
|
|
1593
|
-
*/
|
|
1594
|
-
interface AnnotationV1 {
|
|
1595
|
-
id: string;
|
|
1596
|
-
schemaVersion: 1;
|
|
1597
|
-
createdAt: number;
|
|
1598
|
-
updatedAt?: number;
|
|
1599
|
-
createdBy?: AnnotationAuthor;
|
|
1600
|
-
deletedAt?: number;
|
|
1601
|
-
body: AnnotationBody[];
|
|
1602
|
-
target: AnnotationTarget;
|
|
1603
|
-
/** Optional workflow intent (tight v1 semantics). */
|
|
1604
|
-
intent?: AnnotationIntent;
|
|
1605
|
-
/** Optional lifecycle status. */
|
|
1606
|
-
status?: AnnotationStatus;
|
|
1607
|
-
/** Optional reference to the conversation/thread around this annotation. */
|
|
1608
|
-
threadRef?: {
|
|
1609
|
-
threadId?: string;
|
|
1610
|
-
sessionId?: string;
|
|
1611
|
-
};
|
|
1612
|
-
style?: {
|
|
1613
|
-
color?: 'yellow' | 'green' | 'blue' | 'pink' | string;
|
|
1614
|
-
opacity?: number;
|
|
1615
|
-
};
|
|
1616
|
-
meta?: Record<string, unknown>;
|
|
1617
|
-
}
|
|
1618
|
-
/**
|
|
1619
|
-
* Stored attachment metadata (persisted to disk, no base64)
|
|
1620
|
-
* Created when user sends a message with attachments
|
|
1621
|
-
*/
|
|
1622
|
-
interface StoredAttachment {
|
|
1623
|
-
id: string;
|
|
1624
|
-
type: AttachmentType;
|
|
1625
|
-
name: string;
|
|
1626
|
-
mimeType: string;
|
|
1627
|
-
size: number;
|
|
1628
|
-
originalSize?: number;
|
|
1629
|
-
storedPath: string;
|
|
1630
|
-
thumbnailPath?: string;
|
|
1631
|
-
thumbnailBase64?: string;
|
|
1632
|
-
markdownPath?: string;
|
|
1633
|
-
wasResized?: boolean;
|
|
1634
|
-
resizedBase64?: string;
|
|
1635
|
-
}
|
|
1636
|
-
/**
|
|
1637
|
-
* Runtime message type (includes transient fields like isStreaming)
|
|
1638
|
-
*/
|
|
1639
|
-
interface Message {
|
|
1640
|
-
id: string;
|
|
1641
|
-
role: MessageRole;
|
|
1642
|
-
content: string;
|
|
1643
|
-
timestamp: number;
|
|
1644
|
-
toolName?: string;
|
|
1645
|
-
toolUseId?: string;
|
|
1646
|
-
toolInput?: Record<string, unknown>;
|
|
1647
|
-
toolResult?: string;
|
|
1648
|
-
toolStatus?: ToolStatus;
|
|
1649
|
-
toolDuration?: number;
|
|
1650
|
-
toolIntent?: string;
|
|
1651
|
-
toolDisplayName?: string;
|
|
1652
|
-
/** Tool display metadata with base64 icon - embedded at storage time for viewer */
|
|
1653
|
-
toolDisplayMeta?: ToolDisplayMeta;
|
|
1654
|
-
parentToolUseId?: string;
|
|
1655
|
-
taskId?: string;
|
|
1656
|
-
shellId?: string;
|
|
1657
|
-
elapsedSeconds?: number;
|
|
1658
|
-
isBackground?: boolean;
|
|
1659
|
-
attachments?: StoredAttachment[];
|
|
1660
|
-
badges?: ContentBadge[];
|
|
1661
|
-
/** Annotation payloads for this message */
|
|
1662
|
-
annotations?: AnnotationV1[];
|
|
1663
|
-
isError?: boolean;
|
|
1664
|
-
isStreaming?: boolean;
|
|
1665
|
-
isPending?: boolean;
|
|
1666
|
-
isQueued?: boolean;
|
|
1667
|
-
isIntermediate?: boolean;
|
|
1668
|
-
turnId?: string;
|
|
1669
|
-
statusType?: 'compacting' | 'compaction_complete';
|
|
1670
|
-
infoLevel?: 'info' | 'warning' | 'error' | 'success';
|
|
1671
|
-
errorCode?: string;
|
|
1672
|
-
errorTitle?: string;
|
|
1673
|
-
errorDetails?: string[];
|
|
1674
|
-
errorOriginal?: string;
|
|
1675
|
-
errorCanRetry?: boolean;
|
|
1676
|
-
errorActions?: Array<{
|
|
1677
|
-
key: string;
|
|
1678
|
-
label: string;
|
|
1679
|
-
action?: 'retry' | 'settings' | 'reauth' | 'open_url' | 'reconnect_source';
|
|
1680
|
-
url?: string;
|
|
1681
|
-
sourceSlug?: string;
|
|
1682
|
-
}>;
|
|
1683
|
-
planPath?: string;
|
|
1684
|
-
authRequestId?: string;
|
|
1685
|
-
authRequestType?: AuthRequestType;
|
|
1686
|
-
authSourceSlug?: string;
|
|
1687
|
-
authSourceName?: string;
|
|
1688
|
-
authStatus?: AuthStatus;
|
|
1689
|
-
authCredentialMode?: CredentialInputMode;
|
|
1690
|
-
authHeaderName?: string;
|
|
1691
|
-
authHeaderNames?: string[];
|
|
1692
|
-
authLabels?: {
|
|
1693
|
-
credential?: string;
|
|
1694
|
-
username?: string;
|
|
1695
|
-
password?: string;
|
|
1696
|
-
};
|
|
1697
|
-
authDescription?: string;
|
|
1698
|
-
authHint?: string;
|
|
1699
|
-
authSourceUrl?: string;
|
|
1700
|
-
authPasswordRequired?: boolean;
|
|
1701
|
-
authError?: string;
|
|
1702
|
-
authEmail?: string;
|
|
1703
|
-
authWorkspace?: string;
|
|
1704
|
-
}
|
|
1705
|
-
/**
|
|
1706
|
-
* Stored message format (persistence)
|
|
1707
|
-
* Excludes transient runtime-only fields (isStreaming, isPending)
|
|
1708
|
-
*/
|
|
1709
|
-
interface StoredMessage {
|
|
1710
|
-
id: string;
|
|
1711
|
-
type: MessageRole;
|
|
1712
|
-
content: string;
|
|
1713
|
-
timestamp?: number;
|
|
1714
|
-
toolName?: string;
|
|
1715
|
-
toolUseId?: string;
|
|
1716
|
-
toolInput?: Record<string, unknown>;
|
|
1717
|
-
toolResult?: string;
|
|
1718
|
-
toolStatus?: ToolStatus;
|
|
1719
|
-
toolDuration?: number;
|
|
1720
|
-
toolIntent?: string;
|
|
1721
|
-
toolDisplayName?: string;
|
|
1722
|
-
/** Tool display metadata with base64 icon - embedded at storage time for viewer */
|
|
1723
|
-
toolDisplayMeta?: ToolDisplayMeta;
|
|
1724
|
-
parentToolUseId?: string;
|
|
1725
|
-
taskId?: string;
|
|
1726
|
-
shellId?: string;
|
|
1727
|
-
elapsedSeconds?: number;
|
|
1728
|
-
isBackground?: boolean;
|
|
1729
|
-
isError?: boolean;
|
|
1730
|
-
/** Stored attachments for user messages (persisted to disk) */
|
|
1731
|
-
attachments?: StoredAttachment[];
|
|
1732
|
-
/** Content badges for inline display (sources, skills) */
|
|
1733
|
-
badges?: ContentBadge[];
|
|
1734
|
-
/** Annotations persisted at message level */
|
|
1735
|
-
annotations?: AnnotationV1[];
|
|
1736
|
-
isIntermediate?: boolean;
|
|
1737
|
-
turnId?: string;
|
|
1738
|
-
statusType?: 'compacting' | 'compaction_complete';
|
|
1739
|
-
infoLevel?: 'info' | 'warning' | 'error' | 'success';
|
|
1740
|
-
errorCode?: string;
|
|
1741
|
-
errorTitle?: string;
|
|
1742
|
-
errorDetails?: string[];
|
|
1743
|
-
errorOriginal?: string;
|
|
1744
|
-
errorCanRetry?: boolean;
|
|
1745
|
-
errorActions?: Array<{
|
|
1746
|
-
key: string;
|
|
1747
|
-
label: string;
|
|
1748
|
-
action?: 'retry' | 'settings' | 'reauth' | 'open_url' | 'reconnect_source';
|
|
1749
|
-
url?: string;
|
|
1750
|
-
sourceSlug?: string;
|
|
1751
|
-
}>;
|
|
1752
|
-
planPath?: string;
|
|
1753
|
-
authRequestId?: string;
|
|
1754
|
-
authRequestType?: AuthRequestType;
|
|
1755
|
-
authSourceSlug?: string;
|
|
1756
|
-
authSourceName?: string;
|
|
1757
|
-
authStatus?: AuthStatus;
|
|
1758
|
-
authCredentialMode?: CredentialInputMode;
|
|
1759
|
-
authHeaderName?: string;
|
|
1760
|
-
authHeaderNames?: string[];
|
|
1761
|
-
authLabels?: {
|
|
1762
|
-
credential?: string;
|
|
1763
|
-
username?: string;
|
|
1764
|
-
password?: string;
|
|
1765
|
-
};
|
|
1766
|
-
authDescription?: string;
|
|
1767
|
-
authHint?: string;
|
|
1768
|
-
authSourceUrl?: string;
|
|
1769
|
-
authPasswordRequired?: boolean;
|
|
1770
|
-
authError?: string;
|
|
1771
|
-
authEmail?: string;
|
|
1772
|
-
authWorkspace?: string;
|
|
1773
|
-
isQueued?: boolean;
|
|
1774
|
-
}
|
|
1775
|
-
/**
|
|
1776
|
-
* Token usage tracking
|
|
1777
|
-
*/
|
|
1778
|
-
interface TokenUsage {
|
|
1779
|
-
inputTokens: number;
|
|
1780
|
-
outputTokens: number;
|
|
1781
|
-
totalTokens: number;
|
|
1782
|
-
contextTokens: number;
|
|
1783
|
-
costUsd: number;
|
|
1784
|
-
cacheReadTokens?: number;
|
|
1785
|
-
cacheCreationTokens?: number;
|
|
1786
|
-
}
|
|
1787
|
-
/**
|
|
1788
|
-
* Recovery action for typed errors
|
|
1789
|
-
*/
|
|
1790
|
-
interface RecoveryAction {
|
|
1791
|
-
/** Keyboard shortcut (single letter) */
|
|
1792
|
-
key: string;
|
|
1793
|
-
/** Description of the action */
|
|
1794
|
-
label: string;
|
|
1795
|
-
/** Slash command to execute (e.g., '/settings') */
|
|
1796
|
-
command?: string;
|
|
1797
|
-
/** Custom action type for special handling */
|
|
1798
|
-
action?: 'retry' | 'settings' | 'reauth' | 'open_url' | 'reconnect_source';
|
|
1799
|
-
/** URL to open (for open_url action) */
|
|
1800
|
-
url?: string;
|
|
1801
|
-
/** Source slug (for reconnect_source action) */
|
|
1802
|
-
sourceSlug?: string;
|
|
1803
|
-
}
|
|
1804
|
-
/**
|
|
1805
|
-
* Error codes for typed errors - must match AgentError.code in shared/agent/errors.ts
|
|
1806
|
-
*/
|
|
1807
|
-
type ErrorCode = 'invalid_api_key' | 'invalid_credentials' | 'response_too_large' | 'expired_oauth_token' | 'token_expired' | 'rate_limited' | 'service_error' | 'service_unavailable' | 'network_error' | 'proxy_error' | 'mcp_auth_required' | 'mcp_unreachable' | 'billing_error' | 'model_no_tool_support' | 'invalid_model' | 'data_policy_error' | 'invalid_request' | 'image_too_large' | 'provider_error' | 'queued_message_replay_failed' | 'sdk_binary_missing' | 'sdk_cwd_missing' | 'unknown_error';
|
|
1808
|
-
/**
|
|
1809
|
-
* Typed error from agent
|
|
1810
|
-
*/
|
|
1811
|
-
interface TypedError {
|
|
1812
|
-
/** Error code for programmatic handling */
|
|
1813
|
-
code: ErrorCode;
|
|
1814
|
-
/** User-friendly title */
|
|
1815
|
-
title: string;
|
|
1816
|
-
/** Detailed message explaining what went wrong */
|
|
1817
|
-
message: string;
|
|
1818
|
-
/** Suggested recovery actions */
|
|
1819
|
-
actions: RecoveryAction[];
|
|
1820
|
-
/** Whether auto-retry is possible */
|
|
1821
|
-
canRetry: boolean;
|
|
1822
|
-
/** Retry delay in ms (if canRetry is true) */
|
|
1823
|
-
retryDelayMs?: number;
|
|
1824
|
-
/** Diagnostic check results for debugging */
|
|
1825
|
-
details?: string[];
|
|
1826
|
-
/** Original error message for debugging */
|
|
1827
|
-
originalError?: string;
|
|
1828
|
-
}
|
|
1829
|
-
/**
|
|
1830
|
-
* Permission request type categories
|
|
1831
|
-
*/
|
|
1832
|
-
type PermissionRequestType = 'bash' | 'file_write' | 'mcp_mutation' | 'api_mutation' | 'admin_approval';
|
|
1833
|
-
/**
|
|
1834
|
-
* Permission request from agent (e.g., bash command approval)
|
|
1835
|
-
*/
|
|
1836
|
-
interface PermissionRequest {
|
|
1837
|
-
requestId: string;
|
|
1838
|
-
toolName: string;
|
|
1839
|
-
command?: string;
|
|
1840
|
-
description: string;
|
|
1841
|
-
type?: PermissionRequestType;
|
|
1842
|
-
/** Friendly app/package label for admin approval prompts */
|
|
1843
|
-
appName?: string;
|
|
1844
|
-
/** Plain-language reason shown in admin approval prompt */
|
|
1845
|
-
reason?: string;
|
|
1846
|
-
/** Plain-language impact shown in admin approval prompt */
|
|
1847
|
-
impact?: string;
|
|
1848
|
-
/** Whether native OS auth prompt is expected */
|
|
1849
|
-
requiresSystemPrompt?: boolean;
|
|
1850
|
-
/** Optional remember window for this exact command */
|
|
1851
|
-
rememberForMinutes?: number;
|
|
1852
|
-
/** Hash binding for approval integrity checks */
|
|
1853
|
-
commandHash?: string;
|
|
1854
|
-
/** Approval validity window */
|
|
1855
|
-
approvalTtlSeconds?: number;
|
|
1856
|
-
}
|
|
1857
|
-
/**
|
|
1858
|
-
* Usage data emitted by the agent runtime in 'complete' events
|
|
1859
|
-
* Note: This is a subset of TokenUsage - totalTokens/contextTokens are computed by consumers
|
|
1860
|
-
*/
|
|
1861
|
-
interface AgentEventUsage {
|
|
1862
|
-
inputTokens: number;
|
|
1863
|
-
outputTokens: number;
|
|
1864
|
-
cacheReadTokens?: number;
|
|
1865
|
-
cacheCreationTokens?: number;
|
|
1866
|
-
costUsd?: number;
|
|
1867
|
-
/** Model's context window size in tokens (from SDK modelUsage) */
|
|
1868
|
-
contextWindow?: number;
|
|
1869
|
-
}
|
|
1870
|
-
/**
|
|
1871
|
-
* Events emitted by the agent runtime during chat
|
|
1872
|
-
* turnId: Correlation ID from the API's message.id, groups all events in an assistant turn
|
|
1873
|
-
*/
|
|
1874
|
-
type AgentEvent = {
|
|
1875
|
-
type: 'status';
|
|
1876
|
-
message: string;
|
|
1877
|
-
} | {
|
|
1878
|
-
type: 'info';
|
|
1879
|
-
message: string;
|
|
1880
|
-
} | {
|
|
1881
|
-
type: 'text_delta';
|
|
1882
|
-
text: string;
|
|
1883
|
-
turnId?: string;
|
|
1884
|
-
parentToolUseId?: string;
|
|
1885
|
-
} | {
|
|
1886
|
-
type: 'text_complete';
|
|
1887
|
-
text: string;
|
|
1888
|
-
isIntermediate?: boolean;
|
|
1889
|
-
turnId?: string;
|
|
1890
|
-
parentToolUseId?: string;
|
|
1891
|
-
sdkTurnAnchor?: string;
|
|
1892
|
-
} | {
|
|
1893
|
-
type: 'tool_start';
|
|
1894
|
-
toolName: string;
|
|
1895
|
-
toolUseId: string;
|
|
1896
|
-
input: Record<string, unknown>;
|
|
1897
|
-
intent?: string;
|
|
1898
|
-
displayName?: string;
|
|
1899
|
-
turnId?: string;
|
|
1900
|
-
parentToolUseId?: string;
|
|
1901
|
-
toolDisplayMeta?: ToolDisplayMeta;
|
|
1902
|
-
} | {
|
|
1903
|
-
type: 'tool_result';
|
|
1904
|
-
toolUseId: string;
|
|
1905
|
-
toolName?: string;
|
|
1906
|
-
result: string;
|
|
1907
|
-
isError: boolean;
|
|
1908
|
-
input?: Record<string, unknown>;
|
|
1909
|
-
turnId?: string;
|
|
1910
|
-
parentToolUseId?: string;
|
|
1911
|
-
} | {
|
|
1912
|
-
type: 'permission_request';
|
|
1913
|
-
requestId: string;
|
|
1914
|
-
toolName: string;
|
|
1915
|
-
command?: string;
|
|
1916
|
-
description: string;
|
|
1917
|
-
permissionType?: PermissionRequestType;
|
|
1918
|
-
appName?: string;
|
|
1919
|
-
reason?: string;
|
|
1920
|
-
impact?: string;
|
|
1921
|
-
requiresSystemPrompt?: boolean;
|
|
1922
|
-
rememberForMinutes?: number;
|
|
1923
|
-
commandHash?: string;
|
|
1924
|
-
approvalTtlSeconds?: number;
|
|
1925
|
-
} | {
|
|
1926
|
-
type: 'reasoning_delta';
|
|
1927
|
-
text: string;
|
|
1928
|
-
turnId?: string;
|
|
1929
|
-
} | {
|
|
1930
|
-
type: 'reasoning';
|
|
1931
|
-
text: string;
|
|
1932
|
-
turnId?: string;
|
|
1933
|
-
} | {
|
|
1934
|
-
type: 'permission_response';
|
|
1935
|
-
requestId: string;
|
|
1936
|
-
allowed: boolean;
|
|
1937
|
-
remember?: boolean;
|
|
1938
|
-
} | {
|
|
1939
|
-
type: 'error';
|
|
1940
|
-
message: string;
|
|
1941
|
-
} | {
|
|
1942
|
-
type: 'typed_error';
|
|
1943
|
-
error: TypedError;
|
|
1944
|
-
} | {
|
|
1945
|
-
type: 'complete';
|
|
1946
|
-
usage?: AgentEventUsage;
|
|
1947
|
-
} | {
|
|
1948
|
-
type: 'working_directory_changed';
|
|
1949
|
-
workingDirectory: string;
|
|
1950
|
-
} | {
|
|
1951
|
-
type: 'task_backgrounded';
|
|
1952
|
-
toolUseId: string;
|
|
1953
|
-
taskId: string;
|
|
1954
|
-
intent?: string;
|
|
1955
|
-
turnId?: string;
|
|
1956
|
-
} | {
|
|
1957
|
-
type: 'shell_backgrounded';
|
|
1958
|
-
toolUseId: string;
|
|
1959
|
-
shellId: string;
|
|
1960
|
-
intent?: string;
|
|
1961
|
-
command?: string;
|
|
1962
|
-
turnId?: string;
|
|
1963
|
-
} | {
|
|
1964
|
-
type: 'task_progress';
|
|
1965
|
-
toolUseId: string;
|
|
1966
|
-
elapsedSeconds: number;
|
|
1967
|
-
turnId?: string;
|
|
1968
|
-
} | {
|
|
1969
|
-
type: 'task_completed';
|
|
1970
|
-
taskId: string;
|
|
1971
|
-
status: 'completed' | 'failed' | 'stopped';
|
|
1972
|
-
outputFile?: string;
|
|
1973
|
-
summary?: string;
|
|
1974
|
-
turnId?: string;
|
|
1975
|
-
} | {
|
|
1976
|
-
type: 'shell_killed';
|
|
1977
|
-
shellId: string;
|
|
1978
|
-
turnId?: string;
|
|
1979
|
-
} | {
|
|
1980
|
-
type: 'source_activated';
|
|
1981
|
-
sourceSlug: string;
|
|
1982
|
-
originalMessage: string;
|
|
1983
|
-
} | {
|
|
1984
|
-
type: 'usage_update';
|
|
1985
|
-
usage: Pick<AgentEventUsage, 'inputTokens' | 'contextWindow'>;
|
|
1986
|
-
} | {
|
|
1987
|
-
type: 'steer_undelivered';
|
|
1988
|
-
message: string;
|
|
1989
|
-
} | {
|
|
1990
|
-
type: 'compaction_started';
|
|
1991
|
-
} | {
|
|
1992
|
-
type: 'compaction_boundary';
|
|
1993
|
-
summary?: string;
|
|
1994
|
-
};
|
|
1995
|
-
/**
|
|
1996
|
-
* Generate a unique message ID
|
|
1997
|
-
*/
|
|
1998
|
-
declare function generateMessageId(): string;
|
|
1999
|
-
|
|
2000
|
-
/**
|
|
2001
|
-
* Session types for conversation management
|
|
2002
|
-
*
|
|
2003
|
-
* Sessions are the primary isolation boundary. Each session maps 1:1
|
|
2004
|
-
* with an agent runtime instance and SDK conversation.
|
|
2005
|
-
*/
|
|
2006
|
-
|
|
2007
|
-
/**
|
|
2008
|
-
* Session status for workflow tracking
|
|
2009
|
-
* Agents can update this to reflect the current state of the conversation
|
|
2010
|
-
*/
|
|
2011
|
-
type SessionStatus = 'todo' | 'in_progress' | 'needs_review' | 'done' | 'cancelled';
|
|
2012
|
-
/**
|
|
2013
|
-
* Session represents a conversation scope (SDK session = our scope boundary)
|
|
2014
|
-
*/
|
|
2015
|
-
interface Session {
|
|
2016
|
-
id: string;
|
|
2017
|
-
sdkSessionId?: string;
|
|
2018
|
-
workspaceId: string;
|
|
2019
|
-
name?: string;
|
|
2020
|
-
createdAt: number;
|
|
2021
|
-
lastUsedAt: number;
|
|
2022
|
-
isArchived?: boolean;
|
|
2023
|
-
isFlagged?: boolean;
|
|
2024
|
-
status?: SessionStatus;
|
|
2025
|
-
lastReadMessageId?: string;
|
|
2026
|
-
}
|
|
2027
|
-
/**
|
|
2028
|
-
* Stored session with conversation data (for persistence)
|
|
2029
|
-
*/
|
|
2030
|
-
interface StoredSession extends Session {
|
|
2031
|
-
messages: StoredMessage[];
|
|
2032
|
-
tokenUsage: TokenUsage;
|
|
2033
|
-
}
|
|
2034
|
-
/**
|
|
2035
|
-
* Session metadata for listing (without loading full messages)
|
|
2036
|
-
* Extended with archive status for Inbox/Archive features
|
|
2037
|
-
*/
|
|
2038
|
-
interface SessionMetadata {
|
|
2039
|
-
id: string;
|
|
2040
|
-
workspaceId: string;
|
|
2041
|
-
name?: string;
|
|
2042
|
-
createdAt: number;
|
|
2043
|
-
lastUsedAt: number;
|
|
2044
|
-
messageCount: number;
|
|
2045
|
-
preview?: string;
|
|
2046
|
-
sdkSessionId?: string;
|
|
2047
|
-
isArchived?: boolean;
|
|
2048
|
-
isFlagged?: boolean;
|
|
2049
|
-
status?: SessionStatus;
|
|
2050
|
-
hidden?: boolean;
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
/**
|
|
2054
|
-
* Convert runtime Message to StoredMessage for persistence.
|
|
2055
|
-
*
|
|
2056
|
-
* Excludes transient runtime-only fields:
|
|
2057
|
-
* - isStreaming
|
|
2058
|
-
* - isPending
|
|
2059
|
-
*/
|
|
2060
|
-
declare function messageToStored(msg: Message): StoredMessage;
|
|
2061
|
-
/**
|
|
2062
|
-
* Convert StoredMessage to runtime Message.
|
|
2063
|
-
*
|
|
2064
|
-
* Adds a timestamp fallback for legacy messages where timestamp was omitted.
|
|
2065
|
-
*/
|
|
2066
|
-
declare function storedToMessage(stored: StoredMessage): Message;
|
|
2067
|
-
|
|
2068
|
-
/**
|
|
2069
|
-
* Server-level types for headless server operations.
|
|
2070
|
-
*
|
|
2071
|
-
* These types are used by the `server:` RPC namespace for
|
|
2072
|
-
* server status, health checks, active session discovery,
|
|
2073
|
-
* and headless configuration bootstrap.
|
|
2074
|
-
*/
|
|
2075
|
-
interface ServerStatus {
|
|
2076
|
-
serverId: string;
|
|
2077
|
-
version: string;
|
|
2078
|
-
uptime: number;
|
|
2079
|
-
connectedClients: number;
|
|
2080
|
-
workspaces: {
|
|
2081
|
-
id: string;
|
|
2082
|
-
name: string;
|
|
2083
|
-
slug: string;
|
|
2084
|
-
activeSessions: number;
|
|
2085
|
-
automationCount: number;
|
|
2086
|
-
schedulerRunning: boolean;
|
|
2087
|
-
}[];
|
|
2088
|
-
memory: {
|
|
2089
|
-
heapUsed: number;
|
|
2090
|
-
heapTotal: number;
|
|
2091
|
-
rss: number;
|
|
2092
|
-
};
|
|
2093
|
-
}
|
|
2094
|
-
interface ServerHealth {
|
|
2095
|
-
status: 'ok' | 'degraded' | 'unhealthy';
|
|
2096
|
-
checks: {
|
|
2097
|
-
name: string;
|
|
2098
|
-
status: 'pass' | 'fail';
|
|
2099
|
-
message?: string;
|
|
2100
|
-
}[];
|
|
2101
|
-
}
|
|
2102
|
-
/** Session processing state — typed union, not stringly. */
|
|
2103
|
-
type SessionProcessingStatus = 'idle' | 'processing' | 'waiting_input' | 'error' | 'completed';
|
|
2104
|
-
/** Server-level active session info (cross-workspace, client-safe). */
|
|
2105
|
-
interface ActiveSessionInfo {
|
|
2106
|
-
sessionId: string;
|
|
2107
|
-
workspaceId: string;
|
|
2108
|
-
workspaceName: string;
|
|
2109
|
-
title?: string;
|
|
2110
|
-
status: SessionProcessingStatus;
|
|
2111
|
-
triggeredBy?: {
|
|
2112
|
-
automationName: string;
|
|
2113
|
-
timestamp: number;
|
|
2114
|
-
};
|
|
2115
|
-
createdAt: number;
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
|
-
export { type ActiveSessionInfo, type AgentEvent, type AgentEventUsage, type AnnotationAuthor, type AnnotationBlockType, type AnnotationBody, type AnnotationIntent, type AnnotationSelector, type AnnotationStatus, type AnnotationTarget, type AnnotationV1, type AttachmentType, type AuthRequestType, type AuthStatus, type AuthType, type ContentBadge, type CredentialInputMode, type ErrorCode, type McpAuthType, type Message, type MessageAttachment, type MessageRole, type OAuthCredentials, type PermissionRequest, type PermissionRequestType, type RecoveryAction, type RemoteServerConfig, type ServerHealth, type ServerStatus, type Session, type SessionMetadata, type SessionProcessingStatus, type SessionStatus, type StoredAttachment, type StoredConfig, type StoredMessage, type StoredSession, type TokenUsage, type ToolDisplayMeta, type ToolStatus, type TypedError, type Workspace, type WorkspaceInfo, generateMessageId, messageToStored, storedToMessage };
|
|
2119
|
-
|
|
2120
|
-
// -- @weft/core/utils/index.d.ts --
|
|
2121
|
-
/**
|
|
2122
|
-
* Debug utility for core package
|
|
2123
|
-
*
|
|
2124
|
-
* This is a stub that can be enhanced to support debug logging.
|
|
2125
|
-
* Currently a no-op - use @weft debug utilities for full logging.
|
|
2126
|
-
*/
|
|
2127
|
-
declare function debug(..._args: any[]): void;
|
|
2128
|
-
|
|
2129
|
-
/**
|
|
2130
|
-
* Cross-Platform Path Utilities
|
|
2131
|
-
*
|
|
2132
|
-
* Functions for consistent path handling across Windows, macOS, and Linux.
|
|
2133
|
-
* Always normalize paths to forward slashes before comparison operations.
|
|
2134
|
-
*/
|
|
2135
|
-
/**
|
|
2136
|
-
* Normalize a path to use forward slashes for consistent cross-platform comparison.
|
|
2137
|
-
* Use this before comparing paths or using regex patterns on paths.
|
|
2138
|
-
*
|
|
2139
|
-
* @example
|
|
2140
|
-
* normalizePath('C:\\Users\\foo\\bar') // 'C:/Users/foo/bar'
|
|
2141
|
-
* normalizePath('/Users/foo/bar') // '/Users/foo/bar' (unchanged)
|
|
2142
|
-
*/
|
|
2143
|
-
declare function normalizePath(path: string): string;
|
|
2144
|
-
/**
|
|
2145
|
-
* Check if a file path starts with a directory path (cross-platform).
|
|
2146
|
-
* Handles both Windows backslashes and Unix forward slashes.
|
|
2147
|
-
*
|
|
2148
|
-
* @example
|
|
2149
|
-
* pathStartsWith('C:\\Users\\foo\\file.txt', 'C:\\Users\\foo') // true
|
|
2150
|
-
* pathStartsWith('/home/user/file.txt', '/home/user') // true
|
|
2151
|
-
* pathStartsWith('/home/user2/file.txt', '/home/user') // false
|
|
2152
|
-
*/
|
|
2153
|
-
declare function pathStartsWith(filePath: string, dirPath: string): boolean;
|
|
2154
|
-
/**
|
|
2155
|
-
* Strip a directory prefix from a path (cross-platform).
|
|
2156
|
-
* Returns the relative path portion after the prefix.
|
|
2157
|
-
*
|
|
2158
|
-
* @example
|
|
2159
|
-
* stripPathPrefix('/home/user/docs/file.txt', '/home/user') // 'docs/file.txt'
|
|
2160
|
-
* stripPathPrefix('C:\\foo\\bar\\baz.txt', 'C:\\foo') // 'bar/baz.txt'
|
|
2161
|
-
*/
|
|
2162
|
-
declare function stripPathPrefix(filePath: string, prefix: string): string;
|
|
2163
|
-
|
|
2164
|
-
export { debug, normalizePath, pathStartsWith, stripPathPrefix };
|
|
2165
|
-
|
|
2166
|
-
// ── inlined from @weft/timeline ──
|
|
2167
|
-
// -- @weft/timeline/index.d.ts --
|
|
2168
|
-
type TimelineProvider = string;
|
|
2169
|
-
type TimelinePermissionScope = {
|
|
2170
|
-
type: 'session';
|
|
2171
|
-
sessionId: string;
|
|
2172
|
-
} | {
|
|
2173
|
-
type: 'workspace';
|
|
2174
|
-
workspaceId: string;
|
|
2175
|
-
} | {
|
|
2176
|
-
type: 'source';
|
|
2177
|
-
sourceSlug: string;
|
|
2178
|
-
} | {
|
|
2179
|
-
type: 'skill';
|
|
2180
|
-
skillSlug: string;
|
|
2181
|
-
} | {
|
|
2182
|
-
type: 'automation';
|
|
2183
|
-
automationId: string;
|
|
2184
|
-
} | {
|
|
2185
|
-
type: 'tool-call';
|
|
2186
|
-
callId: string;
|
|
2187
|
-
};
|
|
2188
|
-
type TimelineCommandOrigin = {
|
|
2189
|
-
type: 'user';
|
|
2190
|
-
id?: string;
|
|
2191
|
-
} | {
|
|
2192
|
-
type: 'automation';
|
|
2193
|
-
id: string;
|
|
2194
|
-
} | {
|
|
2195
|
-
type: 'scheduler';
|
|
2196
|
-
id?: string;
|
|
2197
|
-
} | {
|
|
2198
|
-
type: 'host';
|
|
2199
|
-
id?: string;
|
|
2200
|
-
} | {
|
|
2201
|
-
type: 'replay';
|
|
2202
|
-
id?: string;
|
|
2203
|
-
} | {
|
|
2204
|
-
type: 'system';
|
|
2205
|
-
id?: string;
|
|
2206
|
-
};
|
|
2207
|
-
interface ToolIntent {
|
|
2208
|
-
kind: string;
|
|
2209
|
-
command?: string;
|
|
2210
|
-
baseCommand?: string;
|
|
2211
|
-
path?: string;
|
|
2212
|
-
toolName?: string;
|
|
2213
|
-
name?: string;
|
|
2214
|
-
method?: string;
|
|
2215
|
-
url?: string;
|
|
2216
|
-
}
|
|
2217
|
-
interface TimelinePermissionRequest {
|
|
2218
|
-
requestId: string;
|
|
2219
|
-
toolName: string;
|
|
2220
|
-
scope?: TimelinePermissionScope;
|
|
2221
|
-
input?: Record<string, unknown>;
|
|
2222
|
-
reason?: string;
|
|
2223
|
-
intent?: ToolIntent;
|
|
2224
|
-
}
|
|
2225
|
-
interface TimelinePermissionResolution {
|
|
2226
|
-
allowed: boolean;
|
|
2227
|
-
remember?: boolean;
|
|
2228
|
-
reason?: string;
|
|
2229
|
-
}
|
|
2230
|
-
type TimelineToolStatus = 'pending' | 'running' | 'completed' | 'failed';
|
|
2231
|
-
type TimelineItem = {
|
|
2232
|
-
type: 'user_message';
|
|
2233
|
-
text: string;
|
|
2234
|
-
messageId: string;
|
|
2235
|
-
turnId?: string;
|
|
2236
|
-
} | {
|
|
2237
|
-
type: 'assistant_message_delta';
|
|
2238
|
-
text: string;
|
|
2239
|
-
messageId: string;
|
|
2240
|
-
turnId: string;
|
|
2241
|
-
} | {
|
|
2242
|
-
type: 'assistant_message';
|
|
2243
|
-
text: string;
|
|
2244
|
-
messageId: string;
|
|
2245
|
-
turnId: string;
|
|
2246
|
-
} | {
|
|
2247
|
-
type: 'reasoning_delta';
|
|
2248
|
-
text: string;
|
|
2249
|
-
messageId: string;
|
|
2250
|
-
turnId: string;
|
|
2251
|
-
} | {
|
|
2252
|
-
type: 'reasoning';
|
|
2253
|
-
text: string;
|
|
2254
|
-
messageId: string;
|
|
2255
|
-
turnId: string;
|
|
2256
|
-
} | {
|
|
2257
|
-
type: 'tool_call';
|
|
2258
|
-
callId: string;
|
|
2259
|
-
name: string;
|
|
2260
|
-
status: TimelineToolStatus;
|
|
2261
|
-
detail?: unknown;
|
|
2262
|
-
turnId?: string;
|
|
2263
|
-
} | {
|
|
2264
|
-
type: 'tool_output_delta';
|
|
2265
|
-
callId: string;
|
|
2266
|
-
text: string;
|
|
2267
|
-
stream?: 'stdout' | 'stderr' | string;
|
|
2268
|
-
turnId?: string;
|
|
2269
|
-
} | {
|
|
2270
|
-
type: 'tool_result';
|
|
2271
|
-
callId: string;
|
|
2272
|
-
result: unknown;
|
|
2273
|
-
isError?: boolean;
|
|
2274
|
-
turnId?: string;
|
|
2275
|
-
} | {
|
|
2276
|
-
type: 'permission_requested';
|
|
2277
|
-
request: TimelinePermissionRequest;
|
|
2278
|
-
} | {
|
|
2279
|
-
type: 'permission_resolved';
|
|
2280
|
-
requestId: string;
|
|
2281
|
-
resolution: TimelinePermissionResolution;
|
|
2282
|
-
} | {
|
|
2283
|
-
type: 'permission_policy_changed';
|
|
2284
|
-
policy: unknown;
|
|
2285
|
-
} | {
|
|
2286
|
-
type: 'source_state_changed';
|
|
2287
|
-
source: unknown;
|
|
2288
|
-
} | {
|
|
2289
|
-
type: 'skill_activated';
|
|
2290
|
-
skill: unknown;
|
|
2291
|
-
} | {
|
|
2292
|
-
type: 'host_state_changed';
|
|
2293
|
-
state: unknown;
|
|
2294
|
-
} | {
|
|
2295
|
-
type: 'automation_triggered';
|
|
2296
|
-
automation: {
|
|
2297
|
-
automationId: string;
|
|
2298
|
-
origin: TimelineCommandOrigin;
|
|
2299
|
-
detail?: unknown;
|
|
2300
|
-
};
|
|
2301
|
-
} | {
|
|
2302
|
-
type: 'automation_action_result';
|
|
2303
|
-
result: unknown;
|
|
2304
|
-
} | {
|
|
2305
|
-
type: 'runtime_capability_report';
|
|
2306
|
-
report: unknown;
|
|
2307
|
-
} | {
|
|
2308
|
-
type: 'runtime_fallback';
|
|
2309
|
-
reason: string;
|
|
2310
|
-
from?: string;
|
|
2311
|
-
to: string;
|
|
2312
|
-
} | {
|
|
2313
|
-
type: 'turn_started';
|
|
2314
|
-
turnId: string;
|
|
2315
|
-
} | {
|
|
2316
|
-
type: 'turn_completed';
|
|
2317
|
-
turnId: string;
|
|
2318
|
-
usage?: unknown;
|
|
2319
|
-
} | {
|
|
2320
|
-
type: 'turn_failed';
|
|
2321
|
-
turnId: string;
|
|
2322
|
-
error: unknown;
|
|
2323
|
-
} | {
|
|
2324
|
-
type: 'session_status';
|
|
2325
|
-
status: string;
|
|
2326
|
-
} | {
|
|
2327
|
-
type: 'tool_suspended';
|
|
2328
|
-
callId: string;
|
|
2329
|
-
name: string;
|
|
2330
|
-
stepId?: string;
|
|
2331
|
-
} | {
|
|
2332
|
-
type: 'tool_resumed';
|
|
2333
|
-
callId: string;
|
|
2334
|
-
name: string;
|
|
2335
|
-
stepId?: string;
|
|
2336
|
-
} | {
|
|
2337
|
-
type: 'compaction_started';
|
|
2338
|
-
} | {
|
|
2339
|
-
type: 'compaction_boundary';
|
|
2340
|
-
summary?: string;
|
|
2341
|
-
};
|
|
2342
|
-
interface TimelineRawRef {
|
|
2343
|
-
providerEventType?: string;
|
|
2344
|
-
logPath?: string;
|
|
2345
|
-
offset?: number;
|
|
2346
|
-
}
|
|
2347
|
-
interface TimelineEnvelope {
|
|
2348
|
-
sessionId: string;
|
|
2349
|
-
provider: TimelineProvider;
|
|
2350
|
-
seq: number;
|
|
2351
|
-
epoch: string;
|
|
2352
|
-
timestamp: number;
|
|
2353
|
-
item: TimelineItem;
|
|
2354
|
-
rawRef?: TimelineRawRef;
|
|
2355
|
-
}
|
|
2356
|
-
interface TimelineCursor {
|
|
2357
|
-
epoch: string;
|
|
2358
|
-
afterSeq: number;
|
|
2359
|
-
}
|
|
2360
|
-
interface TimelineFetchRequest {
|
|
2361
|
-
cursor?: TimelineCursor;
|
|
2362
|
-
limit?: number;
|
|
2363
|
-
}
|
|
2364
|
-
interface TimelineFetchResult {
|
|
2365
|
-
items: TimelineEnvelope[];
|
|
2366
|
-
nextCursor: TimelineCursor;
|
|
2367
|
-
hasGap: boolean;
|
|
2368
|
-
}
|
|
2369
|
-
interface CreateTimelineSequencerOptions {
|
|
2370
|
-
sessionId: string;
|
|
2371
|
-
provider: TimelineProvider;
|
|
2372
|
-
epoch: string;
|
|
2373
|
-
startSeq?: number;
|
|
2374
|
-
now?: () => number;
|
|
2375
|
-
}
|
|
2376
|
-
interface TimelineSequencer {
|
|
2377
|
-
append(item: TimelineItem, rawRef?: TimelineRawRef): TimelineEnvelope;
|
|
2378
|
-
}
|
|
2379
|
-
declare function createTimelineSequencer(options: CreateTimelineSequencerOptions): TimelineSequencer;
|
|
2380
|
-
declare function appendTimelineItem(envelope: TimelineEnvelope): TimelineEnvelope;
|
|
2381
|
-
declare function createTimelineCursor(cursor: TimelineCursor): TimelineCursor;
|
|
2382
|
-
declare function fetchTimeline(timeline: TimelineEnvelope[], request?: TimelineFetchRequest): TimelineFetchResult;
|
|
2383
|
-
declare function mergeTimeline(existing: TimelineEnvelope[], incoming: TimelineEnvelope[]): TimelineEnvelope[];
|
|
2384
|
-
|
|
2385
|
-
export { type CreateTimelineSequencerOptions, type TimelineCommandOrigin, type TimelineCursor, type TimelineEnvelope, type TimelineFetchRequest, type TimelineFetchResult, type TimelineItem, type TimelinePermissionRequest, type TimelinePermissionResolution, type TimelinePermissionScope, type TimelineProvider, type TimelineRawRef, type TimelineSequencer, type TimelineToolStatus, type ToolIntent, appendTimelineItem, createTimelineCursor, createTimelineSequencer, fetchTimeline, mergeTimeline };
|
|
2386
|
-
|
|
2387
|
-
// ── inlined from @weft/runtime-core ──
|
|
2388
|
-
// -- @weft/runtime-core/index.d.ts --
|
|
2389
|
-
|
|
2390
|
-
declare const RUNTIME_KINDS: readonly ["native-sdk", "app-server", "compatible-sdk", "cli-fallback"];
|
|
2391
|
-
type AgentRuntimeKind = typeof RUNTIME_KINDS[number];
|
|
2392
|
-
type AgentRuntimeStatus = 'idle' | 'preflighting' | 'ready' | 'starting' | 'running' | 'waiting_for_permission' | 'turn_completed' | 'completed' | 'failed' | 'disposed';
|
|
2393
|
-
|
|
2394
|
-
/**
|
|
2395
|
-
* How a provider's authentication is managed.
|
|
2396
|
-
* Provider-neutral auth mode — covers native SDK, app-server, compatible SDK, and CLI fallback.
|
|
2397
|
-
*/
|
|
2398
|
-
type ProviderAuthMode = 'provider-owned' | 'managed' | 'none';
|
|
2399
|
-
/**
|
|
2400
|
-
* Result of probing a provider's auth configuration.
|
|
2401
|
-
*
|
|
2402
|
-
* For provider-owned auth: checks whether the provider binary reports
|
|
2403
|
-
* authentication as configured (e.g. `claude auth status --json` returns
|
|
2404
|
-
* `loggedIn: true`, or `codex app-server account/read` returns an account).
|
|
2405
|
-
*
|
|
2406
|
-
* For managed auth: checks whether required env vars are present.
|
|
2407
|
-
* For 'none': no auth required (e.g. fake backend for testing).
|
|
2408
|
-
*/
|
|
2409
|
-
interface ProviderAuthDetection {
|
|
2410
|
-
/** Which auth mode this provider uses */
|
|
2411
|
-
mode: ProviderAuthMode;
|
|
2412
|
-
/** Whether auth credentials are available and valid */
|
|
2413
|
-
configured: boolean;
|
|
2414
|
-
/** How auth was detected (e.g. "claude auth status --json", "env vars") */
|
|
2415
|
-
source: string;
|
|
2416
|
-
/** Whether an account was found (provider-owned: from CLI output) */
|
|
2417
|
-
accountPresent?: boolean;
|
|
2418
|
-
/** Whether OpenAI auth is required (Codex-specific) */
|
|
2419
|
-
requiresOpenaiAuth?: boolean;
|
|
2420
|
-
/** Auth method reported by provider (e.g. "oauth", "api_key") */
|
|
2421
|
-
method?: string;
|
|
2422
|
-
/** Provider name reported by CLI (e.g. "anthropic") */
|
|
2423
|
-
provider?: string;
|
|
2424
|
-
/** Error message if auth detection failed */
|
|
2425
|
-
error?: string;
|
|
2426
|
-
}
|
|
2427
|
-
/**
|
|
2428
|
-
* Narrowed auth detection for runtime capability reports.
|
|
2429
|
-
* Only covers provider-owned auth, which is the SDK-first default.
|
|
2430
|
-
*/
|
|
2431
|
-
interface RuntimeAuthDetection extends ProviderAuthDetection {
|
|
2432
|
-
mode: 'provider-owned';
|
|
2433
|
-
}
|
|
2434
|
-
interface RuntimeCandidate {
|
|
2435
|
-
kind: AgentRuntimeKind;
|
|
2436
|
-
available: boolean;
|
|
2437
|
-
reason?: string;
|
|
2438
|
-
}
|
|
2439
|
-
interface RuntimeSelectionOptions {
|
|
2440
|
-
provider?: string;
|
|
2441
|
-
candidates: RuntimeCandidate[];
|
|
2442
|
-
preferredRuntime?: AgentRuntimeKind;
|
|
2443
|
-
allowFallback?: boolean;
|
|
2444
|
-
}
|
|
2445
|
-
interface RuntimeSelection {
|
|
2446
|
-
selected?: AgentRuntimeKind;
|
|
2447
|
-
fallback: boolean;
|
|
2448
|
-
fallbackReason?: string;
|
|
2449
|
-
error?: string;
|
|
2450
|
-
}
|
|
2451
|
-
interface RuntimeCapabilityReport extends RuntimeSelection {
|
|
2452
|
-
provider: string;
|
|
2453
|
-
candidates: RuntimeCandidate[];
|
|
2454
|
-
preferredRuntime?: AgentRuntimeKind;
|
|
2455
|
-
allowFallback: boolean;
|
|
2456
|
-
auth: RuntimeAuthDetection;
|
|
2457
|
-
policyCapabilities: RuntimePolicyCapabilities;
|
|
2458
|
-
sourceCapabilities: RuntimeSourceCapabilities;
|
|
2459
|
-
skillCapabilities: RuntimeSkillCapabilities;
|
|
2460
|
-
automationCapabilities: RuntimeAutomationCapabilities;
|
|
2461
|
-
hostToolCapabilities: RuntimeHostToolCapabilities;
|
|
2462
|
-
}
|
|
2463
|
-
interface CreateRuntimeCapabilityReportOptions extends RuntimeSelectionOptions {
|
|
2464
|
-
provider: string;
|
|
2465
|
-
auth: RuntimeAuthDetection;
|
|
2466
|
-
extensionCapabilities?: RuntimeExtensionCapabilities;
|
|
2467
|
-
}
|
|
2468
|
-
interface AgentRuntimeOptions {
|
|
2469
|
-
provider: string;
|
|
2470
|
-
cwd: string;
|
|
2471
|
-
sessionId?: string;
|
|
2472
|
-
model?: string;
|
|
2473
|
-
reasoningEffort?: string;
|
|
2474
|
-
permissionMode?: PermissionMode;
|
|
2475
|
-
authMode?: 'provider-owned';
|
|
2476
|
-
preferredRuntime?: AgentRuntimeKind;
|
|
2477
|
-
allowFallback?: boolean;
|
|
2478
|
-
executable?: string;
|
|
2479
|
-
env?: Record<string, string>;
|
|
2480
|
-
extensions?: RuntimeExtensionContext;
|
|
2481
|
-
}
|
|
2482
|
-
interface SendMessageOptions {
|
|
2483
|
-
turnId?: string;
|
|
2484
|
-
model?: string;
|
|
2485
|
-
reasoningEffort?: string;
|
|
2486
|
-
permissionMode?: PermissionMode;
|
|
2487
|
-
commandOrigin?: CommandOrigin;
|
|
2488
|
-
}
|
|
2489
|
-
type ToolPolicyDecision = {
|
|
2490
|
-
decision: 'allow';
|
|
2491
|
-
} | {
|
|
2492
|
-
decision: 'ask';
|
|
2493
|
-
reason: string;
|
|
2494
|
-
} | {
|
|
2495
|
-
decision: 'deny';
|
|
2496
|
-
reason: string;
|
|
2497
|
-
};
|
|
2498
|
-
interface CodexPermissionParams {
|
|
2499
|
-
approvalPolicy: string;
|
|
2500
|
-
approvalsReviewer: string;
|
|
2501
|
-
sandbox: string;
|
|
2502
|
-
}
|
|
2503
|
-
/**
|
|
2504
|
-
* Canonical PermissionMode → Codex permission parameters mapping, shared by
|
|
2505
|
-
* the app-server driver (thread/start, turn/start), the host controller, and
|
|
2506
|
-
* the CLI fallback runtime. `sandbox` is a Codex `SandboxMode` string as used
|
|
2507
|
-
* by `thread/start` and `codex exec --sandbox`.
|
|
2508
|
-
*/
|
|
2509
|
-
declare function mapPermissionModeToCodexParams(mode: PermissionMode): CodexPermissionParams;
|
|
2510
|
-
/**
|
|
2511
|
-
* Codex app-server v2 `turn/start` takes a tagged `SandboxPolicy` object,
|
|
2512
|
-
* unlike `thread/start` which takes a plain `SandboxMode` string. Variant
|
|
2513
|
-
* fields are all serde-defaulted, so the minimal `{ type }` form is valid.
|
|
2514
|
-
*/
|
|
2515
|
-
declare function mapCodexSandboxModeToSandboxPolicy(sandbox: string): {
|
|
2516
|
-
type: string;
|
|
2517
|
-
};
|
|
2518
|
-
type RuntimePermissionScope = {
|
|
2519
|
-
type: 'session';
|
|
2520
|
-
sessionId: string;
|
|
2521
|
-
} | {
|
|
2522
|
-
type: 'workspace';
|
|
2523
|
-
workspaceId: string;
|
|
2524
|
-
} | {
|
|
2525
|
-
type: 'source';
|
|
2526
|
-
sourceSlug: string;
|
|
2527
|
-
} | {
|
|
2528
|
-
type: 'skill';
|
|
2529
|
-
skillSlug: string;
|
|
2530
|
-
} | {
|
|
2531
|
-
type: 'automation';
|
|
2532
|
-
automationId: string;
|
|
2533
|
-
} | {
|
|
2534
|
-
type: 'tool-call';
|
|
2535
|
-
callId: string;
|
|
2536
|
-
};
|
|
2537
|
-
type RuntimePermissionScopeInput = string | RuntimePermissionScope;
|
|
2538
|
-
type RuntimeToolIntent = {
|
|
2539
|
-
kind: 'bash';
|
|
2540
|
-
command: string;
|
|
2541
|
-
baseCommand: string;
|
|
2542
|
-
} | {
|
|
2543
|
-
kind: 'file_write';
|
|
2544
|
-
path: string;
|
|
2545
|
-
toolName: string;
|
|
2546
|
-
} | {
|
|
2547
|
-
kind: 'mcp';
|
|
2548
|
-
name: string;
|
|
2549
|
-
} | {
|
|
2550
|
-
kind: 'api';
|
|
2551
|
-
method: string;
|
|
2552
|
-
path: string;
|
|
2553
|
-
url?: string;
|
|
2554
|
-
} | {
|
|
2555
|
-
kind: 'unknown';
|
|
2556
|
-
toolName: string;
|
|
2557
|
-
};
|
|
2558
|
-
interface ToolPolicyRequest {
|
|
2559
|
-
toolName: string;
|
|
2560
|
-
input?: Record<string, unknown>;
|
|
2561
|
-
toolIntent?: RuntimeToolIntent;
|
|
2562
|
-
scope?: RuntimePermissionScopeInput;
|
|
2563
|
-
}
|
|
2564
|
-
type RuntimePolicyHook = (request: ToolPolicyRequest) => ToolPolicyDecision | Promise<ToolPolicyDecision>;
|
|
2565
|
-
interface RuntimeFeatureCapabilities {
|
|
2566
|
-
supported: boolean;
|
|
2567
|
-
degraded?: boolean;
|
|
2568
|
-
reason?: string;
|
|
2569
|
-
}
|
|
2570
|
-
interface RuntimePolicyCapabilities extends RuntimeFeatureCapabilities {
|
|
2571
|
-
modes: PermissionMode[];
|
|
2572
|
-
approvals: boolean;
|
|
2573
|
-
toolPolicy: boolean;
|
|
2574
|
-
}
|
|
2575
|
-
interface RuntimeSourceCapabilities extends RuntimeFeatureCapabilities {
|
|
2576
|
-
registry?: boolean;
|
|
2577
|
-
credentialGateway?: boolean;
|
|
2578
|
-
mcpTools?: boolean;
|
|
2579
|
-
}
|
|
2580
|
-
interface RuntimeSkillCapabilities extends RuntimeFeatureCapabilities {
|
|
2581
|
-
registry?: boolean;
|
|
2582
|
-
activationPlan?: boolean;
|
|
2583
|
-
scopedPolicy?: boolean;
|
|
2584
|
-
}
|
|
2585
|
-
interface RuntimeAutomationCapabilities extends RuntimeFeatureCapabilities {
|
|
2586
|
-
eventBus: boolean;
|
|
2587
|
-
schedulerHost: boolean;
|
|
2588
|
-
promptAction: boolean;
|
|
2589
|
-
webhookAction: boolean;
|
|
2590
|
-
}
|
|
2591
|
-
interface RuntimeHostToolCapabilities extends RuntimeFeatureCapabilities {
|
|
2592
|
-
sessionTools: boolean;
|
|
2593
|
-
workflowTransitions: boolean;
|
|
2594
|
-
browserActions: boolean;
|
|
2595
|
-
metadataWrites: boolean;
|
|
2596
|
-
}
|
|
2597
|
-
interface RuntimeExtensionCapabilities {
|
|
2598
|
-
policy?: RuntimePolicyCapabilities;
|
|
2599
|
-
sources?: RuntimeSourceCapabilities;
|
|
2600
|
-
skills?: RuntimeSkillCapabilities;
|
|
2601
|
-
automations?: RuntimeAutomationCapabilities;
|
|
2602
|
-
hostTools?: RuntimeHostToolCapabilities;
|
|
2603
|
-
}
|
|
2604
|
-
interface RuntimePolicyExtension {
|
|
2605
|
-
mode: PermissionMode;
|
|
2606
|
-
hook?: RuntimePolicyHook;
|
|
2607
|
-
degraded?: boolean;
|
|
2608
|
-
}
|
|
2609
|
-
interface SourceSelection {
|
|
2610
|
-
enabledSourceSlugs: string[];
|
|
2611
|
-
}
|
|
2612
|
-
interface ProviderSourceCredentialRef {
|
|
2613
|
-
type: string;
|
|
2614
|
-
sourceSlug: string;
|
|
2615
|
-
workspaceId?: string;
|
|
2616
|
-
}
|
|
2617
|
-
type ProviderSourceToolDescriptor = {
|
|
2618
|
-
kind: 'api-source';
|
|
2619
|
-
sourceSlug: string;
|
|
2620
|
-
baseUrl: string;
|
|
2621
|
-
authType: string;
|
|
2622
|
-
defaultHeaders?: Record<string, string>;
|
|
2623
|
-
credentialRef?: ProviderSourceCredentialRef;
|
|
2624
|
-
[key: string]: unknown;
|
|
2625
|
-
} | {
|
|
2626
|
-
kind: 'local-source';
|
|
2627
|
-
sourceSlug: string;
|
|
2628
|
-
path: string;
|
|
2629
|
-
format?: string;
|
|
2630
|
-
[key: string]: unknown;
|
|
2631
|
-
} | {
|
|
2632
|
-
kind: 'mcp-server';
|
|
2633
|
-
sourceSlug: string;
|
|
2634
|
-
transport: 'stdio' | 'http' | 'sse';
|
|
2635
|
-
url?: string;
|
|
2636
|
-
command?: string;
|
|
2637
|
-
args?: string[];
|
|
2638
|
-
env?: Record<string, string>;
|
|
2639
|
-
headers?: Record<string, string>;
|
|
2640
|
-
credentialRef?: ProviderSourceCredentialRef;
|
|
2641
|
-
[key: string]: unknown;
|
|
2642
|
-
};
|
|
2643
|
-
interface SkillSelection {
|
|
2644
|
-
activeSkillSlugs: string[];
|
|
2645
|
-
}
|
|
2646
|
-
type CommandOrigin = {
|
|
2647
|
-
type: 'user';
|
|
2648
|
-
id?: string;
|
|
2649
|
-
} | {
|
|
2650
|
-
type: 'automation';
|
|
2651
|
-
id: string;
|
|
2652
|
-
} | {
|
|
2653
|
-
type: 'scheduler';
|
|
2654
|
-
id?: string;
|
|
2655
|
-
} | {
|
|
2656
|
-
type: 'host';
|
|
2657
|
-
id?: string;
|
|
2658
|
-
} | {
|
|
2659
|
-
type: 'replay';
|
|
2660
|
-
id?: string;
|
|
2661
|
-
} | {
|
|
2662
|
-
type: 'system';
|
|
2663
|
-
id?: string;
|
|
2664
|
-
};
|
|
2665
|
-
interface SubmitPlanRequest {
|
|
2666
|
-
sessionId?: string;
|
|
2667
|
-
planRef: string;
|
|
2668
|
-
origin?: CommandOrigin;
|
|
2669
|
-
}
|
|
2670
|
-
interface SubmitPlanReceipt {
|
|
2671
|
-
accepted: boolean;
|
|
2672
|
-
planRef?: string;
|
|
2673
|
-
reason?: string;
|
|
2674
|
-
}
|
|
2675
|
-
interface SourceAuthRequest {
|
|
2676
|
-
sessionId?: string;
|
|
2677
|
-
sourceSlug: string;
|
|
2678
|
-
reason?: string;
|
|
2679
|
-
}
|
|
2680
|
-
interface SourceAuthReceipt {
|
|
2681
|
-
ok: boolean;
|
|
2682
|
-
sourceSlug: string;
|
|
2683
|
-
reason?: string;
|
|
2684
|
-
}
|
|
2685
|
-
interface SourceActivationRequest {
|
|
2686
|
-
sessionId?: string;
|
|
2687
|
-
sourceSlug: string;
|
|
2688
|
-
}
|
|
2689
|
-
interface SourceActivationReceipt {
|
|
2690
|
-
ok: boolean;
|
|
2691
|
-
sourceSlug: string;
|
|
2692
|
-
availability?: 'immediate' | 'next-turn';
|
|
2693
|
-
reason?: string;
|
|
2694
|
-
}
|
|
2695
|
-
interface BrowserActionRequest {
|
|
2696
|
-
sessionId?: string;
|
|
2697
|
-
action: string;
|
|
2698
|
-
input?: unknown;
|
|
2699
|
-
}
|
|
2700
|
-
interface BrowserActionReceipt {
|
|
2701
|
-
ok: boolean;
|
|
2702
|
-
result?: unknown;
|
|
2703
|
-
reason?: string;
|
|
2704
|
-
}
|
|
2705
|
-
interface SpawnSessionRequest {
|
|
2706
|
-
parentSessionId?: string;
|
|
2707
|
-
prompt: string;
|
|
2708
|
-
model?: string;
|
|
2709
|
-
commandOrigin?: CommandOrigin;
|
|
2710
|
-
}
|
|
2711
|
-
interface SpawnSessionReceipt {
|
|
2712
|
-
sessionId: string;
|
|
2713
|
-
}
|
|
2714
|
-
interface InterSessionMessageRequest {
|
|
2715
|
-
sessionId: string;
|
|
2716
|
-
message: string;
|
|
2717
|
-
attachments?: Array<{
|
|
2718
|
-
path: string;
|
|
2719
|
-
name?: string;
|
|
2720
|
-
}>;
|
|
2721
|
-
commandOrigin?: CommandOrigin;
|
|
2722
|
-
}
|
|
2723
|
-
interface CommandReceipt {
|
|
2724
|
-
ok: boolean;
|
|
2725
|
-
commandId?: string;
|
|
2726
|
-
reason?: string;
|
|
2727
|
-
}
|
|
2728
|
-
interface SessionMetadataPatch {
|
|
2729
|
-
sessionId?: string;
|
|
2730
|
-
labels?: string[];
|
|
2731
|
-
status?: string;
|
|
2732
|
-
flagged?: boolean;
|
|
2733
|
-
topic?: string;
|
|
2734
|
-
}
|
|
2735
|
-
interface SessionMetadataSnapshot {
|
|
2736
|
-
sessionId?: string;
|
|
2737
|
-
labels?: string[];
|
|
2738
|
-
status?: string;
|
|
2739
|
-
flagged?: boolean;
|
|
2740
|
-
topic?: string;
|
|
2741
|
-
}
|
|
2742
|
-
interface SessionListRequest {
|
|
2743
|
-
status?: string;
|
|
2744
|
-
labels?: string[];
|
|
2745
|
-
limit?: number;
|
|
2746
|
-
}
|
|
2747
|
-
interface SessionListResult {
|
|
2748
|
-
sessions: SessionMetadataSnapshot[];
|
|
2749
|
-
}
|
|
2750
|
-
interface LlmToolRequest {
|
|
2751
|
-
prompt: string;
|
|
2752
|
-
model?: string;
|
|
2753
|
-
commandOrigin?: CommandOrigin;
|
|
2754
|
-
}
|
|
2755
|
-
interface LlmToolResult {
|
|
2756
|
-
text: string;
|
|
2757
|
-
model?: string;
|
|
2758
|
-
usage?: unknown;
|
|
2759
|
-
}
|
|
2760
|
-
interface ListSourcesRequest {
|
|
2761
|
-
sessionId?: string;
|
|
2762
|
-
enabledOnly?: boolean;
|
|
2763
|
-
}
|
|
2764
|
-
interface SourceSummary {
|
|
2765
|
-
slug: string;
|
|
2766
|
-
name: string;
|
|
2767
|
-
provider: string;
|
|
2768
|
-
type: string;
|
|
2769
|
-
enabled: boolean;
|
|
2770
|
-
isAuthenticated?: boolean;
|
|
2771
|
-
connectionStatus?: string;
|
|
2772
|
-
tagline?: string;
|
|
2773
|
-
}
|
|
2774
|
-
interface ListSourcesResult {
|
|
2775
|
-
sources: SourceSummary[];
|
|
2776
|
-
}
|
|
2777
|
-
interface GetSourceRequest {
|
|
2778
|
-
sessionId?: string;
|
|
2779
|
-
sourceSlug: string;
|
|
2780
|
-
}
|
|
2781
|
-
interface GetSourceResult {
|
|
2782
|
-
source: SourceSummary & {
|
|
2783
|
-
createdAt?: number;
|
|
2784
|
-
updatedAt?: number;
|
|
2785
|
-
mcp?: Record<string, unknown>;
|
|
2786
|
-
api?: Record<string, unknown>;
|
|
2787
|
-
local?: Record<string, unknown>;
|
|
2788
|
-
};
|
|
2789
|
-
}
|
|
2790
|
-
interface CreateSourceRequest {
|
|
2791
|
-
sessionId?: string;
|
|
2792
|
-
name: string;
|
|
2793
|
-
provider: string;
|
|
2794
|
-
type: string;
|
|
2795
|
-
mcp?: Record<string, unknown>;
|
|
2796
|
-
api?: Record<string, unknown>;
|
|
2797
|
-
local?: Record<string, unknown>;
|
|
2798
|
-
icon?: string;
|
|
2799
|
-
enabled?: boolean;
|
|
2800
|
-
}
|
|
2801
|
-
interface CreateSourceResult {
|
|
2802
|
-
ok: boolean;
|
|
2803
|
-
source?: SourceSummary;
|
|
2804
|
-
reason?: string;
|
|
2805
|
-
}
|
|
2806
|
-
interface UpdateSourceRequest {
|
|
2807
|
-
sessionId?: string;
|
|
2808
|
-
sourceSlug: string;
|
|
2809
|
-
enabled?: boolean;
|
|
2810
|
-
name?: string;
|
|
2811
|
-
icon?: string;
|
|
2812
|
-
tagline?: string;
|
|
2813
|
-
}
|
|
2814
|
-
interface UpdateSourceResult {
|
|
2815
|
-
ok: boolean;
|
|
2816
|
-
source?: SourceSummary;
|
|
2817
|
-
reason?: string;
|
|
2818
|
-
}
|
|
2819
|
-
interface DeleteSourceRequest {
|
|
2820
|
-
sessionId?: string;
|
|
2821
|
-
sourceSlug: string;
|
|
2822
|
-
}
|
|
2823
|
-
interface DeleteSourceResult {
|
|
2824
|
-
ok: boolean;
|
|
2825
|
-
sourceSlug: string;
|
|
2826
|
-
reason?: string;
|
|
2827
|
-
}
|
|
2828
|
-
interface ListSkillsRequest {
|
|
2829
|
-
sessionId?: string;
|
|
2830
|
-
}
|
|
2831
|
-
interface SkillSummary {
|
|
2832
|
-
slug: string;
|
|
2833
|
-
name: string;
|
|
2834
|
-
description: string;
|
|
2835
|
-
source: string;
|
|
2836
|
-
icon?: string;
|
|
2837
|
-
globs?: string[];
|
|
2838
|
-
requiredSources?: string[];
|
|
2839
|
-
}
|
|
2840
|
-
interface ListSkillsResult {
|
|
2841
|
-
skills: SkillSummary[];
|
|
2842
|
-
}
|
|
2843
|
-
interface GetSkillRequest {
|
|
2844
|
-
sessionId?: string;
|
|
2845
|
-
skillSlug: string;
|
|
2846
|
-
}
|
|
2847
|
-
interface GetSkillResult {
|
|
2848
|
-
skill: SkillSummary & {
|
|
2849
|
-
content: string;
|
|
2850
|
-
alwaysAllow?: string[];
|
|
2851
|
-
};
|
|
2852
|
-
}
|
|
2853
|
-
interface CreateSkillRequest {
|
|
2854
|
-
sessionId?: string;
|
|
2855
|
-
slug: string;
|
|
2856
|
-
name: string;
|
|
2857
|
-
description: string;
|
|
2858
|
-
content: string;
|
|
2859
|
-
globs?: string[];
|
|
2860
|
-
alwaysAllow?: string[];
|
|
2861
|
-
icon?: string;
|
|
2862
|
-
requiredSources?: string[];
|
|
2863
|
-
}
|
|
2864
|
-
interface CreateSkillResult {
|
|
2865
|
-
ok: boolean;
|
|
2866
|
-
skill?: SkillSummary;
|
|
2867
|
-
reason?: string;
|
|
2868
|
-
}
|
|
2869
|
-
interface UpdateSkillRequest {
|
|
2870
|
-
sessionId?: string;
|
|
2871
|
-
skillSlug: string;
|
|
2872
|
-
name?: string;
|
|
2873
|
-
description?: string;
|
|
2874
|
-
content?: string;
|
|
2875
|
-
globs?: string[];
|
|
2876
|
-
alwaysAllow?: string[];
|
|
2877
|
-
icon?: string;
|
|
2878
|
-
requiredSources?: string[];
|
|
2879
|
-
}
|
|
2880
|
-
interface UpdateSkillResult {
|
|
2881
|
-
ok: boolean;
|
|
2882
|
-
skill?: SkillSummary;
|
|
2883
|
-
reason?: string;
|
|
2884
|
-
}
|
|
2885
|
-
interface DeleteSkillRequest {
|
|
2886
|
-
sessionId?: string;
|
|
2887
|
-
skillSlug: string;
|
|
2888
|
-
}
|
|
2889
|
-
interface DeleteSkillResult {
|
|
2890
|
-
ok: boolean;
|
|
2891
|
-
skillSlug: string;
|
|
2892
|
-
reason?: string;
|
|
2893
|
-
}
|
|
2894
|
-
interface GetAutomationsConfigRequest {
|
|
2895
|
-
sessionId?: string;
|
|
2896
|
-
}
|
|
2897
|
-
interface GetAutomationsConfigResult {
|
|
2898
|
-
config: Record<string, unknown> | null;
|
|
2899
|
-
configPath: string;
|
|
2900
|
-
}
|
|
2901
|
-
interface UpdateAutomationsConfigRequest {
|
|
2902
|
-
sessionId?: string;
|
|
2903
|
-
config: Record<string, unknown>;
|
|
2904
|
-
}
|
|
2905
|
-
interface UpdateAutomationsConfigResult {
|
|
2906
|
-
ok: boolean;
|
|
2907
|
-
automationCount?: number;
|
|
2908
|
-
errors?: string[];
|
|
2909
|
-
}
|
|
2910
|
-
interface ListSchedulesRequest {
|
|
2911
|
-
sessionId?: string;
|
|
2912
|
-
}
|
|
2913
|
-
interface ScheduleSummary {
|
|
2914
|
-
schedulerId: string;
|
|
2915
|
-
workspaceId: string;
|
|
2916
|
-
cron: string;
|
|
2917
|
-
timezone: string;
|
|
2918
|
-
}
|
|
2919
|
-
interface ListSchedulesResult {
|
|
2920
|
-
schedules: ScheduleSummary[];
|
|
2921
|
-
}
|
|
2922
|
-
interface StartScheduleRequest {
|
|
2923
|
-
sessionId?: string;
|
|
2924
|
-
schedulerId: string;
|
|
2925
|
-
workspaceId: string;
|
|
2926
|
-
cron: string;
|
|
2927
|
-
timezone: string;
|
|
2928
|
-
}
|
|
2929
|
-
interface StartScheduleResult {
|
|
2930
|
-
schedulerId: string;
|
|
2931
|
-
state: 'started' | 'stopped';
|
|
2932
|
-
timestamp: number;
|
|
2933
|
-
}
|
|
2934
|
-
interface StopScheduleRequest {
|
|
2935
|
-
sessionId?: string;
|
|
2936
|
-
schedulerId: string;
|
|
2937
|
-
}
|
|
2938
|
-
interface StopScheduleResult {
|
|
2939
|
-
ok: boolean;
|
|
2940
|
-
schedulerId: string;
|
|
2941
|
-
state?: 'stopped';
|
|
2942
|
-
reason?: string;
|
|
2943
|
-
}
|
|
2944
|
-
interface SessionToolBridge {
|
|
2945
|
-
submitPlan?(request: SubmitPlanRequest): Promise<SubmitPlanReceipt>;
|
|
2946
|
-
requestSourceAuth?(request: SourceAuthRequest): Promise<SourceAuthReceipt>;
|
|
2947
|
-
activateSource?(request: SourceActivationRequest): Promise<SourceActivationReceipt>;
|
|
2948
|
-
runBrowserAction?(request: BrowserActionRequest): Promise<BrowserActionReceipt>;
|
|
2949
|
-
spawnSession?(request: SpawnSessionRequest): Promise<SpawnSessionReceipt>;
|
|
2950
|
-
sendSessionMessage?(request: InterSessionMessageRequest): Promise<CommandReceipt>;
|
|
2951
|
-
updateSessionMetadata?(request: SessionMetadataPatch): Promise<SessionMetadataSnapshot>;
|
|
2952
|
-
listSessions?(request: SessionListRequest): Promise<SessionListResult>;
|
|
2953
|
-
queryLlm?(request: LlmToolRequest): Promise<LlmToolResult>;
|
|
2954
|
-
listSources?(request: ListSourcesRequest): Promise<ListSourcesResult>;
|
|
2955
|
-
getSource?(request: GetSourceRequest): Promise<GetSourceResult>;
|
|
2956
|
-
createSource?(request: CreateSourceRequest): Promise<CreateSourceResult>;
|
|
2957
|
-
updateSource?(request: UpdateSourceRequest): Promise<UpdateSourceResult>;
|
|
2958
|
-
deleteSource?(request: DeleteSourceRequest): Promise<DeleteSourceResult>;
|
|
2959
|
-
listSkills?(request: ListSkillsRequest): Promise<ListSkillsResult>;
|
|
2960
|
-
getSkill?(request: GetSkillRequest): Promise<GetSkillResult>;
|
|
2961
|
-
createSkill?(request: CreateSkillRequest): Promise<CreateSkillResult>;
|
|
2962
|
-
updateSkill?(request: UpdateSkillRequest): Promise<UpdateSkillResult>;
|
|
2963
|
-
deleteSkill?(request: DeleteSkillRequest): Promise<DeleteSkillResult>;
|
|
2964
|
-
getAutomationsConfig?(request: GetAutomationsConfigRequest): Promise<GetAutomationsConfigResult>;
|
|
2965
|
-
updateAutomationsConfig?(request: UpdateAutomationsConfigRequest): Promise<UpdateAutomationsConfigResult>;
|
|
2966
|
-
listSchedules?(request: ListSchedulesRequest): Promise<ListSchedulesResult>;
|
|
2967
|
-
startSchedule?(request: StartScheduleRequest): Promise<StartScheduleResult>;
|
|
2968
|
-
stopSchedule?(request: StopScheduleRequest): Promise<StopScheduleResult>;
|
|
2969
|
-
}
|
|
2970
|
-
type SessionToolName = keyof SessionToolBridge;
|
|
2971
|
-
type SessionToolRequest = SubmitPlanRequest | SourceAuthRequest | SourceActivationRequest | BrowserActionRequest | SpawnSessionRequest | InterSessionMessageRequest | SessionMetadataPatch | SessionListRequest | LlmToolRequest | ListSourcesRequest | GetSourceRequest | CreateSourceRequest | UpdateSourceRequest | DeleteSourceRequest | ListSkillsRequest | GetSkillRequest | CreateSkillRequest | UpdateSkillRequest | DeleteSkillRequest | GetAutomationsConfigRequest | UpdateAutomationsConfigRequest | ListSchedulesRequest | StartScheduleRequest | StopScheduleRequest;
|
|
2972
|
-
interface SessionToolTimelineRef {
|
|
2973
|
-
epoch: string;
|
|
2974
|
-
seq: number;
|
|
2975
|
-
}
|
|
2976
|
-
interface SessionToolInvocationReceipt {
|
|
2977
|
-
ok: boolean;
|
|
2978
|
-
requestId: string;
|
|
2979
|
-
toolName: SessionToolName;
|
|
2980
|
-
origin?: CommandOrigin;
|
|
2981
|
-
policyDecision: ToolPolicyDecision;
|
|
2982
|
-
result?: unknown;
|
|
2983
|
-
reason?: string;
|
|
2984
|
-
timelineRefs: SessionToolTimelineRef[];
|
|
2985
|
-
}
|
|
2986
|
-
interface InvokeSessionToolOptions {
|
|
2987
|
-
sessionId: string;
|
|
2988
|
-
toolName: SessionToolName;
|
|
2989
|
-
request: SessionToolRequest;
|
|
2990
|
-
bridge: SessionToolBridge;
|
|
2991
|
-
policy?: RuntimePolicyHook;
|
|
2992
|
-
commandOrigin?: CommandOrigin;
|
|
2993
|
-
appendTimeline?: (item: TimelineItem) => TimelineEnvelope;
|
|
2994
|
-
}
|
|
2995
|
-
interface RuntimeHostServices {
|
|
2996
|
-
sessionTools?: SessionToolBridge;
|
|
2997
|
-
}
|
|
2998
|
-
interface RuntimeExtensionContext {
|
|
2999
|
-
policy?: RuntimePolicyExtension;
|
|
3000
|
-
sources?: SourceSelection;
|
|
3001
|
-
skills?: SkillSelection;
|
|
3002
|
-
commandOrigin?: CommandOrigin;
|
|
3003
|
-
hostServices?: RuntimeHostServices;
|
|
3004
|
-
}
|
|
3005
|
-
interface AgentCommandSink {
|
|
3006
|
-
sendMessage(message: string, options?: SendMessageOptions): Promise<void>;
|
|
3007
|
-
abort(reason?: string): Promise<void>;
|
|
3008
|
-
respondToPermission(requestId: string, allowed: boolean, remember?: boolean): Promise<void>;
|
|
3009
|
-
resumeTool?(runId: string, resumeData: Record<string, unknown>): Promise<void>;
|
|
3010
|
-
dispose(): Promise<void>;
|
|
3011
|
-
}
|
|
3012
|
-
interface AgentEventStream {
|
|
3013
|
-
connect(onEvent: (event: AgentEvent) => void, onError?: (error: Error) => void, onClose?: () => void): void;
|
|
3014
|
-
disconnect(): void;
|
|
3015
|
-
isConnected(): boolean;
|
|
3016
|
-
}
|
|
3017
|
-
interface AgentTimelineStream {
|
|
3018
|
-
connect(onEvent: (event: TimelineEnvelope) => void, onError?: (error: Error) => void, onClose?: () => void): void;
|
|
3019
|
-
disconnect(): void;
|
|
3020
|
-
isConnected(): boolean;
|
|
3021
|
-
}
|
|
3022
|
-
interface AgentRuntimeState {
|
|
3023
|
-
status: AgentRuntimeStatus;
|
|
3024
|
-
acceptedMessages: string[];
|
|
3025
|
-
queuedMessages: string[];
|
|
3026
|
-
lastError?: string;
|
|
3027
|
-
waitingPermissionRequestId?: string;
|
|
3028
|
-
}
|
|
3029
|
-
type RuntimeAction = {
|
|
3030
|
-
type: 'preflight_start';
|
|
3031
|
-
} | {
|
|
3032
|
-
type: 'preflight_ok';
|
|
3033
|
-
} | {
|
|
3034
|
-
type: 'preflight_error';
|
|
3035
|
-
error: string;
|
|
3036
|
-
} | {
|
|
3037
|
-
type: 'starting';
|
|
3038
|
-
} | {
|
|
3039
|
-
type: 'send_message';
|
|
3040
|
-
message: string;
|
|
3041
|
-
} | {
|
|
3042
|
-
type: 'permission_request';
|
|
3043
|
-
requestId: string;
|
|
3044
|
-
} | {
|
|
3045
|
-
type: 'permission_response';
|
|
3046
|
-
} | {
|
|
3047
|
-
type: 'turn_completed';
|
|
3048
|
-
} | {
|
|
3049
|
-
type: 'complete';
|
|
3050
|
-
} | {
|
|
3051
|
-
type: 'abort';
|
|
3052
|
-
reason?: string;
|
|
3053
|
-
} | {
|
|
3054
|
-
type: 'error';
|
|
3055
|
-
error: string;
|
|
3056
|
-
} | {
|
|
3057
|
-
type: 'dispose';
|
|
3058
|
-
};
|
|
3059
|
-
declare const initialRuntimeState: AgentRuntimeState;
|
|
3060
|
-
/**
|
|
3061
|
-
* Canonical state machine reducer for AgentRuntime lifecycle.
|
|
3062
|
-
*
|
|
3063
|
-
* Transitions follow the architecture spec:
|
|
3064
|
-
* idle → preflighting → ready → starting → running
|
|
3065
|
-
* running → waiting_for_permission → running
|
|
3066
|
-
* running → turn_completed → ready
|
|
3067
|
-
* running → ready (via complete with empty queue)
|
|
3068
|
-
* any → failed / disposed
|
|
3069
|
-
* any non-disposed → ready (via abort)
|
|
3070
|
-
*
|
|
3071
|
-
* `send_message` while running enqueues (session manager semantics).
|
|
3072
|
-
* `complete` drains the queue: if a queued message exists, it is
|
|
3073
|
-
* immediately accepted and the state stays running.
|
|
3074
|
-
*/
|
|
3075
|
-
declare function reduceRuntimeState(state: AgentRuntimeState | undefined, action: RuntimeAction): AgentRuntimeState;
|
|
3076
|
-
interface AgentRuntime {
|
|
3077
|
-
readonly sessionId: string;
|
|
3078
|
-
readonly provider: string;
|
|
3079
|
-
readonly runtimeKind: AgentRuntimeKind;
|
|
3080
|
-
readonly events: AgentTimelineStream;
|
|
3081
|
-
readonly commands: AgentCommandSink;
|
|
3082
|
-
preflight(): Promise<RuntimeCapabilityReport>;
|
|
3083
|
-
fetchTimeline(request: TimelineFetchRequest): Promise<TimelineFetchResult>;
|
|
3084
|
-
getState(): AgentRuntimeState;
|
|
3085
|
-
}
|
|
3086
|
-
declare function createRuntimeExtensionContext(context?: RuntimeExtensionContext): RuntimeExtensionContext;
|
|
3087
|
-
declare function sanitizeProviderSourceTools(sourceTools: ProviderSourceToolDescriptor[] | undefined): ProviderSourceToolDescriptor[];
|
|
3088
|
-
declare function invokeSessionTool(options: InvokeSessionToolOptions): Promise<SessionToolInvocationReceipt>;
|
|
3089
|
-
declare function selectRuntimeCandidate(options: RuntimeSelectionOptions): RuntimeSelection;
|
|
3090
|
-
declare function createRuntimeCapabilityReport(options: CreateRuntimeCapabilityReportOptions): RuntimeCapabilityReport;
|
|
3091
|
-
|
|
3092
|
-
export { type AgentCommandSink, type AgentEventStream, type AgentRuntime, type AgentRuntimeKind, type AgentRuntimeOptions, type AgentRuntimeState, type AgentRuntimeStatus, type AgentTimelineStream, type BrowserActionReceipt, type BrowserActionRequest, type CodexPermissionParams, type CommandOrigin, type CommandReceipt, type CreateRuntimeCapabilityReportOptions, type CreateSkillRequest, type CreateSkillResult, type CreateSourceRequest, type CreateSourceResult, type DeleteSkillRequest, type DeleteSkillResult, type DeleteSourceRequest, type DeleteSourceResult, type GetAutomationsConfigRequest, type GetAutomationsConfigResult, type GetSkillRequest, type GetSkillResult, type GetSourceRequest, type GetSourceResult, type InterSessionMessageRequest, type InvokeSessionToolOptions, type ListSchedulesRequest, type ListSchedulesResult, type ListSkillsRequest, type ListSkillsResult, type ListSourcesRequest, type ListSourcesResult, type LlmToolRequest, type LlmToolResult, type ProviderAuthDetection, type ProviderAuthMode, type ProviderSourceCredentialRef, type ProviderSourceToolDescriptor, RUNTIME_KINDS, type RuntimeAction, type RuntimeAuthDetection, type RuntimeAutomationCapabilities, type RuntimeCandidate, type RuntimeCapabilityReport, type RuntimeExtensionCapabilities, type RuntimeExtensionContext, type RuntimeFeatureCapabilities, type RuntimeHostServices, type RuntimeHostToolCapabilities, type RuntimePermissionScope, type RuntimePermissionScopeInput, type RuntimePolicyCapabilities, type RuntimePolicyExtension, type RuntimePolicyHook, type RuntimeSelection, type RuntimeSelectionOptions, type RuntimeSkillCapabilities, type RuntimeSourceCapabilities, type RuntimeToolIntent, type ScheduleSummary, type SendMessageOptions, type SessionListRequest, type SessionListResult, type SessionMetadataPatch, type SessionMetadataSnapshot, type SessionToolBridge, type SessionToolInvocationReceipt, type SessionToolName, type SessionToolRequest, type SessionToolTimelineRef, type SkillSelection, type SkillSummary, type SourceActivationReceipt, type SourceActivationRequest, type SourceAuthReceipt, type SourceAuthRequest, type SourceSelection, type SourceSummary, type SpawnSessionReceipt, type SpawnSessionRequest, type StartScheduleRequest, type StartScheduleResult, type StopScheduleRequest, type StopScheduleResult, type SubmitPlanReceipt, type SubmitPlanRequest, type ToolPolicyDecision, type ToolPolicyRequest, type UpdateAutomationsConfigRequest, type UpdateAutomationsConfigResult, type UpdateSkillRequest, type UpdateSkillResult, type UpdateSourceRequest, type UpdateSourceResult, createRuntimeCapabilityReport, createRuntimeExtensionContext, initialRuntimeState, invokeSessionTool, mapCodexSandboxModeToSandboxPolicy, mapPermissionModeToCodexParams, reduceRuntimeState, sanitizeProviderSourceTools, selectRuntimeCandidate };
|
|
3093
|
-
|
|
3094
|
-
// ── inlined from @weft/automations ──
|
|
3095
|
-
// -- @weft/automations/index.d.ts --
|
|
3096
|
-
import { z } from 'zod';
|
|
3097
|
-
|
|
3098
|
-
/**
|
|
3099
|
-
* Automation System Type Definitions
|
|
3100
|
-
*
|
|
3101
|
-
* All types, interfaces, and type exports for the automations system.
|
|
3102
|
-
*/
|
|
3103
|
-
|
|
3104
|
-
/** App events - handled by the host runtime */
|
|
3105
|
-
type AppEvent = 'LabelAdd' | 'LabelRemove' | 'LabelConfigChange' | 'PermissionModeChange' | 'FlagChange' | 'SessionStatusChange' | 'SchedulerTick';
|
|
3106
|
-
/** Agent events - passed to Claude SDK */
|
|
3107
|
-
type AgentEvent = 'PreToolUse' | 'PostToolUse' | 'PostToolUseFailure' | 'Notification' | 'UserPromptSubmit' | 'SessionStart' | 'SessionEnd' | 'Stop' | 'SubagentStart' | 'SubagentStop' | 'PreCompact' | 'PermissionRequest' | 'Setup';
|
|
3108
|
-
type AutomationEvent = AppEvent | AgentEvent;
|
|
3109
|
-
declare const APP_EVENTS: AppEvent[];
|
|
3110
|
-
declare const AGENT_EVENTS: AgentEvent[];
|
|
3111
|
-
/** A prompt action - sends a prompt to the agent runtime */
|
|
3112
|
-
interface PromptAction {
|
|
3113
|
-
type: 'prompt';
|
|
3114
|
-
prompt: string;
|
|
3115
|
-
/** LLM connection slug for the created session (falls back to default if not found) */
|
|
3116
|
-
llmConnection?: string;
|
|
3117
|
-
/** Model ID for the created session (falls back to provider default if invalid) */
|
|
3118
|
-
model?: string;
|
|
3119
|
-
/**
|
|
3120
|
-
* Thinking level for the created session.
|
|
3121
|
-
* When omitted, falls back to the workspace default (then DEFAULT_THINKING_LEVEL).
|
|
3122
|
-
*/
|
|
3123
|
-
thinkingLevel?: ThinkingLevel;
|
|
3124
|
-
}
|
|
3125
|
-
/** HTTP method for webhook actions */
|
|
3126
|
-
type WebhookHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
3127
|
-
/** Body format for webhook actions */
|
|
3128
|
-
type WebhookBodyFormat = 'json' | 'form' | 'raw';
|
|
3129
|
-
/** Authentication shorthand for webhook actions */
|
|
3130
|
-
type WebhookAuth = {
|
|
3131
|
-
type: 'basic';
|
|
3132
|
-
username: string;
|
|
3133
|
-
password: string;
|
|
3134
|
-
} | {
|
|
3135
|
-
type: 'bearer';
|
|
3136
|
-
token: string;
|
|
3137
|
-
};
|
|
3138
|
-
/** A webhook action - sends an HTTP request to an endpoint */
|
|
3139
|
-
interface WebhookAction {
|
|
3140
|
-
type: 'webhook';
|
|
3141
|
-
/** The URL to send the webhook to (http or https) */
|
|
3142
|
-
url: string;
|
|
3143
|
-
/** HTTP method (default: POST) */
|
|
3144
|
-
method?: WebhookHttpMethod;
|
|
3145
|
-
/** HTTP headers as key-value pairs */
|
|
3146
|
-
headers?: Record<string, string>;
|
|
3147
|
-
/** Body format: 'json' sends Content-Type application/json, 'form' URL-encodes, 'raw' sends as-is */
|
|
3148
|
-
bodyFormat?: WebhookBodyFormat;
|
|
3149
|
-
/** Request body — JSON object when bodyFormat is 'json' or 'form', string when 'raw' */
|
|
3150
|
-
body?: unknown;
|
|
3151
|
-
/** Capture response body in result (truncated to 4KB). Default: false */
|
|
3152
|
-
captureResponse?: boolean;
|
|
3153
|
-
/** Authentication shorthand (applied before custom headers) */
|
|
3154
|
-
auth?: WebhookAuth;
|
|
3155
|
-
}
|
|
3156
|
-
type AutomationAction = PromptAction | WebhookAction;
|
|
3157
|
-
/** Time-of-day and day-of-week condition */
|
|
3158
|
-
interface TimeCondition {
|
|
3159
|
-
condition: 'time';
|
|
3160
|
-
/** Start time in 24h HH:MM format */
|
|
3161
|
-
after?: string;
|
|
3162
|
-
/** End time in 24h HH:MM format */
|
|
3163
|
-
before?: string;
|
|
3164
|
-
/** Days of week (3-letter lowercase: mon, tue, wed, thu, fri, sat, sun) */
|
|
3165
|
-
weekday?: string[];
|
|
3166
|
-
/** IANA timezone (falls back to matcher timezone, then system local) */
|
|
3167
|
-
timezone?: string;
|
|
3168
|
-
}
|
|
3169
|
-
/** State/field check condition with HA-style from/to for transitions */
|
|
3170
|
-
interface StateCondition {
|
|
3171
|
-
condition: 'state';
|
|
3172
|
-
/** Field name to check (e.g. 'permissionMode', 'sessionStatus', 'labels', 'isFlagged') */
|
|
3173
|
-
field: string;
|
|
3174
|
-
/** Exact value match */
|
|
3175
|
-
value?: unknown;
|
|
3176
|
-
/** Transition: previous value (mapped via TRANSITION_FIELDS) */
|
|
3177
|
-
from?: unknown;
|
|
3178
|
-
/** Transition: new value (mapped via TRANSITION_FIELDS) */
|
|
3179
|
-
to?: unknown;
|
|
3180
|
-
/** Array membership check */
|
|
3181
|
-
contains?: string;
|
|
3182
|
-
/** Negation: matches anything except this value */
|
|
3183
|
-
not_value?: unknown;
|
|
3184
|
-
}
|
|
3185
|
-
/** Logical composition condition (and/or/not) */
|
|
3186
|
-
interface LogicalCondition {
|
|
3187
|
-
condition: 'and' | 'or' | 'not';
|
|
3188
|
-
conditions: AutomationCondition[];
|
|
3189
|
-
}
|
|
3190
|
-
/** Union of all condition types */
|
|
3191
|
-
type AutomationCondition = TimeCondition | StateCondition | LogicalCondition;
|
|
3192
|
-
interface AutomationMatcher {
|
|
3193
|
-
/** Short 6-character hex ID for stable identification across config changes. */
|
|
3194
|
-
id?: string;
|
|
3195
|
-
/** Optional display name. If omitted, derived from the first action. */
|
|
3196
|
-
name?: string;
|
|
3197
|
-
/** Regex pattern for matching event data (not used for SchedulerTick) */
|
|
3198
|
-
matcher?: string;
|
|
3199
|
-
/** Cron expression for SchedulerTick events (5-field format) */
|
|
3200
|
-
cron?: string;
|
|
3201
|
-
/** IANA timezone for cron evaluation (e.g., "Europe/Budapest", "America/New_York") */
|
|
3202
|
-
timezone?: string;
|
|
3203
|
-
/** Permission mode for sessions created by prompt actions. */
|
|
3204
|
-
permissionMode?: PermissionMode;
|
|
3205
|
-
/** Labels to apply to sessions created by prompt actions */
|
|
3206
|
-
labels?: string[];
|
|
3207
|
-
/** Whether this automation matcher is enabled. Defaults to true. Set to false to disable without removing. */
|
|
3208
|
-
enabled?: boolean;
|
|
3209
|
-
/** Optional conditions that must all pass (AND) after matcher matches, before actions fire */
|
|
3210
|
-
conditions?: AutomationCondition[];
|
|
3211
|
-
/**
|
|
3212
|
-
* Optional Telegram forum-topic name. When set, sessions spawned by this
|
|
3213
|
-
* matcher are bound to a forum topic of this name in the workspace's paired
|
|
3214
|
-
* supergroup. The topic is created on first use and reused thereafter.
|
|
3215
|
-
* Multiple matchers using the same value share one topic.
|
|
3216
|
-
*
|
|
3217
|
-
* Silently ignored when:
|
|
3218
|
-
* - No supergroup is paired in Settings → Messaging → Telegram
|
|
3219
|
-
* - The Telegram bot is not connected
|
|
3220
|
-
* - The bot lacks "Manage Topics" permission in the supergroup
|
|
3221
|
-
*/
|
|
3222
|
-
telegramTopic?: string;
|
|
3223
|
-
actions: AutomationAction[];
|
|
3224
|
-
}
|
|
3225
|
-
interface AutomationsConfig {
|
|
3226
|
-
automations: Partial<Record<AutomationEvent, AutomationMatcher[]>>;
|
|
3227
|
-
}
|
|
3228
|
-
/** References parsed from a prompt (@name for sources and skills) */
|
|
3229
|
-
interface PromptReferences {
|
|
3230
|
-
/**
|
|
3231
|
-
* All @name references found in the prompt.
|
|
3232
|
-
* These could be sources (@linear, @github) or skills (@commit, @review-pr).
|
|
3233
|
-
* The caller should resolve which are sources vs skills based on available configurations.
|
|
3234
|
-
*/
|
|
3235
|
-
mentions: string[];
|
|
3236
|
-
}
|
|
3237
|
-
/** Result of a prompt action - returns the prompt to be executed by caller */
|
|
3238
|
-
interface PromptActionResult {
|
|
3239
|
-
type: 'prompt';
|
|
3240
|
-
prompt: string;
|
|
3241
|
-
/** The expanded prompt with environment variables substituted */
|
|
3242
|
-
expandedPrompt: string;
|
|
3243
|
-
/** References to sources and skills found in the prompt */
|
|
3244
|
-
references: PromptReferences;
|
|
3245
|
-
}
|
|
3246
|
-
/** Result of a webhook action */
|
|
3247
|
-
interface WebhookActionResult {
|
|
3248
|
-
type: 'webhook';
|
|
3249
|
-
/** The URL that was called */
|
|
3250
|
-
url: string;
|
|
3251
|
-
/** HTTP status code from the response */
|
|
3252
|
-
statusCode: number;
|
|
3253
|
-
/** Whether the request was successful (2xx status) */
|
|
3254
|
-
success: boolean;
|
|
3255
|
-
/** Error message if the request failed */
|
|
3256
|
-
error?: string;
|
|
3257
|
-
/** Number of attempts made (1 = no retry, 2+ = retried) */
|
|
3258
|
-
attempts?: number;
|
|
3259
|
-
/** Total duration including retries, in ms */
|
|
3260
|
-
durationMs?: number;
|
|
3261
|
-
/** Captured response body (only when captureResponse is true, truncated to 4KB) */
|
|
3262
|
-
responseBody?: string;
|
|
3263
|
-
}
|
|
3264
|
-
type ActionExecutionResult = PromptActionResult | WebhookActionResult;
|
|
3265
|
-
/** A pending prompt with its metadata */
|
|
3266
|
-
interface PendingPrompt {
|
|
3267
|
-
/** The session ID this prompt should be sent to */
|
|
3268
|
-
sessionId: string | undefined;
|
|
3269
|
-
/** The automation matcher ID this prompt originated from */
|
|
3270
|
-
matcherId?: string;
|
|
3271
|
-
/** Human-readable automation name (from matcher.name or derived fallback) */
|
|
3272
|
-
automationName?: string;
|
|
3273
|
-
/** The expanded prompt text */
|
|
3274
|
-
prompt: string;
|
|
3275
|
-
/**
|
|
3276
|
-
* All @mentions found in the prompt (sources and skills).
|
|
3277
|
-
* The caller should resolve which are sources vs skills based on available configurations.
|
|
3278
|
-
*/
|
|
3279
|
-
mentions: string[];
|
|
3280
|
-
/** Labels to apply to the created session */
|
|
3281
|
-
labels?: string[];
|
|
3282
|
-
/** Permission mode for the created session (from matcher config) */
|
|
3283
|
-
permissionMode?: PermissionMode;
|
|
3284
|
-
/** LLM connection slug for the created session (falls back to default if not found) */
|
|
3285
|
-
llmConnection?: string;
|
|
3286
|
-
/** Model ID for the created session (falls back to provider default if invalid) */
|
|
3287
|
-
model?: string;
|
|
3288
|
-
/** Thinking level for the created session (falls back to workspace default when omitted) */
|
|
3289
|
-
thinkingLevel?: ThinkingLevel;
|
|
3290
|
-
/** Forum-topic name to bind the new session to (Telegram supergroup, when paired). */
|
|
3291
|
-
telegramTopic?: string;
|
|
3292
|
-
}
|
|
3293
|
-
interface AutomationResult {
|
|
3294
|
-
event: string;
|
|
3295
|
-
matched: number;
|
|
3296
|
-
results: ActionExecutionResult[];
|
|
3297
|
-
/** Prompts that should be executed by the agent runtime (with metadata) */
|
|
3298
|
-
pendingPrompts: PendingPrompt[];
|
|
3299
|
-
}
|
|
3300
|
-
/** Internal validation result that includes the parsed config */
|
|
3301
|
-
type AutomationsValidationResult = {
|
|
3302
|
-
valid: boolean;
|
|
3303
|
-
errors: string[];
|
|
3304
|
-
config: AutomationsConfig | null;
|
|
3305
|
-
};
|
|
3306
|
-
/**
|
|
3307
|
-
* SDK automation input type - union of all possible SDK event inputs
|
|
3308
|
-
*/
|
|
3309
|
-
interface SdkAutomationInput {
|
|
3310
|
-
hook_event_name: string;
|
|
3311
|
-
tool_name?: string;
|
|
3312
|
-
tool_input?: Record<string, unknown>;
|
|
3313
|
-
tool_response?: string;
|
|
3314
|
-
tool_use_id?: string;
|
|
3315
|
-
source?: string;
|
|
3316
|
-
model?: string;
|
|
3317
|
-
agent_id?: string;
|
|
3318
|
-
agent_type?: string;
|
|
3319
|
-
prompt?: string;
|
|
3320
|
-
message?: string;
|
|
3321
|
-
title?: string;
|
|
3322
|
-
error?: string;
|
|
3323
|
-
}
|
|
3324
|
-
/**
|
|
3325
|
-
* SDK automation callback signature (matches Claude SDK HookCallback type)
|
|
3326
|
-
*/
|
|
3327
|
-
type SdkAutomationCallback = (input: SdkAutomationInput, toolUseId: string, options: {
|
|
3328
|
-
signal?: AbortSignal;
|
|
3329
|
-
}) => Promise<{
|
|
3330
|
-
continue: boolean;
|
|
3331
|
-
reason?: string;
|
|
3332
|
-
}>;
|
|
3333
|
-
/**
|
|
3334
|
-
* SDK automation matcher format (matches Claude SDK HookCallbackMatcher type)
|
|
3335
|
-
* Note: The `hooks` field name is kept as-is to match the Claude SDK interface.
|
|
3336
|
-
*/
|
|
3337
|
-
interface SdkAutomationCallbackMatcher {
|
|
3338
|
-
matcher?: string;
|
|
3339
|
-
timeout?: number;
|
|
3340
|
-
hooks: SdkAutomationCallback[];
|
|
3341
|
-
}
|
|
3342
|
-
/**
|
|
3343
|
-
* Lightweight session metadata for diffing.
|
|
3344
|
-
* Only includes fields that trigger automations.
|
|
3345
|
-
*/
|
|
3346
|
-
interface SessionMetadataSnapshot {
|
|
3347
|
-
permissionMode?: string;
|
|
3348
|
-
labels?: string[];
|
|
3349
|
-
isFlagged?: boolean;
|
|
3350
|
-
sessionStatus?: string;
|
|
3351
|
-
/** Session name (user-defined or auto-generated) */
|
|
3352
|
-
sessionName?: string;
|
|
3353
|
-
}
|
|
3354
|
-
|
|
3355
|
-
/**
|
|
3356
|
-
* Config Validators Stub
|
|
3357
|
-
*
|
|
3358
|
-
* Provides validation types used by automations.
|
|
3359
|
-
* Stubbed for OSS extraction — the real validators are in the main app.
|
|
3360
|
-
*/
|
|
3361
|
-
interface ValidationIssue {
|
|
3362
|
-
/** File being validated */
|
|
3363
|
-
file: string;
|
|
3364
|
-
/** Path to the issue within the config */
|
|
3365
|
-
path: string;
|
|
3366
|
-
/** Human-readable error/warning message */
|
|
3367
|
-
message: string;
|
|
3368
|
-
/** Issue severity */
|
|
3369
|
-
severity: 'error' | 'warning' | 'info';
|
|
3370
|
-
/** Optional suggestion for fixing the issue */
|
|
3371
|
-
suggestion?: string;
|
|
3372
|
-
}
|
|
3373
|
-
interface ValidationResult {
|
|
3374
|
-
/** Whether the config is valid (no errors) */
|
|
3375
|
-
valid: boolean;
|
|
3376
|
-
/** Error issues (blocking) */
|
|
3377
|
-
errors: ValidationIssue[];
|
|
3378
|
-
/** Warning issues (non-blocking) */
|
|
3379
|
-
warnings: ValidationIssue[];
|
|
3380
|
-
}
|
|
3381
|
-
|
|
3382
|
-
/**
|
|
3383
|
-
* Automation System Validation
|
|
3384
|
-
*
|
|
3385
|
-
* Validators for automations.json configuration files.
|
|
3386
|
-
* Used by PreToolUse automations and workspace validators.
|
|
3387
|
-
*/
|
|
3388
|
-
|
|
3389
|
-
interface AutomationsConfigDoctorReport extends ValidationResult {
|
|
3390
|
-
domain: 'automations';
|
|
3391
|
-
summary: {
|
|
3392
|
-
matcherCount: number;
|
|
3393
|
-
actionCount: number;
|
|
3394
|
-
};
|
|
3395
|
-
}
|
|
3396
|
-
/**
|
|
3397
|
-
* Validate automations config (internal - returns parsed config)
|
|
3398
|
-
*/
|
|
3399
|
-
declare function validateAutomationsConfig(content: unknown): AutomationsValidationResult;
|
|
3400
|
-
/**
|
|
3401
|
-
* Validate automations config from a JSON string (no disk reads).
|
|
3402
|
-
* Used by PreToolUse automation to validate before writing to disk.
|
|
3403
|
-
* Follows the same pattern as other config validators in validators.ts.
|
|
3404
|
-
*/
|
|
3405
|
-
declare function validateAutomationsContent(jsonString: string, fileName?: string): ValidationResult;
|
|
3406
|
-
declare function createAutomationsConfigDoctorReport(jsonString: string, fileName?: string): AutomationsConfigDoctorReport;
|
|
3407
|
-
/**
|
|
3408
|
-
* Validate automations.json from workspace path (reads from disk).
|
|
3409
|
-
* Follows the same pattern as other validators in validators.ts.
|
|
3410
|
-
*/
|
|
3411
|
-
declare function validateAutomations(workspaceRoot: string): ValidationResult;
|
|
3412
|
-
|
|
3413
|
-
/**
|
|
3414
|
-
* SDK Bridge - Environment variable building for Claude SDK automation integration
|
|
3415
|
-
*
|
|
3416
|
-
* Maps SDK automation input fields to WEFT_* environment variables for command execution.
|
|
3417
|
-
*/
|
|
3418
|
-
|
|
3419
|
-
/**
|
|
3420
|
-
* Build environment variables from SDK automation input.
|
|
3421
|
-
* Maps SDK input fields to WEFT_* environment variables.
|
|
3422
|
-
*/
|
|
3423
|
-
declare function buildEnvFromSdkInput(event: AgentEvent, input: SdkAutomationInput): Record<string, string>;
|
|
3424
|
-
|
|
3425
|
-
/**
|
|
3426
|
-
* WorkspaceEventBus - Typed Event Bus for Automations System
|
|
3427
|
-
*
|
|
3428
|
-
* Per-workspace event bus that enables loose coupling between:
|
|
3429
|
-
* - Event producers (ConfigWatcher, SchedulerService)
|
|
3430
|
-
* - Event consumers (CommandHandler, PromptHandler, EventLogHandler)
|
|
3431
|
-
*
|
|
3432
|
-
* Benefits over the current callback-based approach:
|
|
3433
|
-
* - No global state - each workspace has its own bus instance
|
|
3434
|
-
* - Type-safe events with payload validation
|
|
3435
|
-
* - Easy to add/remove handlers dynamically
|
|
3436
|
-
* - Testable in isolation
|
|
3437
|
-
*/
|
|
3438
|
-
|
|
3439
|
-
/** Base event payload with common fields */
|
|
3440
|
-
interface BaseEventPayload {
|
|
3441
|
-
sessionId?: string;
|
|
3442
|
-
sessionName?: string;
|
|
3443
|
-
workspaceId: string;
|
|
3444
|
-
timestamp: number;
|
|
3445
|
-
labels?: string[];
|
|
3446
|
-
}
|
|
3447
|
-
/** Label events payload */
|
|
3448
|
-
interface LabelEventPayload extends BaseEventPayload {
|
|
3449
|
-
label: string;
|
|
3450
|
-
}
|
|
3451
|
-
/** Permission mode change payload */
|
|
3452
|
-
interface PermissionModeChangePayload extends BaseEventPayload {
|
|
3453
|
-
oldMode: string;
|
|
3454
|
-
newMode: string;
|
|
3455
|
-
}
|
|
3456
|
-
/** Flag change payload */
|
|
3457
|
-
interface FlagChangePayload extends BaseEventPayload {
|
|
3458
|
-
isFlagged: boolean;
|
|
3459
|
-
}
|
|
3460
|
-
/** Session status change payload */
|
|
3461
|
-
interface SessionStatusChangePayload extends BaseEventPayload {
|
|
3462
|
-
oldState: string;
|
|
3463
|
-
newState: string;
|
|
3464
|
-
}
|
|
3465
|
-
/** Scheduler tick payload */
|
|
3466
|
-
interface SchedulerTickPayload extends BaseEventPayload {
|
|
3467
|
-
localTime: string;
|
|
3468
|
-
utcTime: string;
|
|
3469
|
-
}
|
|
3470
|
-
/** Label config change payload */
|
|
3471
|
-
interface LabelConfigChangePayload extends BaseEventPayload {
|
|
3472
|
-
}
|
|
3473
|
-
/** Generic event payload for agent events */
|
|
3474
|
-
interface GenericEventPayload extends BaseEventPayload {
|
|
3475
|
-
data: Record<string, unknown>;
|
|
3476
|
-
}
|
|
3477
|
-
/**
|
|
3478
|
-
* Maps event types to their payload types for type safety.
|
|
3479
|
-
*/
|
|
3480
|
-
interface EventPayloadMap {
|
|
3481
|
-
LabelAdd: LabelEventPayload;
|
|
3482
|
-
LabelRemove: LabelEventPayload;
|
|
3483
|
-
LabelConfigChange: LabelConfigChangePayload;
|
|
3484
|
-
PermissionModeChange: PermissionModeChangePayload;
|
|
3485
|
-
FlagChange: FlagChangePayload;
|
|
3486
|
-
SessionStatusChange: SessionStatusChangePayload;
|
|
3487
|
-
SchedulerTick: SchedulerTickPayload;
|
|
3488
|
-
PreToolUse: GenericEventPayload;
|
|
3489
|
-
PostToolUse: GenericEventPayload;
|
|
3490
|
-
PostToolUseFailure: GenericEventPayload;
|
|
3491
|
-
Notification: GenericEventPayload;
|
|
3492
|
-
UserPromptSubmit: GenericEventPayload;
|
|
3493
|
-
SessionStart: GenericEventPayload;
|
|
3494
|
-
SessionEnd: GenericEventPayload;
|
|
3495
|
-
Stop: GenericEventPayload;
|
|
3496
|
-
SubagentStart: GenericEventPayload;
|
|
3497
|
-
SubagentStop: GenericEventPayload;
|
|
3498
|
-
PreCompact: GenericEventPayload;
|
|
3499
|
-
PermissionRequest: GenericEventPayload;
|
|
3500
|
-
Setup: GenericEventPayload;
|
|
3501
|
-
}
|
|
3502
|
-
type EventHandler<T extends AutomationEvent> = (payload: EventPayloadMap[T]) => void | Promise<void>;
|
|
3503
|
-
type AnyEventHandler = (event: AutomationEvent, payload: BaseEventPayload) => void | Promise<void>;
|
|
3504
|
-
interface EventBus {
|
|
3505
|
-
/** Emit an event to all registered handlers */
|
|
3506
|
-
emit<T extends AutomationEvent>(event: T, payload: EventPayloadMap[T]): Promise<void>;
|
|
3507
|
-
/** Register a handler for a specific event type */
|
|
3508
|
-
on<T extends AutomationEvent>(event: T, handler: EventHandler<T>): void;
|
|
3509
|
-
/** Unregister a handler for a specific event type */
|
|
3510
|
-
off<T extends AutomationEvent>(event: T, handler: EventHandler<T>): void;
|
|
3511
|
-
/** Register a handler for all events (useful for logging) */
|
|
3512
|
-
onAny(handler: AnyEventHandler): void;
|
|
3513
|
-
/** Unregister an all-events handler */
|
|
3514
|
-
offAny(handler: AnyEventHandler): void;
|
|
3515
|
-
/** Clean up all handlers */
|
|
3516
|
-
dispose(): void;
|
|
3517
|
-
}
|
|
3518
|
-
declare class WorkspaceEventBus implements EventBus {
|
|
3519
|
-
private readonly workspaceId;
|
|
3520
|
-
private readonly handlers;
|
|
3521
|
-
private readonly anyHandlers;
|
|
3522
|
-
private readonly rateCounts;
|
|
3523
|
-
private disposed;
|
|
3524
|
-
constructor(workspaceId: string);
|
|
3525
|
-
/**
|
|
3526
|
-
* Emit an event to all registered handlers.
|
|
3527
|
-
* Handlers are called in parallel, errors are caught and logged.
|
|
3528
|
-
*/
|
|
3529
|
-
emit<T extends AutomationEvent>(event: T, payload: EventPayloadMap[T]): Promise<void>;
|
|
3530
|
-
/**
|
|
3531
|
-
* Register a handler for a specific event type.
|
|
3532
|
-
*/
|
|
3533
|
-
on<T extends AutomationEvent>(event: T, handler: EventHandler<T>): void;
|
|
3534
|
-
/**
|
|
3535
|
-
* Unregister a handler for a specific event type.
|
|
3536
|
-
*/
|
|
3537
|
-
off<T extends AutomationEvent>(event: T, handler: EventHandler<T>): void;
|
|
3538
|
-
/**
|
|
3539
|
-
* Register a handler for all events.
|
|
3540
|
-
* Useful for logging, metrics, or debugging.
|
|
3541
|
-
*/
|
|
3542
|
-
onAny(handler: AnyEventHandler): void;
|
|
3543
|
-
/**
|
|
3544
|
-
* Unregister an all-events handler.
|
|
3545
|
-
*/
|
|
3546
|
-
offAny(handler: AnyEventHandler): void;
|
|
3547
|
-
/**
|
|
3548
|
-
* Clean up all handlers and mark as disposed.
|
|
3549
|
-
*/
|
|
3550
|
-
dispose(): void;
|
|
3551
|
-
/**
|
|
3552
|
-
* Check if the bus has been disposed.
|
|
3553
|
-
*/
|
|
3554
|
-
isDisposed(): boolean;
|
|
3555
|
-
/**
|
|
3556
|
-
* Get the workspace ID this bus belongs to.
|
|
3557
|
-
*/
|
|
3558
|
-
getWorkspaceId(): string;
|
|
3559
|
-
/**
|
|
3560
|
-
* Get handler count for debugging.
|
|
3561
|
-
*/
|
|
3562
|
-
getHandlerCount(event?: AutomationEvent): number;
|
|
3563
|
-
}
|
|
3564
|
-
|
|
3565
|
-
/**
|
|
3566
|
-
* Shared Utilities for Automations System
|
|
3567
|
-
*
|
|
3568
|
-
* Common helper functions used by both the legacy functional API (index.ts)
|
|
3569
|
-
* and the new Event Bus handlers (command-handler.ts, prompt-handler.ts).
|
|
3570
|
-
*/
|
|
3571
|
-
|
|
3572
|
-
/**
|
|
3573
|
-
* Parse @mentions from a prompt (sources and skills both use @name syntax).
|
|
3574
|
-
*
|
|
3575
|
-
* Syntax:
|
|
3576
|
-
* - @name - references a source or skill (e.g., @linear, @github, @commit, @review-pr)
|
|
3577
|
-
*
|
|
3578
|
-
* References are case-insensitive and support hyphens (e.g., @my-source, @my-skill).
|
|
3579
|
-
* The caller should resolve which mentions are sources vs skills based on available configurations.
|
|
3580
|
-
*/
|
|
3581
|
-
declare function parsePromptReferences(prompt: string): PromptReferences;
|
|
3582
|
-
|
|
3583
|
-
interface AutomationRuntimeGuard {
|
|
3584
|
-
shouldDispatch(key: AutomationDispatchKey): boolean;
|
|
3585
|
-
remember(key: AutomationDispatchKey): void;
|
|
3586
|
-
}
|
|
3587
|
-
interface AutomationDispatchKey {
|
|
3588
|
-
runtimeSessionId: string;
|
|
3589
|
-
automationId: string;
|
|
3590
|
-
prompt: string;
|
|
3591
|
-
}
|
|
3592
|
-
interface ExecuteAutomationPromptOptions {
|
|
3593
|
-
runtime: AgentRuntime;
|
|
3594
|
-
prompt: PendingPrompt;
|
|
3595
|
-
guard?: AutomationRuntimeGuard;
|
|
3596
|
-
}
|
|
3597
|
-
interface ExecuteAutomationPromptResult {
|
|
3598
|
-
skipped: boolean;
|
|
3599
|
-
timelineItems: TimelineItem[];
|
|
3600
|
-
}
|
|
3601
|
-
declare function createAutomationRuntimeGuard(): AutomationRuntimeGuard;
|
|
3602
|
-
declare function executeAutomationPrompt(options: ExecuteAutomationPromptOptions): Promise<ExecuteAutomationPromptResult>;
|
|
3603
|
-
|
|
3604
|
-
type AutomationInputEventSource = 'timeline' | 'host' | 'policy' | 'source' | 'skill';
|
|
3605
|
-
interface AutomationInputEvent {
|
|
3606
|
-
event: string;
|
|
3607
|
-
source: AutomationInputEventSource;
|
|
3608
|
-
sessionId: string;
|
|
3609
|
-
matchValue?: string;
|
|
3610
|
-
payload: unknown;
|
|
3611
|
-
timestamp: number;
|
|
3612
|
-
}
|
|
3613
|
-
interface AutomationTimelineBridge {
|
|
3614
|
-
handleTimelineEnvelope(envelope: TimelineEnvelope): void;
|
|
3615
|
-
}
|
|
3616
|
-
interface CreateAutomationTimelineBridgeOptions {
|
|
3617
|
-
publish(event: AutomationInputEvent): void;
|
|
3618
|
-
}
|
|
3619
|
-
declare function createAutomationTimelineBridge(options: CreateAutomationTimelineBridgeOptions): AutomationTimelineBridge;
|
|
3620
|
-
declare function projectTimelineEnvelopeToAutomationInput(envelope: TimelineEnvelope): AutomationInputEvent[];
|
|
3621
|
-
|
|
3622
|
-
type AutomationHistoryActionType = 'prompt' | 'webhook' | 'scheduler' | 'metadata';
|
|
3623
|
-
type AutomationHistoryStatus = 'success' | 'failed' | 'skipped';
|
|
3624
|
-
interface AutomationHistoryRecordInput {
|
|
3625
|
-
matcherId: string;
|
|
3626
|
-
automationName?: string;
|
|
3627
|
-
sessionId?: string;
|
|
3628
|
-
actionType: AutomationHistoryActionType;
|
|
3629
|
-
status: AutomationHistoryStatus;
|
|
3630
|
-
skipped?: boolean;
|
|
3631
|
-
attempt?: number;
|
|
3632
|
-
promptPreview?: string;
|
|
3633
|
-
error?: string;
|
|
3634
|
-
timelineItemCount?: number;
|
|
3635
|
-
metadata?: Record<string, unknown>;
|
|
3636
|
-
}
|
|
3637
|
-
interface AutomationHistoryRecord extends AutomationHistoryRecordInput {
|
|
3638
|
-
recordId: string;
|
|
3639
|
-
attempt: number;
|
|
3640
|
-
timestamp: number;
|
|
3641
|
-
}
|
|
3642
|
-
interface AutomationHistoryListFilter {
|
|
3643
|
-
matcherId?: string;
|
|
3644
|
-
sessionId?: string;
|
|
3645
|
-
status?: AutomationHistoryStatus;
|
|
3646
|
-
limit?: number;
|
|
3647
|
-
}
|
|
3648
|
-
interface AutomationHistoryStore {
|
|
3649
|
-
record(input: AutomationHistoryRecordInput): Promise<AutomationHistoryRecord>;
|
|
3650
|
-
list(filter?: AutomationHistoryListFilter): Promise<AutomationHistoryRecord[]>;
|
|
3651
|
-
getLastExecuted(matcherId: string): Promise<AutomationHistoryRecord | undefined>;
|
|
3652
|
-
getSnapshot(): {
|
|
3653
|
-
records: AutomationHistoryRecord[];
|
|
3654
|
-
};
|
|
3655
|
-
}
|
|
3656
|
-
interface InMemoryAutomationHistoryStoreOptions {
|
|
3657
|
-
now?: () => number;
|
|
3658
|
-
maxEntries?: number;
|
|
3659
|
-
}
|
|
3660
|
-
declare function createInMemoryAutomationHistoryStore(options?: InMemoryAutomationHistoryStoreOptions): AutomationHistoryStore;
|
|
3661
|
-
declare function automationHistoryInputForPromptResult(prompt: PendingPrompt, result: ExecuteAutomationPromptResult): AutomationHistoryRecordInput;
|
|
3662
|
-
interface AutomationScheduleRegistration {
|
|
3663
|
-
schedulerId: string;
|
|
3664
|
-
workspaceId: string;
|
|
3665
|
-
cron: string;
|
|
3666
|
-
timezone: string;
|
|
3667
|
-
}
|
|
3668
|
-
interface AutomationSchedulerLifecycleReceipt extends AutomationScheduleRegistration {
|
|
3669
|
-
state: 'started' | 'stopped';
|
|
3670
|
-
timestamp: number;
|
|
3671
|
-
}
|
|
3672
|
-
interface AutomationSchedulerTickOptions {
|
|
3673
|
-
reason?: string;
|
|
3674
|
-
}
|
|
3675
|
-
interface AutomationSchedulerHost {
|
|
3676
|
-
start(input: AutomationScheduleRegistration): AutomationSchedulerLifecycleReceipt;
|
|
3677
|
-
stop(schedulerId: string): AutomationSchedulerLifecycleReceipt | undefined;
|
|
3678
|
-
tick(schedulerId: string, options?: AutomationSchedulerTickOptions): boolean;
|
|
3679
|
-
getSnapshot(): {
|
|
3680
|
-
schedules: AutomationScheduleRegistration[];
|
|
3681
|
-
};
|
|
3682
|
-
}
|
|
3683
|
-
interface AutomationSchedulerHostOptions {
|
|
3684
|
-
now?: () => number;
|
|
3685
|
-
publish(event: AutomationInputEvent): void | Promise<void>;
|
|
3686
|
-
}
|
|
3687
|
-
declare function createAutomationSchedulerHost(options: AutomationSchedulerHostOptions): AutomationSchedulerHost;
|
|
3688
|
-
|
|
3689
|
-
interface RuntimeAutomationBridge {
|
|
3690
|
-
handlePromptsReady(prompts: PendingPrompt[]): Promise<ExecuteAutomationPromptResult[]>;
|
|
3691
|
-
dispose(): void;
|
|
3692
|
-
}
|
|
3693
|
-
interface CreateRuntimeAutomationBridgeOptions {
|
|
3694
|
-
runtime: AgentRuntime;
|
|
3695
|
-
publish(event: AutomationInputEvent): void | Promise<void>;
|
|
3696
|
-
emitTimelineItem?: (item: TimelineItem) => void | Promise<void>;
|
|
3697
|
-
historyStore?: AutomationHistoryStore;
|
|
3698
|
-
guard?: AutomationRuntimeGuard;
|
|
3699
|
-
onError?: (error: Error) => void;
|
|
3700
|
-
}
|
|
3701
|
-
declare function createRuntimeAutomationBridge(options: CreateRuntimeAutomationBridgeOptions): RuntimeAutomationBridge;
|
|
3702
|
-
|
|
3703
|
-
/**
|
|
3704
|
-
* Automation Event Logger Stub
|
|
3705
|
-
*
|
|
3706
|
-
* Provides event logging interface for automations.
|
|
3707
|
-
* Stubbed for OSS extraction — the real logger writes to JSONL files.
|
|
3708
|
-
*/
|
|
3709
|
-
interface LoggedAutomationEvent {
|
|
3710
|
-
timestamp: number;
|
|
3711
|
-
/** Event type (renamed from 'type' to match LoggedAutomationEventInput) */
|
|
3712
|
-
event: string;
|
|
3713
|
-
workspaceId: string;
|
|
3714
|
-
sessionId?: string;
|
|
3715
|
-
data?: Record<string, unknown>;
|
|
3716
|
-
}
|
|
3717
|
-
interface LoggedAutomationEventInput {
|
|
3718
|
-
/** Event name */
|
|
3719
|
-
event: string;
|
|
3720
|
-
workspaceId: string;
|
|
3721
|
-
sessionId?: string;
|
|
3722
|
-
data?: Record<string, unknown>;
|
|
3723
|
-
}
|
|
3724
|
-
/**
|
|
3725
|
-
* Automation Event Logger — stub implementation.
|
|
3726
|
-
* The real logger persists events to workspace-scoped JSONL files.
|
|
3727
|
-
*/
|
|
3728
|
-
declare class AutomationEventLogger {
|
|
3729
|
-
/** Callback when an event is lost due to buffer overflow */
|
|
3730
|
-
onEventLost: ((event: LoggedAutomationEvent) => void) | null;
|
|
3731
|
-
constructor(_workspaceRootPath?: string);
|
|
3732
|
-
/**
|
|
3733
|
-
* Log an automation event.
|
|
3734
|
-
* Stub: no persistence in OSS package.
|
|
3735
|
-
*/
|
|
3736
|
-
log(input: LoggedAutomationEventInput): void;
|
|
3737
|
-
/**
|
|
3738
|
-
* Get the path to the event log file.
|
|
3739
|
-
* Stub: returns empty string.
|
|
3740
|
-
*/
|
|
3741
|
-
getLogPath(): string;
|
|
3742
|
-
/**
|
|
3743
|
-
* Dispose the logger, flushing buffered events.
|
|
3744
|
-
* Stub: no-op.
|
|
3745
|
-
*/
|
|
3746
|
-
dispose(): Promise<void>;
|
|
3747
|
-
}
|
|
3748
|
-
|
|
3749
|
-
/**
|
|
3750
|
-
* Automations Schema Definitions
|
|
3751
|
-
*
|
|
3752
|
-
* Zod schemas for validating automations.json configuration.
|
|
3753
|
-
* Extracted from index.ts for better separation of concerns.
|
|
3754
|
-
*/
|
|
3755
|
-
|
|
3756
|
-
declare const TimeConditionSchema: z.ZodObject<{
|
|
3757
|
-
condition: z.ZodLiteral<"time">;
|
|
3758
|
-
after: z.ZodOptional<z.ZodString>;
|
|
3759
|
-
before: z.ZodOptional<z.ZodString>;
|
|
3760
|
-
weekday: z.ZodOptional<z.ZodArray<z.ZodEnum<["mon", "tue", "wed", "thu", "fri", "sat", "sun"]>, "many">>;
|
|
3761
|
-
timezone: z.ZodOptional<z.ZodString>;
|
|
3762
|
-
}, "strip", z.ZodTypeAny, {
|
|
3763
|
-
condition: "time";
|
|
3764
|
-
after?: string | undefined;
|
|
3765
|
-
before?: string | undefined;
|
|
3766
|
-
weekday?: ("mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun")[] | undefined;
|
|
3767
|
-
timezone?: string | undefined;
|
|
3768
|
-
}, {
|
|
3769
|
-
condition: "time";
|
|
3770
|
-
after?: string | undefined;
|
|
3771
|
-
before?: string | undefined;
|
|
3772
|
-
weekday?: ("mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun")[] | undefined;
|
|
3773
|
-
timezone?: string | undefined;
|
|
3774
|
-
}>;
|
|
3775
|
-
declare const StateConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
3776
|
-
condition: z.ZodLiteral<"state">;
|
|
3777
|
-
field: z.ZodString;
|
|
3778
|
-
value: z.ZodOptional<z.ZodUnknown>;
|
|
3779
|
-
from: z.ZodOptional<z.ZodUnknown>;
|
|
3780
|
-
to: z.ZodOptional<z.ZodUnknown>;
|
|
3781
|
-
contains: z.ZodOptional<z.ZodString>;
|
|
3782
|
-
not_value: z.ZodOptional<z.ZodUnknown>;
|
|
3783
|
-
}, "strip", z.ZodTypeAny, {
|
|
3784
|
-
condition: "state";
|
|
3785
|
-
field: string;
|
|
3786
|
-
value?: unknown;
|
|
3787
|
-
from?: unknown;
|
|
3788
|
-
to?: unknown;
|
|
3789
|
-
contains?: string | undefined;
|
|
3790
|
-
not_value?: unknown;
|
|
3791
|
-
}, {
|
|
3792
|
-
condition: "state";
|
|
3793
|
-
field: string;
|
|
3794
|
-
value?: unknown;
|
|
3795
|
-
from?: unknown;
|
|
3796
|
-
to?: unknown;
|
|
3797
|
-
contains?: string | undefined;
|
|
3798
|
-
not_value?: unknown;
|
|
3799
|
-
}>, {
|
|
3800
|
-
condition: "state";
|
|
3801
|
-
field: string;
|
|
3802
|
-
value?: unknown;
|
|
3803
|
-
from?: unknown;
|
|
3804
|
-
to?: unknown;
|
|
3805
|
-
contains?: string | undefined;
|
|
3806
|
-
not_value?: unknown;
|
|
3807
|
-
}, {
|
|
3808
|
-
condition: "state";
|
|
3809
|
-
field: string;
|
|
3810
|
-
value?: unknown;
|
|
3811
|
-
from?: unknown;
|
|
3812
|
-
to?: unknown;
|
|
3813
|
-
contains?: string | undefined;
|
|
3814
|
-
not_value?: unknown;
|
|
3815
|
-
}>;
|
|
3816
|
-
declare const AutomationConditionSchema: z.ZodType;
|
|
3817
|
-
/** All valid event names: canonical events + deprecated aliases. Derived from types.ts. */
|
|
3818
|
-
declare const VALID_EVENTS: readonly string[];
|
|
3819
|
-
declare const AutomationsConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
3820
|
-
version: z.ZodOptional<z.ZodNumber>;
|
|
3821
|
-
automations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
3822
|
-
id: z.ZodOptional<z.ZodString>;
|
|
3823
|
-
name: z.ZodOptional<z.ZodString>;
|
|
3824
|
-
matcher: z.ZodOptional<z.ZodString>;
|
|
3825
|
-
cron: z.ZodOptional<z.ZodString>;
|
|
3826
|
-
timezone: z.ZodOptional<z.ZodString>;
|
|
3827
|
-
permissionMode: z.ZodOptional<z.ZodEnum<["safe", "ask", "allow-all"]>>;
|
|
3828
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3829
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
3830
|
-
conditions: z.ZodOptional<z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">>;
|
|
3831
|
-
telegramTopic: z.ZodOptional<z.ZodString>;
|
|
3832
|
-
actions: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
3833
|
-
type: z.ZodLiteral<"prompt">;
|
|
3834
|
-
prompt: z.ZodString;
|
|
3835
|
-
llmConnection: z.ZodOptional<z.ZodString>;
|
|
3836
|
-
model: z.ZodOptional<z.ZodString>;
|
|
3837
|
-
thinkingLevel: z.ZodOptional<z.ZodEffects<z.ZodEnum<[string, ...string[]]>, "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined, string>>;
|
|
3838
|
-
}, "strip", z.ZodTypeAny, {
|
|
3839
|
-
prompt: string;
|
|
3840
|
-
type: "prompt";
|
|
3841
|
-
llmConnection?: string | undefined;
|
|
3842
|
-
model?: string | undefined;
|
|
3843
|
-
thinkingLevel?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
|
|
3844
|
-
}, {
|
|
3845
|
-
prompt: string;
|
|
3846
|
-
type: "prompt";
|
|
3847
|
-
llmConnection?: string | undefined;
|
|
3848
|
-
model?: string | undefined;
|
|
3849
|
-
thinkingLevel?: string | undefined;
|
|
3850
|
-
}>, z.ZodObject<{
|
|
3851
|
-
type: z.ZodLiteral<"webhook">;
|
|
3852
|
-
url: z.ZodEffects<z.ZodString, string, string>;
|
|
3853
|
-
method: z.ZodOptional<z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE"]>>;
|
|
3854
|
-
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
3855
|
-
bodyFormat: z.ZodOptional<z.ZodEnum<["json", "form", "raw"]>>;
|
|
3856
|
-
body: z.ZodOptional<z.ZodUnknown>;
|
|
3857
|
-
captureResponse: z.ZodOptional<z.ZodBoolean>;
|
|
3858
|
-
auth: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
3859
|
-
type: z.ZodLiteral<"basic">;
|
|
3860
|
-
username: z.ZodString;
|
|
3861
|
-
password: z.ZodString;
|
|
3862
|
-
}, "strip", z.ZodTypeAny, {
|
|
3863
|
-
type: "basic";
|
|
3864
|
-
username: string;
|
|
3865
|
-
password: string;
|
|
3866
|
-
}, {
|
|
3867
|
-
type: "basic";
|
|
3868
|
-
username: string;
|
|
3869
|
-
password: string;
|
|
3870
|
-
}>, z.ZodObject<{
|
|
3871
|
-
type: z.ZodLiteral<"bearer">;
|
|
3872
|
-
token: z.ZodString;
|
|
3873
|
-
}, "strip", z.ZodTypeAny, {
|
|
3874
|
-
type: "bearer";
|
|
3875
|
-
token: string;
|
|
3876
|
-
}, {
|
|
3877
|
-
type: "bearer";
|
|
3878
|
-
token: string;
|
|
3879
|
-
}>]>>;
|
|
3880
|
-
}, "strip", z.ZodTypeAny, {
|
|
3881
|
-
type: "webhook";
|
|
3882
|
-
url: string;
|
|
3883
|
-
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
3884
|
-
headers?: Record<string, string> | undefined;
|
|
3885
|
-
bodyFormat?: "json" | "form" | "raw" | undefined;
|
|
3886
|
-
body?: unknown;
|
|
3887
|
-
captureResponse?: boolean | undefined;
|
|
3888
|
-
auth?: {
|
|
3889
|
-
type: "basic";
|
|
3890
|
-
username: string;
|
|
3891
|
-
password: string;
|
|
3892
|
-
} | {
|
|
3893
|
-
type: "bearer";
|
|
3894
|
-
token: string;
|
|
3895
|
-
} | undefined;
|
|
3896
|
-
}, {
|
|
3897
|
-
type: "webhook";
|
|
3898
|
-
url: string;
|
|
3899
|
-
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
3900
|
-
headers?: Record<string, string> | undefined;
|
|
3901
|
-
bodyFormat?: "json" | "form" | "raw" | undefined;
|
|
3902
|
-
body?: unknown;
|
|
3903
|
-
captureResponse?: boolean | undefined;
|
|
3904
|
-
auth?: {
|
|
3905
|
-
type: "basic";
|
|
3906
|
-
username: string;
|
|
3907
|
-
password: string;
|
|
3908
|
-
} | {
|
|
3909
|
-
type: "bearer";
|
|
3910
|
-
token: string;
|
|
3911
|
-
} | undefined;
|
|
3912
|
-
}>, z.ZodObject<{
|
|
3913
|
-
type: z.ZodString;
|
|
3914
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
3915
|
-
type: z.ZodString;
|
|
3916
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
3917
|
-
type: z.ZodString;
|
|
3918
|
-
}, z.ZodTypeAny, "passthrough">>]>, "many">;
|
|
3919
|
-
}, "strip", z.ZodTypeAny, {
|
|
3920
|
-
actions: ({
|
|
3921
|
-
prompt: string;
|
|
3922
|
-
type: "prompt";
|
|
3923
|
-
llmConnection?: string | undefined;
|
|
3924
|
-
model?: string | undefined;
|
|
3925
|
-
thinkingLevel?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
|
|
3926
|
-
} | {
|
|
3927
|
-
type: "webhook";
|
|
3928
|
-
url: string;
|
|
3929
|
-
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
3930
|
-
headers?: Record<string, string> | undefined;
|
|
3931
|
-
bodyFormat?: "json" | "form" | "raw" | undefined;
|
|
3932
|
-
body?: unknown;
|
|
3933
|
-
captureResponse?: boolean | undefined;
|
|
3934
|
-
auth?: {
|
|
3935
|
-
type: "basic";
|
|
3936
|
-
username: string;
|
|
3937
|
-
password: string;
|
|
3938
|
-
} | {
|
|
3939
|
-
type: "bearer";
|
|
3940
|
-
token: string;
|
|
3941
|
-
} | undefined;
|
|
3942
|
-
} | z.objectOutputType<{
|
|
3943
|
-
type: z.ZodString;
|
|
3944
|
-
}, z.ZodTypeAny, "passthrough">)[];
|
|
3945
|
-
timezone?: string | undefined;
|
|
3946
|
-
conditions?: any[] | undefined;
|
|
3947
|
-
id?: string | undefined;
|
|
3948
|
-
name?: string | undefined;
|
|
3949
|
-
matcher?: string | undefined;
|
|
3950
|
-
cron?: string | undefined;
|
|
3951
|
-
permissionMode?: "safe" | "ask" | "allow-all" | undefined;
|
|
3952
|
-
labels?: string[] | undefined;
|
|
3953
|
-
enabled?: boolean | undefined;
|
|
3954
|
-
telegramTopic?: string | undefined;
|
|
3955
|
-
}, {
|
|
3956
|
-
actions: ({
|
|
3957
|
-
prompt: string;
|
|
3958
|
-
type: "prompt";
|
|
3959
|
-
llmConnection?: string | undefined;
|
|
3960
|
-
model?: string | undefined;
|
|
3961
|
-
thinkingLevel?: string | undefined;
|
|
3962
|
-
} | {
|
|
3963
|
-
type: "webhook";
|
|
3964
|
-
url: string;
|
|
3965
|
-
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
3966
|
-
headers?: Record<string, string> | undefined;
|
|
3967
|
-
bodyFormat?: "json" | "form" | "raw" | undefined;
|
|
3968
|
-
body?: unknown;
|
|
3969
|
-
captureResponse?: boolean | undefined;
|
|
3970
|
-
auth?: {
|
|
3971
|
-
type: "basic";
|
|
3972
|
-
username: string;
|
|
3973
|
-
password: string;
|
|
3974
|
-
} | {
|
|
3975
|
-
type: "bearer";
|
|
3976
|
-
token: string;
|
|
3977
|
-
} | undefined;
|
|
3978
|
-
} | z.objectInputType<{
|
|
3979
|
-
type: z.ZodString;
|
|
3980
|
-
}, z.ZodTypeAny, "passthrough">)[];
|
|
3981
|
-
timezone?: string | undefined;
|
|
3982
|
-
conditions?: any[] | undefined;
|
|
3983
|
-
id?: string | undefined;
|
|
3984
|
-
name?: string | undefined;
|
|
3985
|
-
matcher?: string | undefined;
|
|
3986
|
-
cron?: string | undefined;
|
|
3987
|
-
permissionMode?: "safe" | "ask" | "allow-all" | undefined;
|
|
3988
|
-
labels?: string[] | undefined;
|
|
3989
|
-
enabled?: boolean | undefined;
|
|
3990
|
-
telegramTopic?: string | undefined;
|
|
3991
|
-
}>, "many">>>;
|
|
3992
|
-
}, "strip", z.ZodTypeAny, {
|
|
3993
|
-
version?: number | undefined;
|
|
3994
|
-
automations?: Record<string, {
|
|
3995
|
-
actions: ({
|
|
3996
|
-
prompt: string;
|
|
3997
|
-
type: "prompt";
|
|
3998
|
-
llmConnection?: string | undefined;
|
|
3999
|
-
model?: string | undefined;
|
|
4000
|
-
thinkingLevel?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
|
|
4001
|
-
} | {
|
|
4002
|
-
type: "webhook";
|
|
4003
|
-
url: string;
|
|
4004
|
-
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
4005
|
-
headers?: Record<string, string> | undefined;
|
|
4006
|
-
bodyFormat?: "json" | "form" | "raw" | undefined;
|
|
4007
|
-
body?: unknown;
|
|
4008
|
-
captureResponse?: boolean | undefined;
|
|
4009
|
-
auth?: {
|
|
4010
|
-
type: "basic";
|
|
4011
|
-
username: string;
|
|
4012
|
-
password: string;
|
|
4013
|
-
} | {
|
|
4014
|
-
type: "bearer";
|
|
4015
|
-
token: string;
|
|
4016
|
-
} | undefined;
|
|
4017
|
-
} | z.objectOutputType<{
|
|
4018
|
-
type: z.ZodString;
|
|
4019
|
-
}, z.ZodTypeAny, "passthrough">)[];
|
|
4020
|
-
timezone?: string | undefined;
|
|
4021
|
-
conditions?: any[] | undefined;
|
|
4022
|
-
id?: string | undefined;
|
|
4023
|
-
name?: string | undefined;
|
|
4024
|
-
matcher?: string | undefined;
|
|
4025
|
-
cron?: string | undefined;
|
|
4026
|
-
permissionMode?: "safe" | "ask" | "allow-all" | undefined;
|
|
4027
|
-
labels?: string[] | undefined;
|
|
4028
|
-
enabled?: boolean | undefined;
|
|
4029
|
-
telegramTopic?: string | undefined;
|
|
4030
|
-
}[]> | undefined;
|
|
4031
|
-
}, {
|
|
4032
|
-
version?: number | undefined;
|
|
4033
|
-
automations?: Record<string, {
|
|
4034
|
-
actions: ({
|
|
4035
|
-
prompt: string;
|
|
4036
|
-
type: "prompt";
|
|
4037
|
-
llmConnection?: string | undefined;
|
|
4038
|
-
model?: string | undefined;
|
|
4039
|
-
thinkingLevel?: string | undefined;
|
|
4040
|
-
} | {
|
|
4041
|
-
type: "webhook";
|
|
4042
|
-
url: string;
|
|
4043
|
-
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
4044
|
-
headers?: Record<string, string> | undefined;
|
|
4045
|
-
bodyFormat?: "json" | "form" | "raw" | undefined;
|
|
4046
|
-
body?: unknown;
|
|
4047
|
-
captureResponse?: boolean | undefined;
|
|
4048
|
-
auth?: {
|
|
4049
|
-
type: "basic";
|
|
4050
|
-
username: string;
|
|
4051
|
-
password: string;
|
|
4052
|
-
} | {
|
|
4053
|
-
type: "bearer";
|
|
4054
|
-
token: string;
|
|
4055
|
-
} | undefined;
|
|
4056
|
-
} | z.objectInputType<{
|
|
4057
|
-
type: z.ZodString;
|
|
4058
|
-
}, z.ZodTypeAny, "passthrough">)[];
|
|
4059
|
-
timezone?: string | undefined;
|
|
4060
|
-
conditions?: any[] | undefined;
|
|
4061
|
-
id?: string | undefined;
|
|
4062
|
-
name?: string | undefined;
|
|
4063
|
-
matcher?: string | undefined;
|
|
4064
|
-
cron?: string | undefined;
|
|
4065
|
-
permissionMode?: "safe" | "ask" | "allow-all" | undefined;
|
|
4066
|
-
labels?: string[] | undefined;
|
|
4067
|
-
enabled?: boolean | undefined;
|
|
4068
|
-
telegramTopic?: string | undefined;
|
|
4069
|
-
}[]> | undefined;
|
|
4070
|
-
}>, {
|
|
4071
|
-
version: number | undefined;
|
|
4072
|
-
automations: Record<string, {
|
|
4073
|
-
actions: ({
|
|
4074
|
-
prompt: string;
|
|
4075
|
-
type: "prompt";
|
|
4076
|
-
llmConnection?: string | undefined;
|
|
4077
|
-
model?: string | undefined;
|
|
4078
|
-
thinkingLevel?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
|
|
4079
|
-
} | {
|
|
4080
|
-
type: "webhook";
|
|
4081
|
-
url: string;
|
|
4082
|
-
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
4083
|
-
headers?: Record<string, string> | undefined;
|
|
4084
|
-
bodyFormat?: "json" | "form" | "raw" | undefined;
|
|
4085
|
-
body?: unknown;
|
|
4086
|
-
captureResponse?: boolean | undefined;
|
|
4087
|
-
auth?: {
|
|
4088
|
-
type: "basic";
|
|
4089
|
-
username: string;
|
|
4090
|
-
password: string;
|
|
4091
|
-
} | {
|
|
4092
|
-
type: "bearer";
|
|
4093
|
-
token: string;
|
|
4094
|
-
} | undefined;
|
|
4095
|
-
} | z.objectOutputType<{
|
|
4096
|
-
type: z.ZodString;
|
|
4097
|
-
}, z.ZodTypeAny, "passthrough">)[];
|
|
4098
|
-
timezone?: string | undefined;
|
|
4099
|
-
conditions?: any[] | undefined;
|
|
4100
|
-
id?: string | undefined;
|
|
4101
|
-
name?: string | undefined;
|
|
4102
|
-
matcher?: string | undefined;
|
|
4103
|
-
cron?: string | undefined;
|
|
4104
|
-
permissionMode?: "safe" | "ask" | "allow-all" | undefined;
|
|
4105
|
-
labels?: string[] | undefined;
|
|
4106
|
-
enabled?: boolean | undefined;
|
|
4107
|
-
telegramTopic?: string | undefined;
|
|
4108
|
-
}[]>;
|
|
4109
|
-
}, {
|
|
4110
|
-
version?: number | undefined;
|
|
4111
|
-
automations?: Record<string, {
|
|
4112
|
-
actions: ({
|
|
4113
|
-
prompt: string;
|
|
4114
|
-
type: "prompt";
|
|
4115
|
-
llmConnection?: string | undefined;
|
|
4116
|
-
model?: string | undefined;
|
|
4117
|
-
thinkingLevel?: string | undefined;
|
|
4118
|
-
} | {
|
|
4119
|
-
type: "webhook";
|
|
4120
|
-
url: string;
|
|
4121
|
-
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
4122
|
-
headers?: Record<string, string> | undefined;
|
|
4123
|
-
bodyFormat?: "json" | "form" | "raw" | undefined;
|
|
4124
|
-
body?: unknown;
|
|
4125
|
-
captureResponse?: boolean | undefined;
|
|
4126
|
-
auth?: {
|
|
4127
|
-
type: "basic";
|
|
4128
|
-
username: string;
|
|
4129
|
-
password: string;
|
|
4130
|
-
} | {
|
|
4131
|
-
type: "bearer";
|
|
4132
|
-
token: string;
|
|
4133
|
-
} | undefined;
|
|
4134
|
-
} | z.objectInputType<{
|
|
4135
|
-
type: z.ZodString;
|
|
4136
|
-
}, z.ZodTypeAny, "passthrough">)[];
|
|
4137
|
-
timezone?: string | undefined;
|
|
4138
|
-
conditions?: any[] | undefined;
|
|
4139
|
-
id?: string | undefined;
|
|
4140
|
-
name?: string | undefined;
|
|
4141
|
-
matcher?: string | undefined;
|
|
4142
|
-
cron?: string | undefined;
|
|
4143
|
-
permissionMode?: "safe" | "ask" | "allow-all" | undefined;
|
|
4144
|
-
labels?: string[] | undefined;
|
|
4145
|
-
enabled?: boolean | undefined;
|
|
4146
|
-
telegramTopic?: string | undefined;
|
|
4147
|
-
}[]> | undefined;
|
|
4148
|
-
}>;
|
|
4149
|
-
/**
|
|
4150
|
-
* Convert Zod error to ValidationIssues (matches validators.ts pattern)
|
|
4151
|
-
*/
|
|
4152
|
-
declare function zodErrorToIssues(error: z.ZodError, file: string): ValidationIssue[];
|
|
4153
|
-
|
|
4154
|
-
/**
|
|
4155
|
-
* Automation Condition Evaluator
|
|
4156
|
-
*
|
|
4157
|
-
* Pure synchronous evaluation engine for automation conditions.
|
|
4158
|
-
* Inspired by Home Assistant's condition system.
|
|
4159
|
-
*
|
|
4160
|
-
* Supports:
|
|
4161
|
-
* - time: Time-of-day and day-of-week checks
|
|
4162
|
-
* - state: Event payload field checks with HA-style from/to for transitions
|
|
4163
|
-
* - and/or/not: Logical composition with short-circuit evaluation
|
|
4164
|
-
*/
|
|
4165
|
-
|
|
4166
|
-
/** Context passed to condition evaluators */
|
|
4167
|
-
interface ConditionContext {
|
|
4168
|
-
/** Event payload fields */
|
|
4169
|
-
payload: Record<string, unknown>;
|
|
4170
|
-
/** Injectable current time (for testing) */
|
|
4171
|
-
now?: Date;
|
|
4172
|
-
/** Fallback timezone from the matcher */
|
|
4173
|
-
matcherTimezone?: string;
|
|
4174
|
-
}
|
|
4175
|
-
/**
|
|
4176
|
-
* Evaluate an array of conditions (top-level AND).
|
|
4177
|
-
* Returns true if all conditions pass, or if the array is empty/undefined.
|
|
4178
|
-
*/
|
|
4179
|
-
declare function evaluateConditions(conditions: AutomationCondition[], context: ConditionContext): boolean;
|
|
4180
|
-
|
|
4181
|
-
/**
|
|
4182
|
-
* Security Utilities for Automations
|
|
4183
|
-
*
|
|
4184
|
-
* Shell sanitization and security-related utilities.
|
|
4185
|
-
* Prevents command injection attacks via environment variables.
|
|
4186
|
-
*/
|
|
4187
|
-
/**
|
|
4188
|
-
* Sanitize a value for safe use in shell environment variables.
|
|
4189
|
-
* Escapes characters that could be used for shell injection.
|
|
4190
|
-
*
|
|
4191
|
-
* @param value - The string value to sanitize
|
|
4192
|
-
* @returns Sanitized string safe for shell environment variables
|
|
4193
|
-
*
|
|
4194
|
-
* @example
|
|
4195
|
-
* sanitizeForShell('$(rm -rf /)') // Returns '\\$(rm -rf /)'
|
|
4196
|
-
* sanitizeForShell('`whoami`') // Returns '\\`whoami\\`'
|
|
4197
|
-
*/
|
|
4198
|
-
declare function sanitizeForShell(value: string): string;
|
|
4199
|
-
|
|
4200
|
-
/**
|
|
4201
|
-
* Webhook Execution Utilities
|
|
4202
|
-
*
|
|
4203
|
-
* Shared webhook HTTP execution logic used by both the production WebhookHandler
|
|
4204
|
-
* and the RPC test handler. Centralizes timeout, body consumption, request building,
|
|
4205
|
-
* env var expansion, and retry logic so the two code paths can't diverge.
|
|
4206
|
-
*/
|
|
4207
|
-
|
|
4208
|
-
/**
|
|
4209
|
-
* Create a webhook history entry for appending to the history JSONL file.
|
|
4210
|
-
*/
|
|
4211
|
-
declare function createWebhookHistoryEntry(opts: {
|
|
4212
|
-
matcherId: string;
|
|
4213
|
-
ok: boolean;
|
|
4214
|
-
method?: string;
|
|
4215
|
-
url: string;
|
|
4216
|
-
statusCode: number;
|
|
4217
|
-
durationMs: number;
|
|
4218
|
-
attempts?: number;
|
|
4219
|
-
error?: string;
|
|
4220
|
-
responseBody?: string;
|
|
4221
|
-
}): Record<string, unknown>;
|
|
4222
|
-
/**
|
|
4223
|
-
* Create a prompt-action history entry for appending to the history JSONL file.
|
|
4224
|
-
*/
|
|
4225
|
-
declare function createPromptHistoryEntry(opts: {
|
|
4226
|
-
matcherId: string;
|
|
4227
|
-
ok: boolean;
|
|
4228
|
-
sessionId?: string;
|
|
4229
|
-
prompt?: string;
|
|
4230
|
-
error?: string;
|
|
4231
|
-
}): Record<string, unknown>;
|
|
4232
|
-
interface RetryConfig {
|
|
4233
|
-
/** Max retry attempts (default: 0 = no retry) */
|
|
4234
|
-
maxAttempts: number;
|
|
4235
|
-
/** Initial delay in ms (default: 1000). Doubles each attempt. */
|
|
4236
|
-
initialDelayMs?: number;
|
|
4237
|
-
/** Max delay cap in ms (default: 10000) */
|
|
4238
|
-
maxDelayMs?: number;
|
|
4239
|
-
}
|
|
4240
|
-
interface ExecuteWebhookOptions {
|
|
4241
|
-
/** Timeout in milliseconds (default: 30000) */
|
|
4242
|
-
timeoutMs?: number;
|
|
4243
|
-
/** Environment variables for $VAR expansion. If undefined, no expansion is performed (raw mode for tests) */
|
|
4244
|
-
env?: Record<string, string>;
|
|
4245
|
-
/** Retry config for transient failures. Disabled by default. */
|
|
4246
|
-
retry?: RetryConfig;
|
|
4247
|
-
}
|
|
4248
|
-
/**
|
|
4249
|
-
* Execute a single webhook HTTP request.
|
|
4250
|
-
*
|
|
4251
|
-
* Handles: request building, env var expansion, timeout via AbortController,
|
|
4252
|
-
* response body consumption (prevents memory leaks), and error wrapping.
|
|
4253
|
-
* Includes durationMs in the result for observability.
|
|
4254
|
-
*
|
|
4255
|
-
* @param action - The webhook action definition from automations config
|
|
4256
|
-
* @param options - Execution options (timeout, env vars for expansion)
|
|
4257
|
-
* @returns WebhookActionResult with status, success flag, timing, and any error
|
|
4258
|
-
*/
|
|
4259
|
-
declare function executeWebhookRequest(action: WebhookAction, options?: ExecuteWebhookOptions): Promise<WebhookActionResult>;
|
|
4260
|
-
/**
|
|
4261
|
-
* Execute a webhook request with optional retry for transient failures.
|
|
4262
|
-
*
|
|
4263
|
-
* Wraps executeWebhookRequest with exponential backoff + jitter.
|
|
4264
|
-
* If retry is not configured (or maxAttempts=0), behaves identically to executeWebhookRequest.
|
|
4265
|
-
*
|
|
4266
|
-
* @param action - The webhook action definition
|
|
4267
|
-
* @param options - Execution options including retry config
|
|
4268
|
-
* @returns WebhookActionResult with attempts count and total duration
|
|
4269
|
-
*/
|
|
4270
|
-
declare function executeWithRetry(action: WebhookAction, options?: ExecuteWebhookOptions): Promise<WebhookActionResult>;
|
|
4271
|
-
|
|
4272
|
-
/**
|
|
4273
|
-
* RetryScheduler - Persistent retry queue for failed webhooks
|
|
4274
|
-
*
|
|
4275
|
-
* When immediate retries (seconds-scale) are exhausted and a webhook still fails,
|
|
4276
|
-
* it's added to a persistent JSONL queue file. The scheduler checks the queue
|
|
4277
|
-
* every 60 seconds and retries at increasing intervals:
|
|
4278
|
-
* - 1st deferred: 5 minutes
|
|
4279
|
-
* - 2nd deferred: 30 minutes
|
|
4280
|
-
* - 3rd deferred: 1 hour
|
|
4281
|
-
*
|
|
4282
|
-
* After all deferred attempts fail, the entry is removed and a final history
|
|
4283
|
-
* entry is written. Queue entries survive app restarts.
|
|
4284
|
-
*/
|
|
4285
|
-
|
|
4286
|
-
interface RetryQueueEntry {
|
|
4287
|
-
/** Unique entry ID */
|
|
4288
|
-
id: string;
|
|
4289
|
-
/** Matcher ID (for history correlation) */
|
|
4290
|
-
matcherId: string;
|
|
4291
|
-
/** The webhook action with expanded values (no env vars needed at retry time) */
|
|
4292
|
-
action: WebhookAction;
|
|
4293
|
-
/** Expanded URL (post-env-expansion) for safe logging */
|
|
4294
|
-
expandedUrl: string;
|
|
4295
|
-
/** Number of deferred attempts already made (0 = first deferred pending) */
|
|
4296
|
-
deferredAttempt: number;
|
|
4297
|
-
/** Timestamp when the next retry should happen */
|
|
4298
|
-
nextRetryAt: number;
|
|
4299
|
-
/** Timestamp when this entry was created */
|
|
4300
|
-
createdAt: number;
|
|
4301
|
-
/** Last error message */
|
|
4302
|
-
lastError?: string;
|
|
4303
|
-
}
|
|
4304
|
-
interface RetrySchedulerOptions {
|
|
4305
|
-
workspaceRootPath: string;
|
|
4306
|
-
}
|
|
4307
|
-
declare class RetryScheduler {
|
|
4308
|
-
private readonly workspaceRootPath;
|
|
4309
|
-
private timer;
|
|
4310
|
-
private processing;
|
|
4311
|
-
constructor(options: RetrySchedulerOptions);
|
|
4312
|
-
/**
|
|
4313
|
-
* Start the scheduler. Checks queue every minute.
|
|
4314
|
-
*/
|
|
4315
|
-
start(): void;
|
|
4316
|
-
/**
|
|
4317
|
-
* Stop the scheduler and clean up.
|
|
4318
|
-
*/
|
|
4319
|
-
dispose(): void;
|
|
4320
|
-
/**
|
|
4321
|
-
* Enqueue a failed webhook for deferred retry.
|
|
4322
|
-
* Called by WebhookHandler when immediate retries are exhausted.
|
|
4323
|
-
*/
|
|
4324
|
-
enqueue(matcherId: string, action: WebhookAction, expandedUrl: string, lastError?: string): Promise<void>;
|
|
4325
|
-
/**
|
|
4326
|
-
* Process the queue: read entries, retry those that are due, rewrite the queue.
|
|
4327
|
-
*/
|
|
4328
|
-
private tick;
|
|
4329
|
-
}
|
|
4330
|
-
|
|
4331
|
-
/** Canonical config filename */
|
|
4332
|
-
declare const AUTOMATIONS_CONFIG_FILE = "automations.json";
|
|
4333
|
-
/** History log filename */
|
|
4334
|
-
declare const AUTOMATIONS_HISTORY_FILE = "automations-history.jsonl";
|
|
4335
|
-
/** Persistent retry queue filename */
|
|
4336
|
-
declare const AUTOMATIONS_RETRY_QUEUE_FILE = "automations-retry-queue.jsonl";
|
|
4337
|
-
/** Maximum length for string fields written to automations-history.jsonl (error, responseBody, prompt). */
|
|
4338
|
-
declare const HISTORY_FIELD_MAX_LENGTH = 2000;
|
|
4339
|
-
/** Max history entries retained per automation ID. */
|
|
4340
|
-
declare const AUTOMATION_HISTORY_MAX_RUNS_PER_MATCHER = 20;
|
|
4341
|
-
/** Max total history entries across all automations (global safety cap). */
|
|
4342
|
-
declare const AUTOMATION_HISTORY_MAX_ENTRIES = 1000;
|
|
4343
|
-
|
|
4344
|
-
/**
|
|
4345
|
-
* History Store — single source of truth for automations-history.jsonl writes
|
|
4346
|
-
* and compaction.
|
|
4347
|
-
*
|
|
4348
|
-
* Provides:
|
|
4349
|
-
* - `appendAutomationHistoryEntry()` — serialized append, triggers compaction at the global cap
|
|
4350
|
-
* - `compactAutomationHistory()` — async two-tier retention (runtime, under mutex)
|
|
4351
|
-
* - `compactAutomationHistorySync()` — sync two-tier retention (startup, no mutex needed)
|
|
4352
|
-
*
|
|
4353
|
-
* Both sync and async compaction share the same pure algorithm (`compactEntries`).
|
|
4354
|
-
* All history writes should go through `appendAutomationHistoryEntry` so the mutex
|
|
4355
|
-
* prevents concurrent file corruption.
|
|
4356
|
-
*/
|
|
4357
|
-
/**
|
|
4358
|
-
* Append a history entry to the JSONL file.
|
|
4359
|
-
* Triggers compaction when appends since startup reach the global cap.
|
|
4360
|
-
*
|
|
4361
|
-
* The entry must already be a fully-formed history object (use `createWebhookHistoryEntry`
|
|
4362
|
-
* or `createPromptHistoryEntry` from `webhook-utils.ts` to build one).
|
|
4363
|
-
*/
|
|
4364
|
-
declare function appendAutomationHistoryEntry(workspaceRootPath: string, entry: Record<string, unknown>): Promise<void>;
|
|
4365
|
-
/**
|
|
4366
|
-
* Compact the history file asynchronously (runtime path, under mutex).
|
|
4367
|
-
*/
|
|
4368
|
-
declare function compactAutomationHistory(workspaceRootPath: string, maxPerMatcher?: number, maxTotal?: number): Promise<void>;
|
|
4369
|
-
/**
|
|
4370
|
-
* Compact the history file synchronously (startup path).
|
|
4371
|
-
* Safe to call without the mutex — startup is single-threaded and runs
|
|
4372
|
-
* before any async appends.
|
|
4373
|
-
*/
|
|
4374
|
-
declare function compactAutomationHistorySync(workspaceRootPath: string, maxPerMatcher?: number, maxTotal?: number): void;
|
|
4375
|
-
|
|
4376
|
-
/**
|
|
4377
|
-
* Automations Config Path Resolver
|
|
4378
|
-
*/
|
|
4379
|
-
/**
|
|
4380
|
-
* Generate a short 6-character hex ID for matcher identification.
|
|
4381
|
-
* Uses crypto.randomBytes for uniqueness (24 bits of entropy = 16M possibilities).
|
|
4382
|
-
*/
|
|
4383
|
-
declare function generateShortId(): string;
|
|
4384
|
-
/**
|
|
4385
|
-
* Resolve the automations config path for a workspace.
|
|
4386
|
-
*/
|
|
4387
|
-
declare function resolveAutomationsConfigPath(workspaceRoot: string): string;
|
|
4388
|
-
|
|
4389
|
-
interface LoadAutomationsConfigResult {
|
|
4390
|
-
config: Record<string, unknown> | null;
|
|
4391
|
-
configPath: string;
|
|
4392
|
-
}
|
|
4393
|
-
interface SaveAutomationsConfigResult {
|
|
4394
|
-
ok: boolean;
|
|
4395
|
-
automationCount: number;
|
|
4396
|
-
errors: string[];
|
|
4397
|
-
}
|
|
4398
|
-
declare function loadAutomationsConfig(workspaceRootPath: string): LoadAutomationsConfigResult;
|
|
4399
|
-
declare function saveAutomationsConfig(workspaceRootPath: string, config: unknown): SaveAutomationsConfigResult;
|
|
4400
|
-
|
|
4401
|
-
/**
|
|
4402
|
-
* Cron Matching Utilities for Automations
|
|
4403
|
-
*
|
|
4404
|
-
* Determines if a cron expression matches the current time.
|
|
4405
|
-
* Used by SchedulerTick automations to trigger at specific intervals.
|
|
4406
|
-
*/
|
|
4407
|
-
/**
|
|
4408
|
-
* Check if a cron expression matches the current time.
|
|
4409
|
-
* Uses croner's nextRun to determine if the current minute matches the cron pattern.
|
|
4410
|
-
*
|
|
4411
|
-
* @param cronExpr - Cron expression in 5-field format (minute hour day-of-month month day-of-week)
|
|
4412
|
-
* @param timezone - Optional IANA timezone (e.g., "Europe/Budapest", "America/New_York")
|
|
4413
|
-
* @returns true if the cron expression matches the current minute
|
|
4414
|
-
*
|
|
4415
|
-
* @example
|
|
4416
|
-
* matchesCron('* * * * *') // Matches every minute
|
|
4417
|
-
* matchesCron('0 9 * * *', 'Europe/Budapest') // Matches 9:00 AM Budapest time
|
|
4418
|
-
*/
|
|
4419
|
-
declare function matchesCron(cronExpr: string, timezone?: string): boolean;
|
|
4420
|
-
|
|
4421
|
-
/**
|
|
4422
|
-
* AutomationHandler Interface and Common Types
|
|
4423
|
-
*
|
|
4424
|
-
* Defines the contract for all automation handlers in the Event Bus system.
|
|
4425
|
-
* Each handler:
|
|
4426
|
-
* - Subscribes to relevant events on the bus
|
|
4427
|
-
* - Executes its specific logic
|
|
4428
|
-
* - Is self-contained and testable in isolation
|
|
4429
|
-
*/
|
|
4430
|
-
|
|
4431
|
-
/**
|
|
4432
|
-
* Base interface for all automation handlers.
|
|
4433
|
-
* Handlers subscribe to events and process them independently.
|
|
4434
|
-
*/
|
|
4435
|
-
interface AutomationHandler {
|
|
4436
|
-
/** Subscribe to events on the bus */
|
|
4437
|
-
subscribe(bus: EventBus): void;
|
|
4438
|
-
/** Clean up resources and unsubscribe from events */
|
|
4439
|
-
dispose(): void | Promise<void>;
|
|
4440
|
-
}
|
|
4441
|
-
/** Options for creating a PromptHandler */
|
|
4442
|
-
interface PromptHandlerOptions {
|
|
4443
|
-
/** Workspace ID */
|
|
4444
|
-
workspaceId: string;
|
|
4445
|
-
/** Workspace root path for history file location */
|
|
4446
|
-
workspaceRootPath: string;
|
|
4447
|
-
/** Session ID (if executing in a session context) */
|
|
4448
|
-
sessionId?: string;
|
|
4449
|
-
/** Called when prompts are ready to be executed */
|
|
4450
|
-
onPromptsReady?: (prompts: PendingPrompt[]) => void;
|
|
4451
|
-
/** Called when a prompt execution fails */
|
|
4452
|
-
onError?: (event: AutomationEvent, error: Error) => void;
|
|
4453
|
-
}
|
|
4454
|
-
/** Options for creating an EventLogHandler */
|
|
4455
|
-
interface EventLogHandlerOptions {
|
|
4456
|
-
/** Workspace root path for log file location */
|
|
4457
|
-
workspaceRootPath: string;
|
|
4458
|
-
/** Workspace ID for log entries */
|
|
4459
|
-
workspaceId: string;
|
|
4460
|
-
/** Called when logging fails after retries */
|
|
4461
|
-
onEventLost?: (events: string[], error: Error) => void;
|
|
4462
|
-
}
|
|
4463
|
-
/**
|
|
4464
|
-
* Interface for getting automations configuration.
|
|
4465
|
-
* Allows handlers to be decoupled from config loading.
|
|
4466
|
-
*/
|
|
4467
|
-
interface AutomationsConfigProvider {
|
|
4468
|
-
/** Get the current automations configuration */
|
|
4469
|
-
getConfig(): AutomationsConfig | null;
|
|
4470
|
-
/** Get matchers for a specific event */
|
|
4471
|
-
getMatchersForEvent(event: AutomationEvent): AutomationMatcher[];
|
|
4472
|
-
}
|
|
4473
|
-
|
|
4474
|
-
/**
|
|
4475
|
-
* PromptHandler - Processes prompt actions for App events
|
|
4476
|
-
*
|
|
4477
|
-
* Subscribes to App events and collects prompt actions to be executed.
|
|
4478
|
-
* Prompts are queued and delivered via callback for the caller to execute.
|
|
4479
|
-
*/
|
|
4480
|
-
|
|
4481
|
-
declare class PromptHandler implements AutomationHandler {
|
|
4482
|
-
private readonly options;
|
|
4483
|
-
private readonly configProvider;
|
|
4484
|
-
private bus;
|
|
4485
|
-
private boundHandler;
|
|
4486
|
-
constructor(options: PromptHandlerOptions, configProvider: AutomationsConfigProvider);
|
|
4487
|
-
/**
|
|
4488
|
-
* Subscribe to App events on the bus.
|
|
4489
|
-
*/
|
|
4490
|
-
subscribe(bus: EventBus): void;
|
|
4491
|
-
/**
|
|
4492
|
-
* Handle an event by processing matching prompt actions.
|
|
4493
|
-
*/
|
|
4494
|
-
private handleEvent;
|
|
4495
|
-
/**
|
|
4496
|
-
* Clean up resources.
|
|
4497
|
-
*/
|
|
4498
|
-
dispose(): void;
|
|
4499
|
-
}
|
|
4500
|
-
|
|
4501
|
-
/**
|
|
4502
|
-
* EventLogHandler - Logs all automation events to events.jsonl
|
|
4503
|
-
*
|
|
4504
|
-
* Subscribes to all events and logs them for audit trail and replay.
|
|
4505
|
-
* Uses the existing AutomationEventLogger for buffered I/O.
|
|
4506
|
-
*/
|
|
4507
|
-
|
|
4508
|
-
declare class EventLogHandler implements AutomationHandler {
|
|
4509
|
-
private readonly options;
|
|
4510
|
-
private readonly logger;
|
|
4511
|
-
private bus;
|
|
4512
|
-
private boundHandler;
|
|
4513
|
-
constructor(options: EventLogHandlerOptions);
|
|
4514
|
-
/**
|
|
4515
|
-
* Subscribe to all events on the bus.
|
|
4516
|
-
*/
|
|
4517
|
-
subscribe(bus: EventBus): void;
|
|
4518
|
-
/**
|
|
4519
|
-
* Handle an event by logging it.
|
|
4520
|
-
*/
|
|
4521
|
-
private handleEvent;
|
|
4522
|
-
/**
|
|
4523
|
-
* Get the path to the event log file.
|
|
4524
|
-
*/
|
|
4525
|
-
getLogPath(): string;
|
|
4526
|
-
/**
|
|
4527
|
-
* Clean up resources.
|
|
4528
|
-
*/
|
|
4529
|
-
dispose(): Promise<void>;
|
|
4530
|
-
}
|
|
4531
|
-
|
|
4532
|
-
/**
|
|
4533
|
-
* WebhookHandler - Processes webhook actions for App events
|
|
4534
|
-
*
|
|
4535
|
-
* Subscribes to App events and executes HTTP webhook requests.
|
|
4536
|
-
* Sends requests to configured HTTP/HTTPS endpoints with configurable
|
|
4537
|
-
* method, headers, and body format (JSON or raw).
|
|
4538
|
-
*/
|
|
4539
|
-
|
|
4540
|
-
interface WebhookHandlerOptions {
|
|
4541
|
-
/** Workspace ID */
|
|
4542
|
-
workspaceId: string;
|
|
4543
|
-
/** Workspace root path */
|
|
4544
|
-
workspaceRootPath: string;
|
|
4545
|
-
/** Called when webhook results are available */
|
|
4546
|
-
onWebhookResults?: (results: WebhookActionResult[]) => void;
|
|
4547
|
-
/** Called when a webhook execution fails */
|
|
4548
|
-
onError?: (event: AutomationEvent, error: Error) => void;
|
|
4549
|
-
}
|
|
4550
|
-
declare class WebhookHandler implements AutomationHandler {
|
|
4551
|
-
private readonly options;
|
|
4552
|
-
private readonly configProvider;
|
|
4553
|
-
private readonly rateLimiter;
|
|
4554
|
-
private readonly retryScheduler;
|
|
4555
|
-
private bus;
|
|
4556
|
-
private boundHandler;
|
|
4557
|
-
constructor(options: WebhookHandlerOptions, configProvider: AutomationsConfigProvider);
|
|
4558
|
-
/**
|
|
4559
|
-
* Subscribe to App events on the bus.
|
|
4560
|
-
*/
|
|
4561
|
-
subscribe(bus: EventBus): void;
|
|
4562
|
-
/**
|
|
4563
|
-
* Handle an event by processing matching webhook actions.
|
|
4564
|
-
*/
|
|
4565
|
-
private handleEvent;
|
|
4566
|
-
/**
|
|
4567
|
-
* Clean up resources.
|
|
4568
|
-
*/
|
|
4569
|
-
dispose(): void;
|
|
4570
|
-
}
|
|
4571
|
-
|
|
4572
|
-
/**
|
|
4573
|
-
* AutomationSystem - Unified Facade for the Automations System
|
|
4574
|
-
*
|
|
4575
|
-
* Single entry point that:
|
|
4576
|
-
* - Creates EventBus instance (per workspace)
|
|
4577
|
-
* - Creates and registers all handlers
|
|
4578
|
-
* - Loads automations.json configuration
|
|
4579
|
-
* - Manages scheduler service
|
|
4580
|
-
* - Provides diffing for session metadata changes
|
|
4581
|
-
* - Provides dispose() for cleanup
|
|
4582
|
-
*
|
|
4583
|
-
* Benefits:
|
|
4584
|
-
* - No global state - each AutomationSystem instance is self-contained
|
|
4585
|
-
* - Easy to create for testing
|
|
4586
|
-
* - SessionManager uses ~30 lines instead of ~300
|
|
4587
|
-
*/
|
|
4588
|
-
|
|
4589
|
-
interface AutomationSystemOptions {
|
|
4590
|
-
/** Workspace root path (where automations.json lives) */
|
|
4591
|
-
workspaceRootPath: string;
|
|
4592
|
-
/** Workspace ID for logging and events */
|
|
4593
|
-
workspaceId: string;
|
|
4594
|
-
/** Working directory for command execution */
|
|
4595
|
-
workingDir?: string;
|
|
4596
|
-
/** Active source slugs for permission rules */
|
|
4597
|
-
activeSourceSlugs?: string[];
|
|
4598
|
-
/** Whether to start the scheduler service (default: false) */
|
|
4599
|
-
enableScheduler?: boolean;
|
|
4600
|
-
/** Called when prompts are ready to be executed */
|
|
4601
|
-
onPromptsReady?: (prompts: PendingPrompt[]) => void;
|
|
4602
|
-
/** Called when webhook results are available */
|
|
4603
|
-
onWebhookResults?: (results: WebhookActionResult[]) => void;
|
|
4604
|
-
/** Called when an error occurs during automation execution */
|
|
4605
|
-
onError?: (event: AutomationEvent, error: Error) => void;
|
|
4606
|
-
/** Called when events are lost after retries */
|
|
4607
|
-
onEventLost?: (events: string[], error: Error) => void;
|
|
4608
|
-
}
|
|
4609
|
-
declare class AutomationSystem implements AutomationsConfigProvider {
|
|
4610
|
-
readonly eventBus: WorkspaceEventBus;
|
|
4611
|
-
private readonly options;
|
|
4612
|
-
private config;
|
|
4613
|
-
private promptHandler;
|
|
4614
|
-
private webhookHandler;
|
|
4615
|
-
private eventLogHandler;
|
|
4616
|
-
private scheduler;
|
|
4617
|
-
private disposed;
|
|
4618
|
-
private readonly lastKnownMetadata;
|
|
4619
|
-
constructor(options: AutomationSystemOptions);
|
|
4620
|
-
/**
|
|
4621
|
-
* Read, parse, and validate automations.json. Shared pipeline for loadConfig/reloadConfig.
|
|
4622
|
-
* Returns the raw parsed JSON alongside validation results (avoids re-reading for backfillIds).
|
|
4623
|
-
*/
|
|
4624
|
-
private readAndValidateConfig;
|
|
4625
|
-
/**
|
|
4626
|
-
* Load automations configuration from automations.json.
|
|
4627
|
-
*/
|
|
4628
|
-
private loadConfig;
|
|
4629
|
-
/**
|
|
4630
|
-
* Reload automations configuration.
|
|
4631
|
-
* Call this when automations.json changes.
|
|
4632
|
-
*/
|
|
4633
|
-
reloadConfig(): {
|
|
4634
|
-
success: boolean;
|
|
4635
|
-
automationCount: number;
|
|
4636
|
-
errors: string[];
|
|
4637
|
-
};
|
|
4638
|
-
/**
|
|
4639
|
-
* Backfill missing IDs on matchers in the raw config.
|
|
4640
|
-
* Operates on the already-parsed raw JSON to avoid re-reading from disk.
|
|
4641
|
-
* Only writes if IDs were actually missing — no-op on subsequent loads.
|
|
4642
|
-
*/
|
|
4643
|
-
private backfillIds;
|
|
4644
|
-
/**
|
|
4645
|
-
* Compact automations-history.jsonl on startup: two-tier retention.
|
|
4646
|
-
* 1) Keep only the last N entries per automation ID.
|
|
4647
|
-
* 2) If total still exceeds the global cap, drop oldest globally.
|
|
4648
|
-
* Runs synchronously during init — single-threaded, no race with concurrent appends.
|
|
4649
|
-
*/
|
|
4650
|
-
private rotateHistory;
|
|
4651
|
-
/**
|
|
4652
|
-
* Get total number of actions.
|
|
4653
|
-
*/
|
|
4654
|
-
private getActionCount;
|
|
4655
|
-
getConfig(): AutomationsConfig | null;
|
|
4656
|
-
getMatchersForEvent(event: AutomationEvent): AutomationMatcher[];
|
|
4657
|
-
/**
|
|
4658
|
-
* Create and register all handlers.
|
|
4659
|
-
*/
|
|
4660
|
-
private createHandlers;
|
|
4661
|
-
/**
|
|
4662
|
-
* Start the scheduler service.
|
|
4663
|
-
*/
|
|
4664
|
-
private startScheduler;
|
|
4665
|
-
/**
|
|
4666
|
-
* Stop the scheduler service.
|
|
4667
|
-
*/
|
|
4668
|
-
stopScheduler(): void;
|
|
4669
|
-
/**
|
|
4670
|
-
* Update session metadata and emit events for changes.
|
|
4671
|
-
*
|
|
4672
|
-
* This replaces the diffing logic that was in SessionManager.
|
|
4673
|
-
* Call this whenever session metadata changes.
|
|
4674
|
-
*
|
|
4675
|
-
* @param sessionId - The session ID
|
|
4676
|
-
* @param next - The new metadata snapshot
|
|
4677
|
-
* @returns The events that were emitted
|
|
4678
|
-
*/
|
|
4679
|
-
updateSessionMetadata(sessionId: string, next: SessionMetadataSnapshot): Promise<AppEvent[]>;
|
|
4680
|
-
/**
|
|
4681
|
-
* Remove session metadata tracking.
|
|
4682
|
-
* Call this when a session is deleted.
|
|
4683
|
-
*/
|
|
4684
|
-
removeSessionMetadata(sessionId: string): void;
|
|
4685
|
-
/**
|
|
4686
|
-
* Get stored metadata for a session.
|
|
4687
|
-
*/
|
|
4688
|
-
getSessionMetadata(sessionId: string): SessionMetadataSnapshot | undefined;
|
|
4689
|
-
/**
|
|
4690
|
-
* Set initial metadata for a session (without emitting events).
|
|
4691
|
-
* Call this when loading existing sessions.
|
|
4692
|
-
*/
|
|
4693
|
-
setInitialSessionMetadata(sessionId: string, metadata: SessionMetadataSnapshot): void;
|
|
4694
|
-
/**
|
|
4695
|
-
* Emit a LabelConfigChange event.
|
|
4696
|
-
* Call this when labels/config.json changes.
|
|
4697
|
-
*/
|
|
4698
|
-
emitLabelConfigChange(): Promise<void>;
|
|
4699
|
-
/**
|
|
4700
|
-
* Emit an event directly (for edge cases).
|
|
4701
|
-
*/
|
|
4702
|
-
emit<T extends AutomationEvent>(event: T, payload: EventPayloadMap[T]): Promise<void>;
|
|
4703
|
-
/**
|
|
4704
|
-
* Execute agent event automations directly (without going through the Claude SDK).
|
|
4705
|
-
* This is the backend-agnostic entry point for non-Claude backends (Codex, Copilot, Pi)
|
|
4706
|
-
* to fire agent events from automations.json.
|
|
4707
|
-
*
|
|
4708
|
-
* For each matching automation matcher, builds env vars and evaluates matching.
|
|
4709
|
-
* Command execution has been removed — all automation actions now go through prompt-based
|
|
4710
|
-
* execution (creating agent sessions via PromptHandler).
|
|
4711
|
-
* Catches all errors — automations must never break the agent flow.
|
|
4712
|
-
*
|
|
4713
|
-
* @param signal - Optional AbortSignal for cancelling automation execution on abort
|
|
4714
|
-
* @returns Number of matched matchers (for diagnostics/testing)
|
|
4715
|
-
*/
|
|
4716
|
-
executeAgentEvent(event: AgentEvent, input: SdkAutomationInput, signal?: AbortSignal): Promise<number>;
|
|
4717
|
-
/**
|
|
4718
|
-
* Build SDK hook callbacks from automations.json definitions.
|
|
4719
|
-
*
|
|
4720
|
-
* Command execution has been removed — all automation actions now go through prompt-based
|
|
4721
|
-
* execution (creating agent sessions via PromptHandler). Agent event automations are not
|
|
4722
|
-
* currently supported via prompts, so this returns empty.
|
|
4723
|
-
*/
|
|
4724
|
-
buildSdkHooks(): Partial<Record<AgentEvent, SdkAutomationCallbackMatcher[]>>;
|
|
4725
|
-
/**
|
|
4726
|
-
* Check if the system has been disposed.
|
|
4727
|
-
*/
|
|
4728
|
-
isDisposed(): boolean;
|
|
4729
|
-
/**
|
|
4730
|
-
* Dispose the automation system, cleaning up all resources.
|
|
4731
|
-
*/
|
|
4732
|
-
dispose(): Promise<void>;
|
|
4733
|
-
}
|
|
4734
|
-
|
|
4735
|
-
interface AutoLabelRule {
|
|
4736
|
-
pattern: string;
|
|
4737
|
-
flags?: string;
|
|
4738
|
-
valueTemplate?: string;
|
|
4739
|
-
description?: string;
|
|
4740
|
-
}
|
|
4741
|
-
interface AutoLabelConfig {
|
|
4742
|
-
labelId: string;
|
|
4743
|
-
rules: AutoLabelRule[];
|
|
4744
|
-
}
|
|
4745
|
-
interface AutoLabelMatch {
|
|
4746
|
-
labelId: string;
|
|
4747
|
-
value: string;
|
|
4748
|
-
matchedText: string;
|
|
4749
|
-
}
|
|
4750
|
-
|
|
4751
|
-
declare function evaluateAutoLabels(text: string, configs: AutoLabelConfig[]): AutoLabelMatch[];
|
|
4752
|
-
|
|
4753
|
-
declare function normalizeNumberValue(raw: string): string;
|
|
4754
|
-
|
|
4755
|
-
interface AutoLabelRuleValidation {
|
|
4756
|
-
errors: string[];
|
|
4757
|
-
warnings: string[];
|
|
4758
|
-
}
|
|
4759
|
-
declare function validateAutoLabelPattern(pattern: string, flags?: string): AutoLabelRuleValidation;
|
|
4760
|
-
|
|
4761
|
-
/**
|
|
4762
|
-
* Labels Values Stub
|
|
4763
|
-
*
|
|
4764
|
-
* Provides label ID extraction used by automations.
|
|
4765
|
-
* Stubbed for OSS extraction — the real label utilities are in the main app.
|
|
4766
|
-
*/
|
|
4767
|
-
/**
|
|
4768
|
-
* Extract the label ID from a label string.
|
|
4769
|
-
* Handles formats like "priority::3" → "priority".
|
|
4770
|
-
* Stub: returns the label string itself (no structured labels in OSS package).
|
|
4771
|
-
*/
|
|
4772
|
-
declare function extractLabelId(label: string): string;
|
|
4773
|
-
|
|
4774
|
-
export { AGENT_EVENTS, APP_EVENTS, AUTOMATIONS_CONFIG_FILE, AUTOMATIONS_HISTORY_FILE, AUTOMATIONS_RETRY_QUEUE_FILE, AUTOMATION_HISTORY_MAX_ENTRIES, AUTOMATION_HISTORY_MAX_RUNS_PER_MATCHER, type ActionExecutionResult, type AgentEvent, type AnyEventHandler, type AppEvent, type AutoLabelConfig, type AutoLabelMatch, type AutoLabelRule, type AutoLabelRuleValidation, type AutomationAction, type AutomationCondition, AutomationConditionSchema, type AutomationDispatchKey, type AutomationEvent, AutomationEventLogger, type AutomationHandler, type AutomationHistoryActionType, type AutomationHistoryListFilter, type AutomationHistoryRecord, type AutomationHistoryRecordInput, type AutomationHistoryStatus, type AutomationHistoryStore, type AutomationInputEvent, type AutomationInputEventSource, type AutomationMatcher, type AutomationResult, type AutomationRuntimeGuard, type AutomationScheduleRegistration, type AutomationSchedulerHost, type AutomationSchedulerHostOptions, type AutomationSchedulerLifecycleReceipt, type AutomationSchedulerTickOptions, AutomationSystem, type SessionMetadataSnapshot as AutomationSystemMetadataSnapshot, type AutomationSystemOptions, type AutomationTimelineBridge, type AutomationsConfig, type AutomationsConfigDoctorReport, type AutomationsConfigProvider, AutomationsConfigSchema, type AutomationsValidationResult, type BaseEventPayload, type ConditionContext, type CreateAutomationTimelineBridgeOptions, type CreateRuntimeAutomationBridgeOptions, type EventBus, type EventHandler, EventLogHandler, type EventLogHandlerOptions, type EventPayloadMap, type ExecuteAutomationPromptOptions, type ExecuteAutomationPromptResult, type ExecuteWebhookOptions, type FlagChangePayload, type GenericEventPayload, HISTORY_FIELD_MAX_LENGTH, type LabelConfigChangePayload, type LabelEventPayload, type LoadAutomationsConfigResult, type LoggedAutomationEvent, type LoggedAutomationEventInput, type LogicalCondition, type PendingPrompt, type PermissionModeChangePayload, type PromptAction, type PromptActionResult, PromptHandler, type PromptHandlerOptions, type PromptReferences, type RetryConfig, type RetryQueueEntry, RetryScheduler, type RetrySchedulerOptions, type RuntimeAutomationBridge, type SaveAutomationsConfigResult, type SchedulerTickPayload, type SdkAutomationCallback, type SdkAutomationCallbackMatcher, type SdkAutomationInput, type SessionMetadataSnapshot, type SessionStatusChangePayload, type StateCondition, StateConditionSchema, type TimeCondition, TimeConditionSchema, VALID_EVENTS, type WebhookAction, type WebhookActionResult, type WebhookAuth, type WebhookBodyFormat, WebhookHandler, type WebhookHandlerOptions, type WebhookHttpMethod, WorkspaceEventBus, appendAutomationHistoryEntry, automationHistoryInputForPromptResult, buildEnvFromSdkInput, compactAutomationHistory, compactAutomationHistorySync, createAutomationRuntimeGuard, createAutomationSchedulerHost, createAutomationTimelineBridge, createAutomationsConfigDoctorReport, createInMemoryAutomationHistoryStore, createPromptHistoryEntry, createRuntimeAutomationBridge, createWebhookHistoryEntry, evaluateAutoLabels, evaluateConditions, executeAutomationPrompt, executeWebhookRequest, executeWithRetry, extractLabelId, generateShortId, loadAutomationsConfig, matchesCron, normalizeNumberValue, parsePromptReferences, projectTimelineEnvelopeToAutomationInput, resolveAutomationsConfigPath, sanitizeForShell, saveAutomationsConfig, validateAutoLabelPattern, validateAutomations, validateAutomationsConfig, validateAutomationsContent, zodErrorToIssues };
|