@robota-sdk/agent-sdk 3.0.0-beta.43 → 3.0.0-beta.45

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.
@@ -1,9 +1,9 @@
1
- import { IHookTypeExecutor, IHookDefinition, IHookInput, IHookResult, THooksConfig, TTrustLevel, TPermissionMode, IAIProvider, TToolArgs, IToolWithEventService, TUniversalMessage, IContextWindowState } from '@robota-sdk/agent-core';
2
- export { IContextTokenUsage, IContextWindowState, IHookInput, IPermissionLists, THookEvent, THooksConfig, TPermissionDecision, TPermissionMode, TRUST_TO_MODE, TToolArgs, TTrustLevel, evaluatePermission, runHooks } from '@robota-sdk/agent-core';
1
+ import { IHookTypeExecutor, IHookDefinition, IHookInput, IHookResult, THooksConfig, TTrustLevel, TPermissionMode, IAIProvider, TToolArgs, IToolWithEventService, IHistoryEntry, IContextWindowState, TUniversalMessage } from '@robota-sdk/agent-core';
2
+ 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';
3
+ import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session, FileSessionLogger } from '@robota-sdk/agent-sessions';
4
+ export { ISpinner, ITerminalOutput } from '@robota-sdk/agent-sessions';
3
5
  import { createZodFunctionTool } from '@robota-sdk/agent-tools';
4
- export { TToolResult, bashTool, editTool, globTool, grepTool, readTool, writeTool } from '@robota-sdk/agent-tools';
5
- import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session, FileSessionLogger, TPermissionResult } from '@robota-sdk/agent-sessions';
6
- export { FileSessionLogger, ISessionLogger, ISessionOptions, ISessionRecord, ISpinner, ITerminalOutput, Session, SessionStore, SilentSessionLogger, TPermissionHandler, TPermissionResult, TSessionLogData } from '@robota-sdk/agent-sessions';
6
+ export { TToolResult } from '@robota-sdk/agent-tools';
7
7
 
8
8
  /**
9
9
  * Prompt hook executor — evaluates a prompt via an AI model.
@@ -112,13 +112,6 @@ interface ILoadedContext {
112
112
  /** Extracted "Compact Instructions" section from CLAUDE.md, if present */
113
113
  compactInstructions?: string;
114
114
  }
115
- /**
116
- * Load all AGENTS.md and CLAUDE.md files found by walking up from `cwd`.
117
- * Files from higher directories appear before files from lower directories.
118
- *
119
- * @param cwd - Starting directory for the walk-up search
120
- */
121
- declare function loadContext(cwd: string): Promise<ILoadedContext>;
122
115
 
123
116
  type TProjectType = 'node' | 'python' | 'rust' | 'go' | 'unknown';
124
117
  type TPackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';
@@ -129,10 +122,6 @@ interface IProjectInfo {
129
122
  packageManager?: TPackageManager;
130
123
  language: TLanguage;
131
124
  }
132
- /**
133
- * Detect the project type, language, name, and package manager from `cwd`.
134
- */
135
- declare function detectProject(cwd: string): Promise<IProjectInfo>;
136
125
 
137
126
  /**
138
127
  * System prompt builder — assembles the system message sent to the AI model
@@ -162,7 +151,6 @@ interface ISystemPromptParams {
162
151
  disableModelInvocation?: boolean;
163
152
  }>;
164
153
  }
165
- declare function buildSystemPrompt(params: ISystemPromptParams): string;
166
154
 
167
155
  /**
168
156
  * Session factory — assembles a fully-configured Session from config, context,
@@ -223,35 +211,6 @@ interface ICreateSessionOptions {
223
211
  /** Additional hook type executors beyond the defaults (prompt, agent). */
224
212
  additionalHookExecutors?: IHookTypeExecutor[];
225
213
  }
226
- /**
227
- * Create a fully-configured Session instance.
228
- *
229
- * Assembles provider, tools, and system prompt, then passes them
230
- * to Session as pre-constructed dependencies.
231
- */
232
- declare function createSession(options: ICreateSessionOptions): Session;
233
-
234
- /**
235
- * Default tool set factory — creates the standard set of CLI tools.
236
- */
237
-
238
- /** Human-readable descriptions of the built-in tools (for system prompt) */
239
- declare const DEFAULT_TOOL_DESCRIPTIONS: string[];
240
- /**
241
- * Create the default set of CLI tools.
242
- * Returns the 8 standard tools as IToolWithEventService[].
243
- */
244
- declare function createDefaultTools(): IToolWithEventService[];
245
-
246
- /**
247
- * Provider factory — creates an AI provider from resolved config.
248
- */
249
-
250
- /**
251
- * Create an AI provider from the resolved config.
252
- * Currently supports Anthropic only. Throws if no API key is available.
253
- */
254
- declare function createProvider(config: IResolvedConfig): IAIProvider;
255
214
 
256
215
  /**
257
216
  * Framework system prompt suffixes for subagent sessions.
@@ -331,6 +290,8 @@ interface ISubagentOptions {
331
290
  parentContext: ILoadedContext;
332
291
  /** Parent session's available tools (to inherit/filter). */
333
292
  parentTools: IToolWithEventService[];
293
+ /** AI provider instance. */
294
+ provider: IAIProvider;
334
295
  /** Terminal output interface. */
335
296
  terminal: ITerminalOutput;
336
297
  /** Whether this is a fork worker (uses fork suffix instead of standard). */
@@ -394,63 +355,265 @@ declare function createSubagentLogger(parentSessionId: string, _agentId: string,
394
355
  declare function resolveSubagentLogDir(parentSessionId: string, baseLogsDir: string): string;
395
356
 
396
357
  /**
397
- * query() — single entry point for running an AI agent conversation.
398
- * Automatically loads config, context, and project info.
358
+ * Types for InteractiveSession event-driven session wrapper.
399
359
  */
400
360
 
401
- interface IQueryOptions {
402
- cwd?: string;
403
- permissionMode?: TPermissionMode;
404
- maxTurns?: number;
405
- provider?: IAIProvider;
406
- permissionHandler?: (toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
407
- onTextDelta?: (delta: string) => void;
408
- /** Callback when context is compacted */
409
- onCompact?: (summary: string) => void;
361
+ /** Permission handler result — SDK-owned type (mirrors agent-sessions TPermissionResult).
362
+ * true = allow, false = deny, 'allow-session' = allow and remember for this session. */
363
+ type TPermissionResultValue = boolean | 'allow-session';
364
+ /** Tool execution state visible to clients. */
365
+ interface IToolState {
366
+ toolName: string;
367
+ firstArg: string;
368
+ isRunning: boolean;
369
+ result?: 'success' | 'error' | 'denied';
370
+ diffLines?: IDiffLine[];
371
+ diffFile?: string;
410
372
  }
411
- /**
412
- * query() — single entry point for running an AI agent conversation.
413
- * Equivalent to Claude Agent SDK's query() function.
414
- * Automatically loads config, context, and project info.
415
- */
416
- declare function query(prompt: string, options?: IQueryOptions): Promise<string>;
373
+ /** A single diff line for Edit tool display. */
374
+ interface IDiffLine {
375
+ type: 'add' | 'remove' | 'context';
376
+ text: string;
377
+ lineNumber: number;
378
+ }
379
+ /** Result of a completed prompt execution. */
380
+ interface IExecutionResult {
381
+ response: string;
382
+ history: IHistoryEntry[];
383
+ toolSummaries: IToolSummary[];
384
+ contextState: IContextWindowState;
385
+ }
386
+ /** Summary of a tool call extracted from history. */
387
+ interface IToolSummary {
388
+ name: string;
389
+ args: string;
390
+ }
391
+ /** Permission handler delegate — clients provide their own UI. */
392
+ type TInteractivePermissionHandler = (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResultValue>;
393
+ /** Events emitted by InteractiveSession. */
394
+ interface IInteractiveSessionEvents {
395
+ text_delta: (delta: string) => void;
396
+ tool_start: (state: IToolState) => void;
397
+ tool_end: (state: IToolState) => void;
398
+ thinking: (isThinking: boolean) => void;
399
+ complete: (result: IExecutionResult) => void;
400
+ error: (error: Error) => void;
401
+ context_update: (state: IContextWindowState) => void;
402
+ interrupted: (result: IExecutionResult) => void;
403
+ }
404
+ type TInteractiveEventName = keyof IInteractiveSessionEvents;
417
405
 
418
406
  /**
419
- * Load and merge all settings files, validate with Zod, return resolved config.
407
+ * InteractiveSession the single entry point for all SDK consumers.
420
408
  *
421
- * @param cwd - The working directory (project root) to search for settings
409
+ * Wraps Session (composition). Manages streaming text accumulation,
410
+ * tool execution state tracking, prompt queuing, abort orchestration,
411
+ * message history, and system command execution.
412
+ *
413
+ * Config/context loading is internal. Consumer provides cwd + provider.
422
414
  */
423
- declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
424
415
 
425
- /**
426
- * Interactive permission prompt — asks the user whether to allow a tool invocation
427
- * using an arrow-key selector. Canonical implementation (SSOT).
428
- * Used by both agent-sdk query() and agent-cli.
429
- */
416
+ /** Standard construction: cwd + provider. Config/context loaded internally. */
417
+ interface IInteractiveSessionStandardOptions {
418
+ cwd: string;
419
+ provider: IAIProvider;
420
+ permissionMode?: ICreateSessionOptions['permissionMode'];
421
+ maxTurns?: number;
422
+ permissionHandler?: TInteractivePermissionHandler;
423
+ }
424
+ /** Test/advanced construction: inject pre-built session directly. */
425
+ interface IInteractiveSessionInjectedOptions {
426
+ session: Session;
427
+ cwd?: string;
428
+ provider?: IAIProvider;
429
+ permissionMode?: ICreateSessionOptions['permissionMode'];
430
+ maxTurns?: number;
431
+ permissionHandler?: TInteractivePermissionHandler;
432
+ }
433
+ type IInteractiveSessionOptions = IInteractiveSessionStandardOptions | IInteractiveSessionInjectedOptions;
434
+ declare class InteractiveSession {
435
+ private session;
436
+ private readonly commandExecutor;
437
+ private readonly listeners;
438
+ private initialized;
439
+ private initPromise;
440
+ private streamingText;
441
+ private flushTimer;
442
+ private activeTools;
443
+ private executing;
444
+ private pendingPrompt;
445
+ private pendingDisplayInput;
446
+ private pendingRawInput;
447
+ private history;
448
+ constructor(options: IInteractiveSessionOptions);
449
+ private initializeAsync;
450
+ private ensureInitialized;
451
+ private getSessionOrThrow;
452
+ on<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
453
+ off<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
454
+ private emit;
455
+ /** Submit a prompt. Queues if already executing (max 1 queued). */
456
+ submit(input: string, displayInput?: string, rawInput?: string): Promise<void>;
457
+ /** Execute a system command by name. Returns null if not found. */
458
+ executeCommand(name: string, args: string): Promise<{
459
+ message: string;
460
+ success: boolean;
461
+ data?: Record<string, unknown>;
462
+ } | null>;
463
+ /** List all registered system commands. */
464
+ listCommands(): Array<{
465
+ name: string;
466
+ description: string;
467
+ }>;
468
+ /** Abort current execution and clear queue. */
469
+ abort(): void;
470
+ /** Cancel queued prompt without aborting current execution. */
471
+ cancelQueue(): void;
472
+ isExecuting(): boolean;
473
+ getPendingPrompt(): string | null;
474
+ /** Get full history timeline (chat + events) for TUI rendering */
475
+ getFullHistory(): IHistoryEntry[];
476
+ /** Get chat messages only (backward compatible) */
477
+ getMessages(): TUniversalMessage[];
478
+ getStreamingText(): string;
479
+ getActiveTools(): IToolState[];
480
+ getContextState(): IContextWindowState;
481
+ /** Access underlying Session. For advanced use / testing only. */
482
+ getSession(): Session;
483
+ private executePrompt;
484
+ private handleTextDelta;
485
+ private handleToolExecution;
486
+ /** Push tool execution summary into messages (before Robota response).
487
+ * Moves tool info from activeTools (real-time display) to messages (permanent display).
488
+ * After this, activeTools will be cleared by clearStreaming(). */
489
+ private pushToolSummaryMessage;
490
+ private clearStreaming;
491
+ private flushStreaming;
492
+ private buildResult;
493
+ private buildInterruptedResult;
494
+ private extractToolSummaries;
495
+ private trimCompletedTools;
496
+ }
430
497
 
431
498
  /**
432
- * Prompt the user for approval before running a tool.
499
+ * createQuery() factory that returns a prompt-only convenience function.
500
+ *
501
+ * Usage:
502
+ * const query = createQuery({ provider });
503
+ * const answer = await query('What files are here?');
433
504
  */
434
- declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
435
505
 
506
+ interface ICreateQueryOptions {
507
+ /** AI provider instance (required). */
508
+ provider: IAIProvider;
509
+ /** Working directory. Defaults to process.cwd(). */
510
+ cwd?: string;
511
+ /** Permission mode. Defaults to 'bypassPermissions' for programmatic use. */
512
+ permissionMode?: TPermissionMode;
513
+ /** Maximum agentic turns per query. */
514
+ maxTurns?: number;
515
+ /** Permission handler callback. */
516
+ permissionHandler?: TInteractivePermissionHandler;
517
+ /** Streaming text callback. */
518
+ onTextDelta?: (delta: string) => void;
519
+ }
436
520
  /**
437
- * Standard Robota storage paths.
521
+ * Create a prompt-only query function bound to a provider.
438
522
  *
439
- * All CLI runtime data lives under .robota/ (project) or ~/.robota/ (user).
440
- * .agents/ is read-only from CLI's perspective (owned by AGENTS.md standard).
523
+ * ```typescript
524
+ * import { createQuery } from '@robota-sdk/agent-sdk';
525
+ * import { AnthropicProvider } from '@robota-sdk/agent-provider-anthropic';
526
+ *
527
+ * const query = createQuery({ provider: new AnthropicProvider({ apiKey: '...' }) });
528
+ * const answer = await query('List all TypeScript files');
529
+ * ```
441
530
  */
442
- /** Project-level .robota/ paths (relative to cwd). */
443
- declare function projectPaths(cwd: string): {
444
- settings: string;
445
- settingsLocal: string;
446
- logs: string;
447
- sessions: string;
448
- };
449
- /** User-level ~/.robota/ paths. */
450
- declare function userPaths(): {
451
- settings: string;
452
- sessions: string;
453
- };
531
+ declare function createQuery(options: ICreateQueryOptions): (prompt: string) => Promise<string>;
532
+
533
+ /** A command entry */
534
+ interface ICommand {
535
+ /** Command name without slash (e.g., "mode") */
536
+ name: string;
537
+ /** Short description shown in autocomplete */
538
+ description: string;
539
+ /** Source identifier (e.g., "builtin", "skill") */
540
+ source: string;
541
+ /** Subcommands for hierarchical menus */
542
+ subcommands?: ICommand[];
543
+ /** Execute the command. Args is everything after the command name. */
544
+ execute?: (args: string) => void | Promise<void>;
545
+ /** Full SKILL.md content (only for skill commands) */
546
+ skillContent?: string;
547
+ /** Hint for the expected argument (Claude Code frontmatter) */
548
+ argumentHint?: string;
549
+ /** When true, models cannot invoke this skill autonomously */
550
+ disableModelInvocation?: boolean;
551
+ /** When false, users cannot invoke this skill directly */
552
+ userInvocable?: boolean;
553
+ /** List of tools this skill is allowed to use */
554
+ allowedTools?: string[];
555
+ /** Preferred model for executing this skill */
556
+ model?: string;
557
+ /** Effort level hint for the skill */
558
+ effort?: string;
559
+ /** Context scope for the skill (e.g., "project") */
560
+ context?: string;
561
+ /** Agent identity to use when executing this skill */
562
+ agent?: string;
563
+ /** Plugin installation directory (plugin skills/commands only) */
564
+ pluginDir?: string;
565
+ }
566
+ /** A source that provides commands */
567
+ interface ICommandSource {
568
+ name: string;
569
+ getCommands(): ICommand[];
570
+ }
571
+
572
+ /** Aggregates commands from multiple sources */
573
+ declare class CommandRegistry {
574
+ private sources;
575
+ addSource(source: ICommandSource): void;
576
+ /** Get all commands, optionally filtered by prefix */
577
+ getCommands(filter?: string): ICommand[];
578
+ /** Resolve a short name to its fully qualified plugin:name form */
579
+ resolveQualifiedName(shortName: string): string | null;
580
+ /** Get subcommands for a specific command */
581
+ getSubcommands(commandName: string): ICommand[];
582
+ }
583
+
584
+ /** Command source for built-in commands */
585
+ declare class BuiltinCommandSource implements ICommandSource {
586
+ readonly name = "builtin";
587
+ private readonly commands;
588
+ constructor();
589
+ getCommands(): ICommand[];
590
+ }
591
+
592
+ interface IFrontmatter {
593
+ name?: string;
594
+ description?: string;
595
+ argumentHint?: string;
596
+ disableModelInvocation?: boolean;
597
+ userInvocable?: boolean;
598
+ allowedTools?: string[];
599
+ model?: string;
600
+ effort?: string;
601
+ context?: string;
602
+ agent?: string;
603
+ }
604
+ /** Parse YAML-like frontmatter between --- markers */
605
+ declare function parseFrontmatter(content: string): IFrontmatter | null;
606
+ /** Command source that discovers skills from multiple directories */
607
+ declare class SkillCommandSource implements ICommandSource {
608
+ readonly name = "skill";
609
+ private readonly cwd;
610
+ private readonly home;
611
+ private cachedCommands;
612
+ constructor(cwd: string, home?: string);
613
+ getCommands(): ICommand[];
614
+ getModelInvocableSkills(): ICommand[];
615
+ getUserInvocableSkills(): ICommand[];
616
+ }
454
617
 
455
618
  /**
456
619
  * PluginSettingsStore — single point of read/write for plugin-related settings.
@@ -814,6 +977,75 @@ declare class BundlePluginInstaller {
814
977
  private defaultExec;
815
978
  }
816
979
 
980
+ /**
981
+ * Command source that discovers skills and commands from loaded BundlePlugins.
982
+ *
983
+ * - Skills: exposed as `/name` with `(plugin-name)` hint in description.
984
+ * - Commands: exposed as `/plugin:command` (already namespaced by the loader).
985
+ */
986
+ declare class PluginCommandSource implements ICommandSource {
987
+ readonly name = "plugin";
988
+ private readonly plugins;
989
+ constructor(plugins: ILoadedBundlePlugin[]);
990
+ getCommands(): ICommand[];
991
+ }
992
+
993
+ /**
994
+ * System commands — SDK-level command execution logic.
995
+ *
996
+ * Pure functions that operate on InteractiveSession.
997
+ * No React, no TUI, no framework dependencies.
998
+ * CLI wraps these as slash commands with UI chrome.
999
+ */
1000
+
1001
+ /** Result of a system command execution. */
1002
+ interface ICommandResult {
1003
+ /** Human-readable output message */
1004
+ message: string;
1005
+ /** Command completed successfully */
1006
+ success: boolean;
1007
+ /** Additional structured data (command-specific) */
1008
+ data?: Record<string, unknown>;
1009
+ }
1010
+ /** A system command with name, description, and execute logic. */
1011
+ interface ISystemCommand {
1012
+ name: string;
1013
+ description: string;
1014
+ execute(session: InteractiveSession, args: string): Promise<ICommandResult> | ICommandResult;
1015
+ }
1016
+
1017
+ /**
1018
+ * Build a skill prompt from slash command input.
1019
+ * Supports variable substitution and shell command preprocessing.
1020
+ */
1021
+
1022
+ /** Context variables available during skill prompt processing */
1023
+ interface SkillPromptContext {
1024
+ /** Current session ID — substituted for ${CLAUDE_SESSION_ID} */
1025
+ sessionId?: string;
1026
+ /** Directory containing SKILL.md — substituted for ${CLAUDE_SKILL_DIR} */
1027
+ skillDir?: string;
1028
+ }
1029
+ /**
1030
+ * Substitute variables in skill content.
1031
+ *
1032
+ * Supported variables:
1033
+ * - `$ARGUMENTS` — all arguments passed to the skill
1034
+ * - `$ARGUMENTS[N]` — argument by index (0-based)
1035
+ * - `$N` — shorthand for `$ARGUMENTS[N]` (single digit, 0-9)
1036
+ * - `${CLAUDE_SESSION_ID}` — current session ID
1037
+ * - `${CLAUDE_SKILL_DIR}` — directory containing SKILL.md
1038
+ */
1039
+ declare function substituteVariables(content: string, args: string, context?: SkillPromptContext): string;
1040
+ /**
1041
+ * Preprocess shell commands in skill content.
1042
+ * Matches `` !`...` `` patterns and replaces them with command output.
1043
+ * Commands have a 5-second timeout.
1044
+ */
1045
+ declare function preprocessShellCommands(content: string): Promise<string>;
1046
+ /** Build a skill prompt from a slash command input and registry */
1047
+ declare function buildSkillPrompt(input: string, registry: CommandRegistry, context?: SkillPromptContext): Promise<string | null>;
1048
+
817
1049
  /**
818
1050
  * All built-in agent definitions shipped with the SDK.
819
1051
  * Order matters: general-purpose is the default fallback.
@@ -843,6 +1075,8 @@ interface IAgentToolDeps {
843
1075
  context: ILoadedContext;
844
1076
  tools: IToolWithEventService[];
845
1077
  terminal: ITerminalOutput;
1078
+ /** AI provider instance (passed from consumer). */
1079
+ provider: IAIProvider;
846
1080
  /** Permission mode from parent session (bypassPermissions, acceptEdits, etc.). */
847
1081
  permissionMode?: TPermissionMode;
848
1082
  permissionHandler?: TPermissionHandler;
@@ -871,238 +1105,34 @@ declare function retrieveAgentToolDeps(key: object): IAgentToolDeps | undefined;
871
1105
  */
872
1106
  declare function createAgentTool(deps: IAgentToolDeps): ReturnType<typeof createZodFunctionTool>;
873
1107
 
874
- /** A slash command entry */
875
- interface ISlashCommand {
876
- /** Command name without slash (e.g., "mode") */
877
- name: string;
878
- /** Short description shown in autocomplete */
879
- description: string;
880
- /** Source identifier (e.g., "builtin", "skill") */
881
- source: string;
882
- /** Subcommands for hierarchical menus */
883
- subcommands?: ISlashCommand[];
884
- /** Execute the command. Args is everything after the command name. */
885
- execute?: (args: string) => void | Promise<void>;
886
- /** Full SKILL.md content (only for skill commands) */
887
- skillContent?: string;
888
- /** Hint for the expected argument (Claude Code frontmatter) */
889
- argumentHint?: string;
890
- /** When true, models cannot invoke this skill autonomously */
891
- disableModelInvocation?: boolean;
892
- /** When false, users cannot invoke this skill directly */
893
- userInvocable?: boolean;
894
- /** List of tools this skill is allowed to use */
895
- allowedTools?: string[];
896
- /** Preferred model for executing this skill */
897
- model?: string;
898
- /** Effort level hint for the skill */
899
- effort?: string;
900
- /** Context scope for the skill (e.g., "project") */
901
- context?: string;
902
- /** Agent identity to use when executing this skill */
903
- agent?: string;
904
- /** Plugin installation directory (plugin skills/commands only) */
905
- pluginDir?: string;
906
- }
907
- /** A source that provides slash commands */
908
- interface ICommandSource {
909
- name: string;
910
- getCommands(): ISlashCommand[];
911
- }
912
-
913
- /** Aggregates commands from multiple sources */
914
- declare class CommandRegistry {
915
- private sources;
916
- addSource(source: ICommandSource): void;
917
- /** Get all commands, optionally filtered by prefix */
918
- getCommands(filter?: string): ISlashCommand[];
919
- /** Resolve a short name to its fully qualified plugin:name form */
920
- resolveQualifiedName(shortName: string): string | null;
921
- /** Get subcommands for a specific command */
922
- getSubcommands(commandName: string): ISlashCommand[];
923
- }
924
-
925
- /** Command source for built-in commands */
926
- declare class BuiltinCommandSource implements ICommandSource {
927
- readonly name = "builtin";
928
- private readonly commands;
929
- constructor();
930
- getCommands(): ISlashCommand[];
931
- }
932
-
933
- interface IFrontmatter {
934
- name?: string;
935
- description?: string;
936
- argumentHint?: string;
937
- disableModelInvocation?: boolean;
938
- userInvocable?: boolean;
939
- allowedTools?: string[];
940
- model?: string;
941
- effort?: string;
942
- context?: string;
943
- agent?: string;
944
- }
945
- /** Parse YAML-like frontmatter between --- markers */
946
- declare function parseFrontmatter(content: string): IFrontmatter | null;
947
- /** Command source that discovers skills from multiple directories */
948
- declare class SkillCommandSource implements ICommandSource {
949
- readonly name = "skill";
950
- private readonly cwd;
951
- private readonly home;
952
- private cachedCommands;
953
- constructor(cwd: string, home?: string);
954
- getCommands(): ISlashCommand[];
955
- getModelInvocableSkills(): ISlashCommand[];
956
- getUserInvocableSkills(): ISlashCommand[];
957
- }
958
-
959
1108
  /**
960
- * Types for InteractiveSession — event-driven session wrapper.
1109
+ * Standard Robota storage paths.
1110
+ *
1111
+ * All CLI runtime data lives under .robota/ (project) or ~/.robota/ (user).
1112
+ * .agents/ is read-only from CLI's perspective (owned by AGENTS.md standard).
961
1113
  */
962
-
963
- /** Tool execution state visible to clients. */
964
- interface IToolState {
965
- toolName: string;
966
- firstArg: string;
967
- isRunning: boolean;
968
- result?: 'success' | 'error' | 'denied';
969
- diffLines?: IDiffLine[];
970
- diffFile?: string;
971
- }
972
- /** A single diff line for Edit tool display. */
973
- interface IDiffLine {
974
- type: 'add' | 'remove' | 'context';
975
- content: string;
976
- lineNumber?: number;
977
- }
978
- /** Result of a completed prompt execution. */
979
- interface IExecutionResult {
980
- response: string;
981
- messages: TUniversalMessage[];
982
- toolSummaries: IToolSummary[];
983
- contextState: IContextWindowState;
984
- }
985
- /** Summary of a tool call extracted from history. */
986
- interface IToolSummary {
987
- name: string;
988
- args: string;
989
- }
990
- /** Permission handler delegate — clients provide their own UI. */
991
- type TInteractivePermissionHandler = (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResult>;
992
- /** Events emitted by InteractiveSession. */
993
- interface IInteractiveSessionEvents {
994
- text_delta: (delta: string) => void;
995
- tool_start: (state: IToolState) => void;
996
- tool_end: (state: IToolState) => void;
997
- thinking: (isThinking: boolean) => void;
998
- complete: (result: IExecutionResult) => void;
999
- error: (error: Error) => void;
1000
- context_update: (state: IContextWindowState) => void;
1001
- interrupted: (result: IExecutionResult) => void;
1002
- }
1003
- type TInteractiveEventName = keyof IInteractiveSessionEvents;
1114
+ /** Project-level .robota/ paths (relative to cwd). */
1115
+ declare function projectPaths(cwd: string): {
1116
+ settings: string;
1117
+ settingsLocal: string;
1118
+ logs: string;
1119
+ sessions: string;
1120
+ };
1121
+ /** User-level ~/.robota/ paths. */
1122
+ declare function userPaths(): {
1123
+ settings: string;
1124
+ sessions: string;
1125
+ };
1004
1126
 
1005
1127
  /**
1006
- * InteractiveSessionevent-driven session wrapper for any client.
1007
- *
1008
- * Wraps Session (composition) to provide streaming text accumulation,
1009
- * tool execution state tracking, prompt queuing, abort orchestration,
1010
- * and message history management. Previously embedded in CLI React hooks.
1011
- *
1012
- * Clients (CLI, web, API server, Dynamic Worker) subscribe to events
1013
- * and call submit/abort/cancelQueue.
1128
+ * Interactive permission prompt asks the user whether to allow a tool invocation
1129
+ * using an arrow-key selector. Canonical implementation (SSOT).
1130
+ * Used by both agent-sdk query() and agent-cli.
1014
1131
  */
1015
1132
 
1016
- interface IInteractiveSessionOptions {
1017
- config: ICreateSessionOptions['config'];
1018
- context: ICreateSessionOptions['context'];
1019
- projectInfo?: ICreateSessionOptions['projectInfo'];
1020
- sessionStore?: ICreateSessionOptions['sessionStore'];
1021
- permissionMode?: ICreateSessionOptions['permissionMode'];
1022
- maxTurns?: number;
1023
- cwd?: string;
1024
- permissionHandler?: TInteractivePermissionHandler;
1025
- /** Optional: inject pre-built session (for testing). */
1026
- session?: Session;
1027
- }
1028
- declare class InteractiveSession {
1029
- private readonly session;
1030
- private readonly listeners;
1031
- private streamingText;
1032
- private flushTimer;
1033
- private activeTools;
1034
- private executing;
1035
- private pendingPrompt;
1036
- private pendingDisplayInput;
1037
- private pendingRawInput;
1038
- private messages;
1039
- constructor(options: IInteractiveSessionOptions);
1040
- on<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
1041
- off<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
1042
- private emit;
1043
- /** Submit a prompt. Queues if already executing (max 1 queued).
1044
- * displayInput overrides what appears as the user message (e.g., "/audit" instead of full skill prompt).
1045
- * rawInput is passed to Session.run() for hook matching (e.g., "/rulebased-harness:audit"). */
1046
- submit(input: string, displayInput?: string, rawInput?: string): Promise<void>;
1047
- /** Abort current execution and clear queue. */
1048
- abort(): void;
1049
- /** Cancel queued prompt without aborting current execution. */
1050
- cancelQueue(): void;
1051
- isExecuting(): boolean;
1052
- getPendingPrompt(): string | null;
1053
- getMessages(): TUniversalMessage[];
1054
- getStreamingText(): string;
1055
- getActiveTools(): IToolState[];
1056
- getContextState(): IContextWindowState;
1057
- getSession(): Session;
1058
- private executePrompt;
1059
- private handleTextDelta;
1060
- private handleToolExecution;
1061
- private clearStreaming;
1062
- private flushStreaming;
1063
- private buildResult;
1064
- private buildInterruptedResult;
1065
- private extractToolSummaries;
1066
- private trimCompletedTools;
1067
- }
1068
-
1069
1133
  /**
1070
- * System commands SDK-level command execution logic.
1071
- *
1072
- * Pure functions that operate on InteractiveSession.
1073
- * No React, no TUI, no framework dependencies.
1074
- * CLI wraps these as slash commands with UI chrome.
1134
+ * Prompt the user for approval before running a tool.
1075
1135
  */
1136
+ declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
1076
1137
 
1077
- /** Result of a system command execution. */
1078
- interface ICommandResult {
1079
- /** Human-readable output message */
1080
- message: string;
1081
- /** Command completed successfully */
1082
- success: boolean;
1083
- /** Additional structured data (command-specific) */
1084
- data?: Record<string, unknown>;
1085
- }
1086
- /** A system command with name, description, and execute logic. */
1087
- interface ISystemCommand {
1088
- name: string;
1089
- description: string;
1090
- execute(session: InteractiveSession, args: string): Promise<ICommandResult> | ICommandResult;
1091
- }
1092
- /** Built-in system commands. */
1093
- declare function createSystemCommands(): ISystemCommand[];
1094
- /** Registry for system commands. */
1095
- declare class SystemCommandExecutor {
1096
- private readonly commands;
1097
- constructor(commands?: ISystemCommand[]);
1098
- /** Register an additional command. */
1099
- register(command: ISystemCommand): void;
1100
- /** Execute a command by name. Returns null if command not found. */
1101
- execute(name: string, session: InteractiveSession, args: string): Promise<ICommandResult | null>;
1102
- /** List all registered commands. */
1103
- listCommands(): ISystemCommand[];
1104
- /** Check if a command exists. */
1105
- hasCommand(name: string): boolean;
1106
- }
1107
-
1108
- export { AgentExecutor, BUILT_IN_AGENTS, BuiltinCommandSource, BundlePluginInstaller, BundlePluginLoader, CommandRegistry, DEFAULT_TOOL_DESCRIPTIONS, type IAgentDefinition, type IAgentExecutorOptions, type IAgentSession, type IAgentToolDeps, type IBundlePluginFeatures, type IBundlePluginInstallerOptions, type IBundlePluginManifest, type IBundleSkill, type ICommandResult, type ICommandSource, type ICreateSessionOptions, type IDiffLine, type IExecutionResult, type IInstalledPluginRecord, type IInstalledPluginsRegistry, type IInteractiveSessionEvents, type IInteractiveSessionOptions, 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 ISlashCommand, type ISubagentOptions, type ISubagentPromptOptions, type ISystemCommand, type ISystemPromptParams, type IToolState, type IToolSummary, InteractiveSession, MarketplaceClient, PluginSettingsStore, PromptExecutor, SkillCommandSource, SystemCommandExecutor, type TEnabledPlugins, type TInteractiveEventName, type TInteractivePermissionHandler, type TProviderFactory, type TSessionFactory, assembleSubagentPrompt, buildSystemPrompt, createAgentTool, createDefaultTools, createProvider, createSession, createSubagentLogger, createSubagentSession, createSystemCommands, detectProject, getBuiltInAgent, getForkWorkerSuffix, getSubagentSuffix, loadConfig, loadContext, parseFrontmatter, projectPaths, promptForApproval, query, resolveSubagentLogDir, retrieveAgentToolDeps, storeAgentToolDeps, userPaths };
1138
+ 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, 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 };