@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/sources.d.cts
DELETED
|
@@ -1,3978 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// ── inlined from @weft/timeline ──
|
|
4
|
-
// -- @weft/timeline/index.d.ts --
|
|
5
|
-
type TimelineProvider = string;
|
|
6
|
-
type TimelinePermissionScope = {
|
|
7
|
-
type: 'session';
|
|
8
|
-
sessionId: string;
|
|
9
|
-
} | {
|
|
10
|
-
type: 'workspace';
|
|
11
|
-
workspaceId: string;
|
|
12
|
-
} | {
|
|
13
|
-
type: 'source';
|
|
14
|
-
sourceSlug: string;
|
|
15
|
-
} | {
|
|
16
|
-
type: 'skill';
|
|
17
|
-
skillSlug: string;
|
|
18
|
-
} | {
|
|
19
|
-
type: 'automation';
|
|
20
|
-
automationId: string;
|
|
21
|
-
} | {
|
|
22
|
-
type: 'tool-call';
|
|
23
|
-
callId: string;
|
|
24
|
-
};
|
|
25
|
-
type TimelineCommandOrigin = {
|
|
26
|
-
type: 'user';
|
|
27
|
-
id?: string;
|
|
28
|
-
} | {
|
|
29
|
-
type: 'automation';
|
|
30
|
-
id: string;
|
|
31
|
-
} | {
|
|
32
|
-
type: 'scheduler';
|
|
33
|
-
id?: string;
|
|
34
|
-
} | {
|
|
35
|
-
type: 'host';
|
|
36
|
-
id?: string;
|
|
37
|
-
} | {
|
|
38
|
-
type: 'replay';
|
|
39
|
-
id?: string;
|
|
40
|
-
} | {
|
|
41
|
-
type: 'system';
|
|
42
|
-
id?: string;
|
|
43
|
-
};
|
|
44
|
-
interface ToolIntent {
|
|
45
|
-
kind: string;
|
|
46
|
-
command?: string;
|
|
47
|
-
baseCommand?: string;
|
|
48
|
-
path?: string;
|
|
49
|
-
toolName?: string;
|
|
50
|
-
name?: string;
|
|
51
|
-
method?: string;
|
|
52
|
-
url?: string;
|
|
53
|
-
}
|
|
54
|
-
interface TimelinePermissionRequest {
|
|
55
|
-
requestId: string;
|
|
56
|
-
toolName: string;
|
|
57
|
-
scope?: TimelinePermissionScope;
|
|
58
|
-
input?: Record<string, unknown>;
|
|
59
|
-
reason?: string;
|
|
60
|
-
intent?: ToolIntent;
|
|
61
|
-
}
|
|
62
|
-
interface TimelinePermissionResolution {
|
|
63
|
-
allowed: boolean;
|
|
64
|
-
remember?: boolean;
|
|
65
|
-
reason?: string;
|
|
66
|
-
}
|
|
67
|
-
type TimelineToolStatus = 'pending' | 'running' | 'completed' | 'failed';
|
|
68
|
-
type TimelineItem = {
|
|
69
|
-
type: 'user_message';
|
|
70
|
-
text: string;
|
|
71
|
-
messageId: string;
|
|
72
|
-
turnId?: string;
|
|
73
|
-
} | {
|
|
74
|
-
type: 'assistant_message_delta';
|
|
75
|
-
text: string;
|
|
76
|
-
messageId: string;
|
|
77
|
-
turnId: string;
|
|
78
|
-
} | {
|
|
79
|
-
type: 'assistant_message';
|
|
80
|
-
text: string;
|
|
81
|
-
messageId: string;
|
|
82
|
-
turnId: string;
|
|
83
|
-
} | {
|
|
84
|
-
type: 'reasoning_delta';
|
|
85
|
-
text: string;
|
|
86
|
-
messageId: string;
|
|
87
|
-
turnId: string;
|
|
88
|
-
} | {
|
|
89
|
-
type: 'reasoning';
|
|
90
|
-
text: string;
|
|
91
|
-
messageId: string;
|
|
92
|
-
turnId: string;
|
|
93
|
-
} | {
|
|
94
|
-
type: 'tool_call';
|
|
95
|
-
callId: string;
|
|
96
|
-
name: string;
|
|
97
|
-
status: TimelineToolStatus;
|
|
98
|
-
detail?: unknown;
|
|
99
|
-
turnId?: string;
|
|
100
|
-
} | {
|
|
101
|
-
type: 'tool_output_delta';
|
|
102
|
-
callId: string;
|
|
103
|
-
text: string;
|
|
104
|
-
stream?: 'stdout' | 'stderr' | string;
|
|
105
|
-
turnId?: string;
|
|
106
|
-
} | {
|
|
107
|
-
type: 'tool_result';
|
|
108
|
-
callId: string;
|
|
109
|
-
result: unknown;
|
|
110
|
-
isError?: boolean;
|
|
111
|
-
turnId?: string;
|
|
112
|
-
} | {
|
|
113
|
-
type: 'permission_requested';
|
|
114
|
-
request: TimelinePermissionRequest;
|
|
115
|
-
} | {
|
|
116
|
-
type: 'permission_resolved';
|
|
117
|
-
requestId: string;
|
|
118
|
-
resolution: TimelinePermissionResolution;
|
|
119
|
-
} | {
|
|
120
|
-
type: 'permission_policy_changed';
|
|
121
|
-
policy: unknown;
|
|
122
|
-
} | {
|
|
123
|
-
type: 'source_state_changed';
|
|
124
|
-
source: unknown;
|
|
125
|
-
} | {
|
|
126
|
-
type: 'skill_activated';
|
|
127
|
-
skill: unknown;
|
|
128
|
-
} | {
|
|
129
|
-
type: 'host_state_changed';
|
|
130
|
-
state: unknown;
|
|
131
|
-
} | {
|
|
132
|
-
type: 'automation_triggered';
|
|
133
|
-
automation: {
|
|
134
|
-
automationId: string;
|
|
135
|
-
origin: TimelineCommandOrigin;
|
|
136
|
-
detail?: unknown;
|
|
137
|
-
};
|
|
138
|
-
} | {
|
|
139
|
-
type: 'automation_action_result';
|
|
140
|
-
result: unknown;
|
|
141
|
-
} | {
|
|
142
|
-
type: 'runtime_capability_report';
|
|
143
|
-
report: unknown;
|
|
144
|
-
} | {
|
|
145
|
-
type: 'runtime_fallback';
|
|
146
|
-
reason: string;
|
|
147
|
-
from?: string;
|
|
148
|
-
to: string;
|
|
149
|
-
} | {
|
|
150
|
-
type: 'turn_started';
|
|
151
|
-
turnId: string;
|
|
152
|
-
} | {
|
|
153
|
-
type: 'turn_completed';
|
|
154
|
-
turnId: string;
|
|
155
|
-
usage?: unknown;
|
|
156
|
-
} | {
|
|
157
|
-
type: 'turn_failed';
|
|
158
|
-
turnId: string;
|
|
159
|
-
error: unknown;
|
|
160
|
-
} | {
|
|
161
|
-
type: 'session_status';
|
|
162
|
-
status: string;
|
|
163
|
-
} | {
|
|
164
|
-
type: 'tool_suspended';
|
|
165
|
-
callId: string;
|
|
166
|
-
name: string;
|
|
167
|
-
stepId?: string;
|
|
168
|
-
} | {
|
|
169
|
-
type: 'tool_resumed';
|
|
170
|
-
callId: string;
|
|
171
|
-
name: string;
|
|
172
|
-
stepId?: string;
|
|
173
|
-
} | {
|
|
174
|
-
type: 'compaction_started';
|
|
175
|
-
} | {
|
|
176
|
-
type: 'compaction_boundary';
|
|
177
|
-
summary?: string;
|
|
178
|
-
};
|
|
179
|
-
interface TimelineRawRef {
|
|
180
|
-
providerEventType?: string;
|
|
181
|
-
logPath?: string;
|
|
182
|
-
offset?: number;
|
|
183
|
-
}
|
|
184
|
-
interface TimelineEnvelope {
|
|
185
|
-
sessionId: string;
|
|
186
|
-
provider: TimelineProvider;
|
|
187
|
-
seq: number;
|
|
188
|
-
epoch: string;
|
|
189
|
-
timestamp: number;
|
|
190
|
-
item: TimelineItem;
|
|
191
|
-
rawRef?: TimelineRawRef;
|
|
192
|
-
}
|
|
193
|
-
interface TimelineCursor {
|
|
194
|
-
epoch: string;
|
|
195
|
-
afterSeq: number;
|
|
196
|
-
}
|
|
197
|
-
interface TimelineFetchRequest {
|
|
198
|
-
cursor?: TimelineCursor;
|
|
199
|
-
limit?: number;
|
|
200
|
-
}
|
|
201
|
-
interface TimelineFetchResult {
|
|
202
|
-
items: TimelineEnvelope[];
|
|
203
|
-
nextCursor: TimelineCursor;
|
|
204
|
-
hasGap: boolean;
|
|
205
|
-
}
|
|
206
|
-
interface CreateTimelineSequencerOptions {
|
|
207
|
-
sessionId: string;
|
|
208
|
-
provider: TimelineProvider;
|
|
209
|
-
epoch: string;
|
|
210
|
-
startSeq?: number;
|
|
211
|
-
now?: () => number;
|
|
212
|
-
}
|
|
213
|
-
interface TimelineSequencer {
|
|
214
|
-
append(item: TimelineItem, rawRef?: TimelineRawRef): TimelineEnvelope;
|
|
215
|
-
}
|
|
216
|
-
declare function createTimelineSequencer(options: CreateTimelineSequencerOptions): TimelineSequencer;
|
|
217
|
-
declare function appendTimelineItem(envelope: TimelineEnvelope): TimelineEnvelope;
|
|
218
|
-
declare function createTimelineCursor(cursor: TimelineCursor): TimelineCursor;
|
|
219
|
-
declare function fetchTimeline(timeline: TimelineEnvelope[], request?: TimelineFetchRequest): TimelineFetchResult;
|
|
220
|
-
declare function mergeTimeline(existing: TimelineEnvelope[], incoming: TimelineEnvelope[]): TimelineEnvelope[];
|
|
221
|
-
|
|
222
|
-
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 };
|
|
223
|
-
|
|
224
|
-
// ── inlined from @weft/core ──
|
|
225
|
-
// -- @weft/core/index.d.ts --
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Mode Types and Constants
|
|
229
|
-
*
|
|
230
|
-
* Pure types and UI configuration for permission modes.
|
|
231
|
-
* Note: This file imports zod for schema definitions.
|
|
232
|
-
* Type-only imports (PermissionMode, PermissionModeCanonical) have no runtime cost.
|
|
233
|
-
*/
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Available permission modes (internal storage keys).
|
|
237
|
-
*
|
|
238
|
-
* UI-facing canonical names are:
|
|
239
|
-
* - explore -> safe
|
|
240
|
-
* - ask -> ask
|
|
241
|
-
* - execute -> allow-all
|
|
242
|
-
*/
|
|
243
|
-
type PermissionMode = 'safe' | 'ask' | 'allow-all';
|
|
244
|
-
/**
|
|
245
|
-
* Canonical mode names used in user-facing/session-state surfaces.
|
|
246
|
-
*/
|
|
247
|
-
type PermissionModeCanonical = 'explore' | 'ask' | 'execute';
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Thinking Level Configuration
|
|
251
|
-
*
|
|
252
|
-
* Six-tier thinking system for extended reasoning:
|
|
253
|
-
* - OFF: No extended thinking (disabled)
|
|
254
|
-
* - Low: Light reasoning, faster responses
|
|
255
|
-
* - Medium: Balanced speed and reasoning (default)
|
|
256
|
-
* - High: Deep reasoning for complex tasks
|
|
257
|
-
* - XHigh: Extra-high reasoning — Anthropic's recommended level for Opus 4.7 agentic/coding work
|
|
258
|
-
* - Max: Maximum effort reasoning
|
|
259
|
-
*
|
|
260
|
-
* Session-level setting with workspace defaults.
|
|
261
|
-
*
|
|
262
|
-
* Provider mappings:
|
|
263
|
-
* - Anthropic: adaptive thinking + effort levels (Opus 4.7+). On models that
|
|
264
|
-
* don't accept `xhigh`, the Anthropic SDK silently falls back to `high`.
|
|
265
|
-
* - Pi/OpenAI: reasoning_effort via Pi SDK levels. Pi's ceiling is `xhigh`,
|
|
266
|
-
* so Weft's `max` saturates there.
|
|
267
|
-
*/
|
|
268
|
-
/**
|
|
269
|
-
* Ordered list of valid thinking level IDs. Single source of truth — the
|
|
270
|
-
* `ThinkingLevel` type, `THINKING_LEVELS` metadata, the Zod schema in
|
|
271
|
-
* `validators.ts`, and runtime validation/error messages all derive from this.
|
|
272
|
-
*
|
|
273
|
-
* Order is significant: it determines UI ordering (low → max).
|
|
274
|
-
*/
|
|
275
|
-
declare const THINKING_LEVEL_IDS: readonly ["off", "low", "medium", "high", "xhigh", "max"];
|
|
276
|
-
type ThinkingLevel = (typeof THINKING_LEVEL_IDS)[number];
|
|
277
|
-
interface ThinkingLevelDefinition {
|
|
278
|
-
id: ThinkingLevel;
|
|
279
|
-
/** Translation key for the display name (resolve with t() at render site) */
|
|
280
|
-
nameKey: string;
|
|
281
|
-
/** Translation key for the description (resolve with t() at render site) */
|
|
282
|
-
descriptionKey: string;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Available thinking levels with display metadata.
|
|
286
|
-
* Used in UI dropdowns and for validation.
|
|
287
|
-
*
|
|
288
|
-
* Labels use translation keys — resolve with t(level.nameKey) in components.
|
|
289
|
-
*/
|
|
290
|
-
declare const THINKING_LEVELS: readonly ThinkingLevelDefinition[];
|
|
291
|
-
/**
|
|
292
|
-
* Map ThinkingLevel to Anthropic SDK effort parameter.
|
|
293
|
-
* Used with adaptive thinking (thinking: { type: 'adaptive' }).
|
|
294
|
-
* Returns null for 'off' (thinking should be disabled entirely).
|
|
295
|
-
*/
|
|
296
|
-
declare const THINKING_TO_EFFORT: Record<ThinkingLevel, 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null>;
|
|
297
|
-
/**
|
|
298
|
-
* Get the thinking token budget for a given level and model.
|
|
299
|
-
* Used as fallback for models that don't support adaptive thinking.
|
|
300
|
-
*
|
|
301
|
-
* @param level - The thinking level
|
|
302
|
-
* @param modelId - The model ID (e.g., 'claude-haiku-4-5-20251001')
|
|
303
|
-
* @returns Number of thinking tokens to allocate
|
|
304
|
-
*/
|
|
305
|
-
declare function getThinkingTokens(level: ThinkingLevel, modelId: string): number;
|
|
306
|
-
/**
|
|
307
|
-
* Get the translation key for a thinking level's display name.
|
|
308
|
-
* Resolve with t() or i18n.t() at the call site.
|
|
309
|
-
*/
|
|
310
|
-
declare function getThinkingLevelNameKey(level: ThinkingLevel): string;
|
|
311
|
-
/**
|
|
312
|
-
* Validate that a value is a valid ThinkingLevel.
|
|
313
|
-
*/
|
|
314
|
-
declare function isValidThinkingLevel(value: unknown): value is ThinkingLevel;
|
|
315
|
-
/**
|
|
316
|
-
* Normalize a persisted thinking level value, handling legacy values.
|
|
317
|
-
* Maps the old 'think' value to 'medium' for backward compatibility.
|
|
318
|
-
*
|
|
319
|
-
* TODO: Remove the legacy 'think' compatibility path after old persisted session
|
|
320
|
-
* and workspace data has realistically aged out across upgrades.
|
|
321
|
-
*
|
|
322
|
-
* @returns The normalized ThinkingLevel, or undefined if the value is invalid
|
|
323
|
-
*/
|
|
324
|
-
declare function normalizeThinkingLevel(value: unknown): ThinkingLevel | undefined;
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Server DTO types — data shapes used by RPC handlers and SessionManager.
|
|
328
|
-
*
|
|
329
|
-
* Extracted here so handler code in @weft can import
|
|
330
|
-
* from @weft/protocol without reaching into the app.
|
|
331
|
-
*/
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Dynamic status ID referencing workspace status config.
|
|
335
|
-
* Validated at runtime via validateSessionStatus().
|
|
336
|
-
* Falls back to 'todo' if status doesn't exist.
|
|
337
|
-
*/
|
|
338
|
-
type SessionStatus = string;
|
|
339
|
-
type BuiltInStatusId = 'todo' | 'in-progress' | 'needs-review' | 'done' | 'cancelled';
|
|
340
|
-
/**
|
|
341
|
-
* Electron-specific Session type (includes runtime state).
|
|
342
|
-
* Extends core Session with messages array and processing state.
|
|
343
|
-
*/
|
|
344
|
-
interface Session {
|
|
345
|
-
id: string;
|
|
346
|
-
workspaceId: string;
|
|
347
|
-
workspaceName: string;
|
|
348
|
-
name?: string;
|
|
349
|
-
/** Preview of first user message (from JSONL header, for lazy-loaded sessions) */
|
|
350
|
-
preview?: string;
|
|
351
|
-
lastMessageAt: number;
|
|
352
|
-
messages: Message[];
|
|
353
|
-
isProcessing: boolean;
|
|
354
|
-
isFlagged?: boolean;
|
|
355
|
-
/** Permission mode for this session ('safe', 'ask', 'allow-all') */
|
|
356
|
-
permissionMode?: PermissionMode;
|
|
357
|
-
sessionStatus?: SessionStatus;
|
|
358
|
-
/** Labels (additive tags, many-per-session — bare IDs or "id::value" entries) */
|
|
359
|
-
labels?: string[];
|
|
360
|
-
lastReadMessageId?: string;
|
|
361
|
-
/**
|
|
362
|
-
* Explicit unread flag - single source of truth for NEW badge.
|
|
363
|
-
* Set to true when assistant message completes while user is NOT viewing.
|
|
364
|
-
* Set to false when user views the session (and not processing).
|
|
365
|
-
*/
|
|
366
|
-
hasUnread?: boolean;
|
|
367
|
-
enabledSourceSlugs?: string[];
|
|
368
|
-
workingDirectory?: string;
|
|
369
|
-
sessionFolderPath?: string;
|
|
370
|
-
sharedUrl?: string;
|
|
371
|
-
sharedId?: string;
|
|
372
|
-
model?: string;
|
|
373
|
-
llmConnection?: string;
|
|
374
|
-
thinkingLevel?: ThinkingLevel;
|
|
375
|
-
lastMessageRole?: 'user' | 'assistant' | 'plan' | 'tool' | 'error';
|
|
376
|
-
lastFinalMessageId?: string;
|
|
377
|
-
isAsyncOperationOngoing?: boolean;
|
|
378
|
-
/** @deprecated Use isAsyncOperationOngoing instead */
|
|
379
|
-
isRegeneratingTitle?: boolean;
|
|
380
|
-
currentStatus?: {
|
|
381
|
-
message: string;
|
|
382
|
-
statusType?: string;
|
|
383
|
-
};
|
|
384
|
-
createdAt?: number;
|
|
385
|
-
messageCount?: number;
|
|
386
|
-
tokenUsage?: {
|
|
387
|
-
inputTokens: number;
|
|
388
|
-
outputTokens: number;
|
|
389
|
-
totalTokens: number;
|
|
390
|
-
contextTokens: number;
|
|
391
|
-
costUsd: number;
|
|
392
|
-
cacheReadTokens?: number;
|
|
393
|
-
cacheCreationTokens?: number;
|
|
394
|
-
/** Model's context window size in tokens (from SDK modelUsage) */
|
|
395
|
-
contextWindow?: number;
|
|
396
|
-
};
|
|
397
|
-
/** When true, session is hidden from session list (e.g., mini edit sessions) */
|
|
398
|
-
hidden?: boolean;
|
|
399
|
-
isArchived?: boolean;
|
|
400
|
-
archivedAt?: number;
|
|
401
|
-
supportsBranching?: boolean;
|
|
402
|
-
}
|
|
403
|
-
interface CreateSessionOptions {
|
|
404
|
-
name?: string;
|
|
405
|
-
permissionMode?: PermissionMode;
|
|
406
|
-
/**
|
|
407
|
-
* Reasoning/thinking level override. When set, takes precedence over workspace
|
|
408
|
-
* and global defaults. Silently ignored by the underlying SDK on non-reasoning
|
|
409
|
-
* models (e.g. gpt-4o) — provider drivers don't attach the reasoning param to
|
|
410
|
-
* the API request for models with `reasoning: false` in the Pi SDK catalog.
|
|
411
|
-
*/
|
|
412
|
-
thinkingLevel?: ThinkingLevel;
|
|
413
|
-
/**
|
|
414
|
-
* Working directory for the session:
|
|
415
|
-
* - 'user_default' or undefined: Use workspace's configured default working directory
|
|
416
|
-
* - 'none': No working directory (session folder only)
|
|
417
|
-
* - Absolute path string: Use this specific path
|
|
418
|
-
*/
|
|
419
|
-
workingDirectory?: string | 'user_default' | 'none';
|
|
420
|
-
model?: string;
|
|
421
|
-
llmConnection?: string;
|
|
422
|
-
systemPromptPreset?: 'default' | 'mini' | string;
|
|
423
|
-
hidden?: boolean;
|
|
424
|
-
sessionStatus?: SessionStatus;
|
|
425
|
-
labels?: string[];
|
|
426
|
-
isFlagged?: boolean;
|
|
427
|
-
enabledSourceSlugs?: string[];
|
|
428
|
-
/**
|
|
429
|
-
* Message ID to branch from. This is a hard context cutoff:
|
|
430
|
-
* the new session must not include model context from later parent messages.
|
|
431
|
-
*/
|
|
432
|
-
branchFromMessageId?: string;
|
|
433
|
-
/** Parent session ID used together with branchFromMessageId. */
|
|
434
|
-
branchFromSessionId?: string;
|
|
435
|
-
}
|
|
436
|
-
interface RemoteSessionTransferPayload {
|
|
437
|
-
sourceSessionId: string;
|
|
438
|
-
name?: string;
|
|
439
|
-
sessionStatus?: SessionStatus;
|
|
440
|
-
labels?: string[];
|
|
441
|
-
permissionMode?: PermissionMode;
|
|
442
|
-
summary: string;
|
|
443
|
-
}
|
|
444
|
-
interface ImportRemoteSessionTransferResult {
|
|
445
|
-
sessionId: string;
|
|
446
|
-
}
|
|
447
|
-
interface PermissionModeState {
|
|
448
|
-
permissionMode: PermissionMode;
|
|
449
|
-
previousPermissionMode?: PermissionMode;
|
|
450
|
-
transitionDisplay?: string;
|
|
451
|
-
modeVersion: number;
|
|
452
|
-
changedAt: string;
|
|
453
|
-
changedBy: 'user' | 'system' | 'restore' | 'automation' | 'unknown';
|
|
454
|
-
}
|
|
455
|
-
type SessionEvent = {
|
|
456
|
-
type: 'text_delta';
|
|
457
|
-
sessionId: string;
|
|
458
|
-
delta: string;
|
|
459
|
-
turnId?: string;
|
|
460
|
-
} | {
|
|
461
|
-
type: 'text_complete';
|
|
462
|
-
sessionId: string;
|
|
463
|
-
text: string;
|
|
464
|
-
isIntermediate?: boolean;
|
|
465
|
-
turnId?: string;
|
|
466
|
-
parentToolUseId?: string;
|
|
467
|
-
timestamp?: number;
|
|
468
|
-
messageId?: string;
|
|
469
|
-
} | {
|
|
470
|
-
type: 'tool_start';
|
|
471
|
-
sessionId: string;
|
|
472
|
-
toolName: string;
|
|
473
|
-
toolUseId: string;
|
|
474
|
-
toolInput: Record<string, unknown>;
|
|
475
|
-
toolIntent?: string;
|
|
476
|
-
toolDisplayName?: string;
|
|
477
|
-
toolDisplayMeta?: ToolDisplayMeta;
|
|
478
|
-
turnId?: string;
|
|
479
|
-
parentToolUseId?: string;
|
|
480
|
-
timestamp?: number;
|
|
481
|
-
} | {
|
|
482
|
-
type: 'tool_result';
|
|
483
|
-
sessionId: string;
|
|
484
|
-
toolUseId: string;
|
|
485
|
-
toolName: string;
|
|
486
|
-
result: string;
|
|
487
|
-
turnId?: string;
|
|
488
|
-
parentToolUseId?: string;
|
|
489
|
-
isError?: boolean;
|
|
490
|
-
timestamp?: number;
|
|
491
|
-
} | {
|
|
492
|
-
type: 'error';
|
|
493
|
-
sessionId: string;
|
|
494
|
-
error: string;
|
|
495
|
-
timestamp?: number;
|
|
496
|
-
} | {
|
|
497
|
-
type: 'typed_error';
|
|
498
|
-
sessionId: string;
|
|
499
|
-
error: TypedError;
|
|
500
|
-
timestamp?: number;
|
|
501
|
-
} | {
|
|
502
|
-
type: 'complete';
|
|
503
|
-
sessionId: string;
|
|
504
|
-
tokenUsage?: Session['tokenUsage'];
|
|
505
|
-
hasUnread?: boolean;
|
|
506
|
-
} | {
|
|
507
|
-
type: 'interrupted';
|
|
508
|
-
sessionId: string;
|
|
509
|
-
message?: Message;
|
|
510
|
-
queuedMessages?: string[];
|
|
511
|
-
} | {
|
|
512
|
-
type: 'status';
|
|
513
|
-
sessionId: string;
|
|
514
|
-
message: string;
|
|
515
|
-
statusType?: 'compacting';
|
|
516
|
-
} | {
|
|
517
|
-
type: 'info';
|
|
518
|
-
sessionId: string;
|
|
519
|
-
message: string;
|
|
520
|
-
statusType?: 'compaction_complete';
|
|
521
|
-
level?: 'info' | 'warning' | 'error' | 'success';
|
|
522
|
-
timestamp?: number;
|
|
523
|
-
} | {
|
|
524
|
-
type: 'title_generated';
|
|
525
|
-
sessionId: string;
|
|
526
|
-
title: string;
|
|
527
|
-
} | {
|
|
528
|
-
type: 'title_regenerating';
|
|
529
|
-
sessionId: string;
|
|
530
|
-
isRegenerating: boolean;
|
|
531
|
-
} | {
|
|
532
|
-
type: 'async_operation';
|
|
533
|
-
sessionId: string;
|
|
534
|
-
isOngoing: boolean;
|
|
535
|
-
} | {
|
|
536
|
-
type: 'working_directory_changed';
|
|
537
|
-
sessionId: string;
|
|
538
|
-
workingDirectory: string;
|
|
539
|
-
} | {
|
|
540
|
-
type: 'permission_request';
|
|
541
|
-
sessionId: string;
|
|
542
|
-
request: PermissionRequest;
|
|
543
|
-
} | {
|
|
544
|
-
type: 'credential_request';
|
|
545
|
-
sessionId: string;
|
|
546
|
-
request: CredentialRequest;
|
|
547
|
-
} | {
|
|
548
|
-
type: 'permission_mode_changed';
|
|
549
|
-
sessionId: string;
|
|
550
|
-
permissionMode: PermissionMode;
|
|
551
|
-
previousPermissionMode?: PermissionMode;
|
|
552
|
-
transitionDisplay?: string;
|
|
553
|
-
modeVersion?: number;
|
|
554
|
-
changedAt?: string;
|
|
555
|
-
changedBy?: PermissionModeState['changedBy'];
|
|
556
|
-
} | {
|
|
557
|
-
type: 'plan_submitted';
|
|
558
|
-
sessionId: string;
|
|
559
|
-
message: Message;
|
|
560
|
-
} | {
|
|
561
|
-
type: 'sources_changed';
|
|
562
|
-
sessionId: string;
|
|
563
|
-
enabledSourceSlugs: string[];
|
|
564
|
-
} | {
|
|
565
|
-
type: 'labels_changed';
|
|
566
|
-
sessionId: string;
|
|
567
|
-
labels: string[];
|
|
568
|
-
} | {
|
|
569
|
-
type: 'connection_changed';
|
|
570
|
-
sessionId: string;
|
|
571
|
-
connectionSlug: string;
|
|
572
|
-
supportsBranching?: boolean;
|
|
573
|
-
} | {
|
|
574
|
-
type: 'task_backgrounded';
|
|
575
|
-
sessionId: string;
|
|
576
|
-
toolUseId: string;
|
|
577
|
-
taskId: string;
|
|
578
|
-
intent?: string;
|
|
579
|
-
turnId?: string;
|
|
580
|
-
} | {
|
|
581
|
-
type: 'shell_backgrounded';
|
|
582
|
-
sessionId: string;
|
|
583
|
-
toolUseId: string;
|
|
584
|
-
shellId: string;
|
|
585
|
-
intent?: string;
|
|
586
|
-
command?: string;
|
|
587
|
-
turnId?: string;
|
|
588
|
-
} | {
|
|
589
|
-
type: 'task_progress';
|
|
590
|
-
sessionId: string;
|
|
591
|
-
toolUseId: string;
|
|
592
|
-
elapsedSeconds: number;
|
|
593
|
-
turnId?: string;
|
|
594
|
-
} | {
|
|
595
|
-
type: 'task_completed';
|
|
596
|
-
sessionId: string;
|
|
597
|
-
taskId: string;
|
|
598
|
-
status: 'completed' | 'failed' | 'stopped';
|
|
599
|
-
outputFile?: string;
|
|
600
|
-
summary?: string;
|
|
601
|
-
turnId?: string;
|
|
602
|
-
} | {
|
|
603
|
-
type: 'shell_killed';
|
|
604
|
-
sessionId: string;
|
|
605
|
-
shellId: string;
|
|
606
|
-
} | {
|
|
607
|
-
type: 'user_message';
|
|
608
|
-
sessionId: string;
|
|
609
|
-
message: Message;
|
|
610
|
-
status: 'accepted' | 'queued' | 'processing';
|
|
611
|
-
optimisticMessageId?: string;
|
|
612
|
-
} | {
|
|
613
|
-
type: 'session_flagged';
|
|
614
|
-
sessionId: string;
|
|
615
|
-
} | {
|
|
616
|
-
type: 'session_unflagged';
|
|
617
|
-
sessionId: string;
|
|
618
|
-
} | {
|
|
619
|
-
type: 'session_archived';
|
|
620
|
-
sessionId: string;
|
|
621
|
-
} | {
|
|
622
|
-
type: 'session_unarchived';
|
|
623
|
-
sessionId: string;
|
|
624
|
-
} | {
|
|
625
|
-
type: 'name_changed';
|
|
626
|
-
sessionId: string;
|
|
627
|
-
name?: string;
|
|
628
|
-
} | {
|
|
629
|
-
type: 'session_model_changed';
|
|
630
|
-
sessionId: string;
|
|
631
|
-
model: string | null;
|
|
632
|
-
} | {
|
|
633
|
-
type: 'session_status_changed';
|
|
634
|
-
sessionId: string;
|
|
635
|
-
sessionStatus: SessionStatus;
|
|
636
|
-
} | {
|
|
637
|
-
type: 'session_deleted';
|
|
638
|
-
sessionId: string;
|
|
639
|
-
} | {
|
|
640
|
-
type: 'session_created';
|
|
641
|
-
sessionId: string;
|
|
642
|
-
} | {
|
|
643
|
-
type: 'session_shared';
|
|
644
|
-
sessionId: string;
|
|
645
|
-
sharedUrl: string;
|
|
646
|
-
} | {
|
|
647
|
-
type: 'session_unshared';
|
|
648
|
-
sessionId: string;
|
|
649
|
-
} | {
|
|
650
|
-
type: 'auth_request';
|
|
651
|
-
sessionId: string;
|
|
652
|
-
message: Message;
|
|
653
|
-
request: AuthRequest;
|
|
654
|
-
} | {
|
|
655
|
-
type: 'auth_completed';
|
|
656
|
-
sessionId: string;
|
|
657
|
-
requestId: string;
|
|
658
|
-
success: boolean;
|
|
659
|
-
cancelled?: boolean;
|
|
660
|
-
error?: string;
|
|
661
|
-
} | {
|
|
662
|
-
type: 'source_activated';
|
|
663
|
-
sessionId: string;
|
|
664
|
-
sourceSlug: string;
|
|
665
|
-
originalMessage: string;
|
|
666
|
-
} | {
|
|
667
|
-
type: 'usage_update';
|
|
668
|
-
sessionId: string;
|
|
669
|
-
tokenUsage: {
|
|
670
|
-
inputTokens: number;
|
|
671
|
-
contextWindow?: number;
|
|
672
|
-
};
|
|
673
|
-
} | {
|
|
674
|
-
type: 'message_annotations_updated';
|
|
675
|
-
sessionId: string;
|
|
676
|
-
messageId: string;
|
|
677
|
-
annotations: AnnotationV1[];
|
|
678
|
-
} | {
|
|
679
|
-
type: 'working_directory_error';
|
|
680
|
-
sessionId: string;
|
|
681
|
-
error: string;
|
|
682
|
-
};
|
|
683
|
-
interface SendMessageOptions {
|
|
684
|
-
skillSlugs?: string[];
|
|
685
|
-
badges?: ContentBadge[];
|
|
686
|
-
optimisticMessageId?: string;
|
|
687
|
-
}
|
|
688
|
-
type SessionCommand = {
|
|
689
|
-
type: 'flag';
|
|
690
|
-
} | {
|
|
691
|
-
type: 'unflag';
|
|
692
|
-
} | {
|
|
693
|
-
type: 'archive';
|
|
694
|
-
} | {
|
|
695
|
-
type: 'unarchive';
|
|
696
|
-
} | {
|
|
697
|
-
type: 'rename';
|
|
698
|
-
name: string;
|
|
699
|
-
} | {
|
|
700
|
-
type: 'setSessionStatus';
|
|
701
|
-
state: SessionStatus;
|
|
702
|
-
} | {
|
|
703
|
-
type: 'markRead';
|
|
704
|
-
} | {
|
|
705
|
-
type: 'markUnread';
|
|
706
|
-
} | {
|
|
707
|
-
type: 'setActiveViewing';
|
|
708
|
-
workspaceId: string;
|
|
709
|
-
} | {
|
|
710
|
-
type: 'setPermissionMode';
|
|
711
|
-
mode: PermissionMode;
|
|
712
|
-
} | {
|
|
713
|
-
type: 'setThinkingLevel';
|
|
714
|
-
level: ThinkingLevel;
|
|
715
|
-
} | {
|
|
716
|
-
type: 'updateWorkingDirectory';
|
|
717
|
-
dir: string;
|
|
718
|
-
} | {
|
|
719
|
-
type: 'setSources';
|
|
720
|
-
sourceSlugs: string[];
|
|
721
|
-
} | {
|
|
722
|
-
type: 'setLabels';
|
|
723
|
-
labels: string[];
|
|
724
|
-
} | {
|
|
725
|
-
type: 'showInFinder';
|
|
726
|
-
} | {
|
|
727
|
-
type: 'copyPath';
|
|
728
|
-
} | {
|
|
729
|
-
type: 'shareToViewer';
|
|
730
|
-
} | {
|
|
731
|
-
type: 'updateShare';
|
|
732
|
-
} | {
|
|
733
|
-
type: 'revokeShare';
|
|
734
|
-
} | {
|
|
735
|
-
type: 'refreshTitle';
|
|
736
|
-
} | {
|
|
737
|
-
type: 'setConnection';
|
|
738
|
-
connectionSlug: string;
|
|
739
|
-
} | {
|
|
740
|
-
type: 'setPendingPlanExecution';
|
|
741
|
-
planPath: string;
|
|
742
|
-
draftInputSnapshot?: string;
|
|
743
|
-
} | {
|
|
744
|
-
type: 'markCompactionComplete';
|
|
745
|
-
} | {
|
|
746
|
-
type: 'markPendingPlanExecutionDispatched';
|
|
747
|
-
} | {
|
|
748
|
-
type: 'clearPendingPlanExecution';
|
|
749
|
-
} | {
|
|
750
|
-
type: 'addAnnotation';
|
|
751
|
-
messageId: string;
|
|
752
|
-
annotation: AnnotationV1;
|
|
753
|
-
} | {
|
|
754
|
-
type: 'removeAnnotation';
|
|
755
|
-
messageId: string;
|
|
756
|
-
annotationId: string;
|
|
757
|
-
} | {
|
|
758
|
-
type: 'updateAnnotation';
|
|
759
|
-
messageId: string;
|
|
760
|
-
annotationId: string;
|
|
761
|
-
patch: Partial<AnnotationV1>;
|
|
762
|
-
};
|
|
763
|
-
interface NewChatActionParams {
|
|
764
|
-
input?: string;
|
|
765
|
-
name?: string;
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
/**
|
|
769
|
-
* Permission request with session context (for multi-session Electron app)
|
|
770
|
-
*/
|
|
771
|
-
interface PermissionRequest extends PermissionRequest$1 {
|
|
772
|
-
sessionId: string;
|
|
773
|
-
}
|
|
774
|
-
interface PermissionResponseOptions {
|
|
775
|
-
rememberForMinutes?: number;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
/**
|
|
779
|
-
* Credential request from agent — prompts user for credentials
|
|
780
|
-
* (e.g., API key, username/password, OAuth token)
|
|
781
|
-
*/
|
|
782
|
-
interface CredentialRequest {
|
|
783
|
-
requestId: string;
|
|
784
|
-
toolName: string;
|
|
785
|
-
description: string;
|
|
786
|
-
credentialMode?: CredentialInputMode;
|
|
787
|
-
headerName?: string;
|
|
788
|
-
headerNames?: string[];
|
|
789
|
-
labels?: {
|
|
790
|
-
credential?: string;
|
|
791
|
-
username?: string;
|
|
792
|
-
password?: string;
|
|
793
|
-
};
|
|
794
|
-
hint?: string;
|
|
795
|
-
sourceUrl?: string;
|
|
796
|
-
passwordRequired?: boolean;
|
|
797
|
-
}
|
|
798
|
-
/**
|
|
799
|
-
* Auth request — unified auth flow (credential or OAuth)
|
|
800
|
-
*/
|
|
801
|
-
interface AuthRequest {
|
|
802
|
-
requestId: string;
|
|
803
|
-
type: AuthRequestType;
|
|
804
|
-
sourceSlug?: string;
|
|
805
|
-
sourceName?: string;
|
|
806
|
-
description?: string;
|
|
807
|
-
credentialMode?: CredentialInputMode;
|
|
808
|
-
headerName?: string;
|
|
809
|
-
headerNames?: string[];
|
|
810
|
-
labels?: {
|
|
811
|
-
credential?: string;
|
|
812
|
-
username?: string;
|
|
813
|
-
password?: string;
|
|
814
|
-
};
|
|
815
|
-
hint?: string;
|
|
816
|
-
sourceUrl?: string;
|
|
817
|
-
passwordRequired?: boolean;
|
|
818
|
-
}
|
|
819
|
-
interface CredentialResponse {
|
|
820
|
-
type: 'credential';
|
|
821
|
-
value?: string;
|
|
822
|
-
username?: string;
|
|
823
|
-
password?: string;
|
|
824
|
-
headers?: Record<string, string>;
|
|
825
|
-
cancelled: boolean;
|
|
826
|
-
}
|
|
827
|
-
/** Server-side directory listing result (for remote directory browsing). */
|
|
828
|
-
interface DirectoryListingResult {
|
|
829
|
-
/** Normalized absolute path of the listed directory (after resolve(), not symlink-resolved). */
|
|
830
|
-
currentPath: string;
|
|
831
|
-
/** Parent directory path, or null if at root. */
|
|
832
|
-
parentPath: string | null;
|
|
833
|
-
/** Pre-split breadcrumb segments for display (computed server-side). */
|
|
834
|
-
breadcrumbs: Array<{
|
|
835
|
-
name: string;
|
|
836
|
-
path: string;
|
|
837
|
-
}>;
|
|
838
|
-
/** Server platform info. */
|
|
839
|
-
platform: 'win32' | 'darwin' | 'linux';
|
|
840
|
-
/** Whether the server truncated the directory list for safety/performance. */
|
|
841
|
-
truncated: boolean;
|
|
842
|
-
/** Total number of matching child directories before truncation. */
|
|
843
|
-
totalEntries: number;
|
|
844
|
-
/** Child directory entries. */
|
|
845
|
-
entries: Array<{
|
|
846
|
-
name: string;
|
|
847
|
-
path: string;
|
|
848
|
-
isSymlink: boolean;
|
|
849
|
-
}>;
|
|
850
|
-
}
|
|
851
|
-
interface FileAttachment {
|
|
852
|
-
type: 'image' | 'text' | 'pdf' | 'office' | 'audio' | 'unknown';
|
|
853
|
-
path: string;
|
|
854
|
-
name: string;
|
|
855
|
-
mimeType: string;
|
|
856
|
-
base64?: string;
|
|
857
|
-
text?: string;
|
|
858
|
-
size: number;
|
|
859
|
-
thumbnailBase64?: string;
|
|
860
|
-
}
|
|
861
|
-
interface SessionFile {
|
|
862
|
-
name: string;
|
|
863
|
-
path: string;
|
|
864
|
-
type: 'file' | 'directory';
|
|
865
|
-
size?: number;
|
|
866
|
-
children?: SessionFile[];
|
|
867
|
-
}
|
|
868
|
-
interface FileSearchResult {
|
|
869
|
-
name: string;
|
|
870
|
-
path: string;
|
|
871
|
-
type: 'file' | 'directory';
|
|
872
|
-
relativePath: string;
|
|
873
|
-
}
|
|
874
|
-
interface LlmConnectionSetup {
|
|
875
|
-
slug: string;
|
|
876
|
-
credential?: string;
|
|
877
|
-
baseUrl?: string | null;
|
|
878
|
-
defaultModel?: string | null;
|
|
879
|
-
models?: string[] | null;
|
|
880
|
-
piAuthProvider?: string;
|
|
881
|
-
modelSelectionMode?: 'automaticallySyncedFromProvider' | 'userDefined3Tier';
|
|
882
|
-
/** When true, reject setup if the connection doesn't already exist (reauth guard). */
|
|
883
|
-
updateOnly?: boolean;
|
|
884
|
-
/** Custom endpoint protocol for arbitrary OpenAI/Anthropic-compatible APIs */
|
|
885
|
-
customEndpoint?: Record<string, unknown>;
|
|
886
|
-
/** IAM credentials for Pi+Bedrock (piAuthProvider='amazon-bedrock') connections */
|
|
887
|
-
iamCredentials?: {
|
|
888
|
-
accessKeyId: string;
|
|
889
|
-
secretAccessKey: string;
|
|
890
|
-
sessionToken?: string;
|
|
891
|
-
};
|
|
892
|
-
/** AWS region for Pi+Bedrock connections */
|
|
893
|
-
awsRegion?: string;
|
|
894
|
-
/** Bedrock authentication method — determines auth type for Pi+Bedrock connections */
|
|
895
|
-
bedrockAuthMethod?: 'iam_credentials' | 'environment';
|
|
896
|
-
}
|
|
897
|
-
interface TestLlmConnectionParams {
|
|
898
|
-
provider: 'anthropic' | 'pi';
|
|
899
|
-
apiKey: string;
|
|
900
|
-
baseUrl?: string;
|
|
901
|
-
model?: string;
|
|
902
|
-
piAuthProvider?: string;
|
|
903
|
-
/** Optional custom endpoint protocol hint so setup tests mirror runtime routing */
|
|
904
|
-
customEndpoint?: Record<string, unknown>;
|
|
905
|
-
}
|
|
906
|
-
interface TestLlmConnectionResult {
|
|
907
|
-
success: boolean;
|
|
908
|
-
error?: string;
|
|
909
|
-
}
|
|
910
|
-
interface SkillFile {
|
|
911
|
-
name: string;
|
|
912
|
-
type: 'file' | 'directory';
|
|
913
|
-
size?: number;
|
|
914
|
-
children?: SkillFile[];
|
|
915
|
-
}
|
|
916
|
-
interface OAuthResult {
|
|
917
|
-
success: boolean;
|
|
918
|
-
error?: string;
|
|
919
|
-
}
|
|
920
|
-
interface McpValidationResult {
|
|
921
|
-
success: boolean;
|
|
922
|
-
error?: string;
|
|
923
|
-
tools?: string[];
|
|
924
|
-
}
|
|
925
|
-
interface McpToolWithPermission {
|
|
926
|
-
name: string;
|
|
927
|
-
description?: string;
|
|
928
|
-
allowed: boolean;
|
|
929
|
-
}
|
|
930
|
-
interface McpToolsResult {
|
|
931
|
-
success: boolean;
|
|
932
|
-
error?: string;
|
|
933
|
-
tools?: McpToolWithPermission[];
|
|
934
|
-
}
|
|
935
|
-
interface SessionSearchMatch {
|
|
936
|
-
sessionId: string;
|
|
937
|
-
lineNumber: number;
|
|
938
|
-
snippet: string;
|
|
939
|
-
}
|
|
940
|
-
interface SessionSearchResult {
|
|
941
|
-
sessionId: string;
|
|
942
|
-
matchCount: number;
|
|
943
|
-
matches: SessionSearchMatch[];
|
|
944
|
-
}
|
|
945
|
-
interface UnreadSummary {
|
|
946
|
-
totalUnreadSessions: number;
|
|
947
|
-
byWorkspace: Record<string, number>;
|
|
948
|
-
hasUnreadByWorkspace: Record<string, boolean>;
|
|
949
|
-
}
|
|
950
|
-
interface ShareResult {
|
|
951
|
-
success: boolean;
|
|
952
|
-
url?: string;
|
|
953
|
-
error?: string;
|
|
954
|
-
}
|
|
955
|
-
interface RefreshTitleResult {
|
|
956
|
-
success: boolean;
|
|
957
|
-
title?: string;
|
|
958
|
-
error?: string;
|
|
959
|
-
}
|
|
960
|
-
interface PlanStep {
|
|
961
|
-
id: string;
|
|
962
|
-
description: string;
|
|
963
|
-
tools?: string[];
|
|
964
|
-
status?: 'pending' | 'in_progress' | 'completed' | 'failed' | 'skipped';
|
|
965
|
-
}
|
|
966
|
-
interface Plan {
|
|
967
|
-
id: string;
|
|
968
|
-
title: string;
|
|
969
|
-
summary?: string;
|
|
970
|
-
steps: PlanStep[];
|
|
971
|
-
questions?: string[];
|
|
972
|
-
state?: 'creating' | 'refining' | 'ready' | 'executing' | 'completed' | 'cancelled';
|
|
973
|
-
createdAt?: number;
|
|
974
|
-
updatedAt?: number;
|
|
975
|
-
}
|
|
976
|
-
interface GitBashStatus {
|
|
977
|
-
found: boolean;
|
|
978
|
-
path: string | null;
|
|
979
|
-
platform: 'win32' | 'darwin' | 'linux';
|
|
980
|
-
}
|
|
981
|
-
interface UpdateInfo {
|
|
982
|
-
available: boolean;
|
|
983
|
-
currentVersion: string;
|
|
984
|
-
latestVersion: string | null;
|
|
985
|
-
downloadState: 'idle' | 'downloading' | 'ready' | 'installing' | 'error';
|
|
986
|
-
downloadProgress: number;
|
|
987
|
-
error?: string;
|
|
988
|
-
}
|
|
989
|
-
interface WorkspaceSettings {
|
|
990
|
-
name?: string;
|
|
991
|
-
model?: string;
|
|
992
|
-
permissionMode?: PermissionMode;
|
|
993
|
-
cyclablePermissionModes?: PermissionMode[];
|
|
994
|
-
thinkingLevel?: ThinkingLevel;
|
|
995
|
-
workingDirectory?: string;
|
|
996
|
-
localMcpEnabled?: boolean;
|
|
997
|
-
defaultLlmConnection?: string;
|
|
998
|
-
enabledSourceSlugs?: string[];
|
|
999
|
-
}
|
|
1000
|
-
interface ClaudeOAuthResult {
|
|
1001
|
-
success: boolean;
|
|
1002
|
-
token?: string;
|
|
1003
|
-
error?: string;
|
|
1004
|
-
}
|
|
1005
|
-
type TestAutomationAction = {
|
|
1006
|
-
type: 'prompt';
|
|
1007
|
-
prompt: string;
|
|
1008
|
-
llmConnection?: string;
|
|
1009
|
-
model?: string;
|
|
1010
|
-
thinkingLevel?: ThinkingLevel;
|
|
1011
|
-
} | {
|
|
1012
|
-
type: 'webhook';
|
|
1013
|
-
url: string;
|
|
1014
|
-
method?: string;
|
|
1015
|
-
headers?: Record<string, string>;
|
|
1016
|
-
bodyFormat?: 'json' | 'form' | 'raw';
|
|
1017
|
-
body?: unknown;
|
|
1018
|
-
captureResponse?: boolean;
|
|
1019
|
-
auth?: {
|
|
1020
|
-
type: 'basic';
|
|
1021
|
-
username: string;
|
|
1022
|
-
password: string;
|
|
1023
|
-
} | {
|
|
1024
|
-
type: 'bearer';
|
|
1025
|
-
token: string;
|
|
1026
|
-
};
|
|
1027
|
-
};
|
|
1028
|
-
interface TestAutomationPayload {
|
|
1029
|
-
workspaceId: string;
|
|
1030
|
-
automationId?: string;
|
|
1031
|
-
automationName?: string;
|
|
1032
|
-
actions: TestAutomationAction[];
|
|
1033
|
-
permissionMode?: PermissionMode;
|
|
1034
|
-
labels?: string[];
|
|
1035
|
-
/** Forwarded from the matcher; routes test-run sessions into a Telegram topic when paired. */
|
|
1036
|
-
telegramTopic?: string;
|
|
1037
|
-
}
|
|
1038
|
-
type TestAutomationActionResult = {
|
|
1039
|
-
type: 'prompt';
|
|
1040
|
-
success: boolean;
|
|
1041
|
-
stderr?: string;
|
|
1042
|
-
sessionId?: string;
|
|
1043
|
-
duration: number;
|
|
1044
|
-
} | {
|
|
1045
|
-
type: 'webhook';
|
|
1046
|
-
success: boolean;
|
|
1047
|
-
url: string;
|
|
1048
|
-
statusCode: number;
|
|
1049
|
-
error?: string;
|
|
1050
|
-
duration: number;
|
|
1051
|
-
};
|
|
1052
|
-
interface TestAutomationResult {
|
|
1053
|
-
actions: TestAutomationActionResult[];
|
|
1054
|
-
}
|
|
1055
|
-
type WindowCloseRequestSource = 'keyboard-shortcut' | 'window-button' | 'unknown';
|
|
1056
|
-
interface WindowCloseRequest {
|
|
1057
|
-
source: WindowCloseRequestSource;
|
|
1058
|
-
}
|
|
1059
|
-
interface BrowserInstanceInfo {
|
|
1060
|
-
id: string;
|
|
1061
|
-
url: string;
|
|
1062
|
-
title: string;
|
|
1063
|
-
favicon: string | null;
|
|
1064
|
-
isLoading: boolean;
|
|
1065
|
-
canGoBack: boolean;
|
|
1066
|
-
canGoForward: boolean;
|
|
1067
|
-
boundSessionId: string | null;
|
|
1068
|
-
ownerType: 'session' | 'manual';
|
|
1069
|
-
ownerSessionId: string | null;
|
|
1070
|
-
isVisible: boolean;
|
|
1071
|
-
agentControlActive: boolean;
|
|
1072
|
-
themeColor: string | null;
|
|
1073
|
-
}
|
|
1074
|
-
interface DeepLinkNavigation {
|
|
1075
|
-
view?: string;
|
|
1076
|
-
tabType?: string;
|
|
1077
|
-
tabParams?: Record<string, string>;
|
|
1078
|
-
action?: string;
|
|
1079
|
-
actionParams?: Record<string, string>;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
/**
|
|
1083
|
-
* RPC channel names — organized by domain namespace.
|
|
1084
|
-
* Wire-format strings (values) are the stable API contract.
|
|
1085
|
-
* Key paths are internal and may be reorganized freely.
|
|
1086
|
-
*/
|
|
1087
|
-
declare const RPC_CHANNELS: {
|
|
1088
|
-
readonly remote: {
|
|
1089
|
-
readonly TEST_CONNECTION: "remote:testConnection";
|
|
1090
|
-
};
|
|
1091
|
-
readonly server: {
|
|
1092
|
-
readonly GET_WORKSPACES: "server:getWorkspaces";
|
|
1093
|
-
readonly CREATE_WORKSPACE: "server:createWorkspace";
|
|
1094
|
-
readonly GET_STATUS: "server:getStatus";
|
|
1095
|
-
readonly GET_HEALTH: "server:getHealth";
|
|
1096
|
-
readonly GET_ACTIVE_SESSIONS: "server:getActiveSessions";
|
|
1097
|
-
readonly SHUTTING_DOWN: "server:shuttingDown";
|
|
1098
|
-
readonly STATUS_CHANGED: "server:statusChanged";
|
|
1099
|
-
readonly HOME_DIR: "server:homeDir";
|
|
1100
|
-
};
|
|
1101
|
-
readonly sessions: {
|
|
1102
|
-
readonly GET: "sessions:get";
|
|
1103
|
-
readonly GET_UNREAD_SUMMARY: "sessions:getUnreadSummary";
|
|
1104
|
-
readonly MARK_ALL_READ: "sessions:markAllRead";
|
|
1105
|
-
readonly UNREAD_SUMMARY_CHANGED: "sessions:unreadSummaryChanged";
|
|
1106
|
-
readonly CREATE: "sessions:create";
|
|
1107
|
-
readonly DELETE: "sessions:delete";
|
|
1108
|
-
readonly GET_MESSAGES: "sessions:getMessages";
|
|
1109
|
-
readonly SEND_MESSAGE: "sessions:sendMessage";
|
|
1110
|
-
readonly CANCEL: "sessions:cancel";
|
|
1111
|
-
readonly KILL_SHELL: "sessions:killShell";
|
|
1112
|
-
readonly RESPOND_TO_PERMISSION: "sessions:respondToPermission";
|
|
1113
|
-
readonly RESPOND_TO_CREDENTIAL: "sessions:respondToCredential";
|
|
1114
|
-
readonly COMMAND: "sessions:command";
|
|
1115
|
-
readonly GET_PENDING_PLAN_EXECUTION: "sessions:getPendingPlanExecution";
|
|
1116
|
-
readonly GET_PERMISSION_MODE_STATE: "sessions:getPermissionModeState";
|
|
1117
|
-
readonly EVENT: "session:event";
|
|
1118
|
-
readonly GET_MODEL: "session:getModel";
|
|
1119
|
-
readonly SET_MODEL: "session:setModel";
|
|
1120
|
-
readonly GET_FILES: "sessions:getFiles";
|
|
1121
|
-
readonly GET_NOTES: "sessions:getNotes";
|
|
1122
|
-
readonly SET_NOTES: "sessions:setNotes";
|
|
1123
|
-
readonly WATCH_FILES: "sessions:watchFiles";
|
|
1124
|
-
readonly UNWATCH_FILES: "sessions:unwatchFiles";
|
|
1125
|
-
readonly FILES_CHANGED: "sessions:filesChanged";
|
|
1126
|
-
readonly SEARCH_CONTENT: "sessions:searchContent";
|
|
1127
|
-
readonly EXPORT: "sessions:export";
|
|
1128
|
-
readonly IMPORT: "sessions:import";
|
|
1129
|
-
readonly EXPORT_REMOTE_TRANSFER: "sessions:exportRemoteTransfer";
|
|
1130
|
-
readonly IMPORT_REMOTE_TRANSFER: "sessions:importRemoteTransfer";
|
|
1131
|
-
};
|
|
1132
|
-
readonly transfer: {
|
|
1133
|
-
readonly START: "transfer:start";
|
|
1134
|
-
readonly CHUNK: "transfer:chunk";
|
|
1135
|
-
readonly COMMIT: "transfer:commit";
|
|
1136
|
-
readonly ABORT: "transfer:abort";
|
|
1137
|
-
};
|
|
1138
|
-
readonly tasks: {
|
|
1139
|
-
readonly GET_OUTPUT: "tasks:getOutput";
|
|
1140
|
-
};
|
|
1141
|
-
readonly workspaces: {
|
|
1142
|
-
readonly GET: "workspaces:get";
|
|
1143
|
-
readonly CREATE: "workspaces:create";
|
|
1144
|
-
readonly CHECK_SLUG: "workspaces:checkSlug";
|
|
1145
|
-
readonly UPDATE_REMOTE: "workspaces:updateRemote";
|
|
1146
|
-
};
|
|
1147
|
-
readonly window: {
|
|
1148
|
-
readonly GET_WORKSPACE: "window:getWorkspace";
|
|
1149
|
-
readonly GET_MODE: "window:getMode";
|
|
1150
|
-
readonly OPEN_WORKSPACE: "window:openWorkspace";
|
|
1151
|
-
readonly OPEN_SESSION_IN_NEW_WINDOW: "window:openSessionInNewWindow";
|
|
1152
|
-
readonly SWITCH_WORKSPACE: "window:switchWorkspace";
|
|
1153
|
-
readonly CLOSE: "window:close";
|
|
1154
|
-
readonly CLOSE_REQUESTED: "window:closeRequested";
|
|
1155
|
-
readonly CONFIRM_CLOSE: "window:confirmClose";
|
|
1156
|
-
readonly CANCEL_CLOSE: "window:cancelClose";
|
|
1157
|
-
readonly SET_TRAFFIC_LIGHTS: "window:setTrafficLights";
|
|
1158
|
-
readonly FOCUS_STATE: "window:focusState";
|
|
1159
|
-
readonly GET_FOCUS_STATE: "window:getFocusState";
|
|
1160
|
-
};
|
|
1161
|
-
readonly file: {
|
|
1162
|
-
readonly READ: "file:read";
|
|
1163
|
-
readonly READ_DATA_URL: "file:readDataUrl";
|
|
1164
|
-
readonly READ_PREVIEW_DATA_URL: "file:readPreviewDataUrl";
|
|
1165
|
-
readonly READ_BINARY: "file:readBinary";
|
|
1166
|
-
readonly OPEN_DIALOG: "file:openDialog";
|
|
1167
|
-
readonly READ_ATTACHMENT: "file:readAttachment";
|
|
1168
|
-
readonly READ_USER_ATTACHMENT: "file:readUserAttachment";
|
|
1169
|
-
readonly STORE_ATTACHMENT: "file:storeAttachment";
|
|
1170
|
-
readonly GENERATE_THUMBNAIL: "file:generateThumbnail";
|
|
1171
|
-
};
|
|
1172
|
-
readonly fs: {
|
|
1173
|
-
readonly SEARCH: "fs:search";
|
|
1174
|
-
readonly LIST_DIRECTORY: "fs:listDirectory";
|
|
1175
|
-
};
|
|
1176
|
-
readonly debug: {
|
|
1177
|
-
readonly LOG: "debug:log";
|
|
1178
|
-
};
|
|
1179
|
-
readonly theme: {
|
|
1180
|
-
readonly GET_SYSTEM_PREFERENCE: "theme:getSystemPreference";
|
|
1181
|
-
readonly SYSTEM_CHANGED: "theme:systemChanged";
|
|
1182
|
-
readonly APP_CHANGED: "theme:appChanged";
|
|
1183
|
-
readonly GET_APP: "theme:getApp";
|
|
1184
|
-
readonly GET_PRESETS: "theme:getPresets";
|
|
1185
|
-
readonly LOAD_PRESET: "theme:loadPreset";
|
|
1186
|
-
readonly GET_COLOR_THEME: "theme:getColorTheme";
|
|
1187
|
-
readonly SET_COLOR_THEME: "theme:setColorTheme";
|
|
1188
|
-
readonly BROADCAST_PREFERENCES: "theme:broadcastPreferences";
|
|
1189
|
-
readonly PREFERENCES_CHANGED: "theme:preferencesChanged";
|
|
1190
|
-
readonly GET_WORKSPACE_COLOR_THEME: "theme:getWorkspaceColorTheme";
|
|
1191
|
-
readonly SET_WORKSPACE_COLOR_THEME: "theme:setWorkspaceColorTheme";
|
|
1192
|
-
readonly GET_ALL_WORKSPACE_THEMES: "theme:getAllWorkspaceThemes";
|
|
1193
|
-
readonly BROADCAST_WORKSPACE_THEME: "theme:broadcastWorkspaceTheme";
|
|
1194
|
-
readonly WORKSPACE_THEME_CHANGED: "theme:workspaceThemeChanged";
|
|
1195
|
-
};
|
|
1196
|
-
readonly system: {
|
|
1197
|
-
readonly VERSIONS: "system:versions";
|
|
1198
|
-
readonly HOME_DIR: "system:homeDir";
|
|
1199
|
-
readonly IS_DEBUG_MODE: "system:isDebugMode";
|
|
1200
|
-
};
|
|
1201
|
-
readonly update: {
|
|
1202
|
-
readonly CHECK: "update:check";
|
|
1203
|
-
readonly GET_INFO: "update:getInfo";
|
|
1204
|
-
readonly INSTALL: "update:install";
|
|
1205
|
-
readonly DISMISS: "update:dismiss";
|
|
1206
|
-
readonly GET_DISMISSED: "update:getDismissed";
|
|
1207
|
-
readonly AVAILABLE: "update:available";
|
|
1208
|
-
readonly DOWNLOAD_PROGRESS: "update:downloadProgress";
|
|
1209
|
-
};
|
|
1210
|
-
readonly shell: {
|
|
1211
|
-
readonly OPEN_URL: "shell:openUrl";
|
|
1212
|
-
readonly OPEN_FILE: "shell:openFile";
|
|
1213
|
-
readonly SHOW_IN_FOLDER: "shell:showInFolder";
|
|
1214
|
-
};
|
|
1215
|
-
readonly menu: {
|
|
1216
|
-
readonly NEW_CHAT: "menu:newChat";
|
|
1217
|
-
readonly NEW_WINDOW: "menu:newWindow";
|
|
1218
|
-
readonly OPEN_SETTINGS: "menu:openSettings";
|
|
1219
|
-
readonly KEYBOARD_SHORTCUTS: "menu:keyboardShortcuts";
|
|
1220
|
-
readonly TOGGLE_FOCUS_MODE: "menu:toggleFocusMode";
|
|
1221
|
-
readonly TOGGLE_SIDEBAR: "menu:toggleSidebar";
|
|
1222
|
-
readonly QUIT: "menu:quit";
|
|
1223
|
-
readonly MINIMIZE: "menu:minimize";
|
|
1224
|
-
readonly MAXIMIZE: "menu:maximize";
|
|
1225
|
-
readonly ZOOM_IN: "menu:zoomIn";
|
|
1226
|
-
readonly ZOOM_OUT: "menu:zoomOut";
|
|
1227
|
-
readonly ZOOM_RESET: "menu:zoomReset";
|
|
1228
|
-
readonly TOGGLE_DEV_TOOLS: "menu:toggleDevTools";
|
|
1229
|
-
readonly UNDO: "menu:undo";
|
|
1230
|
-
readonly REDO: "menu:redo";
|
|
1231
|
-
readonly CUT: "menu:cut";
|
|
1232
|
-
readonly COPY: "menu:copy";
|
|
1233
|
-
readonly PASTE: "menu:paste";
|
|
1234
|
-
readonly SELECT_ALL: "menu:selectAll";
|
|
1235
|
-
};
|
|
1236
|
-
readonly deeplink: {
|
|
1237
|
-
readonly NAVIGATE: "deeplink:navigate";
|
|
1238
|
-
};
|
|
1239
|
-
readonly auth: {
|
|
1240
|
-
readonly LOGOUT: "auth:logout";
|
|
1241
|
-
readonly SHOW_LOGOUT_CONFIRMATION: "auth:showLogoutConfirmation";
|
|
1242
|
-
readonly SHOW_DELETE_SESSION_CONFIRMATION: "auth:showDeleteSessionConfirmation";
|
|
1243
|
-
};
|
|
1244
|
-
readonly credentials: {
|
|
1245
|
-
readonly HEALTH_CHECK: "credentials:healthCheck";
|
|
1246
|
-
};
|
|
1247
|
-
readonly onboarding: {
|
|
1248
|
-
readonly GET_AUTH_STATE: "onboarding:getAuthState";
|
|
1249
|
-
readonly VALIDATE_MCP: "onboarding:validateMcp";
|
|
1250
|
-
readonly START_MCP_OAUTH: "onboarding:startMcpOAuth";
|
|
1251
|
-
readonly START_CLAUDE_OAUTH: "onboarding:startClaudeOAuth";
|
|
1252
|
-
readonly EXCHANGE_CLAUDE_CODE: "onboarding:exchangeClaudeCode";
|
|
1253
|
-
readonly HAS_CLAUDE_OAUTH_STATE: "onboarding:hasClaudeOAuthState";
|
|
1254
|
-
readonly CLEAR_CLAUDE_OAUTH_STATE: "onboarding:clearClaudeOAuthState";
|
|
1255
|
-
readonly DEFER_SETUP: "onboarding:deferSetup";
|
|
1256
|
-
};
|
|
1257
|
-
readonly llmConnections: {
|
|
1258
|
-
readonly LIST: "LLM_Connection:list";
|
|
1259
|
-
readonly LIST_WITH_STATUS: "LLM_Connection:listWithStatus";
|
|
1260
|
-
readonly GET: "LLM_Connection:get";
|
|
1261
|
-
readonly GET_API_KEY: "LLM_Connection:getApiKey";
|
|
1262
|
-
readonly SAVE: "LLM_Connection:save";
|
|
1263
|
-
readonly DELETE: "LLM_Connection:delete";
|
|
1264
|
-
readonly TEST: "LLM_Connection:test";
|
|
1265
|
-
readonly SET_DEFAULT: "LLM_Connection:setDefault";
|
|
1266
|
-
readonly SET_WORKSPACE_DEFAULT: "LLM_Connection:setWorkspaceDefault";
|
|
1267
|
-
readonly REFRESH_MODELS: "LLM_Connection:refreshModels";
|
|
1268
|
-
readonly CHANGED: "LLM_Connection:changed";
|
|
1269
|
-
};
|
|
1270
|
-
readonly chatgpt: {
|
|
1271
|
-
readonly START_OAUTH: "chatgpt:startOAuth";
|
|
1272
|
-
readonly COMPLETE_OAUTH: "chatgpt:completeOAuth";
|
|
1273
|
-
readonly CANCEL_OAUTH: "chatgpt:cancelOAuth";
|
|
1274
|
-
readonly GET_AUTH_STATUS: "chatgpt:getAuthStatus";
|
|
1275
|
-
readonly LOGOUT: "chatgpt:logout";
|
|
1276
|
-
};
|
|
1277
|
-
readonly copilot: {
|
|
1278
|
-
readonly START_OAUTH: "copilot:startOAuth";
|
|
1279
|
-
readonly CANCEL_OAUTH: "copilot:cancelOAuth";
|
|
1280
|
-
readonly GET_AUTH_STATUS: "copilot:getAuthStatus";
|
|
1281
|
-
readonly LOGOUT: "copilot:logout";
|
|
1282
|
-
readonly DEVICE_CODE: "copilot:deviceCode";
|
|
1283
|
-
};
|
|
1284
|
-
readonly settings: {
|
|
1285
|
-
readonly SETUP_LLM_CONNECTION: "settings:setupLlmConnection";
|
|
1286
|
-
readonly TEST_LLM_CONNECTION_SETUP: "settings:testLlmConnectionSetup";
|
|
1287
|
-
readonly GET_DEFAULT_THINKING_LEVEL: "settings:getDefaultThinkingLevel";
|
|
1288
|
-
readonly SET_DEFAULT_THINKING_LEVEL: "settings:setDefaultThinkingLevel";
|
|
1289
|
-
readonly GET_NETWORK_PROXY: "settings:getNetworkProxy";
|
|
1290
|
-
readonly SET_NETWORK_PROXY: "settings:setNetworkProxy";
|
|
1291
|
-
readonly GET_SERVER_CONFIG: "settings:getServerConfig";
|
|
1292
|
-
readonly SET_SERVER_CONFIG: "settings:setServerConfig";
|
|
1293
|
-
readonly GET_SERVER_STATUS: "settings:getServerStatus";
|
|
1294
|
-
};
|
|
1295
|
-
readonly pi: {
|
|
1296
|
-
readonly GET_API_KEY_PROVIDERS: "pi:getApiKeyProviders";
|
|
1297
|
-
readonly GET_PROVIDER_BASE_URL: "pi:getProviderBaseUrl";
|
|
1298
|
-
readonly GET_PROVIDER_MODELS: "pi:getProviderModels";
|
|
1299
|
-
};
|
|
1300
|
-
readonly dialog: {
|
|
1301
|
-
readonly OPEN_FOLDER: "dialog:openFolder";
|
|
1302
|
-
};
|
|
1303
|
-
readonly preferences: {
|
|
1304
|
-
readonly READ: "preferences:read";
|
|
1305
|
-
readonly WRITE: "preferences:write";
|
|
1306
|
-
};
|
|
1307
|
-
readonly drafts: {
|
|
1308
|
-
readonly GET: "drafts:get";
|
|
1309
|
-
readonly SET: "drafts:set";
|
|
1310
|
-
readonly DELETE: "drafts:delete";
|
|
1311
|
-
readonly GET_ALL: "drafts:getAll";
|
|
1312
|
-
};
|
|
1313
|
-
readonly sources: {
|
|
1314
|
-
readonly GET: "sources:get";
|
|
1315
|
-
readonly CREATE: "sources:create";
|
|
1316
|
-
readonly DELETE: "sources:delete";
|
|
1317
|
-
readonly START_OAUTH: "sources:startOAuth";
|
|
1318
|
-
readonly SAVE_CREDENTIALS: "sources:saveCredentials";
|
|
1319
|
-
readonly CHANGED: "sources:changed";
|
|
1320
|
-
readonly GET_PERMISSIONS: "sources:getPermissions";
|
|
1321
|
-
readonly GET_MCP_TOOLS: "sources:getMcpTools";
|
|
1322
|
-
};
|
|
1323
|
-
readonly oauth: {
|
|
1324
|
-
readonly START: "oauth:start";
|
|
1325
|
-
readonly COMPLETE: "oauth:complete";
|
|
1326
|
-
readonly CANCEL: "oauth:cancel";
|
|
1327
|
-
readonly REVOKE: "oauth:revoke";
|
|
1328
|
-
};
|
|
1329
|
-
readonly workspace: {
|
|
1330
|
-
readonly GET_PERMISSIONS: "workspace:getPermissions";
|
|
1331
|
-
readonly READ_IMAGE: "workspace:readImage";
|
|
1332
|
-
readonly WRITE_IMAGE: "workspace:writeImage";
|
|
1333
|
-
readonly SETTINGS_GET: "workspaceSettings:get";
|
|
1334
|
-
readonly SETTINGS_UPDATE: "workspaceSettings:update";
|
|
1335
|
-
};
|
|
1336
|
-
readonly permissions: {
|
|
1337
|
-
readonly GET_DEFAULTS: "permissions:getDefaults";
|
|
1338
|
-
readonly DEFAULTS_CHANGED: "permissions:defaultsChanged";
|
|
1339
|
-
};
|
|
1340
|
-
readonly skills: {
|
|
1341
|
-
readonly GET: "skills:get";
|
|
1342
|
-
readonly GET_FILES: "skills:getFiles";
|
|
1343
|
-
readonly DELETE: "skills:delete";
|
|
1344
|
-
readonly OPEN_EDITOR: "skills:openEditor";
|
|
1345
|
-
readonly OPEN_FINDER: "skills:openFinder";
|
|
1346
|
-
readonly CHANGED: "skills:changed";
|
|
1347
|
-
};
|
|
1348
|
-
readonly statuses: {
|
|
1349
|
-
readonly LIST: "statuses:list";
|
|
1350
|
-
readonly REORDER: "statuses:reorder";
|
|
1351
|
-
readonly CHANGED: "statuses:changed";
|
|
1352
|
-
};
|
|
1353
|
-
readonly labels: {
|
|
1354
|
-
readonly LIST: "labels:list";
|
|
1355
|
-
readonly CREATE: "labels:create";
|
|
1356
|
-
readonly DELETE: "labels:delete";
|
|
1357
|
-
readonly CHANGED: "labels:changed";
|
|
1358
|
-
};
|
|
1359
|
-
readonly views: {
|
|
1360
|
-
readonly LIST: "views:list";
|
|
1361
|
-
readonly SAVE: "views:save";
|
|
1362
|
-
};
|
|
1363
|
-
readonly toolIcons: {
|
|
1364
|
-
readonly GET_MAPPINGS: "toolIcons:getMappings";
|
|
1365
|
-
};
|
|
1366
|
-
readonly logo: {
|
|
1367
|
-
readonly GET_URL: "logo:getUrl";
|
|
1368
|
-
};
|
|
1369
|
-
readonly notification: {
|
|
1370
|
-
readonly SHOW: "notification:show";
|
|
1371
|
-
readonly NAVIGATE: "notification:navigate";
|
|
1372
|
-
readonly GET_ENABLED: "notification:getEnabled";
|
|
1373
|
-
readonly SET_ENABLED: "notification:setEnabled";
|
|
1374
|
-
};
|
|
1375
|
-
readonly input: {
|
|
1376
|
-
readonly GET_AUTO_CAPITALISATION: "input:getAutoCapitalisation";
|
|
1377
|
-
readonly SET_AUTO_CAPITALISATION: "input:setAutoCapitalisation";
|
|
1378
|
-
readonly GET_SEND_MESSAGE_KEY: "input:getSendMessageKey";
|
|
1379
|
-
readonly SET_SEND_MESSAGE_KEY: "input:setSendMessageKey";
|
|
1380
|
-
readonly GET_SPELL_CHECK: "input:getSpellCheck";
|
|
1381
|
-
readonly SET_SPELL_CHECK: "input:setSpellCheck";
|
|
1382
|
-
};
|
|
1383
|
-
readonly power: {
|
|
1384
|
-
readonly GET_KEEP_AWAKE: "power:getKeepAwake";
|
|
1385
|
-
readonly SET_KEEP_AWAKE: "power:setKeepAwake";
|
|
1386
|
-
};
|
|
1387
|
-
readonly appearance: {
|
|
1388
|
-
readonly GET_RICH_TOOL_DESCRIPTIONS: "appearance:getRichToolDescriptions";
|
|
1389
|
-
readonly SET_RICH_TOOL_DESCRIPTIONS: "appearance:setRichToolDescriptions";
|
|
1390
|
-
};
|
|
1391
|
-
readonly tools: {
|
|
1392
|
-
readonly GET_BROWSER_TOOL_ENABLED: "tools:getBrowserToolEnabled";
|
|
1393
|
-
readonly SET_BROWSER_TOOL_ENABLED: "tools:setBrowserToolEnabled";
|
|
1394
|
-
};
|
|
1395
|
-
readonly caching: {
|
|
1396
|
-
readonly GET_EXTENDED_PROMPT_CACHE: "caching:getExtendedPromptCache";
|
|
1397
|
-
readonly SET_EXTENDED_PROMPT_CACHE: "caching:setExtendedPromptCache";
|
|
1398
|
-
readonly GET_ENABLE_1M_CONTEXT: "caching:getEnable1MContext";
|
|
1399
|
-
readonly SET_ENABLE_1M_CONTEXT: "caching:setEnable1MContext";
|
|
1400
|
-
};
|
|
1401
|
-
readonly badge: {
|
|
1402
|
-
readonly REFRESH: "badge:refresh";
|
|
1403
|
-
readonly SET_ICON: "badge:setIcon";
|
|
1404
|
-
readonly DRAW: "badge:draw";
|
|
1405
|
-
readonly DRAW_WINDOWS: "badge:draw-windows";
|
|
1406
|
-
};
|
|
1407
|
-
readonly releaseNotes: {
|
|
1408
|
-
readonly GET: "releaseNotes:get";
|
|
1409
|
-
readonly GET_LATEST_VERSION: "releaseNotes:getLatestVersion";
|
|
1410
|
-
};
|
|
1411
|
-
readonly git: {
|
|
1412
|
-
readonly GET_BRANCH: "git:getBranch";
|
|
1413
|
-
};
|
|
1414
|
-
readonly gitbash: {
|
|
1415
|
-
readonly CHECK: "gitbash:check";
|
|
1416
|
-
readonly BROWSE: "gitbash:browse";
|
|
1417
|
-
readonly SET_PATH: "gitbash:setPath";
|
|
1418
|
-
};
|
|
1419
|
-
readonly browserPane: {
|
|
1420
|
-
readonly CREATE: "browser-pane:create";
|
|
1421
|
-
readonly DESTROY: "browser-pane:destroy";
|
|
1422
|
-
readonly LIST: "browser-pane:list";
|
|
1423
|
-
readonly NAVIGATE: "browser-pane:navigate";
|
|
1424
|
-
readonly GO_BACK: "browser-pane:go-back";
|
|
1425
|
-
readonly GO_FORWARD: "browser-pane:go-forward";
|
|
1426
|
-
readonly RELOAD: "browser-pane:reload";
|
|
1427
|
-
readonly STOP: "browser-pane:stop";
|
|
1428
|
-
readonly FOCUS: "browser-pane:focus";
|
|
1429
|
-
readonly SNAPSHOT: "browser-pane:snapshot";
|
|
1430
|
-
readonly CLICK: "browser-pane:click";
|
|
1431
|
-
readonly FILL: "browser-pane:fill";
|
|
1432
|
-
readonly SELECT: "browser-pane:select";
|
|
1433
|
-
readonly SCREENSHOT: "browser-pane:screenshot";
|
|
1434
|
-
readonly EVALUATE: "browser-pane:evaluate";
|
|
1435
|
-
readonly SCROLL: "browser-pane:scroll";
|
|
1436
|
-
readonly LAUNCH: "browser-empty-state:launch";
|
|
1437
|
-
readonly STATE_CHANGED: "browser-pane:state-changed";
|
|
1438
|
-
readonly REMOVED: "browser-pane:removed";
|
|
1439
|
-
readonly INTERACTED: "browser-pane:interacted";
|
|
1440
|
-
};
|
|
1441
|
-
readonly automations: {
|
|
1442
|
-
readonly GET: "automations:get";
|
|
1443
|
-
readonly TEST: "automations:test";
|
|
1444
|
-
readonly SET_ENABLED: "automations:setEnabled";
|
|
1445
|
-
readonly DUPLICATE: "automations:duplicate";
|
|
1446
|
-
readonly DELETE: "automations:delete";
|
|
1447
|
-
readonly GET_HISTORY: "automations:getHistory";
|
|
1448
|
-
readonly GET_LAST_EXECUTED: "automations:getLastExecuted";
|
|
1449
|
-
readonly REPLAY: "automations:replay";
|
|
1450
|
-
readonly CHANGED: "automations:changed";
|
|
1451
|
-
};
|
|
1452
|
-
readonly resources: {
|
|
1453
|
-
readonly EXPORT: "resources:export";
|
|
1454
|
-
readonly IMPORT: "resources:import";
|
|
1455
|
-
};
|
|
1456
|
-
readonly messaging: {
|
|
1457
|
-
readonly WA_REGISTER: "messaging:wa:register";
|
|
1458
|
-
readonly WA_INCOMING: "messaging:wa:incoming";
|
|
1459
|
-
readonly WA_BUTTON_PRESS: "messaging:wa:buttonPress";
|
|
1460
|
-
readonly WA_STATUS: "messaging:wa:status";
|
|
1461
|
-
readonly WA_QR: "messaging:wa:qr";
|
|
1462
|
-
readonly WA_SEND: "messaging:wa:send";
|
|
1463
|
-
readonly WA_SEND_BUTTONS: "messaging:wa:sendButtons";
|
|
1464
|
-
readonly WA_SEND_TYPING: "messaging:wa:sendTyping";
|
|
1465
|
-
readonly WA_SEND_FILE: "messaging:wa:sendFile";
|
|
1466
|
-
readonly WA_CONNECT: "messaging:wa:connect";
|
|
1467
|
-
readonly WA_DISCONNECT: "messaging:wa:disconnect";
|
|
1468
|
-
readonly BINDING_CHANGED: "messaging:bindingChanged";
|
|
1469
|
-
readonly PLATFORM_STATUS: "messaging:platformStatus";
|
|
1470
|
-
/** Broadcast when the workspace's pending-senders list mutates. */
|
|
1471
|
-
readonly PENDING_CHANGED: "messaging:pendingChanged";
|
|
1472
|
-
readonly GET_CONFIG: "messaging:getConfig";
|
|
1473
|
-
readonly UPDATE_CONFIG: "messaging:updateConfig";
|
|
1474
|
-
readonly TEST_TELEGRAM: "messaging:testTelegram";
|
|
1475
|
-
readonly SAVE_TELEGRAM: "messaging:saveTelegram";
|
|
1476
|
-
readonly TEST_LARK: "messaging:testLark";
|
|
1477
|
-
readonly SAVE_LARK: "messaging:saveLark";
|
|
1478
|
-
readonly DISCONNECT: "messaging:disconnect";
|
|
1479
|
-
readonly FORGET: "messaging:forget";
|
|
1480
|
-
readonly GET_BINDINGS: "messaging:getBindings";
|
|
1481
|
-
readonly GENERATE_CODE: "messaging:generateCode";
|
|
1482
|
-
readonly UNBIND: "messaging:unbind";
|
|
1483
|
-
readonly UNBIND_BINDING: "messaging:unbindBinding";
|
|
1484
|
-
/** Workspace-supergroup pairing (Telegram forum support). UI ↔ Server. */
|
|
1485
|
-
readonly GENERATE_SUPERGROUP_CODE: "messaging:generateSupergroupCode";
|
|
1486
|
-
readonly GET_SUPERGROUP: "messaging:getSupergroup";
|
|
1487
|
-
readonly UNBIND_SUPERGROUP: "messaging:unbindSupergroup";
|
|
1488
|
-
readonly WA_START_CONNECT: "messaging:wa:startConnect";
|
|
1489
|
-
readonly WA_SUBMIT_PHONE: "messaging:wa:submitPhone";
|
|
1490
|
-
/** Broadcast to UI clients: QR string, pairing code, status, unavailable, error. */
|
|
1491
|
-
readonly WA_UI_EVENT: "messaging:wa:uiEvent";
|
|
1492
|
-
readonly GET_PLATFORM_OWNERS: "messaging:access:getOwners";
|
|
1493
|
-
readonly SET_PLATFORM_OWNERS: "messaging:access:setOwners";
|
|
1494
|
-
readonly GET_PLATFORM_ACCESS_MODE: "messaging:access:getMode";
|
|
1495
|
-
readonly SET_PLATFORM_ACCESS_MODE: "messaging:access:setMode";
|
|
1496
|
-
readonly GET_PENDING_SENDERS: "messaging:access:getPending";
|
|
1497
|
-
readonly DISMISS_PENDING_SENDER: "messaging:access:dismissPending";
|
|
1498
|
-
readonly ALLOW_PENDING_SENDER: "messaging:access:allowPending";
|
|
1499
|
-
readonly SET_BINDING_ACCESS: "messaging:access:setBindingAccess";
|
|
1500
|
-
};
|
|
1501
|
-
};
|
|
1502
|
-
|
|
1503
|
-
/**
|
|
1504
|
-
* Typed event map for server → client push channels.
|
|
1505
|
-
* Keys are channel string literals, values are argument tuples.
|
|
1506
|
-
*/
|
|
1507
|
-
|
|
1508
|
-
interface BroadcastEventMap {
|
|
1509
|
-
[RPC_CHANNELS.sessions.EVENT]: [event: SessionEvent];
|
|
1510
|
-
[RPC_CHANNELS.sessions.UNREAD_SUMMARY_CHANGED]: [summary: UnreadSummary];
|
|
1511
|
-
[RPC_CHANNELS.sessions.FILES_CHANGED]: [sessionId: string];
|
|
1512
|
-
[RPC_CHANNELS.sources.CHANGED]: [workspaceId: string, sources: unknown[]];
|
|
1513
|
-
[RPC_CHANNELS.labels.CHANGED]: [workspaceId: string];
|
|
1514
|
-
[RPC_CHANNELS.statuses.CHANGED]: [workspaceId: string];
|
|
1515
|
-
[RPC_CHANNELS.automations.CHANGED]: [workspaceId: string];
|
|
1516
|
-
[RPC_CHANNELS.skills.CHANGED]: [workspaceId: string, skills: unknown[]];
|
|
1517
|
-
[RPC_CHANNELS.llmConnections.CHANGED]: [];
|
|
1518
|
-
[RPC_CHANNELS.permissions.DEFAULTS_CHANGED]: [value: null];
|
|
1519
|
-
[RPC_CHANNELS.theme.APP_CHANGED]: [theme: Record<string, unknown> | null];
|
|
1520
|
-
[RPC_CHANNELS.theme.SYSTEM_CHANGED]: [isDark: boolean];
|
|
1521
|
-
[RPC_CHANNELS.theme.PREFERENCES_CHANGED]: [preferences: {
|
|
1522
|
-
mode: string;
|
|
1523
|
-
colorTheme: string;
|
|
1524
|
-
font: string;
|
|
1525
|
-
}];
|
|
1526
|
-
[RPC_CHANNELS.theme.WORKSPACE_THEME_CHANGED]: [data: {
|
|
1527
|
-
workspaceId: string;
|
|
1528
|
-
themeId: string | null;
|
|
1529
|
-
}];
|
|
1530
|
-
[RPC_CHANNELS.update.AVAILABLE]: [info: UpdateInfo];
|
|
1531
|
-
[RPC_CHANNELS.update.DOWNLOAD_PROGRESS]: [progress: number];
|
|
1532
|
-
[RPC_CHANNELS.badge.DRAW]: [data: {
|
|
1533
|
-
count: number;
|
|
1534
|
-
iconDataUrl: string;
|
|
1535
|
-
}];
|
|
1536
|
-
[RPC_CHANNELS.badge.DRAW_WINDOWS]: [data: {
|
|
1537
|
-
count: number;
|
|
1538
|
-
}];
|
|
1539
|
-
[RPC_CHANNELS.window.FOCUS_STATE]: [isFocused: boolean];
|
|
1540
|
-
[RPC_CHANNELS.window.CLOSE_REQUESTED]: [];
|
|
1541
|
-
[RPC_CHANNELS.browserPane.STATE_CHANGED]: [info: BrowserInstanceInfo];
|
|
1542
|
-
[RPC_CHANNELS.browserPane.REMOVED]: [id: string];
|
|
1543
|
-
[RPC_CHANNELS.browserPane.INTERACTED]: [id: string];
|
|
1544
|
-
[RPC_CHANNELS.notification.NAVIGATE]: [data: {
|
|
1545
|
-
workspaceId: string;
|
|
1546
|
-
sessionId: string;
|
|
1547
|
-
}];
|
|
1548
|
-
[RPC_CHANNELS.deeplink.NAVIGATE]: [navigation: DeepLinkNavigation];
|
|
1549
|
-
[RPC_CHANNELS.copilot.DEVICE_CODE]: [data: {
|
|
1550
|
-
userCode: string;
|
|
1551
|
-
verificationUri: string;
|
|
1552
|
-
}];
|
|
1553
|
-
[RPC_CHANNELS.menu.NEW_CHAT]: [];
|
|
1554
|
-
[RPC_CHANNELS.menu.OPEN_SETTINGS]: [];
|
|
1555
|
-
[RPC_CHANNELS.menu.KEYBOARD_SHORTCUTS]: [];
|
|
1556
|
-
[RPC_CHANNELS.menu.TOGGLE_FOCUS_MODE]: [];
|
|
1557
|
-
[RPC_CHANNELS.menu.TOGGLE_SIDEBAR]: [];
|
|
1558
|
-
[RPC_CHANNELS.messaging.BINDING_CHANGED]: [workspaceId: string];
|
|
1559
|
-
[RPC_CHANNELS.messaging.PLATFORM_STATUS]: [workspaceId: string, platform: string, connected: boolean];
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
interface ParsedMentions {
|
|
1563
|
-
skills: string[];
|
|
1564
|
-
invalidSkills: string[];
|
|
1565
|
-
sources: string[];
|
|
1566
|
-
files: string[];
|
|
1567
|
-
folders: string[];
|
|
1568
|
-
}
|
|
1569
|
-
interface MentionMatch {
|
|
1570
|
-
type: 'skill' | 'source' | 'file' | 'folder';
|
|
1571
|
-
id: string;
|
|
1572
|
-
fullMatch: string;
|
|
1573
|
-
startIndex: number;
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
declare function parseMentions(text: string, availableSkillSlugs: string[], availableSourceSlugs: string[]): ParsedMentions;
|
|
1577
|
-
declare function resolveSkillMentions(text: string, skillNames: Map<string, string>): string;
|
|
1578
|
-
declare function resolveSourceMentions(text: string): string;
|
|
1579
|
-
declare function resolvePathMentions(text: string, workingDirectory?: string): Promise<string>;
|
|
1580
|
-
declare function resolveFileMentions(text: string, workingDirectory?: string): Promise<string>;
|
|
1581
|
-
declare function stripAllMentions(text: string): string;
|
|
1582
|
-
declare function findMentionMatches(text: string, availableSkillSlugs: string[], availableSourceSlugs: string[]): MentionMatch[];
|
|
1583
|
-
|
|
1584
|
-
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 };
|
|
1585
|
-
|
|
1586
|
-
// -- @weft/core/types/index.d.ts --
|
|
1587
|
-
/**
|
|
1588
|
-
* Workspace and authentication types
|
|
1589
|
-
*/
|
|
1590
|
-
/**
|
|
1591
|
-
* How MCP server should be authenticated (workspace-level)
|
|
1592
|
-
* Note: Different from SourceMcpAuthType which uses 'oauth' | 'bearer' | 'none' for individual sources
|
|
1593
|
-
*/
|
|
1594
|
-
type McpAuthType = 'workspace_oauth' | 'workspace_bearer' | 'public';
|
|
1595
|
-
/**
|
|
1596
|
-
* Configuration for a remote Agent Server.
|
|
1597
|
-
* When set on a workspace, handler calls are proxied over WebSocket.
|
|
1598
|
-
*/
|
|
1599
|
-
interface RemoteServerConfig {
|
|
1600
|
-
url: string;
|
|
1601
|
-
token: string;
|
|
1602
|
-
remoteWorkspaceId: string;
|
|
1603
|
-
}
|
|
1604
|
-
/**
|
|
1605
|
-
* Client-facing workspace DTO — safe to send over RPC to remote clients.
|
|
1606
|
-
* Does not expose server-internal filesystem paths.
|
|
1607
|
-
*/
|
|
1608
|
-
interface WorkspaceInfo {
|
|
1609
|
-
id: string;
|
|
1610
|
-
name: string;
|
|
1611
|
-
slug: string;
|
|
1612
|
-
lastAccessedAt?: number;
|
|
1613
|
-
iconUrl?: string;
|
|
1614
|
-
mcpUrl?: string;
|
|
1615
|
-
mcpAuthType?: McpAuthType;
|
|
1616
|
-
remoteServer?: RemoteServerConfig;
|
|
1617
|
-
}
|
|
1618
|
-
/**
|
|
1619
|
-
* Full workspace with server-internal details.
|
|
1620
|
-
* Used by server code and local Electron renderer (LOCAL_ONLY channels).
|
|
1621
|
-
*/
|
|
1622
|
-
interface Workspace extends WorkspaceInfo {
|
|
1623
|
-
rootPath: string;
|
|
1624
|
-
createdAt: number;
|
|
1625
|
-
}
|
|
1626
|
-
/**
|
|
1627
|
-
* Authentication type for AI provider
|
|
1628
|
-
* - api_key: Anthropic API key
|
|
1629
|
-
* - oauth_token: Claude Max OAuth (Anthropic)
|
|
1630
|
-
* - codex_oauth: ChatGPT Plus OAuth via Codex app-server
|
|
1631
|
-
* - codex_api_key: OpenAI API key via Codex (OpenRouter, Vercel AI Gateway compatible)
|
|
1632
|
-
* - provider_owned: Auth is owned by the provider tool itself
|
|
1633
|
-
* (Claude Code uses `~/.claude`, Codex uses `~/.codex`).
|
|
1634
|
-
* Weft never injects credentials — it detects and delegates.
|
|
1635
|
-
*/
|
|
1636
|
-
type AuthType = 'api_key' | 'oauth_token' | 'codex_oauth' | 'codex_api_key' | 'provider_owned';
|
|
1637
|
-
/**
|
|
1638
|
-
* OAuth credentials from a fresh authentication flow.
|
|
1639
|
-
* Used for temporary state in UI components before saving to credential store.
|
|
1640
|
-
*/
|
|
1641
|
-
interface OAuthCredentials {
|
|
1642
|
-
accessToken: string;
|
|
1643
|
-
refreshToken?: string;
|
|
1644
|
-
expiresAt?: number;
|
|
1645
|
-
clientId: string;
|
|
1646
|
-
tokenType: string;
|
|
1647
|
-
}
|
|
1648
|
-
interface StoredConfig {
|
|
1649
|
-
authType?: AuthType;
|
|
1650
|
-
workspaces: Workspace[];
|
|
1651
|
-
activeWorkspaceId: string | null;
|
|
1652
|
-
activeSessionId: string | null;
|
|
1653
|
-
model?: string;
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
/**
|
|
1657
|
-
* Message types for conversations
|
|
1658
|
-
*/
|
|
1659
|
-
/**
|
|
1660
|
-
* Message roles for display (runtime)
|
|
1661
|
-
*/
|
|
1662
|
-
type MessageRole = 'user' | 'assistant' | 'tool' | 'error' | 'status' | 'info' | 'warning' | 'plan' | 'auth-request';
|
|
1663
|
-
/**
|
|
1664
|
-
* Credential input modes for different auth types
|
|
1665
|
-
*/
|
|
1666
|
-
type CredentialInputMode = 'bearer' | 'basic' | 'header' | 'query' | 'multi-header';
|
|
1667
|
-
/**
|
|
1668
|
-
* Auth request types
|
|
1669
|
-
*/
|
|
1670
|
-
type AuthRequestType = 'credential' | 'oauth' | 'oauth-google' | 'oauth-slack' | 'oauth-microsoft';
|
|
1671
|
-
/**
|
|
1672
|
-
* Auth request status
|
|
1673
|
-
*/
|
|
1674
|
-
type AuthStatus = 'pending' | 'completed' | 'cancelled' | 'failed';
|
|
1675
|
-
/**
|
|
1676
|
-
* Tool execution status
|
|
1677
|
-
*/
|
|
1678
|
-
type ToolStatus = 'pending' | 'executing' | 'completed' | 'error' | 'backgrounded';
|
|
1679
|
-
/**
|
|
1680
|
-
* Tool display metadata - embedded at storage time for viewer compatibility
|
|
1681
|
-
* Icons are base64-encoded to work in both Electron and web viewer
|
|
1682
|
-
*/
|
|
1683
|
-
interface ToolDisplayMeta {
|
|
1684
|
-
/** Display name for the tool (e.g., "Commit", "Linear") */
|
|
1685
|
-
displayName: string;
|
|
1686
|
-
/** Base64-encoded icon as data URL (e.g., "data:image/png;base64,...") - 32x32px */
|
|
1687
|
-
iconDataUrl?: string;
|
|
1688
|
-
/** Description of what this tool does */
|
|
1689
|
-
description?: string;
|
|
1690
|
-
/** Category for grouping/styling */
|
|
1691
|
-
category?: 'skill' | 'source' | 'native' | 'mcp';
|
|
1692
|
-
}
|
|
1693
|
-
/**
|
|
1694
|
-
* Attachment type categories
|
|
1695
|
-
*/
|
|
1696
|
-
type AttachmentType = 'image' | 'text' | 'pdf' | 'office' | 'audio' | 'unknown';
|
|
1697
|
-
/**
|
|
1698
|
-
* Attachment preview for display in user messages (runtime, before storage)
|
|
1699
|
-
*/
|
|
1700
|
-
interface MessageAttachment {
|
|
1701
|
-
type: AttachmentType;
|
|
1702
|
-
name: string;
|
|
1703
|
-
mimeType: string;
|
|
1704
|
-
size: number;
|
|
1705
|
-
base64?: string;
|
|
1706
|
-
}
|
|
1707
|
-
/**
|
|
1708
|
-
* Content badge for inline display in user messages
|
|
1709
|
-
* Badges are self-contained with all display data (label, icon)
|
|
1710
|
-
*/
|
|
1711
|
-
interface ContentBadge {
|
|
1712
|
-
/** Badge type - used for fallback icon if iconBase64 not available */
|
|
1713
|
-
type: 'source' | 'skill' | 'context' | 'command' | 'file' | 'folder';
|
|
1714
|
-
/** Display label (e.g., "Linear", "Commit") */
|
|
1715
|
-
label: string;
|
|
1716
|
-
/** Original text pattern (e.g., "@linear", "@commit") */
|
|
1717
|
-
rawText: string;
|
|
1718
|
-
/** Icon as data URL (e.g., "data:image/png;base64,...") - preserves mime type */
|
|
1719
|
-
iconDataUrl?: string;
|
|
1720
|
-
/** Start position in content string */
|
|
1721
|
-
start: number;
|
|
1722
|
-
/** End position in content string */
|
|
1723
|
-
end: number;
|
|
1724
|
-
/**
|
|
1725
|
-
* Collapsed label for context badges (e.g., "Edit: Permissions")
|
|
1726
|
-
* When set, the badge replaces the entire marked range with this label
|
|
1727
|
-
* and hides the original content
|
|
1728
|
-
*/
|
|
1729
|
-
collapsedLabel?: string;
|
|
1730
|
-
/**
|
|
1731
|
-
* File path for file badges - stores the full path for click handler
|
|
1732
|
-
* Used when the badge represents a clickable file reference
|
|
1733
|
-
*/
|
|
1734
|
-
filePath?: string;
|
|
1735
|
-
}
|
|
1736
|
-
/**
|
|
1737
|
-
* Author metadata for annotations
|
|
1738
|
-
*/
|
|
1739
|
-
interface AnnotationAuthor {
|
|
1740
|
-
id: string;
|
|
1741
|
-
name?: string;
|
|
1742
|
-
type?: 'user' | 'agent' | 'system';
|
|
1743
|
-
}
|
|
1744
|
-
/**
|
|
1745
|
-
* Annotation body payloads (extensible)
|
|
1746
|
-
*/
|
|
1747
|
-
type AnnotationBody = {
|
|
1748
|
-
type: 'highlight';
|
|
1749
|
-
} | {
|
|
1750
|
-
type: 'note';
|
|
1751
|
-
text: string;
|
|
1752
|
-
format?: 'plain' | 'markdown';
|
|
1753
|
-
} | {
|
|
1754
|
-
type: 'tag';
|
|
1755
|
-
value: string;
|
|
1756
|
-
};
|
|
1757
|
-
/**
|
|
1758
|
-
* Annotation intent (tight v1 semantics).
|
|
1759
|
-
*/
|
|
1760
|
-
type AnnotationIntent = 'highlight' | 'comment' | 'question';
|
|
1761
|
-
/**
|
|
1762
|
-
* Optional lifecycle status for annotation workflows.
|
|
1763
|
-
*/
|
|
1764
|
-
type AnnotationStatus = 'pending' | 'acknowledged' | 'resolved' | 'dismissed';
|
|
1765
|
-
/**
|
|
1766
|
-
* Block types for block selectors.
|
|
1767
|
-
*/
|
|
1768
|
-
type AnnotationBlockType = 'paragraph' | 'code' | 'latex' | 'mermaid' | 'datatable' | 'spreadsheet' | 'image-preview' | 'pdf-preview' | 'html-preview';
|
|
1769
|
-
/**
|
|
1770
|
-
* Selector union used to anchor an annotation target.
|
|
1771
|
-
* Multiple selectors can be stored for robust fallback resolution.
|
|
1772
|
-
*/
|
|
1773
|
-
type AnnotationSelector = {
|
|
1774
|
-
type: 'text-quote';
|
|
1775
|
-
exact: string;
|
|
1776
|
-
prefix?: string;
|
|
1777
|
-
suffix?: string;
|
|
1778
|
-
} | {
|
|
1779
|
-
type: 'text-position';
|
|
1780
|
-
start: number;
|
|
1781
|
-
end: number;
|
|
1782
|
-
textVersion?: string;
|
|
1783
|
-
} | {
|
|
1784
|
-
type: 'block';
|
|
1785
|
-
blockType: AnnotationBlockType;
|
|
1786
|
-
path: string;
|
|
1787
|
-
blockId?: string;
|
|
1788
|
-
} | {
|
|
1789
|
-
type: 'xywh';
|
|
1790
|
-
unit: 'pixel' | 'percent';
|
|
1791
|
-
x: number;
|
|
1792
|
-
y: number;
|
|
1793
|
-
w: number;
|
|
1794
|
-
h: number;
|
|
1795
|
-
page?: number;
|
|
1796
|
-
rotation?: number;
|
|
1797
|
-
} | {
|
|
1798
|
-
type: 'table-cell';
|
|
1799
|
-
rowKey: string | number;
|
|
1800
|
-
columnKey: string;
|
|
1801
|
-
};
|
|
1802
|
-
/**
|
|
1803
|
-
* Annotation target definition.
|
|
1804
|
-
*/
|
|
1805
|
-
interface AnnotationTarget {
|
|
1806
|
-
source: {
|
|
1807
|
-
sessionId: string;
|
|
1808
|
-
messageId: string;
|
|
1809
|
-
};
|
|
1810
|
-
selectors: AnnotationSelector[];
|
|
1811
|
-
}
|
|
1812
|
-
/**
|
|
1813
|
-
* Persisted annotation payload (schema-versioned for migration safety).
|
|
1814
|
-
*/
|
|
1815
|
-
interface AnnotationV1 {
|
|
1816
|
-
id: string;
|
|
1817
|
-
schemaVersion: 1;
|
|
1818
|
-
createdAt: number;
|
|
1819
|
-
updatedAt?: number;
|
|
1820
|
-
createdBy?: AnnotationAuthor;
|
|
1821
|
-
deletedAt?: number;
|
|
1822
|
-
body: AnnotationBody[];
|
|
1823
|
-
target: AnnotationTarget;
|
|
1824
|
-
/** Optional workflow intent (tight v1 semantics). */
|
|
1825
|
-
intent?: AnnotationIntent;
|
|
1826
|
-
/** Optional lifecycle status. */
|
|
1827
|
-
status?: AnnotationStatus;
|
|
1828
|
-
/** Optional reference to the conversation/thread around this annotation. */
|
|
1829
|
-
threadRef?: {
|
|
1830
|
-
threadId?: string;
|
|
1831
|
-
sessionId?: string;
|
|
1832
|
-
};
|
|
1833
|
-
style?: {
|
|
1834
|
-
color?: 'yellow' | 'green' | 'blue' | 'pink' | string;
|
|
1835
|
-
opacity?: number;
|
|
1836
|
-
};
|
|
1837
|
-
meta?: Record<string, unknown>;
|
|
1838
|
-
}
|
|
1839
|
-
/**
|
|
1840
|
-
* Stored attachment metadata (persisted to disk, no base64)
|
|
1841
|
-
* Created when user sends a message with attachments
|
|
1842
|
-
*/
|
|
1843
|
-
interface StoredAttachment {
|
|
1844
|
-
id: string;
|
|
1845
|
-
type: AttachmentType;
|
|
1846
|
-
name: string;
|
|
1847
|
-
mimeType: string;
|
|
1848
|
-
size: number;
|
|
1849
|
-
originalSize?: number;
|
|
1850
|
-
storedPath: string;
|
|
1851
|
-
thumbnailPath?: string;
|
|
1852
|
-
thumbnailBase64?: string;
|
|
1853
|
-
markdownPath?: string;
|
|
1854
|
-
wasResized?: boolean;
|
|
1855
|
-
resizedBase64?: string;
|
|
1856
|
-
}
|
|
1857
|
-
/**
|
|
1858
|
-
* Runtime message type (includes transient fields like isStreaming)
|
|
1859
|
-
*/
|
|
1860
|
-
interface Message {
|
|
1861
|
-
id: string;
|
|
1862
|
-
role: MessageRole;
|
|
1863
|
-
content: string;
|
|
1864
|
-
timestamp: number;
|
|
1865
|
-
toolName?: string;
|
|
1866
|
-
toolUseId?: string;
|
|
1867
|
-
toolInput?: Record<string, unknown>;
|
|
1868
|
-
toolResult?: string;
|
|
1869
|
-
toolStatus?: ToolStatus;
|
|
1870
|
-
toolDuration?: number;
|
|
1871
|
-
toolIntent?: string;
|
|
1872
|
-
toolDisplayName?: string;
|
|
1873
|
-
/** Tool display metadata with base64 icon - embedded at storage time for viewer */
|
|
1874
|
-
toolDisplayMeta?: ToolDisplayMeta;
|
|
1875
|
-
parentToolUseId?: string;
|
|
1876
|
-
taskId?: string;
|
|
1877
|
-
shellId?: string;
|
|
1878
|
-
elapsedSeconds?: number;
|
|
1879
|
-
isBackground?: boolean;
|
|
1880
|
-
attachments?: StoredAttachment[];
|
|
1881
|
-
badges?: ContentBadge[];
|
|
1882
|
-
/** Annotation payloads for this message */
|
|
1883
|
-
annotations?: AnnotationV1[];
|
|
1884
|
-
isError?: boolean;
|
|
1885
|
-
isStreaming?: boolean;
|
|
1886
|
-
isPending?: boolean;
|
|
1887
|
-
isQueued?: boolean;
|
|
1888
|
-
isIntermediate?: boolean;
|
|
1889
|
-
turnId?: string;
|
|
1890
|
-
statusType?: 'compacting' | 'compaction_complete';
|
|
1891
|
-
infoLevel?: 'info' | 'warning' | 'error' | 'success';
|
|
1892
|
-
errorCode?: string;
|
|
1893
|
-
errorTitle?: string;
|
|
1894
|
-
errorDetails?: string[];
|
|
1895
|
-
errorOriginal?: string;
|
|
1896
|
-
errorCanRetry?: boolean;
|
|
1897
|
-
errorActions?: Array<{
|
|
1898
|
-
key: string;
|
|
1899
|
-
label: string;
|
|
1900
|
-
action?: 'retry' | 'settings' | 'reauth' | 'open_url' | 'reconnect_source';
|
|
1901
|
-
url?: string;
|
|
1902
|
-
sourceSlug?: string;
|
|
1903
|
-
}>;
|
|
1904
|
-
planPath?: string;
|
|
1905
|
-
authRequestId?: string;
|
|
1906
|
-
authRequestType?: AuthRequestType;
|
|
1907
|
-
authSourceSlug?: string;
|
|
1908
|
-
authSourceName?: string;
|
|
1909
|
-
authStatus?: AuthStatus;
|
|
1910
|
-
authCredentialMode?: CredentialInputMode;
|
|
1911
|
-
authHeaderName?: string;
|
|
1912
|
-
authHeaderNames?: string[];
|
|
1913
|
-
authLabels?: {
|
|
1914
|
-
credential?: string;
|
|
1915
|
-
username?: string;
|
|
1916
|
-
password?: string;
|
|
1917
|
-
};
|
|
1918
|
-
authDescription?: string;
|
|
1919
|
-
authHint?: string;
|
|
1920
|
-
authSourceUrl?: string;
|
|
1921
|
-
authPasswordRequired?: boolean;
|
|
1922
|
-
authError?: string;
|
|
1923
|
-
authEmail?: string;
|
|
1924
|
-
authWorkspace?: string;
|
|
1925
|
-
}
|
|
1926
|
-
/**
|
|
1927
|
-
* Stored message format (persistence)
|
|
1928
|
-
* Excludes transient runtime-only fields (isStreaming, isPending)
|
|
1929
|
-
*/
|
|
1930
|
-
interface StoredMessage {
|
|
1931
|
-
id: string;
|
|
1932
|
-
type: MessageRole;
|
|
1933
|
-
content: string;
|
|
1934
|
-
timestamp?: number;
|
|
1935
|
-
toolName?: string;
|
|
1936
|
-
toolUseId?: string;
|
|
1937
|
-
toolInput?: Record<string, unknown>;
|
|
1938
|
-
toolResult?: string;
|
|
1939
|
-
toolStatus?: ToolStatus;
|
|
1940
|
-
toolDuration?: number;
|
|
1941
|
-
toolIntent?: string;
|
|
1942
|
-
toolDisplayName?: string;
|
|
1943
|
-
/** Tool display metadata with base64 icon - embedded at storage time for viewer */
|
|
1944
|
-
toolDisplayMeta?: ToolDisplayMeta;
|
|
1945
|
-
parentToolUseId?: string;
|
|
1946
|
-
taskId?: string;
|
|
1947
|
-
shellId?: string;
|
|
1948
|
-
elapsedSeconds?: number;
|
|
1949
|
-
isBackground?: boolean;
|
|
1950
|
-
isError?: boolean;
|
|
1951
|
-
/** Stored attachments for user messages (persisted to disk) */
|
|
1952
|
-
attachments?: StoredAttachment[];
|
|
1953
|
-
/** Content badges for inline display (sources, skills) */
|
|
1954
|
-
badges?: ContentBadge[];
|
|
1955
|
-
/** Annotations persisted at message level */
|
|
1956
|
-
annotations?: AnnotationV1[];
|
|
1957
|
-
isIntermediate?: boolean;
|
|
1958
|
-
turnId?: string;
|
|
1959
|
-
statusType?: 'compacting' | 'compaction_complete';
|
|
1960
|
-
infoLevel?: 'info' | 'warning' | 'error' | 'success';
|
|
1961
|
-
errorCode?: string;
|
|
1962
|
-
errorTitle?: string;
|
|
1963
|
-
errorDetails?: string[];
|
|
1964
|
-
errorOriginal?: string;
|
|
1965
|
-
errorCanRetry?: boolean;
|
|
1966
|
-
errorActions?: Array<{
|
|
1967
|
-
key: string;
|
|
1968
|
-
label: string;
|
|
1969
|
-
action?: 'retry' | 'settings' | 'reauth' | 'open_url' | 'reconnect_source';
|
|
1970
|
-
url?: string;
|
|
1971
|
-
sourceSlug?: string;
|
|
1972
|
-
}>;
|
|
1973
|
-
planPath?: string;
|
|
1974
|
-
authRequestId?: string;
|
|
1975
|
-
authRequestType?: AuthRequestType;
|
|
1976
|
-
authSourceSlug?: string;
|
|
1977
|
-
authSourceName?: string;
|
|
1978
|
-
authStatus?: AuthStatus;
|
|
1979
|
-
authCredentialMode?: CredentialInputMode;
|
|
1980
|
-
authHeaderName?: string;
|
|
1981
|
-
authHeaderNames?: string[];
|
|
1982
|
-
authLabels?: {
|
|
1983
|
-
credential?: string;
|
|
1984
|
-
username?: string;
|
|
1985
|
-
password?: string;
|
|
1986
|
-
};
|
|
1987
|
-
authDescription?: string;
|
|
1988
|
-
authHint?: string;
|
|
1989
|
-
authSourceUrl?: string;
|
|
1990
|
-
authPasswordRequired?: boolean;
|
|
1991
|
-
authError?: string;
|
|
1992
|
-
authEmail?: string;
|
|
1993
|
-
authWorkspace?: string;
|
|
1994
|
-
isQueued?: boolean;
|
|
1995
|
-
}
|
|
1996
|
-
/**
|
|
1997
|
-
* Token usage tracking
|
|
1998
|
-
*/
|
|
1999
|
-
interface TokenUsage {
|
|
2000
|
-
inputTokens: number;
|
|
2001
|
-
outputTokens: number;
|
|
2002
|
-
totalTokens: number;
|
|
2003
|
-
contextTokens: number;
|
|
2004
|
-
costUsd: number;
|
|
2005
|
-
cacheReadTokens?: number;
|
|
2006
|
-
cacheCreationTokens?: number;
|
|
2007
|
-
}
|
|
2008
|
-
/**
|
|
2009
|
-
* Recovery action for typed errors
|
|
2010
|
-
*/
|
|
2011
|
-
interface RecoveryAction {
|
|
2012
|
-
/** Keyboard shortcut (single letter) */
|
|
2013
|
-
key: string;
|
|
2014
|
-
/** Description of the action */
|
|
2015
|
-
label: string;
|
|
2016
|
-
/** Slash command to execute (e.g., '/settings') */
|
|
2017
|
-
command?: string;
|
|
2018
|
-
/** Custom action type for special handling */
|
|
2019
|
-
action?: 'retry' | 'settings' | 'reauth' | 'open_url' | 'reconnect_source';
|
|
2020
|
-
/** URL to open (for open_url action) */
|
|
2021
|
-
url?: string;
|
|
2022
|
-
/** Source slug (for reconnect_source action) */
|
|
2023
|
-
sourceSlug?: string;
|
|
2024
|
-
}
|
|
2025
|
-
/**
|
|
2026
|
-
* Error codes for typed errors - must match AgentError.code in shared/agent/errors.ts
|
|
2027
|
-
*/
|
|
2028
|
-
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';
|
|
2029
|
-
/**
|
|
2030
|
-
* Typed error from agent
|
|
2031
|
-
*/
|
|
2032
|
-
interface TypedError {
|
|
2033
|
-
/** Error code for programmatic handling */
|
|
2034
|
-
code: ErrorCode;
|
|
2035
|
-
/** User-friendly title */
|
|
2036
|
-
title: string;
|
|
2037
|
-
/** Detailed message explaining what went wrong */
|
|
2038
|
-
message: string;
|
|
2039
|
-
/** Suggested recovery actions */
|
|
2040
|
-
actions: RecoveryAction[];
|
|
2041
|
-
/** Whether auto-retry is possible */
|
|
2042
|
-
canRetry: boolean;
|
|
2043
|
-
/** Retry delay in ms (if canRetry is true) */
|
|
2044
|
-
retryDelayMs?: number;
|
|
2045
|
-
/** Diagnostic check results for debugging */
|
|
2046
|
-
details?: string[];
|
|
2047
|
-
/** Original error message for debugging */
|
|
2048
|
-
originalError?: string;
|
|
2049
|
-
}
|
|
2050
|
-
/**
|
|
2051
|
-
* Permission request type categories
|
|
2052
|
-
*/
|
|
2053
|
-
type PermissionRequestType = 'bash' | 'file_write' | 'mcp_mutation' | 'api_mutation' | 'admin_approval';
|
|
2054
|
-
/**
|
|
2055
|
-
* Permission request from agent (e.g., bash command approval)
|
|
2056
|
-
*/
|
|
2057
|
-
interface PermissionRequest {
|
|
2058
|
-
requestId: string;
|
|
2059
|
-
toolName: string;
|
|
2060
|
-
command?: string;
|
|
2061
|
-
description: string;
|
|
2062
|
-
type?: PermissionRequestType;
|
|
2063
|
-
/** Friendly app/package label for admin approval prompts */
|
|
2064
|
-
appName?: string;
|
|
2065
|
-
/** Plain-language reason shown in admin approval prompt */
|
|
2066
|
-
reason?: string;
|
|
2067
|
-
/** Plain-language impact shown in admin approval prompt */
|
|
2068
|
-
impact?: string;
|
|
2069
|
-
/** Whether native OS auth prompt is expected */
|
|
2070
|
-
requiresSystemPrompt?: boolean;
|
|
2071
|
-
/** Optional remember window for this exact command */
|
|
2072
|
-
rememberForMinutes?: number;
|
|
2073
|
-
/** Hash binding for approval integrity checks */
|
|
2074
|
-
commandHash?: string;
|
|
2075
|
-
/** Approval validity window */
|
|
2076
|
-
approvalTtlSeconds?: number;
|
|
2077
|
-
}
|
|
2078
|
-
/**
|
|
2079
|
-
* Usage data emitted by the agent runtime in 'complete' events
|
|
2080
|
-
* Note: This is a subset of TokenUsage - totalTokens/contextTokens are computed by consumers
|
|
2081
|
-
*/
|
|
2082
|
-
interface AgentEventUsage {
|
|
2083
|
-
inputTokens: number;
|
|
2084
|
-
outputTokens: number;
|
|
2085
|
-
cacheReadTokens?: number;
|
|
2086
|
-
cacheCreationTokens?: number;
|
|
2087
|
-
costUsd?: number;
|
|
2088
|
-
/** Model's context window size in tokens (from SDK modelUsage) */
|
|
2089
|
-
contextWindow?: number;
|
|
2090
|
-
}
|
|
2091
|
-
/**
|
|
2092
|
-
* Events emitted by the agent runtime during chat
|
|
2093
|
-
* turnId: Correlation ID from the API's message.id, groups all events in an assistant turn
|
|
2094
|
-
*/
|
|
2095
|
-
type AgentEvent = {
|
|
2096
|
-
type: 'status';
|
|
2097
|
-
message: string;
|
|
2098
|
-
} | {
|
|
2099
|
-
type: 'info';
|
|
2100
|
-
message: string;
|
|
2101
|
-
} | {
|
|
2102
|
-
type: 'text_delta';
|
|
2103
|
-
text: string;
|
|
2104
|
-
turnId?: string;
|
|
2105
|
-
parentToolUseId?: string;
|
|
2106
|
-
} | {
|
|
2107
|
-
type: 'text_complete';
|
|
2108
|
-
text: string;
|
|
2109
|
-
isIntermediate?: boolean;
|
|
2110
|
-
turnId?: string;
|
|
2111
|
-
parentToolUseId?: string;
|
|
2112
|
-
sdkTurnAnchor?: string;
|
|
2113
|
-
} | {
|
|
2114
|
-
type: 'tool_start';
|
|
2115
|
-
toolName: string;
|
|
2116
|
-
toolUseId: string;
|
|
2117
|
-
input: Record<string, unknown>;
|
|
2118
|
-
intent?: string;
|
|
2119
|
-
displayName?: string;
|
|
2120
|
-
turnId?: string;
|
|
2121
|
-
parentToolUseId?: string;
|
|
2122
|
-
toolDisplayMeta?: ToolDisplayMeta;
|
|
2123
|
-
} | {
|
|
2124
|
-
type: 'tool_result';
|
|
2125
|
-
toolUseId: string;
|
|
2126
|
-
toolName?: string;
|
|
2127
|
-
result: string;
|
|
2128
|
-
isError: boolean;
|
|
2129
|
-
input?: Record<string, unknown>;
|
|
2130
|
-
turnId?: string;
|
|
2131
|
-
parentToolUseId?: string;
|
|
2132
|
-
} | {
|
|
2133
|
-
type: 'permission_request';
|
|
2134
|
-
requestId: string;
|
|
2135
|
-
toolName: string;
|
|
2136
|
-
command?: string;
|
|
2137
|
-
description: string;
|
|
2138
|
-
permissionType?: PermissionRequestType;
|
|
2139
|
-
appName?: string;
|
|
2140
|
-
reason?: string;
|
|
2141
|
-
impact?: string;
|
|
2142
|
-
requiresSystemPrompt?: boolean;
|
|
2143
|
-
rememberForMinutes?: number;
|
|
2144
|
-
commandHash?: string;
|
|
2145
|
-
approvalTtlSeconds?: number;
|
|
2146
|
-
} | {
|
|
2147
|
-
type: 'reasoning_delta';
|
|
2148
|
-
text: string;
|
|
2149
|
-
turnId?: string;
|
|
2150
|
-
} | {
|
|
2151
|
-
type: 'reasoning';
|
|
2152
|
-
text: string;
|
|
2153
|
-
turnId?: string;
|
|
2154
|
-
} | {
|
|
2155
|
-
type: 'permission_response';
|
|
2156
|
-
requestId: string;
|
|
2157
|
-
allowed: boolean;
|
|
2158
|
-
remember?: boolean;
|
|
2159
|
-
} | {
|
|
2160
|
-
type: 'error';
|
|
2161
|
-
message: string;
|
|
2162
|
-
} | {
|
|
2163
|
-
type: 'typed_error';
|
|
2164
|
-
error: TypedError;
|
|
2165
|
-
} | {
|
|
2166
|
-
type: 'complete';
|
|
2167
|
-
usage?: AgentEventUsage;
|
|
2168
|
-
} | {
|
|
2169
|
-
type: 'working_directory_changed';
|
|
2170
|
-
workingDirectory: string;
|
|
2171
|
-
} | {
|
|
2172
|
-
type: 'task_backgrounded';
|
|
2173
|
-
toolUseId: string;
|
|
2174
|
-
taskId: string;
|
|
2175
|
-
intent?: string;
|
|
2176
|
-
turnId?: string;
|
|
2177
|
-
} | {
|
|
2178
|
-
type: 'shell_backgrounded';
|
|
2179
|
-
toolUseId: string;
|
|
2180
|
-
shellId: string;
|
|
2181
|
-
intent?: string;
|
|
2182
|
-
command?: string;
|
|
2183
|
-
turnId?: string;
|
|
2184
|
-
} | {
|
|
2185
|
-
type: 'task_progress';
|
|
2186
|
-
toolUseId: string;
|
|
2187
|
-
elapsedSeconds: number;
|
|
2188
|
-
turnId?: string;
|
|
2189
|
-
} | {
|
|
2190
|
-
type: 'task_completed';
|
|
2191
|
-
taskId: string;
|
|
2192
|
-
status: 'completed' | 'failed' | 'stopped';
|
|
2193
|
-
outputFile?: string;
|
|
2194
|
-
summary?: string;
|
|
2195
|
-
turnId?: string;
|
|
2196
|
-
} | {
|
|
2197
|
-
type: 'shell_killed';
|
|
2198
|
-
shellId: string;
|
|
2199
|
-
turnId?: string;
|
|
2200
|
-
} | {
|
|
2201
|
-
type: 'source_activated';
|
|
2202
|
-
sourceSlug: string;
|
|
2203
|
-
originalMessage: string;
|
|
2204
|
-
} | {
|
|
2205
|
-
type: 'usage_update';
|
|
2206
|
-
usage: Pick<AgentEventUsage, 'inputTokens' | 'contextWindow'>;
|
|
2207
|
-
} | {
|
|
2208
|
-
type: 'steer_undelivered';
|
|
2209
|
-
message: string;
|
|
2210
|
-
} | {
|
|
2211
|
-
type: 'compaction_started';
|
|
2212
|
-
} | {
|
|
2213
|
-
type: 'compaction_boundary';
|
|
2214
|
-
summary?: string;
|
|
2215
|
-
};
|
|
2216
|
-
/**
|
|
2217
|
-
* Generate a unique message ID
|
|
2218
|
-
*/
|
|
2219
|
-
declare function generateMessageId(): string;
|
|
2220
|
-
|
|
2221
|
-
/**
|
|
2222
|
-
* Session types for conversation management
|
|
2223
|
-
*
|
|
2224
|
-
* Sessions are the primary isolation boundary. Each session maps 1:1
|
|
2225
|
-
* with an agent runtime instance and SDK conversation.
|
|
2226
|
-
*/
|
|
2227
|
-
|
|
2228
|
-
/**
|
|
2229
|
-
* Session status for workflow tracking
|
|
2230
|
-
* Agents can update this to reflect the current state of the conversation
|
|
2231
|
-
*/
|
|
2232
|
-
type SessionStatus = 'todo' | 'in_progress' | 'needs_review' | 'done' | 'cancelled';
|
|
2233
|
-
/**
|
|
2234
|
-
* Session represents a conversation scope (SDK session = our scope boundary)
|
|
2235
|
-
*/
|
|
2236
|
-
interface Session {
|
|
2237
|
-
id: string;
|
|
2238
|
-
sdkSessionId?: string;
|
|
2239
|
-
workspaceId: string;
|
|
2240
|
-
name?: string;
|
|
2241
|
-
createdAt: number;
|
|
2242
|
-
lastUsedAt: number;
|
|
2243
|
-
isArchived?: boolean;
|
|
2244
|
-
isFlagged?: boolean;
|
|
2245
|
-
status?: SessionStatus;
|
|
2246
|
-
lastReadMessageId?: string;
|
|
2247
|
-
}
|
|
2248
|
-
/**
|
|
2249
|
-
* Stored session with conversation data (for persistence)
|
|
2250
|
-
*/
|
|
2251
|
-
interface StoredSession extends Session {
|
|
2252
|
-
messages: StoredMessage[];
|
|
2253
|
-
tokenUsage: TokenUsage;
|
|
2254
|
-
}
|
|
2255
|
-
/**
|
|
2256
|
-
* Session metadata for listing (without loading full messages)
|
|
2257
|
-
* Extended with archive status for Inbox/Archive features
|
|
2258
|
-
*/
|
|
2259
|
-
interface SessionMetadata {
|
|
2260
|
-
id: string;
|
|
2261
|
-
workspaceId: string;
|
|
2262
|
-
name?: string;
|
|
2263
|
-
createdAt: number;
|
|
2264
|
-
lastUsedAt: number;
|
|
2265
|
-
messageCount: number;
|
|
2266
|
-
preview?: string;
|
|
2267
|
-
sdkSessionId?: string;
|
|
2268
|
-
isArchived?: boolean;
|
|
2269
|
-
isFlagged?: boolean;
|
|
2270
|
-
status?: SessionStatus;
|
|
2271
|
-
hidden?: boolean;
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
/**
|
|
2275
|
-
* Convert runtime Message to StoredMessage for persistence.
|
|
2276
|
-
*
|
|
2277
|
-
* Excludes transient runtime-only fields:
|
|
2278
|
-
* - isStreaming
|
|
2279
|
-
* - isPending
|
|
2280
|
-
*/
|
|
2281
|
-
declare function messageToStored(msg: Message): StoredMessage;
|
|
2282
|
-
/**
|
|
2283
|
-
* Convert StoredMessage to runtime Message.
|
|
2284
|
-
*
|
|
2285
|
-
* Adds a timestamp fallback for legacy messages where timestamp was omitted.
|
|
2286
|
-
*/
|
|
2287
|
-
declare function storedToMessage(stored: StoredMessage): Message;
|
|
2288
|
-
|
|
2289
|
-
/**
|
|
2290
|
-
* Server-level types for headless server operations.
|
|
2291
|
-
*
|
|
2292
|
-
* These types are used by the `server:` RPC namespace for
|
|
2293
|
-
* server status, health checks, active session discovery,
|
|
2294
|
-
* and headless configuration bootstrap.
|
|
2295
|
-
*/
|
|
2296
|
-
interface ServerStatus {
|
|
2297
|
-
serverId: string;
|
|
2298
|
-
version: string;
|
|
2299
|
-
uptime: number;
|
|
2300
|
-
connectedClients: number;
|
|
2301
|
-
workspaces: {
|
|
2302
|
-
id: string;
|
|
2303
|
-
name: string;
|
|
2304
|
-
slug: string;
|
|
2305
|
-
activeSessions: number;
|
|
2306
|
-
automationCount: number;
|
|
2307
|
-
schedulerRunning: boolean;
|
|
2308
|
-
}[];
|
|
2309
|
-
memory: {
|
|
2310
|
-
heapUsed: number;
|
|
2311
|
-
heapTotal: number;
|
|
2312
|
-
rss: number;
|
|
2313
|
-
};
|
|
2314
|
-
}
|
|
2315
|
-
interface ServerHealth {
|
|
2316
|
-
status: 'ok' | 'degraded' | 'unhealthy';
|
|
2317
|
-
checks: {
|
|
2318
|
-
name: string;
|
|
2319
|
-
status: 'pass' | 'fail';
|
|
2320
|
-
message?: string;
|
|
2321
|
-
}[];
|
|
2322
|
-
}
|
|
2323
|
-
/** Session processing state — typed union, not stringly. */
|
|
2324
|
-
type SessionProcessingStatus = 'idle' | 'processing' | 'waiting_input' | 'error' | 'completed';
|
|
2325
|
-
/** Server-level active session info (cross-workspace, client-safe). */
|
|
2326
|
-
interface ActiveSessionInfo {
|
|
2327
|
-
sessionId: string;
|
|
2328
|
-
workspaceId: string;
|
|
2329
|
-
workspaceName: string;
|
|
2330
|
-
title?: string;
|
|
2331
|
-
status: SessionProcessingStatus;
|
|
2332
|
-
triggeredBy?: {
|
|
2333
|
-
automationName: string;
|
|
2334
|
-
timestamp: number;
|
|
2335
|
-
};
|
|
2336
|
-
createdAt: number;
|
|
2337
|
-
}
|
|
2338
|
-
|
|
2339
|
-
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 };
|
|
2340
|
-
|
|
2341
|
-
// -- @weft/core/utils/index.d.ts --
|
|
2342
|
-
/**
|
|
2343
|
-
* Debug utility for core package
|
|
2344
|
-
*
|
|
2345
|
-
* This is a stub that can be enhanced to support debug logging.
|
|
2346
|
-
* Currently a no-op - use @weft debug utilities for full logging.
|
|
2347
|
-
*/
|
|
2348
|
-
declare function debug(..._args: any[]): void;
|
|
2349
|
-
|
|
2350
|
-
/**
|
|
2351
|
-
* Cross-Platform Path Utilities
|
|
2352
|
-
*
|
|
2353
|
-
* Functions for consistent path handling across Windows, macOS, and Linux.
|
|
2354
|
-
* Always normalize paths to forward slashes before comparison operations.
|
|
2355
|
-
*/
|
|
2356
|
-
/**
|
|
2357
|
-
* Normalize a path to use forward slashes for consistent cross-platform comparison.
|
|
2358
|
-
* Use this before comparing paths or using regex patterns on paths.
|
|
2359
|
-
*
|
|
2360
|
-
* @example
|
|
2361
|
-
* normalizePath('C:\\Users\\foo\\bar') // 'C:/Users/foo/bar'
|
|
2362
|
-
* normalizePath('/Users/foo/bar') // '/Users/foo/bar' (unchanged)
|
|
2363
|
-
*/
|
|
2364
|
-
declare function normalizePath(path: string): string;
|
|
2365
|
-
/**
|
|
2366
|
-
* Check if a file path starts with a directory path (cross-platform).
|
|
2367
|
-
* Handles both Windows backslashes and Unix forward slashes.
|
|
2368
|
-
*
|
|
2369
|
-
* @example
|
|
2370
|
-
* pathStartsWith('C:\\Users\\foo\\file.txt', 'C:\\Users\\foo') // true
|
|
2371
|
-
* pathStartsWith('/home/user/file.txt', '/home/user') // true
|
|
2372
|
-
* pathStartsWith('/home/user2/file.txt', '/home/user') // false
|
|
2373
|
-
*/
|
|
2374
|
-
declare function pathStartsWith(filePath: string, dirPath: string): boolean;
|
|
2375
|
-
/**
|
|
2376
|
-
* Strip a directory prefix from a path (cross-platform).
|
|
2377
|
-
* Returns the relative path portion after the prefix.
|
|
2378
|
-
*
|
|
2379
|
-
* @example
|
|
2380
|
-
* stripPathPrefix('/home/user/docs/file.txt', '/home/user') // 'docs/file.txt'
|
|
2381
|
-
* stripPathPrefix('C:\\foo\\bar\\baz.txt', 'C:\\foo') // 'bar/baz.txt'
|
|
2382
|
-
*/
|
|
2383
|
-
declare function stripPathPrefix(filePath: string, prefix: string): string;
|
|
2384
|
-
|
|
2385
|
-
export { debug, normalizePath, pathStartsWith, stripPathPrefix };
|
|
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/sources ──
|
|
3095
|
-
// -- @weft/sources/index.d.ts --
|
|
3096
|
-
|
|
3097
|
-
/**
|
|
3098
|
-
* Entity Color Types
|
|
3099
|
-
*
|
|
3100
|
-
* Provides color type definitions for source brand theming.
|
|
3101
|
-
* Supports light/dark mode color variants for UI consistency.
|
|
3102
|
-
*/
|
|
3103
|
-
/**
|
|
3104
|
-
* Entity color specification.
|
|
3105
|
-
* Can be a system color name or a light/dark mode variant.
|
|
3106
|
-
*/
|
|
3107
|
-
type EntityColor = string | {
|
|
3108
|
-
light: string;
|
|
3109
|
-
dark: string;
|
|
3110
|
-
};
|
|
3111
|
-
|
|
3112
|
-
/**
|
|
3113
|
-
* Source Types
|
|
3114
|
-
*
|
|
3115
|
-
* Sources are external data connections (MCP servers, APIs, local filesystems).
|
|
3116
|
-
* They replace the old "connections" concept with a more flexible, folder-based architecture.
|
|
3117
|
-
*
|
|
3118
|
-
* File structure:
|
|
3119
|
-
* ~/.weft/workspaces/{workspaceId}/sources/{sourceSlug}/
|
|
3120
|
-
* ├── config.json - Source settings
|
|
3121
|
-
* └── guide.md - Usage guidelines + cached data (in YAML frontmatter)
|
|
3122
|
-
*/
|
|
3123
|
-
/**
|
|
3124
|
-
* Source types - how we connect to the source
|
|
3125
|
-
*/
|
|
3126
|
-
type SourceType = 'mcp' | 'api' | 'local';
|
|
3127
|
-
/**
|
|
3128
|
-
* MCP source authentication types (for individual source connections)
|
|
3129
|
-
* Note: Different from workspace McpAuthType which uses 'workspace_oauth' | 'workspace_bearer' | 'public'
|
|
3130
|
-
*/
|
|
3131
|
-
type SourceMcpAuthType = 'oauth' | 'bearer' | 'none';
|
|
3132
|
-
/**
|
|
3133
|
-
* API authentication types
|
|
3134
|
-
*/
|
|
3135
|
-
type ApiAuthType = 'bearer' | 'header' | 'query' | 'basic' | 'oauth' | 'none';
|
|
3136
|
-
/**
|
|
3137
|
-
* Google service types for OAuth scope selection
|
|
3138
|
-
*/
|
|
3139
|
-
type GoogleService = 'gmail' | 'calendar' | 'drive' | 'docs' | 'sheets' | 'youtube' | 'searchconsole';
|
|
3140
|
-
/**
|
|
3141
|
-
* Slack service types for OAuth scope selection
|
|
3142
|
-
*/
|
|
3143
|
-
type SlackService = 'messaging' | 'channels' | 'users' | 'files' | 'full';
|
|
3144
|
-
/**
|
|
3145
|
-
* Microsoft service types for OAuth scope selection
|
|
3146
|
-
*/
|
|
3147
|
-
type MicrosoftService = 'outlook' | 'microsoft-calendar' | 'onedrive' | 'teams' | 'sharepoint';
|
|
3148
|
-
/**
|
|
3149
|
-
* MCP transport type for sources
|
|
3150
|
-
* - 'http': HTTP-based MCP server (URL endpoint)
|
|
3151
|
-
* - 'sse': Server-Sent Events MCP server (URL endpoint)
|
|
3152
|
-
* - 'stdio': Local subprocess MCP server (spawned command)
|
|
3153
|
-
*/
|
|
3154
|
-
type McpTransport = 'http' | 'sse' | 'stdio';
|
|
3155
|
-
/**
|
|
3156
|
-
* MCP-specific configuration
|
|
3157
|
-
* Supports both HTTP-based and local stdio-based MCP servers.
|
|
3158
|
-
*/
|
|
3159
|
-
interface McpSourceConfig {
|
|
3160
|
-
/**
|
|
3161
|
-
* Transport type. Defaults to 'http' if not specified.
|
|
3162
|
-
*/
|
|
3163
|
-
transport?: McpTransport;
|
|
3164
|
-
/**
|
|
3165
|
-
* URL endpoint for HTTP or SSE transport.
|
|
3166
|
-
* Required when transport is 'http' or 'sse' (or undefined).
|
|
3167
|
-
*/
|
|
3168
|
-
url?: string;
|
|
3169
|
-
/**
|
|
3170
|
-
* Authentication type for HTTP/SSE servers.
|
|
3171
|
-
*/
|
|
3172
|
-
authType?: SourceMcpAuthType;
|
|
3173
|
-
/**
|
|
3174
|
-
* OAuth client ID (stored in config, not secret).
|
|
3175
|
-
*/
|
|
3176
|
-
clientId?: string;
|
|
3177
|
-
/**
|
|
3178
|
-
* Command to spawn for stdio transport.
|
|
3179
|
-
* Required when transport is 'stdio'.
|
|
3180
|
-
*/
|
|
3181
|
-
command?: string;
|
|
3182
|
-
/**
|
|
3183
|
-
* Arguments to pass to the command.
|
|
3184
|
-
*/
|
|
3185
|
-
args?: string[];
|
|
3186
|
-
/**
|
|
3187
|
-
* Environment variables for the spawned process.
|
|
3188
|
-
*/
|
|
3189
|
-
env?: Record<string, string>;
|
|
3190
|
-
/**
|
|
3191
|
-
* Custom headers to include in every MCP request.
|
|
3192
|
-
* Auth headers (e.g. Authorization) are merged on top when authType is set.
|
|
3193
|
-
*/
|
|
3194
|
-
headers?: Record<string, string>;
|
|
3195
|
-
/**
|
|
3196
|
-
* Header names for credential-store auth (e.g., ["X-API-Key"]).
|
|
3197
|
-
* Values are stored as JSON in the credential store, same as API multi-header auth.
|
|
3198
|
-
* Precedence: static headers < credential-store headerNames < Authorization bearer.
|
|
3199
|
-
*/
|
|
3200
|
-
headerNames?: string[];
|
|
3201
|
-
}
|
|
3202
|
-
/**
|
|
3203
|
-
* API test endpoint configuration for connection validation
|
|
3204
|
-
*/
|
|
3205
|
-
interface ApiTestEndpoint {
|
|
3206
|
-
method: 'GET' | 'POST';
|
|
3207
|
-
path: string;
|
|
3208
|
-
body?: Record<string, unknown>;
|
|
3209
|
-
headers?: Record<string, string>;
|
|
3210
|
-
}
|
|
3211
|
-
/**
|
|
3212
|
-
* Generic OAuth configuration for API sources.
|
|
3213
|
-
* Allows any OAuth 2.0 provider to be configured via config.json
|
|
3214
|
-
* without needing an MCP server or manual PAT.
|
|
3215
|
-
*/
|
|
3216
|
-
interface ApiOAuthConfig {
|
|
3217
|
-
/** OAuth authorization endpoint URL (REQUIRED) */
|
|
3218
|
-
authorizationUrl: string;
|
|
3219
|
-
/** OAuth token exchange endpoint URL (REQUIRED) */
|
|
3220
|
-
tokenUrl: string;
|
|
3221
|
-
/** OAuth client ID (REQUIRED) */
|
|
3222
|
-
clientId: string;
|
|
3223
|
-
/** OAuth client secret (optional for public PKCE clients) */
|
|
3224
|
-
clientSecret?: string;
|
|
3225
|
-
/** Requested OAuth scopes */
|
|
3226
|
-
scopes?: string[];
|
|
3227
|
-
/** Auth0-style audience parameter */
|
|
3228
|
-
audience?: string;
|
|
3229
|
-
/** Additional parameters to include in the authorization URL */
|
|
3230
|
-
extraParams?: Record<string, string>;
|
|
3231
|
-
}
|
|
3232
|
-
/**
|
|
3233
|
-
* Token renewal endpoint configuration for non-OAuth API sources.
|
|
3234
|
-
* Allows custom bearer-token APIs to auto-renew expired tokens by calling
|
|
3235
|
-
* a provider-specific endpoint (not OAuth-compliant).
|
|
3236
|
-
*
|
|
3237
|
-
* MVP scope: access-token-based renewal only. The current access token is
|
|
3238
|
-
* sent via the Authorization header and/or substituted into body/headers
|
|
3239
|
-
* using the {{token}} placeholder.
|
|
3240
|
-
*/
|
|
3241
|
-
interface ApiRenewEndpoint {
|
|
3242
|
-
/** Renew URL — relative path (resolved against baseUrl) or absolute URL */
|
|
3243
|
-
path: string;
|
|
3244
|
-
/** HTTP method (default: POST) */
|
|
3245
|
-
method?: 'GET' | 'POST';
|
|
3246
|
-
/** Request body — {{token}} in string leaves is substituted with current access token.
|
|
3247
|
-
* Supports nested objects (recursive substitution on string leaves). */
|
|
3248
|
-
body?: Record<string, unknown>;
|
|
3249
|
-
/** Extra headers for the renew request — {{token}} substitution applies here too.
|
|
3250
|
-
* Merged on top of defaultHeaders. Authorization header is always sent unless
|
|
3251
|
-
* explicitly overridden here. */
|
|
3252
|
-
headers?: Record<string, string>;
|
|
3253
|
-
/** JSON field name for the new access token in response (default: "access_token") */
|
|
3254
|
-
tokenField?: string;
|
|
3255
|
-
/** JSON field name for expiry in seconds in response (default: "expires_in") */
|
|
3256
|
-
expiresInField?: string;
|
|
3257
|
-
/** Fallback TTL in seconds when renew response doesn't include expiry (optional).
|
|
3258
|
-
* Without this, missing expiry causes refresh on every session start (safe but noisy). */
|
|
3259
|
-
fallbackTtlSecs?: number;
|
|
3260
|
-
}
|
|
3261
|
-
/**
|
|
3262
|
-
* API-specific configuration
|
|
3263
|
-
*/
|
|
3264
|
-
interface ApiSourceConfig {
|
|
3265
|
-
baseUrl: string;
|
|
3266
|
-
authType: ApiAuthType;
|
|
3267
|
-
headerName?: string;
|
|
3268
|
-
headerNames?: string[];
|
|
3269
|
-
queryParam?: string;
|
|
3270
|
-
authScheme?: string;
|
|
3271
|
-
defaultHeaders?: Record<string, string>;
|
|
3272
|
-
testEndpoint?: ApiTestEndpoint;
|
|
3273
|
-
renewEndpoint?: ApiRenewEndpoint;
|
|
3274
|
-
googleService?: GoogleService;
|
|
3275
|
-
googleScopes?: string[];
|
|
3276
|
-
googleOAuthClientId?: string;
|
|
3277
|
-
googleOAuthClientSecret?: string;
|
|
3278
|
-
slackService?: SlackService;
|
|
3279
|
-
slackUserScopes?: string[];
|
|
3280
|
-
microsoftService?: MicrosoftService;
|
|
3281
|
-
microsoftScopes?: string[];
|
|
3282
|
-
oauth?: ApiOAuthConfig;
|
|
3283
|
-
}
|
|
3284
|
-
/**
|
|
3285
|
-
* Local filesystem/app configuration
|
|
3286
|
-
*/
|
|
3287
|
-
interface LocalSourceConfig {
|
|
3288
|
-
path: string;
|
|
3289
|
-
format?: string;
|
|
3290
|
-
}
|
|
3291
|
-
/**
|
|
3292
|
-
* Source connection status
|
|
3293
|
-
* - 'connected': Source is connected and working
|
|
3294
|
-
* - 'needs_auth': Source requires authentication
|
|
3295
|
-
* - 'failed': Connection failed with error
|
|
3296
|
-
* - 'untested': Connection has not been tested
|
|
3297
|
-
* - 'local_disabled': Stdio source is disabled (local MCP servers off)
|
|
3298
|
-
*/
|
|
3299
|
-
type SourceConnectionStatus = 'connected' | 'needs_auth' | 'failed' | 'untested' | 'local_disabled';
|
|
3300
|
-
/**
|
|
3301
|
-
* Brand theming for a source's UI elements.
|
|
3302
|
-
* Uses the EntityColor system for light/dark mode support.
|
|
3303
|
-
*/
|
|
3304
|
-
interface SourceBrand {
|
|
3305
|
-
/** Primary brand color — used for source-branded UI elements.
|
|
3306
|
-
* Can be a system color name ("accent", "info") or custom { light, dark } values.
|
|
3307
|
-
* Defaults to "accent" if not set. */
|
|
3308
|
-
color?: EntityColor;
|
|
3309
|
-
}
|
|
3310
|
-
/**
|
|
3311
|
-
* Main source configuration (stored in config.json)
|
|
3312
|
-
*/
|
|
3313
|
-
interface FolderSourceConfig {
|
|
3314
|
-
id: string;
|
|
3315
|
-
name: string;
|
|
3316
|
-
slug: string;
|
|
3317
|
-
enabled: boolean;
|
|
3318
|
-
provider: string;
|
|
3319
|
-
type: SourceType;
|
|
3320
|
-
mcp?: McpSourceConfig;
|
|
3321
|
-
api?: ApiSourceConfig;
|
|
3322
|
-
local?: LocalSourceConfig;
|
|
3323
|
-
icon?: string;
|
|
3324
|
-
tagline?: string;
|
|
3325
|
-
brand?: SourceBrand;
|
|
3326
|
-
isAuthenticated?: boolean;
|
|
3327
|
-
connectionStatus?: SourceConnectionStatus;
|
|
3328
|
-
connectionError?: string;
|
|
3329
|
-
lastTestedAt?: number;
|
|
3330
|
-
createdAt?: number;
|
|
3331
|
-
updatedAt?: number;
|
|
3332
|
-
}
|
|
3333
|
-
/**
|
|
3334
|
-
* Parsed guide.md content with embedded cache
|
|
3335
|
-
*/
|
|
3336
|
-
interface SourceGuide {
|
|
3337
|
-
raw: string;
|
|
3338
|
-
scope?: string;
|
|
3339
|
-
guidelines?: string;
|
|
3340
|
-
context?: string;
|
|
3341
|
-
apiNotes?: string;
|
|
3342
|
-
cache?: Record<string, unknown>;
|
|
3343
|
-
}
|
|
3344
|
-
/**
|
|
3345
|
-
* Fully loaded source with all files
|
|
3346
|
-
*/
|
|
3347
|
-
interface LoadedSource {
|
|
3348
|
-
config: FolderSourceConfig;
|
|
3349
|
-
guide: SourceGuide | null;
|
|
3350
|
-
/** Absolute path to source folder (for resolving relative icon paths) */
|
|
3351
|
-
folderPath: string;
|
|
3352
|
-
/** Absolute path to workspace folder (e.g., ~/.weft/workspaces/xxx) */
|
|
3353
|
-
workspaceRootPath: string;
|
|
3354
|
-
/**
|
|
3355
|
-
* Workspace this source belongs to.
|
|
3356
|
-
* Used for credential lookups: source_oauth::{workspaceId}::{sourceSlug}
|
|
3357
|
-
*/
|
|
3358
|
-
workspaceId: string;
|
|
3359
|
-
/**
|
|
3360
|
-
* Whether this is a built-in source (e.g., the always-available docs MCP).
|
|
3361
|
-
* Built-in sources are always available and not shown in the sources UI.
|
|
3362
|
-
*/
|
|
3363
|
-
isBuiltin?: boolean;
|
|
3364
|
-
/**
|
|
3365
|
-
* Pre-computed path to local icon file (icon.svg, icon.png, etc.) if it exists.
|
|
3366
|
-
* Computed during source loading so renderer doesn't need filesystem access.
|
|
3367
|
-
*/
|
|
3368
|
-
iconPath?: string;
|
|
3369
|
-
}
|
|
3370
|
-
/**
|
|
3371
|
-
* Source creation input (without auto-generated fields)
|
|
3372
|
-
*/
|
|
3373
|
-
interface CreateSourceInput {
|
|
3374
|
-
name: string;
|
|
3375
|
-
provider: string;
|
|
3376
|
-
type: SourceType;
|
|
3377
|
-
mcp?: McpSourceConfig;
|
|
3378
|
-
api?: ApiSourceConfig;
|
|
3379
|
-
local?: LocalSourceConfig;
|
|
3380
|
-
icon?: string;
|
|
3381
|
-
enabled?: boolean;
|
|
3382
|
-
}
|
|
3383
|
-
/**
|
|
3384
|
-
* REST API configuration for API sources
|
|
3385
|
-
* Used by api-tools.ts to create dynamic API tools
|
|
3386
|
-
*/
|
|
3387
|
-
interface ApiConfig {
|
|
3388
|
-
name: string;
|
|
3389
|
-
baseUrl: string;
|
|
3390
|
-
auth?: {
|
|
3391
|
-
type: 'none' | 'header' | 'bearer' | 'query' | 'basic';
|
|
3392
|
-
headerName?: string;
|
|
3393
|
-
headerNames?: string[];
|
|
3394
|
-
queryParam?: string;
|
|
3395
|
-
authScheme?: string;
|
|
3396
|
-
credentialLabel?: string;
|
|
3397
|
-
secretLabel?: string;
|
|
3398
|
-
};
|
|
3399
|
-
headers?: Record<string, string>;
|
|
3400
|
-
documentation?: string;
|
|
3401
|
-
docsUrl?: string;
|
|
3402
|
-
defaultHeaders?: Record<string, string>;
|
|
3403
|
-
logo?: string;
|
|
3404
|
-
workspaceId?: string;
|
|
3405
|
-
}
|
|
3406
|
-
|
|
3407
|
-
/**
|
|
3408
|
-
* Built-in Sources
|
|
3409
|
-
*
|
|
3410
|
-
* System-level sources that are always available in every workspace.
|
|
3411
|
-
* These sources are not shown in the sources list UI but are available
|
|
3412
|
-
* for the agent to use.
|
|
3413
|
-
*
|
|
3414
|
-
* NOTE: The docs source is now an always-available MCP server configured
|
|
3415
|
-
* directly in the host runtime, not a source. This file is kept for backwards
|
|
3416
|
-
* compatibility but returns empty results.
|
|
3417
|
-
*/
|
|
3418
|
-
|
|
3419
|
-
/**
|
|
3420
|
-
* Get all built-in sources for a workspace.
|
|
3421
|
-
*
|
|
3422
|
-
* Currently returns empty array - the docs source has been moved to
|
|
3423
|
-
* an always-available MCP server in the host runtime.
|
|
3424
|
-
*
|
|
3425
|
-
* @param _workspaceId - The workspace ID (unused)
|
|
3426
|
-
* @param _workspaceRootPath - Absolute path to workspace root folder (unused)
|
|
3427
|
-
* @returns Empty array (no built-in sources)
|
|
3428
|
-
*/
|
|
3429
|
-
declare function getBuiltinSources(_workspaceId: string, _workspaceRootPath: string): LoadedSource[];
|
|
3430
|
-
|
|
3431
|
-
type SourceActivationStatus = 'active' | 'disabled' | 'needs_auth' | 'failed' | 'missing';
|
|
3432
|
-
interface SourceStateSnapshot {
|
|
3433
|
-
sourceSlug: string;
|
|
3434
|
-
enabled: boolean;
|
|
3435
|
-
authenticated: boolean;
|
|
3436
|
-
status: SourceActivationStatus;
|
|
3437
|
-
reason?: string;
|
|
3438
|
-
}
|
|
3439
|
-
interface CreateSourceActivationPlanOptions {
|
|
3440
|
-
requestedSourceSlugs: string[];
|
|
3441
|
-
sourceStates: SourceStateSnapshot[];
|
|
3442
|
-
}
|
|
3443
|
-
interface SourceActivationPlan {
|
|
3444
|
-
requestedSourceSlugs: string[];
|
|
3445
|
-
activeSourceSlugs: string[];
|
|
3446
|
-
authRequiredSourceSlugs: string[];
|
|
3447
|
-
missingSourceSlugs: string[];
|
|
3448
|
-
blockedSourceSlugs: string[];
|
|
3449
|
-
timelineItems: TimelineItem[];
|
|
3450
|
-
}
|
|
3451
|
-
declare function createSourceActivationPlan(options: CreateSourceActivationPlanOptions): SourceActivationPlan;
|
|
3452
|
-
|
|
3453
|
-
type SourceCredentialRefType = 'source_oauth' | 'source_bearer' | 'source_header' | 'source_query' | 'source_basic' | 'source_multi_header';
|
|
3454
|
-
interface SourceCredentialRef {
|
|
3455
|
-
type: SourceCredentialRefType;
|
|
3456
|
-
sourceSlug: string;
|
|
3457
|
-
workspaceId: string;
|
|
3458
|
-
}
|
|
3459
|
-
type SourceToolDescriptor = {
|
|
3460
|
-
kind: 'api-source';
|
|
3461
|
-
sourceSlug: string;
|
|
3462
|
-
baseUrl: string;
|
|
3463
|
-
authType: ApiAuthType;
|
|
3464
|
-
defaultHeaders?: Record<string, string>;
|
|
3465
|
-
credentialRef?: SourceCredentialRef;
|
|
3466
|
-
} | {
|
|
3467
|
-
kind: 'local-source';
|
|
3468
|
-
sourceSlug: string;
|
|
3469
|
-
path: string;
|
|
3470
|
-
format?: string;
|
|
3471
|
-
} | {
|
|
3472
|
-
kind: 'mcp-server';
|
|
3473
|
-
sourceSlug: string;
|
|
3474
|
-
transport: McpTransport;
|
|
3475
|
-
url?: string;
|
|
3476
|
-
command?: string;
|
|
3477
|
-
args?: string[];
|
|
3478
|
-
env?: Record<string, string>;
|
|
3479
|
-
headers?: Record<string, string>;
|
|
3480
|
-
credentialRef?: SourceCredentialRef;
|
|
3481
|
-
};
|
|
3482
|
-
interface CreateSourceToolAssemblyPlanOptions {
|
|
3483
|
-
activeSourceSlugs: string[];
|
|
3484
|
-
sources: LoadedSource[];
|
|
3485
|
-
credentialRefs?: Record<string, SourceCredentialRef>;
|
|
3486
|
-
allowedStdioEnvKeys?: string[];
|
|
3487
|
-
}
|
|
3488
|
-
interface SourceToolAssemblyPlan {
|
|
3489
|
-
tools: SourceToolDescriptor[];
|
|
3490
|
-
blockedSourceSlugs: string[];
|
|
3491
|
-
}
|
|
3492
|
-
declare function createSourceToolAssemblyPlan(options: CreateSourceToolAssemblyPlanOptions): SourceToolAssemblyPlan;
|
|
3493
|
-
|
|
3494
|
-
interface CreateSourceRuntimeAssemblyPlanOptions {
|
|
3495
|
-
requestedSourceSlugs: string[];
|
|
3496
|
-
sourceStates: SourceStateSnapshot[];
|
|
3497
|
-
sources: LoadedSource[];
|
|
3498
|
-
credentialRefs?: Record<string, SourceCredentialRef>;
|
|
3499
|
-
allowedStdioEnvKeys?: string[];
|
|
3500
|
-
}
|
|
3501
|
-
interface SourceRuntimeAssemblyPlan {
|
|
3502
|
-
requestedSourceSlugs: string[];
|
|
3503
|
-
activeSourceSlugs: string[];
|
|
3504
|
-
authRequiredSourceSlugs: string[];
|
|
3505
|
-
missingSourceSlugs: string[];
|
|
3506
|
-
blockedSourceSlugs: string[];
|
|
3507
|
-
toolBlockedSourceSlugs: string[];
|
|
3508
|
-
sourceTools: SourceToolDescriptor[];
|
|
3509
|
-
timelineItems: TimelineItem[];
|
|
3510
|
-
}
|
|
3511
|
-
declare function createSourceRuntimeAssemblyPlan(options: CreateSourceRuntimeAssemblyPlanOptions): SourceRuntimeAssemblyPlan;
|
|
3512
|
-
|
|
3513
|
-
interface SourceRuntimeCapabilityDegradation {
|
|
3514
|
-
authRequiredSourceSlugs: string[];
|
|
3515
|
-
missingSourceSlugs: string[];
|
|
3516
|
-
blockedSourceSlugs: string[];
|
|
3517
|
-
toolBlockedSourceSlugs: string[];
|
|
3518
|
-
}
|
|
3519
|
-
interface SourceRuntimeProviderOptions {
|
|
3520
|
-
extensions: Pick<RuntimeExtensionContext, 'sources'>;
|
|
3521
|
-
sourceTools: ProviderSourceToolDescriptor[];
|
|
3522
|
-
timelineItems: TimelineItem[];
|
|
3523
|
-
capabilityDegradation: SourceRuntimeCapabilityDegradation;
|
|
3524
|
-
}
|
|
3525
|
-
declare function createSourceRuntimeProviderOptions(options: CreateSourceRuntimeAssemblyPlanOptions): SourceRuntimeProviderOptions;
|
|
3526
|
-
|
|
3527
|
-
interface ValidationIssue {
|
|
3528
|
-
file: string;
|
|
3529
|
-
path: string;
|
|
3530
|
-
message: string;
|
|
3531
|
-
severity: 'error' | 'warning' | 'info';
|
|
3532
|
-
suggestion?: string;
|
|
3533
|
-
}
|
|
3534
|
-
interface ValidationResult {
|
|
3535
|
-
valid: boolean;
|
|
3536
|
-
errors: ValidationIssue[];
|
|
3537
|
-
warnings: ValidationIssue[];
|
|
3538
|
-
}
|
|
3539
|
-
declare function validateSourceConfig(config: unknown): ValidationResult;
|
|
3540
|
-
|
|
3541
|
-
/**
|
|
3542
|
-
* Source Auth — Provider-Owned Detection Interface
|
|
3543
|
-
*
|
|
3544
|
-
* Weft does NOT implement separate OAuth flows for providers
|
|
3545
|
-
* (Claude, Codex). Provider auth is detected and delegated, not managed.
|
|
3546
|
-
*
|
|
3547
|
-
* This module provides:
|
|
3548
|
-
* 1. Detection interface for source-level auth (MCP bearer/basic/apikey)
|
|
3549
|
-
* 2. Provider auth delegation — forwards to @weft/runtime-core auth types
|
|
3550
|
-
* for Claude/Codex/Copilot provider-level detection
|
|
3551
|
-
*
|
|
3552
|
-
* Source-level OAuth (Google, Slack, Microsoft) for MCP/API sources
|
|
3553
|
-
* remains in this package but requires host application injection.
|
|
3554
|
-
* The host app provides the actual OAuth callback server implementation.
|
|
3555
|
-
*/
|
|
3556
|
-
|
|
3557
|
-
/**
|
|
3558
|
-
* Auth session context for source OAuth flows.
|
|
3559
|
-
* Used by host application to track which session/workspace initiated auth.
|
|
3560
|
-
*/
|
|
3561
|
-
interface OAuthSessionContext {
|
|
3562
|
-
sessionId: string;
|
|
3563
|
-
workspaceId: string;
|
|
3564
|
-
}
|
|
3565
|
-
/**
|
|
3566
|
-
* Result of a source authentication attempt.
|
|
3567
|
-
*
|
|
3568
|
-
* On success, the host app can either:
|
|
3569
|
-
* 1. Return token data here → Weft's SourceCredentialManager saves it
|
|
3570
|
-
* 2. Save tokens directly via SourceCredentialManager.save() → return success only
|
|
3571
|
-
*
|
|
3572
|
-
* Option 1 is simpler; Option 2 gives the host app full control over storage.
|
|
3573
|
-
* Both approaches work — Weft handles either case.
|
|
3574
|
-
*/
|
|
3575
|
-
interface SourceAuthResult {
|
|
3576
|
-
/** Whether auth was successful */
|
|
3577
|
-
success: boolean;
|
|
3578
|
-
/** Error message if auth failed */
|
|
3579
|
-
error?: string;
|
|
3580
|
-
/** Email address obtained during auth (if available) */
|
|
3581
|
-
email?: string;
|
|
3582
|
-
/** Access token (host app may return it for Weft to save) */
|
|
3583
|
-
accessToken?: string;
|
|
3584
|
-
/** Refresh token (host app may return it for Weft to save) */
|
|
3585
|
-
refreshToken?: string;
|
|
3586
|
-
/** Token expiry timestamp in ms since epoch (host app may return it) */
|
|
3587
|
-
expiresAt?: number;
|
|
3588
|
-
}
|
|
3589
|
-
/**
|
|
3590
|
-
* Provider auth detection result for source-level usage.
|
|
3591
|
-
* Wraps the runtime-core ProviderAuthDetection for source credential routing.
|
|
3592
|
-
*/
|
|
3593
|
-
interface SourceProviderAuthStatus {
|
|
3594
|
-
/** Which auth mode the provider uses */
|
|
3595
|
-
mode: ProviderAuthMode;
|
|
3596
|
-
/** Whether the provider's auth is configured */
|
|
3597
|
-
configured: boolean;
|
|
3598
|
-
/** Human-readable description of auth state */
|
|
3599
|
-
description: string;
|
|
3600
|
-
}
|
|
3601
|
-
/**
|
|
3602
|
-
* Convert ProviderAuthDetection from runtime-core to a source-friendly status.
|
|
3603
|
-
*/
|
|
3604
|
-
declare function providerAuthToSourceStatus(detection: ProviderAuthDetection): SourceProviderAuthStatus;
|
|
3605
|
-
/**
|
|
3606
|
-
* Interface that the host application must implement for source OAuth flows.
|
|
3607
|
-
*
|
|
3608
|
-
* Weft does NOT own browser callback servers or PKCE flows.
|
|
3609
|
-
* The host app (Electron, web UI, CLI) provides the actual OAuth implementation
|
|
3610
|
-
* and passes credentials back through this interface.
|
|
3611
|
-
*
|
|
3612
|
-
* This replaces the previous stub OAuth classes (GoogleOAuth, SlackOAuth,
|
|
3613
|
-
* MicrosoftOAuth, GenericOAuth) with a single injection point.
|
|
3614
|
-
*/
|
|
3615
|
-
interface SourceOAuthProvider {
|
|
3616
|
-
/**
|
|
3617
|
-
* Authenticate a source via its provider-specific OAuth flow.
|
|
3618
|
-
* The host app opens a browser, handles the callback, and returns tokens.
|
|
3619
|
-
*/
|
|
3620
|
-
authenticate(sourceSlug: string, provider: "google" | "slack" | "microsoft" | "generic" | "mcp", options: SourceOAuthOptions): Promise<SourceAuthResult>;
|
|
3621
|
-
/**
|
|
3622
|
-
* Refresh an expired OAuth token for a source.
|
|
3623
|
-
*/
|
|
3624
|
-
refresh(sourceSlug: string, provider: "google" | "slack" | "microsoft" | "generic" | "mcp", refreshToken: string): Promise<SourceAuthResult>;
|
|
3625
|
-
}
|
|
3626
|
-
/**
|
|
3627
|
-
* Options for source OAuth authentication.
|
|
3628
|
-
* Generalized across all provider types — the host app interprets
|
|
3629
|
-
* provider-specific fields as needed.
|
|
3630
|
-
*/
|
|
3631
|
-
interface SourceOAuthOptions {
|
|
3632
|
-
/** Service identifier (e.g. "google-drive", "slack-workspace") */
|
|
3633
|
-
service?: string;
|
|
3634
|
-
/** OAuth scopes to request */
|
|
3635
|
-
scopes?: string[];
|
|
3636
|
-
/** App type context (e.g. "desktop", "web", "cli") */
|
|
3637
|
-
appType?: string;
|
|
3638
|
-
/** Callback port (host app decides actual port) */
|
|
3639
|
-
callbackPort?: number;
|
|
3640
|
-
/** Callback URL override */
|
|
3641
|
-
callbackUrl?: string;
|
|
3642
|
-
/** OAuth client ID (host app may have its own) */
|
|
3643
|
-
clientId?: string;
|
|
3644
|
-
/** OAuth client secret (host app may have its own) */
|
|
3645
|
-
clientSecret?: string;
|
|
3646
|
-
/** Session context for tracking */
|
|
3647
|
-
sessionContext?: OAuthSessionContext;
|
|
3648
|
-
}
|
|
3649
|
-
/**
|
|
3650
|
-
* No-op SourceOAuthProvider that throws on all operations.
|
|
3651
|
-
* Used when no host app OAuth implementation is injected.
|
|
3652
|
-
*/
|
|
3653
|
-
declare class StubSourceOAuthProvider implements SourceOAuthProvider {
|
|
3654
|
-
authenticate(): Promise<SourceAuthResult>;
|
|
3655
|
-
refresh(): Promise<SourceAuthResult>;
|
|
3656
|
-
}
|
|
3657
|
-
|
|
3658
|
-
/**
|
|
3659
|
-
* Credential Types — Stub for OSS extraction.
|
|
3660
|
-
*
|
|
3661
|
-
* Defines types for credential storage and lookup.
|
|
3662
|
-
*/
|
|
3663
|
-
interface CredentialId {
|
|
3664
|
-
type: 'source_oauth' | 'source_bearer' | 'source_apikey' | 'source_basic';
|
|
3665
|
-
workspaceId: string;
|
|
3666
|
-
sourceId: string;
|
|
3667
|
-
}
|
|
3668
|
-
interface StoredCredential {
|
|
3669
|
-
value: string;
|
|
3670
|
-
refreshToken?: string;
|
|
3671
|
-
expiresAt?: number;
|
|
3672
|
-
clientId?: string;
|
|
3673
|
-
clientSecret?: string;
|
|
3674
|
-
tokenType?: string;
|
|
3675
|
-
}
|
|
3676
|
-
|
|
3677
|
-
/**
|
|
3678
|
-
* SourceCredentialManager
|
|
3679
|
-
*
|
|
3680
|
-
* Unified credential management for sources. Consolidates credential CRUD,
|
|
3681
|
-
* credential ID resolution, expiry checking, and OAuth flows.
|
|
3682
|
-
*
|
|
3683
|
-
* This replaces scattered credential logic across:
|
|
3684
|
-
* - SourceService.getSourceToken()
|
|
3685
|
-
* - SourceService.getApiCredential()
|
|
3686
|
-
* - SourceService.getCredentialId()
|
|
3687
|
-
* - session-scoped-tools OAuth triggers
|
|
3688
|
-
* - IPC handlers for credential storage
|
|
3689
|
-
*
|
|
3690
|
-
* OAuth flows are delegated to the host application via SourceOAuthProvider.
|
|
3691
|
-
* Weft does NOT own browser callback servers or PKCE — the host app
|
|
3692
|
-
* (Electron, web UI, CLI) provides the actual OAuth implementation and
|
|
3693
|
-
* injects it through the constructor or setOAuthProvider() at startup.
|
|
3694
|
-
*/
|
|
3695
|
-
|
|
3696
|
-
/**
|
|
3697
|
-
* OAuth provider type for source credential routing.
|
|
3698
|
-
* Matches the SourceOAuthProvider.authenticate() provider parameter.
|
|
3699
|
-
*/
|
|
3700
|
-
type OAuthProvider = 'google' | 'slack' | 'microsoft' | 'generic' | 'mcp';
|
|
3701
|
-
/**
|
|
3702
|
-
* Result of authentication attempt
|
|
3703
|
-
*/
|
|
3704
|
-
interface AuthResult {
|
|
3705
|
-
success: boolean;
|
|
3706
|
-
error?: string;
|
|
3707
|
-
/** For Gmail OAuth, includes user's email */
|
|
3708
|
-
email?: string;
|
|
3709
|
-
}
|
|
3710
|
-
/**
|
|
3711
|
-
* API credential types (string for simple auth, object for basic auth or multi-header)
|
|
3712
|
-
*/
|
|
3713
|
-
interface BasicAuthCredential {
|
|
3714
|
-
username: string;
|
|
3715
|
-
password: string;
|
|
3716
|
-
}
|
|
3717
|
-
/**
|
|
3718
|
-
* Multi-header credentials stored as Record<string, string>
|
|
3719
|
-
* Used for APIs like Datadog that require multiple auth headers (DD-API-KEY + DD-APPLICATION-KEY)
|
|
3720
|
-
*/
|
|
3721
|
-
type MultiHeaderCredential = Record<string, string>;
|
|
3722
|
-
type ApiCredential = string | BasicAuthCredential | MultiHeaderCredential;
|
|
3723
|
-
/**
|
|
3724
|
-
* Type guard to check if credential is a MultiHeaderCredential.
|
|
3725
|
-
* Returns true for Record<string, string> objects that are NOT BasicAuthCredential.
|
|
3726
|
-
*/
|
|
3727
|
-
declare function isMultiHeaderCredential(cred: ApiCredential): cred is MultiHeaderCredential;
|
|
3728
|
-
/**
|
|
3729
|
-
* SourceCredentialManager - unified credential operations for sources
|
|
3730
|
-
*
|
|
3731
|
-
* Usage:
|
|
3732
|
-
* ```typescript
|
|
3733
|
-
* // Without OAuth provider (stub — errors on auth operations)
|
|
3734
|
-
* const credManager = new SourceCredentialManager();
|
|
3735
|
-
*
|
|
3736
|
-
* // With OAuth provider injected at construction
|
|
3737
|
-
* const credManager = new SourceCredentialManager(myOAuthProvider);
|
|
3738
|
-
*
|
|
3739
|
-
* // Or via the singleton accessor
|
|
3740
|
-
* const credManager = getSourceCredentialManager(myOAuthProvider);
|
|
3741
|
-
*
|
|
3742
|
-
* // Save credentials
|
|
3743
|
-
* await credManager.save(source, { value: 'token123' });
|
|
3744
|
-
*
|
|
3745
|
-
* // Load credentials
|
|
3746
|
-
* const cred = await credManager.load(source);
|
|
3747
|
-
*
|
|
3748
|
-
* // Run OAuth flow (requires host OAuthProvider to be injected)
|
|
3749
|
-
* const result = await credManager.authenticate(source);
|
|
3750
|
-
* ```
|
|
3751
|
-
*/
|
|
3752
|
-
declare class SourceCredentialManager {
|
|
3753
|
-
private pendingRefreshes;
|
|
3754
|
-
/**
|
|
3755
|
-
* Host-injected OAuth provider for source-level auth flows.
|
|
3756
|
-
* Weft does NOT own browser callback servers or PKCE — the host app
|
|
3757
|
-
* (Electron, web UI, CLI) provides the actual implementation.
|
|
3758
|
-
* Defaults to StubSourceOAuthProvider which returns errors for all operations.
|
|
3759
|
-
*/
|
|
3760
|
-
private oauthProvider;
|
|
3761
|
-
/**
|
|
3762
|
-
* Construct a SourceCredentialManager with optional OAuth provider injection.
|
|
3763
|
-
*
|
|
3764
|
-
* If no provider is given, defaults to StubSourceOAuthProvider which
|
|
3765
|
-
* returns errors for all OAuth operations. The host app should either:
|
|
3766
|
-
* 1. Pass its SourceOAuthProvider at construction
|
|
3767
|
-
* 2. Call setOAuthProvider() after construction
|
|
3768
|
-
*/
|
|
3769
|
-
constructor(oauthProvider?: SourceOAuthProvider);
|
|
3770
|
-
/**
|
|
3771
|
-
* Set the host OAuth provider. Called by the host application at startup
|
|
3772
|
-
* to inject its OAuth implementation (browser callbacks, PKCE, etc).
|
|
3773
|
-
*
|
|
3774
|
-
* This can also be used to replace the provider at runtime (e.g. when
|
|
3775
|
-
* the Electron app initializes after the credential manager singleton
|
|
3776
|
-
* has already been created).
|
|
3777
|
-
*/
|
|
3778
|
-
setOAuthProvider(provider: SourceOAuthProvider): void;
|
|
3779
|
-
/**
|
|
3780
|
-
* Save credential for a source
|
|
3781
|
-
*/
|
|
3782
|
-
save(source: LoadedSource, credential: StoredCredential): Promise<void>;
|
|
3783
|
-
/**
|
|
3784
|
-
* Load credential for a source
|
|
3785
|
-
*
|
|
3786
|
-
* For MCP sources, tries both OAuth and bearer credentials as fallback
|
|
3787
|
-
* (credentials may have been stored via different auth modes)
|
|
3788
|
-
*/
|
|
3789
|
-
load(source: LoadedSource): Promise<StoredCredential | null>;
|
|
3790
|
-
/**
|
|
3791
|
-
* Load MCP credential with fallback (OAuth -> bearer)
|
|
3792
|
-
*/
|
|
3793
|
-
private loadMcpCredential;
|
|
3794
|
-
/**
|
|
3795
|
-
* Delete credential for a source
|
|
3796
|
-
*/
|
|
3797
|
-
delete(source: LoadedSource): Promise<boolean>;
|
|
3798
|
-
/**
|
|
3799
|
-
* Get token value for a source (convenience method)
|
|
3800
|
-
* Returns null if no credential exists or if expired
|
|
3801
|
-
*/
|
|
3802
|
-
getToken(source: LoadedSource): Promise<string | null>;
|
|
3803
|
-
/**
|
|
3804
|
-
* Get API credential for a source (handles basic auth and multi-header JSON parsing)
|
|
3805
|
-
*/
|
|
3806
|
-
getApiCredential(source: LoadedSource): Promise<ApiCredential | null>;
|
|
3807
|
-
/**
|
|
3808
|
-
* Get the credential ID for a source
|
|
3809
|
-
*
|
|
3810
|
-
* Determines the correct credential type based on:
|
|
3811
|
-
* - Source type (mcp, api, local)
|
|
3812
|
-
* - Auth type (oauth, bearer, header, etc.)
|
|
3813
|
-
*/
|
|
3814
|
-
getCredentialId(source: LoadedSource): CredentialId;
|
|
3815
|
-
/**
|
|
3816
|
-
* Check if a credential is expired
|
|
3817
|
-
*/
|
|
3818
|
-
isExpired(credential: StoredCredential): boolean;
|
|
3819
|
-
/**
|
|
3820
|
-
* Check if a credential needs refresh (within 5 min of expiry)
|
|
3821
|
-
*/
|
|
3822
|
-
needsRefresh(credential: StoredCredential): boolean;
|
|
3823
|
-
/**
|
|
3824
|
-
* Mark a source as needing re-authentication.
|
|
3825
|
-
* Called when token is missing/expired or token refresh fails.
|
|
3826
|
-
* Updates config.json so the UI shows "needs auth" and the agent gets proper context.
|
|
3827
|
-
*/
|
|
3828
|
-
markSourceNeedsReauth(source: LoadedSource, errorMessage: string): void;
|
|
3829
|
-
/**
|
|
3830
|
-
* Check if source has valid (non-expired) credentials
|
|
3831
|
-
*/
|
|
3832
|
-
hasValidCredentials(source: LoadedSource): Promise<boolean>;
|
|
3833
|
-
/**
|
|
3834
|
-
* Detect the OAuth provider for a source.
|
|
3835
|
-
*/
|
|
3836
|
-
detectProvider(source: LoadedSource): OAuthProvider;
|
|
3837
|
-
/**
|
|
3838
|
-
* Check whether a source uses OAuth authentication.
|
|
3839
|
-
* Used to gate authenticate() and refresh() before delegating to oauthProvider.
|
|
3840
|
-
*/
|
|
3841
|
-
private isOAuthSource;
|
|
3842
|
-
/**
|
|
3843
|
-
* Build SourceOAuthOptions from source config for a given provider.
|
|
3844
|
-
*
|
|
3845
|
-
* Extracts provider-specific fields (service, scopes, clientId, etc.)
|
|
3846
|
-
* and maps them to the generalized SourceOAuthOptions interface.
|
|
3847
|
-
* The host app's SourceOAuthProvider implementation interprets these
|
|
3848
|
-
* fields as needed for its provider-specific OAuth flow.
|
|
3849
|
-
*/
|
|
3850
|
-
private buildOAuthOptions;
|
|
3851
|
-
/**
|
|
3852
|
-
* Authenticate a source via OAuth, delegating to the host app.
|
|
3853
|
-
*
|
|
3854
|
-
* The host app's SourceOAuthProvider handles the entire flow:
|
|
3855
|
-
* browser redirect, callback server, token exchange, and credential storage.
|
|
3856
|
-
* On success, the source is marked as authenticated in config.json.
|
|
3857
|
-
*
|
|
3858
|
-
* This replaces the previous prepare/exchange split (prepareOAuth + exchangeAndStore).
|
|
3859
|
-
* If a host app needs prepare/exchange separation, it implements that in its
|
|
3860
|
-
* SourceOAuthProvider.
|
|
3861
|
-
*/
|
|
3862
|
-
authenticate(source: LoadedSource, options?: {
|
|
3863
|
-
callbackPort?: number;
|
|
3864
|
-
callbackUrl?: string;
|
|
3865
|
-
sessionContext?: OAuthSessionContext;
|
|
3866
|
-
}): Promise<AuthResult>;
|
|
3867
|
-
/**
|
|
3868
|
-
* Refresh token for a source
|
|
3869
|
-
*
|
|
3870
|
-
* Returns the new access token, or null if refresh fails.
|
|
3871
|
-
* On success, credentials are automatically updated by the host app.
|
|
3872
|
-
*
|
|
3873
|
-
* Uses promise deduplication to prevent concurrent refresh requests for the same source.
|
|
3874
|
-
* This is important because:
|
|
3875
|
-
* - Multiple API calls may hit refresh simultaneously when token is expiring
|
|
3876
|
-
* - Microsoft rotates refresh tokens, so concurrent refreshes could cause token invalidation
|
|
3877
|
-
*/
|
|
3878
|
-
refresh(source: LoadedSource): Promise<string | null>;
|
|
3879
|
-
/**
|
|
3880
|
-
* Internal refresh implementation.
|
|
3881
|
-
*
|
|
3882
|
-
* Routes to:
|
|
3883
|
-
* 1. refreshApiRenew — for custom API renew endpoints (non-OAuth)
|
|
3884
|
-
* 2. oauthProvider.refresh() — for all OAuth providers (Google, Slack, Microsoft, Generic, MCP)
|
|
3885
|
-
*
|
|
3886
|
-
* The host app's refresh() implementation handles token refresh and credential storage.
|
|
3887
|
-
* After successful refresh, we reload the credential to return the new access token.
|
|
3888
|
-
*/
|
|
3889
|
-
private doRefresh;
|
|
3890
|
-
/**
|
|
3891
|
-
* Refresh token via a custom API renew endpoint (non-OAuth).
|
|
3892
|
-
* Uses the current access token for renewal — no separate refresh token needed.
|
|
3893
|
-
*/
|
|
3894
|
-
private refreshApiRenew;
|
|
3895
|
-
}
|
|
3896
|
-
|
|
3897
|
-
declare class EncryptedCredentialBackend {
|
|
3898
|
-
private filePath;
|
|
3899
|
-
private cache;
|
|
3900
|
-
constructor(filePath?: string);
|
|
3901
|
-
get(id: CredentialId): Promise<StoredCredential | null>;
|
|
3902
|
-
set(id: CredentialId, credential: StoredCredential): Promise<void>;
|
|
3903
|
-
delete(id: CredentialId): Promise<boolean>;
|
|
3904
|
-
list(filter?: Partial<CredentialId>): Promise<CredentialId[]>;
|
|
3905
|
-
private load;
|
|
3906
|
-
private save;
|
|
3907
|
-
}
|
|
3908
|
-
|
|
3909
|
-
declare function getMachineId(): string;
|
|
3910
|
-
|
|
3911
|
-
interface CredentialManager {
|
|
3912
|
-
get(id: CredentialId): Promise<StoredCredential | null>;
|
|
3913
|
-
set(id: CredentialId, credential: StoredCredential): Promise<void>;
|
|
3914
|
-
delete(id: CredentialId): Promise<boolean>;
|
|
3915
|
-
}
|
|
3916
|
-
declare class InMemoryCredentialManager implements CredentialManager {
|
|
3917
|
-
private store;
|
|
3918
|
-
private key;
|
|
3919
|
-
get(id: CredentialId): Promise<StoredCredential | null>;
|
|
3920
|
-
set(id: CredentialId, credential: StoredCredential): Promise<void>;
|
|
3921
|
-
delete(id: CredentialId): Promise<boolean>;
|
|
3922
|
-
}
|
|
3923
|
-
|
|
3924
|
-
interface CreateCredentialManagerOptions {
|
|
3925
|
-
backend?: 'encrypted' | 'memory';
|
|
3926
|
-
filePath?: string;
|
|
3927
|
-
}
|
|
3928
|
-
declare function getCredentialManager(options?: CreateCredentialManagerOptions): CredentialManager;
|
|
3929
|
-
declare function resetCredentialManager(): void;
|
|
3930
|
-
|
|
3931
|
-
/**
|
|
3932
|
-
* Source Storage
|
|
3933
|
-
*
|
|
3934
|
-
* CRUD operations for workspace-scoped sources.
|
|
3935
|
-
* Sources are stored at {workspaceRootPath}/sources/{sourceSlug}/
|
|
3936
|
-
*
|
|
3937
|
-
* Note: All functions take `workspaceRootPath` (absolute path to workspace folder),
|
|
3938
|
-
* NOT a workspace slug. The `LoadedSource.workspaceId` is derived via basename().
|
|
3939
|
-
*/
|
|
3940
|
-
|
|
3941
|
-
/**
|
|
3942
|
-
* Load source config.json
|
|
3943
|
-
*/
|
|
3944
|
-
declare function loadSourceConfig(workspaceRootPath: string, sourceSlug: string): FolderSourceConfig | null;
|
|
3945
|
-
/**
|
|
3946
|
-
* Save source config.json
|
|
3947
|
-
* @throws Error if config is invalid
|
|
3948
|
-
*/
|
|
3949
|
-
declare function saveSourceConfig(workspaceRootPath: string, config: FolderSourceConfig): void;
|
|
3950
|
-
/**
|
|
3951
|
-
* Load complete source with all files
|
|
3952
|
-
* @param workspaceRootPath - Absolute path to workspace folder (e.g., ~/.weft/workspaces/xxx)
|
|
3953
|
-
* @param sourceSlug - Source folder name
|
|
3954
|
-
*/
|
|
3955
|
-
declare function loadSource(workspaceRootPath: string, sourceSlug: string): LoadedSource | null;
|
|
3956
|
-
/**
|
|
3957
|
-
* Load all sources for a workspace INCLUDING built-in sources.
|
|
3958
|
-
* Built-in sources are always available and merged
|
|
3959
|
-
* with user-configured sources from the workspace.
|
|
3960
|
-
*
|
|
3961
|
-
* Use this when the agent needs visibility into all available sources,
|
|
3962
|
-
* including system-provided ones that don't live on disk.
|
|
3963
|
-
*/
|
|
3964
|
-
declare function loadAllSources(workspaceRootPath: string): LoadedSource[];
|
|
3965
|
-
/**
|
|
3966
|
-
* Create a new source in a workspace
|
|
3967
|
-
*/
|
|
3968
|
-
declare function createSource(workspaceRootPath: string, input: CreateSourceInput): Promise<FolderSourceConfig>;
|
|
3969
|
-
/**
|
|
3970
|
-
* Delete a source from a workspace
|
|
3971
|
-
*/
|
|
3972
|
-
declare function deleteSource(workspaceRootPath: string, sourceSlug: string): void;
|
|
3973
|
-
/**
|
|
3974
|
-
* Check if a source exists in a workspace
|
|
3975
|
-
*/
|
|
3976
|
-
declare function sourceExists(workspaceRootPath: string, sourceSlug: string): boolean;
|
|
3977
|
-
|
|
3978
|
-
export { type ApiConfig, type ApiCredential, type AuthResult, type BasicAuthCredential, type CreateCredentialManagerOptions, type CreateSourceActivationPlanOptions, type CreateSourceInput, type CreateSourceRuntimeAssemblyPlanOptions, type CreateSourceToolAssemblyPlanOptions, type CredentialId, type CredentialManager, EncryptedCredentialBackend, InMemoryCredentialManager, type LoadedSource, type MultiHeaderCredential, type ApiOAuthConfig as OAuthConfig, type SourceActivationPlan, type SourceActivationStatus, type SourceBrand, type FolderSourceConfig as SourceConfig, SourceCredentialManager, type SourceCredentialRef, type SourceCredentialRefType, type SourceConnectionStatus as SourceHealthStatus, type SourceMcpAuthType, type SourceOAuthOptions, type SourceOAuthProvider, type SourceProviderAuthStatus, type SourceRuntimeAssemblyPlan, type SourceRuntimeCapabilityDegradation, type SourceRuntimeProviderOptions, type SourceStateSnapshot, type SourceToolAssemblyPlan, type SourceToolDescriptor, type ValidationIssue as SourceValidationIssue, type ValidationResult as SourceValidationResult, type StoredCredential, StubSourceOAuthProvider, createSource, createSourceActivationPlan, createSourceRuntimeAssemblyPlan, createSourceRuntimeProviderOptions, createSourceToolAssemblyPlan, deleteSource, getBuiltinSources, getCredentialManager, getMachineId, isMultiHeaderCredential, loadAllSources, loadSource, loadSourceConfig, providerAuthToSourceStatus, resetCredentialManager, saveSourceConfig, sourceExists, validateSourceConfig };
|