@robota-sdk/agent-sdk 3.0.0-beta.6 → 3.0.0-beta.61
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/README.md +441 -24
- package/dist/node/index.cjs +8062 -542
- package/dist/node/index.d.cts +2347 -230
- package/dist/node/index.d.ts +2347 -230
- package/dist/node/index.js +7891 -528
- package/package.json +18 -6
package/dist/node/index.d.cts
CHANGED
|
@@ -1,191 +1,1603 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
export {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ISessionReplayValidationResult, ICompactEvent, ITerminalOutput, ISessionLogger, TPermissionHandler, Session, FileSessionLogger } from '@robota-sdk/agent-sessions';
|
|
2
|
+
import { TUniversalValue, TSessionEndReason, TPermissionMode, IToolWithEventService, IContextWindowState, IProviderProfileConfig, IProviderDefinition, TProviderSetupField, IProviderSetupStepDefinition, IProviderSetupHelpLink, IProviderProbeResult, IProviderModelCatalog, IHistoryEntry, TToolArgs, THooksConfig, IAIProvider, IHookTypeExecutor, IHookDefinition, IHookInput, IHookResult, TTrustLevel, TUniversalMessage, IToolSchema } from '@robota-sdk/agent-core';
|
|
3
|
+
import { IBackgroundTaskManager, TBackgroundTaskStatus, IBackgroundTaskError, IBackgroundTaskListFilter, IBackgroundTaskState, IBackgroundTaskLogCursor, IBackgroundTaskLogPage, TBackgroundTaskEvent, ISubagentRunner, IBackgroundTaskRunner, IBackgroundTaskInput, ISubagentJobState, TBackgroundTaskIsolation, ISubagentJobResult, ISubagentManager } from '@robota-sdk/agent-runtime';
|
|
4
|
+
export { BackgroundTaskError, BackgroundTaskManager, DEFAULT_BACKGROUND_TASK_LOG_PAGE_SIZE, IAgentBackgroundTaskRequest, IBackgroundTaskError, IBackgroundTaskHandle, IBackgroundTaskInput, IBackgroundTaskListFilter, IBackgroundTaskLogCursor, IBackgroundTaskLogPage, IBackgroundTaskManager, IBackgroundTaskManagerOptions, IBackgroundTaskRequest, IBackgroundTaskResult, IBackgroundTaskRunner, IBackgroundTaskStart, IBackgroundTaskState, IBaseBackgroundTaskRequest, ICreateLimitedOutputCaptureOptions, ILimitedOutputCapture, IPreparedSubagentWorktree, IProcessBackgroundTaskRequest, ISerializableProviderProfile, ISubagentJobHandle, ISubagentJobResult, ISubagentJobStart, ISubagentJobState, ISubagentManager, ISubagentManagerOptions, ISubagentRunner, ISubagentSpawnRequest, ISubagentWorktreeAdapter, ISubagentWorktreePrepareRequest, IWorktreeSubagentRunnerOptions, SubagentManager, TBackgroundPermissionPolicy, TBackgroundPrimitive, TBackgroundTaskErrorCategory, TBackgroundTaskEvent, TBackgroundTaskEventListener, TBackgroundTaskIdFactory, TBackgroundTaskIsolation, TBackgroundTaskKind, TBackgroundTaskMode, TBackgroundTaskRunnerEvent, TBackgroundTaskStatus, TBackgroundTaskTimeoutReason, TBackgroundTaskTransitionEvent, TSubagentJobMode, TSubagentJobStatus, WorktreeSubagentRunner, appendPrefixedLogLines, createBackgroundTaskLogPage, createLimitedOutputCapture, createWorktreeSubagentRunner, getBackgroundTaskTransitions, isTerminalBackgroundTaskStatus, transitionBackgroundTaskStatus } from '@robota-sdk/agent-runtime';
|
|
5
|
+
import { ISandboxClient, IWorkspaceManifest, createZodFunctionTool } from '@robota-sdk/agent-tools';
|
|
6
|
+
|
|
7
|
+
type TCapabilityKind = 'builtin-command' | 'skill' | 'agent' | 'tool';
|
|
8
|
+
type TCapabilitySafety = 'read-only' | 'write' | 'process' | 'network' | 'background-agent';
|
|
9
|
+
interface ICapabilityDescriptor {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly kind: TCapabilityKind;
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly userInvocable: boolean;
|
|
14
|
+
readonly modelInvocable: boolean;
|
|
15
|
+
readonly argumentHint?: string;
|
|
16
|
+
readonly safety?: TCapabilitySafety;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A command entry */
|
|
20
|
+
interface ICommand {
|
|
21
|
+
/** Command name without slash (e.g., "mode") */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Short description shown in autocomplete */
|
|
24
|
+
description: string;
|
|
25
|
+
/** Source identifier (e.g., "builtin", "skill") */
|
|
26
|
+
source: string;
|
|
27
|
+
/** Subcommands for hierarchical menus */
|
|
28
|
+
subcommands?: ICommand[];
|
|
29
|
+
/** Execute the command. Args is everything after the command name. */
|
|
30
|
+
execute?: (args: string) => void | Promise<void>;
|
|
31
|
+
/** Full SKILL.md content (only for skill commands) */
|
|
32
|
+
skillContent?: string;
|
|
33
|
+
/** Hint for the expected argument (Claude Code frontmatter) */
|
|
34
|
+
argumentHint?: string;
|
|
35
|
+
/** When true, models cannot invoke this skill autonomously */
|
|
36
|
+
disableModelInvocation?: boolean;
|
|
37
|
+
/** When true, models may invoke this command through the SDK-projected command tool */
|
|
38
|
+
modelInvocable?: boolean;
|
|
39
|
+
/** When false, users cannot invoke this skill directly */
|
|
40
|
+
userInvocable?: boolean;
|
|
41
|
+
/** Safety category for model-visible capability descriptors */
|
|
42
|
+
safety?: TCapabilitySafety;
|
|
43
|
+
/** List of tools this skill is allowed to use */
|
|
44
|
+
allowedTools?: string[];
|
|
45
|
+
/** Preferred model for executing this skill */
|
|
46
|
+
model?: string;
|
|
47
|
+
/** Effort level hint for the skill */
|
|
48
|
+
effort?: string;
|
|
49
|
+
/** Context scope for the skill (e.g., "project") */
|
|
50
|
+
context?: string;
|
|
51
|
+
/** Agent identity to use when executing this skill */
|
|
52
|
+
agent?: string;
|
|
53
|
+
/** Plugin installation directory (plugin skills/commands only) */
|
|
54
|
+
pluginDir?: string;
|
|
55
|
+
}
|
|
56
|
+
/** A source that provides commands */
|
|
57
|
+
interface ICommandSource {
|
|
58
|
+
name: string;
|
|
59
|
+
getCommands(): ICommand[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare const STATUSLINE_COMMAND_DESCRIPTION = "Configure TUI status-line visibility and fields such as model, context, tokens, session, and git branch.";
|
|
63
|
+
declare const STATUSLINE_COMMAND_ARGUMENT_HINT = "on | off | reset | git on | git off";
|
|
64
|
+
interface IStatusLineCommandSettings {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
gitBranch: boolean;
|
|
67
|
+
}
|
|
68
|
+
type TStatusLineCommandSettingsPatch = Partial<IStatusLineCommandSettings> & Record<string, TUniversalValue>;
|
|
69
|
+
declare const DEFAULT_STATUS_LINE_COMMAND_SETTINGS: Readonly<IStatusLineCommandSettings>;
|
|
70
|
+
declare function buildStatusLineCommandSubcommands(source?: string): ICommand[];
|
|
71
|
+
declare function isStatusLineCommandSettingsPatch(value: Record<string, TUniversalValue>): value is TStatusLineCommandSettingsPatch;
|
|
72
|
+
|
|
73
|
+
type TCommandEffect = {
|
|
74
|
+
type: 'model-change-requested';
|
|
75
|
+
modelId: string;
|
|
76
|
+
} | {
|
|
77
|
+
type: 'language-change-requested';
|
|
78
|
+
language: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'settings-reset-requested';
|
|
81
|
+
} | {
|
|
82
|
+
type: 'session-exit-requested';
|
|
83
|
+
reason?: TSessionEndReason;
|
|
84
|
+
message?: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: 'session-restart-requested';
|
|
87
|
+
reason: TSessionEndReason;
|
|
88
|
+
message: string;
|
|
89
|
+
} | {
|
|
90
|
+
type: 'plugin-tui-requested';
|
|
91
|
+
} | {
|
|
92
|
+
type: 'plugin-registry-reload-requested';
|
|
93
|
+
} | {
|
|
94
|
+
type: 'session-picker-requested';
|
|
95
|
+
} | {
|
|
96
|
+
type: 'session-renamed';
|
|
97
|
+
name: string;
|
|
98
|
+
} | {
|
|
99
|
+
type: 'conversation-history-cleared';
|
|
100
|
+
} | {
|
|
101
|
+
type: 'session-execution-started';
|
|
102
|
+
} | {
|
|
103
|
+
type: 'statusline-settings-patch';
|
|
104
|
+
patch: TStatusLineCommandSettingsPatch;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Choice option for command-owned follow-up prompts. */
|
|
108
|
+
interface ICommandChoicePromptOption {
|
|
109
|
+
value: string;
|
|
110
|
+
label: string;
|
|
111
|
+
}
|
|
112
|
+
/** Generic prompt descriptor rendered by host UIs for command interactions. */
|
|
113
|
+
type TCommandInteractionPrompt = {
|
|
114
|
+
kind: 'choice';
|
|
115
|
+
title: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
options: readonly ICommandChoicePromptOption[];
|
|
118
|
+
maxVisible?: number;
|
|
119
|
+
} | {
|
|
120
|
+
kind: 'text';
|
|
121
|
+
title: string;
|
|
122
|
+
description?: string;
|
|
123
|
+
placeholder?: string;
|
|
124
|
+
allowEmpty?: boolean;
|
|
125
|
+
masked?: boolean;
|
|
126
|
+
validate?: (value: string) => string | undefined;
|
|
127
|
+
};
|
|
128
|
+
/** Stateful command continuation owned by the command module. */
|
|
129
|
+
interface ICommandInteraction {
|
|
130
|
+
prompt: TCommandInteractionPrompt;
|
|
131
|
+
submit(value: string): Promise<ICommandResult> | ICommandResult;
|
|
132
|
+
cancel?(): Promise<ICommandResult> | ICommandResult;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
type TCommandResultDataValue = TUniversalValue | object | readonly object[];
|
|
136
|
+
/** Result of a system command execution. */
|
|
137
|
+
interface ICommandResult {
|
|
138
|
+
/** Human-readable output message */
|
|
139
|
+
message: string;
|
|
140
|
+
/** Command completed successfully */
|
|
141
|
+
success: boolean;
|
|
142
|
+
/** Additional structured data (command-specific diagnostics only) */
|
|
143
|
+
data?: Record<string, TCommandResultDataValue>;
|
|
144
|
+
/** Typed host effects requested by the command */
|
|
145
|
+
effects?: readonly TCommandEffect[];
|
|
146
|
+
/** Command-owned follow-up prompt and continuation */
|
|
147
|
+
interaction?: ICommandInteraction;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
type TBackgroundJobWaitPolicy = 'detached' | 'wait_all' | 'wait_any' | 'manual';
|
|
151
|
+
type TBackgroundJobGroupStatus = 'running' | 'completed';
|
|
152
|
+
interface IBackgroundJobResultEnvelope {
|
|
153
|
+
taskId: string;
|
|
154
|
+
label: string;
|
|
155
|
+
status: TBackgroundTaskStatus;
|
|
156
|
+
summary?: string;
|
|
157
|
+
outputRef?: string;
|
|
158
|
+
error?: IBackgroundTaskError;
|
|
159
|
+
startedAt?: string;
|
|
160
|
+
completedAt?: string;
|
|
161
|
+
}
|
|
162
|
+
interface IBackgroundJobGroupState {
|
|
163
|
+
id: string;
|
|
164
|
+
parentSessionId: string;
|
|
165
|
+
waitPolicy: TBackgroundJobWaitPolicy;
|
|
166
|
+
taskIds: string[];
|
|
167
|
+
status: TBackgroundJobGroupStatus;
|
|
168
|
+
createdAt: string;
|
|
169
|
+
updatedAt: string;
|
|
170
|
+
label?: string;
|
|
171
|
+
completedAt?: string;
|
|
172
|
+
results: IBackgroundJobResultEnvelope[];
|
|
173
|
+
}
|
|
174
|
+
interface IBackgroundJobGroupSummary {
|
|
175
|
+
groupId: string;
|
|
176
|
+
status: TBackgroundJobGroupStatus;
|
|
177
|
+
total: number;
|
|
178
|
+
completed: number;
|
|
179
|
+
failed: number;
|
|
180
|
+
cancelled: number;
|
|
181
|
+
pending: number;
|
|
182
|
+
lines: string[];
|
|
183
|
+
}
|
|
184
|
+
interface IBackgroundJobGroupCreateRequest {
|
|
185
|
+
parentSessionId: string;
|
|
186
|
+
waitPolicy: TBackgroundJobWaitPolicy;
|
|
187
|
+
taskIds: string[];
|
|
188
|
+
label?: string;
|
|
189
|
+
}
|
|
190
|
+
type TBackgroundJobGroupEvent = {
|
|
191
|
+
type: 'background_job_group_created';
|
|
192
|
+
group: IBackgroundJobGroupState;
|
|
193
|
+
} | {
|
|
194
|
+
type: 'background_job_group_updated';
|
|
195
|
+
group: IBackgroundJobGroupState;
|
|
196
|
+
} | {
|
|
197
|
+
type: 'background_job_group_completed';
|
|
198
|
+
group: IBackgroundJobGroupState;
|
|
199
|
+
};
|
|
200
|
+
type TBackgroundJobGroupEventListener = (event: TBackgroundJobGroupEvent) => void;
|
|
201
|
+
type TBackgroundJobGroupIdFactory = (request: IBackgroundJobGroupCreateRequest) => string;
|
|
202
|
+
interface IBackgroundJobOrchestratorOptions {
|
|
203
|
+
manager: IBackgroundTaskManager;
|
|
204
|
+
now?: () => string;
|
|
205
|
+
idFactory?: TBackgroundJobGroupIdFactory;
|
|
206
|
+
initialGroups?: readonly IBackgroundJobGroupState[];
|
|
207
|
+
}
|
|
208
|
+
declare class BackgroundJobOrchestrator {
|
|
209
|
+
private readonly manager;
|
|
210
|
+
private readonly now;
|
|
211
|
+
private readonly idFactory;
|
|
212
|
+
private readonly unsubscribeManager;
|
|
213
|
+
private readonly listeners;
|
|
214
|
+
private readonly groups;
|
|
215
|
+
private sequence;
|
|
216
|
+
constructor(options: IBackgroundJobOrchestratorOptions);
|
|
217
|
+
createGroup(request: IBackgroundJobGroupCreateRequest): IBackgroundJobGroupState;
|
|
218
|
+
listGroups(): IBackgroundJobGroupState[];
|
|
219
|
+
getGroup(groupId: string): IBackgroundJobGroupState | undefined;
|
|
220
|
+
waitGroup(groupId: string): Promise<IBackgroundJobGroupState>;
|
|
221
|
+
subscribe(listener: TBackgroundJobGroupEventListener): () => void;
|
|
222
|
+
dispose(): void;
|
|
223
|
+
private nextGroupId;
|
|
224
|
+
private restoreGroup;
|
|
225
|
+
private createRecord;
|
|
226
|
+
private captureExistingTerminalTasks;
|
|
227
|
+
private handleTaskEvent;
|
|
228
|
+
private captureTask;
|
|
229
|
+
private evaluateCompletion;
|
|
230
|
+
private emit;
|
|
231
|
+
}
|
|
232
|
+
declare function summarizeBackgroundJobGroup(group: IBackgroundJobGroupState): IBackgroundJobGroupSummary;
|
|
233
|
+
|
|
234
|
+
declare const PLUGIN_COMMAND_DESCRIPTION = "Manage plugins";
|
|
235
|
+
declare const PLUGIN_COMMAND_ARGUMENT_HINT = "manage | install <name@marketplace> | uninstall <name@marketplace> | enable <name@marketplace> | disable <name@marketplace> | marketplace <action>";
|
|
236
|
+
declare const RELOAD_PLUGINS_COMMAND_DESCRIPTION = "Reload all plugin resources";
|
|
237
|
+
type TPluginInstallScope = 'user' | 'project';
|
|
238
|
+
interface ICommandInstalledPlugin {
|
|
239
|
+
name: string;
|
|
240
|
+
description: string;
|
|
241
|
+
enabled: boolean;
|
|
242
|
+
}
|
|
243
|
+
interface ICommandAvailablePlugin {
|
|
244
|
+
name: string;
|
|
245
|
+
description: string;
|
|
246
|
+
installed: boolean;
|
|
247
|
+
}
|
|
248
|
+
interface ICommandMarketplaceSource {
|
|
249
|
+
name: string;
|
|
250
|
+
type: string;
|
|
251
|
+
}
|
|
252
|
+
interface ICommandPluginReloadResult {
|
|
253
|
+
loadedPluginCount: number;
|
|
254
|
+
}
|
|
255
|
+
interface ICommandPluginAdapter {
|
|
256
|
+
listInstalled(): Promise<readonly ICommandInstalledPlugin[]>;
|
|
257
|
+
listAvailablePlugins(marketplace: string): Promise<readonly ICommandAvailablePlugin[]>;
|
|
258
|
+
install(pluginId: string, scope?: TPluginInstallScope): Promise<void>;
|
|
259
|
+
uninstall(pluginId: string): Promise<void>;
|
|
260
|
+
enable(pluginId: string): Promise<void>;
|
|
261
|
+
disable(pluginId: string): Promise<void>;
|
|
262
|
+
marketplaceAdd(source: string): Promise<string>;
|
|
263
|
+
marketplaceRemove(name: string): Promise<void>;
|
|
264
|
+
marketplaceUpdate(name: string): Promise<void>;
|
|
265
|
+
marketplaceList(): Promise<readonly ICommandMarketplaceSource[]>;
|
|
266
|
+
reloadPlugins(): Promise<ICommandPluginReloadResult>;
|
|
267
|
+
}
|
|
268
|
+
declare function createPluginTuiRequestedEffect(): TCommandEffect;
|
|
269
|
+
declare function createPluginRegistryReloadRequestedEffect(): TCommandEffect;
|
|
270
|
+
declare function resolvePluginCommandAdapter(context: ICommandHostContext): ICommandPluginAdapter | undefined;
|
|
271
|
+
declare function buildPluginCommandSubcommands(): ICommand[];
|
|
272
|
+
|
|
273
|
+
interface ICommandSettingsDocument {
|
|
274
|
+
[key: string]: TUniversalValue;
|
|
275
|
+
}
|
|
276
|
+
interface ICommandSettingsAdapter<TSettings extends ICommandSettingsDocument = ICommandSettingsDocument> {
|
|
277
|
+
read(): TSettings;
|
|
278
|
+
write(settings: TSettings): void;
|
|
279
|
+
}
|
|
280
|
+
interface ICommandProcessAdapter {
|
|
281
|
+
requestExit(reason?: TSessionEndReason): void;
|
|
282
|
+
requestRestart(reason: TSessionEndReason, message: string): void;
|
|
283
|
+
}
|
|
284
|
+
interface ICommandPickerAdapter<TItem extends ICommandSettingsDocument> {
|
|
285
|
+
pick(items: readonly TItem[]): Promise<TItem | undefined> | TItem | undefined;
|
|
286
|
+
}
|
|
287
|
+
interface ICommandPermissionModeAdapter {
|
|
288
|
+
getPermissionMode(): TPermissionMode;
|
|
289
|
+
setPermissionMode(mode: TPermissionMode): void;
|
|
290
|
+
listSessionAllowedTools(): readonly string[];
|
|
291
|
+
}
|
|
292
|
+
interface ICommandHostAdapters {
|
|
293
|
+
settings?: ICommandSettingsAdapter;
|
|
294
|
+
process?: ICommandProcessAdapter;
|
|
295
|
+
permissionMode?: ICommandPermissionModeAdapter;
|
|
296
|
+
plugin?: ICommandPluginAdapter;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
interface IEditCheckpointRecorder {
|
|
300
|
+
captureFile(filePath: string): Promise<void> | void;
|
|
301
|
+
}
|
|
302
|
+
interface IEditCheckpointTurnInput {
|
|
303
|
+
sessionId: string;
|
|
304
|
+
prompt: string;
|
|
305
|
+
}
|
|
306
|
+
interface IEditCheckpointSummary {
|
|
307
|
+
id: string;
|
|
308
|
+
sessionId: string;
|
|
309
|
+
sequence: number;
|
|
310
|
+
prompt: string;
|
|
311
|
+
createdAt: string;
|
|
312
|
+
fileCount: number;
|
|
313
|
+
}
|
|
314
|
+
interface IEditCheckpointFileRecord {
|
|
315
|
+
originalPath: string;
|
|
316
|
+
existed: boolean;
|
|
317
|
+
snapshotFile?: string;
|
|
318
|
+
}
|
|
319
|
+
interface IEditCheckpointManifest extends IEditCheckpointSummary {
|
|
320
|
+
version: 1;
|
|
321
|
+
files: IEditCheckpointFileRecord[];
|
|
322
|
+
}
|
|
323
|
+
type TEditCheckpointFileRestoreAction = 'restore-preimage' | 'delete-created-file';
|
|
324
|
+
interface IEditCheckpointFileInspection {
|
|
325
|
+
originalPath: string;
|
|
326
|
+
relativePath: string;
|
|
327
|
+
existed: boolean;
|
|
328
|
+
restoreAction: TEditCheckpointFileRestoreAction;
|
|
329
|
+
snapshotAvailable: boolean;
|
|
330
|
+
snapshotSizeBytes?: number;
|
|
331
|
+
}
|
|
332
|
+
interface IEditCheckpointInspectionPlan {
|
|
333
|
+
checkpointIds: string[];
|
|
334
|
+
fileCount: number;
|
|
335
|
+
}
|
|
336
|
+
interface IEditCheckpointInspection {
|
|
337
|
+
target: IEditCheckpointSummary;
|
|
338
|
+
capturedFiles: IEditCheckpointFileInspection[];
|
|
339
|
+
restoreToCheckpoint: IEditCheckpointInspectionPlan;
|
|
340
|
+
rollbackThroughCheckpoint: IEditCheckpointInspectionPlan;
|
|
341
|
+
}
|
|
342
|
+
interface IEditCheckpointRestoreResult {
|
|
343
|
+
target: IEditCheckpointSummary;
|
|
344
|
+
restoredCheckpointCount: number;
|
|
345
|
+
restoredFileCount: number;
|
|
346
|
+
removedCheckpointCount: number;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
interface IEditCheckpointStoreOptions {
|
|
350
|
+
cwd: string;
|
|
351
|
+
now?: () => Date;
|
|
352
|
+
}
|
|
353
|
+
declare class EditCheckpointStore {
|
|
354
|
+
private readonly cwd;
|
|
355
|
+
private readonly rootDir;
|
|
356
|
+
private readonly now;
|
|
357
|
+
private activeTurn;
|
|
358
|
+
constructor(options: IEditCheckpointStoreOptions);
|
|
359
|
+
beginTurn(input: IEditCheckpointTurnInput): Promise<IEditCheckpointSummary>;
|
|
360
|
+
captureFile(filePath: string): Promise<void>;
|
|
361
|
+
finalizeTurn(): Promise<IEditCheckpointSummary | undefined>;
|
|
362
|
+
list(sessionId: string): IEditCheckpointSummary[];
|
|
363
|
+
inspect(sessionId: string, checkpointId: string): IEditCheckpointInspection;
|
|
364
|
+
restoreToCheckpoint(sessionId: string, checkpointId: string): Promise<IEditCheckpointRestoreResult>;
|
|
365
|
+
rollbackThroughCheckpoint(sessionId: string, checkpointId: string): Promise<IEditCheckpointRestoreResult>;
|
|
366
|
+
private createFileRecord;
|
|
367
|
+
private restoreFile;
|
|
368
|
+
private loadManifests;
|
|
369
|
+
private nextSequence;
|
|
370
|
+
private writeManifest;
|
|
371
|
+
private sessionDir;
|
|
372
|
+
private checkpointDir;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
declare function wrapEditCheckpointTools(tools: readonly IToolWithEventService[], recorder: IEditCheckpointRecorder): IToolWithEventService[];
|
|
376
|
+
|
|
377
|
+
declare const MEMORY_INDEX_MAX_LINES = 200;
|
|
378
|
+
declare const MEMORY_INDEX_MAX_BYTES: number;
|
|
379
|
+
type TMemoryType = 'user' | 'feedback' | 'project' | 'reference';
|
|
380
|
+
interface IStartupMemory {
|
|
381
|
+
content: string;
|
|
382
|
+
path: string;
|
|
383
|
+
lineCount: number;
|
|
384
|
+
truncated: boolean;
|
|
385
|
+
}
|
|
386
|
+
interface IMemoryTopicSummary {
|
|
387
|
+
name: string;
|
|
388
|
+
path: string;
|
|
389
|
+
}
|
|
390
|
+
interface IProjectMemorySummary {
|
|
391
|
+
indexPath: string;
|
|
392
|
+
topicsPath: string;
|
|
393
|
+
topics: IMemoryTopicSummary[];
|
|
394
|
+
}
|
|
395
|
+
interface IAppendMemoryInput {
|
|
396
|
+
type: TMemoryType;
|
|
397
|
+
topic: string;
|
|
398
|
+
text: string;
|
|
399
|
+
}
|
|
400
|
+
interface IAppendMemoryResult {
|
|
401
|
+
indexPath: string;
|
|
402
|
+
topicPath: string;
|
|
403
|
+
topic: string;
|
|
404
|
+
deduplicated: boolean;
|
|
405
|
+
}
|
|
406
|
+
declare function isMemoryType(value: string): value is TMemoryType;
|
|
407
|
+
declare class ProjectMemoryStore {
|
|
408
|
+
private readonly cwd;
|
|
409
|
+
private readonly now;
|
|
410
|
+
constructor(cwd: string, now?: () => Date);
|
|
411
|
+
getIndexPath(): string;
|
|
412
|
+
getTopicsPath(): string;
|
|
413
|
+
loadStartupMemory(): IStartupMemory;
|
|
414
|
+
list(): IProjectMemorySummary;
|
|
415
|
+
readTopic(topic: string): string;
|
|
416
|
+
append(input: IAppendMemoryInput): IAppendMemoryResult;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
type TMemoryCandidateStatus = 'pending' | 'approved' | 'rejected' | 'saved' | 'skipped';
|
|
420
|
+
interface IMemoryCandidate {
|
|
421
|
+
id: string;
|
|
422
|
+
type: TMemoryType;
|
|
423
|
+
topic: string;
|
|
424
|
+
text: string;
|
|
425
|
+
sourceMessageIds: string[];
|
|
426
|
+
confidence: number;
|
|
427
|
+
createdAt: string;
|
|
428
|
+
reason: string;
|
|
429
|
+
}
|
|
430
|
+
interface IMemoryPendingRecord extends IMemoryCandidate {
|
|
431
|
+
status: TMemoryCandidateStatus;
|
|
432
|
+
updatedAt: string;
|
|
433
|
+
decisionReason?: string;
|
|
434
|
+
}
|
|
435
|
+
interface IMemoryReference {
|
|
436
|
+
topic: string;
|
|
437
|
+
path: string;
|
|
438
|
+
score: number;
|
|
439
|
+
truncated: boolean;
|
|
440
|
+
}
|
|
441
|
+
interface IMemoryEvent {
|
|
442
|
+
type: 'memory_candidate_extracted' | 'memory_candidate_queued' | 'memory_candidate_saved' | 'memory_candidate_skipped' | 'memory_candidate_approved' | 'memory_candidate_rejected' | 'memory_retrieved';
|
|
443
|
+
at: string;
|
|
444
|
+
candidateId?: string;
|
|
445
|
+
topic?: string;
|
|
446
|
+
reason?: string;
|
|
447
|
+
data?: Record<string, TUniversalValue>;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
type TPromptFileReferenceReason = 'manual' | 'prompt-reference';
|
|
451
|
+
type TPromptFileReferenceDiagnosticCode = 'not-found' | 'outside-root' | 'directory-not-supported' | 'file-too-large' | 'total-too-large' | 'too-many-references' | 'max-depth' | 'circular-reference' | 'unreadable';
|
|
452
|
+
interface IPromptFileReferenceToken {
|
|
453
|
+
original: string;
|
|
454
|
+
path: string;
|
|
455
|
+
index: number;
|
|
456
|
+
}
|
|
457
|
+
interface IPromptFileReferenceRecord {
|
|
458
|
+
originalReference: string;
|
|
459
|
+
sourcePath: string;
|
|
460
|
+
relativePath: string;
|
|
461
|
+
reason: TPromptFileReferenceReason;
|
|
462
|
+
depth: number;
|
|
463
|
+
byteLength: number;
|
|
464
|
+
}
|
|
465
|
+
interface IResolvedPromptFileReference extends IPromptFileReferenceRecord {
|
|
466
|
+
content: string;
|
|
467
|
+
}
|
|
468
|
+
interface IPromptFileReferenceDiagnostic {
|
|
469
|
+
code: TPromptFileReferenceDiagnosticCode;
|
|
470
|
+
severity: 'error';
|
|
471
|
+
reference: string;
|
|
472
|
+
message: string;
|
|
473
|
+
path?: string;
|
|
474
|
+
}
|
|
475
|
+
interface IPromptFileReferenceLimits {
|
|
476
|
+
maxDepth?: number;
|
|
477
|
+
maxReferences?: number;
|
|
478
|
+
maxFileBytes?: number;
|
|
479
|
+
maxTotalBytes?: number;
|
|
480
|
+
}
|
|
481
|
+
interface IPromptFileReferenceResolveOptions {
|
|
482
|
+
cwd: string;
|
|
483
|
+
limits?: IPromptFileReferenceLimits;
|
|
484
|
+
reason?: TPromptFileReferenceReason;
|
|
485
|
+
}
|
|
486
|
+
interface IResolvedPromptFileReferences {
|
|
487
|
+
references: IResolvedPromptFileReference[];
|
|
488
|
+
diagnostics: IPromptFileReferenceDiagnostic[];
|
|
489
|
+
}
|
|
490
|
+
interface IPromptFileReferenceHistoryData {
|
|
491
|
+
message: string;
|
|
492
|
+
references: IPromptFileReferenceRecord[];
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
type TContextReferenceLoadType = 'manual' | 'prompt-reference';
|
|
496
|
+
type TContextReferenceStatus = 'active' | 'observed';
|
|
497
|
+
interface IContextReferenceItem {
|
|
498
|
+
id: string;
|
|
499
|
+
sourcePath: string;
|
|
500
|
+
relativePath: string;
|
|
501
|
+
originalReference: string;
|
|
502
|
+
loadType: TContextReferenceLoadType;
|
|
503
|
+
status: TContextReferenceStatus;
|
|
504
|
+
byteLength: number;
|
|
505
|
+
loadedAt: string;
|
|
506
|
+
lastUsedAt?: string;
|
|
507
|
+
}
|
|
508
|
+
interface IContextReferenceInventoryLimits {
|
|
509
|
+
maxActiveReferences?: number;
|
|
510
|
+
maxActiveBytes?: number;
|
|
511
|
+
maxObservedReferences?: number;
|
|
512
|
+
}
|
|
513
|
+
interface IContextReferenceAddResult {
|
|
514
|
+
reference?: IContextReferenceItem;
|
|
515
|
+
evicted: IContextReferenceItem[];
|
|
516
|
+
diagnostics: string[];
|
|
517
|
+
}
|
|
518
|
+
interface IContextReferenceRemoveResult {
|
|
519
|
+
removed?: IContextReferenceItem;
|
|
520
|
+
}
|
|
521
|
+
interface IContextReferenceClearResult {
|
|
522
|
+
removed: IContextReferenceItem[];
|
|
523
|
+
}
|
|
524
|
+
interface IContextReferenceUpsertResult {
|
|
525
|
+
references: IContextReferenceItem[];
|
|
526
|
+
evicted: IContextReferenceItem[];
|
|
527
|
+
}
|
|
528
|
+
declare function createContextReferenceItem(record: IPromptFileReferenceRecord, loadType: TContextReferenceLoadType, status: TContextReferenceStatus, timestamp?: string): IContextReferenceItem;
|
|
529
|
+
declare function upsertContextReference(references: readonly IContextReferenceItem[], item: IContextReferenceItem, limits?: IContextReferenceInventoryLimits): IContextReferenceUpsertResult;
|
|
530
|
+
declare function removeContextReference(references: readonly IContextReferenceItem[], query: string): {
|
|
531
|
+
references: IContextReferenceItem[];
|
|
532
|
+
result: IContextReferenceRemoveResult;
|
|
533
|
+
};
|
|
534
|
+
declare function clearContextReferences(references: readonly IContextReferenceItem[]): IContextReferenceClearResult;
|
|
535
|
+
declare function listActiveContextReferences(references: readonly IContextReferenceItem[]): IContextReferenceItem[];
|
|
536
|
+
declare function toContextReferenceRecords(references: readonly IContextReferenceItem[]): IPromptFileReferenceRecord[];
|
|
537
|
+
|
|
538
|
+
type TAutoCompactThreshold$1 = number | false;
|
|
539
|
+
declare const DEFAULT_AUTO_COMPACT_THRESHOLD = 0.835;
|
|
540
|
+
declare const AUTO_COMPACT_THRESHOLD_SETTINGS_KEY = "autoCompactThreshold";
|
|
541
|
+
interface ICompactContextResult {
|
|
542
|
+
before: IContextWindowState;
|
|
543
|
+
after: IContextWindowState;
|
|
544
|
+
}
|
|
545
|
+
/** Read context-window state through the command host facade. */
|
|
546
|
+
declare function readCommandContextState(context: ICommandHostContext): IContextWindowState;
|
|
547
|
+
/** Read the effective automatic compact policy through the command host facade. */
|
|
548
|
+
declare function readAutoCompactThreshold(context: ICommandHostContext): TAutoCompactThreshold$1;
|
|
549
|
+
/** Read the source of the effective automatic compact policy. */
|
|
550
|
+
declare function readAutoCompactThresholdSource(context: ICommandHostContext): TAutoCompactThresholdSource;
|
|
551
|
+
/** Update the active session's automatic compact policy through the command host facade. */
|
|
552
|
+
declare function setCommandAutoCompactThreshold(context: ICommandHostContext, threshold: TAutoCompactThreshold$1, source: TAutoCompactThresholdSource): void;
|
|
553
|
+
/** Persist an automatic compact policy value through the host settings adapter, when present. */
|
|
554
|
+
declare function writeAutoCompactThresholdSetting(context: ICommandHostContext, threshold: TAutoCompactThreshold$1): boolean;
|
|
555
|
+
/** Remove the persisted automatic compact policy through the host settings adapter, when present. */
|
|
556
|
+
declare function resetAutoCompactThresholdSetting(context: ICommandHostContext): boolean;
|
|
557
|
+
/** Run manual compaction through the command host facade and return before/after state. */
|
|
558
|
+
declare function compactCommandContext(context: ICommandHostContext, instructions?: string): Promise<ICompactContextResult>;
|
|
559
|
+
/** List context reference inventory entries through the command host facade. */
|
|
560
|
+
declare function listCommandContextReferences(context: ICommandHostContext): IContextReferenceItem[];
|
|
561
|
+
/** Add a manual context reference through the command host facade. */
|
|
562
|
+
declare function addCommandContextReference(context: ICommandHostContext, path: string): Promise<IContextReferenceAddResult>;
|
|
563
|
+
/** Remove a context reference through the command host facade. */
|
|
564
|
+
declare function removeCommandContextReference(context: ICommandHostContext, path: string): IContextReferenceRemoveResult;
|
|
565
|
+
/** Clear all context references through the command host facade. */
|
|
566
|
+
declare function clearCommandContextReferences(context: ICommandHostContext): IContextReferenceClearResult;
|
|
567
|
+
|
|
568
|
+
interface ICommandListEntry {
|
|
569
|
+
name: string;
|
|
570
|
+
description: string;
|
|
571
|
+
}
|
|
572
|
+
interface ICommandSkillListEntry {
|
|
573
|
+
readonly name: string;
|
|
574
|
+
readonly description: string;
|
|
575
|
+
readonly source: string;
|
|
576
|
+
readonly modelInvocable: boolean;
|
|
577
|
+
readonly userInvocable: boolean;
|
|
578
|
+
readonly argumentHint?: string;
|
|
579
|
+
readonly context?: string;
|
|
580
|
+
readonly agent?: string;
|
|
581
|
+
}
|
|
582
|
+
type TCommandInvocationSource = 'user' | 'model';
|
|
583
|
+
interface ICommandSkillActivationRequest {
|
|
584
|
+
readonly invocationSource: TCommandInvocationSource;
|
|
585
|
+
readonly displayInput?: string;
|
|
586
|
+
readonly rawInput?: string;
|
|
587
|
+
}
|
|
588
|
+
type TAutoCompactThresholdSource = 'default' | 'settings' | 'session';
|
|
589
|
+
interface ICommandSessionRuntime {
|
|
590
|
+
clearHistory(): void;
|
|
591
|
+
compact(instructions?: string): Promise<void>;
|
|
592
|
+
getContextState(): IContextWindowState;
|
|
593
|
+
getPermissionMode(): TPermissionMode;
|
|
594
|
+
setPermissionMode(mode: TPermissionMode): void;
|
|
595
|
+
getSessionId(): string;
|
|
596
|
+
getMessageCount(): number;
|
|
597
|
+
getSessionAllowedTools(): readonly string[];
|
|
598
|
+
getAutoCompactThreshold?(): number | false;
|
|
599
|
+
setAutoCompactThreshold?(threshold: TAutoCompactThreshold$1): void;
|
|
600
|
+
}
|
|
601
|
+
interface ICommandSessionReplayValidationReport {
|
|
602
|
+
logFile: string;
|
|
603
|
+
entryCount: number;
|
|
604
|
+
validation: ISessionReplayValidationResult;
|
|
605
|
+
}
|
|
606
|
+
interface ICommandHostContext {
|
|
607
|
+
clearConversationHistory?(): void;
|
|
608
|
+
validateCurrentSessionReplayLog?(): ICommandSessionReplayValidationReport;
|
|
609
|
+
getSession(): ICommandSessionRuntime;
|
|
610
|
+
getContextState(): IContextWindowState;
|
|
611
|
+
getAutoCompactThreshold(): TAutoCompactThreshold$1;
|
|
612
|
+
getAutoCompactThresholdSource?(): TAutoCompactThresholdSource;
|
|
613
|
+
setAutoCompactThreshold?(threshold: TAutoCompactThreshold$1, source?: TAutoCompactThresholdSource): void;
|
|
614
|
+
getCommandHostAdapters?(): ICommandHostAdapters;
|
|
615
|
+
compactContext(instructions?: string): Promise<void>;
|
|
616
|
+
listContextReferences?(): IContextReferenceItem[];
|
|
617
|
+
addContextReference?(path: string): Promise<IContextReferenceAddResult>;
|
|
618
|
+
removeContextReference?(path: string): IContextReferenceRemoveResult;
|
|
619
|
+
clearContextReferences?(): IContextReferenceClearResult;
|
|
620
|
+
getCwd(): string;
|
|
621
|
+
getCommandInvocationSource?(): TCommandInvocationSource;
|
|
622
|
+
listCommands?(): ICommandListEntry[];
|
|
623
|
+
listSkills?(): ICommandSkillListEntry[];
|
|
624
|
+
executeSkillCommandByName?(name: string, args: string, request: ICommandSkillActivationRequest): Promise<ICommandResult | null>;
|
|
625
|
+
listEditCheckpoints(): IEditCheckpointSummary[];
|
|
626
|
+
inspectEditCheckpoint?(checkpointId: string): IEditCheckpointInspection;
|
|
627
|
+
restoreEditCheckpoint(checkpointId: string): Promise<IEditCheckpointRestoreResult>;
|
|
628
|
+
rollbackEditCheckpoint(checkpointId: string): Promise<IEditCheckpointRestoreResult>;
|
|
629
|
+
getUsedMemoryReferences(): IMemoryReference[];
|
|
630
|
+
recordMemoryEvent(event: IMemoryEvent): void;
|
|
631
|
+
listBackgroundTasks(filter?: IBackgroundTaskListFilter): IBackgroundTaskState[];
|
|
632
|
+
readBackgroundTaskLog(taskId: string, cursor?: IBackgroundTaskLogCursor): Promise<IBackgroundTaskLogPage>;
|
|
633
|
+
cancelBackgroundTask(taskId: string, reason?: string): Promise<void>;
|
|
634
|
+
closeBackgroundTask(taskId: string): Promise<void>;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
type TSystemCommandLifecycle = 'inline' | 'blocking' | 'background';
|
|
638
|
+
/** A user-visible command with descriptor metadata and execute logic. */
|
|
639
|
+
interface ISystemCommand {
|
|
640
|
+
name: string;
|
|
641
|
+
description: string;
|
|
642
|
+
modelInvocable?: boolean;
|
|
643
|
+
userInvocable?: boolean;
|
|
644
|
+
argumentHint?: string;
|
|
645
|
+
safety?: TCapabilitySafety;
|
|
646
|
+
subcommands?: readonly ICommand[];
|
|
647
|
+
lifecycle?: TSystemCommandLifecycle;
|
|
648
|
+
execute(context: ICommandHostContext, args: string): Promise<ICommandResult> | ICommandResult;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
type TCommandModuleSessionRequirement = 'agent-runtime';
|
|
652
|
+
/** Composable command capability module. */
|
|
653
|
+
interface ICommandModule {
|
|
654
|
+
/** Stable module id for diagnostics and duplicate handling. */
|
|
655
|
+
readonly name: string;
|
|
656
|
+
/** Slash palette/autocomplete command sources contributed by this module. */
|
|
657
|
+
readonly commandSources?: readonly ICommandSource[];
|
|
658
|
+
/** Executable system commands contributed by this module. */
|
|
659
|
+
readonly systemCommands?: readonly ISystemCommand[];
|
|
660
|
+
/** Additional model-visible descriptors not derived from executable commands. */
|
|
661
|
+
readonly commandDescriptors?: readonly ICapabilityDescriptor[];
|
|
662
|
+
/** Runtime facilities required by this module. */
|
|
663
|
+
readonly sessionRequirements?: readonly TCommandModuleSessionRequirement[];
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
interface IProviderProfileSettings extends IProviderProfileConfig {
|
|
667
|
+
[key: string]: TUniversalValue;
|
|
668
|
+
}
|
|
669
|
+
interface ILegacyProviderSettings {
|
|
670
|
+
[key: string]: TUniversalValue;
|
|
671
|
+
name?: string;
|
|
672
|
+
model?: string;
|
|
673
|
+
apiKey?: string;
|
|
674
|
+
baseURL?: string;
|
|
675
|
+
timeout?: number;
|
|
676
|
+
options?: Record<string, TUniversalValue>;
|
|
677
|
+
}
|
|
678
|
+
type TProviderSettingsDocument = Record<string, TUniversalValue> & {
|
|
679
|
+
currentProvider?: string;
|
|
680
|
+
providers?: Record<string, IProviderProfileSettings>;
|
|
681
|
+
provider?: ILegacyProviderSettings;
|
|
682
|
+
};
|
|
683
|
+
interface IProviderSetupInput {
|
|
684
|
+
profile: string;
|
|
685
|
+
type: string;
|
|
686
|
+
model?: string;
|
|
687
|
+
apiKey?: string;
|
|
688
|
+
apiKeyEnv?: string;
|
|
689
|
+
baseURL?: string;
|
|
690
|
+
timeout?: number;
|
|
691
|
+
setCurrent?: boolean;
|
|
692
|
+
}
|
|
693
|
+
interface IProviderSetupPatch {
|
|
694
|
+
currentProvider?: string;
|
|
695
|
+
providers: Record<string, IProviderProfileSettings>;
|
|
696
|
+
}
|
|
697
|
+
interface IProviderSettingsBuildOptions {
|
|
698
|
+
providerDefinitions?: readonly IProviderDefinition[];
|
|
699
|
+
}
|
|
700
|
+
declare function upsertProviderProfile(settings: TProviderSettingsDocument, profileName: string, profile: IProviderProfileSettings): TProviderSettingsDocument;
|
|
701
|
+
declare function setCurrentProvider(settings: TProviderSettingsDocument, profileName: string): TProviderSettingsDocument;
|
|
702
|
+
declare function deleteProviderProfile(settings: TProviderSettingsDocument, profileName: string, options?: {
|
|
703
|
+
replacementCurrentProvider?: string;
|
|
704
|
+
}): TProviderSettingsDocument;
|
|
705
|
+
declare function validateProviderProfile(profileName: string, profile: IProviderProfileSettings, options?: IProviderSettingsBuildOptions): void;
|
|
706
|
+
declare function buildProviderSetupPatch(input: IProviderSetupInput, options?: IProviderSettingsBuildOptions): IProviderSetupPatch;
|
|
707
|
+
declare function buildProviderProfile(input: IProviderSetupInput, options?: IProviderSettingsBuildOptions): IProviderProfileSettings;
|
|
708
|
+
declare function mergeProviderPatch(settings: TProviderSettingsDocument, patch: IProviderSetupPatch): TProviderSettingsDocument;
|
|
709
|
+
|
|
710
|
+
interface IProviderCommandSettingsAdapter {
|
|
711
|
+
readMergedSettings(): TProviderSettingsDocument;
|
|
712
|
+
readTargetSettings(): TProviderSettingsDocument;
|
|
713
|
+
writeTargetSettings(settings: TProviderSettingsDocument): void;
|
|
714
|
+
}
|
|
715
|
+
interface IProviderCommandModuleOptions {
|
|
716
|
+
providerDefinitions: readonly IProviderDefinition[];
|
|
717
|
+
settings: IProviderCommandSettingsAdapter;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
interface IProviderProfileNameSuggestionInput {
|
|
721
|
+
type: string;
|
|
722
|
+
model?: string;
|
|
723
|
+
}
|
|
724
|
+
interface IProviderProfileNameSuggestionOptions {
|
|
725
|
+
existingProfileNames?: readonly string[];
|
|
726
|
+
}
|
|
727
|
+
declare function suggestProviderProfileName(input: IProviderProfileNameSuggestionInput, options?: IProviderProfileNameSuggestionOptions): string;
|
|
728
|
+
declare function sanitizeProviderProfileName(value: string | undefined): string | undefined;
|
|
729
|
+
|
|
730
|
+
type TProviderSetupType = string;
|
|
731
|
+
type TPromptInput = (label: string, masked?: boolean) => Promise<string>;
|
|
732
|
+
interface IProviderSetupPromptStep extends IProviderSetupStepDefinition {
|
|
733
|
+
key: TProviderSetupField;
|
|
734
|
+
}
|
|
735
|
+
interface IProviderSetupFlowState {
|
|
736
|
+
type: TProviderSetupType;
|
|
737
|
+
steps: readonly IProviderSetupPromptStep[];
|
|
738
|
+
setupHelpLinks: readonly IProviderSetupHelpLink[];
|
|
739
|
+
stepIndex: number;
|
|
740
|
+
values: Partial<Record<TProviderSetupField, string>>;
|
|
741
|
+
existingProfileNames: readonly string[];
|
|
742
|
+
profileName?: string;
|
|
743
|
+
setCurrent?: boolean;
|
|
744
|
+
}
|
|
745
|
+
interface IProviderSetupFlowOptions {
|
|
746
|
+
existingProfileNames?: readonly string[];
|
|
747
|
+
initialValues?: Partial<Record<TProviderSetupField, string>>;
|
|
748
|
+
profileName?: string;
|
|
749
|
+
setCurrent?: boolean;
|
|
750
|
+
}
|
|
751
|
+
type TProviderSetupFlowSubmitResult = {
|
|
752
|
+
status: 'next';
|
|
753
|
+
state: IProviderSetupFlowState;
|
|
754
|
+
} | {
|
|
755
|
+
status: 'complete';
|
|
756
|
+
input: IProviderSetupInput;
|
|
757
|
+
} | {
|
|
758
|
+
status: 'error';
|
|
759
|
+
state: IProviderSetupFlowState;
|
|
760
|
+
message: string;
|
|
761
|
+
};
|
|
762
|
+
declare function createProviderSetupFlow(type: TProviderSetupType, providerDefinitions: readonly IProviderDefinition[], options?: IProviderSetupFlowOptions): IProviderSetupFlowState;
|
|
763
|
+
declare function formatProviderSetupSelectionPrompt(providerDefinitions: readonly IProviderDefinition[]): string;
|
|
764
|
+
declare function resolveProviderSetupSelection(rawValue: string, providerDefinitions: readonly IProviderDefinition[]): TProviderSetupType;
|
|
765
|
+
declare function getProviderSetupStep(state: IProviderSetupFlowState): IProviderSetupPromptStep;
|
|
766
|
+
declare function submitProviderSetupValue(state: IProviderSetupFlowState, rawValue: string): TProviderSetupFlowSubmitResult;
|
|
767
|
+
declare function runProviderSetupPromptFlow(type: TProviderSetupType, promptInput: TPromptInput, providerDefinitions: readonly IProviderDefinition[], options?: IProviderSetupFlowOptions): Promise<IProviderSetupInput>;
|
|
768
|
+
declare function formatProviderSetupPromptLabel(step: IProviderSetupPromptStep, setupHelpLinks?: readonly IProviderSetupHelpLink[]): string;
|
|
769
|
+
declare function formatProviderSetupChoiceLabel(definition: IProviderDefinition): string;
|
|
770
|
+
declare function formatProviderSetupHelpLinks(setupHelpLinks?: readonly IProviderSetupHelpLink[]): string;
|
|
771
|
+
declare function validateProviderSetupValue(step: IProviderSetupPromptStep, value: string): string | undefined;
|
|
772
|
+
|
|
773
|
+
declare function isEnvReference(value: string): boolean;
|
|
774
|
+
declare function formatEnvReference(name: string): string;
|
|
775
|
+
declare function resolveEnvReference(value: string): string | undefined;
|
|
776
|
+
declare function hasUsableSecretReference(value: string | undefined): boolean;
|
|
777
|
+
|
|
778
|
+
declare function testProviderProfileCommand(currentProvider: string | undefined, providers: Record<string, IProviderProfileSettings> | undefined, profileArg: string | undefined, options: IProviderCommandModuleOptions): Promise<ICommandResult>;
|
|
779
|
+
declare function probeProviderProfile(profile: IProviderProfileConfig): Promise<IProviderProbeResult>;
|
|
780
|
+
|
|
781
|
+
declare const HELP_COMMAND_DESCRIPTION = "Show available commands";
|
|
782
|
+
declare function formatCommandHelpMessage(context: ICommandHostContext): string;
|
|
783
|
+
|
|
784
|
+
declare const BACKGROUND_COMMAND_DESCRIPTION = "List and control background tasks";
|
|
785
|
+
declare const BACKGROUND_COMMAND_USAGE = "Usage: background list | background read <task-id> [offset] | background cancel <task-id> | background close <task-id>";
|
|
786
|
+
declare function buildBackgroundCommandSubcommands(): ICommand[];
|
|
787
|
+
declare function formatCommandBackgroundTask(task: IBackgroundTaskState): string;
|
|
788
|
+
declare function formatCommandBackgroundTaskList(tasks: IBackgroundTaskState[]): string;
|
|
789
|
+
declare function parseCommandBackgroundLogCursor(value?: string): IBackgroundTaskLogCursor | undefined;
|
|
790
|
+
declare function listCommandBackgroundTasks(context: ICommandHostContext, filter?: IBackgroundTaskListFilter): IBackgroundTaskState[];
|
|
791
|
+
declare function readCommandBackgroundTaskLog(context: ICommandHostContext, taskId: string, cursor?: IBackgroundTaskLogCursor): Promise<IBackgroundTaskLogPage>;
|
|
792
|
+
declare function cancelCommandBackgroundTask(context: ICommandHostContext, taskId: string, reason?: string): Promise<void>;
|
|
793
|
+
declare function closeCommandBackgroundTask(context: ICommandHostContext, taskId: string): Promise<void>;
|
|
794
|
+
|
|
795
|
+
declare const MODEL_COMMAND_DESCRIPTION = "Change AI model";
|
|
796
|
+
declare const MODEL_COMMAND_ARGUMENT_HINT = "<model-id>";
|
|
797
|
+
interface IModelCommandSettingsAdapter {
|
|
798
|
+
readMergedSettings(): TProviderSettingsDocument;
|
|
799
|
+
}
|
|
800
|
+
interface IModelCommandModuleOptions {
|
|
801
|
+
providerDefinitions: readonly IProviderDefinition[];
|
|
802
|
+
settings: IModelCommandSettingsAdapter;
|
|
803
|
+
}
|
|
804
|
+
interface IBuildModelCommandSubcommandsOptions {
|
|
805
|
+
source?: string;
|
|
806
|
+
providerDefinitions?: readonly IProviderDefinition[];
|
|
807
|
+
settings?: TProviderSettingsDocument;
|
|
808
|
+
}
|
|
809
|
+
interface IActiveProviderModelCatalogState {
|
|
810
|
+
providerType: string;
|
|
811
|
+
catalog?: IProviderModelCatalog;
|
|
812
|
+
refreshAttempted: boolean;
|
|
813
|
+
refreshMessage?: string;
|
|
814
|
+
}
|
|
815
|
+
interface IResolveActiveProviderModelCatalogStateOptions {
|
|
816
|
+
settings?: TProviderSettingsDocument;
|
|
817
|
+
providerDefinitions?: readonly IProviderDefinition[];
|
|
818
|
+
refresh?: boolean;
|
|
819
|
+
}
|
|
820
|
+
declare function buildModelCommandSubcommands(sourceOrOptions?: string | IBuildModelCommandSubcommandsOptions): ICommand[];
|
|
821
|
+
declare function formatModelCommandUsageMessage(options?: {
|
|
822
|
+
settings?: TProviderSettingsDocument;
|
|
823
|
+
providerDefinitions?: readonly IProviderDefinition[];
|
|
824
|
+
}): string;
|
|
825
|
+
declare function formatModelCommandUsageMessageAsync(options?: IResolveActiveProviderModelCatalogStateOptions): Promise<string>;
|
|
826
|
+
declare function resolveActiveProviderModelCatalog(settings: TProviderSettingsDocument | undefined, providerDefinitions?: readonly IProviderDefinition[]): IProviderModelCatalog | undefined;
|
|
827
|
+
declare function resolveActiveProviderModelCatalogState(options: IResolveActiveProviderModelCatalogStateOptions): Promise<IActiveProviderModelCatalogState | undefined>;
|
|
828
|
+
|
|
829
|
+
declare const LANGUAGE_COMMAND_DESCRIPTION = "Set response language";
|
|
830
|
+
declare const LANGUAGE_COMMAND_ARGUMENT_HINT = "<code>";
|
|
831
|
+
declare const RECOMMENDED_RESPONSE_LANGUAGES: readonly [{
|
|
832
|
+
readonly code: "ko";
|
|
833
|
+
readonly description: "Korean";
|
|
834
|
+
}, {
|
|
835
|
+
readonly code: "en";
|
|
836
|
+
readonly description: "English";
|
|
837
|
+
}, {
|
|
838
|
+
readonly code: "ja";
|
|
839
|
+
readonly description: "Japanese";
|
|
840
|
+
}, {
|
|
841
|
+
readonly code: "zh";
|
|
842
|
+
readonly description: "Chinese";
|
|
843
|
+
}];
|
|
844
|
+
type TRecommendedResponseLanguage = (typeof RECOMMENDED_RESPONSE_LANGUAGES)[number]['code'];
|
|
845
|
+
declare function buildLanguageCommandSubcommands(source?: string): ICommand[];
|
|
846
|
+
declare function parseLanguageArgument(args: string): string | undefined;
|
|
847
|
+
declare function formatLanguageUsageMessage(commandName?: string): string;
|
|
848
|
+
|
|
849
|
+
declare const PERMISSION_MODE_COMMAND_DESCRIPTION = "Show/change permission mode";
|
|
850
|
+
declare const PERMISSION_MODE_ARGUMENT_HINT = "plan | default | acceptEdits | bypassPermissions";
|
|
851
|
+
declare const PERMISSIONS_COMMAND_DESCRIPTION = "Show/change permission mode and permission rules";
|
|
852
|
+
interface IPermissionsCommandState {
|
|
853
|
+
readonly mode: TPermissionMode;
|
|
854
|
+
readonly sessionAllowed: readonly string[];
|
|
855
|
+
}
|
|
856
|
+
declare const VALID_PERMISSION_MODES: readonly TPermissionMode[];
|
|
857
|
+
declare function buildPermissionModeSubcommands(source?: string): ICommand[];
|
|
858
|
+
declare function parsePermissionModeArgument(args: string): string | undefined;
|
|
859
|
+
declare function isPermissionMode(value: string): value is TPermissionMode;
|
|
860
|
+
declare function formatInvalidPermissionModeMessage(): string;
|
|
861
|
+
declare function resolvePermissionModeAdapter(context: ICommandHostContext): ICommandPermissionModeAdapter;
|
|
862
|
+
declare function readCommandPermissionMode(context: ICommandHostContext): TPermissionMode;
|
|
863
|
+
declare function writeCommandPermissionMode(context: ICommandHostContext, mode: TPermissionMode): void;
|
|
864
|
+
declare function listCommandSessionAllowedTools(context: ICommandHostContext): readonly string[];
|
|
865
|
+
declare function readCommandPermissionsState(context: ICommandHostContext): IPermissionsCommandState;
|
|
866
|
+
declare function formatCommandPermissionsMessage(state: IPermissionsCommandState): string;
|
|
867
|
+
|
|
868
|
+
declare const CLEAR_COMMAND_DESCRIPTION = "Clear conversation history";
|
|
869
|
+
declare const RENAME_COMMAND_DESCRIPTION = "Rename the current session";
|
|
870
|
+
declare const RENAME_COMMAND_USAGE = "Usage: rename <name>";
|
|
871
|
+
declare const RESUME_COMMAND_DESCRIPTION = "Resume a previous session";
|
|
872
|
+
declare const COST_COMMAND_DESCRIPTION = "Show session info";
|
|
873
|
+
declare const VALIDATE_SESSION_COMMAND_DESCRIPTION = "Validate current session replay log";
|
|
874
|
+
declare const EXIT_COMMAND_DESCRIPTION = "Exit CLI";
|
|
875
|
+
interface ICommandSessionInfo {
|
|
876
|
+
sessionId: string;
|
|
877
|
+
messageCount: number;
|
|
878
|
+
}
|
|
879
|
+
declare function clearConversationHistory(context: ICommandHostContext): void;
|
|
880
|
+
declare function parseSessionNameArgument(args: string): string | undefined;
|
|
881
|
+
declare function createSessionRenamedEffect(name: string): TCommandEffect;
|
|
882
|
+
declare function createSessionPickerRequestedEffect(): TCommandEffect;
|
|
883
|
+
declare function createSessionExitRequestedEffect(): TCommandEffect;
|
|
884
|
+
declare function readCommandSessionInfo(context: ICommandHostContext): ICommandSessionInfo;
|
|
885
|
+
declare function validateCommandSessionReplayLog(context: ICommandHostContext): ICommandSessionReplayValidationReport;
|
|
886
|
+
declare function formatCommandSessionReplayValidationReport(report: ICommandSessionReplayValidationReport): string;
|
|
887
|
+
|
|
888
|
+
declare const REWIND_COMMAND_DESCRIPTION = "List, inspect, restore, or rollback edit checkpoints.";
|
|
889
|
+
declare const REWIND_COMMAND_ARGUMENT_HINT = "list | inspect CHECKPOINT_ID | restore CHECKPOINT_ID | code CHECKPOINT_ID | rollback CHECKPOINT_ID";
|
|
890
|
+
declare function buildRewindCommandSubcommands(source?: string): ICommand[];
|
|
891
|
+
declare function listCommandEditCheckpoints(context: ICommandHostContext): readonly IEditCheckpointSummary[];
|
|
892
|
+
declare function inspectCommandEditCheckpoint(context: ICommandHostContext, checkpointId: string): IEditCheckpointInspection;
|
|
893
|
+
declare function restoreCommandEditCheckpoint(context: ICommandHostContext, checkpointId: string): Promise<IEditCheckpointRestoreResult>;
|
|
894
|
+
declare function rollbackCommandEditCheckpoint(context: ICommandHostContext, checkpointId: string): Promise<IEditCheckpointRestoreResult>;
|
|
895
|
+
|
|
896
|
+
declare const MEMORY_COMMAND_DESCRIPTION = "Project memory command. Use it to inspect project memory when stored context may help, save durable preferences, project conventions, feedback, or references worth reusing across sessions, review pending candidates, and report memory provenance. Do not store secrets, credentials, or transient facts.";
|
|
897
|
+
declare const MEMORY_COMMAND_ARGUMENT_HINT = "list | show [topic] | add <user|feedback|project|reference> <topic> <text> | pending | approve <id> | reject <id> | used";
|
|
898
|
+
declare const MEMORY_COMMAND_USAGE = "Usage: memory list | memory show [topic] | memory add <user|feedback|project|reference> <topic> <text> | memory pending | memory approve <id> | memory reject <id> | memory used";
|
|
899
|
+
interface ICommandProjectMemoryStore {
|
|
900
|
+
list(): IProjectMemorySummary;
|
|
901
|
+
loadStartupMemory(): IStartupMemory;
|
|
902
|
+
readTopic(topic: string): string;
|
|
903
|
+
append(input: IAppendMemoryInput): IAppendMemoryResult;
|
|
904
|
+
}
|
|
905
|
+
interface ICommandPendingMemoryStore {
|
|
906
|
+
get(id: string): IMemoryPendingRecord | undefined;
|
|
907
|
+
list(status?: TMemoryCandidateStatus): IMemoryPendingRecord[];
|
|
908
|
+
mark(id: string, status: TMemoryCandidateStatus, reason: string): IMemoryPendingRecord;
|
|
909
|
+
upsert(candidate: IMemoryCandidate, status: TMemoryCandidateStatus, reason: string): void;
|
|
910
|
+
}
|
|
911
|
+
interface ICommandMemoryStores {
|
|
912
|
+
project: ICommandProjectMemoryStore;
|
|
913
|
+
pending: ICommandPendingMemoryStore;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
declare function buildMemoryCommandSubcommands(source?: string): ICommand[];
|
|
917
|
+
declare function createCommandProjectMemoryStore(cwd: string, now?: () => Date): ICommandProjectMemoryStore;
|
|
918
|
+
declare function createCommandPendingMemoryStore(cwd: string, now?: () => Date): ICommandPendingMemoryStore;
|
|
919
|
+
declare function createCommandMemoryStores(context: ICommandHostContext, now?: () => Date): ICommandMemoryStores;
|
|
920
|
+
declare function isCommandMemoryType(value: string): value is TMemoryType;
|
|
921
|
+
declare function hasSensitiveCommandMemoryContent(text: string): boolean;
|
|
922
|
+
declare function listCommandUsedMemoryReferences(context: ICommandHostContext): readonly IMemoryReference[];
|
|
923
|
+
declare function recordCommandMemoryEvent(context: ICommandHostContext, event: Omit<IMemoryEvent, 'at'>, now?: () => Date): void;
|
|
924
|
+
|
|
925
|
+
/** Aggregates commands from multiple sources */
|
|
926
|
+
declare class CommandRegistry {
|
|
927
|
+
private sources;
|
|
928
|
+
addSource(source: ICommandSource): void;
|
|
929
|
+
replaceSource(name: string, source?: ICommandSource): void;
|
|
930
|
+
addModule(module: ICommandModule): void;
|
|
931
|
+
/** Get all commands, optionally filtered by prefix */
|
|
932
|
+
getCommands(filter?: string): ICommand[];
|
|
933
|
+
/** Resolve a short name to its fully qualified plugin:name form */
|
|
934
|
+
resolveQualifiedName(shortName: string): string | null;
|
|
935
|
+
/** Get subcommands for a specific command */
|
|
936
|
+
getSubcommands(commandName: string): ICommand[];
|
|
937
|
+
getCapabilityDescriptors(): ICapabilityDescriptor[];
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
/** Command source for SDK-owned built-in commands. */
|
|
941
|
+
declare class BuiltinCommandSource implements ICommandSource {
|
|
942
|
+
readonly name = "builtin";
|
|
943
|
+
private readonly commands;
|
|
944
|
+
constructor(systemCommands?: readonly ISystemCommand[]);
|
|
945
|
+
getCommands(): ICommand[];
|
|
946
|
+
}
|
|
947
|
+
declare function createBuiltinCommandModule(): ICommandModule;
|
|
948
|
+
|
|
949
|
+
interface IFrontmatter {
|
|
950
|
+
name?: string;
|
|
951
|
+
description?: string;
|
|
952
|
+
argumentHint?: string;
|
|
953
|
+
disableModelInvocation?: boolean;
|
|
954
|
+
userInvocable?: boolean;
|
|
955
|
+
allowedTools?: string[];
|
|
956
|
+
model?: string;
|
|
957
|
+
effort?: string;
|
|
958
|
+
context?: string;
|
|
959
|
+
agent?: string;
|
|
960
|
+
}
|
|
961
|
+
/** Parse YAML-like frontmatter between --- markers */
|
|
962
|
+
declare function parseFrontmatter(content: string): IFrontmatter | null;
|
|
963
|
+
/** Command source that discovers skills from multiple directories */
|
|
964
|
+
declare class SkillCommandSource implements ICommandSource {
|
|
965
|
+
readonly name = "skill";
|
|
966
|
+
private readonly cwd;
|
|
967
|
+
private readonly home;
|
|
968
|
+
private cachedCommands;
|
|
969
|
+
constructor(cwd: string, home?: string);
|
|
970
|
+
getCommands(): ICommand[];
|
|
971
|
+
getModelInvocableSkills(): ICommand[];
|
|
972
|
+
getUserInvocableSkills(): ICommand[];
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* PluginSettingsStore — single point of read/write for plugin-related settings.
|
|
977
|
+
*
|
|
978
|
+
* Shared by MarketplaceClient and BundlePluginInstaller to prevent
|
|
979
|
+
* concurrent writes from overwriting each other's changes.
|
|
980
|
+
*/
|
|
981
|
+
/** Source type for a marketplace registry. */
|
|
982
|
+
type IMarketplaceSource$1 = {
|
|
983
|
+
type: 'github';
|
|
984
|
+
repo: string;
|
|
985
|
+
ref?: string;
|
|
986
|
+
} | {
|
|
987
|
+
type: 'git';
|
|
988
|
+
url: string;
|
|
989
|
+
ref?: string;
|
|
990
|
+
} | {
|
|
991
|
+
type: 'local';
|
|
992
|
+
path: string;
|
|
993
|
+
} | {
|
|
994
|
+
type: 'url';
|
|
995
|
+
url: string;
|
|
996
|
+
};
|
|
997
|
+
/** Persisted marketplace source entry. */
|
|
998
|
+
interface IPersistedMarketplaceSource {
|
|
999
|
+
source: IMarketplaceSource$1;
|
|
1000
|
+
}
|
|
1001
|
+
/** Shape of the plugin-related keys in settings.json. */
|
|
1002
|
+
interface IPluginSettings {
|
|
1003
|
+
enabledPlugins: Record<string, boolean>;
|
|
1004
|
+
extraKnownMarketplaces: Record<string, IPersistedMarketplaceSource>;
|
|
1005
|
+
}
|
|
1006
|
+
/** Centralized settings store for plugin configuration. */
|
|
1007
|
+
declare class PluginSettingsStore {
|
|
1008
|
+
private readonly settingsPath;
|
|
1009
|
+
constructor(settingsPath: string);
|
|
1010
|
+
/** Read the full settings file from disk. */
|
|
1011
|
+
private readAll;
|
|
1012
|
+
/** Write the full settings file to disk. */
|
|
1013
|
+
private writeAll;
|
|
1014
|
+
/** Get the enabledPlugins map. */
|
|
1015
|
+
getEnabledPlugins(): Record<string, boolean>;
|
|
1016
|
+
/** Set a single plugin's enabled state. */
|
|
1017
|
+
setPluginEnabled(pluginId: string, enabled: boolean): void;
|
|
1018
|
+
/** Remove a plugin from enabledPlugins. */
|
|
1019
|
+
removePluginEntry(pluginId: string): void;
|
|
1020
|
+
/** Get all persisted marketplace sources. */
|
|
1021
|
+
getMarketplaceSources(): Record<string, IPersistedMarketplaceSource>;
|
|
1022
|
+
/** Add or update a marketplace source. */
|
|
1023
|
+
setMarketplaceSource(name: string, source: IMarketplaceSource$1): void;
|
|
1024
|
+
/** Remove a marketplace source. */
|
|
1025
|
+
removeMarketplaceSource(name: string): void;
|
|
1026
|
+
private getEnabledPluginsFrom;
|
|
1027
|
+
private getMarketplaceSourcesFrom;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Types for the BundlePlugin system.
|
|
1032
|
+
*
|
|
1033
|
+
* A BundlePlugin is a directory-based plugin package that bundles
|
|
1034
|
+
* skills, hooks, agents, and MCP server configurations.
|
|
1035
|
+
*/
|
|
1036
|
+
/** Feature flags indicating what a bundle plugin provides. */
|
|
1037
|
+
interface IBundlePluginFeatures {
|
|
1038
|
+
commands?: boolean;
|
|
1039
|
+
agents?: boolean;
|
|
1040
|
+
skills?: boolean;
|
|
1041
|
+
hooks?: boolean;
|
|
1042
|
+
mcp?: boolean;
|
|
1043
|
+
}
|
|
1044
|
+
/** Manifest read from `.claude-plugin/plugin.json`. */
|
|
1045
|
+
interface IBundlePluginManifest {
|
|
1046
|
+
name: string;
|
|
1047
|
+
version: string;
|
|
1048
|
+
description: string;
|
|
1049
|
+
features: IBundlePluginFeatures;
|
|
1050
|
+
}
|
|
1051
|
+
/** A skill loaded from a bundle plugin's `skills/` directory. */
|
|
1052
|
+
interface IBundleSkill {
|
|
1053
|
+
name: string;
|
|
1054
|
+
description: string;
|
|
1055
|
+
skillContent: string;
|
|
1056
|
+
[key: string]: unknown;
|
|
1057
|
+
}
|
|
1058
|
+
/** A fully loaded bundle plugin with all its assets. */
|
|
1059
|
+
interface ILoadedBundlePlugin {
|
|
1060
|
+
manifest: IBundlePluginManifest;
|
|
1061
|
+
skills: IBundleSkill[];
|
|
1062
|
+
commands: IBundleSkill[];
|
|
1063
|
+
hooks: Record<string, unknown>;
|
|
1064
|
+
mcpConfig?: unknown;
|
|
1065
|
+
agents: string[];
|
|
1066
|
+
pluginDir: string;
|
|
1067
|
+
}
|
|
1068
|
+
/** Map of plugin identifiers to enabled/disabled state. */
|
|
1069
|
+
type TEnabledPlugins = Record<string, boolean>;
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* BundlePluginLoader — discovers and loads directory-based bundle plugins.
|
|
1073
|
+
*
|
|
1074
|
+
* Scans the cache directory (`<pluginsDir>/cache/<marketplace>/<plugin>/<version>/`)
|
|
1075
|
+
* for subdirectories containing `.claude-plugin/plugin.json`,
|
|
1076
|
+
* reads manifests, loads skills (with frontmatter parsing), hooks, and agent definitions.
|
|
1077
|
+
*
|
|
1078
|
+
* For each plugin, the latest version directory (lexicographically last) is loaded.
|
|
1079
|
+
*/
|
|
1080
|
+
|
|
1081
|
+
/** Loader for directory-based bundle plugins from the cache directory. */
|
|
1082
|
+
declare class BundlePluginLoader {
|
|
1083
|
+
private readonly pluginsDir;
|
|
1084
|
+
private readonly enabledPlugins;
|
|
1085
|
+
constructor(pluginsDir: string, enabledPlugins?: TEnabledPlugins);
|
|
1086
|
+
/** Load all discovered and enabled bundle plugins (sync). */
|
|
1087
|
+
loadPluginsSync(): ILoadedBundlePlugin[];
|
|
1088
|
+
/** Load all discovered and enabled bundle plugins (async wrapper). */
|
|
1089
|
+
loadAll(): Promise<ILoadedBundlePlugin[]>;
|
|
1090
|
+
/**
|
|
1091
|
+
* Discover and load plugins from the cache directory.
|
|
1092
|
+
*
|
|
1093
|
+
* Directory structure: `<pluginsDir>/cache/<marketplace>/<plugin>/<version>/`
|
|
1094
|
+
* For each marketplace/plugin pair, the latest version (lexicographically last) is loaded.
|
|
1095
|
+
*/
|
|
1096
|
+
private discoverAndLoad;
|
|
1097
|
+
/** Read and validate a plugin.json manifest. Returns null on failure. */
|
|
1098
|
+
private readManifest;
|
|
1099
|
+
/**
|
|
1100
|
+
* Check if a plugin is explicitly disabled.
|
|
1101
|
+
* Checks both `name@marketplace` and `name` keys.
|
|
1102
|
+
* Plugins not listed in enabledPlugins are enabled by default.
|
|
1103
|
+
*/
|
|
1104
|
+
private isDisabled;
|
|
1105
|
+
/** Load a single plugin's skills, hooks, agents, and MCP config. */
|
|
1106
|
+
private loadPlugin;
|
|
1107
|
+
/** Load skills from the plugin's skills/ directory. */
|
|
1108
|
+
private loadSkills;
|
|
1109
|
+
/** Load commands from the plugin's commands/ directory (flat .md files). */
|
|
1110
|
+
private loadCommands;
|
|
1111
|
+
/** Load hooks from hooks/hooks.json if present. */
|
|
1112
|
+
private loadHooks;
|
|
1113
|
+
/** Load MCP server configuration if present. Checks `.mcp.json` at plugin root first. */
|
|
1114
|
+
private loadMcpConfig;
|
|
1115
|
+
/** Load agent definitions from agents/ directory if present. */
|
|
1116
|
+
private loadAgents;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* Shared types for marketplace client and registry.
|
|
1121
|
+
*/
|
|
1122
|
+
/** Source specification for a marketplace. */
|
|
1123
|
+
type IMarketplaceSource = {
|
|
1124
|
+
type: 'github';
|
|
1125
|
+
repo: string;
|
|
1126
|
+
ref?: string;
|
|
1127
|
+
} | {
|
|
1128
|
+
type: 'git';
|
|
1129
|
+
url: string;
|
|
1130
|
+
ref?: string;
|
|
1131
|
+
} | {
|
|
1132
|
+
type: 'local';
|
|
1133
|
+
path: string;
|
|
1134
|
+
} | {
|
|
1135
|
+
type: 'url';
|
|
1136
|
+
url: string;
|
|
1137
|
+
};
|
|
1138
|
+
/** A single plugin entry in a marketplace manifest. */
|
|
1139
|
+
interface IMarketplacePluginEntry {
|
|
1140
|
+
name: string;
|
|
1141
|
+
title: string;
|
|
1142
|
+
description: string;
|
|
1143
|
+
source: string | {
|
|
1144
|
+
type: 'github';
|
|
1145
|
+
repo: string;
|
|
1146
|
+
} | {
|
|
1147
|
+
type: 'url';
|
|
1148
|
+
url: string;
|
|
1149
|
+
};
|
|
1150
|
+
tags: string[];
|
|
1151
|
+
}
|
|
1152
|
+
/** Manifest format read from `.claude-plugin/marketplace.json`. */
|
|
1153
|
+
interface IMarketplaceManifest {
|
|
1154
|
+
name: string;
|
|
1155
|
+
version: string;
|
|
1156
|
+
plugins: IMarketplacePluginEntry[];
|
|
1157
|
+
}
|
|
1158
|
+
/** Entry in known_marketplaces.json. */
|
|
1159
|
+
interface IKnownMarketplaceEntry {
|
|
1160
|
+
source: IMarketplaceSource;
|
|
1161
|
+
installLocation: string;
|
|
1162
|
+
lastUpdated: string;
|
|
1163
|
+
}
|
|
1164
|
+
/** Shape of known_marketplaces.json. */
|
|
1165
|
+
type IKnownMarketplacesRegistry = Record<string, IKnownMarketplaceEntry>;
|
|
1166
|
+
/** Exec function type for running shell commands. */
|
|
1167
|
+
type ExecFn$1 = (command: string, options: {
|
|
1168
|
+
timeout: number;
|
|
1169
|
+
stdio?: string;
|
|
1170
|
+
}) => string | Buffer;
|
|
1171
|
+
/** Options for constructing a MarketplaceClient. */
|
|
1172
|
+
interface IMarketplaceClientOptions {
|
|
1173
|
+
/** Base plugins directory (e.g., `~/.robota/plugins`). */
|
|
1174
|
+
pluginsDir: string;
|
|
1175
|
+
/** Custom exec function for testing (replaces child_process.execSync). */
|
|
1176
|
+
exec?: ExecFn$1;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* MarketplaceClient — manages marketplace registries via shallow git clones.
|
|
1181
|
+
*
|
|
1182
|
+
* Marketplaces are git repositories containing `.claude-plugin/marketplace.json`.
|
|
1183
|
+
* They are cloned to `~/.robota/plugins/marketplaces/<name>/` and tracked
|
|
1184
|
+
* in `known_marketplaces.json`.
|
|
1185
|
+
*/
|
|
1186
|
+
|
|
1187
|
+
/** Manages marketplace registries via shallow git clones. */
|
|
1188
|
+
declare class MarketplaceClient {
|
|
1189
|
+
private readonly pluginsDir;
|
|
1190
|
+
private readonly exec;
|
|
1191
|
+
private readonly marketplacesDir;
|
|
1192
|
+
private readonly registryPath;
|
|
1193
|
+
constructor(options: IMarketplaceClientOptions);
|
|
1194
|
+
/**
|
|
1195
|
+
* Add a marketplace by cloning its repository.
|
|
1196
|
+
*
|
|
1197
|
+
* 1. Shallow git clone (`--depth 1`) to `marketplaces/<name>/`.
|
|
1198
|
+
* 2. Read `.claude-plugin/marketplace.json` for the `name` field.
|
|
1199
|
+
* 3. Register in `known_marketplaces.json`.
|
|
1200
|
+
*
|
|
1201
|
+
* Returns the registered marketplace name from the manifest.
|
|
1202
|
+
*/
|
|
1203
|
+
addMarketplace(source: IMarketplaceSource): string;
|
|
1204
|
+
/**
|
|
1205
|
+
* Remove a marketplace.
|
|
1206
|
+
* Uninstalls all plugins from that marketplace, then deletes the clone directory
|
|
1207
|
+
* and removes from the registry.
|
|
1208
|
+
*/
|
|
1209
|
+
removeMarketplace(name: string): void;
|
|
1210
|
+
/**
|
|
1211
|
+
* Update a marketplace by running git pull on its clone.
|
|
1212
|
+
* The manifest is re-read from disk on demand (via fetchManifest), so the
|
|
1213
|
+
* updated manifest is automatically available after pull.
|
|
1214
|
+
*/
|
|
1215
|
+
updateMarketplace(name: string): void;
|
|
1216
|
+
/** List all registered marketplaces. */
|
|
1217
|
+
listMarketplaces(): Array<{
|
|
1218
|
+
name: string;
|
|
1219
|
+
source: IMarketplaceSource;
|
|
1220
|
+
lastUpdated: string;
|
|
1221
|
+
}>;
|
|
1222
|
+
/** Read the marketplace manifest from a registered marketplace's clone. */
|
|
1223
|
+
fetchManifest(marketplaceName: string): IMarketplaceManifest;
|
|
1224
|
+
/** Get the clone directory path for a registered marketplace. */
|
|
1225
|
+
getMarketplaceDir(name: string): string;
|
|
1226
|
+
/**
|
|
1227
|
+
* Get the current git SHA (first 12 chars) for a marketplace clone.
|
|
1228
|
+
* Used as a version identifier when plugins lack explicit versions.
|
|
1229
|
+
*/
|
|
1230
|
+
getMarketplaceSha(name: string): string;
|
|
1231
|
+
/** List all available plugins across all marketplaces. */
|
|
1232
|
+
listAvailablePlugins(): Array<IMarketplacePluginEntry & {
|
|
1233
|
+
marketplace: string;
|
|
1234
|
+
}>;
|
|
1235
|
+
/** Resolve a marketplace source to a git clone URL. */
|
|
1236
|
+
private resolveCloneUrl;
|
|
1237
|
+
/** Read and parse a marketplace.json from a file path. */
|
|
1238
|
+
private readManifestFromPath;
|
|
1239
|
+
/** Default exec implementation using child_process. */
|
|
1240
|
+
private defaultExec;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* BundlePluginInstaller — installs, uninstalls, enables, and disables bundle plugins.
|
|
1245
|
+
*
|
|
1246
|
+
* Resolves plugin sources from marketplace manifests, copies/clones to the
|
|
1247
|
+
* cache directory, and tracks installations in `installed_plugins.json`.
|
|
1248
|
+
*/
|
|
1249
|
+
|
|
1250
|
+
/** Record of an installed plugin in installed_plugins.json. */
|
|
1251
|
+
interface IInstalledPluginRecord {
|
|
1252
|
+
pluginName: string;
|
|
1253
|
+
marketplace: string;
|
|
1254
|
+
version: string;
|
|
1255
|
+
installPath: string;
|
|
1256
|
+
installedAt: string;
|
|
1257
|
+
}
|
|
1258
|
+
/** Shape of installed_plugins.json. */
|
|
1259
|
+
type IInstalledPluginsRegistry = Record<string, IInstalledPluginRecord>;
|
|
1260
|
+
/** Exec function type for running shell commands. */
|
|
1261
|
+
type ExecFn = (command: string, options: {
|
|
1262
|
+
timeout: number;
|
|
1263
|
+
stdio?: string;
|
|
1264
|
+
}) => string | Buffer;
|
|
1265
|
+
/** Options for constructing a BundlePluginInstaller. */
|
|
1266
|
+
interface IBundlePluginInstallerOptions {
|
|
1267
|
+
/** Base plugins directory (e.g., `~/.robota/plugins`). */
|
|
1268
|
+
pluginsDir: string;
|
|
1269
|
+
/** Shared settings store for enable/disable persistence. */
|
|
1270
|
+
settingsStore: PluginSettingsStore;
|
|
1271
|
+
/** MarketplaceClient for reading marketplace manifests. */
|
|
1272
|
+
marketplaceClient: MarketplaceClient;
|
|
1273
|
+
/** Custom exec function for testing (replaces child_process.execSync). */
|
|
1274
|
+
exec?: ExecFn;
|
|
1275
|
+
}
|
|
1276
|
+
/** Installs, uninstalls, enables, and disables bundle plugins. */
|
|
1277
|
+
declare class BundlePluginInstaller {
|
|
1278
|
+
private readonly pluginsDir;
|
|
1279
|
+
private readonly cacheDir;
|
|
1280
|
+
private readonly registryPath;
|
|
1281
|
+
private readonly settingsStore;
|
|
1282
|
+
private readonly marketplaceClient;
|
|
1283
|
+
private readonly exec;
|
|
1284
|
+
constructor(options: IBundlePluginInstallerOptions);
|
|
1285
|
+
/**
|
|
1286
|
+
* Install a plugin from a marketplace.
|
|
1287
|
+
*
|
|
1288
|
+
* 1. Read marketplace manifest to find the plugin entry.
|
|
1289
|
+
* 2. Resolve source (relative path, github, or url).
|
|
1290
|
+
* 3. Copy/clone to `cache/<marketplace>/<plugin>/<version>/`.
|
|
1291
|
+
* 4. Record in `installed_plugins.json`.
|
|
1292
|
+
*/
|
|
1293
|
+
install(pluginName: string, marketplaceName: string): Promise<void>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Uninstall a plugin.
|
|
1296
|
+
* Removes from cache and from installed_plugins.json.
|
|
1297
|
+
*/
|
|
1298
|
+
uninstall(pluginId: string): Promise<void>;
|
|
1299
|
+
/** Enable a plugin by setting its enabledPlugins entry to true. */
|
|
1300
|
+
enable(pluginId: string): Promise<void>;
|
|
1301
|
+
/** Disable a plugin by setting its enabledPlugins entry to false. */
|
|
1302
|
+
disable(pluginId: string): Promise<void>;
|
|
1303
|
+
/** Get all installed plugins. */
|
|
1304
|
+
getInstalledPlugins(): IInstalledPluginsRegistry;
|
|
1305
|
+
/** Get plugins installed from a specific marketplace. */
|
|
1306
|
+
getPluginsByMarketplace(marketplaceName: string): IInstalledPluginRecord[];
|
|
1307
|
+
/** Resolve the version for a plugin entry. */
|
|
1308
|
+
private resolveVersion;
|
|
1309
|
+
/**
|
|
1310
|
+
* Normalize source object — Claude Code manifests use `source` key instead of `type`.
|
|
1311
|
+
* e.g., { source: "url", url: "..." } → { type: "url", url: "..." }
|
|
1312
|
+
*/
|
|
1313
|
+
private normalizeSource;
|
|
1314
|
+
/** Resolve the source and install the plugin. */
|
|
1315
|
+
private resolveAndInstall;
|
|
1316
|
+
/** Clone a git repository to the target directory. */
|
|
1317
|
+
private cloneToDir;
|
|
1318
|
+
/** Read the installed_plugins.json registry. */
|
|
1319
|
+
private readRegistry;
|
|
1320
|
+
/** Write the installed_plugins.json registry. */
|
|
1321
|
+
private writeRegistry;
|
|
1322
|
+
/** Default exec implementation using child_process. */
|
|
1323
|
+
private defaultExec;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* Command source that discovers skills and commands from loaded BundlePlugins.
|
|
1328
|
+
*
|
|
1329
|
+
* - Skills: exposed as `/name` with `(plugin-name)` hint in description.
|
|
1330
|
+
* - Commands: exposed as `/plugin:command` (already namespaced by the loader).
|
|
1331
|
+
*/
|
|
1332
|
+
declare class PluginCommandSource implements ICommandSource {
|
|
1333
|
+
readonly name = "plugin";
|
|
1334
|
+
private readonly plugins;
|
|
1335
|
+
constructor(plugins: ILoadedBundlePlugin[]);
|
|
1336
|
+
getCommands(): ICommand[];
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/** Registry for system commands. */
|
|
1340
|
+
declare class SystemCommandExecutor {
|
|
1341
|
+
private readonly commands;
|
|
1342
|
+
constructor(commands?: ISystemCommand[]);
|
|
1343
|
+
/** Register an additional command. */
|
|
1344
|
+
register(command: ISystemCommand): void;
|
|
1345
|
+
/** Execute a command by name. Returns null if command not found. */
|
|
1346
|
+
execute(name: string, session: ICommandHostContext, args: string): Promise<ICommandResult | null>;
|
|
1347
|
+
getCommand(name: string): ISystemCommand | undefined;
|
|
1348
|
+
executeCommand(command: ISystemCommand, session: ICommandHostContext, args: string): Promise<ICommandResult>;
|
|
1349
|
+
/** List all registered commands. */
|
|
1350
|
+
listCommands(): ISystemCommand[];
|
|
1351
|
+
listModelInvocableCommands(): ICapabilityDescriptor[];
|
|
1352
|
+
isModelInvocable(name: string): boolean;
|
|
1353
|
+
executeModelInvocable(name: string, session: ICommandHostContext, args: string): Promise<ICommandResult | null>;
|
|
1354
|
+
/** Check if a command exists. */
|
|
1355
|
+
hasCommand(name: string): boolean;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
/** Built-in system commands. */
|
|
1359
|
+
declare function createSystemCommands(): ISystemCommand[];
|
|
1360
|
+
|
|
1361
|
+
/** Context variables available during skill prompt processing */
|
|
1362
|
+
interface SkillPromptContext {
|
|
1363
|
+
/** Current session ID — substituted for ${CLAUDE_SESSION_ID} */
|
|
1364
|
+
sessionId?: string;
|
|
1365
|
+
/** Directory containing SKILL.md — substituted for ${CLAUDE_SKILL_DIR} */
|
|
1366
|
+
skillDir?: string;
|
|
1367
|
+
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Substitute variables in skill content.
|
|
1370
|
+
*
|
|
1371
|
+
* Supported variables:
|
|
1372
|
+
* - `$ARGUMENTS` — all arguments passed to the skill
|
|
1373
|
+
* - `$ARGUMENTS[N]` — argument by index (0-based)
|
|
1374
|
+
* - `$N` — shorthand for `$ARGUMENTS[N]` (single digit, 0-9)
|
|
1375
|
+
* - `${CLAUDE_SESSION_ID}` — current session ID
|
|
1376
|
+
* - `${CLAUDE_SKILL_DIR}` — directory containing SKILL.md
|
|
1377
|
+
*/
|
|
1378
|
+
declare function substituteVariables(content: string, args: string, context?: SkillPromptContext): string;
|
|
1379
|
+
/**
|
|
1380
|
+
* Preprocess shell commands in skill content.
|
|
1381
|
+
* Matches `` !`...` `` patterns and replaces them with command output.
|
|
1382
|
+
* Commands have a 5-second timeout.
|
|
1383
|
+
*/
|
|
1384
|
+
declare function preprocessShellCommands(content: string): Promise<string>;
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* Skill execution logic.
|
|
1388
|
+
* Handles both fork-based (subagent) and inject-based (user message) execution.
|
|
1389
|
+
*/
|
|
1390
|
+
|
|
1391
|
+
/** Options passed to the fork execution callback */
|
|
1392
|
+
interface IForkExecutionOptions {
|
|
1393
|
+
/** Agent identity to use (e.g., 'Explore', 'Plan') */
|
|
1394
|
+
agent?: string;
|
|
1395
|
+
/** Tools the subagent is allowed to use */
|
|
1396
|
+
allowedTools?: string[];
|
|
1397
|
+
}
|
|
1398
|
+
/** Callback interface for skill execution infrastructure */
|
|
1399
|
+
interface ISkillExecutionCallbacks {
|
|
1400
|
+
/**
|
|
1401
|
+
* Run skill content in an isolated subagent session.
|
|
1402
|
+
* The content becomes the subagent's prompt.
|
|
1403
|
+
* Returns the subagent's response.
|
|
1404
|
+
*/
|
|
1405
|
+
runInFork?: (content: string, options: IForkExecutionOptions) => Promise<string>;
|
|
1406
|
+
}
|
|
1407
|
+
/** Result of skill execution */
|
|
1408
|
+
interface ISkillExecutionResult {
|
|
1409
|
+
/** Execution mode used */
|
|
1410
|
+
mode: 'fork' | 'inject';
|
|
1411
|
+
/** For inject mode: the prompt to send as a user message */
|
|
1412
|
+
prompt?: string;
|
|
1413
|
+
/** For fork mode: the subagent's response */
|
|
1414
|
+
result?: string;
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* Execute a skill command.
|
|
1418
|
+
*
|
|
1419
|
+
* When `context: 'fork'`, the skill runs in an isolated subagent session
|
|
1420
|
+
* via the `runInFork` callback. Throws if `runInFork` is not available.
|
|
1421
|
+
* For non-fork skills, the content is returned as a prompt for injection
|
|
1422
|
+
* into the current session.
|
|
1423
|
+
*/
|
|
1424
|
+
declare function executeSkill(skill: ICommand, args: string, callbacks: ISkillExecutionCallbacks, context?: SkillPromptContext): Promise<ISkillExecutionResult>;
|
|
1425
|
+
|
|
1426
|
+
type TSkillActivationSource = 'skill' | 'plugin';
|
|
1427
|
+
type TSkillActivationInvocation = 'user-slash' | 'model-tool';
|
|
1428
|
+
type TSkillActivationMode = 'inject' | 'fork';
|
|
1429
|
+
type TSkillActivationStatus = 'started' | 'completed' | 'failed';
|
|
1430
|
+
interface ISkillActivationEvent {
|
|
1431
|
+
readonly type: 'skill-activation';
|
|
1432
|
+
readonly skillName: string;
|
|
1433
|
+
readonly source: TSkillActivationSource;
|
|
1434
|
+
readonly invocation: TSkillActivationInvocation;
|
|
1435
|
+
readonly mode: TSkillActivationMode;
|
|
1436
|
+
readonly status: TSkillActivationStatus;
|
|
1437
|
+
readonly timestamp: string;
|
|
1438
|
+
readonly qualifiedName?: string;
|
|
1439
|
+
readonly error?: string;
|
|
1440
|
+
}
|
|
1441
|
+
interface ISkillActivationHistoryData extends ISkillActivationEvent {
|
|
1442
|
+
readonly message: string;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
declare function buildPromptWithFileReferences(input: string, references: readonly IResolvedPromptFileReference[]): string;
|
|
1446
|
+
declare function hasBlockingPromptFileReferenceDiagnostics(diagnostics: readonly IPromptFileReferenceDiagnostic[]): boolean;
|
|
1447
|
+
declare function formatPromptFileReferenceDiagnostics(diagnostics: readonly IPromptFileReferenceDiagnostic[]): string;
|
|
1448
|
+
declare function toPromptFileReferenceRecords(references: readonly IResolvedPromptFileReference[]): IPromptFileReferenceRecord[];
|
|
1449
|
+
declare function createPromptFileReferenceHistoryEntry(references: readonly IResolvedPromptFileReference[]): IHistoryEntry<IPromptFileReferenceHistoryData>;
|
|
1450
|
+
|
|
1451
|
+
declare function parsePromptFileReferences(input: string): IPromptFileReferenceToken[];
|
|
1452
|
+
|
|
1453
|
+
declare function resolvePromptFileReferences(input: string, options: IPromptFileReferenceResolveOptions): Promise<IResolvedPromptFileReferences>;
|
|
1454
|
+
declare function resolvePromptFileReferencePaths(referencePaths: readonly string[], options: IPromptFileReferenceResolveOptions): Promise<IResolvedPromptFileReferences>;
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Types for InteractiveSession — event-driven session wrapper.
|
|
1458
|
+
*/
|
|
1459
|
+
|
|
1460
|
+
/** Permission handler result — SDK-owned type (mirrors agent-sessions TPermissionResult).
|
|
1461
|
+
* true = allow, false = deny, 'allow-session' = allow and remember for this session. */
|
|
1462
|
+
type TPermissionResultValue = boolean | 'allow-session';
|
|
1463
|
+
/** Tool execution state visible to clients. */
|
|
1464
|
+
interface IToolState {
|
|
1465
|
+
toolName: string;
|
|
1466
|
+
firstArg: string;
|
|
1467
|
+
isRunning: boolean;
|
|
1468
|
+
result?: 'success' | 'error' | 'denied';
|
|
1469
|
+
diffLines?: IDiffLine[];
|
|
1470
|
+
diffFile?: string;
|
|
1471
|
+
toolResultData?: string;
|
|
1472
|
+
}
|
|
1473
|
+
/** A single diff line for Edit tool display. */
|
|
1474
|
+
interface IDiffLine {
|
|
1475
|
+
type: 'add' | 'remove' | 'context' | 'hunk';
|
|
1476
|
+
text: string;
|
|
1477
|
+
lineNumber: number;
|
|
1478
|
+
}
|
|
1479
|
+
interface IUsageSnapshot {
|
|
1480
|
+
kind: 'exact' | 'estimated';
|
|
1481
|
+
scope: 'turn';
|
|
1482
|
+
totalTokens: number;
|
|
1483
|
+
promptTokens?: number;
|
|
1484
|
+
completionTokens?: number;
|
|
1485
|
+
contextUsedTokens: number;
|
|
1486
|
+
contextMaxTokens: number;
|
|
1487
|
+
contextUsedPercentage: number;
|
|
1488
|
+
costStatus: 'unknown' | 'estimated' | 'exact';
|
|
1489
|
+
}
|
|
1490
|
+
/** Result of a completed prompt execution. */
|
|
1491
|
+
interface IExecutionResult {
|
|
1492
|
+
response: string;
|
|
1493
|
+
history: IHistoryEntry[];
|
|
1494
|
+
toolSummaries: IToolSummary[];
|
|
1495
|
+
contextState: IContextWindowState;
|
|
1496
|
+
usage?: IUsageSnapshot;
|
|
1497
|
+
promptFileReferences?: IPromptFileReferenceRecord[];
|
|
1498
|
+
}
|
|
1499
|
+
/** Summary of a tool call extracted from history. */
|
|
1500
|
+
interface IToolSummary {
|
|
1501
|
+
name: string;
|
|
1502
|
+
args: string;
|
|
1503
|
+
}
|
|
1504
|
+
/** Permission handler delegate — clients provide their own UI. */
|
|
1505
|
+
type TInteractivePermissionHandler = (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResultValue>;
|
|
1506
|
+
/** Events emitted by InteractiveSession. */
|
|
1507
|
+
interface IInteractiveSessionEvents {
|
|
1508
|
+
text_delta: (delta: string) => void;
|
|
1509
|
+
tool_start: (state: IToolState) => void;
|
|
1510
|
+
tool_end: (state: IToolState) => void;
|
|
1511
|
+
thinking: (isThinking: boolean) => void;
|
|
1512
|
+
complete: (result: IExecutionResult) => void;
|
|
1513
|
+
error: (error: Error) => void;
|
|
1514
|
+
context_update: (state: IContextWindowState) => void;
|
|
1515
|
+
compact: (event: ICompactEvent) => void;
|
|
1516
|
+
interrupted: (result: IExecutionResult) => void;
|
|
1517
|
+
skill_activation: (event: ISkillActivationEvent) => void;
|
|
1518
|
+
background_task_event: (event: TBackgroundTaskEvent) => void;
|
|
1519
|
+
background_job_group_event: (event: TBackgroundJobGroupEvent) => void;
|
|
1520
|
+
}
|
|
1521
|
+
type TInteractiveEventName = keyof IInteractiveSessionEvents;
|
|
1522
|
+
/**
|
|
1523
|
+
* Common interface for all transport adapters.
|
|
1524
|
+
* Each transport exposes InteractiveSession over a specific protocol.
|
|
1525
|
+
*/
|
|
1526
|
+
interface ITransportAdapter {
|
|
1527
|
+
/** Human-readable transport name (e.g., 'http', 'ws', 'mcp', 'headless') */
|
|
1528
|
+
readonly name: string;
|
|
1529
|
+
/** Attach an InteractiveSession to this transport. */
|
|
1530
|
+
attach(session: InteractiveSession): void;
|
|
1531
|
+
/** Start serving. What this means depends on the transport. */
|
|
1532
|
+
start(): Promise<void>;
|
|
1533
|
+
/** Stop serving and clean up resources. */
|
|
1534
|
+
stop(): Promise<void>;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Definition of an agent that can be spawned as a subagent.
|
|
1539
|
+
*
|
|
1540
|
+
* Built-in agents and custom (user-defined) agents share this shape.
|
|
1541
|
+
* Optional fields inherit from the parent session when omitted.
|
|
1542
|
+
*/
|
|
1543
|
+
interface IAgentDefinition {
|
|
1544
|
+
/** Unique name used to reference the agent (e.g., 'Explore', 'Plan'). */
|
|
1545
|
+
name: string;
|
|
1546
|
+
/** Human-readable description of the agent's purpose. */
|
|
1547
|
+
description: string;
|
|
1548
|
+
/** Markdown body content used as the agent's system prompt. */
|
|
1549
|
+
systemPrompt: string;
|
|
1550
|
+
/** Model override (e.g., 'claude-haiku-4-5', 'sonnet', 'opus'). Inherits parent model when omitted. */
|
|
1551
|
+
model?: string;
|
|
1552
|
+
/** Maximum number of agentic turns the subagent may execute. */
|
|
1553
|
+
maxTurns?: number;
|
|
1554
|
+
/** Allowlist of tool names. Only these tools are available when set. */
|
|
1555
|
+
tools?: string[];
|
|
1556
|
+
/** Denylist of tool names. These tools are removed from the inherited set. */
|
|
1557
|
+
disallowedTools?: string[];
|
|
1558
|
+
}
|
|
8
1559
|
|
|
9
1560
|
/**
|
|
10
1561
|
* Zod schemas and TypeScript types for Robota CLI settings
|
|
11
1562
|
*/
|
|
12
1563
|
|
|
13
|
-
declare const HooksSchema: z.ZodOptional<z.ZodObject<{
|
|
14
|
-
PreToolUse: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
15
|
-
matcher: z.ZodString;
|
|
16
|
-
hooks: z.ZodArray<z.ZodObject<{
|
|
17
|
-
type: z.ZodLiteral<"command">;
|
|
18
|
-
command: z.ZodString;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
type: "command";
|
|
21
|
-
command: string;
|
|
22
|
-
}, {
|
|
23
|
-
type: "command";
|
|
24
|
-
command: string;
|
|
25
|
-
}>, "many">;
|
|
26
|
-
}, "strip", z.ZodTypeAny, {
|
|
27
|
-
matcher: string;
|
|
28
|
-
hooks: {
|
|
29
|
-
type: "command";
|
|
30
|
-
command: string;
|
|
31
|
-
}[];
|
|
32
|
-
}, {
|
|
33
|
-
matcher: string;
|
|
34
|
-
hooks: {
|
|
35
|
-
type: "command";
|
|
36
|
-
command: string;
|
|
37
|
-
}[];
|
|
38
|
-
}>, "many">>;
|
|
39
|
-
PostToolUse: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
|
-
matcher: z.ZodString;
|
|
41
|
-
hooks: z.ZodArray<z.ZodObject<{
|
|
42
|
-
type: z.ZodLiteral<"command">;
|
|
43
|
-
command: z.ZodString;
|
|
44
|
-
}, "strip", z.ZodTypeAny, {
|
|
45
|
-
type: "command";
|
|
46
|
-
command: string;
|
|
47
|
-
}, {
|
|
48
|
-
type: "command";
|
|
49
|
-
command: string;
|
|
50
|
-
}>, "many">;
|
|
51
|
-
}, "strip", z.ZodTypeAny, {
|
|
52
|
-
matcher: string;
|
|
53
|
-
hooks: {
|
|
54
|
-
type: "command";
|
|
55
|
-
command: string;
|
|
56
|
-
}[];
|
|
57
|
-
}, {
|
|
58
|
-
matcher: string;
|
|
59
|
-
hooks: {
|
|
60
|
-
type: "command";
|
|
61
|
-
command: string;
|
|
62
|
-
}[];
|
|
63
|
-
}>, "many">>;
|
|
64
|
-
SessionStart: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
65
|
-
matcher: z.ZodString;
|
|
66
|
-
hooks: z.ZodArray<z.ZodObject<{
|
|
67
|
-
type: z.ZodLiteral<"command">;
|
|
68
|
-
command: z.ZodString;
|
|
69
|
-
}, "strip", z.ZodTypeAny, {
|
|
70
|
-
type: "command";
|
|
71
|
-
command: string;
|
|
72
|
-
}, {
|
|
73
|
-
type: "command";
|
|
74
|
-
command: string;
|
|
75
|
-
}>, "many">;
|
|
76
|
-
}, "strip", z.ZodTypeAny, {
|
|
77
|
-
matcher: string;
|
|
78
|
-
hooks: {
|
|
79
|
-
type: "command";
|
|
80
|
-
command: string;
|
|
81
|
-
}[];
|
|
82
|
-
}, {
|
|
83
|
-
matcher: string;
|
|
84
|
-
hooks: {
|
|
85
|
-
type: "command";
|
|
86
|
-
command: string;
|
|
87
|
-
}[];
|
|
88
|
-
}>, "many">>;
|
|
89
|
-
Stop: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
90
|
-
matcher: z.ZodString;
|
|
91
|
-
hooks: z.ZodArray<z.ZodObject<{
|
|
92
|
-
type: z.ZodLiteral<"command">;
|
|
93
|
-
command: z.ZodString;
|
|
94
|
-
}, "strip", z.ZodTypeAny, {
|
|
95
|
-
type: "command";
|
|
96
|
-
command: string;
|
|
97
|
-
}, {
|
|
98
|
-
type: "command";
|
|
99
|
-
command: string;
|
|
100
|
-
}>, "many">;
|
|
101
|
-
}, "strip", z.ZodTypeAny, {
|
|
102
|
-
matcher: string;
|
|
103
|
-
hooks: {
|
|
104
|
-
type: "command";
|
|
105
|
-
command: string;
|
|
106
|
-
}[];
|
|
107
|
-
}, {
|
|
108
|
-
matcher: string;
|
|
109
|
-
hooks: {
|
|
110
|
-
type: "command";
|
|
111
|
-
command: string;
|
|
112
|
-
}[];
|
|
113
|
-
}>, "many">>;
|
|
114
|
-
}, "strip", z.ZodTypeAny, {
|
|
115
|
-
PreToolUse?: {
|
|
116
|
-
matcher: string;
|
|
117
|
-
hooks: {
|
|
118
|
-
type: "command";
|
|
119
|
-
command: string;
|
|
120
|
-
}[];
|
|
121
|
-
}[] | undefined;
|
|
122
|
-
PostToolUse?: {
|
|
123
|
-
matcher: string;
|
|
124
|
-
hooks: {
|
|
125
|
-
type: "command";
|
|
126
|
-
command: string;
|
|
127
|
-
}[];
|
|
128
|
-
}[] | undefined;
|
|
129
|
-
SessionStart?: {
|
|
130
|
-
matcher: string;
|
|
131
|
-
hooks: {
|
|
132
|
-
type: "command";
|
|
133
|
-
command: string;
|
|
134
|
-
}[];
|
|
135
|
-
}[] | undefined;
|
|
136
|
-
Stop?: {
|
|
137
|
-
matcher: string;
|
|
138
|
-
hooks: {
|
|
139
|
-
type: "command";
|
|
140
|
-
command: string;
|
|
141
|
-
}[];
|
|
142
|
-
}[] | undefined;
|
|
143
|
-
}, {
|
|
144
|
-
PreToolUse?: {
|
|
145
|
-
matcher: string;
|
|
146
|
-
hooks: {
|
|
147
|
-
type: "command";
|
|
148
|
-
command: string;
|
|
149
|
-
}[];
|
|
150
|
-
}[] | undefined;
|
|
151
|
-
PostToolUse?: {
|
|
152
|
-
matcher: string;
|
|
153
|
-
hooks: {
|
|
154
|
-
type: "command";
|
|
155
|
-
command: string;
|
|
156
|
-
}[];
|
|
157
|
-
}[] | undefined;
|
|
158
|
-
SessionStart?: {
|
|
159
|
-
matcher: string;
|
|
160
|
-
hooks: {
|
|
161
|
-
type: "command";
|
|
162
|
-
command: string;
|
|
163
|
-
}[];
|
|
164
|
-
}[] | undefined;
|
|
165
|
-
Stop?: {
|
|
166
|
-
matcher: string;
|
|
167
|
-
hooks: {
|
|
168
|
-
type: "command";
|
|
169
|
-
command: string;
|
|
170
|
-
}[];
|
|
171
|
-
}[] | undefined;
|
|
172
|
-
}>>;
|
|
173
1564
|
/**
|
|
174
1565
|
* Fully resolved config after merging all settings files and applying defaults.
|
|
175
1566
|
*/
|
|
176
1567
|
interface IResolvedConfig {
|
|
177
1568
|
defaultTrustLevel: 'safe' | 'moderate' | 'full';
|
|
1569
|
+
/** Response language code (e.g., "ko", "en"). Undefined = no language constraint. */
|
|
1570
|
+
language?: string;
|
|
1571
|
+
/** Active provider profile key when providers/currentProvider are used. */
|
|
1572
|
+
currentProvider?: string;
|
|
178
1573
|
provider: {
|
|
179
1574
|
name: string;
|
|
180
1575
|
model: string;
|
|
181
1576
|
apiKey: string | undefined;
|
|
1577
|
+
baseURL?: string;
|
|
1578
|
+
timeout?: number;
|
|
1579
|
+
options?: Record<string, TUniversalValue>;
|
|
182
1580
|
};
|
|
183
1581
|
permissions: {
|
|
184
1582
|
allow: string[];
|
|
185
1583
|
deny: string[];
|
|
186
1584
|
};
|
|
187
1585
|
env: Record<string, string>;
|
|
188
|
-
hooks?:
|
|
1586
|
+
hooks?: THooksConfig;
|
|
1587
|
+
/** Plugin enablement map: plugin name -> enabled/disabled */
|
|
1588
|
+
enabledPlugins?: Record<string, boolean>;
|
|
1589
|
+
/** Extra marketplace sources: name -> { source } */
|
|
1590
|
+
extraKnownMarketplaces?: Record<string, {
|
|
1591
|
+
source: {
|
|
1592
|
+
type: string;
|
|
1593
|
+
repo?: string;
|
|
1594
|
+
url?: string;
|
|
1595
|
+
path?: string;
|
|
1596
|
+
ref?: string;
|
|
1597
|
+
};
|
|
1598
|
+
}>;
|
|
1599
|
+
/** Auto-compact threshold as a 0-1 fraction. Set false to disable automatic compaction. */
|
|
1600
|
+
autoCompactThreshold?: number | false;
|
|
189
1601
|
}
|
|
190
1602
|
|
|
191
1603
|
interface ILoadedContext {
|
|
@@ -193,16 +1605,156 @@ interface ILoadedContext {
|
|
|
193
1605
|
agentsMd: string;
|
|
194
1606
|
/** Concatenated content of all CLAUDE.md files found (root-first) */
|
|
195
1607
|
claudeMd: string;
|
|
1608
|
+
/** Startup project memory index loaded from .robota/memory/MEMORY.md, if present */
|
|
1609
|
+
memoryMd?: string;
|
|
1610
|
+
/** Formatted active task context loaded from .agents/tasks/*.md, if present */
|
|
1611
|
+
taskContext?: string;
|
|
196
1612
|
/** Extracted "Compact Instructions" section from CLAUDE.md, if present */
|
|
197
1613
|
compactInstructions?: string;
|
|
198
1614
|
}
|
|
1615
|
+
|
|
199
1616
|
/**
|
|
200
|
-
*
|
|
201
|
-
* Files from higher directories appear before files from lower directories.
|
|
1617
|
+
* Subagent session factory — assembles an isolated child Session for subagent execution.
|
|
202
1618
|
*
|
|
203
|
-
*
|
|
1619
|
+
* Unlike `createSession`, this factory does not load config files or context from disk.
|
|
1620
|
+
* It receives pre-resolved config and context from the parent session, applies tool
|
|
1621
|
+
* filtering and model resolution from the agent definition, and creates a lightweight
|
|
1622
|
+
* Session suitable for subagent use.
|
|
204
1623
|
*/
|
|
205
|
-
|
|
1624
|
+
|
|
1625
|
+
/** Options for creating a subagent session. */
|
|
1626
|
+
interface ISubagentOptions {
|
|
1627
|
+
/** Agent definition (built-in or custom). */
|
|
1628
|
+
agentDefinition: IAgentDefinition;
|
|
1629
|
+
/** Parent's resolved config (for provider, permissions, etc.). */
|
|
1630
|
+
parentConfig: IResolvedConfig;
|
|
1631
|
+
/** Parent's loaded context (CLAUDE.md, AGENTS.md). */
|
|
1632
|
+
parentContext: ILoadedContext;
|
|
1633
|
+
/** Parent session's available tools (to inherit/filter). */
|
|
1634
|
+
parentTools: IToolWithEventService[];
|
|
1635
|
+
/** AI provider instance. */
|
|
1636
|
+
provider: IAIProvider;
|
|
1637
|
+
/** Terminal output interface. */
|
|
1638
|
+
terminal: ITerminalOutput;
|
|
1639
|
+
/** Stable session ID for transcript files. */
|
|
1640
|
+
sessionId?: string;
|
|
1641
|
+
/** Optional logger for subagent transcripts. */
|
|
1642
|
+
sessionLogger?: ISessionLogger;
|
|
1643
|
+
/** Whether this is a fork worker (uses fork suffix instead of standard). */
|
|
1644
|
+
isForkWorker?: boolean;
|
|
1645
|
+
/** Permission mode from parent (bypassPermissions, acceptEdits, etc.). */
|
|
1646
|
+
permissionMode?: TPermissionMode;
|
|
1647
|
+
/** Permission handler from parent. */
|
|
1648
|
+
permissionHandler?: TPermissionHandler;
|
|
1649
|
+
/** Plugin hooks configuration from parent session. */
|
|
1650
|
+
hooks?: Record<string, unknown>;
|
|
1651
|
+
/** Hook type executors from parent session (prompt, agent, etc.). */
|
|
1652
|
+
hookTypeExecutors?: IHookTypeExecutor[];
|
|
1653
|
+
/** Streaming callback. */
|
|
1654
|
+
onTextDelta?: (delta: string) => void;
|
|
1655
|
+
/** Tool execution callback. */
|
|
1656
|
+
onToolExecution?: (event: {
|
|
1657
|
+
type: 'start' | 'end';
|
|
1658
|
+
toolName: string;
|
|
1659
|
+
toolArgs?: TToolArgs;
|
|
1660
|
+
success?: boolean;
|
|
1661
|
+
denied?: boolean;
|
|
1662
|
+
toolResultData?: string;
|
|
1663
|
+
}) => void;
|
|
1664
|
+
}
|
|
1665
|
+
/**
|
|
1666
|
+
* Create a fully-configured Session for subagent execution.
|
|
1667
|
+
*
|
|
1668
|
+
* Assembles provider, tools, and system prompt from parent context and
|
|
1669
|
+
* agent definition, then returns a new Session instance.
|
|
1670
|
+
*/
|
|
1671
|
+
declare function createSubagentSession(options: ISubagentOptions): Session;
|
|
1672
|
+
|
|
1673
|
+
interface IInProcessSubagentRunnerDeps {
|
|
1674
|
+
config: IResolvedConfig;
|
|
1675
|
+
context: ILoadedContext;
|
|
1676
|
+
tools: IToolWithEventService[];
|
|
1677
|
+
terminal: ITerminalOutput;
|
|
1678
|
+
provider: IAIProvider;
|
|
1679
|
+
permissionMode?: TPermissionMode;
|
|
1680
|
+
permissionHandler?: TPermissionHandler;
|
|
1681
|
+
hooks?: ISubagentOptions['hooks'];
|
|
1682
|
+
hookTypeExecutors?: IHookTypeExecutor[];
|
|
1683
|
+
onTextDelta?: (delta: string) => void;
|
|
1684
|
+
onToolExecution?: (event: {
|
|
1685
|
+
type: 'start' | 'end';
|
|
1686
|
+
toolName: string;
|
|
1687
|
+
toolArgs?: TToolArgs;
|
|
1688
|
+
success?: boolean;
|
|
1689
|
+
denied?: boolean;
|
|
1690
|
+
toolResultData?: string;
|
|
1691
|
+
}) => void;
|
|
1692
|
+
customAgentRegistry?: (name: string) => IAgentDefinition | undefined;
|
|
1693
|
+
}
|
|
1694
|
+
type TSubagentRunnerFactory = (deps: IInProcessSubagentRunnerDeps) => ISubagentRunner;
|
|
1695
|
+
|
|
1696
|
+
/**
|
|
1697
|
+
* Prompt hook executor — evaluates a prompt via an AI model.
|
|
1698
|
+
*
|
|
1699
|
+
* Makes a single-turn LLM call with hook input context as the prompt.
|
|
1700
|
+
* Parses { ok: boolean, reason?: string } from the AI response.
|
|
1701
|
+
*
|
|
1702
|
+
* Exit codes:
|
|
1703
|
+
* - 0: ok: true (allow/proceed)
|
|
1704
|
+
* - 2: ok: false (block/deny), reason in stderr
|
|
1705
|
+
* - 1: execution error (provider failure, parse error)
|
|
1706
|
+
*/
|
|
1707
|
+
|
|
1708
|
+
/** A minimal provider interface for single-turn completion. */
|
|
1709
|
+
interface IPromptProvider {
|
|
1710
|
+
complete(prompt: string): Promise<string>;
|
|
1711
|
+
}
|
|
1712
|
+
/** Factory that creates a provider instance, optionally for a specific model. */
|
|
1713
|
+
type TProviderFactory = (model?: string) => IPromptProvider;
|
|
1714
|
+
/** Constructor options for PromptExecutor. */
|
|
1715
|
+
interface IPromptExecutorOptions {
|
|
1716
|
+
providerFactory: TProviderFactory;
|
|
1717
|
+
defaultModel?: string;
|
|
1718
|
+
}
|
|
1719
|
+
declare class PromptExecutor implements IHookTypeExecutor {
|
|
1720
|
+
readonly type: "prompt";
|
|
1721
|
+
private readonly providerFactory;
|
|
1722
|
+
private readonly defaultModel;
|
|
1723
|
+
constructor(options: IPromptExecutorOptions);
|
|
1724
|
+
execute(definition: IHookDefinition, input: IHookInput): Promise<IHookResult>;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
/**
|
|
1728
|
+
* Agent hook executor — delegates to a sub-agent session.
|
|
1729
|
+
*
|
|
1730
|
+
* Creates a subagent session with maxTurns and timeout limits,
|
|
1731
|
+
* runs hook input as the initial prompt, and parses the result.
|
|
1732
|
+
*
|
|
1733
|
+
* Exit codes:
|
|
1734
|
+
* - 0: ok: true (allow/proceed)
|
|
1735
|
+
* - 2: ok: false (block/deny), reason in stderr
|
|
1736
|
+
* - 1: execution error (session failure, parse error)
|
|
1737
|
+
*/
|
|
1738
|
+
|
|
1739
|
+
/** A minimal session interface for running a prompt. */
|
|
1740
|
+
interface IAgentSession {
|
|
1741
|
+
run(prompt: string): Promise<string>;
|
|
1742
|
+
}
|
|
1743
|
+
/** Factory that creates a session instance with the given options. */
|
|
1744
|
+
type TSessionFactory = (options: {
|
|
1745
|
+
maxTurns?: number;
|
|
1746
|
+
timeout?: number;
|
|
1747
|
+
}) => IAgentSession;
|
|
1748
|
+
/** Constructor options for AgentExecutor. */
|
|
1749
|
+
interface IAgentExecutorOptions {
|
|
1750
|
+
sessionFactory: TSessionFactory;
|
|
1751
|
+
}
|
|
1752
|
+
declare class AgentExecutor implements IHookTypeExecutor {
|
|
1753
|
+
readonly type: "agent";
|
|
1754
|
+
private readonly sessionFactory;
|
|
1755
|
+
constructor(options: IAgentExecutorOptions);
|
|
1756
|
+
execute(definition: IHookDefinition, input: IHookInput): Promise<IHookResult>;
|
|
1757
|
+
}
|
|
206
1758
|
|
|
207
1759
|
type TProjectType = 'node' | 'python' | 'rust' | 'go' | 'unknown';
|
|
208
1760
|
type TPackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';
|
|
@@ -213,33 +1765,110 @@ interface IProjectInfo {
|
|
|
213
1765
|
packageManager?: TPackageManager;
|
|
214
1766
|
language: TLanguage;
|
|
215
1767
|
}
|
|
216
|
-
/**
|
|
217
|
-
* Detect the project type, language, name, and package manager from `cwd`.
|
|
218
|
-
*/
|
|
219
|
-
declare function detectProject(cwd: string): Promise<IProjectInfo>;
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* System prompt builder — assembles the system message sent to the AI model
|
|
223
|
-
* from base role, project context, AGENTS.md/CLAUDE.md, tool list, and
|
|
224
|
-
* permission trust level.
|
|
225
|
-
*/
|
|
226
1768
|
|
|
227
1769
|
interface ISystemPromptParams {
|
|
228
1770
|
/** Concatenated AGENTS.md content (may be empty string) */
|
|
229
1771
|
agentsMd: string;
|
|
230
1772
|
/** Concatenated CLAUDE.md content (may be empty string) */
|
|
231
1773
|
claudeMd: string;
|
|
1774
|
+
/** Startup project memory index loaded from .robota/memory/MEMORY.md */
|
|
1775
|
+
memoryMd?: string;
|
|
1776
|
+
/** Formatted active task context loaded from .agents/tasks/*.md */
|
|
1777
|
+
taskContext?: string;
|
|
232
1778
|
/** Human-readable tool descriptions, one per entry */
|
|
233
1779
|
toolDescriptions: string[];
|
|
234
1780
|
/** Active trust level governing permission checks */
|
|
235
1781
|
trustLevel: TTrustLevel;
|
|
236
1782
|
/** Detected project metadata */
|
|
237
1783
|
projectInfo: IProjectInfo;
|
|
1784
|
+
/** Current working directory */
|
|
1785
|
+
cwd?: string;
|
|
1786
|
+
/** Response language code (e.g., "ko", "en"). If set, AI must respond in this language. */
|
|
1787
|
+
language?: string;
|
|
1788
|
+
/** Discovered skills to expose in the system prompt */
|
|
1789
|
+
skills?: Array<{
|
|
1790
|
+
name: string;
|
|
1791
|
+
description: string;
|
|
1792
|
+
disableModelInvocation?: boolean;
|
|
1793
|
+
}>;
|
|
1794
|
+
/** Discovered agents to expose in the system prompt */
|
|
1795
|
+
agents?: Array<{
|
|
1796
|
+
name: string;
|
|
1797
|
+
description: string;
|
|
1798
|
+
}>;
|
|
1799
|
+
/** Command descriptors to expose to the model */
|
|
1800
|
+
commandDescriptors?: ICapabilityDescriptor[];
|
|
238
1801
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
1802
|
+
|
|
1803
|
+
type TReversibleExecutionIsolation = 'none' | 'worktree' | 'provider-sandbox';
|
|
1804
|
+
type TReversibleRollbackLayer = 'none' | 'edit-checkpoint' | 'worktree' | 'provider-sandbox';
|
|
1805
|
+
type TReversibleSideEffect = 'none' | 'file-mutation' | 'shell-process' | 'subagent' | 'unknown';
|
|
1806
|
+
type TReversibleSafetyStatus = 'reversible' | 'read-only' | 'requires-checkpoint' | 'requires-isolation' | 'unknown';
|
|
1807
|
+
interface IReversibleExecutionOptions {
|
|
1808
|
+
mode: 'local-first';
|
|
1809
|
+
isolation?: TReversibleExecutionIsolation;
|
|
1810
|
+
enforceUntrackedSideEffects?: boolean;
|
|
1811
|
+
}
|
|
1812
|
+
interface IReversibleToolSafetyContext {
|
|
1813
|
+
checkpointAvailable: boolean;
|
|
1814
|
+
isolation: TReversibleExecutionIsolation;
|
|
1815
|
+
}
|
|
1816
|
+
interface IReversibleToolSafetyInput {
|
|
1817
|
+
toolName: string;
|
|
1818
|
+
toolArgs?: TToolArgs;
|
|
1819
|
+
context: IReversibleToolSafetyContext;
|
|
1820
|
+
}
|
|
1821
|
+
interface IReversibleToolSafetyReport {
|
|
1822
|
+
toolName: string;
|
|
1823
|
+
reversible: boolean;
|
|
1824
|
+
sideEffect: TReversibleSideEffect;
|
|
1825
|
+
rollbackLayer: TReversibleRollbackLayer;
|
|
1826
|
+
status: TReversibleSafetyStatus;
|
|
1827
|
+
message: string;
|
|
1828
|
+
}
|
|
1829
|
+
declare function evaluateReversibleToolSafety(input: IReversibleToolSafetyInput): IReversibleToolSafetyReport;
|
|
1830
|
+
declare function wrapReversibleExecutionTools(tools: readonly IToolWithEventService[], options: IReversibleExecutionOptions & {
|
|
1831
|
+
checkpointAvailable: boolean;
|
|
1832
|
+
}): IToolWithEventService[];
|
|
1833
|
+
|
|
1834
|
+
interface IInteractiveSessionRecord {
|
|
1835
|
+
id: string;
|
|
1836
|
+
name?: string;
|
|
1837
|
+
cwd: string;
|
|
1838
|
+
createdAt: string;
|
|
1839
|
+
updatedAt: string;
|
|
1840
|
+
messages: TUniversalMessage[];
|
|
1841
|
+
history?: IHistoryEntry[];
|
|
1842
|
+
systemPrompt?: string;
|
|
1843
|
+
toolSchemas?: IToolSchema[];
|
|
1844
|
+
backgroundTasks?: IBackgroundTaskState[];
|
|
1845
|
+
backgroundTaskEvents?: TBackgroundTaskEvent[];
|
|
1846
|
+
backgroundJobGroups?: IBackgroundJobGroupState[];
|
|
1847
|
+
backgroundJobGroupEvents?: TBackgroundJobGroupEvent[];
|
|
1848
|
+
skillActivationEvents?: ISkillActivationEvent[];
|
|
1849
|
+
memoryEvents?: IMemoryEvent[];
|
|
1850
|
+
usedMemoryReferences?: IMemoryReference[];
|
|
1851
|
+
contextReferences?: IContextReferenceItem[];
|
|
1852
|
+
sandboxSnapshotId?: string;
|
|
1853
|
+
}
|
|
1854
|
+
interface IInteractiveSessionStore {
|
|
1855
|
+
save(session: IInteractiveSessionRecord): void;
|
|
1856
|
+
load(id: string): IInteractiveSessionRecord | undefined;
|
|
1857
|
+
list(): IInteractiveSessionRecord[];
|
|
1858
|
+
delete(id: string): void;
|
|
1859
|
+
}
|
|
1860
|
+
interface IResumableSessionSummary {
|
|
1861
|
+
id: string;
|
|
1862
|
+
name?: string;
|
|
1863
|
+
cwd: string;
|
|
1864
|
+
updatedAt: string;
|
|
1865
|
+
messageCount: number;
|
|
1866
|
+
preview: string;
|
|
1867
|
+
}
|
|
1868
|
+
declare function createProjectSessionStore(cwd: string): IInteractiveSessionStore;
|
|
1869
|
+
declare function listResumableSessionSummaries(sessionStore: IInteractiveSessionStore | undefined, cwd: string): IResumableSessionSummary[];
|
|
1870
|
+
declare function resolveLatestSessionId(sessionStore: IInteractiveSessionStore | undefined, cwd: string): string | undefined;
|
|
1871
|
+
declare function resolveSessionIdByIdOrName(sessionStore: IInteractiveSessionStore | undefined, idOrName: string): string | undefined;
|
|
243
1872
|
|
|
244
1873
|
/**
|
|
245
1874
|
* Session factory — assembles a fully-configured Session from config, context,
|
|
@@ -250,10 +1879,13 @@ declare function buildSystemPrompt(params: ISystemPromptParams): string;
|
|
|
250
1879
|
* expects as pre-constructed dependencies.
|
|
251
1880
|
*/
|
|
252
1881
|
|
|
1882
|
+
type TAutoCompactThreshold = number | false;
|
|
253
1883
|
/** Options for the createSession factory */
|
|
254
1884
|
interface ICreateSessionOptions {
|
|
255
1885
|
/** Resolved CLI configuration (model, API key, permissions) */
|
|
256
1886
|
config: IResolvedConfig;
|
|
1887
|
+
/** Working directory used for project context, skills, and agent definitions. */
|
|
1888
|
+
cwd?: string;
|
|
257
1889
|
/** Loaded AGENTS.md / CLAUDE.md context */
|
|
258
1890
|
context: ILoadedContext;
|
|
259
1891
|
/** Terminal I/O for permission prompts */
|
|
@@ -265,97 +1897,552 @@ interface ICreateSessionOptions {
|
|
|
265
1897
|
/** Maximum number of agentic turns per run() call. Undefined = unlimited. */
|
|
266
1898
|
maxTurns?: number;
|
|
267
1899
|
/** Optional session store for persistence */
|
|
268
|
-
sessionStore?:
|
|
1900
|
+
sessionStore?: IInteractiveSessionStore;
|
|
269
1901
|
/** Inject a pre-constructed AI provider (used by tests to avoid real API calls) */
|
|
270
1902
|
provider?: IAIProvider;
|
|
271
1903
|
/** Custom permission handler (overrides terminal-based prompts, used by Ink UI) */
|
|
272
1904
|
permissionHandler?: TPermissionHandler;
|
|
273
1905
|
/** Callback for text deltas — enables streaming text to the UI in real-time */
|
|
274
1906
|
onTextDelta?: (delta: string) => void;
|
|
1907
|
+
/** Callback when context window usage is refreshed */
|
|
1908
|
+
onContextUpdate?: (state: IContextWindowState) => void;
|
|
275
1909
|
/** Custom prompt-for-approval function (injected from CLI) */
|
|
276
1910
|
promptForApproval?: (terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
|
|
277
1911
|
/** Additional tools to register beyond the defaults (e.g. agent-tool) */
|
|
278
1912
|
additionalTools?: IToolWithEventService[];
|
|
1913
|
+
/** Additional background task runners composed by the runtime shell. */
|
|
1914
|
+
backgroundTaskRunners?: IBackgroundTaskRunner[];
|
|
1915
|
+
/** Runtime shell override for subagent execution. Defaults to the SDK in-process runner. */
|
|
1916
|
+
subagentRunnerFactory?: TSubagentRunnerFactory;
|
|
1917
|
+
/** Enable agent tool, agent definitions, and subagent runtime wiring for this session. */
|
|
1918
|
+
enableAgentRuntime?: boolean;
|
|
1919
|
+
/** Callback when a tool starts or finishes execution — enables real-time tool display in UI */
|
|
1920
|
+
onToolExecution?: (event: {
|
|
1921
|
+
type: 'start' | 'end';
|
|
1922
|
+
toolName: string;
|
|
1923
|
+
toolArgs?: TToolArgs;
|
|
1924
|
+
success?: boolean;
|
|
1925
|
+
denied?: boolean;
|
|
1926
|
+
toolResultData?: string;
|
|
1927
|
+
}) => void;
|
|
279
1928
|
/** Callback when context is compacted */
|
|
280
1929
|
onCompact?: (summary: string) => void;
|
|
1930
|
+
/** Callback with structured compaction metadata */
|
|
1931
|
+
onCompactEvent?: (event: ICompactEvent) => void;
|
|
281
1932
|
/** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
|
|
282
1933
|
compactInstructions?: string;
|
|
1934
|
+
/** Auto-compact threshold as a 0-1 fraction. Set false to disable automatic compaction. */
|
|
1935
|
+
autoCompactThreshold?: TAutoCompactThreshold;
|
|
283
1936
|
/** Custom system prompt builder function */
|
|
284
1937
|
systemPromptBuilder?: (params: ISystemPromptParams) => string;
|
|
285
1938
|
/** Custom tool descriptions for the system prompt */
|
|
286
1939
|
toolDescriptions?: string[];
|
|
287
1940
|
/** Session logger — injected for pluggable session event logging. */
|
|
288
1941
|
sessionLogger?: ISessionLogger;
|
|
1942
|
+
/** Provider factory for prompt hook executors (DI). */
|
|
1943
|
+
providerFactory?: TProviderFactory;
|
|
1944
|
+
/** Session factory for agent hook executors (DI). */
|
|
1945
|
+
sessionFactory?: TSessionFactory;
|
|
1946
|
+
/** Additional hook type executors beyond the defaults (prompt, agent). */
|
|
1947
|
+
additionalHookExecutors?: IHookTypeExecutor[];
|
|
1948
|
+
/** Override session ID (used when resuming a session to reuse the original ID) */
|
|
1949
|
+
sessionId?: string;
|
|
1950
|
+
/** Pre-approved tool names — added to permissions.allow as ToolName(*) patterns. */
|
|
1951
|
+
allowedTools?: string[];
|
|
1952
|
+
/** Text to append to the generated system prompt. */
|
|
1953
|
+
appendSystemPrompt?: string;
|
|
1954
|
+
/** Model command execution bridge. */
|
|
1955
|
+
modelCommandExecutor?: (command: string, args: string) => Promise<ICommandResult | null>;
|
|
1956
|
+
/** Predicate for commands allowed through the model command execution bridge. */
|
|
1957
|
+
isModelCommandInvocable?: (command: string) => boolean;
|
|
1958
|
+
/** Model-visible command descriptors. */
|
|
1959
|
+
commandDescriptors?: ICapabilityDescriptor[];
|
|
1960
|
+
/** Recorder used to snapshot files before Write/Edit tools mutate them. */
|
|
1961
|
+
editCheckpointRecorder?: IEditCheckpointRecorder;
|
|
1962
|
+
/** Opt-in local-first reversible execution policy for write/shell tools. */
|
|
1963
|
+
reversibleExecution?: IReversibleExecutionOptions;
|
|
1964
|
+
/** Optional provider sandbox client used by sandbox-aware built-in tools. */
|
|
1965
|
+
sandboxClient?: ISandboxClient;
|
|
289
1966
|
}
|
|
290
|
-
/**
|
|
291
|
-
* Create a fully-configured Session instance.
|
|
292
|
-
*
|
|
293
|
-
* Assembles provider, tools, and system prompt, then passes them
|
|
294
|
-
* to Session as pre-constructed dependencies.
|
|
295
|
-
*/
|
|
296
|
-
declare function createSession(options: ICreateSessionOptions): Session;
|
|
297
1967
|
|
|
298
1968
|
/**
|
|
299
1969
|
* Default tool set factory — creates the standard set of CLI tools.
|
|
300
1970
|
*/
|
|
301
1971
|
|
|
302
|
-
/** Human-readable descriptions of the built-in tools (for system prompt) */
|
|
303
|
-
declare const DEFAULT_TOOL_DESCRIPTIONS: string[];
|
|
304
1972
|
/**
|
|
305
1973
|
* Create the default set of CLI tools.
|
|
306
1974
|
* Returns the 8 standard tools as IToolWithEventService[].
|
|
307
1975
|
*/
|
|
308
|
-
|
|
1976
|
+
interface ICreateDefaultToolsOptions {
|
|
1977
|
+
sandboxClient?: ISandboxClient;
|
|
1978
|
+
}
|
|
1979
|
+
declare function createDefaultTools(options?: ICreateDefaultToolsOptions): IToolWithEventService[];
|
|
309
1980
|
|
|
310
1981
|
/**
|
|
311
|
-
*
|
|
1982
|
+
* Framework system prompt suffixes for subagent sessions.
|
|
1983
|
+
*
|
|
1984
|
+
* These functions generate the standard prompt content injected into
|
|
1985
|
+
* subagent sessions to control output format and behavior.
|
|
1986
|
+
*/
|
|
1987
|
+
/** Options for assembling a subagent system prompt. */
|
|
1988
|
+
interface ISubagentPromptOptions {
|
|
1989
|
+
/** Agent definition markdown body. */
|
|
1990
|
+
agentBody: string;
|
|
1991
|
+
/** CLAUDE.md content to include. */
|
|
1992
|
+
claudeMd?: string;
|
|
1993
|
+
/** AGENTS.md content to include. */
|
|
1994
|
+
agentsMd?: string;
|
|
1995
|
+
/** When true, use fork worker suffix instead of standard subagent suffix. */
|
|
1996
|
+
isForkWorker: boolean;
|
|
1997
|
+
}
|
|
1998
|
+
/**
|
|
1999
|
+
* Returns the standard subagent suffix appended to agent body for normal subagents.
|
|
2000
|
+
*/
|
|
2001
|
+
declare function getSubagentSuffix(): string;
|
|
2002
|
+
/**
|
|
2003
|
+
* Returns the fork worker suffix for context:fork skill workers.
|
|
2004
|
+
*/
|
|
2005
|
+
declare function getForkWorkerSuffix(): string;
|
|
2006
|
+
/**
|
|
2007
|
+
* Assembles the full system prompt for a subagent.
|
|
2008
|
+
*
|
|
2009
|
+
* Assembly order:
|
|
2010
|
+
* 1. Agent definition body
|
|
2011
|
+
* 2. CLAUDE.md content (if provided)
|
|
2012
|
+
* 3. AGENTS.md content (if provided)
|
|
2013
|
+
* 4. Framework suffix (fork worker OR standard subagent)
|
|
312
2014
|
*/
|
|
2015
|
+
declare function assembleSubagentPrompt(options: ISubagentPromptOptions): string;
|
|
313
2016
|
|
|
314
2017
|
/**
|
|
315
|
-
*
|
|
316
|
-
*
|
|
2018
|
+
* Subagent transcript logger — creates a FileSessionLogger that writes
|
|
2019
|
+
* subagent session logs into a subdirectory of the parent session's log folder.
|
|
2020
|
+
*
|
|
2021
|
+
* Log structure:
|
|
2022
|
+
* {baseLogsDir}/{parentSessionId}/subagents/{agentId}.jsonl
|
|
317
2023
|
*/
|
|
318
|
-
declare function createProvider(config: IResolvedConfig): IAIProvider;
|
|
319
2024
|
|
|
320
2025
|
/**
|
|
321
|
-
*
|
|
322
|
-
*
|
|
2026
|
+
* Create a FileSessionLogger for a subagent session.
|
|
2027
|
+
*
|
|
2028
|
+
* The logger writes JSONL files into a `subagents/` subdirectory under the
|
|
2029
|
+
* parent session's log folder. The directory is created if it does not exist.
|
|
2030
|
+
*
|
|
2031
|
+
* @param parentSessionId - ID of the parent session (used as directory name)
|
|
2032
|
+
* @param agentId - Unique identifier for this subagent run
|
|
2033
|
+
* @param baseLogsDir - Root logs directory (e.g., `.robota/logs`)
|
|
2034
|
+
* @returns A FileSessionLogger writing to the subagent directory
|
|
2035
|
+
*/
|
|
2036
|
+
declare function createSubagentLogger(parentSessionId: string, _agentId: string, baseLogsDir: string): FileSessionLogger;
|
|
2037
|
+
/**
|
|
2038
|
+
* Resolve the subagent log directory path without creating it.
|
|
2039
|
+
*
|
|
2040
|
+
* Useful when the caller needs the path for display or configuration
|
|
2041
|
+
* but does not want to create the directory immediately.
|
|
2042
|
+
*
|
|
2043
|
+
* @param parentSessionId - ID of the parent session
|
|
2044
|
+
* @param baseLogsDir - Root logs directory
|
|
2045
|
+
* @returns The resolved subagent log directory path
|
|
2046
|
+
*/
|
|
2047
|
+
declare function resolveSubagentLogDir(parentSessionId: string, baseLogsDir: string): string;
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* Session initialization helpers for InteractiveSession.
|
|
2051
|
+
*
|
|
2052
|
+
* Handles async config/context loading, plugin merging, and session creation.
|
|
2053
|
+
* Also provides session-restore (resume/fork) logic.
|
|
323
2054
|
*/
|
|
324
2055
|
|
|
325
|
-
|
|
2056
|
+
/** Standard construction: cwd + provider. Config/context loaded internally. */
|
|
2057
|
+
interface IInteractiveSessionStandardOptions {
|
|
2058
|
+
cwd: string;
|
|
2059
|
+
provider: IAIProvider;
|
|
2060
|
+
permissionMode?: ICreateSessionOptions['permissionMode'];
|
|
2061
|
+
maxTurns?: number;
|
|
2062
|
+
permissionHandler?: TInteractivePermissionHandler;
|
|
2063
|
+
sessionStore?: IInteractiveSessionStore;
|
|
2064
|
+
sessionName?: string;
|
|
2065
|
+
resumeSessionId?: string;
|
|
2066
|
+
forkSession?: boolean;
|
|
2067
|
+
/** Skip AGENTS.md/CLAUDE.md loading and plugin discovery. */
|
|
2068
|
+
bare?: boolean;
|
|
2069
|
+
/** Pre-approved tool names passed to createSession. */
|
|
2070
|
+
allowedTools?: string[];
|
|
2071
|
+
/** Text to append to the system prompt. */
|
|
2072
|
+
appendSystemPrompt?: string;
|
|
2073
|
+
/** Runtime-composed background task runners. */
|
|
2074
|
+
backgroundTaskRunners?: IBackgroundTaskRunner[];
|
|
2075
|
+
/** Runtime shell override for subagent execution. */
|
|
2076
|
+
subagentRunnerFactory?: TSubagentRunnerFactory;
|
|
2077
|
+
/** Optional command modules composed into this session. */
|
|
2078
|
+
commandModules?: readonly ICommandModule[];
|
|
2079
|
+
/** Host adapters available to composed command modules. */
|
|
2080
|
+
commandHostAdapters?: ICommandHostAdapters;
|
|
2081
|
+
/** Model-visible command descriptors derived from the composed command executor. */
|
|
2082
|
+
commandDescriptors?: readonly ICapabilityDescriptor[];
|
|
2083
|
+
/** Model command execution bridge. */
|
|
2084
|
+
modelCommandExecutor?: (command: string, args: string) => Promise<ICommandResult | null>;
|
|
2085
|
+
/** Predicate for commands allowed through the model command execution bridge. */
|
|
2086
|
+
isModelCommandInvocable?: (command: string) => boolean;
|
|
2087
|
+
/** Preloaded config to avoid duplicate discovery when caller needs it too. */
|
|
2088
|
+
config?: IResolvedConfig;
|
|
2089
|
+
/** Opt-in local-first reversible execution policy for write/shell tools. */
|
|
2090
|
+
reversibleExecution?: IReversibleExecutionOptions;
|
|
2091
|
+
/** Optional provider sandbox client used by sandbox-aware built-in tools. */
|
|
2092
|
+
sandboxClient?: ISandboxClient;
|
|
2093
|
+
/** Fresh-session workspace manifest applied through the sandbox client. */
|
|
2094
|
+
workspaceManifest?: IWorkspaceManifest;
|
|
2095
|
+
/** Sandbox target root for workspace manifest entries. Defaults to /workspace. */
|
|
2096
|
+
sandboxWorkspaceRoot?: string;
|
|
2097
|
+
/** Provider sandbox snapshot id to restore before replaying saved messages. */
|
|
2098
|
+
sandboxSnapshotId?: string;
|
|
2099
|
+
}
|
|
2100
|
+
/** Test/advanced construction: inject pre-built session directly. */
|
|
2101
|
+
interface IInteractiveSessionInjectedOptions {
|
|
2102
|
+
session: Session;
|
|
326
2103
|
cwd?: string;
|
|
2104
|
+
provider?: IAIProvider;
|
|
2105
|
+
permissionMode?: ICreateSessionOptions['permissionMode'];
|
|
2106
|
+
maxTurns?: number;
|
|
2107
|
+
permissionHandler?: TInteractivePermissionHandler;
|
|
2108
|
+
sessionStore?: IInteractiveSessionStore;
|
|
2109
|
+
sessionName?: string;
|
|
2110
|
+
resumeSessionId?: string;
|
|
2111
|
+
forkSession?: boolean;
|
|
2112
|
+
/** Optional command modules composed into this injected session. */
|
|
2113
|
+
commandModules?: readonly ICommandModule[];
|
|
2114
|
+
/** Host adapters available to composed command modules. */
|
|
2115
|
+
commandHostAdapters?: ICommandHostAdapters;
|
|
2116
|
+
}
|
|
2117
|
+
/** Union of standard and injected construction options. */
|
|
2118
|
+
type IInteractiveSessionOptions = IInteractiveSessionStandardOptions | IInteractiveSessionInjectedOptions;
|
|
2119
|
+
|
|
2120
|
+
/**
|
|
2121
|
+
* InteractiveSession — the single entry point for all SDK consumers.
|
|
2122
|
+
*
|
|
2123
|
+
* Wraps Session (composition). Manages streaming text accumulation,
|
|
2124
|
+
* tool execution state tracking, prompt queuing, abort orchestration,
|
|
2125
|
+
* message history, and system command execution.
|
|
2126
|
+
*
|
|
2127
|
+
* Config/context loading is internal. Consumer provides cwd + provider.
|
|
2128
|
+
*/
|
|
2129
|
+
|
|
2130
|
+
interface IInteractiveSessionShutdownOptions {
|
|
2131
|
+
reason?: TSessionEndReason;
|
|
2132
|
+
message?: string;
|
|
2133
|
+
}
|
|
2134
|
+
declare class InteractiveSession {
|
|
2135
|
+
private session;
|
|
2136
|
+
private readonly commandExecutor;
|
|
2137
|
+
private readonly listeners;
|
|
2138
|
+
private initialized;
|
|
2139
|
+
private initPromise;
|
|
2140
|
+
private streamingText;
|
|
2141
|
+
private flushTimer;
|
|
2142
|
+
private activeTools;
|
|
2143
|
+
private executing;
|
|
2144
|
+
private pendingPrompt;
|
|
2145
|
+
private pendingDisplayInput;
|
|
2146
|
+
private pendingRawInput;
|
|
2147
|
+
private history;
|
|
2148
|
+
private sessionStore?;
|
|
2149
|
+
private sessionName?;
|
|
2150
|
+
private cwd?;
|
|
2151
|
+
private pendingRestoreMessages;
|
|
2152
|
+
private backgroundTasks;
|
|
2153
|
+
private backgroundTaskEvents;
|
|
2154
|
+
private backgroundJobGroups;
|
|
2155
|
+
private backgroundJobGroupEvents;
|
|
2156
|
+
private memoryEvents;
|
|
2157
|
+
private usedMemoryReferences;
|
|
2158
|
+
private contextReferences;
|
|
2159
|
+
private editCheckpointStore;
|
|
2160
|
+
private resumeSessionId?;
|
|
2161
|
+
private forkSession;
|
|
2162
|
+
private backgroundTaskUnsubscribe;
|
|
2163
|
+
private backgroundJobUnsubscribe;
|
|
2164
|
+
private backgroundJobOrchestrator;
|
|
2165
|
+
private readonly commandModules;
|
|
2166
|
+
private readonly commandHostAdapters?;
|
|
2167
|
+
private readonly skillCommandSource;
|
|
2168
|
+
private skillActivationEvents;
|
|
2169
|
+
private autoCompactThresholdSource;
|
|
2170
|
+
private shuttingDown;
|
|
2171
|
+
private shutdownPromise;
|
|
2172
|
+
private readonly sandboxClient?;
|
|
2173
|
+
private sandboxSnapshotId?;
|
|
2174
|
+
private commandInvocationSource;
|
|
2175
|
+
constructor(options: IInteractiveSessionOptions);
|
|
2176
|
+
private configureInjectedSession;
|
|
2177
|
+
private restoreSessionRecordIfNeeded;
|
|
2178
|
+
private startAsyncInitializationIfNeeded;
|
|
2179
|
+
private initializeAsync;
|
|
2180
|
+
private ensureInitialized;
|
|
2181
|
+
private getSessionOrThrow;
|
|
2182
|
+
on<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
2183
|
+
off<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
2184
|
+
private emit;
|
|
2185
|
+
submit(input: string, displayInput?: string, rawInput?: string): Promise<void>;
|
|
2186
|
+
executeCommand(name: string, args: string): Promise<ICommandResult | null>;
|
|
2187
|
+
private executeCommandWithInvocationSource;
|
|
2188
|
+
executeModelCommand(name: string, args: string): Promise<ICommandResult | null>;
|
|
2189
|
+
getCommandInvocationSource(): TCommandInvocationSource;
|
|
2190
|
+
executeSkillCommandByName(name: string, args: string, request: ICommandSkillActivationRequest): Promise<ICommandResult | null>;
|
|
2191
|
+
private executeUserResolvedSkillCommand;
|
|
2192
|
+
listCommands(): Array<{
|
|
2193
|
+
name: string;
|
|
2194
|
+
description: string;
|
|
2195
|
+
}>;
|
|
2196
|
+
listSkills(): ICommandSkillListEntry[];
|
|
2197
|
+
listModelInvocableCommands(): Array<{
|
|
2198
|
+
name: string;
|
|
2199
|
+
description: string;
|
|
2200
|
+
}>;
|
|
2201
|
+
getSkillActivationEvents(): ISkillActivationEvent[];
|
|
2202
|
+
private findSkillCommand;
|
|
2203
|
+
abort(): void;
|
|
2204
|
+
shutdown(options?: IInteractiveSessionShutdownOptions): Promise<void>;
|
|
2205
|
+
cancelQueue(): void;
|
|
2206
|
+
private clearPendingQueue;
|
|
2207
|
+
isExecuting(): boolean;
|
|
2208
|
+
getPendingPrompt(): string | null;
|
|
2209
|
+
getFullHistory(): IHistoryEntry[];
|
|
2210
|
+
getMessages(): TUniversalMessage[];
|
|
2211
|
+
getStreamingText(): string;
|
|
2212
|
+
getActiveTools(): IToolState[];
|
|
2213
|
+
getContextState(): IContextWindowState;
|
|
2214
|
+
getAutoCompactThreshold(): number | false;
|
|
2215
|
+
getAutoCompactThresholdSource(): TAutoCompactThresholdSource;
|
|
2216
|
+
setAutoCompactThreshold(threshold: TAutoCompactThreshold$1, source?: TAutoCompactThresholdSource): void;
|
|
2217
|
+
getCommandHostAdapters(): ICommandHostAdapters;
|
|
2218
|
+
clearConversationHistory(): void;
|
|
2219
|
+
compactContext(instructions?: string): Promise<void>;
|
|
2220
|
+
getName(): string | undefined;
|
|
2221
|
+
getCwd(): string;
|
|
2222
|
+
getSession(): Session;
|
|
2223
|
+
listEditCheckpoints(): IEditCheckpointSummary[];
|
|
2224
|
+
inspectEditCheckpoint(checkpointId: string): IEditCheckpointInspection;
|
|
2225
|
+
restoreEditCheckpoint(checkpointId: string): Promise<IEditCheckpointRestoreResult>;
|
|
2226
|
+
rollbackEditCheckpoint(checkpointId: string): Promise<IEditCheckpointRestoreResult>;
|
|
2227
|
+
getUsedMemoryReferences(): IMemoryReference[];
|
|
2228
|
+
recordMemoryEvent(event: IMemoryEvent): void;
|
|
2229
|
+
listContextReferences(): IContextReferenceItem[];
|
|
2230
|
+
addContextReference(path: string): Promise<IContextReferenceAddResult>;
|
|
2231
|
+
removeContextReference(path: string): IContextReferenceRemoveResult;
|
|
2232
|
+
clearContextReferences(): IContextReferenceClearResult;
|
|
2233
|
+
listBackgroundTasks(filter?: IBackgroundTaskListFilter): IBackgroundTaskState[];
|
|
2234
|
+
getBackgroundTask(taskId: string): IBackgroundTaskState | undefined;
|
|
2235
|
+
cancelBackgroundTask(taskId: string, reason?: string): Promise<void>;
|
|
2236
|
+
closeBackgroundTask(taskId: string): Promise<void>;
|
|
2237
|
+
sendBackgroundTask(taskId: string, input: IBackgroundTaskInput): Promise<void>;
|
|
2238
|
+
readBackgroundTaskLog(taskId: string, cursor?: IBackgroundTaskLogCursor): Promise<IBackgroundTaskLogPage>;
|
|
2239
|
+
createBackgroundJobGroup(input: Omit<IBackgroundJobGroupCreateRequest, 'parentSessionId'>): IBackgroundJobGroupState;
|
|
2240
|
+
listBackgroundJobGroups(): IBackgroundJobGroupState[];
|
|
2241
|
+
getBackgroundJobGroup(groupId: string): IBackgroundJobGroupState | undefined;
|
|
2242
|
+
waitBackgroundJobGroup(groupId: string): Promise<IBackgroundJobGroupState>;
|
|
2243
|
+
listAgentDefinitions(): Array<{
|
|
2244
|
+
name: string;
|
|
2245
|
+
description: string;
|
|
2246
|
+
}>;
|
|
2247
|
+
listAgentJobs(): ISubagentJobState[];
|
|
2248
|
+
spawnAgentJob(input: {
|
|
2249
|
+
agentType: string;
|
|
2250
|
+
label: string;
|
|
2251
|
+
mode: 'foreground' | 'background';
|
|
2252
|
+
prompt: string;
|
|
2253
|
+
model?: string;
|
|
2254
|
+
isolation?: TBackgroundTaskIsolation;
|
|
2255
|
+
}): Promise<ISubagentJobState>;
|
|
2256
|
+
waitAgentJob(jobId: string): Promise<ISubagentJobResult>;
|
|
2257
|
+
sendAgentJob(jobId: string, prompt: string): Promise<void>;
|
|
2258
|
+
cancelAgentJob(jobId: string, reason?: string): Promise<void>;
|
|
2259
|
+
closeAgentJob(jobId: string): Promise<void>;
|
|
2260
|
+
setName(name: string): void;
|
|
2261
|
+
attachTransport(transport: ITransportAdapter): void;
|
|
2262
|
+
private executeSkillWithActivation;
|
|
2263
|
+
private recordSkillActivation;
|
|
2264
|
+
private recordSkillActivationEvent;
|
|
2265
|
+
private executeForkSkillCommand;
|
|
2266
|
+
private getBackgroundTaskManagerOrThrow;
|
|
2267
|
+
private getBackgroundTaskManager;
|
|
2268
|
+
private getBackgroundJobOrchestratorOrThrow;
|
|
2269
|
+
private getAgentToolDepsOrThrow;
|
|
2270
|
+
private getSubagentManagerOrThrow;
|
|
2271
|
+
private resolveAgentDefinition;
|
|
2272
|
+
private subscribeBackgroundTaskEvents;
|
|
2273
|
+
private subscribeBackgroundJobGroupEvents;
|
|
2274
|
+
private recordBackgroundTaskEvent;
|
|
2275
|
+
private recordBackgroundJobGroupEvent;
|
|
2276
|
+
private getBackgroundTaskSnapshots;
|
|
2277
|
+
private getBackgroundJobGroupSnapshots;
|
|
2278
|
+
private persistCurrentSession;
|
|
2279
|
+
private captureSandboxSnapshot;
|
|
2280
|
+
private startForkSkillExecution;
|
|
2281
|
+
private finishForkSkillExecution;
|
|
2282
|
+
private recordForkSkillError;
|
|
2283
|
+
private resolveForkAgentDefinition;
|
|
2284
|
+
private runSkillInFork;
|
|
2285
|
+
private applyForkSkillResult;
|
|
2286
|
+
private executeForegroundCommand;
|
|
2287
|
+
private executePrompt;
|
|
2288
|
+
private recordContextReferenceUsage;
|
|
2289
|
+
private recordPromptContextReferences;
|
|
2290
|
+
private getEditCheckpointStore;
|
|
2291
|
+
private beginEditCheckpointTurn;
|
|
2292
|
+
private finalizeEditCheckpointTurn;
|
|
2293
|
+
private handleTextDelta;
|
|
2294
|
+
private handleCompactEvent;
|
|
2295
|
+
private handleToolExecution;
|
|
2296
|
+
private clearStreaming;
|
|
2297
|
+
private flushStreaming;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
/**
|
|
2301
|
+
* createQuery() — factory that returns a prompt-only convenience function.
|
|
2302
|
+
*
|
|
2303
|
+
* Usage:
|
|
2304
|
+
* const query = createQuery({ provider });
|
|
2305
|
+
* const answer = await query('What files are here?');
|
|
2306
|
+
*/
|
|
2307
|
+
|
|
2308
|
+
interface ICreateQueryOptions {
|
|
2309
|
+
/** AI provider instance (required). */
|
|
2310
|
+
provider: IAIProvider;
|
|
2311
|
+
/** Working directory. Defaults to process.cwd(). */
|
|
2312
|
+
cwd?: string;
|
|
2313
|
+
/** Permission mode. Defaults to 'bypassPermissions' for programmatic use. */
|
|
327
2314
|
permissionMode?: TPermissionMode;
|
|
2315
|
+
/** Maximum agentic turns per query. */
|
|
328
2316
|
maxTurns?: number;
|
|
329
|
-
|
|
330
|
-
permissionHandler?:
|
|
2317
|
+
/** Permission handler callback. */
|
|
2318
|
+
permissionHandler?: TInteractivePermissionHandler;
|
|
2319
|
+
/** Streaming text callback. */
|
|
331
2320
|
onTextDelta?: (delta: string) => void;
|
|
332
|
-
/** Callback when context is compacted */
|
|
333
|
-
onCompact?: (summary: string) => void;
|
|
334
2321
|
}
|
|
335
2322
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
2323
|
+
* Create a prompt-only query function bound to a provider.
|
|
2324
|
+
*
|
|
2325
|
+
* ```typescript
|
|
2326
|
+
* import { createQuery } from '@robota-sdk/agent-sdk';
|
|
2327
|
+
* import { AnthropicProvider } from '@robota-sdk/agent-provider-anthropic';
|
|
2328
|
+
*
|
|
2329
|
+
* const query = createQuery({ provider: new AnthropicProvider({ apiKey: '...' }) });
|
|
2330
|
+
* const answer = await query('List all TypeScript files');
|
|
2331
|
+
* ```
|
|
339
2332
|
*/
|
|
340
|
-
declare function
|
|
2333
|
+
declare function createQuery(options: ICreateQueryOptions): (prompt: string) => Promise<string>;
|
|
2334
|
+
|
|
2335
|
+
type TSelfHostingVerificationPhase = 'checkpoint' | 'edit' | 'handoff' | 'verify' | 'recover';
|
|
2336
|
+
type TSelfHostingLoopState = 'idle' | 'checkpointed' | 'editing' | 'verifying' | 'passed' | 'failed' | 'rolled_back' | 'cancelled';
|
|
2337
|
+
type TSelfHostingLoopEvent = 'checkpoint_created' | 'edits_started' | 'edits_applied' | 'verify_passed' | 'verify_failed' | 'rollback_completed' | 'cancelled';
|
|
2338
|
+
interface ISelfHostingVerificationPlanInput {
|
|
2339
|
+
changedFiles: readonly string[];
|
|
2340
|
+
packageScopes?: readonly string[];
|
|
2341
|
+
baseRef?: string;
|
|
2342
|
+
}
|
|
2343
|
+
interface ISelfHostingVerificationStep {
|
|
2344
|
+
id: string;
|
|
2345
|
+
phase: TSelfHostingVerificationPhase;
|
|
2346
|
+
description: string;
|
|
2347
|
+
required: boolean;
|
|
2348
|
+
command?: string;
|
|
2349
|
+
}
|
|
2350
|
+
interface ISelfHostingVerificationPlan {
|
|
2351
|
+
changedFiles: readonly string[];
|
|
2352
|
+
packageScopes: readonly string[];
|
|
2353
|
+
baseRef: string;
|
|
2354
|
+
steps: readonly ISelfHostingVerificationStep[];
|
|
2355
|
+
}
|
|
2356
|
+
declare function planSelfHostingVerification(input: ISelfHostingVerificationPlanInput): ISelfHostingVerificationPlan;
|
|
2357
|
+
declare function transitionSelfHostingLoop(state: TSelfHostingLoopState, event: TSelfHostingLoopEvent): TSelfHostingLoopState;
|
|
341
2358
|
|
|
342
2359
|
/**
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
|
|
2360
|
+
* All built-in agent definitions shipped with the SDK.
|
|
2361
|
+
* Order matters: general-purpose is the default fallback.
|
|
2362
|
+
*/
|
|
2363
|
+
declare const BUILT_IN_AGENTS: IAgentDefinition[];
|
|
2364
|
+
/**
|
|
2365
|
+
* Look up a built-in agent definition by name.
|
|
2366
|
+
* Returns `undefined` if no built-in agent matches.
|
|
346
2367
|
*/
|
|
347
|
-
declare function
|
|
2368
|
+
declare function getBuiltInAgent(name: string): IAgentDefinition | undefined;
|
|
348
2369
|
|
|
349
2370
|
/**
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
2371
|
+
* AgentTool — spawn a sub-agent with isolated context.
|
|
2372
|
+
*
|
|
2373
|
+
* Uses `SubagentManager` with an in-process runner to assemble a child Session
|
|
2374
|
+
* with filtered tools, model resolution, and framework system prompt. The
|
|
2375
|
+
* sub-agent shares the same config and context but has its own conversation
|
|
2376
|
+
* history.
|
|
2377
|
+
*
|
|
2378
|
+
* Each call to `createAgentTool(deps)` returns a fresh tool instance with deps
|
|
2379
|
+
* captured in closure, eliminating module-level mutable state and enabling
|
|
2380
|
+
* multiple concurrent sessions without race conditions.
|
|
353
2381
|
*/
|
|
354
2382
|
|
|
2383
|
+
/** Dependencies injected at creation time via createAgentTool factory */
|
|
2384
|
+
interface IAgentToolDeps extends IInProcessSubagentRunnerDeps {
|
|
2385
|
+
cwd?: string;
|
|
2386
|
+
parentSessionId?: string;
|
|
2387
|
+
subagentDepth?: number;
|
|
2388
|
+
subagentManager?: ISubagentManager;
|
|
2389
|
+
backgroundTaskManager?: IBackgroundTaskManager;
|
|
2390
|
+
/** Optional custom agent registry for resolving non-built-in agent types. */
|
|
2391
|
+
customAgentRegistry?: (name: string) => IAgentDefinition | undefined;
|
|
2392
|
+
/** Model-visible and command-visible agent definitions available to this session. */
|
|
2393
|
+
agentDefinitions?: IAgentDefinition[];
|
|
2394
|
+
}
|
|
2395
|
+
/** Store agent tool deps keyed by a session (or any object). */
|
|
2396
|
+
declare function storeAgentToolDeps(key: object, deps: IAgentToolDeps): void;
|
|
2397
|
+
/** Retrieve agent tool deps for a given session key. */
|
|
2398
|
+
declare function retrieveAgentToolDeps(key: object): IAgentToolDeps | undefined;
|
|
355
2399
|
/**
|
|
356
|
-
*
|
|
2400
|
+
* Create an agent tool instance with deps captured in closure.
|
|
2401
|
+
*
|
|
2402
|
+
* Each session gets its own tool instance — no shared mutable state.
|
|
357
2403
|
*/
|
|
358
|
-
declare function
|
|
2404
|
+
declare function createAgentTool(deps: IAgentToolDeps): ReturnType<typeof createZodFunctionTool>;
|
|
2405
|
+
|
|
2406
|
+
type TModelCommandDescriptor$1 = Pick<ICapabilityDescriptor, 'name' | 'description' | 'argumentHint'>;
|
|
2407
|
+
interface ICommandExecutionToolDeps {
|
|
2408
|
+
isModelInvocable: (command: string) => boolean;
|
|
2409
|
+
execute: (command: string, args: string) => Promise<ICommandResult | null>;
|
|
2410
|
+
commandNames?: readonly string[];
|
|
2411
|
+
commandDescriptors?: readonly TModelCommandDescriptor$1[];
|
|
2412
|
+
}
|
|
2413
|
+
declare function createCommandExecutionTool(deps: ICommandExecutionToolDeps): ReturnType<typeof createZodFunctionTool>;
|
|
2414
|
+
|
|
2415
|
+
declare const MODEL_COMMAND_TOOL_PREFIX: "robota_command_";
|
|
2416
|
+
declare const PROVIDER_SAFE_TOOL_NAME_PATTERN: RegExp;
|
|
2417
|
+
type TModelCommandDescriptor = Pick<ICapabilityDescriptor, 'name' | 'description' | 'argumentHint'>;
|
|
2418
|
+
interface IProjectedModelCommandTool {
|
|
2419
|
+
readonly commandName: string;
|
|
2420
|
+
readonly toolName: string;
|
|
2421
|
+
readonly description: string;
|
|
2422
|
+
readonly descriptor: TModelCommandDescriptor;
|
|
2423
|
+
}
|
|
2424
|
+
interface IModelCommandToolProjection {
|
|
2425
|
+
readonly commandTools: readonly IProjectedModelCommandTool[];
|
|
2426
|
+
readonly toolNameToCommandName: ReadonlyMap<string, string>;
|
|
2427
|
+
readonly commandNameToToolName: ReadonlyMap<string, string>;
|
|
2428
|
+
}
|
|
2429
|
+
interface IProjectedCommandExecutionToolsDeps {
|
|
2430
|
+
isModelInvocable: (command: string) => boolean;
|
|
2431
|
+
execute: (command: string, args: string) => Promise<ICommandResult | null>;
|
|
2432
|
+
commandDescriptors: readonly TModelCommandDescriptor[];
|
|
2433
|
+
}
|
|
2434
|
+
declare function normalizeModelCommandName(command: string): string;
|
|
2435
|
+
declare function createProviderSafeModelCommandToolName(commandName: string): string;
|
|
2436
|
+
declare function createModelCommandToolProjection(commandDescriptors: readonly TModelCommandDescriptor[]): IModelCommandToolProjection;
|
|
2437
|
+
declare function formatProjectedModelCommandToolPromptDescription(projection: IProjectedModelCommandTool): string;
|
|
2438
|
+
declare function createProjectedCommandExecutionTools(deps: IProjectedCommandExecutionToolsDeps): Array<ReturnType<typeof createZodFunctionTool>>;
|
|
2439
|
+
|
|
2440
|
+
interface IBackgroundProcessToolDeps {
|
|
2441
|
+
backgroundTaskManager: IBackgroundTaskManager;
|
|
2442
|
+
cwd?: string;
|
|
2443
|
+
parentSessionId?: string;
|
|
2444
|
+
}
|
|
2445
|
+
declare function createBackgroundProcessTool(deps: IBackgroundProcessToolDeps): ReturnType<typeof createZodFunctionTool>;
|
|
359
2446
|
|
|
360
2447
|
/**
|
|
361
2448
|
* Standard Robota storage paths.
|
|
@@ -369,6 +2456,8 @@ declare function projectPaths(cwd: string): {
|
|
|
369
2456
|
settingsLocal: string;
|
|
370
2457
|
logs: string;
|
|
371
2458
|
sessions: string;
|
|
2459
|
+
memory: string;
|
|
2460
|
+
checkpoints: string;
|
|
372
2461
|
};
|
|
373
2462
|
/** User-level ~/.robota/ paths. */
|
|
374
2463
|
declare function userPaths(): {
|
|
@@ -376,14 +2465,42 @@ declare function userPaths(): {
|
|
|
376
2465
|
sessions: string;
|
|
377
2466
|
};
|
|
378
2467
|
|
|
379
|
-
|
|
380
|
-
interface
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
2468
|
+
type TTaskFileStatus = 'todo' | 'in-progress' | 'blocked' | 'completed' | 'unknown';
|
|
2469
|
+
interface ITaskContextFile {
|
|
2470
|
+
path: string;
|
|
2471
|
+
relativePath: string;
|
|
2472
|
+
title: string;
|
|
2473
|
+
status: TTaskFileStatus;
|
|
2474
|
+
branch?: string;
|
|
2475
|
+
scope?: string;
|
|
2476
|
+
objective?: string;
|
|
2477
|
+
openItems: readonly string[];
|
|
2478
|
+
}
|
|
2479
|
+
interface ITaskSelectionOptions {
|
|
2480
|
+
currentBranch?: string;
|
|
2481
|
+
maxTasks?: number;
|
|
384
2482
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
2483
|
+
interface IUpdateTaskFileStatusOptions {
|
|
2484
|
+
now?: Date;
|
|
2485
|
+
progressMessage?: string;
|
|
2486
|
+
}
|
|
2487
|
+
declare function readCurrentGitBranch(cwd: string): string | undefined;
|
|
2488
|
+
declare function discoverTaskFiles(cwd: string): string[];
|
|
2489
|
+
declare function parseTaskFile(taskPath: string, cwd: string): ITaskContextFile;
|
|
2490
|
+
declare function selectRelevantTasks(tasks: readonly ITaskContextFile[], options?: ITaskSelectionOptions): ITaskContextFile[];
|
|
2491
|
+
declare function formatTaskContext(tasks: readonly ITaskContextFile[]): string;
|
|
2492
|
+
declare function loadTaskContext(cwd: string, options?: ITaskSelectionOptions): string;
|
|
2493
|
+
declare function updateTaskFileStatus(taskPath: string, status: TTaskFileStatus, options?: IUpdateTaskFileStatusOptions): void;
|
|
2494
|
+
|
|
2495
|
+
/**
|
|
2496
|
+
* Interactive permission prompt — asks the user whether to allow a tool invocation
|
|
2497
|
+
* using an arrow-key selector. Canonical implementation (SSOT).
|
|
2498
|
+
* Used by both agent-sdk query() and agent-cli.
|
|
2499
|
+
*/
|
|
2500
|
+
|
|
2501
|
+
/**
|
|
2502
|
+
* Prompt the user for approval before running a tool.
|
|
2503
|
+
*/
|
|
2504
|
+
declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
|
|
388
2505
|
|
|
389
|
-
export { DEFAULT_TOOL_DESCRIPTIONS, type ICreateSessionOptions, type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, createDefaultTools, createProvider, createSession, detectProject, loadConfig, loadContext, projectPaths, promptForApproval, query, setAgentToolDeps, userPaths };
|
|
2506
|
+
export { AUTO_COMPACT_THRESHOLD_SETTINGS_KEY, AgentExecutor, BACKGROUND_COMMAND_DESCRIPTION, BACKGROUND_COMMAND_USAGE, BUILT_IN_AGENTS, BackgroundJobOrchestrator, BuiltinCommandSource, BundlePluginInstaller, BundlePluginLoader, CLEAR_COMMAND_DESCRIPTION, COST_COMMAND_DESCRIPTION, CommandRegistry, DEFAULT_AUTO_COMPACT_THRESHOLD, DEFAULT_STATUS_LINE_COMMAND_SETTINGS, EXIT_COMMAND_DESCRIPTION, EditCheckpointStore, HELP_COMMAND_DESCRIPTION, type IActiveProviderModelCatalogState, type IAgentDefinition, type IAgentExecutorOptions, type IAgentSession, type IAgentToolDeps, type IAppendMemoryInput, type IAppendMemoryResult, type IBackgroundJobGroupCreateRequest, type IBackgroundJobGroupState, type IBackgroundJobGroupSummary, type IBackgroundJobOrchestratorOptions, type IBackgroundJobResultEnvelope, type IBackgroundProcessToolDeps, type IBuildModelCommandSubcommandsOptions, type IBundlePluginFeatures, type IBundlePluginInstallerOptions, type IBundlePluginManifest, type IBundleSkill, type ICapabilityDescriptor, type ICommand, type ICommandAvailablePlugin, type ICommandChoicePromptOption, type ICommandExecutionToolDeps, type ICommandHostAdapters, type ICommandHostContext, type ICommandInstalledPlugin, type ICommandInteraction, type ICommandListEntry, type ICommandMarketplaceSource, type ICommandMemoryStores, type ICommandModule, type ICommandPendingMemoryStore, type ICommandPermissionModeAdapter, type ICommandPickerAdapter, type ICommandPluginAdapter, type ICommandPluginReloadResult, type ICommandProcessAdapter, type ICommandProjectMemoryStore, type ICommandResult, type ICommandSessionInfo, type ICommandSessionReplayValidationReport, type ICommandSessionRuntime, type ICommandSettingsAdapter, type ICommandSettingsDocument, type ICommandSkillListEntry, type ICommandSource, type ICompactContextResult, type IContextReferenceAddResult, type IContextReferenceClearResult, type IContextReferenceInventoryLimits, type IContextReferenceItem, type IContextReferenceRemoveResult, type IContextReferenceUpsertResult, type ICreateQueryOptions, type IDiffLine, type IEditCheckpointFileInspection, type IEditCheckpointFileRecord, type IEditCheckpointInspection, type IEditCheckpointInspectionPlan, type IEditCheckpointManifest, type IEditCheckpointRecorder, type IEditCheckpointRestoreResult, type IEditCheckpointSummary, type IEditCheckpointTurnInput, type IExecutionResult, type IForkExecutionOptions, type IInProcessSubagentRunnerDeps, type IInstalledPluginRecord, type IInstalledPluginsRegistry, type IInteractiveSessionEvents, type IInteractiveSessionOptions, type IInteractiveSessionRecord, type IInteractiveSessionShutdownOptions, type IInteractiveSessionStore, type IKnownMarketplaceEntry, type IKnownMarketplacesRegistry, type ILegacyProviderSettings, type ILoadedBundlePlugin, type IMarketplaceClientOptions, type IMarketplaceManifest, type IMarketplacePluginEntry, type IMarketplaceSource, type IMemoryCandidate, type IMemoryEvent, type IMemoryPendingRecord, type IMemoryReference, type IModelCommandModuleOptions, type IModelCommandSettingsAdapter, type IModelCommandToolProjection, type IPermissionsCommandState, type IPluginSettings, type IProjectMemorySummary, type IProjectedCommandExecutionToolsDeps, type IProjectedModelCommandTool, type IPromptExecutorOptions, type IPromptFileReferenceDiagnostic, type IPromptFileReferenceHistoryData, type IPromptFileReferenceLimits, type IPromptFileReferenceRecord, type IPromptFileReferenceResolveOptions, type IPromptFileReferenceToken, type IPromptProvider, type IProviderCommandModuleOptions, type IProviderCommandSettingsAdapter, type IProviderProfileNameSuggestionInput, type IProviderProfileNameSuggestionOptions, type IProviderProfileSettings, type IProviderSettingsBuildOptions, type IProviderSetupFlowOptions, type IProviderSetupFlowState, type IProviderSetupInput, type IProviderSetupPatch, type IProviderSetupPromptStep, type IResolveActiveProviderModelCatalogStateOptions, type IResolvedPromptFileReference, type IResolvedPromptFileReferences, type IResumableSessionSummary, type IReversibleExecutionOptions, type IReversibleToolSafetyContext, type IReversibleToolSafetyInput, type IReversibleToolSafetyReport, type ISelfHostingVerificationPlan, type ISelfHostingVerificationPlanInput, type ISelfHostingVerificationStep, type ISkillActivationEvent, type ISkillActivationHistoryData, type ISkillExecutionCallbacks, type ISkillExecutionResult, type IStartupMemory, type IStatusLineCommandSettings, type ISubagentOptions, type ISubagentPromptOptions, type ISystemCommand, type ITaskContextFile, type ITaskSelectionOptions, type IToolState, type IToolSummary, type ITransportAdapter, type IUpdateTaskFileStatusOptions, type IUsageSnapshot, InteractiveSession, LANGUAGE_COMMAND_ARGUMENT_HINT, LANGUAGE_COMMAND_DESCRIPTION, MEMORY_COMMAND_ARGUMENT_HINT, MEMORY_COMMAND_DESCRIPTION, MEMORY_COMMAND_USAGE, MEMORY_INDEX_MAX_BYTES, MEMORY_INDEX_MAX_LINES, MODEL_COMMAND_ARGUMENT_HINT, MODEL_COMMAND_DESCRIPTION, MODEL_COMMAND_TOOL_PREFIX, MarketplaceClient, PERMISSIONS_COMMAND_DESCRIPTION, PERMISSION_MODE_ARGUMENT_HINT, PERMISSION_MODE_COMMAND_DESCRIPTION, PLUGIN_COMMAND_ARGUMENT_HINT, PLUGIN_COMMAND_DESCRIPTION, PROVIDER_SAFE_TOOL_NAME_PATTERN, PluginCommandSource, PluginSettingsStore, ProjectMemoryStore, PromptExecutor, RECOMMENDED_RESPONSE_LANGUAGES, RELOAD_PLUGINS_COMMAND_DESCRIPTION, RENAME_COMMAND_DESCRIPTION, RENAME_COMMAND_USAGE, RESUME_COMMAND_DESCRIPTION, REWIND_COMMAND_ARGUMENT_HINT, REWIND_COMMAND_DESCRIPTION, STATUSLINE_COMMAND_ARGUMENT_HINT, STATUSLINE_COMMAND_DESCRIPTION, SkillCommandSource, type SkillPromptContext, SystemCommandExecutor, type TAutoCompactThreshold$1 as TAutoCompactThreshold, type TAutoCompactThresholdSource, type TBackgroundJobGroupEvent, type TBackgroundJobGroupEventListener, type TBackgroundJobGroupIdFactory, type TBackgroundJobGroupStatus, type TBackgroundJobWaitPolicy, type TCapabilityKind, type TCapabilitySafety, type TCommandEffect, type TCommandInteractionPrompt, type TCommandModuleSessionRequirement, type TCommandResultDataValue, type TContextReferenceLoadType, type TContextReferenceStatus, type TEditCheckpointFileRestoreAction, type TEnabledPlugins, type TInteractiveEventName, type TInteractivePermissionHandler, type TMemoryCandidateStatus, type TMemoryType, type TPermissionResultValue, type TPluginInstallScope, type TPromptFileReferenceDiagnosticCode, type TPromptFileReferenceReason, type TPromptInput, type TProviderFactory, type TProviderSettingsDocument, type TProviderSetupFlowSubmitResult, type TProviderSetupType, type TRecommendedResponseLanguage, type TReversibleExecutionIsolation, type TReversibleRollbackLayer, type TReversibleSafetyStatus, type TReversibleSideEffect, type TSelfHostingLoopEvent, type TSelfHostingLoopState, type TSelfHostingVerificationPhase, type TSessionFactory, type TSkillActivationInvocation, type TSkillActivationMode, type TSkillActivationSource, type TSkillActivationStatus, type TStatusLineCommandSettingsPatch, type TSubagentRunnerFactory, type TSystemCommandLifecycle, type TTaskFileStatus, VALIDATE_SESSION_COMMAND_DESCRIPTION, VALID_PERMISSION_MODES, addCommandContextReference, assembleSubagentPrompt, buildBackgroundCommandSubcommands, buildLanguageCommandSubcommands, buildMemoryCommandSubcommands, buildModelCommandSubcommands, buildPermissionModeSubcommands, buildPluginCommandSubcommands, buildPromptWithFileReferences, buildProviderProfile, buildProviderSetupPatch, buildRewindCommandSubcommands, buildStatusLineCommandSubcommands, cancelCommandBackgroundTask, clearCommandContextReferences, clearContextReferences, clearConversationHistory, closeCommandBackgroundTask, compactCommandContext, createAgentTool, createBackgroundProcessTool, createBuiltinCommandModule, createCommandExecutionTool, createCommandMemoryStores, createCommandPendingMemoryStore, createCommandProjectMemoryStore, createContextReferenceItem, createDefaultTools, createModelCommandToolProjection, createPluginRegistryReloadRequestedEffect, createPluginTuiRequestedEffect, createProjectSessionStore, createProjectedCommandExecutionTools, createPromptFileReferenceHistoryEntry, createProviderSafeModelCommandToolName, createProviderSetupFlow, createQuery, createSessionExitRequestedEffect, createSessionPickerRequestedEffect, createSessionRenamedEffect, createSubagentLogger, createSubagentSession, createSystemCommands, deleteProviderProfile, discoverTaskFiles, evaluateReversibleToolSafety, executeSkill, formatCommandBackgroundTask, formatCommandBackgroundTaskList, formatCommandHelpMessage, formatCommandPermissionsMessage, formatCommandSessionReplayValidationReport, formatEnvReference, formatInvalidPermissionModeMessage, formatLanguageUsageMessage, formatModelCommandUsageMessage, formatModelCommandUsageMessageAsync, formatProjectedModelCommandToolPromptDescription, formatPromptFileReferenceDiagnostics, formatProviderSetupChoiceLabel, formatProviderSetupHelpLinks, formatProviderSetupPromptLabel, formatProviderSetupSelectionPrompt, formatTaskContext, getBuiltInAgent, getForkWorkerSuffix, getProviderSetupStep, getSubagentSuffix, hasBlockingPromptFileReferenceDiagnostics, hasSensitiveCommandMemoryContent, hasUsableSecretReference, inspectCommandEditCheckpoint, isCommandMemoryType, isEnvReference, isMemoryType, isPermissionMode, isStatusLineCommandSettingsPatch, listActiveContextReferences, listCommandBackgroundTasks, listCommandContextReferences, listCommandEditCheckpoints, listCommandSessionAllowedTools, listCommandUsedMemoryReferences, listResumableSessionSummaries, loadTaskContext, mergeProviderPatch, normalizeModelCommandName, parseCommandBackgroundLogCursor, parseFrontmatter, parseLanguageArgument, parsePermissionModeArgument, parsePromptFileReferences, parseSessionNameArgument, parseTaskFile, planSelfHostingVerification, preprocessShellCommands, probeProviderProfile, projectPaths, promptForApproval, readAutoCompactThreshold, readAutoCompactThresholdSource, readCommandBackgroundTaskLog, readCommandContextState, readCommandPermissionMode, readCommandPermissionsState, readCommandSessionInfo, readCurrentGitBranch, recordCommandMemoryEvent, removeCommandContextReference, removeContextReference, resetAutoCompactThresholdSetting, resolveActiveProviderModelCatalog, resolveActiveProviderModelCatalogState, resolveEnvReference, resolveLatestSessionId, resolvePermissionModeAdapter, resolvePluginCommandAdapter, resolvePromptFileReferencePaths, resolvePromptFileReferences, resolveProviderSetupSelection, resolveSessionIdByIdOrName, resolveSubagentLogDir, restoreCommandEditCheckpoint, retrieveAgentToolDeps, rollbackCommandEditCheckpoint, runProviderSetupPromptFlow, sanitizeProviderProfileName, selectRelevantTasks, setCommandAutoCompactThreshold, setCurrentProvider, storeAgentToolDeps, submitProviderSetupValue, substituteVariables, suggestProviderProfileName, summarizeBackgroundJobGroup, testProviderProfileCommand, toContextReferenceRecords, toPromptFileReferenceRecords, transitionSelfHostingLoop, updateTaskFileStatus, upsertContextReference, upsertProviderProfile, userPaths, validateCommandSessionReplayLog, validateProviderProfile, validateProviderSetupValue, wrapEditCheckpointTools, wrapReversibleExecutionTools, writeAutoCompactThresholdSetting, writeCommandPermissionMode };
|