@robota-sdk/agent-sdk 3.0.0-beta.31 → 3.0.0-beta.32
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 +576 -266
- package/dist/node/index.d.cts +195 -8
- package/dist/node/index.d.ts +195 -8
- package/dist/node/index.js +576 -275
- package/package.json +5 -5
package/dist/node/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
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
|
-
import
|
|
3
|
+
import { createZodFunctionTool } from '@robota-sdk/agent-tools';
|
|
4
4
|
export { TToolResult, bashTool, editTool, globTool, grepTool, readTool, writeTool } from '@robota-sdk/agent-tools';
|
|
5
|
-
import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session } from '@robota-sdk/agent-sessions';
|
|
5
|
+
import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session, FileSessionLogger } 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
8
|
/**
|
|
@@ -253,6 +253,146 @@ declare function createDefaultTools(): IToolWithEventService[];
|
|
|
253
253
|
*/
|
|
254
254
|
declare function createProvider(config: IResolvedConfig): IAIProvider;
|
|
255
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Framework system prompt suffixes for subagent sessions.
|
|
258
|
+
*
|
|
259
|
+
* These functions generate the standard prompt content injected into
|
|
260
|
+
* subagent sessions to control output format and behavior.
|
|
261
|
+
*/
|
|
262
|
+
/** Options for assembling a subagent system prompt. */
|
|
263
|
+
interface ISubagentPromptOptions {
|
|
264
|
+
/** Agent definition markdown body. */
|
|
265
|
+
agentBody: string;
|
|
266
|
+
/** CLAUDE.md content to include. */
|
|
267
|
+
claudeMd?: string;
|
|
268
|
+
/** AGENTS.md content to include. */
|
|
269
|
+
agentsMd?: string;
|
|
270
|
+
/** When true, use fork worker suffix instead of standard subagent suffix. */
|
|
271
|
+
isForkWorker: boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Returns the standard subagent suffix appended to agent body for normal subagents.
|
|
275
|
+
*/
|
|
276
|
+
declare function getSubagentSuffix(): string;
|
|
277
|
+
/**
|
|
278
|
+
* Returns the fork worker suffix for context:fork skill workers.
|
|
279
|
+
*/
|
|
280
|
+
declare function getForkWorkerSuffix(): string;
|
|
281
|
+
/**
|
|
282
|
+
* Assembles the full system prompt for a subagent.
|
|
283
|
+
*
|
|
284
|
+
* Assembly order:
|
|
285
|
+
* 1. Agent definition body
|
|
286
|
+
* 2. CLAUDE.md content (if provided)
|
|
287
|
+
* 3. AGENTS.md content (if provided)
|
|
288
|
+
* 4. Framework suffix (fork worker OR standard subagent)
|
|
289
|
+
*/
|
|
290
|
+
declare function assembleSubagentPrompt(options: ISubagentPromptOptions): string;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Definition of an agent that can be spawned as a subagent.
|
|
294
|
+
*
|
|
295
|
+
* Built-in agents and custom (user-defined) agents share this shape.
|
|
296
|
+
* Optional fields inherit from the parent session when omitted.
|
|
297
|
+
*/
|
|
298
|
+
interface IAgentDefinition {
|
|
299
|
+
/** Unique name used to reference the agent (e.g., 'Explore', 'Plan'). */
|
|
300
|
+
name: string;
|
|
301
|
+
/** Human-readable description of the agent's purpose. */
|
|
302
|
+
description: string;
|
|
303
|
+
/** Markdown body content used as the agent's system prompt. */
|
|
304
|
+
systemPrompt: string;
|
|
305
|
+
/** Model override (e.g., 'claude-haiku-4-5', 'sonnet', 'opus'). Inherits parent model when omitted. */
|
|
306
|
+
model?: string;
|
|
307
|
+
/** Maximum number of agentic turns the subagent may execute. */
|
|
308
|
+
maxTurns?: number;
|
|
309
|
+
/** Allowlist of tool names. Only these tools are available when set. */
|
|
310
|
+
tools?: string[];
|
|
311
|
+
/** Denylist of tool names. These tools are removed from the inherited set. */
|
|
312
|
+
disallowedTools?: string[];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Subagent session factory — assembles an isolated child Session for subagent execution.
|
|
317
|
+
*
|
|
318
|
+
* Unlike `createSession`, this factory does not load config files or context from disk.
|
|
319
|
+
* It receives pre-resolved config and context from the parent session, applies tool
|
|
320
|
+
* filtering and model resolution from the agent definition, and creates a lightweight
|
|
321
|
+
* Session suitable for subagent use.
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/** Options for creating a subagent session. */
|
|
325
|
+
interface ISubagentOptions {
|
|
326
|
+
/** Agent definition (built-in or custom). */
|
|
327
|
+
agentDefinition: IAgentDefinition;
|
|
328
|
+
/** Parent's resolved config (for provider, permissions, etc.). */
|
|
329
|
+
parentConfig: IResolvedConfig;
|
|
330
|
+
/** Parent's loaded context (CLAUDE.md, AGENTS.md). */
|
|
331
|
+
parentContext: ILoadedContext;
|
|
332
|
+
/** Parent session's available tools (to inherit/filter). */
|
|
333
|
+
parentTools: IToolWithEventService[];
|
|
334
|
+
/** Terminal output interface. */
|
|
335
|
+
terminal: ITerminalOutput;
|
|
336
|
+
/** Whether this is a fork worker (uses fork suffix instead of standard). */
|
|
337
|
+
isForkWorker?: boolean;
|
|
338
|
+
/** Permission mode from parent (bypassPermissions, acceptEdits, etc.). */
|
|
339
|
+
permissionMode?: TPermissionMode;
|
|
340
|
+
/** Permission handler from parent. */
|
|
341
|
+
permissionHandler?: TPermissionHandler;
|
|
342
|
+
/** Plugin hooks configuration from parent session. */
|
|
343
|
+
hooks?: Record<string, unknown>;
|
|
344
|
+
/** Hook type executors from parent session (prompt, agent, etc.). */
|
|
345
|
+
hookTypeExecutors?: IHookTypeExecutor[];
|
|
346
|
+
/** Streaming callback. */
|
|
347
|
+
onTextDelta?: (delta: string) => void;
|
|
348
|
+
/** Tool execution callback. */
|
|
349
|
+
onToolExecution?: (event: {
|
|
350
|
+
type: 'start' | 'end';
|
|
351
|
+
toolName: string;
|
|
352
|
+
toolArgs?: TToolArgs;
|
|
353
|
+
success?: boolean;
|
|
354
|
+
}) => void;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Create a fully-configured Session for subagent execution.
|
|
358
|
+
*
|
|
359
|
+
* Assembles provider, tools, and system prompt from parent context and
|
|
360
|
+
* agent definition, then returns a new Session instance.
|
|
361
|
+
*/
|
|
362
|
+
declare function createSubagentSession(options: ISubagentOptions): Session;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Subagent transcript logger — creates a FileSessionLogger that writes
|
|
366
|
+
* subagent session logs into a subdirectory of the parent session's log folder.
|
|
367
|
+
*
|
|
368
|
+
* Log structure:
|
|
369
|
+
* {baseLogsDir}/{parentSessionId}/subagents/{agentId}.jsonl
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Create a FileSessionLogger for a subagent session.
|
|
374
|
+
*
|
|
375
|
+
* The logger writes JSONL files into a `subagents/` subdirectory under the
|
|
376
|
+
* parent session's log folder. The directory is created if it does not exist.
|
|
377
|
+
*
|
|
378
|
+
* @param parentSessionId - ID of the parent session (used as directory name)
|
|
379
|
+
* @param agentId - Unique identifier for this subagent run
|
|
380
|
+
* @param baseLogsDir - Root logs directory (e.g., `.robota/logs`)
|
|
381
|
+
* @returns A FileSessionLogger writing to the subagent directory
|
|
382
|
+
*/
|
|
383
|
+
declare function createSubagentLogger(parentSessionId: string, _agentId: string, baseLogsDir: string): FileSessionLogger;
|
|
384
|
+
/**
|
|
385
|
+
* Resolve the subagent log directory path without creating it.
|
|
386
|
+
*
|
|
387
|
+
* Useful when the caller needs the path for display or configuration
|
|
388
|
+
* but does not want to create the directory immediately.
|
|
389
|
+
*
|
|
390
|
+
* @param parentSessionId - ID of the parent session
|
|
391
|
+
* @param baseLogsDir - Root logs directory
|
|
392
|
+
* @returns The resolved subagent log directory path
|
|
393
|
+
*/
|
|
394
|
+
declare function resolveSubagentLogDir(parentSessionId: string, baseLogsDir: string): string;
|
|
395
|
+
|
|
256
396
|
/**
|
|
257
397
|
* query() — single entry point for running an AI agent conversation.
|
|
258
398
|
* Automatically loads config, context, and project info.
|
|
@@ -674,14 +814,61 @@ declare class BundlePluginInstaller {
|
|
|
674
814
|
private defaultExec;
|
|
675
815
|
}
|
|
676
816
|
|
|
677
|
-
/**
|
|
817
|
+
/**
|
|
818
|
+
* All built-in agent definitions shipped with the SDK.
|
|
819
|
+
* Order matters: general-purpose is the default fallback.
|
|
820
|
+
*/
|
|
821
|
+
declare const BUILT_IN_AGENTS: IAgentDefinition[];
|
|
822
|
+
/**
|
|
823
|
+
* Look up a built-in agent definition by name.
|
|
824
|
+
* Returns `undefined` if no built-in agent matches.
|
|
825
|
+
*/
|
|
826
|
+
declare function getBuiltInAgent(name: string): IAgentDefinition | undefined;
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* AgentTool — spawn a sub-agent with isolated context.
|
|
830
|
+
*
|
|
831
|
+
* Uses `createSubagentSession` to assemble a child Session with filtered tools,
|
|
832
|
+
* model resolution, and framework system prompt. The sub-agent shares the same
|
|
833
|
+
* config and context but has its own conversation history.
|
|
834
|
+
*
|
|
835
|
+
* Each call to `createAgentTool(deps)` returns a fresh tool instance with deps
|
|
836
|
+
* captured in closure, eliminating module-level mutable state and enabling
|
|
837
|
+
* multiple concurrent sessions without race conditions.
|
|
838
|
+
*/
|
|
839
|
+
|
|
840
|
+
/** Dependencies injected at creation time via createAgentTool factory */
|
|
678
841
|
interface IAgentToolDeps {
|
|
679
842
|
config: IResolvedConfig;
|
|
680
843
|
context: ILoadedContext;
|
|
681
|
-
|
|
844
|
+
tools: IToolWithEventService[];
|
|
845
|
+
terminal: ITerminalOutput;
|
|
846
|
+
/** Permission mode from parent session (bypassPermissions, acceptEdits, etc.). */
|
|
847
|
+
permissionMode?: TPermissionMode;
|
|
848
|
+
permissionHandler?: TPermissionHandler;
|
|
849
|
+
/** Plugin hooks configuration from parent session. */
|
|
850
|
+
hooks?: Record<string, unknown>;
|
|
851
|
+
/** Hook type executors from parent session (prompt, agent, etc.). */
|
|
852
|
+
hookTypeExecutors?: IHookTypeExecutor[];
|
|
853
|
+
onTextDelta?: (delta: string) => void;
|
|
854
|
+
onToolExecution?: (event: {
|
|
855
|
+
type: 'start' | 'end';
|
|
856
|
+
toolName: string;
|
|
857
|
+
toolArgs?: TToolArgs;
|
|
858
|
+
success?: boolean;
|
|
859
|
+
}) => void;
|
|
860
|
+
/** Optional custom agent registry for resolving non-built-in agent types. */
|
|
861
|
+
customAgentRegistry?: (name: string) => IAgentDefinition | undefined;
|
|
682
862
|
}
|
|
683
|
-
/**
|
|
684
|
-
declare function
|
|
685
|
-
|
|
863
|
+
/** Store agent tool deps keyed by a session (or any object). */
|
|
864
|
+
declare function storeAgentToolDeps(key: object, deps: IAgentToolDeps): void;
|
|
865
|
+
/** Retrieve agent tool deps for a given session key. */
|
|
866
|
+
declare function retrieveAgentToolDeps(key: object): IAgentToolDeps | undefined;
|
|
867
|
+
/**
|
|
868
|
+
* Create an agent tool instance with deps captured in closure.
|
|
869
|
+
*
|
|
870
|
+
* Each session gets its own tool instance — no shared mutable state.
|
|
871
|
+
*/
|
|
872
|
+
declare function createAgentTool(deps: IAgentToolDeps): ReturnType<typeof createZodFunctionTool>;
|
|
686
873
|
|
|
687
|
-
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,
|
|
874
|
+
export { AgentExecutor, BUILT_IN_AGENTS, BundlePluginInstaller, BundlePluginLoader, DEFAULT_TOOL_DESCRIPTIONS, type IAgentDefinition, type IAgentExecutorOptions, type IAgentSession, type IAgentToolDeps, 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 ISubagentOptions, type ISubagentPromptOptions, type ISystemPromptParams, MarketplaceClient, PluginSettingsStore, PromptExecutor, type TEnabledPlugins, type TProviderFactory, type TSessionFactory, assembleSubagentPrompt, buildSystemPrompt, createAgentTool, createDefaultTools, createProvider, createSession, createSubagentLogger, createSubagentSession, detectProject, getBuiltInAgent, getForkWorkerSuffix, getSubagentSuffix, loadConfig, loadContext, projectPaths, promptForApproval, query, resolveSubagentLogDir, retrieveAgentToolDeps, storeAgentToolDeps, userPaths };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
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
|
-
import
|
|
3
|
+
import { createZodFunctionTool } from '@robota-sdk/agent-tools';
|
|
4
4
|
export { TToolResult, bashTool, editTool, globTool, grepTool, readTool, writeTool } from '@robota-sdk/agent-tools';
|
|
5
|
-
import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session } from '@robota-sdk/agent-sessions';
|
|
5
|
+
import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session, FileSessionLogger } 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
8
|
/**
|
|
@@ -253,6 +253,146 @@ declare function createDefaultTools(): IToolWithEventService[];
|
|
|
253
253
|
*/
|
|
254
254
|
declare function createProvider(config: IResolvedConfig): IAIProvider;
|
|
255
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Framework system prompt suffixes for subagent sessions.
|
|
258
|
+
*
|
|
259
|
+
* These functions generate the standard prompt content injected into
|
|
260
|
+
* subagent sessions to control output format and behavior.
|
|
261
|
+
*/
|
|
262
|
+
/** Options for assembling a subagent system prompt. */
|
|
263
|
+
interface ISubagentPromptOptions {
|
|
264
|
+
/** Agent definition markdown body. */
|
|
265
|
+
agentBody: string;
|
|
266
|
+
/** CLAUDE.md content to include. */
|
|
267
|
+
claudeMd?: string;
|
|
268
|
+
/** AGENTS.md content to include. */
|
|
269
|
+
agentsMd?: string;
|
|
270
|
+
/** When true, use fork worker suffix instead of standard subagent suffix. */
|
|
271
|
+
isForkWorker: boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Returns the standard subagent suffix appended to agent body for normal subagents.
|
|
275
|
+
*/
|
|
276
|
+
declare function getSubagentSuffix(): string;
|
|
277
|
+
/**
|
|
278
|
+
* Returns the fork worker suffix for context:fork skill workers.
|
|
279
|
+
*/
|
|
280
|
+
declare function getForkWorkerSuffix(): string;
|
|
281
|
+
/**
|
|
282
|
+
* Assembles the full system prompt for a subagent.
|
|
283
|
+
*
|
|
284
|
+
* Assembly order:
|
|
285
|
+
* 1. Agent definition body
|
|
286
|
+
* 2. CLAUDE.md content (if provided)
|
|
287
|
+
* 3. AGENTS.md content (if provided)
|
|
288
|
+
* 4. Framework suffix (fork worker OR standard subagent)
|
|
289
|
+
*/
|
|
290
|
+
declare function assembleSubagentPrompt(options: ISubagentPromptOptions): string;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Definition of an agent that can be spawned as a subagent.
|
|
294
|
+
*
|
|
295
|
+
* Built-in agents and custom (user-defined) agents share this shape.
|
|
296
|
+
* Optional fields inherit from the parent session when omitted.
|
|
297
|
+
*/
|
|
298
|
+
interface IAgentDefinition {
|
|
299
|
+
/** Unique name used to reference the agent (e.g., 'Explore', 'Plan'). */
|
|
300
|
+
name: string;
|
|
301
|
+
/** Human-readable description of the agent's purpose. */
|
|
302
|
+
description: string;
|
|
303
|
+
/** Markdown body content used as the agent's system prompt. */
|
|
304
|
+
systemPrompt: string;
|
|
305
|
+
/** Model override (e.g., 'claude-haiku-4-5', 'sonnet', 'opus'). Inherits parent model when omitted. */
|
|
306
|
+
model?: string;
|
|
307
|
+
/** Maximum number of agentic turns the subagent may execute. */
|
|
308
|
+
maxTurns?: number;
|
|
309
|
+
/** Allowlist of tool names. Only these tools are available when set. */
|
|
310
|
+
tools?: string[];
|
|
311
|
+
/** Denylist of tool names. These tools are removed from the inherited set. */
|
|
312
|
+
disallowedTools?: string[];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Subagent session factory — assembles an isolated child Session for subagent execution.
|
|
317
|
+
*
|
|
318
|
+
* Unlike `createSession`, this factory does not load config files or context from disk.
|
|
319
|
+
* It receives pre-resolved config and context from the parent session, applies tool
|
|
320
|
+
* filtering and model resolution from the agent definition, and creates a lightweight
|
|
321
|
+
* Session suitable for subagent use.
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/** Options for creating a subagent session. */
|
|
325
|
+
interface ISubagentOptions {
|
|
326
|
+
/** Agent definition (built-in or custom). */
|
|
327
|
+
agentDefinition: IAgentDefinition;
|
|
328
|
+
/** Parent's resolved config (for provider, permissions, etc.). */
|
|
329
|
+
parentConfig: IResolvedConfig;
|
|
330
|
+
/** Parent's loaded context (CLAUDE.md, AGENTS.md). */
|
|
331
|
+
parentContext: ILoadedContext;
|
|
332
|
+
/** Parent session's available tools (to inherit/filter). */
|
|
333
|
+
parentTools: IToolWithEventService[];
|
|
334
|
+
/** Terminal output interface. */
|
|
335
|
+
terminal: ITerminalOutput;
|
|
336
|
+
/** Whether this is a fork worker (uses fork suffix instead of standard). */
|
|
337
|
+
isForkWorker?: boolean;
|
|
338
|
+
/** Permission mode from parent (bypassPermissions, acceptEdits, etc.). */
|
|
339
|
+
permissionMode?: TPermissionMode;
|
|
340
|
+
/** Permission handler from parent. */
|
|
341
|
+
permissionHandler?: TPermissionHandler;
|
|
342
|
+
/** Plugin hooks configuration from parent session. */
|
|
343
|
+
hooks?: Record<string, unknown>;
|
|
344
|
+
/** Hook type executors from parent session (prompt, agent, etc.). */
|
|
345
|
+
hookTypeExecutors?: IHookTypeExecutor[];
|
|
346
|
+
/** Streaming callback. */
|
|
347
|
+
onTextDelta?: (delta: string) => void;
|
|
348
|
+
/** Tool execution callback. */
|
|
349
|
+
onToolExecution?: (event: {
|
|
350
|
+
type: 'start' | 'end';
|
|
351
|
+
toolName: string;
|
|
352
|
+
toolArgs?: TToolArgs;
|
|
353
|
+
success?: boolean;
|
|
354
|
+
}) => void;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Create a fully-configured Session for subagent execution.
|
|
358
|
+
*
|
|
359
|
+
* Assembles provider, tools, and system prompt from parent context and
|
|
360
|
+
* agent definition, then returns a new Session instance.
|
|
361
|
+
*/
|
|
362
|
+
declare function createSubagentSession(options: ISubagentOptions): Session;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Subagent transcript logger — creates a FileSessionLogger that writes
|
|
366
|
+
* subagent session logs into a subdirectory of the parent session's log folder.
|
|
367
|
+
*
|
|
368
|
+
* Log structure:
|
|
369
|
+
* {baseLogsDir}/{parentSessionId}/subagents/{agentId}.jsonl
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Create a FileSessionLogger for a subagent session.
|
|
374
|
+
*
|
|
375
|
+
* The logger writes JSONL files into a `subagents/` subdirectory under the
|
|
376
|
+
* parent session's log folder. The directory is created if it does not exist.
|
|
377
|
+
*
|
|
378
|
+
* @param parentSessionId - ID of the parent session (used as directory name)
|
|
379
|
+
* @param agentId - Unique identifier for this subagent run
|
|
380
|
+
* @param baseLogsDir - Root logs directory (e.g., `.robota/logs`)
|
|
381
|
+
* @returns A FileSessionLogger writing to the subagent directory
|
|
382
|
+
*/
|
|
383
|
+
declare function createSubagentLogger(parentSessionId: string, _agentId: string, baseLogsDir: string): FileSessionLogger;
|
|
384
|
+
/**
|
|
385
|
+
* Resolve the subagent log directory path without creating it.
|
|
386
|
+
*
|
|
387
|
+
* Useful when the caller needs the path for display or configuration
|
|
388
|
+
* but does not want to create the directory immediately.
|
|
389
|
+
*
|
|
390
|
+
* @param parentSessionId - ID of the parent session
|
|
391
|
+
* @param baseLogsDir - Root logs directory
|
|
392
|
+
* @returns The resolved subagent log directory path
|
|
393
|
+
*/
|
|
394
|
+
declare function resolveSubagentLogDir(parentSessionId: string, baseLogsDir: string): string;
|
|
395
|
+
|
|
256
396
|
/**
|
|
257
397
|
* query() — single entry point for running an AI agent conversation.
|
|
258
398
|
* Automatically loads config, context, and project info.
|
|
@@ -674,14 +814,61 @@ declare class BundlePluginInstaller {
|
|
|
674
814
|
private defaultExec;
|
|
675
815
|
}
|
|
676
816
|
|
|
677
|
-
/**
|
|
817
|
+
/**
|
|
818
|
+
* All built-in agent definitions shipped with the SDK.
|
|
819
|
+
* Order matters: general-purpose is the default fallback.
|
|
820
|
+
*/
|
|
821
|
+
declare const BUILT_IN_AGENTS: IAgentDefinition[];
|
|
822
|
+
/**
|
|
823
|
+
* Look up a built-in agent definition by name.
|
|
824
|
+
* Returns `undefined` if no built-in agent matches.
|
|
825
|
+
*/
|
|
826
|
+
declare function getBuiltInAgent(name: string): IAgentDefinition | undefined;
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* AgentTool — spawn a sub-agent with isolated context.
|
|
830
|
+
*
|
|
831
|
+
* Uses `createSubagentSession` to assemble a child Session with filtered tools,
|
|
832
|
+
* model resolution, and framework system prompt. The sub-agent shares the same
|
|
833
|
+
* config and context but has its own conversation history.
|
|
834
|
+
*
|
|
835
|
+
* Each call to `createAgentTool(deps)` returns a fresh tool instance with deps
|
|
836
|
+
* captured in closure, eliminating module-level mutable state and enabling
|
|
837
|
+
* multiple concurrent sessions without race conditions.
|
|
838
|
+
*/
|
|
839
|
+
|
|
840
|
+
/** Dependencies injected at creation time via createAgentTool factory */
|
|
678
841
|
interface IAgentToolDeps {
|
|
679
842
|
config: IResolvedConfig;
|
|
680
843
|
context: ILoadedContext;
|
|
681
|
-
|
|
844
|
+
tools: IToolWithEventService[];
|
|
845
|
+
terminal: ITerminalOutput;
|
|
846
|
+
/** Permission mode from parent session (bypassPermissions, acceptEdits, etc.). */
|
|
847
|
+
permissionMode?: TPermissionMode;
|
|
848
|
+
permissionHandler?: TPermissionHandler;
|
|
849
|
+
/** Plugin hooks configuration from parent session. */
|
|
850
|
+
hooks?: Record<string, unknown>;
|
|
851
|
+
/** Hook type executors from parent session (prompt, agent, etc.). */
|
|
852
|
+
hookTypeExecutors?: IHookTypeExecutor[];
|
|
853
|
+
onTextDelta?: (delta: string) => void;
|
|
854
|
+
onToolExecution?: (event: {
|
|
855
|
+
type: 'start' | 'end';
|
|
856
|
+
toolName: string;
|
|
857
|
+
toolArgs?: TToolArgs;
|
|
858
|
+
success?: boolean;
|
|
859
|
+
}) => void;
|
|
860
|
+
/** Optional custom agent registry for resolving non-built-in agent types. */
|
|
861
|
+
customAgentRegistry?: (name: string) => IAgentDefinition | undefined;
|
|
682
862
|
}
|
|
683
|
-
/**
|
|
684
|
-
declare function
|
|
685
|
-
|
|
863
|
+
/** Store agent tool deps keyed by a session (or any object). */
|
|
864
|
+
declare function storeAgentToolDeps(key: object, deps: IAgentToolDeps): void;
|
|
865
|
+
/** Retrieve agent tool deps for a given session key. */
|
|
866
|
+
declare function retrieveAgentToolDeps(key: object): IAgentToolDeps | undefined;
|
|
867
|
+
/**
|
|
868
|
+
* Create an agent tool instance with deps captured in closure.
|
|
869
|
+
*
|
|
870
|
+
* Each session gets its own tool instance — no shared mutable state.
|
|
871
|
+
*/
|
|
872
|
+
declare function createAgentTool(deps: IAgentToolDeps): ReturnType<typeof createZodFunctionTool>;
|
|
686
873
|
|
|
687
|
-
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,
|
|
874
|
+
export { AgentExecutor, BUILT_IN_AGENTS, BundlePluginInstaller, BundlePluginLoader, DEFAULT_TOOL_DESCRIPTIONS, type IAgentDefinition, type IAgentExecutorOptions, type IAgentSession, type IAgentToolDeps, 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 ISubagentOptions, type ISubagentPromptOptions, type ISystemPromptParams, MarketplaceClient, PluginSettingsStore, PromptExecutor, type TEnabledPlugins, type TProviderFactory, type TSessionFactory, assembleSubagentPrompt, buildSystemPrompt, createAgentTool, createDefaultTools, createProvider, createSession, createSubagentLogger, createSubagentSession, detectProject, getBuiltInAgent, getForkWorkerSuffix, getSubagentSuffix, loadConfig, loadContext, projectPaths, promptForApproval, query, resolveSubagentLogDir, retrieveAgentToolDeps, storeAgentToolDeps, userPaths };
|