@robota-sdk/agent-sdk 3.0.0-beta.1 → 3.0.0-beta.10

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.
@@ -30,36 +30,201 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- Session: () => import_agent_sessions.Session,
34
- SessionStore: () => import_agent_sessions2.SessionStore,
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: () => import_agent_tools.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: () => import_agent_tools4.editTool,
46
+ editTool: () => import_agent_tools6.editTool,
41
47
  evaluatePermission: () => import_agent_core2.evaluatePermission,
42
- globTool: () => import_agent_tools5.globTool,
43
- grepTool: () => import_agent_tools6.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: () => import_agent_tools2.readTool,
55
+ readTool: () => import_agent_tools4.readTool,
49
56
  runHooks: () => import_agent_core3.runHooks,
50
57
  setAgentToolDeps: () => setAgentToolDeps,
51
- writeTool: () => import_agent_tools3.writeTool
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/session-store.ts
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
+ promptForApproval: options.promptForApproval,
218
+ onCompact: options.onCompact,
219
+ compactInstructions: options.compactInstructions ?? options.context.compactInstructions,
220
+ sessionLogger: options.sessionLogger
221
+ });
222
+ }
223
+
224
+ // src/index.ts
62
225
  var import_agent_sessions2 = require("@robota-sdk/agent-sessions");
226
+ var import_agent_sessions3 = require("@robota-sdk/agent-sessions");
227
+ var import_agent_sessions4 = require("@robota-sdk/agent-sessions");
63
228
 
64
229
  // src/config/config-loader.ts
65
230
  var import_fs = require("fs");
@@ -324,77 +489,6 @@ async function detectProject(cwd) {
324
489
  };
325
490
  }
326
491
 
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
492
  // src/permissions/permission-prompt.ts
399
493
  var import_chalk = __toESM(require("chalk"), 1);
400
494
  var PERMISSION_OPTIONS = ["Allow", "Deny"];
@@ -438,7 +532,7 @@ async function query(prompt, options) {
438
532
  }, update: () => {
439
533
  } })
440
534
  };
441
- const session = new import_agent_sessions3.Session({
535
+ const session = createSession({
442
536
  config,
443
537
  context,
444
538
  terminal: noopTerminal,
@@ -450,40 +544,38 @@ async function query(prompt, options) {
450
544
  onTextDelta: options?.onTextDelta,
451
545
  onCompact: options?.onCompact,
452
546
  compactInstructions: context.compactInstructions,
453
- systemPromptBuilder: buildSystemPrompt,
454
547
  promptForApproval
455
548
  });
456
549
  return session.run(prompt);
457
550
  }
458
551
 
459
- // src/permissions/permission-gate.ts
552
+ // src/index.ts
460
553
  var import_agent_core2 = require("@robota-sdk/agent-core");
461
-
462
- // src/hooks/hook-runner.ts
463
554
  var import_agent_core3 = require("@robota-sdk/agent-core");
464
555
 
465
- // src/tools/bash-tool.ts
466
- var import_agent_tools = require("@robota-sdk/agent-tools");
467
-
468
- // src/tools/read-tool.ts
469
- var import_agent_tools2 = require("@robota-sdk/agent-tools");
470
-
471
- // src/tools/write-tool.ts
472
- var import_agent_tools3 = require("@robota-sdk/agent-tools");
473
-
474
- // src/tools/edit-tool.ts
475
- var import_agent_tools4 = require("@robota-sdk/agent-tools");
476
-
477
- // src/tools/glob-tool.ts
478
- var import_agent_tools5 = require("@robota-sdk/agent-tools");
479
-
480
- // src/tools/grep-tool.ts
481
- var import_agent_tools6 = require("@robota-sdk/agent-tools");
556
+ // src/paths.ts
557
+ var import_node_path = require("path");
558
+ var import_node_os = require("os");
559
+ function projectPaths(cwd) {
560
+ const base = (0, import_node_path.join)(cwd, ".robota");
561
+ return {
562
+ settings: (0, import_node_path.join)(base, "settings.json"),
563
+ settingsLocal: (0, import_node_path.join)(base, "settings.local.json"),
564
+ logs: (0, import_node_path.join)(base, "logs"),
565
+ sessions: (0, import_node_path.join)(base, "sessions")
566
+ };
567
+ }
568
+ function userPaths() {
569
+ const base = (0, import_node_path.join)((0, import_node_os.homedir)(), ".robota");
570
+ return {
571
+ settings: (0, import_node_path.join)(base, "settings.json"),
572
+ sessions: (0, import_node_path.join)(base, "sessions")
573
+ };
574
+ }
482
575
 
483
576
  // src/tools/agent-tool.ts
484
577
  var import_zod2 = require("zod");
485
- var import_agent_tools7 = require("@robota-sdk/agent-tools");
486
- var import_agent_sessions4 = require("@robota-sdk/agent-sessions");
578
+ var import_agent_tools2 = require("@robota-sdk/agent-tools");
487
579
  function asZodSchema(schema) {
488
580
  return schema;
489
581
  }
@@ -504,26 +596,26 @@ async function runAgent(args) {
504
596
  };
505
597
  return JSON.stringify(result);
506
598
  }
507
- const subSession = new import_agent_sessions4.Session({
599
+ const noopTerminal = {
600
+ write: () => {
601
+ },
602
+ writeLine: () => {
603
+ },
604
+ writeMarkdown: () => {
605
+ },
606
+ writeError: () => {
607
+ },
608
+ prompt: () => Promise.resolve(""),
609
+ select: () => Promise.resolve(0),
610
+ spinner: () => ({ stop: () => {
611
+ }, update: () => {
612
+ } })
613
+ };
614
+ const subSession = createSession({
508
615
  config: agentToolDeps.config,
509
616
  context: agentToolDeps.context,
510
617
  projectInfo: agentToolDeps.projectInfo,
511
- // No terminal needed — sub-agents don't prompt for permissions
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
- },
618
+ terminal: noopTerminal,
527
619
  // Sub-agents bypass permissions — they inherit parent's trust
528
620
  permissionMode: "bypassPermissions"
529
621
  });
@@ -544,7 +636,7 @@ async function runAgent(args) {
544
636
  return JSON.stringify(result);
545
637
  }
546
638
  }
547
- var agentTool = (0, import_agent_tools7.createZodFunctionTool)(
639
+ var agentTool = (0, import_agent_tools2.createZodFunctionTool)(
548
640
  "Agent",
549
641
  "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
642
  asZodSchema(AgentSchema),
@@ -552,14 +644,28 @@ var agentTool = (0, import_agent_tools7.createZodFunctionTool)(
552
644
  return runAgent(params);
553
645
  }
554
646
  );
647
+
648
+ // src/index.ts
649
+ var import_agent_tools3 = require("@robota-sdk/agent-tools");
650
+ var import_agent_tools4 = require("@robota-sdk/agent-tools");
651
+ var import_agent_tools5 = require("@robota-sdk/agent-tools");
652
+ var import_agent_tools6 = require("@robota-sdk/agent-tools");
653
+ var import_agent_tools7 = require("@robota-sdk/agent-tools");
654
+ var import_agent_tools8 = require("@robota-sdk/agent-tools");
555
655
  // Annotate the CommonJS export names for ESM import in node:
556
656
  0 && (module.exports = {
657
+ DEFAULT_TOOL_DESCRIPTIONS,
658
+ FileSessionLogger,
557
659
  Session,
558
660
  SessionStore,
661
+ SilentSessionLogger,
559
662
  TRUST_TO_MODE,
560
663
  agentTool,
561
664
  bashTool,
562
665
  buildSystemPrompt,
666
+ createDefaultTools,
667
+ createProvider,
668
+ createSession,
563
669
  detectProject,
564
670
  editTool,
565
671
  evaluatePermission,
@@ -567,10 +673,12 @@ var agentTool = (0, import_agent_tools7.createZodFunctionTool)(
567
673
  grepTool,
568
674
  loadConfig,
569
675
  loadContext,
676
+ projectPaths,
570
677
  promptForApproval,
571
678
  query,
572
679
  readTool,
573
680
  runHooks,
574
681
  setAgentToolDeps,
682
+ userPaths,
575
683
  writeTool
576
684
  });
@@ -1,33 +1,11 @@
1
- import { TPermissionMode, IAIProvider, TToolArgs, TTrustLevel } from '@robota-sdk/agent-core';
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, IResolvedConfig as IResolvedConfig$1, ILoadedContext as ILoadedContext$1, IProjectInfo as IProjectInfo$1 } from '@robota-sdk/agent-sessions';
6
- export { ISessionOptions, ISessionRecord, ISpinner, ITerminalOutput, Session, SessionStore, TPermissionHandler } 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,12 +235,119 @@ 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.
270
243
  */
271
244
  declare function buildSystemPrompt(params: ISystemPromptParams): string;
272
245
 
246
+ /**
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 context is compacted */
282
+ onCompact?: (summary: string) => void;
283
+ /** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
284
+ compactInstructions?: string;
285
+ /** Custom system prompt builder function */
286
+ systemPromptBuilder?: (params: ISystemPromptParams) => string;
287
+ /** Custom tool descriptions for the system prompt */
288
+ toolDescriptions?: string[];
289
+ /** Session logger — injected for pluggable session event logging. */
290
+ sessionLogger?: ISessionLogger;
291
+ }
292
+ /**
293
+ * Create a fully-configured Session instance.
294
+ *
295
+ * Assembles provider, tools, and system prompt, then passes them
296
+ * to Session as pre-constructed dependencies.
297
+ */
298
+ declare function createSession(options: ICreateSessionOptions): Session;
299
+
300
+ /**
301
+ * Default tool set factory — creates the standard set of CLI tools.
302
+ */
303
+
304
+ /** Human-readable descriptions of the built-in tools (for system prompt) */
305
+ declare const DEFAULT_TOOL_DESCRIPTIONS: string[];
306
+ /**
307
+ * Create the default set of CLI tools.
308
+ * Returns the 8 standard tools as IToolWithEventService[].
309
+ */
310
+ declare function createDefaultTools(): IToolWithEventService[];
311
+
312
+ /**
313
+ * Provider factory — creates an AI provider from resolved config.
314
+ */
315
+
316
+ /**
317
+ * Create an AI provider from the resolved config.
318
+ * Currently supports Anthropic only. Throws if no API key is available.
319
+ */
320
+ declare function createProvider(config: IResolvedConfig): IAIProvider;
321
+
322
+ /**
323
+ * query() — single entry point for running an AI agent conversation.
324
+ * Automatically loads config, context, and project info.
325
+ */
326
+
327
+ interface IQueryOptions {
328
+ cwd?: string;
329
+ permissionMode?: TPermissionMode;
330
+ maxTurns?: number;
331
+ provider?: IAIProvider;
332
+ permissionHandler?: (toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
333
+ onTextDelta?: (delta: string) => void;
334
+ /** Callback when context is compacted */
335
+ onCompact?: (summary: string) => void;
336
+ }
337
+ /**
338
+ * query() — single entry point for running an AI agent conversation.
339
+ * Equivalent to Claude Agent SDK's query() function.
340
+ * Automatically loads config, context, and project info.
341
+ */
342
+ declare function query(prompt: string, options?: IQueryOptions): Promise<string>;
343
+
344
+ /**
345
+ * Load and merge all settings files, validate with Zod, return resolved config.
346
+ *
347
+ * @param cwd - The working directory (project root) to search for .robota/
348
+ */
349
+ declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
350
+
273
351
  /**
274
352
  * Permission prompt — this is now CLI-specific.
275
353
  * Re-exported here for backward compatibility.
@@ -281,14 +359,33 @@ declare function buildSystemPrompt(params: ISystemPromptParams): string;
281
359
  */
282
360
  declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
283
361
 
362
+ /**
363
+ * Standard Robota storage paths.
364
+ *
365
+ * All CLI runtime data lives under .robota/ (project) or ~/.robota/ (user).
366
+ * .agents/ is read-only from CLI's perspective (owned by AGENTS.md standard).
367
+ */
368
+ /** Project-level .robota/ paths (relative to cwd). */
369
+ declare function projectPaths(cwd: string): {
370
+ settings: string;
371
+ settingsLocal: string;
372
+ logs: string;
373
+ sessions: string;
374
+ };
375
+ /** User-level ~/.robota/ paths. */
376
+ declare function userPaths(): {
377
+ settings: string;
378
+ sessions: string;
379
+ };
380
+
284
381
  /** Dependencies injected at registration time */
285
382
  interface IAgentToolDeps {
286
- config: IResolvedConfig$1;
287
- context: ILoadedContext$1;
288
- projectInfo?: IProjectInfo$1;
383
+ config: IResolvedConfig;
384
+ context: ILoadedContext;
385
+ projectInfo?: IProjectInfo;
289
386
  }
290
387
  /** Set dependencies for the agent tool. Must be called before tool is used. */
291
388
  declare function setAgentToolDeps(deps: IAgentToolDeps): void;
292
389
  declare const agentTool: _robota_sdk_agent_tools.FunctionTool;
293
390
 
294
- export { type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, detectProject, loadConfig, loadContext, promptForApproval, query, setAgentToolDeps };
391
+ 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 };
@@ -1,33 +1,11 @@
1
- import { TPermissionMode, IAIProvider, TToolArgs, TTrustLevel } from '@robota-sdk/agent-core';
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, IResolvedConfig as IResolvedConfig$1, ILoadedContext as ILoadedContext$1, IProjectInfo as IProjectInfo$1 } from '@robota-sdk/agent-sessions';
6
- export { ISessionOptions, ISessionRecord, ISpinner, ITerminalOutput, Session, SessionStore, TPermissionHandler } 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,12 +235,119 @@ 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.
270
243
  */
271
244
  declare function buildSystemPrompt(params: ISystemPromptParams): string;
272
245
 
246
+ /**
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 context is compacted */
282
+ onCompact?: (summary: string) => void;
283
+ /** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
284
+ compactInstructions?: string;
285
+ /** Custom system prompt builder function */
286
+ systemPromptBuilder?: (params: ISystemPromptParams) => string;
287
+ /** Custom tool descriptions for the system prompt */
288
+ toolDescriptions?: string[];
289
+ /** Session logger — injected for pluggable session event logging. */
290
+ sessionLogger?: ISessionLogger;
291
+ }
292
+ /**
293
+ * Create a fully-configured Session instance.
294
+ *
295
+ * Assembles provider, tools, and system prompt, then passes them
296
+ * to Session as pre-constructed dependencies.
297
+ */
298
+ declare function createSession(options: ICreateSessionOptions): Session;
299
+
300
+ /**
301
+ * Default tool set factory — creates the standard set of CLI tools.
302
+ */
303
+
304
+ /** Human-readable descriptions of the built-in tools (for system prompt) */
305
+ declare const DEFAULT_TOOL_DESCRIPTIONS: string[];
306
+ /**
307
+ * Create the default set of CLI tools.
308
+ * Returns the 8 standard tools as IToolWithEventService[].
309
+ */
310
+ declare function createDefaultTools(): IToolWithEventService[];
311
+
312
+ /**
313
+ * Provider factory — creates an AI provider from resolved config.
314
+ */
315
+
316
+ /**
317
+ * Create an AI provider from the resolved config.
318
+ * Currently supports Anthropic only. Throws if no API key is available.
319
+ */
320
+ declare function createProvider(config: IResolvedConfig): IAIProvider;
321
+
322
+ /**
323
+ * query() — single entry point for running an AI agent conversation.
324
+ * Automatically loads config, context, and project info.
325
+ */
326
+
327
+ interface IQueryOptions {
328
+ cwd?: string;
329
+ permissionMode?: TPermissionMode;
330
+ maxTurns?: number;
331
+ provider?: IAIProvider;
332
+ permissionHandler?: (toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
333
+ onTextDelta?: (delta: string) => void;
334
+ /** Callback when context is compacted */
335
+ onCompact?: (summary: string) => void;
336
+ }
337
+ /**
338
+ * query() — single entry point for running an AI agent conversation.
339
+ * Equivalent to Claude Agent SDK's query() function.
340
+ * Automatically loads config, context, and project info.
341
+ */
342
+ declare function query(prompt: string, options?: IQueryOptions): Promise<string>;
343
+
344
+ /**
345
+ * Load and merge all settings files, validate with Zod, return resolved config.
346
+ *
347
+ * @param cwd - The working directory (project root) to search for .robota/
348
+ */
349
+ declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
350
+
273
351
  /**
274
352
  * Permission prompt — this is now CLI-specific.
275
353
  * Re-exported here for backward compatibility.
@@ -281,14 +359,33 @@ declare function buildSystemPrompt(params: ISystemPromptParams): string;
281
359
  */
282
360
  declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
283
361
 
362
+ /**
363
+ * Standard Robota storage paths.
364
+ *
365
+ * All CLI runtime data lives under .robota/ (project) or ~/.robota/ (user).
366
+ * .agents/ is read-only from CLI's perspective (owned by AGENTS.md standard).
367
+ */
368
+ /** Project-level .robota/ paths (relative to cwd). */
369
+ declare function projectPaths(cwd: string): {
370
+ settings: string;
371
+ settingsLocal: string;
372
+ logs: string;
373
+ sessions: string;
374
+ };
375
+ /** User-level ~/.robota/ paths. */
376
+ declare function userPaths(): {
377
+ settings: string;
378
+ sessions: string;
379
+ };
380
+
284
381
  /** Dependencies injected at registration time */
285
382
  interface IAgentToolDeps {
286
- config: IResolvedConfig$1;
287
- context: ILoadedContext$1;
288
- projectInfo?: IProjectInfo$1;
383
+ config: IResolvedConfig;
384
+ context: ILoadedContext;
385
+ projectInfo?: IProjectInfo;
289
386
  }
290
387
  /** Set dependencies for the agent tool. Must be called before tool is used. */
291
388
  declare function setAgentToolDeps(deps: IAgentToolDeps): void;
292
389
  declare const agentTool: _robota_sdk_agent_tools.FunctionTool;
293
390
 
294
- export { type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, detectProject, loadConfig, loadContext, promptForApproval, query, setAgentToolDeps };
391
+ 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 };
@@ -1,10 +1,176 @@
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/session-store.ts
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
+ promptForApproval: options.promptForApproval,
165
+ onCompact: options.onCompact,
166
+ compactInstructions: options.compactInstructions ?? options.context.compactInstructions,
167
+ sessionLogger: options.sessionLogger
168
+ });
169
+ }
170
+
171
+ // src/index.ts
172
+ import { Session as Session2 } from "@robota-sdk/agent-sessions";
173
+ import { FileSessionLogger, SilentSessionLogger } from "@robota-sdk/agent-sessions";
8
174
  import { SessionStore } from "@robota-sdk/agent-sessions";
9
175
 
10
176
  // src/config/config-loader.ts
@@ -270,77 +436,6 @@ async function detectProject(cwd) {
270
436
  };
271
437
  }
272
438
 
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
439
  // src/permissions/permission-prompt.ts
345
440
  import chalk from "chalk";
346
441
  var PERMISSION_OPTIONS = ["Allow", "Deny"];
@@ -384,7 +479,7 @@ async function query(prompt, options) {
384
479
  }, update: () => {
385
480
  } })
386
481
  };
387
- const session = new Session2({
482
+ const session = createSession({
388
483
  config,
389
484
  context,
390
485
  terminal: noopTerminal,
@@ -396,40 +491,38 @@ async function query(prompt, options) {
396
491
  onTextDelta: options?.onTextDelta,
397
492
  onCompact: options?.onCompact,
398
493
  compactInstructions: context.compactInstructions,
399
- systemPromptBuilder: buildSystemPrompt,
400
494
  promptForApproval
401
495
  });
402
496
  return session.run(prompt);
403
497
  }
404
498
 
405
- // src/permissions/permission-gate.ts
499
+ // src/index.ts
406
500
  import { evaluatePermission } from "@robota-sdk/agent-core";
407
-
408
- // src/hooks/hook-runner.ts
409
501
  import { runHooks } from "@robota-sdk/agent-core";
410
502
 
411
- // src/tools/bash-tool.ts
412
- import { bashTool } from "@robota-sdk/agent-tools";
413
-
414
- // src/tools/read-tool.ts
415
- import { readTool } from "@robota-sdk/agent-tools";
416
-
417
- // src/tools/write-tool.ts
418
- import { writeTool } from "@robota-sdk/agent-tools";
419
-
420
- // src/tools/edit-tool.ts
421
- import { editTool } from "@robota-sdk/agent-tools";
422
-
423
- // src/tools/glob-tool.ts
424
- import { globTool } from "@robota-sdk/agent-tools";
425
-
426
- // src/tools/grep-tool.ts
427
- import { grepTool } from "@robota-sdk/agent-tools";
503
+ // src/paths.ts
504
+ import { join as join4 } from "path";
505
+ import { homedir } from "os";
506
+ function projectPaths(cwd) {
507
+ const base = join4(cwd, ".robota");
508
+ return {
509
+ settings: join4(base, "settings.json"),
510
+ settingsLocal: join4(base, "settings.local.json"),
511
+ logs: join4(base, "logs"),
512
+ sessions: join4(base, "sessions")
513
+ };
514
+ }
515
+ function userPaths() {
516
+ const base = join4(homedir(), ".robota");
517
+ return {
518
+ settings: join4(base, "settings.json"),
519
+ sessions: join4(base, "sessions")
520
+ };
521
+ }
428
522
 
429
523
  // src/tools/agent-tool.ts
430
524
  import { z as z2 } from "zod";
431
525
  import { createZodFunctionTool } from "@robota-sdk/agent-tools";
432
- import { Session as Session3 } from "@robota-sdk/agent-sessions";
433
526
  function asZodSchema(schema) {
434
527
  return schema;
435
528
  }
@@ -450,26 +543,26 @@ async function runAgent(args) {
450
543
  };
451
544
  return JSON.stringify(result);
452
545
  }
453
- const subSession = new Session3({
546
+ const noopTerminal = {
547
+ write: () => {
548
+ },
549
+ writeLine: () => {
550
+ },
551
+ writeMarkdown: () => {
552
+ },
553
+ writeError: () => {
554
+ },
555
+ prompt: () => Promise.resolve(""),
556
+ select: () => Promise.resolve(0),
557
+ spinner: () => ({ stop: () => {
558
+ }, update: () => {
559
+ } })
560
+ };
561
+ const subSession = createSession({
454
562
  config: agentToolDeps.config,
455
563
  context: agentToolDeps.context,
456
564
  projectInfo: agentToolDeps.projectInfo,
457
- // No terminal needed — sub-agents don't prompt for permissions
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
- },
565
+ terminal: noopTerminal,
473
566
  // Sub-agents bypass permissions — they inherit parent's trust
474
567
  permissionMode: "bypassPermissions"
475
568
  });
@@ -498,24 +591,40 @@ var agentTool = createZodFunctionTool(
498
591
  return runAgent(params);
499
592
  }
500
593
  );
594
+
595
+ // src/index.ts
596
+ import { bashTool as bashTool2 } from "@robota-sdk/agent-tools";
597
+ import { readTool as readTool2 } from "@robota-sdk/agent-tools";
598
+ import { writeTool as writeTool2 } from "@robota-sdk/agent-tools";
599
+ import { editTool as editTool2 } from "@robota-sdk/agent-tools";
600
+ import { globTool as globTool2 } from "@robota-sdk/agent-tools";
601
+ import { grepTool as grepTool2 } from "@robota-sdk/agent-tools";
501
602
  export {
502
- Session,
603
+ DEFAULT_TOOL_DESCRIPTIONS,
604
+ FileSessionLogger,
605
+ Session2 as Session,
503
606
  SessionStore,
607
+ SilentSessionLogger,
504
608
  TRUST_TO_MODE,
505
609
  agentTool,
506
- bashTool,
610
+ bashTool2 as bashTool,
507
611
  buildSystemPrompt,
612
+ createDefaultTools,
613
+ createProvider,
614
+ createSession,
508
615
  detectProject,
509
- editTool,
616
+ editTool2 as editTool,
510
617
  evaluatePermission,
511
- globTool,
512
- grepTool,
618
+ globTool2 as globTool,
619
+ grepTool2 as grepTool,
513
620
  loadConfig,
514
621
  loadContext,
622
+ projectPaths,
515
623
  promptForApproval,
516
624
  query,
517
- readTool,
625
+ readTool2 as readTool,
518
626
  runHooks,
519
627
  setAgentToolDeps,
520
- writeTool
628
+ userPaths,
629
+ writeTool2 as writeTool
521
630
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robota-sdk/agent-sdk",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.10",
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-provider-anthropic": "3.0.0-beta.1",
28
- "@robota-sdk/agent-core": "3.0.0-beta.1",
29
- "@robota-sdk/agent-tools": "3.0.0-beta.1",
30
- "@robota-sdk/agent-sessions": "3.0.0-beta.1"
27
+ "@robota-sdk/agent-provider-anthropic": "3.0.0-beta.10",
28
+ "@robota-sdk/agent-core": "3.0.0-beta.10",
29
+ "@robota-sdk/agent-sessions": "3.0.0-beta.10",
30
+ "@robota-sdk/agent-tools": "3.0.0-beta.10"
31
31
  },
32
32
  "devDependencies": {
33
33
  "rimraf": "^5.0.5",