@robota-sdk/agent-sdk 3.0.0-beta.2 → 3.0.0-beta.20
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 +241 -125
- package/dist/node/index.d.cts +143 -39
- package/dist/node/index.d.ts +143 -39
- package/dist/node/index.js +239 -122
- package/package.json +5 -5
package/dist/node/index.cjs
CHANGED
|
@@ -30,36 +30,202 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
DEFAULT_TOOL_DESCRIPTIONS: () => DEFAULT_TOOL_DESCRIPTIONS,
|
|
34
|
+
FileSessionLogger: () => import_agent_sessions3.FileSessionLogger,
|
|
35
|
+
Session: () => import_agent_sessions2.Session,
|
|
36
|
+
SessionStore: () => import_agent_sessions4.SessionStore,
|
|
37
|
+
SilentSessionLogger: () => import_agent_sessions3.SilentSessionLogger,
|
|
35
38
|
TRUST_TO_MODE: () => import_agent_core.TRUST_TO_MODE,
|
|
36
39
|
agentTool: () => agentTool,
|
|
37
|
-
bashTool: () =>
|
|
40
|
+
bashTool: () => import_agent_tools3.bashTool,
|
|
38
41
|
buildSystemPrompt: () => buildSystemPrompt,
|
|
42
|
+
createDefaultTools: () => createDefaultTools,
|
|
43
|
+
createProvider: () => createProvider,
|
|
44
|
+
createSession: () => createSession,
|
|
39
45
|
detectProject: () => detectProject,
|
|
40
|
-
editTool: () =>
|
|
46
|
+
editTool: () => import_agent_tools6.editTool,
|
|
41
47
|
evaluatePermission: () => import_agent_core2.evaluatePermission,
|
|
42
|
-
globTool: () =>
|
|
43
|
-
grepTool: () =>
|
|
48
|
+
globTool: () => import_agent_tools7.globTool,
|
|
49
|
+
grepTool: () => import_agent_tools8.grepTool,
|
|
44
50
|
loadConfig: () => loadConfig,
|
|
45
51
|
loadContext: () => loadContext,
|
|
52
|
+
projectPaths: () => projectPaths,
|
|
46
53
|
promptForApproval: () => promptForApproval,
|
|
47
54
|
query: () => query,
|
|
48
|
-
readTool: () =>
|
|
55
|
+
readTool: () => import_agent_tools4.readTool,
|
|
49
56
|
runHooks: () => import_agent_core3.runHooks,
|
|
50
57
|
setAgentToolDeps: () => setAgentToolDeps,
|
|
51
|
-
|
|
58
|
+
userPaths: () => userPaths,
|
|
59
|
+
writeTool: () => import_agent_tools5.writeTool
|
|
52
60
|
});
|
|
53
61
|
module.exports = __toCommonJS(index_exports);
|
|
54
62
|
|
|
55
63
|
// src/types.ts
|
|
56
64
|
var import_agent_core = require("@robota-sdk/agent-core");
|
|
57
65
|
|
|
58
|
-
// src/session.ts
|
|
66
|
+
// src/assembly/create-session.ts
|
|
59
67
|
var import_agent_sessions = require("@robota-sdk/agent-sessions");
|
|
60
68
|
|
|
61
|
-
// src/
|
|
69
|
+
// src/context/system-prompt-builder.ts
|
|
70
|
+
var TRUST_LEVEL_DESCRIPTIONS = {
|
|
71
|
+
safe: "safe (read-only / plan mode \u2014 only read-access tools are available)",
|
|
72
|
+
moderate: "moderate (default mode \u2014 write and bash tools require approval)",
|
|
73
|
+
full: "full (acceptEdits mode \u2014 file writes are auto-approved; bash requires approval)"
|
|
74
|
+
};
|
|
75
|
+
function buildProjectSection(info) {
|
|
76
|
+
const lines = ["## Current Project"];
|
|
77
|
+
if (info.name !== void 0) {
|
|
78
|
+
lines.push(`- **Name:** ${info.name}`);
|
|
79
|
+
}
|
|
80
|
+
if (info.type !== "unknown") {
|
|
81
|
+
lines.push(`- **Type:** ${info.type}`);
|
|
82
|
+
}
|
|
83
|
+
if (info.language !== "unknown") {
|
|
84
|
+
lines.push(`- **Language:** ${info.language}`);
|
|
85
|
+
}
|
|
86
|
+
if (info.packageManager !== void 0) {
|
|
87
|
+
lines.push(`- **Package manager:** ${info.packageManager}`);
|
|
88
|
+
}
|
|
89
|
+
return lines.join("\n");
|
|
90
|
+
}
|
|
91
|
+
function buildToolsSection(descriptions) {
|
|
92
|
+
if (descriptions.length === 0) {
|
|
93
|
+
return "";
|
|
94
|
+
}
|
|
95
|
+
const lines = ["## Available Tools", ...descriptions.map((d) => `- ${d}`)];
|
|
96
|
+
return lines.join("\n");
|
|
97
|
+
}
|
|
98
|
+
function buildSystemPrompt(params) {
|
|
99
|
+
const { agentsMd, claudeMd, toolDescriptions, trustLevel, projectInfo, cwd } = params;
|
|
100
|
+
const sections = [];
|
|
101
|
+
sections.push(
|
|
102
|
+
[
|
|
103
|
+
"## Role",
|
|
104
|
+
"You are an AI coding assistant with access to tools that let you read and modify code.",
|
|
105
|
+
"You help developers understand, write, and improve their codebase.",
|
|
106
|
+
"Always be precise, follow existing code conventions, and prefer minimal changes."
|
|
107
|
+
].join("\n")
|
|
108
|
+
);
|
|
109
|
+
if (cwd) {
|
|
110
|
+
sections.push(`## Working Directory
|
|
111
|
+
\`${cwd}\``);
|
|
112
|
+
}
|
|
113
|
+
sections.push(buildProjectSection(projectInfo));
|
|
114
|
+
sections.push(
|
|
115
|
+
[
|
|
116
|
+
"## Permission Mode",
|
|
117
|
+
`Your current trust level is **${TRUST_LEVEL_DESCRIPTIONS[trustLevel]}**.`
|
|
118
|
+
].join("\n")
|
|
119
|
+
);
|
|
120
|
+
if (agentsMd.trim().length > 0) {
|
|
121
|
+
sections.push(["## Agent Instructions", agentsMd].join("\n"));
|
|
122
|
+
}
|
|
123
|
+
if (claudeMd.trim().length > 0) {
|
|
124
|
+
sections.push(["## Project Notes", claudeMd].join("\n"));
|
|
125
|
+
}
|
|
126
|
+
sections.push(
|
|
127
|
+
[
|
|
128
|
+
"## Web Search",
|
|
129
|
+
"You have access to web search. When the user asks to search, look up, or find current/latest information,",
|
|
130
|
+
"you MUST use the web_search tool. Do NOT answer from training data when the user explicitly asks to search.",
|
|
131
|
+
"Always prefer web search for: news, latest versions, current events, live documentation."
|
|
132
|
+
].join("\n")
|
|
133
|
+
);
|
|
134
|
+
const toolsSection = buildToolsSection(toolDescriptions);
|
|
135
|
+
if (toolsSection.length > 0) {
|
|
136
|
+
sections.push(toolsSection);
|
|
137
|
+
}
|
|
138
|
+
return sections.join("\n\n");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/assembly/create-tools.ts
|
|
142
|
+
var import_agent_tools = require("@robota-sdk/agent-tools");
|
|
143
|
+
var DEFAULT_TOOL_DESCRIPTIONS = [
|
|
144
|
+
"Bash \u2014 execute shell commands",
|
|
145
|
+
"Read \u2014 read file contents with line numbers",
|
|
146
|
+
"Write \u2014 write content to a file",
|
|
147
|
+
"Edit \u2014 replace a string in a file",
|
|
148
|
+
"Glob \u2014 find files matching a pattern",
|
|
149
|
+
"Grep \u2014 search file contents with regex",
|
|
150
|
+
"WebSearch \u2014 search the internet (Anthropic built-in)"
|
|
151
|
+
];
|
|
152
|
+
function createDefaultTools() {
|
|
153
|
+
return [
|
|
154
|
+
import_agent_tools.bashTool,
|
|
155
|
+
import_agent_tools.readTool,
|
|
156
|
+
import_agent_tools.writeTool,
|
|
157
|
+
import_agent_tools.editTool,
|
|
158
|
+
import_agent_tools.globTool,
|
|
159
|
+
import_agent_tools.grepTool,
|
|
160
|
+
import_agent_tools.webFetchTool,
|
|
161
|
+
import_agent_tools.webSearchTool
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/assembly/create-provider.ts
|
|
166
|
+
var import_agent_provider_anthropic = require("@robota-sdk/agent-provider-anthropic");
|
|
167
|
+
function createProvider(config) {
|
|
168
|
+
const apiKey = config.provider.apiKey ?? process.env["ANTHROPIC_API_KEY"];
|
|
169
|
+
if (!apiKey) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
"ANTHROPIC_API_KEY is not set. Set the environment variable or configure provider.apiKey in ~/.robota/settings.json"
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return new import_agent_provider_anthropic.AnthropicProvider({ apiKey });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/assembly/create-session.ts
|
|
178
|
+
function createSession(options) {
|
|
179
|
+
const provider = options.provider ?? createProvider(options.config);
|
|
180
|
+
const defaultTools = createDefaultTools();
|
|
181
|
+
const tools = [...defaultTools, ...options.additionalTools ?? []];
|
|
182
|
+
const buildPrompt = options.systemPromptBuilder ?? buildSystemPrompt;
|
|
183
|
+
const systemMessage = buildPrompt({
|
|
184
|
+
agentsMd: options.context.agentsMd,
|
|
185
|
+
claudeMd: options.context.claudeMd,
|
|
186
|
+
toolDescriptions: options.toolDescriptions ?? DEFAULT_TOOL_DESCRIPTIONS,
|
|
187
|
+
trustLevel: options.config.defaultTrustLevel,
|
|
188
|
+
projectInfo: options.projectInfo ?? { type: "unknown", language: "unknown" },
|
|
189
|
+
cwd: process.cwd()
|
|
190
|
+
});
|
|
191
|
+
const defaultAllow = [
|
|
192
|
+
"Read(.agents/**)",
|
|
193
|
+
"Read(.claude/**)",
|
|
194
|
+
"Read(.robota/**)",
|
|
195
|
+
"Glob(.agents/**)",
|
|
196
|
+
"Glob(.claude/**)",
|
|
197
|
+
"Glob(.robota/**)"
|
|
198
|
+
];
|
|
199
|
+
const mergedPermissions = {
|
|
200
|
+
allow: [...defaultAllow, ...options.config.permissions.allow ?? []],
|
|
201
|
+
deny: options.config.permissions.deny ?? []
|
|
202
|
+
};
|
|
203
|
+
return new import_agent_sessions.Session({
|
|
204
|
+
tools,
|
|
205
|
+
provider,
|
|
206
|
+
systemMessage,
|
|
207
|
+
terminal: options.terminal,
|
|
208
|
+
permissions: mergedPermissions,
|
|
209
|
+
hooks: options.config.hooks,
|
|
210
|
+
permissionMode: options.permissionMode,
|
|
211
|
+
defaultTrustLevel: options.config.defaultTrustLevel,
|
|
212
|
+
model: options.config.provider.model,
|
|
213
|
+
maxTurns: options.maxTurns,
|
|
214
|
+
sessionStore: options.sessionStore,
|
|
215
|
+
permissionHandler: options.permissionHandler,
|
|
216
|
+
onTextDelta: options.onTextDelta,
|
|
217
|
+
onToolExecution: options.onToolExecution,
|
|
218
|
+
promptForApproval: options.promptForApproval,
|
|
219
|
+
onCompact: options.onCompact,
|
|
220
|
+
compactInstructions: options.compactInstructions ?? options.context.compactInstructions,
|
|
221
|
+
sessionLogger: options.sessionLogger
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/index.ts
|
|
62
226
|
var import_agent_sessions2 = require("@robota-sdk/agent-sessions");
|
|
227
|
+
var import_agent_sessions3 = require("@robota-sdk/agent-sessions");
|
|
228
|
+
var import_agent_sessions4 = require("@robota-sdk/agent-sessions");
|
|
63
229
|
|
|
64
230
|
// src/config/config-loader.ts
|
|
65
231
|
var import_fs = require("fs");
|
|
@@ -123,8 +289,15 @@ function readJsonFile(filePath) {
|
|
|
123
289
|
if (!(0, import_fs.existsSync)(filePath)) {
|
|
124
290
|
return void 0;
|
|
125
291
|
}
|
|
126
|
-
const raw = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
127
|
-
|
|
292
|
+
const raw = (0, import_fs.readFileSync)(filePath, "utf-8").trim();
|
|
293
|
+
if (raw.length === 0) {
|
|
294
|
+
return void 0;
|
|
295
|
+
}
|
|
296
|
+
try {
|
|
297
|
+
return JSON.parse(raw);
|
|
298
|
+
} catch {
|
|
299
|
+
return void 0;
|
|
300
|
+
}
|
|
128
301
|
}
|
|
129
302
|
function resolveEnvRef(value) {
|
|
130
303
|
const ENV_PREFIX = "$ENV:";
|
|
@@ -324,77 +497,6 @@ async function detectProject(cwd) {
|
|
|
324
497
|
};
|
|
325
498
|
}
|
|
326
499
|
|
|
327
|
-
// src/context/system-prompt-builder.ts
|
|
328
|
-
var TRUST_LEVEL_DESCRIPTIONS = {
|
|
329
|
-
safe: "safe (read-only / plan mode \u2014 only read-access tools are available)",
|
|
330
|
-
moderate: "moderate (default mode \u2014 write and bash tools require approval)",
|
|
331
|
-
full: "full (acceptEdits mode \u2014 file writes are auto-approved; bash requires approval)"
|
|
332
|
-
};
|
|
333
|
-
function buildProjectSection(info) {
|
|
334
|
-
const lines = ["## Current Project"];
|
|
335
|
-
if (info.name !== void 0) {
|
|
336
|
-
lines.push(`- **Name:** ${info.name}`);
|
|
337
|
-
}
|
|
338
|
-
if (info.type !== "unknown") {
|
|
339
|
-
lines.push(`- **Type:** ${info.type}`);
|
|
340
|
-
}
|
|
341
|
-
if (info.language !== "unknown") {
|
|
342
|
-
lines.push(`- **Language:** ${info.language}`);
|
|
343
|
-
}
|
|
344
|
-
if (info.packageManager !== void 0) {
|
|
345
|
-
lines.push(`- **Package manager:** ${info.packageManager}`);
|
|
346
|
-
}
|
|
347
|
-
return lines.join("\n");
|
|
348
|
-
}
|
|
349
|
-
function buildToolsSection(descriptions) {
|
|
350
|
-
if (descriptions.length === 0) {
|
|
351
|
-
return "";
|
|
352
|
-
}
|
|
353
|
-
const lines = ["## Available Tools", ...descriptions.map((d) => `- ${d}`)];
|
|
354
|
-
return lines.join("\n");
|
|
355
|
-
}
|
|
356
|
-
function buildSystemPrompt(params) {
|
|
357
|
-
const { agentsMd, claudeMd, toolDescriptions, trustLevel, projectInfo } = params;
|
|
358
|
-
const sections = [];
|
|
359
|
-
sections.push(
|
|
360
|
-
[
|
|
361
|
-
"## Role",
|
|
362
|
-
"You are an AI coding assistant with access to tools that let you read and modify code.",
|
|
363
|
-
"You help developers understand, write, and improve their codebase.",
|
|
364
|
-
"Always be precise, follow existing code conventions, and prefer minimal changes."
|
|
365
|
-
].join("\n")
|
|
366
|
-
);
|
|
367
|
-
sections.push(buildProjectSection(projectInfo));
|
|
368
|
-
sections.push(
|
|
369
|
-
[
|
|
370
|
-
"## Permission Mode",
|
|
371
|
-
`Your current trust level is **${TRUST_LEVEL_DESCRIPTIONS[trustLevel]}**.`
|
|
372
|
-
].join("\n")
|
|
373
|
-
);
|
|
374
|
-
if (agentsMd.trim().length > 0) {
|
|
375
|
-
sections.push(["## Agent Instructions", agentsMd].join("\n"));
|
|
376
|
-
}
|
|
377
|
-
if (claudeMd.trim().length > 0) {
|
|
378
|
-
sections.push(["## Project Notes", claudeMd].join("\n"));
|
|
379
|
-
}
|
|
380
|
-
sections.push(
|
|
381
|
-
[
|
|
382
|
-
"## Web Search",
|
|
383
|
-
"You have access to web search. When the user asks to search, look up, or find current/latest information,",
|
|
384
|
-
"you MUST use the web_search tool. Do NOT answer from training data when the user explicitly asks to search.",
|
|
385
|
-
"Always prefer web search for: news, latest versions, current events, live documentation."
|
|
386
|
-
].join("\n")
|
|
387
|
-
);
|
|
388
|
-
const toolsSection = buildToolsSection(toolDescriptions);
|
|
389
|
-
if (toolsSection.length > 0) {
|
|
390
|
-
sections.push(toolsSection);
|
|
391
|
-
}
|
|
392
|
-
return sections.join("\n\n");
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// src/query.ts
|
|
396
|
-
var import_agent_sessions3 = require("@robota-sdk/agent-sessions");
|
|
397
|
-
|
|
398
500
|
// src/permissions/permission-prompt.ts
|
|
399
501
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
400
502
|
var PERMISSION_OPTIONS = ["Allow", "Deny"];
|
|
@@ -438,7 +540,7 @@ async function query(prompt, options) {
|
|
|
438
540
|
}, update: () => {
|
|
439
541
|
} })
|
|
440
542
|
};
|
|
441
|
-
const session =
|
|
543
|
+
const session = createSession({
|
|
442
544
|
config,
|
|
443
545
|
context,
|
|
444
546
|
terminal: noopTerminal,
|
|
@@ -450,40 +552,38 @@ async function query(prompt, options) {
|
|
|
450
552
|
onTextDelta: options?.onTextDelta,
|
|
451
553
|
onCompact: options?.onCompact,
|
|
452
554
|
compactInstructions: context.compactInstructions,
|
|
453
|
-
systemPromptBuilder: buildSystemPrompt,
|
|
454
555
|
promptForApproval
|
|
455
556
|
});
|
|
456
557
|
return session.run(prompt);
|
|
457
558
|
}
|
|
458
559
|
|
|
459
|
-
// src/
|
|
560
|
+
// src/index.ts
|
|
460
561
|
var import_agent_core2 = require("@robota-sdk/agent-core");
|
|
461
|
-
|
|
462
|
-
// src/hooks/hook-runner.ts
|
|
463
562
|
var import_agent_core3 = require("@robota-sdk/agent-core");
|
|
464
563
|
|
|
465
|
-
// src/
|
|
466
|
-
var
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
564
|
+
// src/paths.ts
|
|
565
|
+
var import_node_path = require("path");
|
|
566
|
+
var import_node_os = require("os");
|
|
567
|
+
function projectPaths(cwd) {
|
|
568
|
+
const base = (0, import_node_path.join)(cwd, ".robota");
|
|
569
|
+
return {
|
|
570
|
+
settings: (0, import_node_path.join)(base, "settings.json"),
|
|
571
|
+
settingsLocal: (0, import_node_path.join)(base, "settings.local.json"),
|
|
572
|
+
logs: (0, import_node_path.join)(base, "logs"),
|
|
573
|
+
sessions: (0, import_node_path.join)(base, "sessions")
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
function userPaths() {
|
|
577
|
+
const base = (0, import_node_path.join)((0, import_node_os.homedir)(), ".robota");
|
|
578
|
+
return {
|
|
579
|
+
settings: (0, import_node_path.join)(base, "settings.json"),
|
|
580
|
+
sessions: (0, import_node_path.join)(base, "sessions")
|
|
581
|
+
};
|
|
582
|
+
}
|
|
482
583
|
|
|
483
584
|
// src/tools/agent-tool.ts
|
|
484
585
|
var import_zod2 = require("zod");
|
|
485
|
-
var
|
|
486
|
-
var import_agent_sessions4 = require("@robota-sdk/agent-sessions");
|
|
586
|
+
var import_agent_tools2 = require("@robota-sdk/agent-tools");
|
|
487
587
|
function asZodSchema(schema) {
|
|
488
588
|
return schema;
|
|
489
589
|
}
|
|
@@ -504,26 +604,26 @@ async function runAgent(args) {
|
|
|
504
604
|
};
|
|
505
605
|
return JSON.stringify(result);
|
|
506
606
|
}
|
|
507
|
-
const
|
|
607
|
+
const noopTerminal = {
|
|
608
|
+
write: () => {
|
|
609
|
+
},
|
|
610
|
+
writeLine: () => {
|
|
611
|
+
},
|
|
612
|
+
writeMarkdown: () => {
|
|
613
|
+
},
|
|
614
|
+
writeError: () => {
|
|
615
|
+
},
|
|
616
|
+
prompt: () => Promise.resolve(""),
|
|
617
|
+
select: () => Promise.resolve(0),
|
|
618
|
+
spinner: () => ({ stop: () => {
|
|
619
|
+
}, update: () => {
|
|
620
|
+
} })
|
|
621
|
+
};
|
|
622
|
+
const subSession = createSession({
|
|
508
623
|
config: agentToolDeps.config,
|
|
509
624
|
context: agentToolDeps.context,
|
|
510
625
|
projectInfo: agentToolDeps.projectInfo,
|
|
511
|
-
|
|
512
|
-
terminal: {
|
|
513
|
-
write: () => {
|
|
514
|
-
},
|
|
515
|
-
writeLine: () => {
|
|
516
|
-
},
|
|
517
|
-
writeMarkdown: () => {
|
|
518
|
-
},
|
|
519
|
-
writeError: () => {
|
|
520
|
-
},
|
|
521
|
-
prompt: () => Promise.resolve(""),
|
|
522
|
-
select: () => Promise.resolve(0),
|
|
523
|
-
spinner: () => ({ stop: () => {
|
|
524
|
-
}, update: () => {
|
|
525
|
-
} })
|
|
526
|
-
},
|
|
626
|
+
terminal: noopTerminal,
|
|
527
627
|
// Sub-agents bypass permissions — they inherit parent's trust
|
|
528
628
|
permissionMode: "bypassPermissions"
|
|
529
629
|
});
|
|
@@ -544,7 +644,7 @@ async function runAgent(args) {
|
|
|
544
644
|
return JSON.stringify(result);
|
|
545
645
|
}
|
|
546
646
|
}
|
|
547
|
-
var agentTool = (0,
|
|
647
|
+
var agentTool = (0, import_agent_tools2.createZodFunctionTool)(
|
|
548
648
|
"Agent",
|
|
549
649
|
"Spawn a sub-agent with isolated context to handle a task. The sub-agent has its own conversation history and can use all tools.",
|
|
550
650
|
asZodSchema(AgentSchema),
|
|
@@ -552,14 +652,28 @@ var agentTool = (0, import_agent_tools7.createZodFunctionTool)(
|
|
|
552
652
|
return runAgent(params);
|
|
553
653
|
}
|
|
554
654
|
);
|
|
655
|
+
|
|
656
|
+
// src/index.ts
|
|
657
|
+
var import_agent_tools3 = require("@robota-sdk/agent-tools");
|
|
658
|
+
var import_agent_tools4 = require("@robota-sdk/agent-tools");
|
|
659
|
+
var import_agent_tools5 = require("@robota-sdk/agent-tools");
|
|
660
|
+
var import_agent_tools6 = require("@robota-sdk/agent-tools");
|
|
661
|
+
var import_agent_tools7 = require("@robota-sdk/agent-tools");
|
|
662
|
+
var import_agent_tools8 = require("@robota-sdk/agent-tools");
|
|
555
663
|
// Annotate the CommonJS export names for ESM import in node:
|
|
556
664
|
0 && (module.exports = {
|
|
665
|
+
DEFAULT_TOOL_DESCRIPTIONS,
|
|
666
|
+
FileSessionLogger,
|
|
557
667
|
Session,
|
|
558
668
|
SessionStore,
|
|
669
|
+
SilentSessionLogger,
|
|
559
670
|
TRUST_TO_MODE,
|
|
560
671
|
agentTool,
|
|
561
672
|
bashTool,
|
|
562
673
|
buildSystemPrompt,
|
|
674
|
+
createDefaultTools,
|
|
675
|
+
createProvider,
|
|
676
|
+
createSession,
|
|
563
677
|
detectProject,
|
|
564
678
|
editTool,
|
|
565
679
|
evaluatePermission,
|
|
@@ -567,10 +681,12 @@ var agentTool = (0, import_agent_tools7.createZodFunctionTool)(
|
|
|
567
681
|
grepTool,
|
|
568
682
|
loadConfig,
|
|
569
683
|
loadContext,
|
|
684
|
+
projectPaths,
|
|
570
685
|
promptForApproval,
|
|
571
686
|
query,
|
|
572
687
|
readTool,
|
|
573
688
|
runHooks,
|
|
574
689
|
setAgentToolDeps,
|
|
690
|
+
userPaths,
|
|
575
691
|
writeTool
|
|
576
692
|
});
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
import { TPermissionMode, IAIProvider, TToolArgs,
|
|
1
|
+
import { TTrustLevel, TPermissionMode, IAIProvider, TToolArgs, IToolWithEventService } from '@robota-sdk/agent-core';
|
|
2
2
|
export { IContextTokenUsage, IContextWindowState, IHookInput, IPermissionLists, THookEvent, THooksConfig, TPermissionDecision, TPermissionMode, TRUST_TO_MODE, TToolArgs, TTrustLevel, evaluatePermission, runHooks } from '@robota-sdk/agent-core';
|
|
3
3
|
import * as _robota_sdk_agent_tools from '@robota-sdk/agent-tools';
|
|
4
4
|
export { TToolResult, bashTool, editTool, globTool, grepTool, readTool, writeTool } from '@robota-sdk/agent-tools';
|
|
5
|
-
import { ITerminalOutput,
|
|
6
|
-
export { ISessionOptions, ISessionRecord, ISpinner, ITerminalOutput, Session, SessionStore, TPermissionHandler, TPermissionResult } from '@robota-sdk/agent-sessions';
|
|
5
|
+
import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session } from '@robota-sdk/agent-sessions';
|
|
6
|
+
export { FileSessionLogger, ISessionLogger, ISessionOptions, ISessionRecord, ISpinner, ITerminalOutput, Session, SessionStore, SilentSessionLogger, TPermissionHandler, TPermissionResult, TSessionLogData } from '@robota-sdk/agent-sessions';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* query() — single entry point for running an AI agent conversation.
|
|
11
|
-
* Automatically loads config, context, and project info.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
interface IQueryOptions {
|
|
15
|
-
cwd?: string;
|
|
16
|
-
permissionMode?: TPermissionMode;
|
|
17
|
-
maxTurns?: number;
|
|
18
|
-
provider?: IAIProvider;
|
|
19
|
-
permissionHandler?: (toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
|
|
20
|
-
onTextDelta?: (delta: string) => void;
|
|
21
|
-
/** Callback when context is compacted */
|
|
22
|
-
onCompact?: (summary: string) => void;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* query() — single entry point for running an AI agent conversation.
|
|
26
|
-
* Equivalent to Claude Agent SDK's query() function.
|
|
27
|
-
* Automatically loads config, context, and project info.
|
|
28
|
-
*/
|
|
29
|
-
declare function query(prompt: string, options?: IQueryOptions): Promise<string>;
|
|
30
|
-
|
|
31
9
|
/**
|
|
32
10
|
* Zod schemas and TypeScript types for Robota CLI settings
|
|
33
11
|
*/
|
|
@@ -210,13 +188,6 @@ interface IResolvedConfig {
|
|
|
210
188
|
hooks?: z.infer<typeof HooksSchema>;
|
|
211
189
|
}
|
|
212
190
|
|
|
213
|
-
/**
|
|
214
|
-
* Load and merge all settings files, validate with Zod, return resolved config.
|
|
215
|
-
*
|
|
216
|
-
* @param cwd - The working directory (project root) to search for .robota/
|
|
217
|
-
*/
|
|
218
|
-
declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
|
|
219
|
-
|
|
220
191
|
interface ILoadedContext {
|
|
221
192
|
/** Concatenated content of all AGENTS.md files found (root-first) */
|
|
222
193
|
agentsMd: string;
|
|
@@ -264,6 +235,8 @@ interface ISystemPromptParams {
|
|
|
264
235
|
trustLevel: TTrustLevel;
|
|
265
236
|
/** Detected project metadata */
|
|
266
237
|
projectInfo: IProjectInfo;
|
|
238
|
+
/** Current working directory */
|
|
239
|
+
cwd?: string;
|
|
267
240
|
}
|
|
268
241
|
/**
|
|
269
242
|
* Assemble the full system prompt string from the provided parameters.
|
|
@@ -271,9 +244,121 @@ interface ISystemPromptParams {
|
|
|
271
244
|
declare function buildSystemPrompt(params: ISystemPromptParams): string;
|
|
272
245
|
|
|
273
246
|
/**
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
247
|
+
* Session factory — assembles a fully-configured Session from config, context,
|
|
248
|
+
* tools, and provider.
|
|
249
|
+
*
|
|
250
|
+
* This is the main entry point for creating sessions. It wires together
|
|
251
|
+
* the provider, tools, system prompt, and configuration that Session now
|
|
252
|
+
* expects as pre-constructed dependencies.
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
/** Options for the createSession factory */
|
|
256
|
+
interface ICreateSessionOptions {
|
|
257
|
+
/** Resolved CLI configuration (model, API key, permissions) */
|
|
258
|
+
config: IResolvedConfig;
|
|
259
|
+
/** Loaded AGENTS.md / CLAUDE.md context */
|
|
260
|
+
context: ILoadedContext;
|
|
261
|
+
/** Terminal I/O for permission prompts */
|
|
262
|
+
terminal: ITerminalOutput;
|
|
263
|
+
/** Project metadata for system prompt */
|
|
264
|
+
projectInfo?: IProjectInfo;
|
|
265
|
+
/** Initial permission mode (defaults to config.defaultTrustLevel → mode mapping) */
|
|
266
|
+
permissionMode?: TPermissionMode;
|
|
267
|
+
/** Maximum number of agentic turns per run() call. Undefined = unlimited. */
|
|
268
|
+
maxTurns?: number;
|
|
269
|
+
/** Optional session store for persistence */
|
|
270
|
+
sessionStore?: SessionStore;
|
|
271
|
+
/** Inject a pre-constructed AI provider (used by tests to avoid real API calls) */
|
|
272
|
+
provider?: IAIProvider;
|
|
273
|
+
/** Custom permission handler (overrides terminal-based prompts, used by Ink UI) */
|
|
274
|
+
permissionHandler?: TPermissionHandler;
|
|
275
|
+
/** Callback for text deltas — enables streaming text to the UI in real-time */
|
|
276
|
+
onTextDelta?: (delta: string) => void;
|
|
277
|
+
/** Custom prompt-for-approval function (injected from CLI) */
|
|
278
|
+
promptForApproval?: (terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
|
|
279
|
+
/** Additional tools to register beyond the defaults (e.g. agent-tool) */
|
|
280
|
+
additionalTools?: IToolWithEventService[];
|
|
281
|
+
/** Callback when a tool starts or finishes execution — enables real-time tool display in UI */
|
|
282
|
+
onToolExecution?: (event: {
|
|
283
|
+
type: 'start' | 'end';
|
|
284
|
+
toolName: string;
|
|
285
|
+
toolArgs?: TToolArgs;
|
|
286
|
+
success?: boolean;
|
|
287
|
+
}) => void;
|
|
288
|
+
/** Callback when context is compacted */
|
|
289
|
+
onCompact?: (summary: string) => void;
|
|
290
|
+
/** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
|
|
291
|
+
compactInstructions?: string;
|
|
292
|
+
/** Custom system prompt builder function */
|
|
293
|
+
systemPromptBuilder?: (params: ISystemPromptParams) => string;
|
|
294
|
+
/** Custom tool descriptions for the system prompt */
|
|
295
|
+
toolDescriptions?: string[];
|
|
296
|
+
/** Session logger — injected for pluggable session event logging. */
|
|
297
|
+
sessionLogger?: ISessionLogger;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Create a fully-configured Session instance.
|
|
301
|
+
*
|
|
302
|
+
* Assembles provider, tools, and system prompt, then passes them
|
|
303
|
+
* to Session as pre-constructed dependencies.
|
|
304
|
+
*/
|
|
305
|
+
declare function createSession(options: ICreateSessionOptions): Session;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Default tool set factory — creates the standard set of CLI tools.
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
/** Human-readable descriptions of the built-in tools (for system prompt) */
|
|
312
|
+
declare const DEFAULT_TOOL_DESCRIPTIONS: string[];
|
|
313
|
+
/**
|
|
314
|
+
* Create the default set of CLI tools.
|
|
315
|
+
* Returns the 8 standard tools as IToolWithEventService[].
|
|
316
|
+
*/
|
|
317
|
+
declare function createDefaultTools(): IToolWithEventService[];
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Provider factory — creates an AI provider from resolved config.
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Create an AI provider from the resolved config.
|
|
325
|
+
* Currently supports Anthropic only. Throws if no API key is available.
|
|
326
|
+
*/
|
|
327
|
+
declare function createProvider(config: IResolvedConfig): IAIProvider;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* query() — single entry point for running an AI agent conversation.
|
|
331
|
+
* Automatically loads config, context, and project info.
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
interface IQueryOptions {
|
|
335
|
+
cwd?: string;
|
|
336
|
+
permissionMode?: TPermissionMode;
|
|
337
|
+
maxTurns?: number;
|
|
338
|
+
provider?: IAIProvider;
|
|
339
|
+
permissionHandler?: (toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
|
|
340
|
+
onTextDelta?: (delta: string) => void;
|
|
341
|
+
/** Callback when context is compacted */
|
|
342
|
+
onCompact?: (summary: string) => void;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* query() — single entry point for running an AI agent conversation.
|
|
346
|
+
* Equivalent to Claude Agent SDK's query() function.
|
|
347
|
+
* Automatically loads config, context, and project info.
|
|
348
|
+
*/
|
|
349
|
+
declare function query(prompt: string, options?: IQueryOptions): Promise<string>;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Load and merge all settings files, validate with Zod, return resolved config.
|
|
353
|
+
*
|
|
354
|
+
* @param cwd - The working directory (project root) to search for .robota/
|
|
355
|
+
*/
|
|
356
|
+
declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Interactive permission prompt — asks the user whether to allow a tool invocation
|
|
360
|
+
* using an arrow-key selector. Canonical implementation (SSOT).
|
|
361
|
+
* Used by both agent-sdk query() and agent-cli.
|
|
277
362
|
*/
|
|
278
363
|
|
|
279
364
|
/**
|
|
@@ -281,14 +366,33 @@ declare function buildSystemPrompt(params: ISystemPromptParams): string;
|
|
|
281
366
|
*/
|
|
282
367
|
declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
|
|
283
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Standard Robota storage paths.
|
|
371
|
+
*
|
|
372
|
+
* All CLI runtime data lives under .robota/ (project) or ~/.robota/ (user).
|
|
373
|
+
* .agents/ is read-only from CLI's perspective (owned by AGENTS.md standard).
|
|
374
|
+
*/
|
|
375
|
+
/** Project-level .robota/ paths (relative to cwd). */
|
|
376
|
+
declare function projectPaths(cwd: string): {
|
|
377
|
+
settings: string;
|
|
378
|
+
settingsLocal: string;
|
|
379
|
+
logs: string;
|
|
380
|
+
sessions: string;
|
|
381
|
+
};
|
|
382
|
+
/** User-level ~/.robota/ paths. */
|
|
383
|
+
declare function userPaths(): {
|
|
384
|
+
settings: string;
|
|
385
|
+
sessions: string;
|
|
386
|
+
};
|
|
387
|
+
|
|
284
388
|
/** Dependencies injected at registration time */
|
|
285
389
|
interface IAgentToolDeps {
|
|
286
|
-
config: IResolvedConfig
|
|
287
|
-
context: ILoadedContext
|
|
288
|
-
projectInfo?: IProjectInfo
|
|
390
|
+
config: IResolvedConfig;
|
|
391
|
+
context: ILoadedContext;
|
|
392
|
+
projectInfo?: IProjectInfo;
|
|
289
393
|
}
|
|
290
394
|
/** Set dependencies for the agent tool. Must be called before tool is used. */
|
|
291
395
|
declare function setAgentToolDeps(deps: IAgentToolDeps): void;
|
|
292
396
|
declare const agentTool: _robota_sdk_agent_tools.FunctionTool;
|
|
293
397
|
|
|
294
|
-
export { type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, detectProject, loadConfig, loadContext, promptForApproval, query, setAgentToolDeps };
|
|
398
|
+
export { DEFAULT_TOOL_DESCRIPTIONS, type ICreateSessionOptions, type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, createDefaultTools, createProvider, createSession, detectProject, loadConfig, loadContext, projectPaths, promptForApproval, query, setAgentToolDeps, userPaths };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
import { TPermissionMode, IAIProvider, TToolArgs,
|
|
1
|
+
import { TTrustLevel, TPermissionMode, IAIProvider, TToolArgs, IToolWithEventService } from '@robota-sdk/agent-core';
|
|
2
2
|
export { IContextTokenUsage, IContextWindowState, IHookInput, IPermissionLists, THookEvent, THooksConfig, TPermissionDecision, TPermissionMode, TRUST_TO_MODE, TToolArgs, TTrustLevel, evaluatePermission, runHooks } from '@robota-sdk/agent-core';
|
|
3
3
|
import * as _robota_sdk_agent_tools from '@robota-sdk/agent-tools';
|
|
4
4
|
export { TToolResult, bashTool, editTool, globTool, grepTool, readTool, writeTool } from '@robota-sdk/agent-tools';
|
|
5
|
-
import { ITerminalOutput,
|
|
6
|
-
export { ISessionOptions, ISessionRecord, ISpinner, ITerminalOutput, Session, SessionStore, TPermissionHandler, TPermissionResult } from '@robota-sdk/agent-sessions';
|
|
5
|
+
import { ITerminalOutput, SessionStore, TPermissionHandler, ISessionLogger, Session } from '@robota-sdk/agent-sessions';
|
|
6
|
+
export { FileSessionLogger, ISessionLogger, ISessionOptions, ISessionRecord, ISpinner, ITerminalOutput, Session, SessionStore, SilentSessionLogger, TPermissionHandler, TPermissionResult, TSessionLogData } from '@robota-sdk/agent-sessions';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* query() — single entry point for running an AI agent conversation.
|
|
11
|
-
* Automatically loads config, context, and project info.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
interface IQueryOptions {
|
|
15
|
-
cwd?: string;
|
|
16
|
-
permissionMode?: TPermissionMode;
|
|
17
|
-
maxTurns?: number;
|
|
18
|
-
provider?: IAIProvider;
|
|
19
|
-
permissionHandler?: (toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
|
|
20
|
-
onTextDelta?: (delta: string) => void;
|
|
21
|
-
/** Callback when context is compacted */
|
|
22
|
-
onCompact?: (summary: string) => void;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* query() — single entry point for running an AI agent conversation.
|
|
26
|
-
* Equivalent to Claude Agent SDK's query() function.
|
|
27
|
-
* Automatically loads config, context, and project info.
|
|
28
|
-
*/
|
|
29
|
-
declare function query(prompt: string, options?: IQueryOptions): Promise<string>;
|
|
30
|
-
|
|
31
9
|
/**
|
|
32
10
|
* Zod schemas and TypeScript types for Robota CLI settings
|
|
33
11
|
*/
|
|
@@ -210,13 +188,6 @@ interface IResolvedConfig {
|
|
|
210
188
|
hooks?: z.infer<typeof HooksSchema>;
|
|
211
189
|
}
|
|
212
190
|
|
|
213
|
-
/**
|
|
214
|
-
* Load and merge all settings files, validate with Zod, return resolved config.
|
|
215
|
-
*
|
|
216
|
-
* @param cwd - The working directory (project root) to search for .robota/
|
|
217
|
-
*/
|
|
218
|
-
declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
|
|
219
|
-
|
|
220
191
|
interface ILoadedContext {
|
|
221
192
|
/** Concatenated content of all AGENTS.md files found (root-first) */
|
|
222
193
|
agentsMd: string;
|
|
@@ -264,6 +235,8 @@ interface ISystemPromptParams {
|
|
|
264
235
|
trustLevel: TTrustLevel;
|
|
265
236
|
/** Detected project metadata */
|
|
266
237
|
projectInfo: IProjectInfo;
|
|
238
|
+
/** Current working directory */
|
|
239
|
+
cwd?: string;
|
|
267
240
|
}
|
|
268
241
|
/**
|
|
269
242
|
* Assemble the full system prompt string from the provided parameters.
|
|
@@ -271,9 +244,121 @@ interface ISystemPromptParams {
|
|
|
271
244
|
declare function buildSystemPrompt(params: ISystemPromptParams): string;
|
|
272
245
|
|
|
273
246
|
/**
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
247
|
+
* Session factory — assembles a fully-configured Session from config, context,
|
|
248
|
+
* tools, and provider.
|
|
249
|
+
*
|
|
250
|
+
* This is the main entry point for creating sessions. It wires together
|
|
251
|
+
* the provider, tools, system prompt, and configuration that Session now
|
|
252
|
+
* expects as pre-constructed dependencies.
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
/** Options for the createSession factory */
|
|
256
|
+
interface ICreateSessionOptions {
|
|
257
|
+
/** Resolved CLI configuration (model, API key, permissions) */
|
|
258
|
+
config: IResolvedConfig;
|
|
259
|
+
/** Loaded AGENTS.md / CLAUDE.md context */
|
|
260
|
+
context: ILoadedContext;
|
|
261
|
+
/** Terminal I/O for permission prompts */
|
|
262
|
+
terminal: ITerminalOutput;
|
|
263
|
+
/** Project metadata for system prompt */
|
|
264
|
+
projectInfo?: IProjectInfo;
|
|
265
|
+
/** Initial permission mode (defaults to config.defaultTrustLevel → mode mapping) */
|
|
266
|
+
permissionMode?: TPermissionMode;
|
|
267
|
+
/** Maximum number of agentic turns per run() call. Undefined = unlimited. */
|
|
268
|
+
maxTurns?: number;
|
|
269
|
+
/** Optional session store for persistence */
|
|
270
|
+
sessionStore?: SessionStore;
|
|
271
|
+
/** Inject a pre-constructed AI provider (used by tests to avoid real API calls) */
|
|
272
|
+
provider?: IAIProvider;
|
|
273
|
+
/** Custom permission handler (overrides terminal-based prompts, used by Ink UI) */
|
|
274
|
+
permissionHandler?: TPermissionHandler;
|
|
275
|
+
/** Callback for text deltas — enables streaming text to the UI in real-time */
|
|
276
|
+
onTextDelta?: (delta: string) => void;
|
|
277
|
+
/** Custom prompt-for-approval function (injected from CLI) */
|
|
278
|
+
promptForApproval?: (terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
|
|
279
|
+
/** Additional tools to register beyond the defaults (e.g. agent-tool) */
|
|
280
|
+
additionalTools?: IToolWithEventService[];
|
|
281
|
+
/** Callback when a tool starts or finishes execution — enables real-time tool display in UI */
|
|
282
|
+
onToolExecution?: (event: {
|
|
283
|
+
type: 'start' | 'end';
|
|
284
|
+
toolName: string;
|
|
285
|
+
toolArgs?: TToolArgs;
|
|
286
|
+
success?: boolean;
|
|
287
|
+
}) => void;
|
|
288
|
+
/** Callback when context is compacted */
|
|
289
|
+
onCompact?: (summary: string) => void;
|
|
290
|
+
/** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
|
|
291
|
+
compactInstructions?: string;
|
|
292
|
+
/** Custom system prompt builder function */
|
|
293
|
+
systemPromptBuilder?: (params: ISystemPromptParams) => string;
|
|
294
|
+
/** Custom tool descriptions for the system prompt */
|
|
295
|
+
toolDescriptions?: string[];
|
|
296
|
+
/** Session logger — injected for pluggable session event logging. */
|
|
297
|
+
sessionLogger?: ISessionLogger;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Create a fully-configured Session instance.
|
|
301
|
+
*
|
|
302
|
+
* Assembles provider, tools, and system prompt, then passes them
|
|
303
|
+
* to Session as pre-constructed dependencies.
|
|
304
|
+
*/
|
|
305
|
+
declare function createSession(options: ICreateSessionOptions): Session;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Default tool set factory — creates the standard set of CLI tools.
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
/** Human-readable descriptions of the built-in tools (for system prompt) */
|
|
312
|
+
declare const DEFAULT_TOOL_DESCRIPTIONS: string[];
|
|
313
|
+
/**
|
|
314
|
+
* Create the default set of CLI tools.
|
|
315
|
+
* Returns the 8 standard tools as IToolWithEventService[].
|
|
316
|
+
*/
|
|
317
|
+
declare function createDefaultTools(): IToolWithEventService[];
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Provider factory — creates an AI provider from resolved config.
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Create an AI provider from the resolved config.
|
|
325
|
+
* Currently supports Anthropic only. Throws if no API key is available.
|
|
326
|
+
*/
|
|
327
|
+
declare function createProvider(config: IResolvedConfig): IAIProvider;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* query() — single entry point for running an AI agent conversation.
|
|
331
|
+
* Automatically loads config, context, and project info.
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
interface IQueryOptions {
|
|
335
|
+
cwd?: string;
|
|
336
|
+
permissionMode?: TPermissionMode;
|
|
337
|
+
maxTurns?: number;
|
|
338
|
+
provider?: IAIProvider;
|
|
339
|
+
permissionHandler?: (toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
|
|
340
|
+
onTextDelta?: (delta: string) => void;
|
|
341
|
+
/** Callback when context is compacted */
|
|
342
|
+
onCompact?: (summary: string) => void;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* query() — single entry point for running an AI agent conversation.
|
|
346
|
+
* Equivalent to Claude Agent SDK's query() function.
|
|
347
|
+
* Automatically loads config, context, and project info.
|
|
348
|
+
*/
|
|
349
|
+
declare function query(prompt: string, options?: IQueryOptions): Promise<string>;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Load and merge all settings files, validate with Zod, return resolved config.
|
|
353
|
+
*
|
|
354
|
+
* @param cwd - The working directory (project root) to search for .robota/
|
|
355
|
+
*/
|
|
356
|
+
declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Interactive permission prompt — asks the user whether to allow a tool invocation
|
|
360
|
+
* using an arrow-key selector. Canonical implementation (SSOT).
|
|
361
|
+
* Used by both agent-sdk query() and agent-cli.
|
|
277
362
|
*/
|
|
278
363
|
|
|
279
364
|
/**
|
|
@@ -281,14 +366,33 @@ declare function buildSystemPrompt(params: ISystemPromptParams): string;
|
|
|
281
366
|
*/
|
|
282
367
|
declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
|
|
283
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Standard Robota storage paths.
|
|
371
|
+
*
|
|
372
|
+
* All CLI runtime data lives under .robota/ (project) or ~/.robota/ (user).
|
|
373
|
+
* .agents/ is read-only from CLI's perspective (owned by AGENTS.md standard).
|
|
374
|
+
*/
|
|
375
|
+
/** Project-level .robota/ paths (relative to cwd). */
|
|
376
|
+
declare function projectPaths(cwd: string): {
|
|
377
|
+
settings: string;
|
|
378
|
+
settingsLocal: string;
|
|
379
|
+
logs: string;
|
|
380
|
+
sessions: string;
|
|
381
|
+
};
|
|
382
|
+
/** User-level ~/.robota/ paths. */
|
|
383
|
+
declare function userPaths(): {
|
|
384
|
+
settings: string;
|
|
385
|
+
sessions: string;
|
|
386
|
+
};
|
|
387
|
+
|
|
284
388
|
/** Dependencies injected at registration time */
|
|
285
389
|
interface IAgentToolDeps {
|
|
286
|
-
config: IResolvedConfig
|
|
287
|
-
context: ILoadedContext
|
|
288
|
-
projectInfo?: IProjectInfo
|
|
390
|
+
config: IResolvedConfig;
|
|
391
|
+
context: ILoadedContext;
|
|
392
|
+
projectInfo?: IProjectInfo;
|
|
289
393
|
}
|
|
290
394
|
/** Set dependencies for the agent tool. Must be called before tool is used. */
|
|
291
395
|
declare function setAgentToolDeps(deps: IAgentToolDeps): void;
|
|
292
396
|
declare const agentTool: _robota_sdk_agent_tools.FunctionTool;
|
|
293
397
|
|
|
294
|
-
export { type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, detectProject, loadConfig, loadContext, promptForApproval, query, setAgentToolDeps };
|
|
398
|
+
export { DEFAULT_TOOL_DESCRIPTIONS, type ICreateSessionOptions, type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, createDefaultTools, createProvider, createSession, detectProject, loadConfig, loadContext, projectPaths, promptForApproval, query, setAgentToolDeps, userPaths };
|
package/dist/node/index.js
CHANGED
|
@@ -1,10 +1,177 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
2
|
import { TRUST_TO_MODE } from "@robota-sdk/agent-core";
|
|
3
3
|
|
|
4
|
-
// src/session.ts
|
|
4
|
+
// src/assembly/create-session.ts
|
|
5
5
|
import { Session } from "@robota-sdk/agent-sessions";
|
|
6
6
|
|
|
7
|
-
// src/
|
|
7
|
+
// src/context/system-prompt-builder.ts
|
|
8
|
+
var TRUST_LEVEL_DESCRIPTIONS = {
|
|
9
|
+
safe: "safe (read-only / plan mode \u2014 only read-access tools are available)",
|
|
10
|
+
moderate: "moderate (default mode \u2014 write and bash tools require approval)",
|
|
11
|
+
full: "full (acceptEdits mode \u2014 file writes are auto-approved; bash requires approval)"
|
|
12
|
+
};
|
|
13
|
+
function buildProjectSection(info) {
|
|
14
|
+
const lines = ["## Current Project"];
|
|
15
|
+
if (info.name !== void 0) {
|
|
16
|
+
lines.push(`- **Name:** ${info.name}`);
|
|
17
|
+
}
|
|
18
|
+
if (info.type !== "unknown") {
|
|
19
|
+
lines.push(`- **Type:** ${info.type}`);
|
|
20
|
+
}
|
|
21
|
+
if (info.language !== "unknown") {
|
|
22
|
+
lines.push(`- **Language:** ${info.language}`);
|
|
23
|
+
}
|
|
24
|
+
if (info.packageManager !== void 0) {
|
|
25
|
+
lines.push(`- **Package manager:** ${info.packageManager}`);
|
|
26
|
+
}
|
|
27
|
+
return lines.join("\n");
|
|
28
|
+
}
|
|
29
|
+
function buildToolsSection(descriptions) {
|
|
30
|
+
if (descriptions.length === 0) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
const lines = ["## Available Tools", ...descriptions.map((d) => `- ${d}`)];
|
|
34
|
+
return lines.join("\n");
|
|
35
|
+
}
|
|
36
|
+
function buildSystemPrompt(params) {
|
|
37
|
+
const { agentsMd, claudeMd, toolDescriptions, trustLevel, projectInfo, cwd } = params;
|
|
38
|
+
const sections = [];
|
|
39
|
+
sections.push(
|
|
40
|
+
[
|
|
41
|
+
"## Role",
|
|
42
|
+
"You are an AI coding assistant with access to tools that let you read and modify code.",
|
|
43
|
+
"You help developers understand, write, and improve their codebase.",
|
|
44
|
+
"Always be precise, follow existing code conventions, and prefer minimal changes."
|
|
45
|
+
].join("\n")
|
|
46
|
+
);
|
|
47
|
+
if (cwd) {
|
|
48
|
+
sections.push(`## Working Directory
|
|
49
|
+
\`${cwd}\``);
|
|
50
|
+
}
|
|
51
|
+
sections.push(buildProjectSection(projectInfo));
|
|
52
|
+
sections.push(
|
|
53
|
+
[
|
|
54
|
+
"## Permission Mode",
|
|
55
|
+
`Your current trust level is **${TRUST_LEVEL_DESCRIPTIONS[trustLevel]}**.`
|
|
56
|
+
].join("\n")
|
|
57
|
+
);
|
|
58
|
+
if (agentsMd.trim().length > 0) {
|
|
59
|
+
sections.push(["## Agent Instructions", agentsMd].join("\n"));
|
|
60
|
+
}
|
|
61
|
+
if (claudeMd.trim().length > 0) {
|
|
62
|
+
sections.push(["## Project Notes", claudeMd].join("\n"));
|
|
63
|
+
}
|
|
64
|
+
sections.push(
|
|
65
|
+
[
|
|
66
|
+
"## Web Search",
|
|
67
|
+
"You have access to web search. When the user asks to search, look up, or find current/latest information,",
|
|
68
|
+
"you MUST use the web_search tool. Do NOT answer from training data when the user explicitly asks to search.",
|
|
69
|
+
"Always prefer web search for: news, latest versions, current events, live documentation."
|
|
70
|
+
].join("\n")
|
|
71
|
+
);
|
|
72
|
+
const toolsSection = buildToolsSection(toolDescriptions);
|
|
73
|
+
if (toolsSection.length > 0) {
|
|
74
|
+
sections.push(toolsSection);
|
|
75
|
+
}
|
|
76
|
+
return sections.join("\n\n");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/assembly/create-tools.ts
|
|
80
|
+
import {
|
|
81
|
+
bashTool,
|
|
82
|
+
readTool,
|
|
83
|
+
writeTool,
|
|
84
|
+
editTool,
|
|
85
|
+
globTool,
|
|
86
|
+
grepTool,
|
|
87
|
+
webFetchTool,
|
|
88
|
+
webSearchTool
|
|
89
|
+
} from "@robota-sdk/agent-tools";
|
|
90
|
+
var DEFAULT_TOOL_DESCRIPTIONS = [
|
|
91
|
+
"Bash \u2014 execute shell commands",
|
|
92
|
+
"Read \u2014 read file contents with line numbers",
|
|
93
|
+
"Write \u2014 write content to a file",
|
|
94
|
+
"Edit \u2014 replace a string in a file",
|
|
95
|
+
"Glob \u2014 find files matching a pattern",
|
|
96
|
+
"Grep \u2014 search file contents with regex",
|
|
97
|
+
"WebSearch \u2014 search the internet (Anthropic built-in)"
|
|
98
|
+
];
|
|
99
|
+
function createDefaultTools() {
|
|
100
|
+
return [
|
|
101
|
+
bashTool,
|
|
102
|
+
readTool,
|
|
103
|
+
writeTool,
|
|
104
|
+
editTool,
|
|
105
|
+
globTool,
|
|
106
|
+
grepTool,
|
|
107
|
+
webFetchTool,
|
|
108
|
+
webSearchTool
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/assembly/create-provider.ts
|
|
113
|
+
import { AnthropicProvider } from "@robota-sdk/agent-provider-anthropic";
|
|
114
|
+
function createProvider(config) {
|
|
115
|
+
const apiKey = config.provider.apiKey ?? process.env["ANTHROPIC_API_KEY"];
|
|
116
|
+
if (!apiKey) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
"ANTHROPIC_API_KEY is not set. Set the environment variable or configure provider.apiKey in ~/.robota/settings.json"
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return new AnthropicProvider({ apiKey });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/assembly/create-session.ts
|
|
125
|
+
function createSession(options) {
|
|
126
|
+
const provider = options.provider ?? createProvider(options.config);
|
|
127
|
+
const defaultTools = createDefaultTools();
|
|
128
|
+
const tools = [...defaultTools, ...options.additionalTools ?? []];
|
|
129
|
+
const buildPrompt = options.systemPromptBuilder ?? buildSystemPrompt;
|
|
130
|
+
const systemMessage = buildPrompt({
|
|
131
|
+
agentsMd: options.context.agentsMd,
|
|
132
|
+
claudeMd: options.context.claudeMd,
|
|
133
|
+
toolDescriptions: options.toolDescriptions ?? DEFAULT_TOOL_DESCRIPTIONS,
|
|
134
|
+
trustLevel: options.config.defaultTrustLevel,
|
|
135
|
+
projectInfo: options.projectInfo ?? { type: "unknown", language: "unknown" },
|
|
136
|
+
cwd: process.cwd()
|
|
137
|
+
});
|
|
138
|
+
const defaultAllow = [
|
|
139
|
+
"Read(.agents/**)",
|
|
140
|
+
"Read(.claude/**)",
|
|
141
|
+
"Read(.robota/**)",
|
|
142
|
+
"Glob(.agents/**)",
|
|
143
|
+
"Glob(.claude/**)",
|
|
144
|
+
"Glob(.robota/**)"
|
|
145
|
+
];
|
|
146
|
+
const mergedPermissions = {
|
|
147
|
+
allow: [...defaultAllow, ...options.config.permissions.allow ?? []],
|
|
148
|
+
deny: options.config.permissions.deny ?? []
|
|
149
|
+
};
|
|
150
|
+
return new Session({
|
|
151
|
+
tools,
|
|
152
|
+
provider,
|
|
153
|
+
systemMessage,
|
|
154
|
+
terminal: options.terminal,
|
|
155
|
+
permissions: mergedPermissions,
|
|
156
|
+
hooks: options.config.hooks,
|
|
157
|
+
permissionMode: options.permissionMode,
|
|
158
|
+
defaultTrustLevel: options.config.defaultTrustLevel,
|
|
159
|
+
model: options.config.provider.model,
|
|
160
|
+
maxTurns: options.maxTurns,
|
|
161
|
+
sessionStore: options.sessionStore,
|
|
162
|
+
permissionHandler: options.permissionHandler,
|
|
163
|
+
onTextDelta: options.onTextDelta,
|
|
164
|
+
onToolExecution: options.onToolExecution,
|
|
165
|
+
promptForApproval: options.promptForApproval,
|
|
166
|
+
onCompact: options.onCompact,
|
|
167
|
+
compactInstructions: options.compactInstructions ?? options.context.compactInstructions,
|
|
168
|
+
sessionLogger: options.sessionLogger
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/index.ts
|
|
173
|
+
import { Session as Session2 } from "@robota-sdk/agent-sessions";
|
|
174
|
+
import { FileSessionLogger, SilentSessionLogger } from "@robota-sdk/agent-sessions";
|
|
8
175
|
import { SessionStore } from "@robota-sdk/agent-sessions";
|
|
9
176
|
|
|
10
177
|
// src/config/config-loader.ts
|
|
@@ -69,8 +236,15 @@ function readJsonFile(filePath) {
|
|
|
69
236
|
if (!existsSync(filePath)) {
|
|
70
237
|
return void 0;
|
|
71
238
|
}
|
|
72
|
-
const raw = readFileSync(filePath, "utf-8");
|
|
73
|
-
|
|
239
|
+
const raw = readFileSync(filePath, "utf-8").trim();
|
|
240
|
+
if (raw.length === 0) {
|
|
241
|
+
return void 0;
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
return JSON.parse(raw);
|
|
245
|
+
} catch {
|
|
246
|
+
return void 0;
|
|
247
|
+
}
|
|
74
248
|
}
|
|
75
249
|
function resolveEnvRef(value) {
|
|
76
250
|
const ENV_PREFIX = "$ENV:";
|
|
@@ -270,77 +444,6 @@ async function detectProject(cwd) {
|
|
|
270
444
|
};
|
|
271
445
|
}
|
|
272
446
|
|
|
273
|
-
// src/context/system-prompt-builder.ts
|
|
274
|
-
var TRUST_LEVEL_DESCRIPTIONS = {
|
|
275
|
-
safe: "safe (read-only / plan mode \u2014 only read-access tools are available)",
|
|
276
|
-
moderate: "moderate (default mode \u2014 write and bash tools require approval)",
|
|
277
|
-
full: "full (acceptEdits mode \u2014 file writes are auto-approved; bash requires approval)"
|
|
278
|
-
};
|
|
279
|
-
function buildProjectSection(info) {
|
|
280
|
-
const lines = ["## Current Project"];
|
|
281
|
-
if (info.name !== void 0) {
|
|
282
|
-
lines.push(`- **Name:** ${info.name}`);
|
|
283
|
-
}
|
|
284
|
-
if (info.type !== "unknown") {
|
|
285
|
-
lines.push(`- **Type:** ${info.type}`);
|
|
286
|
-
}
|
|
287
|
-
if (info.language !== "unknown") {
|
|
288
|
-
lines.push(`- **Language:** ${info.language}`);
|
|
289
|
-
}
|
|
290
|
-
if (info.packageManager !== void 0) {
|
|
291
|
-
lines.push(`- **Package manager:** ${info.packageManager}`);
|
|
292
|
-
}
|
|
293
|
-
return lines.join("\n");
|
|
294
|
-
}
|
|
295
|
-
function buildToolsSection(descriptions) {
|
|
296
|
-
if (descriptions.length === 0) {
|
|
297
|
-
return "";
|
|
298
|
-
}
|
|
299
|
-
const lines = ["## Available Tools", ...descriptions.map((d) => `- ${d}`)];
|
|
300
|
-
return lines.join("\n");
|
|
301
|
-
}
|
|
302
|
-
function buildSystemPrompt(params) {
|
|
303
|
-
const { agentsMd, claudeMd, toolDescriptions, trustLevel, projectInfo } = params;
|
|
304
|
-
const sections = [];
|
|
305
|
-
sections.push(
|
|
306
|
-
[
|
|
307
|
-
"## Role",
|
|
308
|
-
"You are an AI coding assistant with access to tools that let you read and modify code.",
|
|
309
|
-
"You help developers understand, write, and improve their codebase.",
|
|
310
|
-
"Always be precise, follow existing code conventions, and prefer minimal changes."
|
|
311
|
-
].join("\n")
|
|
312
|
-
);
|
|
313
|
-
sections.push(buildProjectSection(projectInfo));
|
|
314
|
-
sections.push(
|
|
315
|
-
[
|
|
316
|
-
"## Permission Mode",
|
|
317
|
-
`Your current trust level is **${TRUST_LEVEL_DESCRIPTIONS[trustLevel]}**.`
|
|
318
|
-
].join("\n")
|
|
319
|
-
);
|
|
320
|
-
if (agentsMd.trim().length > 0) {
|
|
321
|
-
sections.push(["## Agent Instructions", agentsMd].join("\n"));
|
|
322
|
-
}
|
|
323
|
-
if (claudeMd.trim().length > 0) {
|
|
324
|
-
sections.push(["## Project Notes", claudeMd].join("\n"));
|
|
325
|
-
}
|
|
326
|
-
sections.push(
|
|
327
|
-
[
|
|
328
|
-
"## Web Search",
|
|
329
|
-
"You have access to web search. When the user asks to search, look up, or find current/latest information,",
|
|
330
|
-
"you MUST use the web_search tool. Do NOT answer from training data when the user explicitly asks to search.",
|
|
331
|
-
"Always prefer web search for: news, latest versions, current events, live documentation."
|
|
332
|
-
].join("\n")
|
|
333
|
-
);
|
|
334
|
-
const toolsSection = buildToolsSection(toolDescriptions);
|
|
335
|
-
if (toolsSection.length > 0) {
|
|
336
|
-
sections.push(toolsSection);
|
|
337
|
-
}
|
|
338
|
-
return sections.join("\n\n");
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// src/query.ts
|
|
342
|
-
import { Session as Session2 } from "@robota-sdk/agent-sessions";
|
|
343
|
-
|
|
344
447
|
// src/permissions/permission-prompt.ts
|
|
345
448
|
import chalk from "chalk";
|
|
346
449
|
var PERMISSION_OPTIONS = ["Allow", "Deny"];
|
|
@@ -384,7 +487,7 @@ async function query(prompt, options) {
|
|
|
384
487
|
}, update: () => {
|
|
385
488
|
} })
|
|
386
489
|
};
|
|
387
|
-
const session =
|
|
490
|
+
const session = createSession({
|
|
388
491
|
config,
|
|
389
492
|
context,
|
|
390
493
|
terminal: noopTerminal,
|
|
@@ -396,40 +499,38 @@ async function query(prompt, options) {
|
|
|
396
499
|
onTextDelta: options?.onTextDelta,
|
|
397
500
|
onCompact: options?.onCompact,
|
|
398
501
|
compactInstructions: context.compactInstructions,
|
|
399
|
-
systemPromptBuilder: buildSystemPrompt,
|
|
400
502
|
promptForApproval
|
|
401
503
|
});
|
|
402
504
|
return session.run(prompt);
|
|
403
505
|
}
|
|
404
506
|
|
|
405
|
-
// src/
|
|
507
|
+
// src/index.ts
|
|
406
508
|
import { evaluatePermission } from "@robota-sdk/agent-core";
|
|
407
|
-
|
|
408
|
-
// src/hooks/hook-runner.ts
|
|
409
509
|
import { runHooks } from "@robota-sdk/agent-core";
|
|
410
510
|
|
|
411
|
-
// src/
|
|
412
|
-
import {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
511
|
+
// src/paths.ts
|
|
512
|
+
import { join as join4 } from "path";
|
|
513
|
+
import { homedir } from "os";
|
|
514
|
+
function projectPaths(cwd) {
|
|
515
|
+
const base = join4(cwd, ".robota");
|
|
516
|
+
return {
|
|
517
|
+
settings: join4(base, "settings.json"),
|
|
518
|
+
settingsLocal: join4(base, "settings.local.json"),
|
|
519
|
+
logs: join4(base, "logs"),
|
|
520
|
+
sessions: join4(base, "sessions")
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function userPaths() {
|
|
524
|
+
const base = join4(homedir(), ".robota");
|
|
525
|
+
return {
|
|
526
|
+
settings: join4(base, "settings.json"),
|
|
527
|
+
sessions: join4(base, "sessions")
|
|
528
|
+
};
|
|
529
|
+
}
|
|
428
530
|
|
|
429
531
|
// src/tools/agent-tool.ts
|
|
430
532
|
import { z as z2 } from "zod";
|
|
431
533
|
import { createZodFunctionTool } from "@robota-sdk/agent-tools";
|
|
432
|
-
import { Session as Session3 } from "@robota-sdk/agent-sessions";
|
|
433
534
|
function asZodSchema(schema) {
|
|
434
535
|
return schema;
|
|
435
536
|
}
|
|
@@ -450,26 +551,26 @@ async function runAgent(args) {
|
|
|
450
551
|
};
|
|
451
552
|
return JSON.stringify(result);
|
|
452
553
|
}
|
|
453
|
-
const
|
|
554
|
+
const noopTerminal = {
|
|
555
|
+
write: () => {
|
|
556
|
+
},
|
|
557
|
+
writeLine: () => {
|
|
558
|
+
},
|
|
559
|
+
writeMarkdown: () => {
|
|
560
|
+
},
|
|
561
|
+
writeError: () => {
|
|
562
|
+
},
|
|
563
|
+
prompt: () => Promise.resolve(""),
|
|
564
|
+
select: () => Promise.resolve(0),
|
|
565
|
+
spinner: () => ({ stop: () => {
|
|
566
|
+
}, update: () => {
|
|
567
|
+
} })
|
|
568
|
+
};
|
|
569
|
+
const subSession = createSession({
|
|
454
570
|
config: agentToolDeps.config,
|
|
455
571
|
context: agentToolDeps.context,
|
|
456
572
|
projectInfo: agentToolDeps.projectInfo,
|
|
457
|
-
|
|
458
|
-
terminal: {
|
|
459
|
-
write: () => {
|
|
460
|
-
},
|
|
461
|
-
writeLine: () => {
|
|
462
|
-
},
|
|
463
|
-
writeMarkdown: () => {
|
|
464
|
-
},
|
|
465
|
-
writeError: () => {
|
|
466
|
-
},
|
|
467
|
-
prompt: () => Promise.resolve(""),
|
|
468
|
-
select: () => Promise.resolve(0),
|
|
469
|
-
spinner: () => ({ stop: () => {
|
|
470
|
-
}, update: () => {
|
|
471
|
-
} })
|
|
472
|
-
},
|
|
573
|
+
terminal: noopTerminal,
|
|
473
574
|
// Sub-agents bypass permissions — they inherit parent's trust
|
|
474
575
|
permissionMode: "bypassPermissions"
|
|
475
576
|
});
|
|
@@ -498,24 +599,40 @@ var agentTool = createZodFunctionTool(
|
|
|
498
599
|
return runAgent(params);
|
|
499
600
|
}
|
|
500
601
|
);
|
|
602
|
+
|
|
603
|
+
// src/index.ts
|
|
604
|
+
import { bashTool as bashTool2 } from "@robota-sdk/agent-tools";
|
|
605
|
+
import { readTool as readTool2 } from "@robota-sdk/agent-tools";
|
|
606
|
+
import { writeTool as writeTool2 } from "@robota-sdk/agent-tools";
|
|
607
|
+
import { editTool as editTool2 } from "@robota-sdk/agent-tools";
|
|
608
|
+
import { globTool as globTool2 } from "@robota-sdk/agent-tools";
|
|
609
|
+
import { grepTool as grepTool2 } from "@robota-sdk/agent-tools";
|
|
501
610
|
export {
|
|
502
|
-
|
|
611
|
+
DEFAULT_TOOL_DESCRIPTIONS,
|
|
612
|
+
FileSessionLogger,
|
|
613
|
+
Session2 as Session,
|
|
503
614
|
SessionStore,
|
|
615
|
+
SilentSessionLogger,
|
|
504
616
|
TRUST_TO_MODE,
|
|
505
617
|
agentTool,
|
|
506
|
-
bashTool,
|
|
618
|
+
bashTool2 as bashTool,
|
|
507
619
|
buildSystemPrompt,
|
|
620
|
+
createDefaultTools,
|
|
621
|
+
createProvider,
|
|
622
|
+
createSession,
|
|
508
623
|
detectProject,
|
|
509
|
-
editTool,
|
|
624
|
+
editTool2 as editTool,
|
|
510
625
|
evaluatePermission,
|
|
511
|
-
globTool,
|
|
512
|
-
grepTool,
|
|
626
|
+
globTool2 as globTool,
|
|
627
|
+
grepTool2 as grepTool,
|
|
513
628
|
loadConfig,
|
|
514
629
|
loadContext,
|
|
630
|
+
projectPaths,
|
|
515
631
|
promptForApproval,
|
|
516
632
|
query,
|
|
517
|
-
readTool,
|
|
633
|
+
readTool2 as readTool,
|
|
518
634
|
runHooks,
|
|
519
635
|
setAgentToolDeps,
|
|
520
|
-
|
|
636
|
+
userPaths,
|
|
637
|
+
writeTool2 as writeTool
|
|
521
638
|
};
|
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.20",
|
|
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",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"chalk": "^5.3.0",
|
|
26
26
|
"zod": "^3.24.0",
|
|
27
|
-
"@robota-sdk/agent-core": "3.0.0-beta.
|
|
28
|
-
"@robota-sdk/agent-
|
|
29
|
-
"@robota-sdk/agent-
|
|
30
|
-
"@robota-sdk/agent-
|
|
27
|
+
"@robota-sdk/agent-core": "3.0.0-beta.20",
|
|
28
|
+
"@robota-sdk/agent-sessions": "3.0.0-beta.20",
|
|
29
|
+
"@robota-sdk/agent-tools": "3.0.0-beta.20",
|
|
30
|
+
"@robota-sdk/agent-provider-anthropic": "3.0.0-beta.20"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"rimraf": "^5.0.5",
|