@robota-sdk/agent-sdk 3.0.0-beta.35 → 3.0.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -7
- package/dist/node/index.cjs +17 -24
- package/dist/node/index.d.cts +6 -2
- package/dist/node/index.d.ts +6 -2
- package/dist/node/index.js +18 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @robota-sdk/agent-sdk
|
|
2
2
|
|
|
3
|
-
Programmatic SDK for building AI agents with Robota. Provides
|
|
3
|
+
Programmatic SDK for building AI agents with Robota. Provides `InteractiveSession` as the central client-facing API, `query()` for one-shot use, session management, built-in tools, permissions, hooks, streaming, and context loading.
|
|
4
4
|
|
|
5
5
|
This is the **assembly layer** of the Robota ecosystem — it composes lower-level packages (`agent-core`, `agent-tools`, `agent-sessions`, `agent-provider-anthropic`) into a cohesive SDK.
|
|
6
6
|
|
|
@@ -33,7 +33,10 @@ const response = await query('Analyze the code', {
|
|
|
33
33
|
|
|
34
34
|
## Features
|
|
35
35
|
|
|
36
|
-
- **
|
|
36
|
+
- **InteractiveSession** — Event-driven session wrapper (composition over Session). Central client-facing API for CLI, web, API server, or any other client
|
|
37
|
+
- **SystemCommandExecutor + ISystemCommand** — SDK-level command execution. Built-in commands: `help`, `clear`, `compact`, `mode`, `model`, `language`, `cost`, `context`, `permissions`, `reset`
|
|
38
|
+
- **CommandRegistry, BuiltinCommandSource, SkillCommandSource** — Slash command registry and discovery (owned by SDK; agent-cli re-exports `CommandRegistry` from here)
|
|
39
|
+
- **query()** — Single entry point for one-shot AI agent interactions with streaming support
|
|
37
40
|
- **createSession()** — Assembly factory: wires tools, provider, config, and context into a Session
|
|
38
41
|
- **Built-in Tools** — Bash, Read, Write, Edit, Glob, Grep (re-exported from `@robota-sdk/agent-tools`)
|
|
39
42
|
- **Agent Tool** — Sub-agent session creation for multi-agent workflows
|
|
@@ -49,16 +52,167 @@ const response = await query('Analyze the code', {
|
|
|
49
52
|
|
|
50
53
|
```
|
|
51
54
|
agent-sdk (assembly layer)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
├── InteractiveSession ← central client-facing API (event-driven)
|
|
56
|
+
│ └── Session ← generic session (agent-sessions)
|
|
57
|
+
├── SystemCommandExecutor ← SDK-level command execution
|
|
58
|
+
├── CommandRegistry / BuiltinCommandSource / SkillCommandSource
|
|
59
|
+
├── query() ← one-shot entry point
|
|
60
|
+
├── createSession() ← assembly factory
|
|
61
|
+
└── deps:
|
|
62
|
+
agent-sessions (Session, SessionStore)
|
|
63
|
+
agent-tools (tool infrastructure + 8 built-in tools)
|
|
64
|
+
agent-provider-anthropic (Anthropic LLM provider)
|
|
65
|
+
agent-core (Robota engine, providers, permissions, hooks)
|
|
66
|
+
|
|
67
|
+
agent-cli (TUI layer — bridges InteractiveSession events to React/Ink state)
|
|
68
|
+
→ agent-sdk
|
|
56
69
|
```
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
The SDK is **pure TypeScript with no React dependency**. The CLI is a thin TUI-only layer that consumes `InteractiveSession` events and maps them to React state. Any other client (web app, API server, worker) can do the same.
|
|
59
72
|
|
|
60
73
|
## API
|
|
61
74
|
|
|
75
|
+
### InteractiveSession — Central Client-Facing API
|
|
76
|
+
|
|
77
|
+
`InteractiveSession` wraps `Session` (composition over inheritance) to provide event-driven interaction for any client. It manages streaming text accumulation, tool execution state tracking, prompt queuing, abort orchestration, and message history. Logic that was previously embedded in CLI React hooks now lives here.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { InteractiveSession } from '@robota-sdk/agent-sdk';
|
|
81
|
+
import type { IInteractiveSessionOptions } from '@robota-sdk/agent-sdk';
|
|
82
|
+
|
|
83
|
+
const session = new InteractiveSession({
|
|
84
|
+
config,
|
|
85
|
+
context,
|
|
86
|
+
projectInfo,
|
|
87
|
+
sessionStore,
|
|
88
|
+
permissionMode: 'default',
|
|
89
|
+
maxTurns: 10,
|
|
90
|
+
cwd: process.cwd(),
|
|
91
|
+
permissionHandler: async (toolName, toolArgs) => ({ allowed: true }),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Subscribe to events
|
|
95
|
+
session.on('text_delta', (delta: string) => {
|
|
96
|
+
process.stdout.write(delta); // streaming text chunk
|
|
97
|
+
});
|
|
98
|
+
session.on('tool_start', (state) => {
|
|
99
|
+
console.log(`Running: ${state.toolName}`);
|
|
100
|
+
});
|
|
101
|
+
session.on('tool_end', (state) => {
|
|
102
|
+
console.log(`Done: ${state.toolName} — ${state.result}`);
|
|
103
|
+
});
|
|
104
|
+
session.on('thinking', (isThinking: boolean) => {
|
|
105
|
+
// show/hide spinner
|
|
106
|
+
});
|
|
107
|
+
session.on('complete', (result) => {
|
|
108
|
+
console.log(result.response);
|
|
109
|
+
});
|
|
110
|
+
session.on('error', (error: Error) => {
|
|
111
|
+
console.error(error);
|
|
112
|
+
});
|
|
113
|
+
session.on('context_update', (state) => {
|
|
114
|
+
// token usage updated
|
|
115
|
+
});
|
|
116
|
+
session.on('interrupted', (result) => {
|
|
117
|
+
// abort completed
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Submit a prompt (queues if already executing, max 1 queued)
|
|
121
|
+
await session.submit('Explain this code');
|
|
122
|
+
|
|
123
|
+
// Submit with display override (shown in UI) and raw input (for hook matching)
|
|
124
|
+
await session.submit(fullPrompt, '/audit', '/rulebased-harness:audit');
|
|
125
|
+
|
|
126
|
+
// Abort current execution and clear queue
|
|
127
|
+
session.abort();
|
|
128
|
+
|
|
129
|
+
// Cancel queued prompt without aborting current execution
|
|
130
|
+
session.cancelQueue();
|
|
131
|
+
|
|
132
|
+
// State queries
|
|
133
|
+
session.isExecuting(); // boolean
|
|
134
|
+
session.getPendingPrompt(); // string | null
|
|
135
|
+
session.getMessages(); // TUniversalMessage[]
|
|
136
|
+
session.getContextState(); // IContextWindowState
|
|
137
|
+
session.getStreamingText(); // string (accumulated so far)
|
|
138
|
+
session.getActiveTools(); // IToolState[]
|
|
139
|
+
|
|
140
|
+
// Access underlying Session for advanced use
|
|
141
|
+
session.getSession(); // Session
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### SystemCommandExecutor — SDK-Level Commands
|
|
145
|
+
|
|
146
|
+
`SystemCommandExecutor` executes named system commands against an `InteractiveSession`. Commands are pure TypeScript — no React, no TUI dependency. The CLI wraps them as slash commands with UI chrome.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { SystemCommandExecutor, createSystemCommands } from '@robota-sdk/agent-sdk';
|
|
150
|
+
import type { ICommandResult } from '@robota-sdk/agent-sdk';
|
|
151
|
+
|
|
152
|
+
const executor = new SystemCommandExecutor(); // loads built-in commands by default
|
|
153
|
+
|
|
154
|
+
// Execute a command
|
|
155
|
+
const result: ICommandResult | null = await executor.execute('context', session, '');
|
|
156
|
+
if (result) {
|
|
157
|
+
console.log(result.message); // "Context: 12,345 / 200,000 tokens (6%)"
|
|
158
|
+
console.log(result.data); // { usedTokens, maxTokens, percentage }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Register a custom command
|
|
162
|
+
executor.register({
|
|
163
|
+
name: 'status',
|
|
164
|
+
description: 'Show agent status',
|
|
165
|
+
execute: (session, args) => ({ message: 'OK', success: true }),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// List all commands
|
|
169
|
+
executor.listCommands(); // ISystemCommand[]
|
|
170
|
+
executor.hasCommand('mode'); // boolean
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Built-in commands:
|
|
174
|
+
|
|
175
|
+
| Command | Description |
|
|
176
|
+
| ------------- | ------------------------------------------------------- |
|
|
177
|
+
| `help` | Show available commands |
|
|
178
|
+
| `clear` | Clear conversation history |
|
|
179
|
+
| `compact` | Compress context window (optional focus instructions) |
|
|
180
|
+
| `mode [m]` | Show or change permission mode |
|
|
181
|
+
| `model <id>` | Change AI model |
|
|
182
|
+
| `language` | Set response language (ko, en, ja, zh) |
|
|
183
|
+
| `cost` | Show session info (session ID, message count) |
|
|
184
|
+
| `context` | Context window token usage |
|
|
185
|
+
| `permissions` | Show current permission mode and session-approved tools |
|
|
186
|
+
| `reset` | Delete settings (caller handles file I/O and exit) |
|
|
187
|
+
|
|
188
|
+
### CommandRegistry, BuiltinCommandSource, SkillCommandSource
|
|
189
|
+
|
|
190
|
+
These classes provide slash command discovery and aggregation for clients that expose a command palette or autocomplete UI.
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import { CommandRegistry, BuiltinCommandSource, SkillCommandSource } from '@robota-sdk/agent-sdk';
|
|
194
|
+
|
|
195
|
+
const registry = new CommandRegistry();
|
|
196
|
+
registry.addSource(new BuiltinCommandSource());
|
|
197
|
+
registry.addSource(new SkillCommandSource(process.cwd()));
|
|
198
|
+
|
|
199
|
+
// Get all commands (returns ISlashCommand[])
|
|
200
|
+
const commands = registry.getCommands();
|
|
201
|
+
|
|
202
|
+
// Filter by prefix (for autocomplete)
|
|
203
|
+
const filtered = registry.getCommands('mod'); // matches "mode", "model"
|
|
204
|
+
|
|
205
|
+
// Resolve short plugin name to fully qualified form
|
|
206
|
+
registry.resolveQualifiedName('audit'); // "my-plugin:audit"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`SkillCommandSource` discovers skills from (highest priority first):
|
|
210
|
+
|
|
211
|
+
- `<cwd>/.claude/skills/*/SKILL.md`
|
|
212
|
+
- `<cwd>/.claude/commands/*.md` (Claude Code compatible)
|
|
213
|
+
- `~/.robota/skills/*/SKILL.md`
|
|
214
|
+
- `<cwd>/.agents/skills/*/SKILL.md`
|
|
215
|
+
|
|
62
216
|
### query()
|
|
63
217
|
|
|
64
218
|
```typescript
|
package/dist/node/index.cjs
CHANGED
|
@@ -2398,7 +2398,6 @@ var SystemCommandExecutor = class {
|
|
|
2398
2398
|
// src/interactive/interactive-session.ts
|
|
2399
2399
|
var import_agent_sessions4 = require("@robota-sdk/agent-sessions");
|
|
2400
2400
|
var import_agent_core3 = require("@robota-sdk/agent-core");
|
|
2401
|
-
var import_node_crypto = require("crypto");
|
|
2402
2401
|
var TOOL_ARG_DISPLAY_MAX = 80;
|
|
2403
2402
|
var TAIL_KEEP = 30;
|
|
2404
2403
|
var MAX_COMPLETED_TOOLS = 50;
|
|
@@ -2414,6 +2413,8 @@ var InteractiveSession = class {
|
|
|
2414
2413
|
// Execution state
|
|
2415
2414
|
executing = false;
|
|
2416
2415
|
pendingPrompt = null;
|
|
2416
|
+
pendingDisplayInput;
|
|
2417
|
+
pendingRawInput;
|
|
2417
2418
|
// Display messages (what clients render — not the raw session history)
|
|
2418
2419
|
messages = [];
|
|
2419
2420
|
constructor(options) {
|
|
@@ -2456,13 +2457,17 @@ var InteractiveSession = class {
|
|
|
2456
2457
|
}
|
|
2457
2458
|
}
|
|
2458
2459
|
// ── Public API ────────────────────────────────────────────────
|
|
2459
|
-
/** Submit a prompt. Queues if already executing (max 1 queued).
|
|
2460
|
-
|
|
2460
|
+
/** Submit a prompt. Queues if already executing (max 1 queued).
|
|
2461
|
+
* displayInput overrides what appears as the user message (e.g., "/audit" instead of full skill prompt).
|
|
2462
|
+
* rawInput is passed to Session.run() for hook matching (e.g., "/rulebased-harness:audit"). */
|
|
2463
|
+
async submit(input, displayInput, rawInput) {
|
|
2461
2464
|
if (this.executing) {
|
|
2462
2465
|
this.pendingPrompt = input;
|
|
2466
|
+
this.pendingDisplayInput = displayInput;
|
|
2467
|
+
this.pendingRawInput = rawInput;
|
|
2463
2468
|
return;
|
|
2464
2469
|
}
|
|
2465
|
-
await this.executePrompt(input);
|
|
2470
|
+
await this.executePrompt(input, displayInput, rawInput);
|
|
2466
2471
|
}
|
|
2467
2472
|
/** Abort current execution and clear queue. */
|
|
2468
2473
|
abort() {
|
|
@@ -2495,14 +2500,14 @@ var InteractiveSession = class {
|
|
|
2495
2500
|
return this.session;
|
|
2496
2501
|
}
|
|
2497
2502
|
// ── Execution ─────────────────────────────────────────────────
|
|
2498
|
-
async executePrompt(input) {
|
|
2503
|
+
async executePrompt(input, displayInput, rawInput) {
|
|
2499
2504
|
this.executing = true;
|
|
2500
2505
|
this.clearStreaming();
|
|
2501
2506
|
this.emit("thinking", true);
|
|
2502
|
-
this.messages.push((0, import_agent_core3.createUserMessage)(input));
|
|
2507
|
+
this.messages.push((0, import_agent_core3.createUserMessage)(displayInput ?? input));
|
|
2503
2508
|
const historyBefore = this.session.getHistory().length;
|
|
2504
2509
|
try {
|
|
2505
|
-
const response = await this.session.run(input);
|
|
2510
|
+
const response = await this.session.run(input, rawInput);
|
|
2506
2511
|
this.flushStreaming();
|
|
2507
2512
|
this.clearStreaming();
|
|
2508
2513
|
const result = this.buildResult(response || "(empty response)", historyBefore);
|
|
@@ -2529,8 +2534,12 @@ var InteractiveSession = class {
|
|
|
2529
2534
|
this.emit("thinking", false);
|
|
2530
2535
|
if (this.pendingPrompt) {
|
|
2531
2536
|
const queued = this.pendingPrompt;
|
|
2537
|
+
const queuedDisplay = this.pendingDisplayInput;
|
|
2538
|
+
const queuedRaw = this.pendingRawInput;
|
|
2532
2539
|
this.pendingPrompt = null;
|
|
2533
|
-
|
|
2540
|
+
this.pendingDisplayInput = void 0;
|
|
2541
|
+
this.pendingRawInput = void 0;
|
|
2542
|
+
setTimeout(() => this.executePrompt(queued, queuedDisplay, queuedRaw), 0);
|
|
2534
2543
|
}
|
|
2535
2544
|
}
|
|
2536
2545
|
}
|
|
@@ -2586,14 +2595,6 @@ var InteractiveSession = class {
|
|
|
2586
2595
|
}
|
|
2587
2596
|
buildResult(response, historyBefore) {
|
|
2588
2597
|
const toolSummaries = this.extractToolSummaries(historyBefore);
|
|
2589
|
-
if (toolSummaries.length > 0) {
|
|
2590
|
-
this.messages.push(
|
|
2591
|
-
(0, import_agent_core3.createToolMessage)(JSON.stringify(toolSummaries), {
|
|
2592
|
-
toolCallId: (0, import_node_crypto.randomUUID)(),
|
|
2593
|
-
name: `${toolSummaries.length} tools`
|
|
2594
|
-
})
|
|
2595
|
-
);
|
|
2596
|
-
}
|
|
2597
2598
|
return {
|
|
2598
2599
|
response,
|
|
2599
2600
|
messages: this.messages,
|
|
@@ -2604,14 +2605,6 @@ var InteractiveSession = class {
|
|
|
2604
2605
|
buildInterruptedResult(historyBefore) {
|
|
2605
2606
|
const history = this.session.getHistory();
|
|
2606
2607
|
const toolSummaries = this.extractToolSummaries(historyBefore);
|
|
2607
|
-
if (toolSummaries.length > 0) {
|
|
2608
|
-
this.messages.push(
|
|
2609
|
-
(0, import_agent_core3.createToolMessage)(JSON.stringify(toolSummaries), {
|
|
2610
|
-
toolCallId: (0, import_node_crypto.randomUUID)(),
|
|
2611
|
-
name: `${toolSummaries.length} tools`
|
|
2612
|
-
})
|
|
2613
|
-
);
|
|
2614
|
-
}
|
|
2615
2608
|
const parts = [];
|
|
2616
2609
|
for (let i = historyBefore; i < history.length; i++) {
|
|
2617
2610
|
const msg = history[i];
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1033,13 +1033,17 @@ declare class InteractiveSession {
|
|
|
1033
1033
|
private activeTools;
|
|
1034
1034
|
private executing;
|
|
1035
1035
|
private pendingPrompt;
|
|
1036
|
+
private pendingDisplayInput;
|
|
1037
|
+
private pendingRawInput;
|
|
1036
1038
|
private messages;
|
|
1037
1039
|
constructor(options: IInteractiveSessionOptions);
|
|
1038
1040
|
on<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
1039
1041
|
off<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
1040
1042
|
private emit;
|
|
1041
|
-
/** Submit a prompt. Queues if already executing (max 1 queued).
|
|
1042
|
-
|
|
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>;
|
|
1043
1047
|
/** Abort current execution and clear queue. */
|
|
1044
1048
|
abort(): void;
|
|
1045
1049
|
/** Cancel queued prompt without aborting current execution. */
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1033,13 +1033,17 @@ declare class InteractiveSession {
|
|
|
1033
1033
|
private activeTools;
|
|
1034
1034
|
private executing;
|
|
1035
1035
|
private pendingPrompt;
|
|
1036
|
+
private pendingDisplayInput;
|
|
1037
|
+
private pendingRawInput;
|
|
1036
1038
|
private messages;
|
|
1037
1039
|
constructor(options: IInteractiveSessionOptions);
|
|
1038
1040
|
on<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
1039
1041
|
off<E extends TInteractiveEventName>(event: E, handler: IInteractiveSessionEvents[E]): void;
|
|
1040
1042
|
private emit;
|
|
1041
|
-
/** Submit a prompt. Queues if already executing (max 1 queued).
|
|
1042
|
-
|
|
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>;
|
|
1043
1047
|
/** Abort current execution and clear queue. */
|
|
1044
1048
|
abort(): void;
|
|
1045
1049
|
/** Cancel queued prompt without aborting current execution. */
|
package/dist/node/index.js
CHANGED
|
@@ -2333,10 +2333,8 @@ import { FileSessionLogger as FileSessionLogger2 } from "@robota-sdk/agent-sessi
|
|
|
2333
2333
|
import {
|
|
2334
2334
|
createUserMessage,
|
|
2335
2335
|
createAssistantMessage,
|
|
2336
|
-
createSystemMessage
|
|
2337
|
-
createToolMessage
|
|
2336
|
+
createSystemMessage
|
|
2338
2337
|
} from "@robota-sdk/agent-core";
|
|
2339
|
-
import { randomUUID } from "crypto";
|
|
2340
2338
|
var TOOL_ARG_DISPLAY_MAX = 80;
|
|
2341
2339
|
var TAIL_KEEP = 30;
|
|
2342
2340
|
var MAX_COMPLETED_TOOLS = 50;
|
|
@@ -2352,6 +2350,8 @@ var InteractiveSession = class {
|
|
|
2352
2350
|
// Execution state
|
|
2353
2351
|
executing = false;
|
|
2354
2352
|
pendingPrompt = null;
|
|
2353
|
+
pendingDisplayInput;
|
|
2354
|
+
pendingRawInput;
|
|
2355
2355
|
// Display messages (what clients render — not the raw session history)
|
|
2356
2356
|
messages = [];
|
|
2357
2357
|
constructor(options) {
|
|
@@ -2394,13 +2394,17 @@ var InteractiveSession = class {
|
|
|
2394
2394
|
}
|
|
2395
2395
|
}
|
|
2396
2396
|
// ── Public API ────────────────────────────────────────────────
|
|
2397
|
-
/** Submit a prompt. Queues if already executing (max 1 queued).
|
|
2398
|
-
|
|
2397
|
+
/** Submit a prompt. Queues if already executing (max 1 queued).
|
|
2398
|
+
* displayInput overrides what appears as the user message (e.g., "/audit" instead of full skill prompt).
|
|
2399
|
+
* rawInput is passed to Session.run() for hook matching (e.g., "/rulebased-harness:audit"). */
|
|
2400
|
+
async submit(input, displayInput, rawInput) {
|
|
2399
2401
|
if (this.executing) {
|
|
2400
2402
|
this.pendingPrompt = input;
|
|
2403
|
+
this.pendingDisplayInput = displayInput;
|
|
2404
|
+
this.pendingRawInput = rawInput;
|
|
2401
2405
|
return;
|
|
2402
2406
|
}
|
|
2403
|
-
await this.executePrompt(input);
|
|
2407
|
+
await this.executePrompt(input, displayInput, rawInput);
|
|
2404
2408
|
}
|
|
2405
2409
|
/** Abort current execution and clear queue. */
|
|
2406
2410
|
abort() {
|
|
@@ -2433,14 +2437,14 @@ var InteractiveSession = class {
|
|
|
2433
2437
|
return this.session;
|
|
2434
2438
|
}
|
|
2435
2439
|
// ── Execution ─────────────────────────────────────────────────
|
|
2436
|
-
async executePrompt(input) {
|
|
2440
|
+
async executePrompt(input, displayInput, rawInput) {
|
|
2437
2441
|
this.executing = true;
|
|
2438
2442
|
this.clearStreaming();
|
|
2439
2443
|
this.emit("thinking", true);
|
|
2440
|
-
this.messages.push(createUserMessage(input));
|
|
2444
|
+
this.messages.push(createUserMessage(displayInput ?? input));
|
|
2441
2445
|
const historyBefore = this.session.getHistory().length;
|
|
2442
2446
|
try {
|
|
2443
|
-
const response = await this.session.run(input);
|
|
2447
|
+
const response = await this.session.run(input, rawInput);
|
|
2444
2448
|
this.flushStreaming();
|
|
2445
2449
|
this.clearStreaming();
|
|
2446
2450
|
const result = this.buildResult(response || "(empty response)", historyBefore);
|
|
@@ -2467,8 +2471,12 @@ var InteractiveSession = class {
|
|
|
2467
2471
|
this.emit("thinking", false);
|
|
2468
2472
|
if (this.pendingPrompt) {
|
|
2469
2473
|
const queued = this.pendingPrompt;
|
|
2474
|
+
const queuedDisplay = this.pendingDisplayInput;
|
|
2475
|
+
const queuedRaw = this.pendingRawInput;
|
|
2470
2476
|
this.pendingPrompt = null;
|
|
2471
|
-
|
|
2477
|
+
this.pendingDisplayInput = void 0;
|
|
2478
|
+
this.pendingRawInput = void 0;
|
|
2479
|
+
setTimeout(() => this.executePrompt(queued, queuedDisplay, queuedRaw), 0);
|
|
2472
2480
|
}
|
|
2473
2481
|
}
|
|
2474
2482
|
}
|
|
@@ -2524,14 +2532,6 @@ var InteractiveSession = class {
|
|
|
2524
2532
|
}
|
|
2525
2533
|
buildResult(response, historyBefore) {
|
|
2526
2534
|
const toolSummaries = this.extractToolSummaries(historyBefore);
|
|
2527
|
-
if (toolSummaries.length > 0) {
|
|
2528
|
-
this.messages.push(
|
|
2529
|
-
createToolMessage(JSON.stringify(toolSummaries), {
|
|
2530
|
-
toolCallId: randomUUID(),
|
|
2531
|
-
name: `${toolSummaries.length} tools`
|
|
2532
|
-
})
|
|
2533
|
-
);
|
|
2534
|
-
}
|
|
2535
2535
|
return {
|
|
2536
2536
|
response,
|
|
2537
2537
|
messages: this.messages,
|
|
@@ -2542,14 +2542,6 @@ var InteractiveSession = class {
|
|
|
2542
2542
|
buildInterruptedResult(historyBefore) {
|
|
2543
2543
|
const history = this.session.getHistory();
|
|
2544
2544
|
const toolSummaries = this.extractToolSummaries(historyBefore);
|
|
2545
|
-
if (toolSummaries.length > 0) {
|
|
2546
|
-
this.messages.push(
|
|
2547
|
-
createToolMessage(JSON.stringify(toolSummaries), {
|
|
2548
|
-
toolCallId: randomUUID(),
|
|
2549
|
-
name: `${toolSummaries.length} tools`
|
|
2550
|
-
})
|
|
2551
|
-
);
|
|
2552
|
-
}
|
|
2553
2545
|
const parts = [];
|
|
2554
2546
|
for (let i = historyBefore; i < history.length; i++) {
|
|
2555
2547
|
const msg = history[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robota-sdk/agent-sdk",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.36",
|
|
4
4
|
"description": "Programmatic SDK for building AI agents with Robota — provides Session, query(), built-in tools, permissions, hooks, and context loading",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/node/index.js",
|