@robota-sdk/agent-sdk 3.0.0-beta.52 → 3.0.0-beta.53
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 +712 -685
- package/dist/node/index.d.cts +96 -116
- package/dist/node/index.d.ts +96 -116
- package/dist/node/index.js +937 -918
- package/package.json +4 -4
package/dist/node/index.d.cts
CHANGED
|
@@ -1,10 +1,73 @@
|
|
|
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
1
|
import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session, FileSessionLogger } from '@robota-sdk/agent-sessions';
|
|
4
2
|
export { ISpinner, ITerminalOutput } from '@robota-sdk/agent-sessions';
|
|
3
|
+
import { TToolArgs, IHistoryEntry, IContextWindowState, IHookTypeExecutor, IHookDefinition, IHookInput, IHookResult, THooksConfig, TTrustLevel, TPermissionMode, IAIProvider, IToolWithEventService, TUniversalMessage } from '@robota-sdk/agent-core';
|
|
4
|
+
export { IAIProvider, IContextTokenUsage, IContextWindowState, IHistoryEntry, IHookInput, IPermissionLists, THookEvent, THooksConfig, TPermissionDecision, TPermissionMode, TRUST_TO_MODE, TToolArgs, TTrustLevel, chatEntryToMessage, evaluatePermission, getMessagesForAPI, isChatEntry, messageToHistoryEntry, runHooks } from '@robota-sdk/agent-core';
|
|
5
5
|
import { createZodFunctionTool } from '@robota-sdk/agent-tools';
|
|
6
6
|
export { TToolResult } from '@robota-sdk/agent-tools';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Types for InteractiveSession — event-driven session wrapper.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Permission handler result — SDK-owned type (mirrors agent-sessions TPermissionResult).
|
|
13
|
+
* true = allow, false = deny, 'allow-session' = allow and remember for this session. */
|
|
14
|
+
type TPermissionResultValue = boolean | 'allow-session';
|
|
15
|
+
/** Tool execution state visible to clients. */
|
|
16
|
+
interface IToolState {
|
|
17
|
+
toolName: string;
|
|
18
|
+
firstArg: string;
|
|
19
|
+
isRunning: boolean;
|
|
20
|
+
result?: 'success' | 'error' | 'denied';
|
|
21
|
+
diffLines?: IDiffLine[];
|
|
22
|
+
diffFile?: string;
|
|
23
|
+
}
|
|
24
|
+
/** A single diff line for Edit tool display. */
|
|
25
|
+
interface IDiffLine {
|
|
26
|
+
type: 'add' | 'remove' | 'context';
|
|
27
|
+
text: string;
|
|
28
|
+
lineNumber: number;
|
|
29
|
+
}
|
|
30
|
+
/** Result of a completed prompt execution. */
|
|
31
|
+
interface IExecutionResult {
|
|
32
|
+
response: string;
|
|
33
|
+
history: IHistoryEntry[];
|
|
34
|
+
toolSummaries: IToolSummary[];
|
|
35
|
+
contextState: IContextWindowState;
|
|
36
|
+
}
|
|
37
|
+
/** Summary of a tool call extracted from history. */
|
|
38
|
+
interface IToolSummary {
|
|
39
|
+
name: string;
|
|
40
|
+
args: string;
|
|
41
|
+
}
|
|
42
|
+
/** Permission handler delegate — clients provide their own UI. */
|
|
43
|
+
type TInteractivePermissionHandler = (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResultValue>;
|
|
44
|
+
/** Events emitted by InteractiveSession. */
|
|
45
|
+
interface IInteractiveSessionEvents {
|
|
46
|
+
text_delta: (delta: string) => void;
|
|
47
|
+
tool_start: (state: IToolState) => void;
|
|
48
|
+
tool_end: (state: IToolState) => void;
|
|
49
|
+
thinking: (isThinking: boolean) => void;
|
|
50
|
+
complete: (result: IExecutionResult) => void;
|
|
51
|
+
error: (error: Error) => void;
|
|
52
|
+
context_update: (state: IContextWindowState) => void;
|
|
53
|
+
interrupted: (result: IExecutionResult) => void;
|
|
54
|
+
}
|
|
55
|
+
type TInteractiveEventName = keyof IInteractiveSessionEvents;
|
|
56
|
+
/**
|
|
57
|
+
* Common interface for all transport adapters.
|
|
58
|
+
* Each transport exposes InteractiveSession over a specific protocol.
|
|
59
|
+
*/
|
|
60
|
+
interface ITransportAdapter {
|
|
61
|
+
/** Human-readable transport name (e.g., 'http', 'ws', 'mcp', 'headless') */
|
|
62
|
+
readonly name: string;
|
|
63
|
+
/** Attach an InteractiveSession to this transport. */
|
|
64
|
+
attach(session: InteractiveSession): void;
|
|
65
|
+
/** Start serving. What this means depends on the transport. */
|
|
66
|
+
start(): Promise<void>;
|
|
67
|
+
/** Stop serving and clean up resources. */
|
|
68
|
+
stop(): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
|
|
8
71
|
/**
|
|
9
72
|
* Prompt hook executor — evaluates a prompt via an AI model.
|
|
10
73
|
*
|
|
@@ -357,76 +420,10 @@ declare function createSubagentLogger(parentSessionId: string, _agentId: string,
|
|
|
357
420
|
declare function resolveSubagentLogDir(parentSessionId: string, baseLogsDir: string): string;
|
|
358
421
|
|
|
359
422
|
/**
|
|
360
|
-
*
|
|
361
|
-
*/
|
|
362
|
-
|
|
363
|
-
/** Permission handler result — SDK-owned type (mirrors agent-sessions TPermissionResult).
|
|
364
|
-
* true = allow, false = deny, 'allow-session' = allow and remember for this session. */
|
|
365
|
-
type TPermissionResultValue = boolean | 'allow-session';
|
|
366
|
-
/** Tool execution state visible to clients. */
|
|
367
|
-
interface IToolState {
|
|
368
|
-
toolName: string;
|
|
369
|
-
firstArg: string;
|
|
370
|
-
isRunning: boolean;
|
|
371
|
-
result?: 'success' | 'error' | 'denied';
|
|
372
|
-
diffLines?: IDiffLine[];
|
|
373
|
-
diffFile?: string;
|
|
374
|
-
}
|
|
375
|
-
/** A single diff line for Edit tool display. */
|
|
376
|
-
interface IDiffLine {
|
|
377
|
-
type: 'add' | 'remove' | 'context';
|
|
378
|
-
text: string;
|
|
379
|
-
lineNumber: number;
|
|
380
|
-
}
|
|
381
|
-
/** Result of a completed prompt execution. */
|
|
382
|
-
interface IExecutionResult {
|
|
383
|
-
response: string;
|
|
384
|
-
history: IHistoryEntry[];
|
|
385
|
-
toolSummaries: IToolSummary[];
|
|
386
|
-
contextState: IContextWindowState;
|
|
387
|
-
}
|
|
388
|
-
/** Summary of a tool call extracted from history. */
|
|
389
|
-
interface IToolSummary {
|
|
390
|
-
name: string;
|
|
391
|
-
args: string;
|
|
392
|
-
}
|
|
393
|
-
/** Permission handler delegate — clients provide their own UI. */
|
|
394
|
-
type TInteractivePermissionHandler = (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResultValue>;
|
|
395
|
-
/** Events emitted by InteractiveSession. */
|
|
396
|
-
interface IInteractiveSessionEvents {
|
|
397
|
-
text_delta: (delta: string) => void;
|
|
398
|
-
tool_start: (state: IToolState) => void;
|
|
399
|
-
tool_end: (state: IToolState) => void;
|
|
400
|
-
thinking: (isThinking: boolean) => void;
|
|
401
|
-
complete: (result: IExecutionResult) => void;
|
|
402
|
-
error: (error: Error) => void;
|
|
403
|
-
context_update: (state: IContextWindowState) => void;
|
|
404
|
-
interrupted: (result: IExecutionResult) => void;
|
|
405
|
-
}
|
|
406
|
-
type TInteractiveEventName = keyof IInteractiveSessionEvents;
|
|
407
|
-
/**
|
|
408
|
-
* Common interface for all transport adapters.
|
|
409
|
-
* Each transport exposes InteractiveSession over a specific protocol.
|
|
410
|
-
*/
|
|
411
|
-
interface ITransportAdapter {
|
|
412
|
-
/** Human-readable transport name (e.g., 'http', 'ws', 'mcp', 'headless') */
|
|
413
|
-
readonly name: string;
|
|
414
|
-
/** Attach an InteractiveSession to this transport. */
|
|
415
|
-
attach(session: InteractiveSession): void;
|
|
416
|
-
/** Start serving. What this means depends on the transport. */
|
|
417
|
-
start(): Promise<void>;
|
|
418
|
-
/** Stop serving and clean up resources. */
|
|
419
|
-
stop(): Promise<void>;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* InteractiveSession — the single entry point for all SDK consumers.
|
|
423
|
+
* Session initialization helpers for InteractiveSession.
|
|
424
424
|
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
* message history, and system command execution.
|
|
428
|
-
*
|
|
429
|
-
* Config/context loading is internal. Consumer provides cwd + provider.
|
|
425
|
+
* Handles async config/context loading, plugin merging, and session creation.
|
|
426
|
+
* Also provides session-restore (resume/fork) logic.
|
|
430
427
|
*/
|
|
431
428
|
|
|
432
429
|
/** Standard construction: cwd + provider. Config/context loaded internally. */
|
|
@@ -454,7 +451,19 @@ interface IInteractiveSessionInjectedOptions {
|
|
|
454
451
|
resumeSessionId?: string;
|
|
455
452
|
forkSession?: boolean;
|
|
456
453
|
}
|
|
454
|
+
/** Union of standard and injected construction options. */
|
|
457
455
|
type IInteractiveSessionOptions = IInteractiveSessionStandardOptions | IInteractiveSessionInjectedOptions;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* InteractiveSession — the single entry point for all SDK consumers.
|
|
459
|
+
*
|
|
460
|
+
* Wraps Session (composition). Manages streaming text accumulation,
|
|
461
|
+
* tool execution state tracking, prompt queuing, abort orchestration,
|
|
462
|
+
* message history, and system command execution.
|
|
463
|
+
*
|
|
464
|
+
* Config/context loading is internal. Consumer provides cwd + provider.
|
|
465
|
+
*/
|
|
466
|
+
|
|
458
467
|
declare class InteractiveSession {
|
|
459
468
|
private session;
|
|
460
469
|
private readonly commandExecutor;
|
|
@@ -482,53 +491,35 @@ declare class InteractiveSession {
|
|
|
482
491
|
on<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
483
492
|
off<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
484
493
|
private emit;
|
|
485
|
-
/** Submit a prompt. Queues if already executing (max 1 queued). */
|
|
486
494
|
submit(input: string, displayInput?: string, rawInput?: string): Promise<void>;
|
|
487
|
-
/** Execute a system command by name. Returns null if not found. */
|
|
488
495
|
executeCommand(name: string, args: string): Promise<{
|
|
489
496
|
message: string;
|
|
490
497
|
success: boolean;
|
|
491
498
|
data?: Record<string, unknown>;
|
|
492
499
|
} | null>;
|
|
493
|
-
/** List all registered system commands. */
|
|
494
500
|
listCommands(): Array<{
|
|
495
501
|
name: string;
|
|
496
502
|
description: string;
|
|
497
503
|
}>;
|
|
498
|
-
/** Abort current execution and clear queue. */
|
|
499
504
|
abort(): void;
|
|
500
|
-
/** Cancel queued prompt without aborting current execution. */
|
|
501
505
|
cancelQueue(): void;
|
|
506
|
+
private clearPendingQueue;
|
|
502
507
|
isExecuting(): boolean;
|
|
503
508
|
getPendingPrompt(): string | null;
|
|
504
|
-
/** Get full history timeline (chat + events) for TUI rendering */
|
|
505
509
|
getFullHistory(): IHistoryEntry[];
|
|
506
|
-
/** Get chat messages only (backward compatible) */
|
|
507
510
|
getMessages(): TUniversalMessage[];
|
|
508
511
|
getStreamingText(): string;
|
|
509
512
|
getActiveTools(): IToolState[];
|
|
510
513
|
getContextState(): IContextWindowState;
|
|
511
|
-
/** Get session name. */
|
|
512
514
|
getName(): string | undefined;
|
|
513
|
-
|
|
515
|
+
getSession(): Session;
|
|
514
516
|
setName(name: string): void;
|
|
515
|
-
/** Attach a transport adapter to this session. Calls transport.attach(this). */
|
|
516
517
|
attachTransport(transport: ITransportAdapter): void;
|
|
517
|
-
/** Access underlying Session. For advanced use / testing only. */
|
|
518
|
-
getSession(): Session;
|
|
519
518
|
private executePrompt;
|
|
520
519
|
private handleTextDelta;
|
|
521
520
|
private handleToolExecution;
|
|
522
|
-
/** Push tool execution summary into messages (before Robota response).
|
|
523
|
-
* Moves tool info from activeTools (real-time display) to messages (permanent display).
|
|
524
|
-
* After this, activeTools will be cleared by clearStreaming(). */
|
|
525
|
-
private pushToolSummaryMessage;
|
|
526
521
|
private clearStreaming;
|
|
527
522
|
private flushStreaming;
|
|
528
|
-
private buildResult;
|
|
529
|
-
private buildInterruptedResult;
|
|
530
|
-
private extractToolSummaries;
|
|
531
|
-
private trimCompletedTools;
|
|
532
523
|
}
|
|
533
524
|
|
|
534
525
|
/**
|
|
@@ -796,11 +787,7 @@ declare class BundlePluginLoader {
|
|
|
796
787
|
}
|
|
797
788
|
|
|
798
789
|
/**
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
* Marketplaces are git repositories containing `.claude-plugin/marketplace.json`.
|
|
802
|
-
* They are cloned to `~/.robota/plugins/marketplaces/<name>/` and tracked
|
|
803
|
-
* in `known_marketplaces.json`.
|
|
790
|
+
* Shared types for marketplace client and registry.
|
|
804
791
|
*/
|
|
805
792
|
/** Source specification for a marketplace. */
|
|
806
793
|
type IMarketplaceSource = {
|
|
@@ -858,6 +845,15 @@ interface IMarketplaceClientOptions {
|
|
|
858
845
|
/** Custom exec function for testing (replaces child_process.execSync). */
|
|
859
846
|
exec?: ExecFn$1;
|
|
860
847
|
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* MarketplaceClient — manages marketplace registries via shallow git clones.
|
|
851
|
+
*
|
|
852
|
+
* Marketplaces are git repositories containing `.claude-plugin/marketplace.json`.
|
|
853
|
+
* They are cloned to `~/.robota/plugins/marketplaces/<name>/` and tracked
|
|
854
|
+
* in `known_marketplaces.json`.
|
|
855
|
+
*/
|
|
856
|
+
|
|
861
857
|
/** Manages marketplace registries via shallow git clones. */
|
|
862
858
|
declare class MarketplaceClient {
|
|
863
859
|
private readonly pluginsDir;
|
|
@@ -868,10 +864,9 @@ declare class MarketplaceClient {
|
|
|
868
864
|
/**
|
|
869
865
|
* Add a marketplace by cloning its repository.
|
|
870
866
|
*
|
|
871
|
-
* 1.
|
|
872
|
-
* 2.
|
|
873
|
-
* 3.
|
|
874
|
-
* 4. Register in `known_marketplaces.json`.
|
|
867
|
+
* 1. Shallow git clone (`--depth 1`) to `marketplaces/<name>/`.
|
|
868
|
+
* 2. Read `.claude-plugin/marketplace.json` for the `name` field.
|
|
869
|
+
* 3. Register in `known_marketplaces.json`.
|
|
875
870
|
*
|
|
876
871
|
* Returns the registered marketplace name from the manifest.
|
|
877
872
|
*/
|
|
@@ -886,9 +881,6 @@ declare class MarketplaceClient {
|
|
|
886
881
|
* Update a marketplace by running git pull on its clone.
|
|
887
882
|
* The manifest is re-read from disk on demand (via fetchManifest), so the
|
|
888
883
|
* updated manifest is automatically available after pull.
|
|
889
|
-
*
|
|
890
|
-
* TODO: After pull, detect version changes in installed plugins and offer
|
|
891
|
-
* to update them (re-install at new version).
|
|
892
884
|
*/
|
|
893
885
|
updateMarketplace(name: string): void;
|
|
894
886
|
/** List all registered marketplaces. */
|
|
@@ -897,9 +889,7 @@ declare class MarketplaceClient {
|
|
|
897
889
|
source: IMarketplaceSource;
|
|
898
890
|
lastUpdated: string;
|
|
899
891
|
}>;
|
|
900
|
-
/**
|
|
901
|
-
* Read the marketplace manifest from a registered marketplace's clone.
|
|
902
|
-
*/
|
|
892
|
+
/** Read the marketplace manifest from a registered marketplace's clone. */
|
|
903
893
|
fetchManifest(marketplaceName: string): IMarketplaceManifest;
|
|
904
894
|
/** Get the clone directory path for a registered marketplace. */
|
|
905
895
|
getMarketplaceDir(name: string): string;
|
|
@@ -914,18 +904,8 @@ declare class MarketplaceClient {
|
|
|
914
904
|
}>;
|
|
915
905
|
/** Resolve a marketplace source to a git clone URL. */
|
|
916
906
|
private resolveCloneUrl;
|
|
917
|
-
/**
|
|
918
|
-
* Remove all installed plugins that belong to a given marketplace.
|
|
919
|
-
* Reads installed_plugins.json, deletes cache directories for matching plugins,
|
|
920
|
-
* and updates the registry.
|
|
921
|
-
*/
|
|
922
|
-
private removeInstalledPluginsForMarketplace;
|
|
923
907
|
/** Read and parse a marketplace.json from a file path. */
|
|
924
908
|
private readManifestFromPath;
|
|
925
|
-
/** Read the known_marketplaces.json registry. */
|
|
926
|
-
private readRegistry;
|
|
927
|
-
/** Write the known_marketplaces.json registry. */
|
|
928
|
-
private writeRegistry;
|
|
929
909
|
/** Default exec implementation using child_process. */
|
|
930
910
|
private defaultExec;
|
|
931
911
|
}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,10 +1,73 @@
|
|
|
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
1
|
import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session, FileSessionLogger } from '@robota-sdk/agent-sessions';
|
|
4
2
|
export { ISpinner, ITerminalOutput } from '@robota-sdk/agent-sessions';
|
|
3
|
+
import { TToolArgs, IHistoryEntry, IContextWindowState, IHookTypeExecutor, IHookDefinition, IHookInput, IHookResult, THooksConfig, TTrustLevel, TPermissionMode, IAIProvider, IToolWithEventService, TUniversalMessage } from '@robota-sdk/agent-core';
|
|
4
|
+
export { IAIProvider, IContextTokenUsage, IContextWindowState, IHistoryEntry, IHookInput, IPermissionLists, THookEvent, THooksConfig, TPermissionDecision, TPermissionMode, TRUST_TO_MODE, TToolArgs, TTrustLevel, chatEntryToMessage, evaluatePermission, getMessagesForAPI, isChatEntry, messageToHistoryEntry, runHooks } from '@robota-sdk/agent-core';
|
|
5
5
|
import { createZodFunctionTool } from '@robota-sdk/agent-tools';
|
|
6
6
|
export { TToolResult } from '@robota-sdk/agent-tools';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Types for InteractiveSession — event-driven session wrapper.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Permission handler result — SDK-owned type (mirrors agent-sessions TPermissionResult).
|
|
13
|
+
* true = allow, false = deny, 'allow-session' = allow and remember for this session. */
|
|
14
|
+
type TPermissionResultValue = boolean | 'allow-session';
|
|
15
|
+
/** Tool execution state visible to clients. */
|
|
16
|
+
interface IToolState {
|
|
17
|
+
toolName: string;
|
|
18
|
+
firstArg: string;
|
|
19
|
+
isRunning: boolean;
|
|
20
|
+
result?: 'success' | 'error' | 'denied';
|
|
21
|
+
diffLines?: IDiffLine[];
|
|
22
|
+
diffFile?: string;
|
|
23
|
+
}
|
|
24
|
+
/** A single diff line for Edit tool display. */
|
|
25
|
+
interface IDiffLine {
|
|
26
|
+
type: 'add' | 'remove' | 'context';
|
|
27
|
+
text: string;
|
|
28
|
+
lineNumber: number;
|
|
29
|
+
}
|
|
30
|
+
/** Result of a completed prompt execution. */
|
|
31
|
+
interface IExecutionResult {
|
|
32
|
+
response: string;
|
|
33
|
+
history: IHistoryEntry[];
|
|
34
|
+
toolSummaries: IToolSummary[];
|
|
35
|
+
contextState: IContextWindowState;
|
|
36
|
+
}
|
|
37
|
+
/** Summary of a tool call extracted from history. */
|
|
38
|
+
interface IToolSummary {
|
|
39
|
+
name: string;
|
|
40
|
+
args: string;
|
|
41
|
+
}
|
|
42
|
+
/** Permission handler delegate — clients provide their own UI. */
|
|
43
|
+
type TInteractivePermissionHandler = (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResultValue>;
|
|
44
|
+
/** Events emitted by InteractiveSession. */
|
|
45
|
+
interface IInteractiveSessionEvents {
|
|
46
|
+
text_delta: (delta: string) => void;
|
|
47
|
+
tool_start: (state: IToolState) => void;
|
|
48
|
+
tool_end: (state: IToolState) => void;
|
|
49
|
+
thinking: (isThinking: boolean) => void;
|
|
50
|
+
complete: (result: IExecutionResult) => void;
|
|
51
|
+
error: (error: Error) => void;
|
|
52
|
+
context_update: (state: IContextWindowState) => void;
|
|
53
|
+
interrupted: (result: IExecutionResult) => void;
|
|
54
|
+
}
|
|
55
|
+
type TInteractiveEventName = keyof IInteractiveSessionEvents;
|
|
56
|
+
/**
|
|
57
|
+
* Common interface for all transport adapters.
|
|
58
|
+
* Each transport exposes InteractiveSession over a specific protocol.
|
|
59
|
+
*/
|
|
60
|
+
interface ITransportAdapter {
|
|
61
|
+
/** Human-readable transport name (e.g., 'http', 'ws', 'mcp', 'headless') */
|
|
62
|
+
readonly name: string;
|
|
63
|
+
/** Attach an InteractiveSession to this transport. */
|
|
64
|
+
attach(session: InteractiveSession): void;
|
|
65
|
+
/** Start serving. What this means depends on the transport. */
|
|
66
|
+
start(): Promise<void>;
|
|
67
|
+
/** Stop serving and clean up resources. */
|
|
68
|
+
stop(): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
|
|
8
71
|
/**
|
|
9
72
|
* Prompt hook executor — evaluates a prompt via an AI model.
|
|
10
73
|
*
|
|
@@ -357,76 +420,10 @@ declare function createSubagentLogger(parentSessionId: string, _agentId: string,
|
|
|
357
420
|
declare function resolveSubagentLogDir(parentSessionId: string, baseLogsDir: string): string;
|
|
358
421
|
|
|
359
422
|
/**
|
|
360
|
-
*
|
|
361
|
-
*/
|
|
362
|
-
|
|
363
|
-
/** Permission handler result — SDK-owned type (mirrors agent-sessions TPermissionResult).
|
|
364
|
-
* true = allow, false = deny, 'allow-session' = allow and remember for this session. */
|
|
365
|
-
type TPermissionResultValue = boolean | 'allow-session';
|
|
366
|
-
/** Tool execution state visible to clients. */
|
|
367
|
-
interface IToolState {
|
|
368
|
-
toolName: string;
|
|
369
|
-
firstArg: string;
|
|
370
|
-
isRunning: boolean;
|
|
371
|
-
result?: 'success' | 'error' | 'denied';
|
|
372
|
-
diffLines?: IDiffLine[];
|
|
373
|
-
diffFile?: string;
|
|
374
|
-
}
|
|
375
|
-
/** A single diff line for Edit tool display. */
|
|
376
|
-
interface IDiffLine {
|
|
377
|
-
type: 'add' | 'remove' | 'context';
|
|
378
|
-
text: string;
|
|
379
|
-
lineNumber: number;
|
|
380
|
-
}
|
|
381
|
-
/** Result of a completed prompt execution. */
|
|
382
|
-
interface IExecutionResult {
|
|
383
|
-
response: string;
|
|
384
|
-
history: IHistoryEntry[];
|
|
385
|
-
toolSummaries: IToolSummary[];
|
|
386
|
-
contextState: IContextWindowState;
|
|
387
|
-
}
|
|
388
|
-
/** Summary of a tool call extracted from history. */
|
|
389
|
-
interface IToolSummary {
|
|
390
|
-
name: string;
|
|
391
|
-
args: string;
|
|
392
|
-
}
|
|
393
|
-
/** Permission handler delegate — clients provide their own UI. */
|
|
394
|
-
type TInteractivePermissionHandler = (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResultValue>;
|
|
395
|
-
/** Events emitted by InteractiveSession. */
|
|
396
|
-
interface IInteractiveSessionEvents {
|
|
397
|
-
text_delta: (delta: string) => void;
|
|
398
|
-
tool_start: (state: IToolState) => void;
|
|
399
|
-
tool_end: (state: IToolState) => void;
|
|
400
|
-
thinking: (isThinking: boolean) => void;
|
|
401
|
-
complete: (result: IExecutionResult) => void;
|
|
402
|
-
error: (error: Error) => void;
|
|
403
|
-
context_update: (state: IContextWindowState) => void;
|
|
404
|
-
interrupted: (result: IExecutionResult) => void;
|
|
405
|
-
}
|
|
406
|
-
type TInteractiveEventName = keyof IInteractiveSessionEvents;
|
|
407
|
-
/**
|
|
408
|
-
* Common interface for all transport adapters.
|
|
409
|
-
* Each transport exposes InteractiveSession over a specific protocol.
|
|
410
|
-
*/
|
|
411
|
-
interface ITransportAdapter {
|
|
412
|
-
/** Human-readable transport name (e.g., 'http', 'ws', 'mcp', 'headless') */
|
|
413
|
-
readonly name: string;
|
|
414
|
-
/** Attach an InteractiveSession to this transport. */
|
|
415
|
-
attach(session: InteractiveSession): void;
|
|
416
|
-
/** Start serving. What this means depends on the transport. */
|
|
417
|
-
start(): Promise<void>;
|
|
418
|
-
/** Stop serving and clean up resources. */
|
|
419
|
-
stop(): Promise<void>;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* InteractiveSession — the single entry point for all SDK consumers.
|
|
423
|
+
* Session initialization helpers for InteractiveSession.
|
|
424
424
|
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
* message history, and system command execution.
|
|
428
|
-
*
|
|
429
|
-
* Config/context loading is internal. Consumer provides cwd + provider.
|
|
425
|
+
* Handles async config/context loading, plugin merging, and session creation.
|
|
426
|
+
* Also provides session-restore (resume/fork) logic.
|
|
430
427
|
*/
|
|
431
428
|
|
|
432
429
|
/** Standard construction: cwd + provider. Config/context loaded internally. */
|
|
@@ -454,7 +451,19 @@ interface IInteractiveSessionInjectedOptions {
|
|
|
454
451
|
resumeSessionId?: string;
|
|
455
452
|
forkSession?: boolean;
|
|
456
453
|
}
|
|
454
|
+
/** Union of standard and injected construction options. */
|
|
457
455
|
type IInteractiveSessionOptions = IInteractiveSessionStandardOptions | IInteractiveSessionInjectedOptions;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* InteractiveSession — the single entry point for all SDK consumers.
|
|
459
|
+
*
|
|
460
|
+
* Wraps Session (composition). Manages streaming text accumulation,
|
|
461
|
+
* tool execution state tracking, prompt queuing, abort orchestration,
|
|
462
|
+
* message history, and system command execution.
|
|
463
|
+
*
|
|
464
|
+
* Config/context loading is internal. Consumer provides cwd + provider.
|
|
465
|
+
*/
|
|
466
|
+
|
|
458
467
|
declare class InteractiveSession {
|
|
459
468
|
private session;
|
|
460
469
|
private readonly commandExecutor;
|
|
@@ -482,53 +491,35 @@ declare class InteractiveSession {
|
|
|
482
491
|
on<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
483
492
|
off<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
484
493
|
private emit;
|
|
485
|
-
/** Submit a prompt. Queues if already executing (max 1 queued). */
|
|
486
494
|
submit(input: string, displayInput?: string, rawInput?: string): Promise<void>;
|
|
487
|
-
/** Execute a system command by name. Returns null if not found. */
|
|
488
495
|
executeCommand(name: string, args: string): Promise<{
|
|
489
496
|
message: string;
|
|
490
497
|
success: boolean;
|
|
491
498
|
data?: Record<string, unknown>;
|
|
492
499
|
} | null>;
|
|
493
|
-
/** List all registered system commands. */
|
|
494
500
|
listCommands(): Array<{
|
|
495
501
|
name: string;
|
|
496
502
|
description: string;
|
|
497
503
|
}>;
|
|
498
|
-
/** Abort current execution and clear queue. */
|
|
499
504
|
abort(): void;
|
|
500
|
-
/** Cancel queued prompt without aborting current execution. */
|
|
501
505
|
cancelQueue(): void;
|
|
506
|
+
private clearPendingQueue;
|
|
502
507
|
isExecuting(): boolean;
|
|
503
508
|
getPendingPrompt(): string | null;
|
|
504
|
-
/** Get full history timeline (chat + events) for TUI rendering */
|
|
505
509
|
getFullHistory(): IHistoryEntry[];
|
|
506
|
-
/** Get chat messages only (backward compatible) */
|
|
507
510
|
getMessages(): TUniversalMessage[];
|
|
508
511
|
getStreamingText(): string;
|
|
509
512
|
getActiveTools(): IToolState[];
|
|
510
513
|
getContextState(): IContextWindowState;
|
|
511
|
-
/** Get session name. */
|
|
512
514
|
getName(): string | undefined;
|
|
513
|
-
|
|
515
|
+
getSession(): Session;
|
|
514
516
|
setName(name: string): void;
|
|
515
|
-
/** Attach a transport adapter to this session. Calls transport.attach(this). */
|
|
516
517
|
attachTransport(transport: ITransportAdapter): void;
|
|
517
|
-
/** Access underlying Session. For advanced use / testing only. */
|
|
518
|
-
getSession(): Session;
|
|
519
518
|
private executePrompt;
|
|
520
519
|
private handleTextDelta;
|
|
521
520
|
private handleToolExecution;
|
|
522
|
-
/** Push tool execution summary into messages (before Robota response).
|
|
523
|
-
* Moves tool info from activeTools (real-time display) to messages (permanent display).
|
|
524
|
-
* After this, activeTools will be cleared by clearStreaming(). */
|
|
525
|
-
private pushToolSummaryMessage;
|
|
526
521
|
private clearStreaming;
|
|
527
522
|
private flushStreaming;
|
|
528
|
-
private buildResult;
|
|
529
|
-
private buildInterruptedResult;
|
|
530
|
-
private extractToolSummaries;
|
|
531
|
-
private trimCompletedTools;
|
|
532
523
|
}
|
|
533
524
|
|
|
534
525
|
/**
|
|
@@ -796,11 +787,7 @@ declare class BundlePluginLoader {
|
|
|
796
787
|
}
|
|
797
788
|
|
|
798
789
|
/**
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
* Marketplaces are git repositories containing `.claude-plugin/marketplace.json`.
|
|
802
|
-
* They are cloned to `~/.robota/plugins/marketplaces/<name>/` and tracked
|
|
803
|
-
* in `known_marketplaces.json`.
|
|
790
|
+
* Shared types for marketplace client and registry.
|
|
804
791
|
*/
|
|
805
792
|
/** Source specification for a marketplace. */
|
|
806
793
|
type IMarketplaceSource = {
|
|
@@ -858,6 +845,15 @@ interface IMarketplaceClientOptions {
|
|
|
858
845
|
/** Custom exec function for testing (replaces child_process.execSync). */
|
|
859
846
|
exec?: ExecFn$1;
|
|
860
847
|
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* MarketplaceClient — manages marketplace registries via shallow git clones.
|
|
851
|
+
*
|
|
852
|
+
* Marketplaces are git repositories containing `.claude-plugin/marketplace.json`.
|
|
853
|
+
* They are cloned to `~/.robota/plugins/marketplaces/<name>/` and tracked
|
|
854
|
+
* in `known_marketplaces.json`.
|
|
855
|
+
*/
|
|
856
|
+
|
|
861
857
|
/** Manages marketplace registries via shallow git clones. */
|
|
862
858
|
declare class MarketplaceClient {
|
|
863
859
|
private readonly pluginsDir;
|
|
@@ -868,10 +864,9 @@ declare class MarketplaceClient {
|
|
|
868
864
|
/**
|
|
869
865
|
* Add a marketplace by cloning its repository.
|
|
870
866
|
*
|
|
871
|
-
* 1.
|
|
872
|
-
* 2.
|
|
873
|
-
* 3.
|
|
874
|
-
* 4. Register in `known_marketplaces.json`.
|
|
867
|
+
* 1. Shallow git clone (`--depth 1`) to `marketplaces/<name>/`.
|
|
868
|
+
* 2. Read `.claude-plugin/marketplace.json` for the `name` field.
|
|
869
|
+
* 3. Register in `known_marketplaces.json`.
|
|
875
870
|
*
|
|
876
871
|
* Returns the registered marketplace name from the manifest.
|
|
877
872
|
*/
|
|
@@ -886,9 +881,6 @@ declare class MarketplaceClient {
|
|
|
886
881
|
* Update a marketplace by running git pull on its clone.
|
|
887
882
|
* The manifest is re-read from disk on demand (via fetchManifest), so the
|
|
888
883
|
* updated manifest is automatically available after pull.
|
|
889
|
-
*
|
|
890
|
-
* TODO: After pull, detect version changes in installed plugins and offer
|
|
891
|
-
* to update them (re-install at new version).
|
|
892
884
|
*/
|
|
893
885
|
updateMarketplace(name: string): void;
|
|
894
886
|
/** List all registered marketplaces. */
|
|
@@ -897,9 +889,7 @@ declare class MarketplaceClient {
|
|
|
897
889
|
source: IMarketplaceSource;
|
|
898
890
|
lastUpdated: string;
|
|
899
891
|
}>;
|
|
900
|
-
/**
|
|
901
|
-
* Read the marketplace manifest from a registered marketplace's clone.
|
|
902
|
-
*/
|
|
892
|
+
/** Read the marketplace manifest from a registered marketplace's clone. */
|
|
903
893
|
fetchManifest(marketplaceName: string): IMarketplaceManifest;
|
|
904
894
|
/** Get the clone directory path for a registered marketplace. */
|
|
905
895
|
getMarketplaceDir(name: string): string;
|
|
@@ -914,18 +904,8 @@ declare class MarketplaceClient {
|
|
|
914
904
|
}>;
|
|
915
905
|
/** Resolve a marketplace source to a git clone URL. */
|
|
916
906
|
private resolveCloneUrl;
|
|
917
|
-
/**
|
|
918
|
-
* Remove all installed plugins that belong to a given marketplace.
|
|
919
|
-
* Reads installed_plugins.json, deletes cache directories for matching plugins,
|
|
920
|
-
* and updates the registry.
|
|
921
|
-
*/
|
|
922
|
-
private removeInstalledPluginsForMarketplace;
|
|
923
907
|
/** Read and parse a marketplace.json from a file path. */
|
|
924
908
|
private readManifestFromPath;
|
|
925
|
-
/** Read the known_marketplaces.json registry. */
|
|
926
|
-
private readRegistry;
|
|
927
|
-
/** Write the known_marketplaces.json registry. */
|
|
928
|
-
private writeRegistry;
|
|
929
909
|
/** Default exec implementation using child_process. */
|
|
930
910
|
private defaultExec;
|
|
931
911
|
}
|