@robota-sdk/agent-sdk 3.0.0-beta.24 → 3.0.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/index.cjs +1013 -21
- package/dist/node/index.d.cts +448 -168
- package/dist/node/index.d.ts +448 -168
- package/dist/node/index.js +1015 -21
- package/package.json +5 -5
package/dist/node/index.d.ts
CHANGED
|
@@ -1,175 +1,77 @@
|
|
|
1
|
-
import { TTrustLevel, TPermissionMode, IAIProvider, TToolArgs, IToolWithEventService } from '@robota-sdk/agent-core';
|
|
1
|
+
import { IHookTypeExecutor, IHookDefinition, IHookInput, IHookResult, THooksConfig, TTrustLevel, TPermissionMode, IAIProvider, TToolArgs, IToolWithEventService } from '@robota-sdk/agent-core';
|
|
2
2
|
export { IContextTokenUsage, IContextWindowState, IHookInput, IPermissionLists, THookEvent, THooksConfig, TPermissionDecision, TPermissionMode, TRUST_TO_MODE, TToolArgs, TTrustLevel, evaluatePermission, runHooks } from '@robota-sdk/agent-core';
|
|
3
3
|
import * as _robota_sdk_agent_tools from '@robota-sdk/agent-tools';
|
|
4
4
|
export { TToolResult, bashTool, editTool, globTool, grepTool, readTool, writeTool } from '@robota-sdk/agent-tools';
|
|
5
5
|
import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session } from '@robota-sdk/agent-sessions';
|
|
6
6
|
export { FileSessionLogger, ISessionLogger, ISessionOptions, ISessionRecord, ISpinner, ITerminalOutput, Session, SessionStore, SilentSessionLogger, TPermissionHandler, TPermissionResult, TSessionLogData } from '@robota-sdk/agent-sessions';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Prompt hook executor — evaluates a prompt via an AI model.
|
|
10
|
+
*
|
|
11
|
+
* Makes a single-turn LLM call with hook input context as the prompt.
|
|
12
|
+
* Parses { ok: boolean, reason?: string } from the AI response.
|
|
13
|
+
*
|
|
14
|
+
* Exit codes:
|
|
15
|
+
* - 0: ok: true (allow/proceed)
|
|
16
|
+
* - 2: ok: false (block/deny), reason in stderr
|
|
17
|
+
* - 1: execution error (provider failure, parse error)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** A minimal provider interface for single-turn completion. */
|
|
21
|
+
interface IPromptProvider {
|
|
22
|
+
complete(prompt: string): Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
/** Factory that creates a provider instance, optionally for a specific model. */
|
|
25
|
+
type TProviderFactory = (model?: string) => IPromptProvider;
|
|
26
|
+
/** Constructor options for PromptExecutor. */
|
|
27
|
+
interface IPromptExecutorOptions {
|
|
28
|
+
providerFactory: TProviderFactory;
|
|
29
|
+
defaultModel?: string;
|
|
30
|
+
}
|
|
31
|
+
declare class PromptExecutor implements IHookTypeExecutor {
|
|
32
|
+
readonly type: "prompt";
|
|
33
|
+
private readonly providerFactory;
|
|
34
|
+
private readonly defaultModel;
|
|
35
|
+
constructor(options: IPromptExecutorOptions);
|
|
36
|
+
execute(definition: IHookDefinition, input: IHookInput): Promise<IHookResult>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Agent hook executor — delegates to a sub-agent session.
|
|
41
|
+
*
|
|
42
|
+
* Creates a subagent session with maxTurns and timeout limits,
|
|
43
|
+
* runs hook input as the initial prompt, and parses the result.
|
|
44
|
+
*
|
|
45
|
+
* Exit codes:
|
|
46
|
+
* - 0: ok: true (allow/proceed)
|
|
47
|
+
* - 2: ok: false (block/deny), reason in stderr
|
|
48
|
+
* - 1: execution error (session failure, parse error)
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/** A minimal session interface for running a prompt. */
|
|
52
|
+
interface IAgentSession {
|
|
53
|
+
run(prompt: string): Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
/** Factory that creates a session instance with the given options. */
|
|
56
|
+
type TSessionFactory = (options: {
|
|
57
|
+
maxTurns?: number;
|
|
58
|
+
timeout?: number;
|
|
59
|
+
}) => IAgentSession;
|
|
60
|
+
/** Constructor options for AgentExecutor. */
|
|
61
|
+
interface IAgentExecutorOptions {
|
|
62
|
+
sessionFactory: TSessionFactory;
|
|
63
|
+
}
|
|
64
|
+
declare class AgentExecutor implements IHookTypeExecutor {
|
|
65
|
+
readonly type: "agent";
|
|
66
|
+
private readonly sessionFactory;
|
|
67
|
+
constructor(options: IAgentExecutorOptions);
|
|
68
|
+
execute(definition: IHookDefinition, input: IHookInput): Promise<IHookResult>;
|
|
69
|
+
}
|
|
8
70
|
|
|
9
71
|
/**
|
|
10
72
|
* Zod schemas and TypeScript types for Robota CLI settings
|
|
11
73
|
*/
|
|
12
74
|
|
|
13
|
-
declare const HooksSchema: z.ZodOptional<z.ZodObject<{
|
|
14
|
-
PreToolUse: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
15
|
-
matcher: z.ZodString;
|
|
16
|
-
hooks: z.ZodArray<z.ZodObject<{
|
|
17
|
-
type: z.ZodLiteral<"command">;
|
|
18
|
-
command: z.ZodString;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
type: "command";
|
|
21
|
-
command: string;
|
|
22
|
-
}, {
|
|
23
|
-
type: "command";
|
|
24
|
-
command: string;
|
|
25
|
-
}>, "many">;
|
|
26
|
-
}, "strip", z.ZodTypeAny, {
|
|
27
|
-
matcher: string;
|
|
28
|
-
hooks: {
|
|
29
|
-
type: "command";
|
|
30
|
-
command: string;
|
|
31
|
-
}[];
|
|
32
|
-
}, {
|
|
33
|
-
matcher: string;
|
|
34
|
-
hooks: {
|
|
35
|
-
type: "command";
|
|
36
|
-
command: string;
|
|
37
|
-
}[];
|
|
38
|
-
}>, "many">>;
|
|
39
|
-
PostToolUse: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
|
-
matcher: z.ZodString;
|
|
41
|
-
hooks: z.ZodArray<z.ZodObject<{
|
|
42
|
-
type: z.ZodLiteral<"command">;
|
|
43
|
-
command: z.ZodString;
|
|
44
|
-
}, "strip", z.ZodTypeAny, {
|
|
45
|
-
type: "command";
|
|
46
|
-
command: string;
|
|
47
|
-
}, {
|
|
48
|
-
type: "command";
|
|
49
|
-
command: string;
|
|
50
|
-
}>, "many">;
|
|
51
|
-
}, "strip", z.ZodTypeAny, {
|
|
52
|
-
matcher: string;
|
|
53
|
-
hooks: {
|
|
54
|
-
type: "command";
|
|
55
|
-
command: string;
|
|
56
|
-
}[];
|
|
57
|
-
}, {
|
|
58
|
-
matcher: string;
|
|
59
|
-
hooks: {
|
|
60
|
-
type: "command";
|
|
61
|
-
command: string;
|
|
62
|
-
}[];
|
|
63
|
-
}>, "many">>;
|
|
64
|
-
SessionStart: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
65
|
-
matcher: z.ZodString;
|
|
66
|
-
hooks: z.ZodArray<z.ZodObject<{
|
|
67
|
-
type: z.ZodLiteral<"command">;
|
|
68
|
-
command: z.ZodString;
|
|
69
|
-
}, "strip", z.ZodTypeAny, {
|
|
70
|
-
type: "command";
|
|
71
|
-
command: string;
|
|
72
|
-
}, {
|
|
73
|
-
type: "command";
|
|
74
|
-
command: string;
|
|
75
|
-
}>, "many">;
|
|
76
|
-
}, "strip", z.ZodTypeAny, {
|
|
77
|
-
matcher: string;
|
|
78
|
-
hooks: {
|
|
79
|
-
type: "command";
|
|
80
|
-
command: string;
|
|
81
|
-
}[];
|
|
82
|
-
}, {
|
|
83
|
-
matcher: string;
|
|
84
|
-
hooks: {
|
|
85
|
-
type: "command";
|
|
86
|
-
command: string;
|
|
87
|
-
}[];
|
|
88
|
-
}>, "many">>;
|
|
89
|
-
Stop: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
90
|
-
matcher: z.ZodString;
|
|
91
|
-
hooks: z.ZodArray<z.ZodObject<{
|
|
92
|
-
type: z.ZodLiteral<"command">;
|
|
93
|
-
command: z.ZodString;
|
|
94
|
-
}, "strip", z.ZodTypeAny, {
|
|
95
|
-
type: "command";
|
|
96
|
-
command: string;
|
|
97
|
-
}, {
|
|
98
|
-
type: "command";
|
|
99
|
-
command: string;
|
|
100
|
-
}>, "many">;
|
|
101
|
-
}, "strip", z.ZodTypeAny, {
|
|
102
|
-
matcher: string;
|
|
103
|
-
hooks: {
|
|
104
|
-
type: "command";
|
|
105
|
-
command: string;
|
|
106
|
-
}[];
|
|
107
|
-
}, {
|
|
108
|
-
matcher: string;
|
|
109
|
-
hooks: {
|
|
110
|
-
type: "command";
|
|
111
|
-
command: string;
|
|
112
|
-
}[];
|
|
113
|
-
}>, "many">>;
|
|
114
|
-
}, "strip", z.ZodTypeAny, {
|
|
115
|
-
PreToolUse?: {
|
|
116
|
-
matcher: string;
|
|
117
|
-
hooks: {
|
|
118
|
-
type: "command";
|
|
119
|
-
command: string;
|
|
120
|
-
}[];
|
|
121
|
-
}[] | undefined;
|
|
122
|
-
PostToolUse?: {
|
|
123
|
-
matcher: string;
|
|
124
|
-
hooks: {
|
|
125
|
-
type: "command";
|
|
126
|
-
command: string;
|
|
127
|
-
}[];
|
|
128
|
-
}[] | undefined;
|
|
129
|
-
SessionStart?: {
|
|
130
|
-
matcher: string;
|
|
131
|
-
hooks: {
|
|
132
|
-
type: "command";
|
|
133
|
-
command: string;
|
|
134
|
-
}[];
|
|
135
|
-
}[] | undefined;
|
|
136
|
-
Stop?: {
|
|
137
|
-
matcher: string;
|
|
138
|
-
hooks: {
|
|
139
|
-
type: "command";
|
|
140
|
-
command: string;
|
|
141
|
-
}[];
|
|
142
|
-
}[] | undefined;
|
|
143
|
-
}, {
|
|
144
|
-
PreToolUse?: {
|
|
145
|
-
matcher: string;
|
|
146
|
-
hooks: {
|
|
147
|
-
type: "command";
|
|
148
|
-
command: string;
|
|
149
|
-
}[];
|
|
150
|
-
}[] | undefined;
|
|
151
|
-
PostToolUse?: {
|
|
152
|
-
matcher: string;
|
|
153
|
-
hooks: {
|
|
154
|
-
type: "command";
|
|
155
|
-
command: string;
|
|
156
|
-
}[];
|
|
157
|
-
}[] | undefined;
|
|
158
|
-
SessionStart?: {
|
|
159
|
-
matcher: string;
|
|
160
|
-
hooks: {
|
|
161
|
-
type: "command";
|
|
162
|
-
command: string;
|
|
163
|
-
}[];
|
|
164
|
-
}[] | undefined;
|
|
165
|
-
Stop?: {
|
|
166
|
-
matcher: string;
|
|
167
|
-
hooks: {
|
|
168
|
-
type: "command";
|
|
169
|
-
command: string;
|
|
170
|
-
}[];
|
|
171
|
-
}[] | undefined;
|
|
172
|
-
}>>;
|
|
173
75
|
/**
|
|
174
76
|
* Fully resolved config after merging all settings files and applying defaults.
|
|
175
77
|
*/
|
|
@@ -187,7 +89,19 @@ interface IResolvedConfig {
|
|
|
187
89
|
deny: string[];
|
|
188
90
|
};
|
|
189
91
|
env: Record<string, string>;
|
|
190
|
-
hooks?:
|
|
92
|
+
hooks?: THooksConfig;
|
|
93
|
+
/** Plugin enablement map: plugin name -> enabled/disabled */
|
|
94
|
+
enabledPlugins?: Record<string, boolean>;
|
|
95
|
+
/** Extra marketplace sources: name -> { source } */
|
|
96
|
+
extraKnownMarketplaces?: Record<string, {
|
|
97
|
+
source: {
|
|
98
|
+
type: string;
|
|
99
|
+
repo?: string;
|
|
100
|
+
url?: string;
|
|
101
|
+
path?: string;
|
|
102
|
+
ref?: string;
|
|
103
|
+
};
|
|
104
|
+
}>;
|
|
191
105
|
}
|
|
192
106
|
|
|
193
107
|
interface ILoadedContext {
|
|
@@ -241,10 +155,13 @@ interface ISystemPromptParams {
|
|
|
241
155
|
cwd?: string;
|
|
242
156
|
/** Response language code (e.g., "ko", "en"). If set, AI must respond in this language. */
|
|
243
157
|
language?: string;
|
|
158
|
+
/** Discovered skills to expose in the system prompt */
|
|
159
|
+
skills?: Array<{
|
|
160
|
+
name: string;
|
|
161
|
+
description: string;
|
|
162
|
+
disableModelInvocation?: boolean;
|
|
163
|
+
}>;
|
|
244
164
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Assemble the full system prompt string from the provided parameters.
|
|
247
|
-
*/
|
|
248
165
|
declare function buildSystemPrompt(params: ISystemPromptParams): string;
|
|
249
166
|
|
|
250
167
|
/**
|
|
@@ -299,6 +216,12 @@ interface ICreateSessionOptions {
|
|
|
299
216
|
toolDescriptions?: string[];
|
|
300
217
|
/** Session logger — injected for pluggable session event logging. */
|
|
301
218
|
sessionLogger?: ISessionLogger;
|
|
219
|
+
/** Provider factory for prompt hook executors (DI). */
|
|
220
|
+
providerFactory?: TProviderFactory;
|
|
221
|
+
/** Session factory for agent hook executors (DI). */
|
|
222
|
+
sessionFactory?: TSessionFactory;
|
|
223
|
+
/** Additional hook type executors beyond the defaults (prompt, agent). */
|
|
224
|
+
additionalHookExecutors?: IHookTypeExecutor[];
|
|
302
225
|
}
|
|
303
226
|
/**
|
|
304
227
|
* Create a fully-configured Session instance.
|
|
@@ -355,7 +278,7 @@ declare function query(prompt: string, options?: IQueryOptions): Promise<string>
|
|
|
355
278
|
/**
|
|
356
279
|
* Load and merge all settings files, validate with Zod, return resolved config.
|
|
357
280
|
*
|
|
358
|
-
* @param cwd - The working directory (project root) to search for
|
|
281
|
+
* @param cwd - The working directory (project root) to search for settings
|
|
359
282
|
*/
|
|
360
283
|
declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
|
|
361
284
|
|
|
@@ -389,6 +312,363 @@ declare function userPaths(): {
|
|
|
389
312
|
sessions: string;
|
|
390
313
|
};
|
|
391
314
|
|
|
315
|
+
/**
|
|
316
|
+
* PluginSettingsStore — single point of read/write for plugin-related settings.
|
|
317
|
+
*
|
|
318
|
+
* Shared by MarketplaceClient and BundlePluginInstaller to prevent
|
|
319
|
+
* concurrent writes from overwriting each other's changes.
|
|
320
|
+
*/
|
|
321
|
+
/** Source type for a marketplace registry. */
|
|
322
|
+
type IMarketplaceSource$1 = {
|
|
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
|
+
/** Persisted marketplace source entry. */
|
|
338
|
+
interface IPersistedMarketplaceSource {
|
|
339
|
+
source: IMarketplaceSource$1;
|
|
340
|
+
}
|
|
341
|
+
/** Shape of the plugin-related keys in settings.json. */
|
|
342
|
+
interface IPluginSettings {
|
|
343
|
+
enabledPlugins: Record<string, boolean>;
|
|
344
|
+
extraKnownMarketplaces: Record<string, IPersistedMarketplaceSource>;
|
|
345
|
+
}
|
|
346
|
+
/** Centralized settings store for plugin configuration. */
|
|
347
|
+
declare class PluginSettingsStore {
|
|
348
|
+
private readonly settingsPath;
|
|
349
|
+
constructor(settingsPath: string);
|
|
350
|
+
/** Read the full settings file from disk. */
|
|
351
|
+
private readAll;
|
|
352
|
+
/** Write the full settings file to disk. */
|
|
353
|
+
private writeAll;
|
|
354
|
+
/** Get the enabledPlugins map. */
|
|
355
|
+
getEnabledPlugins(): Record<string, boolean>;
|
|
356
|
+
/** Set a single plugin's enabled state. */
|
|
357
|
+
setPluginEnabled(pluginId: string, enabled: boolean): void;
|
|
358
|
+
/** Remove a plugin from enabledPlugins. */
|
|
359
|
+
removePluginEntry(pluginId: string): void;
|
|
360
|
+
/** Get all persisted marketplace sources. */
|
|
361
|
+
getMarketplaceSources(): Record<string, IPersistedMarketplaceSource>;
|
|
362
|
+
/** Add or update a marketplace source. */
|
|
363
|
+
setMarketplaceSource(name: string, source: IMarketplaceSource$1): void;
|
|
364
|
+
/** Remove a marketplace source. */
|
|
365
|
+
removeMarketplaceSource(name: string): void;
|
|
366
|
+
private getEnabledPluginsFrom;
|
|
367
|
+
private getMarketplaceSourcesFrom;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Types for the BundlePlugin system.
|
|
372
|
+
*
|
|
373
|
+
* A BundlePlugin is a directory-based plugin package that bundles
|
|
374
|
+
* skills, hooks, agents, and MCP server configurations.
|
|
375
|
+
*/
|
|
376
|
+
/** Feature flags indicating what a bundle plugin provides. */
|
|
377
|
+
interface IBundlePluginFeatures {
|
|
378
|
+
commands?: boolean;
|
|
379
|
+
agents?: boolean;
|
|
380
|
+
skills?: boolean;
|
|
381
|
+
hooks?: boolean;
|
|
382
|
+
mcp?: boolean;
|
|
383
|
+
}
|
|
384
|
+
/** Manifest read from `.claude-plugin/plugin.json`. */
|
|
385
|
+
interface IBundlePluginManifest {
|
|
386
|
+
name: string;
|
|
387
|
+
version: string;
|
|
388
|
+
description: string;
|
|
389
|
+
features: IBundlePluginFeatures;
|
|
390
|
+
}
|
|
391
|
+
/** A skill loaded from a bundle plugin's `skills/` directory. */
|
|
392
|
+
interface IBundleSkill {
|
|
393
|
+
name: string;
|
|
394
|
+
description: string;
|
|
395
|
+
skillContent: string;
|
|
396
|
+
[key: string]: unknown;
|
|
397
|
+
}
|
|
398
|
+
/** A fully loaded bundle plugin with all its assets. */
|
|
399
|
+
interface ILoadedBundlePlugin {
|
|
400
|
+
manifest: IBundlePluginManifest;
|
|
401
|
+
skills: IBundleSkill[];
|
|
402
|
+
commands: IBundleSkill[];
|
|
403
|
+
hooks: Record<string, unknown>;
|
|
404
|
+
mcpConfig?: unknown;
|
|
405
|
+
agents: string[];
|
|
406
|
+
pluginDir: string;
|
|
407
|
+
}
|
|
408
|
+
/** Map of plugin identifiers to enabled/disabled state. */
|
|
409
|
+
type TEnabledPlugins = Record<string, boolean>;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* BundlePluginLoader — discovers and loads directory-based bundle plugins.
|
|
413
|
+
*
|
|
414
|
+
* Scans the cache directory (`<pluginsDir>/cache/<marketplace>/<plugin>/<version>/`)
|
|
415
|
+
* for subdirectories containing `.claude-plugin/plugin.json`,
|
|
416
|
+
* reads manifests, loads skills (with frontmatter parsing), hooks, and agent definitions.
|
|
417
|
+
*
|
|
418
|
+
* For each plugin, the latest version directory (lexicographically last) is loaded.
|
|
419
|
+
*/
|
|
420
|
+
|
|
421
|
+
/** Loader for directory-based bundle plugins from the cache directory. */
|
|
422
|
+
declare class BundlePluginLoader {
|
|
423
|
+
private readonly pluginsDir;
|
|
424
|
+
private readonly enabledPlugins;
|
|
425
|
+
constructor(pluginsDir: string, enabledPlugins?: TEnabledPlugins);
|
|
426
|
+
/** Load all discovered and enabled bundle plugins (sync). */
|
|
427
|
+
loadPluginsSync(): ILoadedBundlePlugin[];
|
|
428
|
+
/** Load all discovered and enabled bundle plugins (async wrapper). */
|
|
429
|
+
loadAll(): Promise<ILoadedBundlePlugin[]>;
|
|
430
|
+
/**
|
|
431
|
+
* Discover and load plugins from the cache directory.
|
|
432
|
+
*
|
|
433
|
+
* Directory structure: `<pluginsDir>/cache/<marketplace>/<plugin>/<version>/`
|
|
434
|
+
* For each marketplace/plugin pair, the latest version (lexicographically last) is loaded.
|
|
435
|
+
*/
|
|
436
|
+
private discoverAndLoad;
|
|
437
|
+
/** Read and validate a plugin.json manifest. Returns null on failure. */
|
|
438
|
+
private readManifest;
|
|
439
|
+
/**
|
|
440
|
+
* Check if a plugin is explicitly disabled.
|
|
441
|
+
* Checks both `name@marketplace` and `name` keys.
|
|
442
|
+
* Plugins not listed in enabledPlugins are enabled by default.
|
|
443
|
+
*/
|
|
444
|
+
private isDisabled;
|
|
445
|
+
/** Load a single plugin's skills, hooks, agents, and MCP config. */
|
|
446
|
+
private loadPlugin;
|
|
447
|
+
/** Load skills from the plugin's skills/ directory. */
|
|
448
|
+
private loadSkills;
|
|
449
|
+
/** Load commands from the plugin's commands/ directory (flat .md files). */
|
|
450
|
+
private loadCommands;
|
|
451
|
+
/** Load hooks from hooks/hooks.json if present. */
|
|
452
|
+
private loadHooks;
|
|
453
|
+
/** Load MCP server configuration if present. Checks `.mcp.json` at plugin root first. */
|
|
454
|
+
private loadMcpConfig;
|
|
455
|
+
/** Load agent definitions from agents/ directory if present. */
|
|
456
|
+
private loadAgents;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* MarketplaceClient — manages marketplace registries via shallow git clones.
|
|
461
|
+
*
|
|
462
|
+
* Marketplaces are git repositories containing `.claude-plugin/marketplace.json`.
|
|
463
|
+
* They are cloned to `~/.robota/plugins/marketplaces/<name>/` and tracked
|
|
464
|
+
* in `known_marketplaces.json`.
|
|
465
|
+
*/
|
|
466
|
+
/** Source specification for a marketplace. */
|
|
467
|
+
type IMarketplaceSource = {
|
|
468
|
+
type: 'github';
|
|
469
|
+
repo: string;
|
|
470
|
+
ref?: string;
|
|
471
|
+
} | {
|
|
472
|
+
type: 'git';
|
|
473
|
+
url: string;
|
|
474
|
+
ref?: string;
|
|
475
|
+
} | {
|
|
476
|
+
type: 'local';
|
|
477
|
+
path: string;
|
|
478
|
+
} | {
|
|
479
|
+
type: 'url';
|
|
480
|
+
url: string;
|
|
481
|
+
};
|
|
482
|
+
/** A single plugin entry in a marketplace manifest. */
|
|
483
|
+
interface IMarketplacePluginEntry {
|
|
484
|
+
name: string;
|
|
485
|
+
title: string;
|
|
486
|
+
description: string;
|
|
487
|
+
source: string | {
|
|
488
|
+
type: 'github';
|
|
489
|
+
repo: string;
|
|
490
|
+
} | {
|
|
491
|
+
type: 'url';
|
|
492
|
+
url: string;
|
|
493
|
+
};
|
|
494
|
+
tags: string[];
|
|
495
|
+
}
|
|
496
|
+
/** Manifest format read from `.claude-plugin/marketplace.json`. */
|
|
497
|
+
interface IMarketplaceManifest {
|
|
498
|
+
name: string;
|
|
499
|
+
version: string;
|
|
500
|
+
plugins: IMarketplacePluginEntry[];
|
|
501
|
+
}
|
|
502
|
+
/** Entry in known_marketplaces.json. */
|
|
503
|
+
interface IKnownMarketplaceEntry {
|
|
504
|
+
source: IMarketplaceSource;
|
|
505
|
+
installLocation: string;
|
|
506
|
+
lastUpdated: string;
|
|
507
|
+
}
|
|
508
|
+
/** Shape of known_marketplaces.json. */
|
|
509
|
+
type IKnownMarketplacesRegistry = Record<string, IKnownMarketplaceEntry>;
|
|
510
|
+
/** Exec function type for running shell commands. */
|
|
511
|
+
type ExecFn$1 = (command: string, options: {
|
|
512
|
+
timeout: number;
|
|
513
|
+
stdio?: string;
|
|
514
|
+
}) => string | Buffer;
|
|
515
|
+
/** Options for constructing a MarketplaceClient. */
|
|
516
|
+
interface IMarketplaceClientOptions {
|
|
517
|
+
/** Base plugins directory (e.g., `~/.robota/plugins`). */
|
|
518
|
+
pluginsDir: string;
|
|
519
|
+
/** Custom exec function for testing (replaces child_process.execSync). */
|
|
520
|
+
exec?: ExecFn$1;
|
|
521
|
+
}
|
|
522
|
+
/** Manages marketplace registries via shallow git clones. */
|
|
523
|
+
declare class MarketplaceClient {
|
|
524
|
+
private readonly pluginsDir;
|
|
525
|
+
private readonly exec;
|
|
526
|
+
private readonly marketplacesDir;
|
|
527
|
+
private readonly registryPath;
|
|
528
|
+
constructor(options: IMarketplaceClientOptions);
|
|
529
|
+
/**
|
|
530
|
+
* Add a marketplace by cloning its repository.
|
|
531
|
+
*
|
|
532
|
+
* 1. Parse source: `owner/repo` string becomes a GitHub source.
|
|
533
|
+
* 2. Shallow git clone (`--depth 1`) to `marketplaces/<name>/`.
|
|
534
|
+
* 3. Read `.claude-plugin/marketplace.json` for the `name` field.
|
|
535
|
+
* 4. Register in `known_marketplaces.json`.
|
|
536
|
+
*
|
|
537
|
+
* Returns the registered marketplace name from the manifest.
|
|
538
|
+
*/
|
|
539
|
+
addMarketplace(source: IMarketplaceSource): string;
|
|
540
|
+
/**
|
|
541
|
+
* Remove a marketplace.
|
|
542
|
+
* Uninstalls all plugins from that marketplace, then deletes the clone directory
|
|
543
|
+
* and removes from the registry.
|
|
544
|
+
*/
|
|
545
|
+
removeMarketplace(name: string): void;
|
|
546
|
+
/**
|
|
547
|
+
* Update a marketplace by running git pull on its clone.
|
|
548
|
+
* The manifest is re-read from disk on demand (via fetchManifest), so the
|
|
549
|
+
* updated manifest is automatically available after pull.
|
|
550
|
+
*
|
|
551
|
+
* TODO: After pull, detect version changes in installed plugins and offer
|
|
552
|
+
* to update them (re-install at new version).
|
|
553
|
+
*/
|
|
554
|
+
updateMarketplace(name: string): void;
|
|
555
|
+
/** List all registered marketplaces. */
|
|
556
|
+
listMarketplaces(): Array<{
|
|
557
|
+
name: string;
|
|
558
|
+
source: IMarketplaceSource;
|
|
559
|
+
lastUpdated: string;
|
|
560
|
+
}>;
|
|
561
|
+
/**
|
|
562
|
+
* Read the marketplace manifest from a registered marketplace's clone.
|
|
563
|
+
*/
|
|
564
|
+
fetchManifest(marketplaceName: string): IMarketplaceManifest;
|
|
565
|
+
/** Get the clone directory path for a registered marketplace. */
|
|
566
|
+
getMarketplaceDir(name: string): string;
|
|
567
|
+
/**
|
|
568
|
+
* Get the current git SHA (first 12 chars) for a marketplace clone.
|
|
569
|
+
* Used as a version identifier when plugins lack explicit versions.
|
|
570
|
+
*/
|
|
571
|
+
getMarketplaceSha(name: string): string;
|
|
572
|
+
/** List all available plugins across all marketplaces. */
|
|
573
|
+
listAvailablePlugins(): Array<IMarketplacePluginEntry & {
|
|
574
|
+
marketplace: string;
|
|
575
|
+
}>;
|
|
576
|
+
/** Resolve a marketplace source to a git clone URL. */
|
|
577
|
+
private resolveCloneUrl;
|
|
578
|
+
/**
|
|
579
|
+
* Remove all installed plugins that belong to a given marketplace.
|
|
580
|
+
* Reads installed_plugins.json, deletes cache directories for matching plugins,
|
|
581
|
+
* and updates the registry.
|
|
582
|
+
*/
|
|
583
|
+
private removeInstalledPluginsForMarketplace;
|
|
584
|
+
/** Read and parse a marketplace.json from a file path. */
|
|
585
|
+
private readManifestFromPath;
|
|
586
|
+
/** Read the known_marketplaces.json registry. */
|
|
587
|
+
private readRegistry;
|
|
588
|
+
/** Write the known_marketplaces.json registry. */
|
|
589
|
+
private writeRegistry;
|
|
590
|
+
/** Default exec implementation using child_process. */
|
|
591
|
+
private defaultExec;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* BundlePluginInstaller — installs, uninstalls, enables, and disables bundle plugins.
|
|
596
|
+
*
|
|
597
|
+
* Resolves plugin sources from marketplace manifests, copies/clones to the
|
|
598
|
+
* cache directory, and tracks installations in `installed_plugins.json`.
|
|
599
|
+
*/
|
|
600
|
+
|
|
601
|
+
/** Record of an installed plugin in installed_plugins.json. */
|
|
602
|
+
interface IInstalledPluginRecord {
|
|
603
|
+
pluginName: string;
|
|
604
|
+
marketplace: string;
|
|
605
|
+
version: string;
|
|
606
|
+
installPath: string;
|
|
607
|
+
installedAt: string;
|
|
608
|
+
}
|
|
609
|
+
/** Shape of installed_plugins.json. */
|
|
610
|
+
type IInstalledPluginsRegistry = Record<string, IInstalledPluginRecord>;
|
|
611
|
+
/** Exec function type for running shell commands. */
|
|
612
|
+
type ExecFn = (command: string, options: {
|
|
613
|
+
timeout: number;
|
|
614
|
+
stdio?: string;
|
|
615
|
+
}) => string | Buffer;
|
|
616
|
+
/** Options for constructing a BundlePluginInstaller. */
|
|
617
|
+
interface IBundlePluginInstallerOptions {
|
|
618
|
+
/** Base plugins directory (e.g., `~/.robota/plugins`). */
|
|
619
|
+
pluginsDir: string;
|
|
620
|
+
/** Shared settings store for enable/disable persistence. */
|
|
621
|
+
settingsStore: PluginSettingsStore;
|
|
622
|
+
/** MarketplaceClient for reading marketplace manifests. */
|
|
623
|
+
marketplaceClient: MarketplaceClient;
|
|
624
|
+
/** Custom exec function for testing (replaces child_process.execSync). */
|
|
625
|
+
exec?: ExecFn;
|
|
626
|
+
}
|
|
627
|
+
/** Installs, uninstalls, enables, and disables bundle plugins. */
|
|
628
|
+
declare class BundlePluginInstaller {
|
|
629
|
+
private readonly pluginsDir;
|
|
630
|
+
private readonly cacheDir;
|
|
631
|
+
private readonly registryPath;
|
|
632
|
+
private readonly settingsStore;
|
|
633
|
+
private readonly marketplaceClient;
|
|
634
|
+
private readonly exec;
|
|
635
|
+
constructor(options: IBundlePluginInstallerOptions);
|
|
636
|
+
/**
|
|
637
|
+
* Install a plugin from a marketplace.
|
|
638
|
+
*
|
|
639
|
+
* 1. Read marketplace manifest to find the plugin entry.
|
|
640
|
+
* 2. Resolve source (relative path, github, or url).
|
|
641
|
+
* 3. Copy/clone to `cache/<marketplace>/<plugin>/<version>/`.
|
|
642
|
+
* 4. Record in `installed_plugins.json`.
|
|
643
|
+
*/
|
|
644
|
+
install(pluginName: string, marketplaceName: string): Promise<void>;
|
|
645
|
+
/**
|
|
646
|
+
* Uninstall a plugin.
|
|
647
|
+
* Removes from cache and from installed_plugins.json.
|
|
648
|
+
*/
|
|
649
|
+
uninstall(pluginId: string): Promise<void>;
|
|
650
|
+
/** Enable a plugin by setting its enabledPlugins entry to true. */
|
|
651
|
+
enable(pluginId: string): Promise<void>;
|
|
652
|
+
/** Disable a plugin by setting its enabledPlugins entry to false. */
|
|
653
|
+
disable(pluginId: string): Promise<void>;
|
|
654
|
+
/** Get all installed plugins. */
|
|
655
|
+
getInstalledPlugins(): IInstalledPluginsRegistry;
|
|
656
|
+
/** Get plugins installed from a specific marketplace. */
|
|
657
|
+
getPluginsByMarketplace(marketplaceName: string): IInstalledPluginRecord[];
|
|
658
|
+
/** Resolve the version for a plugin entry. */
|
|
659
|
+
private resolveVersion;
|
|
660
|
+
/** Resolve the source and install the plugin. */
|
|
661
|
+
private resolveAndInstall;
|
|
662
|
+
/** Clone a git repository to the target directory. */
|
|
663
|
+
private cloneToDir;
|
|
664
|
+
/** Read the installed_plugins.json registry. */
|
|
665
|
+
private readRegistry;
|
|
666
|
+
/** Write the installed_plugins.json registry. */
|
|
667
|
+
private writeRegistry;
|
|
668
|
+
/** Default exec implementation using child_process. */
|
|
669
|
+
private defaultExec;
|
|
670
|
+
}
|
|
671
|
+
|
|
392
672
|
/** Dependencies injected at registration time */
|
|
393
673
|
interface IAgentToolDeps {
|
|
394
674
|
config: IResolvedConfig;
|
|
@@ -399,4 +679,4 @@ interface IAgentToolDeps {
|
|
|
399
679
|
declare function setAgentToolDeps(deps: IAgentToolDeps): void;
|
|
400
680
|
declare const agentTool: _robota_sdk_agent_tools.FunctionTool;
|
|
401
681
|
|
|
402
|
-
export { DEFAULT_TOOL_DESCRIPTIONS, type ICreateSessionOptions, type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, createDefaultTools, createProvider, createSession, detectProject, loadConfig, loadContext, projectPaths, promptForApproval, query, setAgentToolDeps, userPaths };
|
|
682
|
+
export { AgentExecutor, BundlePluginInstaller, BundlePluginLoader, DEFAULT_TOOL_DESCRIPTIONS, type IAgentExecutorOptions, type IAgentSession, type IBundlePluginFeatures, type IBundlePluginInstallerOptions, type IBundlePluginManifest, type IBundleSkill, type ICreateSessionOptions, type IInstalledPluginRecord, type IInstalledPluginsRegistry, type IKnownMarketplaceEntry, type IKnownMarketplacesRegistry, type ILoadedBundlePlugin, type ILoadedContext, type IMarketplaceClientOptions, type IMarketplaceManifest, type IMarketplacePluginEntry, type IMarketplaceSource, type IPluginSettings, type IProjectInfo, type IPromptExecutorOptions, type IPromptProvider, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, MarketplaceClient, PluginSettingsStore, PromptExecutor, type TEnabledPlugins, type TProviderFactory, type TSessionFactory, agentTool, buildSystemPrompt, createDefaultTools, createProvider, createSession, detectProject, loadConfig, loadContext, projectPaths, promptForApproval, query, setAgentToolDeps, userPaths };
|