@robota-sdk/agent-sdk 3.0.0-beta.53 → 3.0.0-beta.55
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 +34 -16
- package/dist/node/index.cjs +2552 -1184
- package/dist/node/index.d.cts +1286 -952
- package/dist/node/index.d.ts +1286 -952
- package/dist/node/index.js +2530 -1172
- package/package.json +7 -4
package/dist/node/index.d.ts
CHANGED
|
@@ -1,1066 +1,1399 @@
|
|
|
1
|
-
import { ITerminalOutput,
|
|
1
|
+
import { ITerminalOutput, ISessionLogger, TPermissionHandler, Session, SessionStore, FileSessionLogger } from '@robota-sdk/agent-sessions';
|
|
2
2
|
export { ISpinner, ITerminalOutput } from '@robota-sdk/agent-sessions';
|
|
3
|
-
import { TToolArgs, IHistoryEntry, IContextWindowState,
|
|
3
|
+
import { TToolArgs, IHistoryEntry, IContextWindowState, THooksConfig, IToolWithEventService, IAIProvider, TPermissionMode, IHookTypeExecutor, IHookDefinition, IHookInput, IHookResult, TTrustLevel, TSessionEndReason, TUniversalMessage } from '@robota-sdk/agent-core';
|
|
4
4
|
export { IAIProvider, IContextTokenUsage, IContextWindowState, IHistoryEntry, IHookInput, IPermissionLists, THookEvent, THooksConfig, TPermissionDecision, TPermissionMode, TRUST_TO_MODE, TToolArgs, TTrustLevel, chatEntryToMessage, evaluatePermission, getMessagesForAPI, isChatEntry, messageToHistoryEntry, runHooks } from '@robota-sdk/agent-core';
|
|
5
|
+
import { IBackgroundTaskManager, TBackgroundTaskStatus, IBackgroundTaskError, TBackgroundTaskEvent, ISubagentRunner, IBackgroundTaskRunner, IBackgroundTaskListFilter, IBackgroundTaskState, IBackgroundTaskInput, IBackgroundTaskLogCursor, IBackgroundTaskLogPage, ISubagentJobState, TBackgroundTaskIsolation, ISubagentJobResult, ISubagentManager } from '@robota-sdk/agent-runtime';
|
|
6
|
+
export { BackgroundTaskError, BackgroundTaskManager, IAgentBackgroundTaskRequest, IBackgroundTaskError, IBackgroundTaskHandle, IBackgroundTaskInput, IBackgroundTaskListFilter, IBackgroundTaskLogCursor, IBackgroundTaskLogPage, IBackgroundTaskManager, IBackgroundTaskManagerOptions, IBackgroundTaskRequest, IBackgroundTaskResult, IBackgroundTaskRunner, IBackgroundTaskStart, IBackgroundTaskState, IBaseBackgroundTaskRequest, 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, createWorktreeSubagentRunner, getBackgroundTaskTransitions, isTerminalBackgroundTaskStatus, transitionBackgroundTaskStatus } from '@robota-sdk/agent-runtime';
|
|
5
7
|
import { createZodFunctionTool } from '@robota-sdk/agent-tools';
|
|
6
8
|
export { TToolResult } from '@robota-sdk/agent-tools';
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** Permission handler result — SDK-owned type (mirrors agent-sessions TPermissionResult).
|
|
13
|
-
* true = allow, false = deny, 'allow-session' = allow and remember for this session. */
|
|
14
|
-
type TPermissionResultValue = boolean | 'allow-session';
|
|
15
|
-
/** Tool execution state visible to clients. */
|
|
16
|
-
interface IToolState {
|
|
17
|
-
toolName: string;
|
|
18
|
-
firstArg: string;
|
|
19
|
-
isRunning: boolean;
|
|
20
|
-
result?: 'success' | 'error' | 'denied';
|
|
21
|
-
diffLines?: IDiffLine[];
|
|
22
|
-
diffFile?: string;
|
|
23
|
-
}
|
|
24
|
-
/** A single diff line for Edit tool display. */
|
|
25
|
-
interface IDiffLine {
|
|
26
|
-
type: 'add' | 'remove' | 'context';
|
|
27
|
-
text: string;
|
|
28
|
-
lineNumber: number;
|
|
29
|
-
}
|
|
30
|
-
/** Result of a completed prompt execution. */
|
|
31
|
-
interface IExecutionResult {
|
|
32
|
-
response: string;
|
|
33
|
-
history: IHistoryEntry[];
|
|
34
|
-
toolSummaries: IToolSummary[];
|
|
35
|
-
contextState: IContextWindowState;
|
|
36
|
-
}
|
|
37
|
-
/** Summary of a tool call extracted from history. */
|
|
38
|
-
interface IToolSummary {
|
|
39
|
-
name: string;
|
|
40
|
-
args: string;
|
|
41
|
-
}
|
|
42
|
-
/** Permission handler delegate — clients provide their own UI. */
|
|
43
|
-
type TInteractivePermissionHandler = (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResultValue>;
|
|
44
|
-
/** Events emitted by InteractiveSession. */
|
|
45
|
-
interface IInteractiveSessionEvents {
|
|
46
|
-
text_delta: (delta: string) => void;
|
|
47
|
-
tool_start: (state: IToolState) => void;
|
|
48
|
-
tool_end: (state: IToolState) => void;
|
|
49
|
-
thinking: (isThinking: boolean) => void;
|
|
50
|
-
complete: (result: IExecutionResult) => void;
|
|
51
|
-
error: (error: Error) => void;
|
|
52
|
-
context_update: (state: IContextWindowState) => void;
|
|
53
|
-
interrupted: (result: IExecutionResult) => void;
|
|
54
|
-
}
|
|
55
|
-
type TInteractiveEventName = keyof IInteractiveSessionEvents;
|
|
56
|
-
/**
|
|
57
|
-
* Common interface for all transport adapters.
|
|
58
|
-
* Each transport exposes InteractiveSession over a specific protocol.
|
|
59
|
-
*/
|
|
60
|
-
interface ITransportAdapter {
|
|
61
|
-
/** Human-readable transport name (e.g., 'http', 'ws', 'mcp', 'headless') */
|
|
10
|
+
type TCapabilityKind = 'builtin-command' | 'skill' | 'agent' | 'tool';
|
|
11
|
+
type TCapabilitySafety = 'read-only' | 'write' | 'process' | 'network' | 'background-agent';
|
|
12
|
+
interface ICapabilityDescriptor {
|
|
62
13
|
readonly name: string;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
14
|
+
readonly kind: TCapabilityKind;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly userInvocable: boolean;
|
|
17
|
+
readonly modelInvocable: boolean;
|
|
18
|
+
readonly argumentHint?: string;
|
|
19
|
+
readonly safety?: TCapabilitySafety;
|
|
69
20
|
}
|
|
70
21
|
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
22
|
+
/** A command entry */
|
|
23
|
+
interface ICommand {
|
|
24
|
+
/** Command name without slash (e.g., "mode") */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Short description shown in autocomplete */
|
|
27
|
+
description: string;
|
|
28
|
+
/** Source identifier (e.g., "builtin", "skill") */
|
|
29
|
+
source: string;
|
|
30
|
+
/** Subcommands for hierarchical menus */
|
|
31
|
+
subcommands?: ICommand[];
|
|
32
|
+
/** Execute the command. Args is everything after the command name. */
|
|
33
|
+
execute?: (args: string) => void | Promise<void>;
|
|
34
|
+
/** Full SKILL.md content (only for skill commands) */
|
|
35
|
+
skillContent?: string;
|
|
36
|
+
/** Hint for the expected argument (Claude Code frontmatter) */
|
|
37
|
+
argumentHint?: string;
|
|
38
|
+
/** When true, models cannot invoke this skill autonomously */
|
|
39
|
+
disableModelInvocation?: boolean;
|
|
40
|
+
/** When true, models may invoke this command through the command execution tool */
|
|
41
|
+
modelInvocable?: boolean;
|
|
42
|
+
/** When false, users cannot invoke this skill directly */
|
|
43
|
+
userInvocable?: boolean;
|
|
44
|
+
/** Safety category for model-visible capability descriptors */
|
|
45
|
+
safety?: TCapabilitySafety;
|
|
46
|
+
/** List of tools this skill is allowed to use */
|
|
47
|
+
allowedTools?: string[];
|
|
48
|
+
/** Preferred model for executing this skill */
|
|
49
|
+
model?: string;
|
|
50
|
+
/** Effort level hint for the skill */
|
|
51
|
+
effort?: string;
|
|
52
|
+
/** Context scope for the skill (e.g., "project") */
|
|
53
|
+
context?: string;
|
|
54
|
+
/** Agent identity to use when executing this skill */
|
|
55
|
+
agent?: string;
|
|
56
|
+
/** Plugin installation directory (plugin skills/commands only) */
|
|
57
|
+
pluginDir?: string;
|
|
93
58
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
constructor(options: IPromptExecutorOptions);
|
|
99
|
-
execute(definition: IHookDefinition, input: IHookInput): Promise<IHookResult>;
|
|
59
|
+
/** A source that provides commands */
|
|
60
|
+
interface ICommandSource {
|
|
61
|
+
name: string;
|
|
62
|
+
getCommands(): ICommand[];
|
|
100
63
|
}
|
|
101
64
|
|
|
102
65
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* Creates a subagent session with maxTurns and timeout limits,
|
|
106
|
-
* runs hook input as the initial prompt, and parses the result.
|
|
66
|
+
* System commands — SDK-level command execution logic.
|
|
107
67
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* - 1: execution error (session failure, parse error)
|
|
68
|
+
* Pure functions that operate on InteractiveSession.
|
|
69
|
+
* No React, no TUI, no framework dependencies.
|
|
70
|
+
* CLI wraps these as slash commands with UI chrome.
|
|
112
71
|
*/
|
|
113
72
|
|
|
114
|
-
/**
|
|
115
|
-
interface
|
|
116
|
-
|
|
73
|
+
/** Result of a system command execution. */
|
|
74
|
+
interface ICommandResult {
|
|
75
|
+
/** Human-readable output message */
|
|
76
|
+
message: string;
|
|
77
|
+
/** Command completed successfully */
|
|
78
|
+
success: boolean;
|
|
79
|
+
/** Additional structured data (command-specific) */
|
|
80
|
+
data?: Record<string, unknown>;
|
|
117
81
|
}
|
|
118
|
-
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
82
|
+
/** A system command with name, description, and execute logic. */
|
|
83
|
+
interface ISystemCommand {
|
|
84
|
+
name: string;
|
|
85
|
+
description: string;
|
|
86
|
+
modelInvocable?: boolean;
|
|
87
|
+
userInvocable?: boolean;
|
|
88
|
+
argumentHint?: string;
|
|
89
|
+
safety?: TCapabilitySafety;
|
|
90
|
+
execute(session: InteractiveSession, args: string): Promise<ICommandResult> | ICommandResult;
|
|
126
91
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
92
|
+
/** Built-in system commands. */
|
|
93
|
+
declare function createSystemCommands(): ISystemCommand[];
|
|
94
|
+
/** Registry for system commands. */
|
|
95
|
+
declare class SystemCommandExecutor {
|
|
96
|
+
private readonly commands;
|
|
97
|
+
constructor(commands?: ISystemCommand[]);
|
|
98
|
+
/** Register an additional command. */
|
|
99
|
+
register(command: ISystemCommand): void;
|
|
100
|
+
/** Execute a command by name. Returns null if command not found. */
|
|
101
|
+
execute(name: string, session: InteractiveSession, args: string): Promise<ICommandResult | null>;
|
|
102
|
+
/** List all registered commands. */
|
|
103
|
+
listCommands(): ISystemCommand[];
|
|
104
|
+
listModelInvocableCommands(): ICapabilityDescriptor[];
|
|
105
|
+
isModelInvocable(name: string): boolean;
|
|
106
|
+
executeModelInvocable(name: string, session: InteractiveSession, args: string): Promise<ICommandResult | null>;
|
|
107
|
+
/** Check if a command exists. */
|
|
108
|
+
hasCommand(name: string): boolean;
|
|
132
109
|
}
|
|
133
110
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
111
|
+
type TCommandModuleSessionRequirement = 'agent-runtime';
|
|
112
|
+
/** Composable command capability module. */
|
|
113
|
+
interface ICommandModule {
|
|
114
|
+
/** Stable module id for diagnostics and duplicate handling. */
|
|
115
|
+
readonly name: string;
|
|
116
|
+
/** Slash palette/autocomplete command sources contributed by this module. */
|
|
117
|
+
readonly commandSources?: readonly ICommandSource[];
|
|
118
|
+
/** Executable system commands contributed by this module. */
|
|
119
|
+
readonly systemCommands?: readonly ISystemCommand[];
|
|
120
|
+
/** Additional model-visible descriptors not derived from executable commands. */
|
|
121
|
+
readonly commandDescriptors?: readonly ICapabilityDescriptor[];
|
|
122
|
+
/** Runtime facilities required by this module. */
|
|
123
|
+
readonly sessionRequirements?: readonly TCommandModuleSessionRequirement[];
|
|
124
|
+
}
|
|
137
125
|
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
permissions: {
|
|
151
|
-
allow: string[];
|
|
152
|
-
deny: string[];
|
|
153
|
-
};
|
|
154
|
-
env: Record<string, string>;
|
|
155
|
-
hooks?: THooksConfig;
|
|
156
|
-
/** Plugin enablement map: plugin name -> enabled/disabled */
|
|
157
|
-
enabledPlugins?: Record<string, boolean>;
|
|
158
|
-
/** Extra marketplace sources: name -> { source } */
|
|
159
|
-
extraKnownMarketplaces?: Record<string, {
|
|
160
|
-
source: {
|
|
161
|
-
type: string;
|
|
162
|
-
repo?: string;
|
|
163
|
-
url?: string;
|
|
164
|
-
path?: string;
|
|
165
|
-
ref?: string;
|
|
166
|
-
};
|
|
167
|
-
}>;
|
|
126
|
+
/** Aggregates commands from multiple sources */
|
|
127
|
+
declare class CommandRegistry {
|
|
128
|
+
private sources;
|
|
129
|
+
addSource(source: ICommandSource): void;
|
|
130
|
+
addModule(module: ICommandModule): void;
|
|
131
|
+
/** Get all commands, optionally filtered by prefix */
|
|
132
|
+
getCommands(filter?: string): ICommand[];
|
|
133
|
+
/** Resolve a short name to its fully qualified plugin:name form */
|
|
134
|
+
resolveQualifiedName(shortName: string): string | null;
|
|
135
|
+
/** Get subcommands for a specific command */
|
|
136
|
+
getSubcommands(commandName: string): ICommand[];
|
|
137
|
+
getCapabilityDescriptors(): ICapabilityDescriptor[];
|
|
168
138
|
}
|
|
169
139
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
compactInstructions?: string;
|
|
140
|
+
/** Command source for built-in commands */
|
|
141
|
+
declare class BuiltinCommandSource implements ICommandSource {
|
|
142
|
+
readonly name = "builtin";
|
|
143
|
+
private readonly commands;
|
|
144
|
+
constructor();
|
|
145
|
+
getCommands(): ICommand[];
|
|
177
146
|
}
|
|
178
147
|
|
|
179
|
-
|
|
180
|
-
type TPackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';
|
|
181
|
-
type TLanguage = 'typescript' | 'javascript' | 'python' | 'rust' | 'go' | 'unknown';
|
|
182
|
-
interface IProjectInfo {
|
|
183
|
-
type: TProjectType;
|
|
148
|
+
interface IFrontmatter {
|
|
184
149
|
name?: string;
|
|
185
|
-
|
|
186
|
-
|
|
150
|
+
description?: string;
|
|
151
|
+
argumentHint?: string;
|
|
152
|
+
disableModelInvocation?: boolean;
|
|
153
|
+
userInvocable?: boolean;
|
|
154
|
+
allowedTools?: string[];
|
|
155
|
+
model?: string;
|
|
156
|
+
effort?: string;
|
|
157
|
+
context?: string;
|
|
158
|
+
agent?: string;
|
|
159
|
+
}
|
|
160
|
+
/** Parse YAML-like frontmatter between --- markers */
|
|
161
|
+
declare function parseFrontmatter(content: string): IFrontmatter | null;
|
|
162
|
+
/** Command source that discovers skills from multiple directories */
|
|
163
|
+
declare class SkillCommandSource implements ICommandSource {
|
|
164
|
+
readonly name = "skill";
|
|
165
|
+
private readonly cwd;
|
|
166
|
+
private readonly home;
|
|
167
|
+
private cachedCommands;
|
|
168
|
+
constructor(cwd: string, home?: string);
|
|
169
|
+
getCommands(): ICommand[];
|
|
170
|
+
getModelInvocableSkills(): ICommand[];
|
|
171
|
+
getUserInvocableSkills(): ICommand[];
|
|
187
172
|
}
|
|
188
173
|
|
|
189
174
|
/**
|
|
190
|
-
*
|
|
191
|
-
* from base role, project context, AGENTS.md/CLAUDE.md, tool list, and
|
|
192
|
-
* permission trust level.
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
interface ISystemPromptParams {
|
|
196
|
-
/** Concatenated AGENTS.md content (may be empty string) */
|
|
197
|
-
agentsMd: string;
|
|
198
|
-
/** Concatenated CLAUDE.md content (may be empty string) */
|
|
199
|
-
claudeMd: string;
|
|
200
|
-
/** Human-readable tool descriptions, one per entry */
|
|
201
|
-
toolDescriptions: string[];
|
|
202
|
-
/** Active trust level governing permission checks */
|
|
203
|
-
trustLevel: TTrustLevel;
|
|
204
|
-
/** Detected project metadata */
|
|
205
|
-
projectInfo: IProjectInfo;
|
|
206
|
-
/** Current working directory */
|
|
207
|
-
cwd?: string;
|
|
208
|
-
/** Response language code (e.g., "ko", "en"). If set, AI must respond in this language. */
|
|
209
|
-
language?: string;
|
|
210
|
-
/** Discovered skills to expose in the system prompt */
|
|
211
|
-
skills?: Array<{
|
|
212
|
-
name: string;
|
|
213
|
-
description: string;
|
|
214
|
-
disableModelInvocation?: boolean;
|
|
215
|
-
}>;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Session factory — assembles a fully-configured Session from config, context,
|
|
220
|
-
* tools, and provider.
|
|
175
|
+
* PluginSettingsStore — single point of read/write for plugin-related settings.
|
|
221
176
|
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* expects as pre-constructed dependencies.
|
|
177
|
+
* Shared by MarketplaceClient and BundlePluginInstaller to prevent
|
|
178
|
+
* concurrent writes from overwriting each other's changes.
|
|
225
179
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
/** Custom permission handler (overrides terminal-based prompts, used by Ink UI) */
|
|
246
|
-
permissionHandler?: TPermissionHandler;
|
|
247
|
-
/** Callback for text deltas — enables streaming text to the UI in real-time */
|
|
248
|
-
onTextDelta?: (delta: string) => void;
|
|
249
|
-
/** Custom prompt-for-approval function (injected from CLI) */
|
|
250
|
-
promptForApproval?: (terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
|
|
251
|
-
/** Additional tools to register beyond the defaults (e.g. agent-tool) */
|
|
252
|
-
additionalTools?: IToolWithEventService[];
|
|
253
|
-
/** Callback when a tool starts or finishes execution — enables real-time tool display in UI */
|
|
254
|
-
onToolExecution?: (event: {
|
|
255
|
-
type: 'start' | 'end';
|
|
256
|
-
toolName: string;
|
|
257
|
-
toolArgs?: TToolArgs;
|
|
258
|
-
success?: boolean;
|
|
259
|
-
}) => void;
|
|
260
|
-
/** Callback when context is compacted */
|
|
261
|
-
onCompact?: (summary: string) => void;
|
|
262
|
-
/** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
|
|
263
|
-
compactInstructions?: string;
|
|
264
|
-
/** Custom system prompt builder function */
|
|
265
|
-
systemPromptBuilder?: (params: ISystemPromptParams) => string;
|
|
266
|
-
/** Custom tool descriptions for the system prompt */
|
|
267
|
-
toolDescriptions?: string[];
|
|
268
|
-
/** Session logger — injected for pluggable session event logging. */
|
|
269
|
-
sessionLogger?: ISessionLogger;
|
|
270
|
-
/** Provider factory for prompt hook executors (DI). */
|
|
271
|
-
providerFactory?: TProviderFactory;
|
|
272
|
-
/** Session factory for agent hook executors (DI). */
|
|
273
|
-
sessionFactory?: TSessionFactory;
|
|
274
|
-
/** Additional hook type executors beyond the defaults (prompt, agent). */
|
|
275
|
-
additionalHookExecutors?: IHookTypeExecutor[];
|
|
276
|
-
/** Override session ID (used when resuming a session to reuse the original ID) */
|
|
277
|
-
sessionId?: string;
|
|
180
|
+
/** Source type for a marketplace registry. */
|
|
181
|
+
type IMarketplaceSource$1 = {
|
|
182
|
+
type: 'github';
|
|
183
|
+
repo: string;
|
|
184
|
+
ref?: string;
|
|
185
|
+
} | {
|
|
186
|
+
type: 'git';
|
|
187
|
+
url: string;
|
|
188
|
+
ref?: string;
|
|
189
|
+
} | {
|
|
190
|
+
type: 'local';
|
|
191
|
+
path: string;
|
|
192
|
+
} | {
|
|
193
|
+
type: 'url';
|
|
194
|
+
url: string;
|
|
195
|
+
};
|
|
196
|
+
/** Persisted marketplace source entry. */
|
|
197
|
+
interface IPersistedMarketplaceSource {
|
|
198
|
+
source: IMarketplaceSource$1;
|
|
278
199
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
|
|
200
|
+
/** Shape of the plugin-related keys in settings.json. */
|
|
201
|
+
interface IPluginSettings {
|
|
202
|
+
enabledPlugins: Record<string, boolean>;
|
|
203
|
+
extraKnownMarketplaces: Record<string, IPersistedMarketplaceSource>;
|
|
204
|
+
}
|
|
205
|
+
/** Centralized settings store for plugin configuration. */
|
|
206
|
+
declare class PluginSettingsStore {
|
|
207
|
+
private readonly settingsPath;
|
|
208
|
+
constructor(settingsPath: string);
|
|
209
|
+
/** Read the full settings file from disk. */
|
|
210
|
+
private readAll;
|
|
211
|
+
/** Write the full settings file to disk. */
|
|
212
|
+
private writeAll;
|
|
213
|
+
/** Get the enabledPlugins map. */
|
|
214
|
+
getEnabledPlugins(): Record<string, boolean>;
|
|
215
|
+
/** Set a single plugin's enabled state. */
|
|
216
|
+
setPluginEnabled(pluginId: string, enabled: boolean): void;
|
|
217
|
+
/** Remove a plugin from enabledPlugins. */
|
|
218
|
+
removePluginEntry(pluginId: string): void;
|
|
219
|
+
/** Get all persisted marketplace sources. */
|
|
220
|
+
getMarketplaceSources(): Record<string, IPersistedMarketplaceSource>;
|
|
221
|
+
/** Add or update a marketplace source. */
|
|
222
|
+
setMarketplaceSource(name: string, source: IMarketplaceSource$1): void;
|
|
223
|
+
/** Remove a marketplace source. */
|
|
224
|
+
removeMarketplaceSource(name: string): void;
|
|
225
|
+
private getEnabledPluginsFrom;
|
|
226
|
+
private getMarketplaceSourcesFrom;
|
|
296
227
|
}
|
|
297
|
-
/**
|
|
298
|
-
* Returns the standard subagent suffix appended to agent body for normal subagents.
|
|
299
|
-
*/
|
|
300
|
-
declare function getSubagentSuffix(): string;
|
|
301
|
-
/**
|
|
302
|
-
* Returns the fork worker suffix for context:fork skill workers.
|
|
303
|
-
*/
|
|
304
|
-
declare function getForkWorkerSuffix(): string;
|
|
305
|
-
/**
|
|
306
|
-
* Assembles the full system prompt for a subagent.
|
|
307
|
-
*
|
|
308
|
-
* Assembly order:
|
|
309
|
-
* 1. Agent definition body
|
|
310
|
-
* 2. CLAUDE.md content (if provided)
|
|
311
|
-
* 3. AGENTS.md content (if provided)
|
|
312
|
-
* 4. Framework suffix (fork worker OR standard subagent)
|
|
313
|
-
*/
|
|
314
|
-
declare function assembleSubagentPrompt(options: ISubagentPromptOptions): string;
|
|
315
228
|
|
|
316
229
|
/**
|
|
317
|
-
*
|
|
230
|
+
* Types for the BundlePlugin system.
|
|
318
231
|
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
232
|
+
* A BundlePlugin is a directory-based plugin package that bundles
|
|
233
|
+
* skills, hooks, agents, and MCP server configurations.
|
|
321
234
|
*/
|
|
322
|
-
|
|
323
|
-
|
|
235
|
+
/** Feature flags indicating what a bundle plugin provides. */
|
|
236
|
+
interface IBundlePluginFeatures {
|
|
237
|
+
commands?: boolean;
|
|
238
|
+
agents?: boolean;
|
|
239
|
+
skills?: boolean;
|
|
240
|
+
hooks?: boolean;
|
|
241
|
+
mcp?: boolean;
|
|
242
|
+
}
|
|
243
|
+
/** Manifest read from `.claude-plugin/plugin.json`. */
|
|
244
|
+
interface IBundlePluginManifest {
|
|
324
245
|
name: string;
|
|
325
|
-
|
|
246
|
+
version: string;
|
|
326
247
|
description: string;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
248
|
+
features: IBundlePluginFeatures;
|
|
249
|
+
}
|
|
250
|
+
/** A skill loaded from a bundle plugin's `skills/` directory. */
|
|
251
|
+
interface IBundleSkill {
|
|
252
|
+
name: string;
|
|
253
|
+
description: string;
|
|
254
|
+
skillContent: string;
|
|
255
|
+
[key: string]: unknown;
|
|
256
|
+
}
|
|
257
|
+
/** A fully loaded bundle plugin with all its assets. */
|
|
258
|
+
interface ILoadedBundlePlugin {
|
|
259
|
+
manifest: IBundlePluginManifest;
|
|
260
|
+
skills: IBundleSkill[];
|
|
261
|
+
commands: IBundleSkill[];
|
|
262
|
+
hooks: Record<string, unknown>;
|
|
263
|
+
mcpConfig?: unknown;
|
|
264
|
+
agents: string[];
|
|
265
|
+
pluginDir: string;
|
|
337
266
|
}
|
|
267
|
+
/** Map of plugin identifiers to enabled/disabled state. */
|
|
268
|
+
type TEnabledPlugins = Record<string, boolean>;
|
|
338
269
|
|
|
339
270
|
/**
|
|
340
|
-
*
|
|
271
|
+
* BundlePluginLoader — discovers and loads directory-based bundle plugins.
|
|
341
272
|
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
273
|
+
* Scans the cache directory (`<pluginsDir>/cache/<marketplace>/<plugin>/<version>/`)
|
|
274
|
+
* for subdirectories containing `.claude-plugin/plugin.json`,
|
|
275
|
+
* reads manifests, loads skills (with frontmatter parsing), hooks, and agent definitions.
|
|
276
|
+
*
|
|
277
|
+
* For each plugin, the latest version directory (lexicographically last) is loaded.
|
|
346
278
|
*/
|
|
347
279
|
|
|
348
|
-
/**
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
280
|
+
/** Loader for directory-based bundle plugins from the cache directory. */
|
|
281
|
+
declare class BundlePluginLoader {
|
|
282
|
+
private readonly pluginsDir;
|
|
283
|
+
private readonly enabledPlugins;
|
|
284
|
+
constructor(pluginsDir: string, enabledPlugins?: TEnabledPlugins);
|
|
285
|
+
/** Load all discovered and enabled bundle plugins (sync). */
|
|
286
|
+
loadPluginsSync(): ILoadedBundlePlugin[];
|
|
287
|
+
/** Load all discovered and enabled bundle plugins (async wrapper). */
|
|
288
|
+
loadAll(): Promise<ILoadedBundlePlugin[]>;
|
|
289
|
+
/**
|
|
290
|
+
* Discover and load plugins from the cache directory.
|
|
291
|
+
*
|
|
292
|
+
* Directory structure: `<pluginsDir>/cache/<marketplace>/<plugin>/<version>/`
|
|
293
|
+
* For each marketplace/plugin pair, the latest version (lexicographically last) is loaded.
|
|
294
|
+
*/
|
|
295
|
+
private discoverAndLoad;
|
|
296
|
+
/** Read and validate a plugin.json manifest. Returns null on failure. */
|
|
297
|
+
private readManifest;
|
|
298
|
+
/**
|
|
299
|
+
* Check if a plugin is explicitly disabled.
|
|
300
|
+
* Checks both `name@marketplace` and `name` keys.
|
|
301
|
+
* Plugins not listed in enabledPlugins are enabled by default.
|
|
302
|
+
*/
|
|
303
|
+
private isDisabled;
|
|
304
|
+
/** Load a single plugin's skills, hooks, agents, and MCP config. */
|
|
305
|
+
private loadPlugin;
|
|
306
|
+
/** Load skills from the plugin's skills/ directory. */
|
|
307
|
+
private loadSkills;
|
|
308
|
+
/** Load commands from the plugin's commands/ directory (flat .md files). */
|
|
309
|
+
private loadCommands;
|
|
310
|
+
/** Load hooks from hooks/hooks.json if present. */
|
|
311
|
+
private loadHooks;
|
|
312
|
+
/** Load MCP server configuration if present. Checks `.mcp.json` at plugin root first. */
|
|
313
|
+
private loadMcpConfig;
|
|
314
|
+
/** Load agent definitions from agents/ directory if present. */
|
|
315
|
+
private loadAgents;
|
|
381
316
|
}
|
|
382
|
-
/**
|
|
383
|
-
* Create a fully-configured Session for subagent execution.
|
|
384
|
-
*
|
|
385
|
-
* Assembles provider, tools, and system prompt from parent context and
|
|
386
|
-
* agent definition, then returns a new Session instance.
|
|
387
|
-
*/
|
|
388
|
-
declare function createSubagentSession(options: ISubagentOptions): Session;
|
|
389
317
|
|
|
390
318
|
/**
|
|
391
|
-
*
|
|
392
|
-
* subagent session logs into a subdirectory of the parent session's log folder.
|
|
393
|
-
*
|
|
394
|
-
* Log structure:
|
|
395
|
-
* {baseLogsDir}/{parentSessionId}/subagents/{agentId}.jsonl
|
|
396
|
-
*/
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Create a FileSessionLogger for a subagent session.
|
|
400
|
-
*
|
|
401
|
-
* The logger writes JSONL files into a `subagents/` subdirectory under the
|
|
402
|
-
* parent session's log folder. The directory is created if it does not exist.
|
|
403
|
-
*
|
|
404
|
-
* @param parentSessionId - ID of the parent session (used as directory name)
|
|
405
|
-
* @param agentId - Unique identifier for this subagent run
|
|
406
|
-
* @param baseLogsDir - Root logs directory (e.g., `.robota/logs`)
|
|
407
|
-
* @returns A FileSessionLogger writing to the subagent directory
|
|
408
|
-
*/
|
|
409
|
-
declare function createSubagentLogger(parentSessionId: string, _agentId: string, baseLogsDir: string): FileSessionLogger;
|
|
410
|
-
/**
|
|
411
|
-
* Resolve the subagent log directory path without creating it.
|
|
412
|
-
*
|
|
413
|
-
* Useful when the caller needs the path for display or configuration
|
|
414
|
-
* but does not want to create the directory immediately.
|
|
415
|
-
*
|
|
416
|
-
* @param parentSessionId - ID of the parent session
|
|
417
|
-
* @param baseLogsDir - Root logs directory
|
|
418
|
-
* @returns The resolved subagent log directory path
|
|
319
|
+
* Shared types for marketplace client and registry.
|
|
419
320
|
*/
|
|
420
|
-
|
|
321
|
+
/** Source specification for a marketplace. */
|
|
322
|
+
type IMarketplaceSource = {
|
|
323
|
+
type: 'github';
|
|
324
|
+
repo: string;
|
|
325
|
+
ref?: string;
|
|
326
|
+
} | {
|
|
327
|
+
type: 'git';
|
|
328
|
+
url: string;
|
|
329
|
+
ref?: string;
|
|
330
|
+
} | {
|
|
331
|
+
type: 'local';
|
|
332
|
+
path: string;
|
|
333
|
+
} | {
|
|
334
|
+
type: 'url';
|
|
335
|
+
url: string;
|
|
336
|
+
};
|
|
337
|
+
/** A single plugin entry in a marketplace manifest. */
|
|
338
|
+
interface IMarketplacePluginEntry {
|
|
339
|
+
name: string;
|
|
340
|
+
title: string;
|
|
341
|
+
description: string;
|
|
342
|
+
source: string | {
|
|
343
|
+
type: 'github';
|
|
344
|
+
repo: string;
|
|
345
|
+
} | {
|
|
346
|
+
type: 'url';
|
|
347
|
+
url: string;
|
|
348
|
+
};
|
|
349
|
+
tags: string[];
|
|
350
|
+
}
|
|
351
|
+
/** Manifest format read from `.claude-plugin/marketplace.json`. */
|
|
352
|
+
interface IMarketplaceManifest {
|
|
353
|
+
name: string;
|
|
354
|
+
version: string;
|
|
355
|
+
plugins: IMarketplacePluginEntry[];
|
|
356
|
+
}
|
|
357
|
+
/** Entry in known_marketplaces.json. */
|
|
358
|
+
interface IKnownMarketplaceEntry {
|
|
359
|
+
source: IMarketplaceSource;
|
|
360
|
+
installLocation: string;
|
|
361
|
+
lastUpdated: string;
|
|
362
|
+
}
|
|
363
|
+
/** Shape of known_marketplaces.json. */
|
|
364
|
+
type IKnownMarketplacesRegistry = Record<string, IKnownMarketplaceEntry>;
|
|
365
|
+
/** Exec function type for running shell commands. */
|
|
366
|
+
type ExecFn$1 = (command: string, options: {
|
|
367
|
+
timeout: number;
|
|
368
|
+
stdio?: string;
|
|
369
|
+
}) => string | Buffer;
|
|
370
|
+
/** Options for constructing a MarketplaceClient. */
|
|
371
|
+
interface IMarketplaceClientOptions {
|
|
372
|
+
/** Base plugins directory (e.g., `~/.robota/plugins`). */
|
|
373
|
+
pluginsDir: string;
|
|
374
|
+
/** Custom exec function for testing (replaces child_process.execSync). */
|
|
375
|
+
exec?: ExecFn$1;
|
|
376
|
+
}
|
|
421
377
|
|
|
422
378
|
/**
|
|
423
|
-
*
|
|
379
|
+
* MarketplaceClient — manages marketplace registries via shallow git clones.
|
|
424
380
|
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
381
|
+
* Marketplaces are git repositories containing `.claude-plugin/marketplace.json`.
|
|
382
|
+
* They are cloned to `~/.robota/plugins/marketplaces/<name>/` and tracked
|
|
383
|
+
* in `known_marketplaces.json`.
|
|
427
384
|
*/
|
|
428
385
|
|
|
429
|
-
/**
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
386
|
+
/** Manages marketplace registries via shallow git clones. */
|
|
387
|
+
declare class MarketplaceClient {
|
|
388
|
+
private readonly pluginsDir;
|
|
389
|
+
private readonly exec;
|
|
390
|
+
private readonly marketplacesDir;
|
|
391
|
+
private readonly registryPath;
|
|
392
|
+
constructor(options: IMarketplaceClientOptions);
|
|
393
|
+
/**
|
|
394
|
+
* Add a marketplace by cloning its repository.
|
|
395
|
+
*
|
|
396
|
+
* 1. Shallow git clone (`--depth 1`) to `marketplaces/<name>/`.
|
|
397
|
+
* 2. Read `.claude-plugin/marketplace.json` for the `name` field.
|
|
398
|
+
* 3. Register in `known_marketplaces.json`.
|
|
399
|
+
*
|
|
400
|
+
* Returns the registered marketplace name from the manifest.
|
|
401
|
+
*/
|
|
402
|
+
addMarketplace(source: IMarketplaceSource): string;
|
|
403
|
+
/**
|
|
404
|
+
* Remove a marketplace.
|
|
405
|
+
* Uninstalls all plugins from that marketplace, then deletes the clone directory
|
|
406
|
+
* and removes from the registry.
|
|
407
|
+
*/
|
|
408
|
+
removeMarketplace(name: string): void;
|
|
409
|
+
/**
|
|
410
|
+
* Update a marketplace by running git pull on its clone.
|
|
411
|
+
* The manifest is re-read from disk on demand (via fetchManifest), so the
|
|
412
|
+
* updated manifest is automatically available after pull.
|
|
413
|
+
*/
|
|
414
|
+
updateMarketplace(name: string): void;
|
|
415
|
+
/** List all registered marketplaces. */
|
|
416
|
+
listMarketplaces(): Array<{
|
|
417
|
+
name: string;
|
|
418
|
+
source: IMarketplaceSource;
|
|
419
|
+
lastUpdated: string;
|
|
420
|
+
}>;
|
|
421
|
+
/** Read the marketplace manifest from a registered marketplace's clone. */
|
|
422
|
+
fetchManifest(marketplaceName: string): IMarketplaceManifest;
|
|
423
|
+
/** Get the clone directory path for a registered marketplace. */
|
|
424
|
+
getMarketplaceDir(name: string): string;
|
|
425
|
+
/**
|
|
426
|
+
* Get the current git SHA (first 12 chars) for a marketplace clone.
|
|
427
|
+
* Used as a version identifier when plugins lack explicit versions.
|
|
428
|
+
*/
|
|
429
|
+
getMarketplaceSha(name: string): string;
|
|
430
|
+
/** List all available plugins across all marketplaces. */
|
|
431
|
+
listAvailablePlugins(): Array<IMarketplacePluginEntry & {
|
|
432
|
+
marketplace: string;
|
|
433
|
+
}>;
|
|
434
|
+
/** Resolve a marketplace source to a git clone URL. */
|
|
435
|
+
private resolveCloneUrl;
|
|
436
|
+
/** Read and parse a marketplace.json from a file path. */
|
|
437
|
+
private readManifestFromPath;
|
|
438
|
+
/** Default exec implementation using child_process. */
|
|
439
|
+
private defaultExec;
|
|
453
440
|
}
|
|
454
|
-
/** Union of standard and injected construction options. */
|
|
455
|
-
type IInteractiveSessionOptions = IInteractiveSessionStandardOptions | IInteractiveSessionInjectedOptions;
|
|
456
441
|
|
|
457
442
|
/**
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
* Wraps Session (composition). Manages streaming text accumulation,
|
|
461
|
-
* tool execution state tracking, prompt queuing, abort orchestration,
|
|
462
|
-
* message history, and system command execution.
|
|
443
|
+
* BundlePluginInstaller — installs, uninstalls, enables, and disables bundle plugins.
|
|
463
444
|
*
|
|
464
|
-
*
|
|
445
|
+
* Resolves plugin sources from marketplace manifests, copies/clones to the
|
|
446
|
+
* cache directory, and tracks installations in `installed_plugins.json`.
|
|
465
447
|
*/
|
|
466
448
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
449
|
+
/** Record of an installed plugin in installed_plugins.json. */
|
|
450
|
+
interface IInstalledPluginRecord {
|
|
451
|
+
pluginName: string;
|
|
452
|
+
marketplace: string;
|
|
453
|
+
version: string;
|
|
454
|
+
installPath: string;
|
|
455
|
+
installedAt: string;
|
|
456
|
+
}
|
|
457
|
+
/** Shape of installed_plugins.json. */
|
|
458
|
+
type IInstalledPluginsRegistry = Record<string, IInstalledPluginRecord>;
|
|
459
|
+
/** Exec function type for running shell commands. */
|
|
460
|
+
type ExecFn = (command: string, options: {
|
|
461
|
+
timeout: number;
|
|
462
|
+
stdio?: string;
|
|
463
|
+
}) => string | Buffer;
|
|
464
|
+
/** Options for constructing a BundlePluginInstaller. */
|
|
465
|
+
interface IBundlePluginInstallerOptions {
|
|
466
|
+
/** Base plugins directory (e.g., `~/.robota/plugins`). */
|
|
467
|
+
pluginsDir: string;
|
|
468
|
+
/** Shared settings store for enable/disable persistence. */
|
|
469
|
+
settingsStore: PluginSettingsStore;
|
|
470
|
+
/** MarketplaceClient for reading marketplace manifests. */
|
|
471
|
+
marketplaceClient: MarketplaceClient;
|
|
472
|
+
/** Custom exec function for testing (replaces child_process.execSync). */
|
|
473
|
+
exec?: ExecFn;
|
|
474
|
+
}
|
|
475
|
+
/** Installs, uninstalls, enables, and disables bundle plugins. */
|
|
476
|
+
declare class BundlePluginInstaller {
|
|
477
|
+
private readonly pluginsDir;
|
|
478
|
+
private readonly cacheDir;
|
|
479
|
+
private readonly registryPath;
|
|
480
|
+
private readonly settingsStore;
|
|
481
|
+
private readonly marketplaceClient;
|
|
482
|
+
private readonly exec;
|
|
483
|
+
constructor(options: IBundlePluginInstallerOptions);
|
|
484
|
+
/**
|
|
485
|
+
* Install a plugin from a marketplace.
|
|
486
|
+
*
|
|
487
|
+
* 1. Read marketplace manifest to find the plugin entry.
|
|
488
|
+
* 2. Resolve source (relative path, github, or url).
|
|
489
|
+
* 3. Copy/clone to `cache/<marketplace>/<plugin>/<version>/`.
|
|
490
|
+
* 4. Record in `installed_plugins.json`.
|
|
491
|
+
*/
|
|
492
|
+
install(pluginName: string, marketplaceName: string): Promise<void>;
|
|
493
|
+
/**
|
|
494
|
+
* Uninstall a plugin.
|
|
495
|
+
* Removes from cache and from installed_plugins.json.
|
|
496
|
+
*/
|
|
497
|
+
uninstall(pluginId: string): Promise<void>;
|
|
498
|
+
/** Enable a plugin by setting its enabledPlugins entry to true. */
|
|
499
|
+
enable(pluginId: string): Promise<void>;
|
|
500
|
+
/** Disable a plugin by setting its enabledPlugins entry to false. */
|
|
501
|
+
disable(pluginId: string): Promise<void>;
|
|
502
|
+
/** Get all installed plugins. */
|
|
503
|
+
getInstalledPlugins(): IInstalledPluginsRegistry;
|
|
504
|
+
/** Get plugins installed from a specific marketplace. */
|
|
505
|
+
getPluginsByMarketplace(marketplaceName: string): IInstalledPluginRecord[];
|
|
506
|
+
/** Resolve the version for a plugin entry. */
|
|
507
|
+
private resolveVersion;
|
|
508
|
+
/**
|
|
509
|
+
* Normalize source object — Claude Code manifests use `source` key instead of `type`.
|
|
510
|
+
* e.g., { source: "url", url: "..." } → { type: "url", url: "..." }
|
|
511
|
+
*/
|
|
512
|
+
private normalizeSource;
|
|
513
|
+
/** Resolve the source and install the plugin. */
|
|
514
|
+
private resolveAndInstall;
|
|
515
|
+
/** Clone a git repository to the target directory. */
|
|
516
|
+
private cloneToDir;
|
|
517
|
+
/** Read the installed_plugins.json registry. */
|
|
518
|
+
private readRegistry;
|
|
519
|
+
/** Write the installed_plugins.json registry. */
|
|
520
|
+
private writeRegistry;
|
|
521
|
+
/** Default exec implementation using child_process. */
|
|
522
|
+
private defaultExec;
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
/**
|
|
526
|
-
*
|
|
526
|
+
* Command source that discovers skills and commands from loaded BundlePlugins.
|
|
527
527
|
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
* const answer = await query('What files are here?');
|
|
528
|
+
* - Skills: exposed as `/name` with `(plugin-name)` hint in description.
|
|
529
|
+
* - Commands: exposed as `/plugin:command` (already namespaced by the loader).
|
|
531
530
|
*/
|
|
531
|
+
declare class PluginCommandSource implements ICommandSource {
|
|
532
|
+
readonly name = "plugin";
|
|
533
|
+
private readonly plugins;
|
|
534
|
+
constructor(plugins: ILoadedBundlePlugin[]);
|
|
535
|
+
getCommands(): ICommand[];
|
|
536
|
+
}
|
|
532
537
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
|
|
544
|
-
/** Streaming text callback. */
|
|
545
|
-
onTextDelta?: (delta: string) => void;
|
|
538
|
+
/**
|
|
539
|
+
* Build a skill prompt from slash command input.
|
|
540
|
+
* Supports variable substitution and shell command preprocessing.
|
|
541
|
+
*/
|
|
542
|
+
|
|
543
|
+
/** Context variables available during skill prompt processing */
|
|
544
|
+
interface SkillPromptContext {
|
|
545
|
+
/** Current session ID — substituted for ${CLAUDE_SESSION_ID} */
|
|
546
|
+
sessionId?: string;
|
|
547
|
+
/** Directory containing SKILL.md — substituted for ${CLAUDE_SKILL_DIR} */
|
|
548
|
+
skillDir?: string;
|
|
546
549
|
}
|
|
547
550
|
/**
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
* ```typescript
|
|
551
|
-
* import { createQuery } from '@robota-sdk/agent-sdk';
|
|
552
|
-
* import { AnthropicProvider } from '@robota-sdk/agent-provider-anthropic';
|
|
551
|
+
* Substitute variables in skill content.
|
|
553
552
|
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
553
|
+
* Supported variables:
|
|
554
|
+
* - `$ARGUMENTS` — all arguments passed to the skill
|
|
555
|
+
* - `$ARGUMENTS[N]` — argument by index (0-based)
|
|
556
|
+
* - `$N` — shorthand for `$ARGUMENTS[N]` (single digit, 0-9)
|
|
557
|
+
* - `${CLAUDE_SESSION_ID}` — current session ID
|
|
558
|
+
* - `${CLAUDE_SKILL_DIR}` — directory containing SKILL.md
|
|
557
559
|
*/
|
|
558
|
-
declare function
|
|
560
|
+
declare function substituteVariables(content: string, args: string, context?: SkillPromptContext): string;
|
|
561
|
+
/**
|
|
562
|
+
* Preprocess shell commands in skill content.
|
|
563
|
+
* Matches `` !`...` `` patterns and replaces them with command output.
|
|
564
|
+
* Commands have a 5-second timeout.
|
|
565
|
+
*/
|
|
566
|
+
declare function preprocessShellCommands(content: string): Promise<string>;
|
|
567
|
+
/** Build a skill prompt from a slash command input and registry */
|
|
568
|
+
declare function buildSkillPrompt(input: string, registry: CommandRegistry, context?: SkillPromptContext): Promise<string | null>;
|
|
559
569
|
|
|
560
|
-
/**
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
/** Subcommands for hierarchical menus */
|
|
569
|
-
subcommands?: ICommand[];
|
|
570
|
-
/** Execute the command. Args is everything after the command name. */
|
|
571
|
-
execute?: (args: string) => void | Promise<void>;
|
|
572
|
-
/** Full SKILL.md content (only for skill commands) */
|
|
573
|
-
skillContent?: string;
|
|
574
|
-
/** Hint for the expected argument (Claude Code frontmatter) */
|
|
575
|
-
argumentHint?: string;
|
|
576
|
-
/** When true, models cannot invoke this skill autonomously */
|
|
577
|
-
disableModelInvocation?: boolean;
|
|
578
|
-
/** When false, users cannot invoke this skill directly */
|
|
579
|
-
userInvocable?: boolean;
|
|
580
|
-
/** List of tools this skill is allowed to use */
|
|
581
|
-
allowedTools?: string[];
|
|
582
|
-
/** Preferred model for executing this skill */
|
|
583
|
-
model?: string;
|
|
584
|
-
/** Effort level hint for the skill */
|
|
585
|
-
effort?: string;
|
|
586
|
-
/** Context scope for the skill (e.g., "project") */
|
|
587
|
-
context?: string;
|
|
588
|
-
/** Agent identity to use when executing this skill */
|
|
570
|
+
/**
|
|
571
|
+
* Skill execution logic.
|
|
572
|
+
* Handles both fork-based (subagent) and inject-based (user message) execution.
|
|
573
|
+
*/
|
|
574
|
+
|
|
575
|
+
/** Options passed to the fork execution callback */
|
|
576
|
+
interface IForkExecutionOptions {
|
|
577
|
+
/** Agent identity to use (e.g., 'Explore', 'Plan') */
|
|
589
578
|
agent?: string;
|
|
590
|
-
/**
|
|
591
|
-
|
|
579
|
+
/** Tools the subagent is allowed to use */
|
|
580
|
+
allowedTools?: string[];
|
|
592
581
|
}
|
|
593
|
-
/**
|
|
594
|
-
interface
|
|
595
|
-
|
|
596
|
-
|
|
582
|
+
/** Callback interface for skill execution infrastructure */
|
|
583
|
+
interface ISkillExecutionCallbacks {
|
|
584
|
+
/**
|
|
585
|
+
* Run skill content in an isolated subagent session.
|
|
586
|
+
* The content becomes the subagent's prompt.
|
|
587
|
+
* Returns the subagent's response.
|
|
588
|
+
*/
|
|
589
|
+
runInFork?: (content: string, options: IForkExecutionOptions) => Promise<string>;
|
|
597
590
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
resolveQualifiedName(shortName: string): string | null;
|
|
607
|
-
/** Get subcommands for a specific command */
|
|
608
|
-
getSubcommands(commandName: string): ICommand[];
|
|
591
|
+
/** Result of skill execution */
|
|
592
|
+
interface ISkillExecutionResult {
|
|
593
|
+
/** Execution mode used */
|
|
594
|
+
mode: 'fork' | 'inject';
|
|
595
|
+
/** For inject mode: the prompt to send as a user message */
|
|
596
|
+
prompt?: string;
|
|
597
|
+
/** For fork mode: the subagent's response */
|
|
598
|
+
result?: string;
|
|
609
599
|
}
|
|
600
|
+
/**
|
|
601
|
+
* Execute a skill command.
|
|
602
|
+
*
|
|
603
|
+
* When `context: 'fork'`, the skill runs in an isolated subagent session
|
|
604
|
+
* via the `runInFork` callback. Throws if `runInFork` is not available.
|
|
605
|
+
* For non-fork skills, the content is returned as a prompt for injection
|
|
606
|
+
* into the current session.
|
|
607
|
+
*/
|
|
608
|
+
declare function executeSkill(skill: ICommand, args: string, callbacks: ISkillExecutionCallbacks, context?: SkillPromptContext): Promise<ISkillExecutionResult>;
|
|
610
609
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
610
|
+
type TBackgroundJobWaitPolicy = 'detached' | 'wait_all' | 'wait_any' | 'manual';
|
|
611
|
+
type TBackgroundJobGroupStatus = 'running' | 'completed';
|
|
612
|
+
interface IBackgroundJobResultEnvelope {
|
|
613
|
+
taskId: string;
|
|
614
|
+
label: string;
|
|
615
|
+
status: TBackgroundTaskStatus;
|
|
616
|
+
summary?: string;
|
|
617
|
+
outputRef?: string;
|
|
618
|
+
error?: IBackgroundTaskError;
|
|
619
|
+
startedAt?: string;
|
|
620
|
+
completedAt?: string;
|
|
617
621
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
agent?: string;
|
|
622
|
+
interface IBackgroundJobGroupState {
|
|
623
|
+
id: string;
|
|
624
|
+
parentSessionId: string;
|
|
625
|
+
waitPolicy: TBackgroundJobWaitPolicy;
|
|
626
|
+
taskIds: string[];
|
|
627
|
+
status: TBackgroundJobGroupStatus;
|
|
628
|
+
createdAt: string;
|
|
629
|
+
updatedAt: string;
|
|
630
|
+
label?: string;
|
|
631
|
+
completedAt?: string;
|
|
632
|
+
results: IBackgroundJobResultEnvelope[];
|
|
630
633
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
getCommands(): ICommand[];
|
|
641
|
-
getModelInvocableSkills(): ICommand[];
|
|
642
|
-
getUserInvocableSkills(): ICommand[];
|
|
634
|
+
interface IBackgroundJobGroupSummary {
|
|
635
|
+
groupId: string;
|
|
636
|
+
status: TBackgroundJobGroupStatus;
|
|
637
|
+
total: number;
|
|
638
|
+
completed: number;
|
|
639
|
+
failed: number;
|
|
640
|
+
cancelled: number;
|
|
641
|
+
pending: number;
|
|
642
|
+
lines: string[];
|
|
643
643
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
type: 'github';
|
|
654
|
-
repo: string;
|
|
655
|
-
ref?: string;
|
|
656
|
-
} | {
|
|
657
|
-
type: 'git';
|
|
658
|
-
url: string;
|
|
659
|
-
ref?: string;
|
|
644
|
+
interface IBackgroundJobGroupCreateRequest {
|
|
645
|
+
parentSessionId: string;
|
|
646
|
+
waitPolicy: TBackgroundJobWaitPolicy;
|
|
647
|
+
taskIds: string[];
|
|
648
|
+
label?: string;
|
|
649
|
+
}
|
|
650
|
+
type TBackgroundJobGroupEvent = {
|
|
651
|
+
type: 'background_job_group_created';
|
|
652
|
+
group: IBackgroundJobGroupState;
|
|
660
653
|
} | {
|
|
661
|
-
type: '
|
|
662
|
-
|
|
654
|
+
type: 'background_job_group_updated';
|
|
655
|
+
group: IBackgroundJobGroupState;
|
|
663
656
|
} | {
|
|
664
|
-
type: '
|
|
665
|
-
|
|
657
|
+
type: 'background_job_group_completed';
|
|
658
|
+
group: IBackgroundJobGroupState;
|
|
666
659
|
};
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
extraKnownMarketplaces: Record<string, IPersistedMarketplaceSource>;
|
|
660
|
+
type TBackgroundJobGroupEventListener = (event: TBackgroundJobGroupEvent) => void;
|
|
661
|
+
type TBackgroundJobGroupIdFactory = (request: IBackgroundJobGroupCreateRequest) => string;
|
|
662
|
+
interface IBackgroundJobOrchestratorOptions {
|
|
663
|
+
manager: IBackgroundTaskManager;
|
|
664
|
+
now?: () => string;
|
|
665
|
+
idFactory?: TBackgroundJobGroupIdFactory;
|
|
666
|
+
initialGroups?: readonly IBackgroundJobGroupState[];
|
|
675
667
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
private readonly
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
private
|
|
682
|
-
|
|
683
|
-
private
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
private
|
|
697
|
-
private
|
|
668
|
+
declare class BackgroundJobOrchestrator {
|
|
669
|
+
private readonly manager;
|
|
670
|
+
private readonly now;
|
|
671
|
+
private readonly idFactory;
|
|
672
|
+
private readonly unsubscribeManager;
|
|
673
|
+
private readonly listeners;
|
|
674
|
+
private readonly groups;
|
|
675
|
+
private sequence;
|
|
676
|
+
constructor(options: IBackgroundJobOrchestratorOptions);
|
|
677
|
+
createGroup(request: IBackgroundJobGroupCreateRequest): IBackgroundJobGroupState;
|
|
678
|
+
listGroups(): IBackgroundJobGroupState[];
|
|
679
|
+
getGroup(groupId: string): IBackgroundJobGroupState | undefined;
|
|
680
|
+
waitGroup(groupId: string): Promise<IBackgroundJobGroupState>;
|
|
681
|
+
subscribe(listener: TBackgroundJobGroupEventListener): () => void;
|
|
682
|
+
dispose(): void;
|
|
683
|
+
private nextGroupId;
|
|
684
|
+
private restoreGroup;
|
|
685
|
+
private createRecord;
|
|
686
|
+
private captureExistingTerminalTasks;
|
|
687
|
+
private handleTaskEvent;
|
|
688
|
+
private captureTask;
|
|
689
|
+
private evaluateCompletion;
|
|
690
|
+
private emit;
|
|
698
691
|
}
|
|
692
|
+
declare function summarizeBackgroundJobGroup(group: IBackgroundJobGroupState): IBackgroundJobGroupSummary;
|
|
699
693
|
|
|
700
694
|
/**
|
|
701
|
-
* Types for
|
|
702
|
-
*
|
|
703
|
-
* A BundlePlugin is a directory-based plugin package that bundles
|
|
704
|
-
* skills, hooks, agents, and MCP server configurations.
|
|
695
|
+
* Types for InteractiveSession — event-driven session wrapper.
|
|
705
696
|
*/
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
697
|
+
|
|
698
|
+
/** Permission handler result — SDK-owned type (mirrors agent-sessions TPermissionResult).
|
|
699
|
+
* true = allow, false = deny, 'allow-session' = allow and remember for this session. */
|
|
700
|
+
type TPermissionResultValue = boolean | 'allow-session';
|
|
701
|
+
/** Tool execution state visible to clients. */
|
|
702
|
+
interface IToolState {
|
|
703
|
+
toolName: string;
|
|
704
|
+
firstArg: string;
|
|
705
|
+
isRunning: boolean;
|
|
706
|
+
result?: 'success' | 'error' | 'denied';
|
|
707
|
+
diffLines?: IDiffLine[];
|
|
708
|
+
diffFile?: string;
|
|
713
709
|
}
|
|
714
|
-
/**
|
|
715
|
-
interface
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
features: IBundlePluginFeatures;
|
|
710
|
+
/** A single diff line for Edit tool display. */
|
|
711
|
+
interface IDiffLine {
|
|
712
|
+
type: 'add' | 'remove' | 'context';
|
|
713
|
+
text: string;
|
|
714
|
+
lineNumber: number;
|
|
720
715
|
}
|
|
721
|
-
/**
|
|
722
|
-
interface
|
|
716
|
+
/** Result of a completed prompt execution. */
|
|
717
|
+
interface IExecutionResult {
|
|
718
|
+
response: string;
|
|
719
|
+
history: IHistoryEntry[];
|
|
720
|
+
toolSummaries: IToolSummary[];
|
|
721
|
+
contextState: IContextWindowState;
|
|
722
|
+
}
|
|
723
|
+
/** Summary of a tool call extracted from history. */
|
|
724
|
+
interface IToolSummary {
|
|
723
725
|
name: string;
|
|
724
|
-
|
|
725
|
-
skillContent: string;
|
|
726
|
-
[key: string]: unknown;
|
|
726
|
+
args: string;
|
|
727
727
|
}
|
|
728
|
-
/**
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
728
|
+
/** Permission handler delegate — clients provide their own UI. */
|
|
729
|
+
type TInteractivePermissionHandler = (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResultValue>;
|
|
730
|
+
/** Events emitted by InteractiveSession. */
|
|
731
|
+
interface IInteractiveSessionEvents {
|
|
732
|
+
text_delta: (delta: string) => void;
|
|
733
|
+
tool_start: (state: IToolState) => void;
|
|
734
|
+
tool_end: (state: IToolState) => void;
|
|
735
|
+
thinking: (isThinking: boolean) => void;
|
|
736
|
+
complete: (result: IExecutionResult) => void;
|
|
737
|
+
error: (error: Error) => void;
|
|
738
|
+
context_update: (state: IContextWindowState) => void;
|
|
739
|
+
interrupted: (result: IExecutionResult) => void;
|
|
740
|
+
background_task_event: (event: TBackgroundTaskEvent) => void;
|
|
741
|
+
background_job_group_event: (event: TBackgroundJobGroupEvent) => void;
|
|
737
742
|
}
|
|
738
|
-
|
|
739
|
-
type TEnabledPlugins = Record<string, boolean>;
|
|
740
|
-
|
|
743
|
+
type TInteractiveEventName = keyof IInteractiveSessionEvents;
|
|
741
744
|
/**
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
* Scans the cache directory (`<pluginsDir>/cache/<marketplace>/<plugin>/<version>/`)
|
|
745
|
-
* for subdirectories containing `.claude-plugin/plugin.json`,
|
|
746
|
-
* reads manifests, loads skills (with frontmatter parsing), hooks, and agent definitions.
|
|
747
|
-
*
|
|
748
|
-
* For each plugin, the latest version directory (lexicographically last) is loaded.
|
|
745
|
+
* Common interface for all transport adapters.
|
|
746
|
+
* Each transport exposes InteractiveSession over a specific protocol.
|
|
749
747
|
*/
|
|
750
|
-
|
|
751
|
-
/**
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
loadAll(): Promise<ILoadedBundlePlugin[]>;
|
|
760
|
-
/**
|
|
761
|
-
* Discover and load plugins from the cache directory.
|
|
762
|
-
*
|
|
763
|
-
* Directory structure: `<pluginsDir>/cache/<marketplace>/<plugin>/<version>/`
|
|
764
|
-
* For each marketplace/plugin pair, the latest version (lexicographically last) is loaded.
|
|
765
|
-
*/
|
|
766
|
-
private discoverAndLoad;
|
|
767
|
-
/** Read and validate a plugin.json manifest. Returns null on failure. */
|
|
768
|
-
private readManifest;
|
|
769
|
-
/**
|
|
770
|
-
* Check if a plugin is explicitly disabled.
|
|
771
|
-
* Checks both `name@marketplace` and `name` keys.
|
|
772
|
-
* Plugins not listed in enabledPlugins are enabled by default.
|
|
773
|
-
*/
|
|
774
|
-
private isDisabled;
|
|
775
|
-
/** Load a single plugin's skills, hooks, agents, and MCP config. */
|
|
776
|
-
private loadPlugin;
|
|
777
|
-
/** Load skills from the plugin's skills/ directory. */
|
|
778
|
-
private loadSkills;
|
|
779
|
-
/** Load commands from the plugin's commands/ directory (flat .md files). */
|
|
780
|
-
private loadCommands;
|
|
781
|
-
/** Load hooks from hooks/hooks.json if present. */
|
|
782
|
-
private loadHooks;
|
|
783
|
-
/** Load MCP server configuration if present. Checks `.mcp.json` at plugin root first. */
|
|
784
|
-
private loadMcpConfig;
|
|
785
|
-
/** Load agent definitions from agents/ directory if present. */
|
|
786
|
-
private loadAgents;
|
|
748
|
+
interface ITransportAdapter {
|
|
749
|
+
/** Human-readable transport name (e.g., 'http', 'ws', 'mcp', 'headless') */
|
|
750
|
+
readonly name: string;
|
|
751
|
+
/** Attach an InteractiveSession to this transport. */
|
|
752
|
+
attach(session: InteractiveSession): void;
|
|
753
|
+
/** Start serving. What this means depends on the transport. */
|
|
754
|
+
start(): Promise<void>;
|
|
755
|
+
/** Stop serving and clean up resources. */
|
|
756
|
+
stop(): Promise<void>;
|
|
787
757
|
}
|
|
788
758
|
|
|
789
759
|
/**
|
|
790
|
-
*
|
|
760
|
+
* Definition of an agent that can be spawned as a subagent.
|
|
761
|
+
*
|
|
762
|
+
* Built-in agents and custom (user-defined) agents share this shape.
|
|
763
|
+
* Optional fields inherit from the parent session when omitted.
|
|
791
764
|
*/
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
type: 'github';
|
|
795
|
-
repo: string;
|
|
796
|
-
ref?: string;
|
|
797
|
-
} | {
|
|
798
|
-
type: 'git';
|
|
799
|
-
url: string;
|
|
800
|
-
ref?: string;
|
|
801
|
-
} | {
|
|
802
|
-
type: 'local';
|
|
803
|
-
path: string;
|
|
804
|
-
} | {
|
|
805
|
-
type: 'url';
|
|
806
|
-
url: string;
|
|
807
|
-
};
|
|
808
|
-
/** A single plugin entry in a marketplace manifest. */
|
|
809
|
-
interface IMarketplacePluginEntry {
|
|
765
|
+
interface IAgentDefinition {
|
|
766
|
+
/** Unique name used to reference the agent (e.g., 'Explore', 'Plan'). */
|
|
810
767
|
name: string;
|
|
811
|
-
|
|
768
|
+
/** Human-readable description of the agent's purpose. */
|
|
812
769
|
description: string;
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
interface IMarketplaceManifest {
|
|
824
|
-
name: string;
|
|
825
|
-
version: string;
|
|
826
|
-
plugins: IMarketplacePluginEntry[];
|
|
827
|
-
}
|
|
828
|
-
/** Entry in known_marketplaces.json. */
|
|
829
|
-
interface IKnownMarketplaceEntry {
|
|
830
|
-
source: IMarketplaceSource;
|
|
831
|
-
installLocation: string;
|
|
832
|
-
lastUpdated: string;
|
|
833
|
-
}
|
|
834
|
-
/** Shape of known_marketplaces.json. */
|
|
835
|
-
type IKnownMarketplacesRegistry = Record<string, IKnownMarketplaceEntry>;
|
|
836
|
-
/** Exec function type for running shell commands. */
|
|
837
|
-
type ExecFn$1 = (command: string, options: {
|
|
838
|
-
timeout: number;
|
|
839
|
-
stdio?: string;
|
|
840
|
-
}) => string | Buffer;
|
|
841
|
-
/** Options for constructing a MarketplaceClient. */
|
|
842
|
-
interface IMarketplaceClientOptions {
|
|
843
|
-
/** Base plugins directory (e.g., `~/.robota/plugins`). */
|
|
844
|
-
pluginsDir: string;
|
|
845
|
-
/** Custom exec function for testing (replaces child_process.execSync). */
|
|
846
|
-
exec?: ExecFn$1;
|
|
770
|
+
/** Markdown body content used as the agent's system prompt. */
|
|
771
|
+
systemPrompt: string;
|
|
772
|
+
/** Model override (e.g., 'claude-haiku-4-5', 'sonnet', 'opus'). Inherits parent model when omitted. */
|
|
773
|
+
model?: string;
|
|
774
|
+
/** Maximum number of agentic turns the subagent may execute. */
|
|
775
|
+
maxTurns?: number;
|
|
776
|
+
/** Allowlist of tool names. Only these tools are available when set. */
|
|
777
|
+
tools?: string[];
|
|
778
|
+
/** Denylist of tool names. These tools are removed from the inherited set. */
|
|
779
|
+
disallowedTools?: string[];
|
|
847
780
|
}
|
|
848
781
|
|
|
849
782
|
/**
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
* Marketplaces are git repositories containing `.claude-plugin/marketplace.json`.
|
|
853
|
-
* They are cloned to `~/.robota/plugins/marketplaces/<name>/` and tracked
|
|
854
|
-
* in `known_marketplaces.json`.
|
|
783
|
+
* Zod schemas and TypeScript types for Robota CLI settings
|
|
855
784
|
*/
|
|
856
785
|
|
|
857
|
-
/**
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
/**
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
* 1. Shallow git clone (`--depth 1`) to `marketplaces/<name>/`.
|
|
868
|
-
* 2. Read `.claude-plugin/marketplace.json` for the `name` field.
|
|
869
|
-
* 3. Register in `known_marketplaces.json`.
|
|
870
|
-
*
|
|
871
|
-
* Returns the registered marketplace name from the manifest.
|
|
872
|
-
*/
|
|
873
|
-
addMarketplace(source: IMarketplaceSource): string;
|
|
874
|
-
/**
|
|
875
|
-
* Remove a marketplace.
|
|
876
|
-
* Uninstalls all plugins from that marketplace, then deletes the clone directory
|
|
877
|
-
* and removes from the registry.
|
|
878
|
-
*/
|
|
879
|
-
removeMarketplace(name: string): void;
|
|
880
|
-
/**
|
|
881
|
-
* Update a marketplace by running git pull on its clone.
|
|
882
|
-
* The manifest is re-read from disk on demand (via fetchManifest), so the
|
|
883
|
-
* updated manifest is automatically available after pull.
|
|
884
|
-
*/
|
|
885
|
-
updateMarketplace(name: string): void;
|
|
886
|
-
/** List all registered marketplaces. */
|
|
887
|
-
listMarketplaces(): Array<{
|
|
786
|
+
/**
|
|
787
|
+
* Fully resolved config after merging all settings files and applying defaults.
|
|
788
|
+
*/
|
|
789
|
+
interface IResolvedConfig {
|
|
790
|
+
defaultTrustLevel: 'safe' | 'moderate' | 'full';
|
|
791
|
+
/** Response language code (e.g., "ko", "en"). Undefined = no language constraint. */
|
|
792
|
+
language?: string;
|
|
793
|
+
/** Active provider profile key when providers/currentProvider are used. */
|
|
794
|
+
currentProvider?: string;
|
|
795
|
+
provider: {
|
|
888
796
|
name: string;
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
797
|
+
model: string;
|
|
798
|
+
apiKey: string | undefined;
|
|
799
|
+
baseURL?: string;
|
|
800
|
+
timeout?: number;
|
|
801
|
+
};
|
|
802
|
+
permissions: {
|
|
803
|
+
allow: string[];
|
|
804
|
+
deny: string[];
|
|
805
|
+
};
|
|
806
|
+
env: Record<string, string>;
|
|
807
|
+
hooks?: THooksConfig;
|
|
808
|
+
/** Plugin enablement map: plugin name -> enabled/disabled */
|
|
809
|
+
enabledPlugins?: Record<string, boolean>;
|
|
810
|
+
/** Extra marketplace sources: name -> { source } */
|
|
811
|
+
extraKnownMarketplaces?: Record<string, {
|
|
812
|
+
source: {
|
|
813
|
+
type: string;
|
|
814
|
+
repo?: string;
|
|
815
|
+
url?: string;
|
|
816
|
+
path?: string;
|
|
817
|
+
ref?: string;
|
|
818
|
+
};
|
|
904
819
|
}>;
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
interface ILoadedContext {
|
|
823
|
+
/** Concatenated content of all AGENTS.md files found (root-first) */
|
|
824
|
+
agentsMd: string;
|
|
825
|
+
/** Concatenated content of all CLAUDE.md files found (root-first) */
|
|
826
|
+
claudeMd: string;
|
|
827
|
+
/** Extracted "Compact Instructions" section from CLAUDE.md, if present */
|
|
828
|
+
compactInstructions?: string;
|
|
911
829
|
}
|
|
912
830
|
|
|
913
831
|
/**
|
|
914
|
-
*
|
|
832
|
+
* Subagent session factory — assembles an isolated child Session for subagent execution.
|
|
915
833
|
*
|
|
916
|
-
*
|
|
917
|
-
*
|
|
834
|
+
* Unlike `createSession`, this factory does not load config files or context from disk.
|
|
835
|
+
* It receives pre-resolved config and context from the parent session, applies tool
|
|
836
|
+
* filtering and model resolution from the agent definition, and creates a lightweight
|
|
837
|
+
* Session suitable for subagent use.
|
|
918
838
|
*/
|
|
919
839
|
|
|
920
|
-
/**
|
|
921
|
-
interface
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
840
|
+
/** Options for creating a subagent session. */
|
|
841
|
+
interface ISubagentOptions {
|
|
842
|
+
/** Agent definition (built-in or custom). */
|
|
843
|
+
agentDefinition: IAgentDefinition;
|
|
844
|
+
/** Parent's resolved config (for provider, permissions, etc.). */
|
|
845
|
+
parentConfig: IResolvedConfig;
|
|
846
|
+
/** Parent's loaded context (CLAUDE.md, AGENTS.md). */
|
|
847
|
+
parentContext: ILoadedContext;
|
|
848
|
+
/** Parent session's available tools (to inherit/filter). */
|
|
849
|
+
parentTools: IToolWithEventService[];
|
|
850
|
+
/** AI provider instance. */
|
|
851
|
+
provider: IAIProvider;
|
|
852
|
+
/** Terminal output interface. */
|
|
853
|
+
terminal: ITerminalOutput;
|
|
854
|
+
/** Stable session ID for transcript files. */
|
|
855
|
+
sessionId?: string;
|
|
856
|
+
/** Optional logger for subagent transcripts. */
|
|
857
|
+
sessionLogger?: ISessionLogger;
|
|
858
|
+
/** Whether this is a fork worker (uses fork suffix instead of standard). */
|
|
859
|
+
isForkWorker?: boolean;
|
|
860
|
+
/** Permission mode from parent (bypassPermissions, acceptEdits, etc.). */
|
|
861
|
+
permissionMode?: TPermissionMode;
|
|
862
|
+
/** Permission handler from parent. */
|
|
863
|
+
permissionHandler?: TPermissionHandler;
|
|
864
|
+
/** Plugin hooks configuration from parent session. */
|
|
865
|
+
hooks?: Record<string, unknown>;
|
|
866
|
+
/** Hook type executors from parent session (prompt, agent, etc.). */
|
|
867
|
+
hookTypeExecutors?: IHookTypeExecutor[];
|
|
868
|
+
/** Streaming callback. */
|
|
869
|
+
onTextDelta?: (delta: string) => void;
|
|
870
|
+
/** Tool execution callback. */
|
|
871
|
+
onToolExecution?: (event: {
|
|
872
|
+
type: 'start' | 'end';
|
|
873
|
+
toolName: string;
|
|
874
|
+
toolArgs?: TToolArgs;
|
|
875
|
+
success?: boolean;
|
|
876
|
+
}) => void;
|
|
927
877
|
}
|
|
928
|
-
/**
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
interface
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
878
|
+
/**
|
|
879
|
+
* Create a fully-configured Session for subagent execution.
|
|
880
|
+
*
|
|
881
|
+
* Assembles provider, tools, and system prompt from parent context and
|
|
882
|
+
* agent definition, then returns a new Session instance.
|
|
883
|
+
*/
|
|
884
|
+
declare function createSubagentSession(options: ISubagentOptions): Session;
|
|
885
|
+
|
|
886
|
+
interface IInProcessSubagentRunnerDeps {
|
|
887
|
+
config: IResolvedConfig;
|
|
888
|
+
context: ILoadedContext;
|
|
889
|
+
tools: IToolWithEventService[];
|
|
890
|
+
terminal: ITerminalOutput;
|
|
891
|
+
provider: IAIProvider;
|
|
892
|
+
permissionMode?: TPermissionMode;
|
|
893
|
+
permissionHandler?: TPermissionHandler;
|
|
894
|
+
hooks?: ISubagentOptions['hooks'];
|
|
895
|
+
hookTypeExecutors?: IHookTypeExecutor[];
|
|
896
|
+
onTextDelta?: (delta: string) => void;
|
|
897
|
+
onToolExecution?: (event: {
|
|
898
|
+
type: 'start' | 'end';
|
|
899
|
+
toolName: string;
|
|
900
|
+
toolArgs?: TToolArgs;
|
|
901
|
+
success?: boolean;
|
|
902
|
+
}) => void;
|
|
903
|
+
customAgentRegistry?: (name: string) => IAgentDefinition | undefined;
|
|
945
904
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
905
|
+
type TSubagentRunnerFactory = (deps: IInProcessSubagentRunnerDeps) => ISubagentRunner;
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Prompt hook executor — evaluates a prompt via an AI model.
|
|
909
|
+
*
|
|
910
|
+
* Makes a single-turn LLM call with hook input context as the prompt.
|
|
911
|
+
* Parses { ok: boolean, reason?: string } from the AI response.
|
|
912
|
+
*
|
|
913
|
+
* Exit codes:
|
|
914
|
+
* - 0: ok: true (allow/proceed)
|
|
915
|
+
* - 2: ok: false (block/deny), reason in stderr
|
|
916
|
+
* - 1: execution error (provider failure, parse error)
|
|
917
|
+
*/
|
|
918
|
+
|
|
919
|
+
/** A minimal provider interface for single-turn completion. */
|
|
920
|
+
interface IPromptProvider {
|
|
921
|
+
complete(prompt: string): Promise<string>;
|
|
922
|
+
}
|
|
923
|
+
/** Factory that creates a provider instance, optionally for a specific model. */
|
|
924
|
+
type TProviderFactory = (model?: string) => IPromptProvider;
|
|
925
|
+
/** Constructor options for PromptExecutor. */
|
|
926
|
+
interface IPromptExecutorOptions {
|
|
927
|
+
providerFactory: TProviderFactory;
|
|
928
|
+
defaultModel?: string;
|
|
929
|
+
}
|
|
930
|
+
declare class PromptExecutor implements IHookTypeExecutor {
|
|
931
|
+
readonly type: "prompt";
|
|
932
|
+
private readonly providerFactory;
|
|
933
|
+
private readonly defaultModel;
|
|
934
|
+
constructor(options: IPromptExecutorOptions);
|
|
935
|
+
execute(definition: IHookDefinition, input: IHookInput): Promise<IHookResult>;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Agent hook executor — delegates to a sub-agent session.
|
|
940
|
+
*
|
|
941
|
+
* Creates a subagent session with maxTurns and timeout limits,
|
|
942
|
+
* runs hook input as the initial prompt, and parses the result.
|
|
943
|
+
*
|
|
944
|
+
* Exit codes:
|
|
945
|
+
* - 0: ok: true (allow/proceed)
|
|
946
|
+
* - 2: ok: false (block/deny), reason in stderr
|
|
947
|
+
* - 1: execution error (session failure, parse error)
|
|
948
|
+
*/
|
|
949
|
+
|
|
950
|
+
/** A minimal session interface for running a prompt. */
|
|
951
|
+
interface IAgentSession {
|
|
952
|
+
run(prompt: string): Promise<string>;
|
|
953
|
+
}
|
|
954
|
+
/** Factory that creates a session instance with the given options. */
|
|
955
|
+
type TSessionFactory = (options: {
|
|
956
|
+
maxTurns?: number;
|
|
957
|
+
timeout?: number;
|
|
958
|
+
}) => IAgentSession;
|
|
959
|
+
/** Constructor options for AgentExecutor. */
|
|
960
|
+
interface IAgentExecutorOptions {
|
|
961
|
+
sessionFactory: TSessionFactory;
|
|
962
|
+
}
|
|
963
|
+
declare class AgentExecutor implements IHookTypeExecutor {
|
|
964
|
+
readonly type: "agent";
|
|
965
|
+
private readonly sessionFactory;
|
|
966
|
+
constructor(options: IAgentExecutorOptions);
|
|
967
|
+
execute(definition: IHookDefinition, input: IHookInput): Promise<IHookResult>;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
type TProjectType = 'node' | 'python' | 'rust' | 'go' | 'unknown';
|
|
971
|
+
type TPackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';
|
|
972
|
+
type TLanguage = 'typescript' | 'javascript' | 'python' | 'rust' | 'go' | 'unknown';
|
|
973
|
+
interface IProjectInfo {
|
|
974
|
+
type: TProjectType;
|
|
975
|
+
name?: string;
|
|
976
|
+
packageManager?: TPackageManager;
|
|
977
|
+
language: TLanguage;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
interface ISystemPromptParams {
|
|
981
|
+
/** Concatenated AGENTS.md content (may be empty string) */
|
|
982
|
+
agentsMd: string;
|
|
983
|
+
/** Concatenated CLAUDE.md content (may be empty string) */
|
|
984
|
+
claudeMd: string;
|
|
985
|
+
/** Human-readable tool descriptions, one per entry */
|
|
986
|
+
toolDescriptions: string[];
|
|
987
|
+
/** Active trust level governing permission checks */
|
|
988
|
+
trustLevel: TTrustLevel;
|
|
989
|
+
/** Detected project metadata */
|
|
990
|
+
projectInfo: IProjectInfo;
|
|
991
|
+
/** Current working directory */
|
|
992
|
+
cwd?: string;
|
|
993
|
+
/** Response language code (e.g., "ko", "en"). If set, AI must respond in this language. */
|
|
994
|
+
language?: string;
|
|
995
|
+
/** Discovered skills to expose in the system prompt */
|
|
996
|
+
skills?: Array<{
|
|
997
|
+
name: string;
|
|
998
|
+
description: string;
|
|
999
|
+
disableModelInvocation?: boolean;
|
|
1000
|
+
}>;
|
|
1001
|
+
/** Discovered agents to expose in the system prompt */
|
|
1002
|
+
agents?: Array<{
|
|
1003
|
+
name: string;
|
|
1004
|
+
description: string;
|
|
1005
|
+
}>;
|
|
1006
|
+
/** Command descriptors to expose to the model */
|
|
1007
|
+
commandDescriptors?: ICapabilityDescriptor[];
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* Session factory — assembles a fully-configured Session from config, context,
|
|
1012
|
+
* tools, and provider.
|
|
1013
|
+
*
|
|
1014
|
+
* This is the main entry point for creating sessions. It wires together
|
|
1015
|
+
* the provider, tools, system prompt, and configuration that Session now
|
|
1016
|
+
* expects as pre-constructed dependencies.
|
|
1017
|
+
*/
|
|
1018
|
+
|
|
1019
|
+
/** Options for the createSession factory */
|
|
1020
|
+
interface ICreateSessionOptions {
|
|
1021
|
+
/** Resolved CLI configuration (model, API key, permissions) */
|
|
1022
|
+
config: IResolvedConfig;
|
|
1023
|
+
/** Working directory used for project context, skills, and agent definitions. */
|
|
1024
|
+
cwd?: string;
|
|
1025
|
+
/** Loaded AGENTS.md / CLAUDE.md context */
|
|
1026
|
+
context: ILoadedContext;
|
|
1027
|
+
/** Terminal I/O for permission prompts */
|
|
1028
|
+
terminal: ITerminalOutput;
|
|
1029
|
+
/** Project metadata for system prompt */
|
|
1030
|
+
projectInfo?: IProjectInfo;
|
|
1031
|
+
/** Initial permission mode (defaults to config.defaultTrustLevel → mode mapping) */
|
|
1032
|
+
permissionMode?: TPermissionMode;
|
|
1033
|
+
/** Maximum number of agentic turns per run() call. Undefined = unlimited. */
|
|
1034
|
+
maxTurns?: number;
|
|
1035
|
+
/** Optional session store for persistence */
|
|
1036
|
+
sessionStore?: SessionStore;
|
|
1037
|
+
/** Inject a pre-constructed AI provider (used by tests to avoid real API calls) */
|
|
1038
|
+
provider?: IAIProvider;
|
|
1039
|
+
/** Custom permission handler (overrides terminal-based prompts, used by Ink UI) */
|
|
1040
|
+
permissionHandler?: TPermissionHandler;
|
|
1041
|
+
/** Callback for text deltas — enables streaming text to the UI in real-time */
|
|
1042
|
+
onTextDelta?: (delta: string) => void;
|
|
1043
|
+
/** Custom prompt-for-approval function (injected from CLI) */
|
|
1044
|
+
promptForApproval?: (terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
|
|
1045
|
+
/** Additional tools to register beyond the defaults (e.g. agent-tool) */
|
|
1046
|
+
additionalTools?: IToolWithEventService[];
|
|
1047
|
+
/** Additional background task runners composed by the runtime shell. */
|
|
1048
|
+
backgroundTaskRunners?: IBackgroundTaskRunner[];
|
|
1049
|
+
/** Runtime shell override for subagent execution. Defaults to the SDK in-process runner. */
|
|
1050
|
+
subagentRunnerFactory?: TSubagentRunnerFactory;
|
|
1051
|
+
/** Enable agent tool, agent definitions, and subagent runtime wiring for this session. */
|
|
1052
|
+
enableAgentRuntime?: boolean;
|
|
1053
|
+
/** Callback when a tool starts or finishes execution — enables real-time tool display in UI */
|
|
1054
|
+
onToolExecution?: (event: {
|
|
1055
|
+
type: 'start' | 'end';
|
|
1056
|
+
toolName: string;
|
|
1057
|
+
toolArgs?: TToolArgs;
|
|
1058
|
+
success?: boolean;
|
|
1059
|
+
}) => void;
|
|
1060
|
+
/** Callback when context is compacted */
|
|
1061
|
+
onCompact?: (summary: string) => void;
|
|
1062
|
+
/** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
|
|
1063
|
+
compactInstructions?: string;
|
|
1064
|
+
/** Custom system prompt builder function */
|
|
1065
|
+
systemPromptBuilder?: (params: ISystemPromptParams) => string;
|
|
1066
|
+
/** Custom tool descriptions for the system prompt */
|
|
1067
|
+
toolDescriptions?: string[];
|
|
1068
|
+
/** Session logger — injected for pluggable session event logging. */
|
|
1069
|
+
sessionLogger?: ISessionLogger;
|
|
1070
|
+
/** Provider factory for prompt hook executors (DI). */
|
|
1071
|
+
providerFactory?: TProviderFactory;
|
|
1072
|
+
/** Session factory for agent hook executors (DI). */
|
|
1073
|
+
sessionFactory?: TSessionFactory;
|
|
1074
|
+
/** Additional hook type executors beyond the defaults (prompt, agent). */
|
|
1075
|
+
additionalHookExecutors?: IHookTypeExecutor[];
|
|
1076
|
+
/** Override session ID (used when resuming a session to reuse the original ID) */
|
|
1077
|
+
sessionId?: string;
|
|
1078
|
+
/** Pre-approved tool names — added to permissions.allow as ToolName(*) patterns. */
|
|
1079
|
+
allowedTools?: string[];
|
|
1080
|
+
/** Text to append to the generated system prompt. */
|
|
1081
|
+
appendSystemPrompt?: string;
|
|
1082
|
+
/** Model command execution bridge. */
|
|
1083
|
+
modelCommandExecutor?: (command: string, args: string) => Promise<ICommandResult | null>;
|
|
1084
|
+
/** Predicate for commands allowed through the model command execution bridge. */
|
|
1085
|
+
isModelCommandInvocable?: (command: string) => boolean;
|
|
1086
|
+
/** Model-visible command descriptors. */
|
|
1087
|
+
commandDescriptors?: ICapabilityDescriptor[];
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Default tool set factory — creates the standard set of CLI tools.
|
|
1092
|
+
*/
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Create the default set of CLI tools.
|
|
1096
|
+
* Returns the 8 standard tools as IToolWithEventService[].
|
|
1097
|
+
*/
|
|
1098
|
+
declare function createDefaultTools(): IToolWithEventService[];
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Framework system prompt suffixes for subagent sessions.
|
|
1102
|
+
*
|
|
1103
|
+
* These functions generate the standard prompt content injected into
|
|
1104
|
+
* subagent sessions to control output format and behavior.
|
|
1105
|
+
*/
|
|
1106
|
+
/** Options for assembling a subagent system prompt. */
|
|
1107
|
+
interface ISubagentPromptOptions {
|
|
1108
|
+
/** Agent definition markdown body. */
|
|
1109
|
+
agentBody: string;
|
|
1110
|
+
/** CLAUDE.md content to include. */
|
|
1111
|
+
claudeMd?: string;
|
|
1112
|
+
/** AGENTS.md content to include. */
|
|
1113
|
+
agentsMd?: string;
|
|
1114
|
+
/** When true, use fork worker suffix instead of standard subagent suffix. */
|
|
1115
|
+
isForkWorker: boolean;
|
|
994
1116
|
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Returns the standard subagent suffix appended to agent body for normal subagents.
|
|
1119
|
+
*/
|
|
1120
|
+
declare function getSubagentSuffix(): string;
|
|
1121
|
+
/**
|
|
1122
|
+
* Returns the fork worker suffix for context:fork skill workers.
|
|
1123
|
+
*/
|
|
1124
|
+
declare function getForkWorkerSuffix(): string;
|
|
1125
|
+
/**
|
|
1126
|
+
* Assembles the full system prompt for a subagent.
|
|
1127
|
+
*
|
|
1128
|
+
* Assembly order:
|
|
1129
|
+
* 1. Agent definition body
|
|
1130
|
+
* 2. CLAUDE.md content (if provided)
|
|
1131
|
+
* 3. AGENTS.md content (if provided)
|
|
1132
|
+
* 4. Framework suffix (fork worker OR standard subagent)
|
|
1133
|
+
*/
|
|
1134
|
+
declare function assembleSubagentPrompt(options: ISubagentPromptOptions): string;
|
|
995
1135
|
|
|
996
1136
|
/**
|
|
997
|
-
*
|
|
1137
|
+
* Subagent transcript logger — creates a FileSessionLogger that writes
|
|
1138
|
+
* subagent session logs into a subdirectory of the parent session's log folder.
|
|
998
1139
|
*
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1140
|
+
* Log structure:
|
|
1141
|
+
* {baseLogsDir}/{parentSessionId}/subagents/{agentId}.jsonl
|
|
1001
1142
|
*/
|
|
1002
|
-
declare class PluginCommandSource implements ICommandSource {
|
|
1003
|
-
readonly name = "plugin";
|
|
1004
|
-
private readonly plugins;
|
|
1005
|
-
constructor(plugins: ILoadedBundlePlugin[]);
|
|
1006
|
-
getCommands(): ICommand[];
|
|
1007
|
-
}
|
|
1008
1143
|
|
|
1009
1144
|
/**
|
|
1010
|
-
*
|
|
1145
|
+
* Create a FileSessionLogger for a subagent session.
|
|
1011
1146
|
*
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1147
|
+
* The logger writes JSONL files into a `subagents/` subdirectory under the
|
|
1148
|
+
* parent session's log folder. The directory is created if it does not exist.
|
|
1149
|
+
*
|
|
1150
|
+
* @param parentSessionId - ID of the parent session (used as directory name)
|
|
1151
|
+
* @param agentId - Unique identifier for this subagent run
|
|
1152
|
+
* @param baseLogsDir - Root logs directory (e.g., `.robota/logs`)
|
|
1153
|
+
* @returns A FileSessionLogger writing to the subagent directory
|
|
1015
1154
|
*/
|
|
1155
|
+
declare function createSubagentLogger(parentSessionId: string, _agentId: string, baseLogsDir: string): FileSessionLogger;
|
|
1156
|
+
/**
|
|
1157
|
+
* Resolve the subagent log directory path without creating it.
|
|
1158
|
+
*
|
|
1159
|
+
* Useful when the caller needs the path for display or configuration
|
|
1160
|
+
* but does not want to create the directory immediately.
|
|
1161
|
+
*
|
|
1162
|
+
* @param parentSessionId - ID of the parent session
|
|
1163
|
+
* @param baseLogsDir - Root logs directory
|
|
1164
|
+
* @returns The resolved subagent log directory path
|
|
1165
|
+
*/
|
|
1166
|
+
declare function resolveSubagentLogDir(parentSessionId: string, baseLogsDir: string): string;
|
|
1016
1167
|
|
|
1017
|
-
/**
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1168
|
+
/**
|
|
1169
|
+
* Session initialization helpers for InteractiveSession.
|
|
1170
|
+
*
|
|
1171
|
+
* Handles async config/context loading, plugin merging, and session creation.
|
|
1172
|
+
* Also provides session-restore (resume/fork) logic.
|
|
1173
|
+
*/
|
|
1174
|
+
|
|
1175
|
+
/** Standard construction: cwd + provider. Config/context loaded internally. */
|
|
1176
|
+
interface IInteractiveSessionStandardOptions {
|
|
1177
|
+
cwd: string;
|
|
1178
|
+
provider: IAIProvider;
|
|
1179
|
+
permissionMode?: ICreateSessionOptions['permissionMode'];
|
|
1180
|
+
maxTurns?: number;
|
|
1181
|
+
permissionHandler?: TInteractivePermissionHandler;
|
|
1182
|
+
sessionStore?: SessionStore;
|
|
1183
|
+
sessionName?: string;
|
|
1184
|
+
resumeSessionId?: string;
|
|
1185
|
+
forkSession?: boolean;
|
|
1186
|
+
/** Skip AGENTS.md/CLAUDE.md loading and plugin discovery. */
|
|
1187
|
+
bare?: boolean;
|
|
1188
|
+
/** Pre-approved tool names passed to createSession. */
|
|
1189
|
+
allowedTools?: string[];
|
|
1190
|
+
/** Text to append to the system prompt. */
|
|
1191
|
+
appendSystemPrompt?: string;
|
|
1192
|
+
/** Runtime-composed background task runners. */
|
|
1193
|
+
backgroundTaskRunners?: IBackgroundTaskRunner[];
|
|
1194
|
+
/** Runtime shell override for subagent execution. */
|
|
1195
|
+
subagentRunnerFactory?: TSubagentRunnerFactory;
|
|
1196
|
+
/** Optional command modules composed into this session. */
|
|
1197
|
+
commandModules?: readonly ICommandModule[];
|
|
1198
|
+
/** Model-visible command descriptors derived from the composed command executor. */
|
|
1199
|
+
commandDescriptors?: readonly ICapabilityDescriptor[];
|
|
1200
|
+
/** Model command execution bridge. */
|
|
1201
|
+
modelCommandExecutor?: (command: string, args: string) => Promise<ICommandResult | null>;
|
|
1202
|
+
/** Predicate for commands allowed through the model command execution bridge. */
|
|
1203
|
+
isModelCommandInvocable?: (command: string) => boolean;
|
|
1025
1204
|
}
|
|
1026
|
-
/**
|
|
1027
|
-
interface
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1205
|
+
/** Test/advanced construction: inject pre-built session directly. */
|
|
1206
|
+
interface IInteractiveSessionInjectedOptions {
|
|
1207
|
+
session: Session;
|
|
1208
|
+
cwd?: string;
|
|
1209
|
+
provider?: IAIProvider;
|
|
1210
|
+
permissionMode?: ICreateSessionOptions['permissionMode'];
|
|
1211
|
+
maxTurns?: number;
|
|
1212
|
+
permissionHandler?: TInteractivePermissionHandler;
|
|
1213
|
+
sessionStore?: SessionStore;
|
|
1214
|
+
sessionName?: string;
|
|
1215
|
+
resumeSessionId?: string;
|
|
1216
|
+
forkSession?: boolean;
|
|
1217
|
+
/** Optional command modules composed into this injected session. */
|
|
1218
|
+
commandModules?: readonly ICommandModule[];
|
|
1031
1219
|
}
|
|
1220
|
+
/** Union of standard and injected construction options. */
|
|
1221
|
+
type IInteractiveSessionOptions = IInteractiveSessionStandardOptions | IInteractiveSessionInjectedOptions;
|
|
1032
1222
|
|
|
1033
1223
|
/**
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1224
|
+
* InteractiveSession — the single entry point for all SDK consumers.
|
|
1225
|
+
*
|
|
1226
|
+
* Wraps Session (composition). Manages streaming text accumulation,
|
|
1227
|
+
* tool execution state tracking, prompt queuing, abort orchestration,
|
|
1228
|
+
* message history, and system command execution.
|
|
1229
|
+
*
|
|
1230
|
+
* Config/context loading is internal. Consumer provides cwd + provider.
|
|
1036
1231
|
*/
|
|
1037
1232
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1233
|
+
interface IInteractiveSessionShutdownOptions {
|
|
1234
|
+
reason?: TSessionEndReason;
|
|
1235
|
+
message?: string;
|
|
1236
|
+
}
|
|
1237
|
+
declare class InteractiveSession {
|
|
1238
|
+
private session;
|
|
1239
|
+
private readonly commandExecutor;
|
|
1240
|
+
private readonly listeners;
|
|
1241
|
+
private initialized;
|
|
1242
|
+
private initPromise;
|
|
1243
|
+
private streamingText;
|
|
1244
|
+
private flushTimer;
|
|
1245
|
+
private activeTools;
|
|
1246
|
+
private executing;
|
|
1247
|
+
private pendingPrompt;
|
|
1248
|
+
private pendingDisplayInput;
|
|
1249
|
+
private pendingRawInput;
|
|
1250
|
+
private history;
|
|
1251
|
+
private sessionStore?;
|
|
1252
|
+
private sessionName?;
|
|
1253
|
+
private cwd?;
|
|
1254
|
+
private pendingRestoreMessages;
|
|
1255
|
+
private backgroundTasks;
|
|
1256
|
+
private backgroundTaskEvents;
|
|
1257
|
+
private backgroundJobGroups;
|
|
1258
|
+
private backgroundJobGroupEvents;
|
|
1259
|
+
private resumeSessionId?;
|
|
1260
|
+
private forkSession;
|
|
1261
|
+
private backgroundTaskUnsubscribe;
|
|
1262
|
+
private backgroundJobUnsubscribe;
|
|
1263
|
+
private backgroundJobOrchestrator;
|
|
1264
|
+
private readonly commandModules;
|
|
1265
|
+
private shuttingDown;
|
|
1266
|
+
private shutdownPromise;
|
|
1267
|
+
constructor(options: IInteractiveSessionOptions);
|
|
1268
|
+
private initializeAsync;
|
|
1269
|
+
private ensureInitialized;
|
|
1270
|
+
private getSessionOrThrow;
|
|
1271
|
+
on<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
1272
|
+
off<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
1273
|
+
private emit;
|
|
1274
|
+
submit(input: string, displayInput?: string, rawInput?: string): Promise<void>;
|
|
1275
|
+
executeCommand(name: string, args: string): Promise<{
|
|
1276
|
+
message: string;
|
|
1277
|
+
success: boolean;
|
|
1278
|
+
data?: Record<string, unknown>;
|
|
1279
|
+
} | null>;
|
|
1280
|
+
executeModelCommand(name: string, args: string): Promise<{
|
|
1281
|
+
message: string;
|
|
1282
|
+
success: boolean;
|
|
1283
|
+
data?: Record<string, unknown>;
|
|
1284
|
+
} | null>;
|
|
1285
|
+
executeSkillCommand(skill: ICommand, args: string, displayInput?: string, rawInput?: string): Promise<ISkillExecutionResult>;
|
|
1286
|
+
listCommands(): Array<{
|
|
1287
|
+
name: string;
|
|
1288
|
+
description: string;
|
|
1289
|
+
}>;
|
|
1290
|
+
listModelInvocableCommands(): Array<{
|
|
1291
|
+
name: string;
|
|
1292
|
+
description: string;
|
|
1293
|
+
}>;
|
|
1294
|
+
abort(): void;
|
|
1295
|
+
shutdown(options?: IInteractiveSessionShutdownOptions): Promise<void>;
|
|
1296
|
+
cancelQueue(): void;
|
|
1297
|
+
private clearPendingQueue;
|
|
1298
|
+
isExecuting(): boolean;
|
|
1299
|
+
getPendingPrompt(): string | null;
|
|
1300
|
+
getFullHistory(): IHistoryEntry[];
|
|
1301
|
+
getMessages(): TUniversalMessage[];
|
|
1302
|
+
getStreamingText(): string;
|
|
1303
|
+
getActiveTools(): IToolState[];
|
|
1304
|
+
getContextState(): IContextWindowState;
|
|
1305
|
+
getName(): string | undefined;
|
|
1306
|
+
getSession(): Session;
|
|
1307
|
+
listBackgroundTasks(filter?: IBackgroundTaskListFilter): IBackgroundTaskState[];
|
|
1308
|
+
getBackgroundTask(taskId: string): IBackgroundTaskState | undefined;
|
|
1309
|
+
cancelBackgroundTask(taskId: string, reason?: string): Promise<void>;
|
|
1310
|
+
closeBackgroundTask(taskId: string): Promise<void>;
|
|
1311
|
+
sendBackgroundTask(taskId: string, input: IBackgroundTaskInput): Promise<void>;
|
|
1312
|
+
readBackgroundTaskLog(taskId: string, cursor?: IBackgroundTaskLogCursor): Promise<IBackgroundTaskLogPage>;
|
|
1313
|
+
createBackgroundJobGroup(input: Omit<IBackgroundJobGroupCreateRequest, 'parentSessionId'>): IBackgroundJobGroupState;
|
|
1314
|
+
listBackgroundJobGroups(): IBackgroundJobGroupState[];
|
|
1315
|
+
getBackgroundJobGroup(groupId: string): IBackgroundJobGroupState | undefined;
|
|
1316
|
+
waitBackgroundJobGroup(groupId: string): Promise<IBackgroundJobGroupState>;
|
|
1317
|
+
listAgentDefinitions(): Array<{
|
|
1318
|
+
name: string;
|
|
1319
|
+
description: string;
|
|
1320
|
+
}>;
|
|
1321
|
+
listAgentJobs(): ISubagentJobState[];
|
|
1322
|
+
spawnAgentJob(input: {
|
|
1323
|
+
agentType: string;
|
|
1324
|
+
label: string;
|
|
1325
|
+
mode: 'foreground' | 'background';
|
|
1326
|
+
prompt: string;
|
|
1327
|
+
model?: string;
|
|
1328
|
+
isolation?: TBackgroundTaskIsolation;
|
|
1329
|
+
}): Promise<ISubagentJobState>;
|
|
1330
|
+
waitAgentJob(jobId: string): Promise<ISubagentJobResult>;
|
|
1331
|
+
sendAgentJob(jobId: string, prompt: string): Promise<void>;
|
|
1332
|
+
cancelAgentJob(jobId: string, reason?: string): Promise<void>;
|
|
1333
|
+
closeAgentJob(jobId: string): Promise<void>;
|
|
1334
|
+
setName(name: string): void;
|
|
1335
|
+
attachTransport(transport: ITransportAdapter): void;
|
|
1336
|
+
private executeForkSkillCommand;
|
|
1337
|
+
private getBackgroundTaskManagerOrThrow;
|
|
1338
|
+
private getBackgroundTaskManager;
|
|
1339
|
+
private getBackgroundJobOrchestratorOrThrow;
|
|
1340
|
+
private getAgentToolDepsOrThrow;
|
|
1341
|
+
private getSubagentManagerOrThrow;
|
|
1342
|
+
private resolveAgentDefinition;
|
|
1343
|
+
private subscribeBackgroundTaskEvents;
|
|
1344
|
+
private subscribeBackgroundJobGroupEvents;
|
|
1345
|
+
private recordBackgroundTaskEvent;
|
|
1346
|
+
private recordBackgroundJobGroupEvent;
|
|
1347
|
+
private getBackgroundTaskSnapshots;
|
|
1348
|
+
private getBackgroundJobGroupSnapshots;
|
|
1349
|
+
private persistCurrentSession;
|
|
1350
|
+
private startForkSkillExecution;
|
|
1351
|
+
private finishForkSkillExecution;
|
|
1352
|
+
private recordForkSkillError;
|
|
1353
|
+
private resolveForkAgentDefinition;
|
|
1354
|
+
private runSkillInFork;
|
|
1355
|
+
private applyForkSkillResult;
|
|
1356
|
+
private executePrompt;
|
|
1357
|
+
private handleTextDelta;
|
|
1358
|
+
private handleToolExecution;
|
|
1359
|
+
private clearStreaming;
|
|
1360
|
+
private flushStreaming;
|
|
1044
1361
|
}
|
|
1362
|
+
|
|
1045
1363
|
/**
|
|
1046
|
-
*
|
|
1364
|
+
* createQuery() — factory that returns a prompt-only convenience function.
|
|
1047
1365
|
*
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1051
|
-
* - `$N` — shorthand for `$ARGUMENTS[N]` (single digit, 0-9)
|
|
1052
|
-
* - `${CLAUDE_SESSION_ID}` — current session ID
|
|
1053
|
-
* - `${CLAUDE_SKILL_DIR}` — directory containing SKILL.md
|
|
1366
|
+
* Usage:
|
|
1367
|
+
* const query = createQuery({ provider });
|
|
1368
|
+
* const answer = await query('What files are here?');
|
|
1054
1369
|
*/
|
|
1055
|
-
|
|
1370
|
+
|
|
1371
|
+
interface ICreateQueryOptions {
|
|
1372
|
+
/** AI provider instance (required). */
|
|
1373
|
+
provider: IAIProvider;
|
|
1374
|
+
/** Working directory. Defaults to process.cwd(). */
|
|
1375
|
+
cwd?: string;
|
|
1376
|
+
/** Permission mode. Defaults to 'bypassPermissions' for programmatic use. */
|
|
1377
|
+
permissionMode?: TPermissionMode;
|
|
1378
|
+
/** Maximum agentic turns per query. */
|
|
1379
|
+
maxTurns?: number;
|
|
1380
|
+
/** Permission handler callback. */
|
|
1381
|
+
permissionHandler?: TInteractivePermissionHandler;
|
|
1382
|
+
/** Streaming text callback. */
|
|
1383
|
+
onTextDelta?: (delta: string) => void;
|
|
1384
|
+
}
|
|
1056
1385
|
/**
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1059
|
-
*
|
|
1386
|
+
* Create a prompt-only query function bound to a provider.
|
|
1387
|
+
*
|
|
1388
|
+
* ```typescript
|
|
1389
|
+
* import { createQuery } from '@robota-sdk/agent-sdk';
|
|
1390
|
+
* import { AnthropicProvider } from '@robota-sdk/agent-provider-anthropic';
|
|
1391
|
+
*
|
|
1392
|
+
* const query = createQuery({ provider: new AnthropicProvider({ apiKey: '...' }) });
|
|
1393
|
+
* const answer = await query('List all TypeScript files');
|
|
1394
|
+
* ```
|
|
1060
1395
|
*/
|
|
1061
|
-
declare function
|
|
1062
|
-
/** Build a skill prompt from a slash command input and registry */
|
|
1063
|
-
declare function buildSkillPrompt(input: string, registry: CommandRegistry, context?: SkillPromptContext): Promise<string | null>;
|
|
1396
|
+
declare function createQuery(options: ICreateQueryOptions): (prompt: string) => Promise<string>;
|
|
1064
1397
|
|
|
1065
1398
|
/**
|
|
1066
1399
|
* All built-in agent definitions shipped with the SDK.
|
|
@@ -1076,9 +1409,10 @@ declare function getBuiltInAgent(name: string): IAgentDefinition | undefined;
|
|
|
1076
1409
|
/**
|
|
1077
1410
|
* AgentTool — spawn a sub-agent with isolated context.
|
|
1078
1411
|
*
|
|
1079
|
-
* Uses `
|
|
1080
|
-
* model resolution, and framework system prompt. The
|
|
1081
|
-
* config and context but has its own conversation
|
|
1412
|
+
* Uses `SubagentManager` with an in-process runner to assemble a child Session
|
|
1413
|
+
* with filtered tools, model resolution, and framework system prompt. The
|
|
1414
|
+
* sub-agent shares the same config and context but has its own conversation
|
|
1415
|
+
* history.
|
|
1082
1416
|
*
|
|
1083
1417
|
* Each call to `createAgentTool(deps)` returns a fresh tool instance with deps
|
|
1084
1418
|
* captured in closure, eliminating module-level mutable state and enabling
|
|
@@ -1086,29 +1420,16 @@ declare function getBuiltInAgent(name: string): IAgentDefinition | undefined;
|
|
|
1086
1420
|
*/
|
|
1087
1421
|
|
|
1088
1422
|
/** Dependencies injected at creation time via createAgentTool factory */
|
|
1089
|
-
interface IAgentToolDeps {
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
provider: IAIProvider;
|
|
1096
|
-
/** Permission mode from parent session (bypassPermissions, acceptEdits, etc.). */
|
|
1097
|
-
permissionMode?: TPermissionMode;
|
|
1098
|
-
permissionHandler?: TPermissionHandler;
|
|
1099
|
-
/** Plugin hooks configuration from parent session. */
|
|
1100
|
-
hooks?: Record<string, unknown>;
|
|
1101
|
-
/** Hook type executors from parent session (prompt, agent, etc.). */
|
|
1102
|
-
hookTypeExecutors?: IHookTypeExecutor[];
|
|
1103
|
-
onTextDelta?: (delta: string) => void;
|
|
1104
|
-
onToolExecution?: (event: {
|
|
1105
|
-
type: 'start' | 'end';
|
|
1106
|
-
toolName: string;
|
|
1107
|
-
toolArgs?: TToolArgs;
|
|
1108
|
-
success?: boolean;
|
|
1109
|
-
}) => void;
|
|
1423
|
+
interface IAgentToolDeps extends IInProcessSubagentRunnerDeps {
|
|
1424
|
+
cwd?: string;
|
|
1425
|
+
parentSessionId?: string;
|
|
1426
|
+
subagentDepth?: number;
|
|
1427
|
+
subagentManager?: ISubagentManager;
|
|
1428
|
+
backgroundTaskManager?: IBackgroundTaskManager;
|
|
1110
1429
|
/** Optional custom agent registry for resolving non-built-in agent types. */
|
|
1111
1430
|
customAgentRegistry?: (name: string) => IAgentDefinition | undefined;
|
|
1431
|
+
/** Model-visible and command-visible agent definitions available to this session. */
|
|
1432
|
+
agentDefinitions?: IAgentDefinition[];
|
|
1112
1433
|
}
|
|
1113
1434
|
/** Store agent tool deps keyed by a session (or any object). */
|
|
1114
1435
|
declare function storeAgentToolDeps(key: object, deps: IAgentToolDeps): void;
|
|
@@ -1121,6 +1442,19 @@ declare function retrieveAgentToolDeps(key: object): IAgentToolDeps | undefined;
|
|
|
1121
1442
|
*/
|
|
1122
1443
|
declare function createAgentTool(deps: IAgentToolDeps): ReturnType<typeof createZodFunctionTool>;
|
|
1123
1444
|
|
|
1445
|
+
interface ICommandExecutionToolDeps {
|
|
1446
|
+
isModelInvocable: (command: string) => boolean;
|
|
1447
|
+
execute: (command: string, args: string) => Promise<ICommandResult | null>;
|
|
1448
|
+
}
|
|
1449
|
+
declare function createCommandExecutionTool(deps: ICommandExecutionToolDeps): ReturnType<typeof createZodFunctionTool>;
|
|
1450
|
+
|
|
1451
|
+
interface IBackgroundProcessToolDeps {
|
|
1452
|
+
backgroundTaskManager: IBackgroundTaskManager;
|
|
1453
|
+
cwd?: string;
|
|
1454
|
+
parentSessionId?: string;
|
|
1455
|
+
}
|
|
1456
|
+
declare function createBackgroundProcessTool(deps: IBackgroundProcessToolDeps): ReturnType<typeof createZodFunctionTool>;
|
|
1457
|
+
|
|
1124
1458
|
/**
|
|
1125
1459
|
* Standard Robota storage paths.
|
|
1126
1460
|
*
|
|
@@ -1151,4 +1485,4 @@ declare function userPaths(): {
|
|
|
1151
1485
|
*/
|
|
1152
1486
|
declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
|
|
1153
1487
|
|
|
1154
|
-
export { AgentExecutor, BUILT_IN_AGENTS, BuiltinCommandSource, BundlePluginInstaller, BundlePluginLoader, CommandRegistry, type IAgentDefinition, type IAgentExecutorOptions, type IAgentSession, type IAgentToolDeps, type IBundlePluginFeatures, type IBundlePluginInstallerOptions, type IBundlePluginManifest, type IBundleSkill, type ICommand, type ICommandResult, type ICommandSource, type ICreateQueryOptions, type IDiffLine, type IExecutionResult, type IInstalledPluginRecord, type IInstalledPluginsRegistry, type IInteractiveSessionEvents, type IInteractiveSessionOptions, type IKnownMarketplaceEntry, type IKnownMarketplacesRegistry, type ILoadedBundlePlugin, type IMarketplaceClientOptions, type IMarketplaceManifest, type IMarketplacePluginEntry, type IMarketplaceSource, type IPluginSettings, type IPromptExecutorOptions, type IPromptProvider, type ISubagentOptions, type ISubagentPromptOptions, type ISystemCommand, type IToolState, type IToolSummary, type ITransportAdapter, InteractiveSession, MarketplaceClient, PluginCommandSource, PluginSettingsStore, PromptExecutor, SkillCommandSource, type SkillPromptContext, type TEnabledPlugins, type TInteractiveEventName, type TInteractivePermissionHandler, type TPermissionResultValue, type TProviderFactory, type TSessionFactory, assembleSubagentPrompt, buildSkillPrompt, createAgentTool, createQuery, createSubagentLogger, createSubagentSession, getBuiltInAgent, getForkWorkerSuffix, getSubagentSuffix, parseFrontmatter, preprocessShellCommands, projectPaths, promptForApproval, resolveSubagentLogDir, retrieveAgentToolDeps, storeAgentToolDeps, substituteVariables, userPaths };
|
|
1488
|
+
export { AgentExecutor, BUILT_IN_AGENTS, BackgroundJobOrchestrator, BuiltinCommandSource, BundlePluginInstaller, BundlePluginLoader, CommandRegistry, type IAgentDefinition, type IAgentExecutorOptions, type IAgentSession, type IAgentToolDeps, type IBackgroundJobGroupCreateRequest, type IBackgroundJobGroupState, type IBackgroundJobGroupSummary, type IBackgroundJobOrchestratorOptions, type IBackgroundJobResultEnvelope, type IBackgroundProcessToolDeps, type IBundlePluginFeatures, type IBundlePluginInstallerOptions, type IBundlePluginManifest, type IBundleSkill, type ICapabilityDescriptor, type ICommand, type ICommandExecutionToolDeps, type ICommandModule, type ICommandResult, type ICommandSource, type ICreateQueryOptions, type IDiffLine, type IExecutionResult, type IForkExecutionOptions, type IInProcessSubagentRunnerDeps, type IInstalledPluginRecord, type IInstalledPluginsRegistry, type IInteractiveSessionEvents, type IInteractiveSessionOptions, type IInteractiveSessionShutdownOptions, type IKnownMarketplaceEntry, type IKnownMarketplacesRegistry, type ILoadedBundlePlugin, type IMarketplaceClientOptions, type IMarketplaceManifest, type IMarketplacePluginEntry, type IMarketplaceSource, type IPluginSettings, type IPromptExecutorOptions, type IPromptProvider, type ISkillExecutionCallbacks, type ISkillExecutionResult, type ISubagentOptions, type ISubagentPromptOptions, type ISystemCommand, type IToolState, type IToolSummary, type ITransportAdapter, InteractiveSession, MarketplaceClient, PluginCommandSource, PluginSettingsStore, PromptExecutor, SkillCommandSource, type SkillPromptContext, SystemCommandExecutor, type TBackgroundJobGroupEvent, type TBackgroundJobGroupEventListener, type TBackgroundJobGroupIdFactory, type TBackgroundJobGroupStatus, type TBackgroundJobWaitPolicy, type TCapabilityKind, type TCapabilitySafety, type TCommandModuleSessionRequirement, type TEnabledPlugins, type TInteractiveEventName, type TInteractivePermissionHandler, type TPermissionResultValue, type TProviderFactory, type TSessionFactory, type TSubagentRunnerFactory, assembleSubagentPrompt, buildSkillPrompt, createAgentTool, createBackgroundProcessTool, createCommandExecutionTool, createDefaultTools, createQuery, createSubagentLogger, createSubagentSession, createSystemCommands, executeSkill, getBuiltInAgent, getForkWorkerSuffix, getSubagentSuffix, parseFrontmatter, preprocessShellCommands, projectPaths, promptForApproval, resolveSubagentLogDir, retrieveAgentToolDeps, storeAgentToolDeps, substituteVariables, summarizeBackgroundJobGroup, userPaths };
|