@robota-sdk/agent-sdk 3.0.0-beta.2 → 3.0.0-beta.4

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,184 @@ 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 } = 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
+ sections.push(buildProjectSection(projectInfo));
110
+ sections.push(
111
+ [
112
+ "## Permission Mode",
113
+ `Your current trust level is **${TRUST_LEVEL_DESCRIPTIONS[trustLevel]}**.`
114
+ ].join("\n")
115
+ );
116
+ if (agentsMd.trim().length > 0) {
117
+ sections.push(["## Agent Instructions", agentsMd].join("\n"));
118
+ }
119
+ if (claudeMd.trim().length > 0) {
120
+ sections.push(["## Project Notes", claudeMd].join("\n"));
121
+ }
122
+ sections.push(
123
+ [
124
+ "## Web Search",
125
+ "You have access to web search. When the user asks to search, look up, or find current/latest information,",
126
+ "you MUST use the web_search tool. Do NOT answer from training data when the user explicitly asks to search.",
127
+ "Always prefer web search for: news, latest versions, current events, live documentation."
128
+ ].join("\n")
129
+ );
130
+ const toolsSection = buildToolsSection(toolDescriptions);
131
+ if (toolsSection.length > 0) {
132
+ sections.push(toolsSection);
133
+ }
134
+ return sections.join("\n\n");
135
+ }
136
+
137
+ // src/assembly/create-tools.ts
138
+ var import_agent_tools = require("@robota-sdk/agent-tools");
139
+ var DEFAULT_TOOL_DESCRIPTIONS = [
140
+ "Bash \u2014 execute shell commands",
141
+ "Read \u2014 read file contents with line numbers",
142
+ "Write \u2014 write content to a file",
143
+ "Edit \u2014 replace a string in a file",
144
+ "Glob \u2014 find files matching a pattern",
145
+ "Grep \u2014 search file contents with regex",
146
+ "WebSearch \u2014 search the internet (Anthropic built-in)"
147
+ ];
148
+ function createDefaultTools() {
149
+ return [
150
+ import_agent_tools.bashTool,
151
+ import_agent_tools.readTool,
152
+ import_agent_tools.writeTool,
153
+ import_agent_tools.editTool,
154
+ import_agent_tools.globTool,
155
+ import_agent_tools.grepTool,
156
+ import_agent_tools.webFetchTool,
157
+ import_agent_tools.webSearchTool
158
+ ];
159
+ }
160
+
161
+ // src/assembly/create-provider.ts
162
+ var import_agent_provider_anthropic = require("@robota-sdk/agent-provider-anthropic");
163
+ function createProvider(config) {
164
+ const apiKey = config.provider.apiKey ?? process.env["ANTHROPIC_API_KEY"];
165
+ if (!apiKey) {
166
+ throw new Error(
167
+ "ANTHROPIC_API_KEY is not set. Set the environment variable or configure provider.apiKey in ~/.robota/settings.json"
168
+ );
169
+ }
170
+ return new import_agent_provider_anthropic.AnthropicProvider({ apiKey });
171
+ }
172
+
173
+ // src/assembly/create-session.ts
174
+ function createSession(options) {
175
+ const provider = options.provider ?? createProvider(options.config);
176
+ const defaultTools = createDefaultTools();
177
+ const tools = [...defaultTools, ...options.additionalTools ?? []];
178
+ const buildPrompt = options.systemPromptBuilder ?? buildSystemPrompt;
179
+ const systemMessage = buildPrompt({
180
+ agentsMd: options.context.agentsMd,
181
+ claudeMd: options.context.claudeMd,
182
+ toolDescriptions: options.toolDescriptions ?? DEFAULT_TOOL_DESCRIPTIONS,
183
+ trustLevel: options.config.defaultTrustLevel,
184
+ projectInfo: options.projectInfo ?? { type: "unknown", language: "unknown" }
185
+ });
186
+ return new import_agent_sessions.Session({
187
+ tools,
188
+ provider,
189
+ systemMessage,
190
+ terminal: options.terminal,
191
+ permissions: options.config.permissions,
192
+ hooks: options.config.hooks,
193
+ permissionMode: options.permissionMode,
194
+ defaultTrustLevel: options.config.defaultTrustLevel,
195
+ model: options.config.provider.model,
196
+ maxTurns: options.maxTurns,
197
+ sessionStore: options.sessionStore,
198
+ permissionHandler: options.permissionHandler,
199
+ onTextDelta: options.onTextDelta,
200
+ promptForApproval: options.promptForApproval,
201
+ onCompact: options.onCompact,
202
+ compactInstructions: options.compactInstructions ?? options.context.compactInstructions,
203
+ sessionLogger: options.sessionLogger
204
+ });
205
+ }
206
+
207
+ // src/index.ts
62
208
  var import_agent_sessions2 = require("@robota-sdk/agent-sessions");
209
+ var import_agent_sessions3 = require("@robota-sdk/agent-sessions");
210
+ var import_agent_sessions4 = require("@robota-sdk/agent-sessions");
63
211
 
64
212
  // src/config/config-loader.ts
65
213
  var import_fs = require("fs");
@@ -324,77 +472,6 @@ async function detectProject(cwd) {
324
472
  };
325
473
  }
326
474
 
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
475
  // src/permissions/permission-prompt.ts
399
476
  var import_chalk = __toESM(require("chalk"), 1);
400
477
  var PERMISSION_OPTIONS = ["Allow", "Deny"];
@@ -438,7 +515,7 @@ async function query(prompt, options) {
438
515
  }, update: () => {
439
516
  } })
440
517
  };
441
- const session = new import_agent_sessions3.Session({
518
+ const session = createSession({
442
519
  config,
443
520
  context,
444
521
  terminal: noopTerminal,
@@ -450,40 +527,38 @@ async function query(prompt, options) {
450
527
  onTextDelta: options?.onTextDelta,
451
528
  onCompact: options?.onCompact,
452
529
  compactInstructions: context.compactInstructions,
453
- systemPromptBuilder: buildSystemPrompt,
454
530
  promptForApproval
455
531
  });
456
532
  return session.run(prompt);
457
533
  }
458
534
 
459
- // src/permissions/permission-gate.ts
535
+ // src/index.ts
460
536
  var import_agent_core2 = require("@robota-sdk/agent-core");
461
-
462
- // src/hooks/hook-runner.ts
463
537
  var import_agent_core3 = require("@robota-sdk/agent-core");
464
538
 
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");
539
+ // src/paths.ts
540
+ var import_node_path = require("path");
541
+ var import_node_os = require("os");
542
+ function projectPaths(cwd) {
543
+ const base = (0, import_node_path.join)(cwd, ".robota");
544
+ return {
545
+ settings: (0, import_node_path.join)(base, "settings.json"),
546
+ settingsLocal: (0, import_node_path.join)(base, "settings.local.json"),
547
+ logs: (0, import_node_path.join)(base, "logs"),
548
+ sessions: (0, import_node_path.join)(base, "sessions")
549
+ };
550
+ }
551
+ function userPaths() {
552
+ const base = (0, import_node_path.join)((0, import_node_os.homedir)(), ".robota");
553
+ return {
554
+ settings: (0, import_node_path.join)(base, "settings.json"),
555
+ sessions: (0, import_node_path.join)(base, "sessions")
556
+ };
557
+ }
482
558
 
483
559
  // src/tools/agent-tool.ts
484
560
  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");
561
+ var import_agent_tools2 = require("@robota-sdk/agent-tools");
487
562
  function asZodSchema(schema) {
488
563
  return schema;
489
564
  }
@@ -504,26 +579,26 @@ async function runAgent(args) {
504
579
  };
505
580
  return JSON.stringify(result);
506
581
  }
507
- const subSession = new import_agent_sessions4.Session({
582
+ const noopTerminal = {
583
+ write: () => {
584
+ },
585
+ writeLine: () => {
586
+ },
587
+ writeMarkdown: () => {
588
+ },
589
+ writeError: () => {
590
+ },
591
+ prompt: () => Promise.resolve(""),
592
+ select: () => Promise.resolve(0),
593
+ spinner: () => ({ stop: () => {
594
+ }, update: () => {
595
+ } })
596
+ };
597
+ const subSession = createSession({
508
598
  config: agentToolDeps.config,
509
599
  context: agentToolDeps.context,
510
600
  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
- },
601
+ terminal: noopTerminal,
527
602
  // Sub-agents bypass permissions — they inherit parent's trust
528
603
  permissionMode: "bypassPermissions"
529
604
  });
@@ -544,7 +619,7 @@ async function runAgent(args) {
544
619
  return JSON.stringify(result);
545
620
  }
546
621
  }
547
- var agentTool = (0, import_agent_tools7.createZodFunctionTool)(
622
+ var agentTool = (0, import_agent_tools2.createZodFunctionTool)(
548
623
  "Agent",
549
624
  "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
625
  asZodSchema(AgentSchema),
@@ -552,14 +627,28 @@ var agentTool = (0, import_agent_tools7.createZodFunctionTool)(
552
627
  return runAgent(params);
553
628
  }
554
629
  );
630
+
631
+ // src/index.ts
632
+ var import_agent_tools3 = require("@robota-sdk/agent-tools");
633
+ var import_agent_tools4 = require("@robota-sdk/agent-tools");
634
+ var import_agent_tools5 = require("@robota-sdk/agent-tools");
635
+ var import_agent_tools6 = require("@robota-sdk/agent-tools");
636
+ var import_agent_tools7 = require("@robota-sdk/agent-tools");
637
+ var import_agent_tools8 = require("@robota-sdk/agent-tools");
555
638
  // Annotate the CommonJS export names for ESM import in node:
556
639
  0 && (module.exports = {
640
+ DEFAULT_TOOL_DESCRIPTIONS,
641
+ FileSessionLogger,
557
642
  Session,
558
643
  SessionStore,
644
+ SilentSessionLogger,
559
645
  TRUST_TO_MODE,
560
646
  agentTool,
561
647
  bashTool,
562
648
  buildSystemPrompt,
649
+ createDefaultTools,
650
+ createProvider,
651
+ createSession,
563
652
  detectProject,
564
653
  editTool,
565
654
  evaluatePermission,
@@ -567,10 +656,12 @@ var agentTool = (0, import_agent_tools7.createZodFunctionTool)(
567
656
  grepTool,
568
657
  loadConfig,
569
658
  loadContext,
659
+ projectPaths,
570
660
  promptForApproval,
571
661
  query,
572
662
  readTool,
573
663
  runHooks,
574
664
  setAgentToolDeps,
665
+ userPaths,
575
666
  writeTool
576
667
  });
@@ -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, 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;
@@ -270,6 +241,111 @@ interface ISystemPromptParams {
270
241
  */
271
242
  declare function buildSystemPrompt(params: ISystemPromptParams): string;
272
243
 
244
+ /**
245
+ * Session factory — assembles a fully-configured Session from config, context,
246
+ * tools, and provider.
247
+ *
248
+ * This is the main entry point for creating sessions. It wires together
249
+ * the provider, tools, system prompt, and configuration that Session now
250
+ * expects as pre-constructed dependencies.
251
+ */
252
+
253
+ /** Options for the createSession factory */
254
+ interface ICreateSessionOptions {
255
+ /** Resolved CLI configuration (model, API key, permissions) */
256
+ config: IResolvedConfig;
257
+ /** Loaded AGENTS.md / CLAUDE.md context */
258
+ context: ILoadedContext;
259
+ /** Terminal I/O for permission prompts */
260
+ terminal: ITerminalOutput;
261
+ /** Project metadata for system prompt */
262
+ projectInfo?: IProjectInfo;
263
+ /** Initial permission mode (defaults to config.defaultTrustLevel → mode mapping) */
264
+ permissionMode?: TPermissionMode;
265
+ /** Maximum number of agentic turns per run() call. Undefined = unlimited. */
266
+ maxTurns?: number;
267
+ /** Optional session store for persistence */
268
+ sessionStore?: SessionStore;
269
+ /** Inject a pre-constructed AI provider (used by tests to avoid real API calls) */
270
+ provider?: IAIProvider;
271
+ /** Custom permission handler (overrides terminal-based prompts, used by Ink UI) */
272
+ permissionHandler?: TPermissionHandler;
273
+ /** Callback for text deltas — enables streaming text to the UI in real-time */
274
+ onTextDelta?: (delta: string) => void;
275
+ /** Custom prompt-for-approval function (injected from CLI) */
276
+ promptForApproval?: (terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
277
+ /** Additional tools to register beyond the defaults (e.g. agent-tool) */
278
+ additionalTools?: IToolWithEventService[];
279
+ /** Callback when context is compacted */
280
+ onCompact?: (summary: string) => void;
281
+ /** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
282
+ compactInstructions?: string;
283
+ /** Custom system prompt builder function */
284
+ systemPromptBuilder?: (params: ISystemPromptParams) => string;
285
+ /** Custom tool descriptions for the system prompt */
286
+ toolDescriptions?: string[];
287
+ /** Session logger — injected for pluggable session event logging. */
288
+ sessionLogger?: ISessionLogger;
289
+ }
290
+ /**
291
+ * Create a fully-configured Session instance.
292
+ *
293
+ * Assembles provider, tools, and system prompt, then passes them
294
+ * to Session as pre-constructed dependencies.
295
+ */
296
+ declare function createSession(options: ICreateSessionOptions): Session;
297
+
298
+ /**
299
+ * Default tool set factory — creates the standard set of CLI tools.
300
+ */
301
+
302
+ /** Human-readable descriptions of the built-in tools (for system prompt) */
303
+ declare const DEFAULT_TOOL_DESCRIPTIONS: string[];
304
+ /**
305
+ * Create the default set of CLI tools.
306
+ * Returns the 8 standard tools as IToolWithEventService[].
307
+ */
308
+ declare function createDefaultTools(): IToolWithEventService[];
309
+
310
+ /**
311
+ * Provider factory — creates an AI provider from resolved config.
312
+ */
313
+
314
+ /**
315
+ * Create an AI provider from the resolved config.
316
+ * Currently supports Anthropic only. Throws if no API key is available.
317
+ */
318
+ declare function createProvider(config: IResolvedConfig): IAIProvider;
319
+
320
+ /**
321
+ * query() — single entry point for running an AI agent conversation.
322
+ * Automatically loads config, context, and project info.
323
+ */
324
+
325
+ interface IQueryOptions {
326
+ cwd?: string;
327
+ permissionMode?: TPermissionMode;
328
+ maxTurns?: number;
329
+ provider?: IAIProvider;
330
+ permissionHandler?: (toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
331
+ onTextDelta?: (delta: string) => void;
332
+ /** Callback when context is compacted */
333
+ onCompact?: (summary: string) => void;
334
+ }
335
+ /**
336
+ * query() — single entry point for running an AI agent conversation.
337
+ * Equivalent to Claude Agent SDK's query() function.
338
+ * Automatically loads config, context, and project info.
339
+ */
340
+ declare function query(prompt: string, options?: IQueryOptions): Promise<string>;
341
+
342
+ /**
343
+ * Load and merge all settings files, validate with Zod, return resolved config.
344
+ *
345
+ * @param cwd - The working directory (project root) to search for .robota/
346
+ */
347
+ declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
348
+
273
349
  /**
274
350
  * Permission prompt — this is now CLI-specific.
275
351
  * Re-exported here for backward compatibility.
@@ -281,14 +357,33 @@ declare function buildSystemPrompt(params: ISystemPromptParams): string;
281
357
  */
282
358
  declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
283
359
 
360
+ /**
361
+ * Standard Robota storage paths.
362
+ *
363
+ * All CLI runtime data lives under .robota/ (project) or ~/.robota/ (user).
364
+ * .agents/ is read-only from CLI's perspective (owned by AGENTS.md standard).
365
+ */
366
+ /** Project-level .robota/ paths (relative to cwd). */
367
+ declare function projectPaths(cwd: string): {
368
+ settings: string;
369
+ settingsLocal: string;
370
+ logs: string;
371
+ sessions: string;
372
+ };
373
+ /** User-level ~/.robota/ paths. */
374
+ declare function userPaths(): {
375
+ settings: string;
376
+ sessions: string;
377
+ };
378
+
284
379
  /** Dependencies injected at registration time */
285
380
  interface IAgentToolDeps {
286
- config: IResolvedConfig$1;
287
- context: ILoadedContext$1;
288
- projectInfo?: IProjectInfo$1;
381
+ config: IResolvedConfig;
382
+ context: ILoadedContext;
383
+ projectInfo?: IProjectInfo;
289
384
  }
290
385
  /** Set dependencies for the agent tool. Must be called before tool is used. */
291
386
  declare function setAgentToolDeps(deps: IAgentToolDeps): void;
292
387
  declare const agentTool: _robota_sdk_agent_tools.FunctionTool;
293
388
 
294
- export { type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, detectProject, loadConfig, loadContext, promptForApproval, query, setAgentToolDeps };
389
+ 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, 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;
@@ -270,6 +241,111 @@ interface ISystemPromptParams {
270
241
  */
271
242
  declare function buildSystemPrompt(params: ISystemPromptParams): string;
272
243
 
244
+ /**
245
+ * Session factory — assembles a fully-configured Session from config, context,
246
+ * tools, and provider.
247
+ *
248
+ * This is the main entry point for creating sessions. It wires together
249
+ * the provider, tools, system prompt, and configuration that Session now
250
+ * expects as pre-constructed dependencies.
251
+ */
252
+
253
+ /** Options for the createSession factory */
254
+ interface ICreateSessionOptions {
255
+ /** Resolved CLI configuration (model, API key, permissions) */
256
+ config: IResolvedConfig;
257
+ /** Loaded AGENTS.md / CLAUDE.md context */
258
+ context: ILoadedContext;
259
+ /** Terminal I/O for permission prompts */
260
+ terminal: ITerminalOutput;
261
+ /** Project metadata for system prompt */
262
+ projectInfo?: IProjectInfo;
263
+ /** Initial permission mode (defaults to config.defaultTrustLevel → mode mapping) */
264
+ permissionMode?: TPermissionMode;
265
+ /** Maximum number of agentic turns per run() call. Undefined = unlimited. */
266
+ maxTurns?: number;
267
+ /** Optional session store for persistence */
268
+ sessionStore?: SessionStore;
269
+ /** Inject a pre-constructed AI provider (used by tests to avoid real API calls) */
270
+ provider?: IAIProvider;
271
+ /** Custom permission handler (overrides terminal-based prompts, used by Ink UI) */
272
+ permissionHandler?: TPermissionHandler;
273
+ /** Callback for text deltas — enables streaming text to the UI in real-time */
274
+ onTextDelta?: (delta: string) => void;
275
+ /** Custom prompt-for-approval function (injected from CLI) */
276
+ promptForApproval?: (terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
277
+ /** Additional tools to register beyond the defaults (e.g. agent-tool) */
278
+ additionalTools?: IToolWithEventService[];
279
+ /** Callback when context is compacted */
280
+ onCompact?: (summary: string) => void;
281
+ /** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
282
+ compactInstructions?: string;
283
+ /** Custom system prompt builder function */
284
+ systemPromptBuilder?: (params: ISystemPromptParams) => string;
285
+ /** Custom tool descriptions for the system prompt */
286
+ toolDescriptions?: string[];
287
+ /** Session logger — injected for pluggable session event logging. */
288
+ sessionLogger?: ISessionLogger;
289
+ }
290
+ /**
291
+ * Create a fully-configured Session instance.
292
+ *
293
+ * Assembles provider, tools, and system prompt, then passes them
294
+ * to Session as pre-constructed dependencies.
295
+ */
296
+ declare function createSession(options: ICreateSessionOptions): Session;
297
+
298
+ /**
299
+ * Default tool set factory — creates the standard set of CLI tools.
300
+ */
301
+
302
+ /** Human-readable descriptions of the built-in tools (for system prompt) */
303
+ declare const DEFAULT_TOOL_DESCRIPTIONS: string[];
304
+ /**
305
+ * Create the default set of CLI tools.
306
+ * Returns the 8 standard tools as IToolWithEventService[].
307
+ */
308
+ declare function createDefaultTools(): IToolWithEventService[];
309
+
310
+ /**
311
+ * Provider factory — creates an AI provider from resolved config.
312
+ */
313
+
314
+ /**
315
+ * Create an AI provider from the resolved config.
316
+ * Currently supports Anthropic only. Throws if no API key is available.
317
+ */
318
+ declare function createProvider(config: IResolvedConfig): IAIProvider;
319
+
320
+ /**
321
+ * query() — single entry point for running an AI agent conversation.
322
+ * Automatically loads config, context, and project info.
323
+ */
324
+
325
+ interface IQueryOptions {
326
+ cwd?: string;
327
+ permissionMode?: TPermissionMode;
328
+ maxTurns?: number;
329
+ provider?: IAIProvider;
330
+ permissionHandler?: (toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
331
+ onTextDelta?: (delta: string) => void;
332
+ /** Callback when context is compacted */
333
+ onCompact?: (summary: string) => void;
334
+ }
335
+ /**
336
+ * query() — single entry point for running an AI agent conversation.
337
+ * Equivalent to Claude Agent SDK's query() function.
338
+ * Automatically loads config, context, and project info.
339
+ */
340
+ declare function query(prompt: string, options?: IQueryOptions): Promise<string>;
341
+
342
+ /**
343
+ * Load and merge all settings files, validate with Zod, return resolved config.
344
+ *
345
+ * @param cwd - The working directory (project root) to search for .robota/
346
+ */
347
+ declare function loadConfig(cwd: string): Promise<IResolvedConfig>;
348
+
273
349
  /**
274
350
  * Permission prompt — this is now CLI-specific.
275
351
  * Re-exported here for backward compatibility.
@@ -281,14 +357,33 @@ declare function buildSystemPrompt(params: ISystemPromptParams): string;
281
357
  */
282
358
  declare function promptForApproval(terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs): Promise<boolean>;
283
359
 
360
+ /**
361
+ * Standard Robota storage paths.
362
+ *
363
+ * All CLI runtime data lives under .robota/ (project) or ~/.robota/ (user).
364
+ * .agents/ is read-only from CLI's perspective (owned by AGENTS.md standard).
365
+ */
366
+ /** Project-level .robota/ paths (relative to cwd). */
367
+ declare function projectPaths(cwd: string): {
368
+ settings: string;
369
+ settingsLocal: string;
370
+ logs: string;
371
+ sessions: string;
372
+ };
373
+ /** User-level ~/.robota/ paths. */
374
+ declare function userPaths(): {
375
+ settings: string;
376
+ sessions: string;
377
+ };
378
+
284
379
  /** Dependencies injected at registration time */
285
380
  interface IAgentToolDeps {
286
- config: IResolvedConfig$1;
287
- context: ILoadedContext$1;
288
- projectInfo?: IProjectInfo$1;
381
+ config: IResolvedConfig;
382
+ context: ILoadedContext;
383
+ projectInfo?: IProjectInfo;
289
384
  }
290
385
  /** Set dependencies for the agent tool. Must be called before tool is used. */
291
386
  declare function setAgentToolDeps(deps: IAgentToolDeps): void;
292
387
  declare const agentTool: _robota_sdk_agent_tools.FunctionTool;
293
388
 
294
- export { type ILoadedContext, type IProjectInfo, type IQueryOptions, type IResolvedConfig, type ISystemPromptParams, agentTool, buildSystemPrompt, detectProject, loadConfig, loadContext, promptForApproval, query, setAgentToolDeps };
389
+ 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,159 @@
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 } = 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
+ sections.push(buildProjectSection(projectInfo));
48
+ sections.push(
49
+ [
50
+ "## Permission Mode",
51
+ `Your current trust level is **${TRUST_LEVEL_DESCRIPTIONS[trustLevel]}**.`
52
+ ].join("\n")
53
+ );
54
+ if (agentsMd.trim().length > 0) {
55
+ sections.push(["## Agent Instructions", agentsMd].join("\n"));
56
+ }
57
+ if (claudeMd.trim().length > 0) {
58
+ sections.push(["## Project Notes", claudeMd].join("\n"));
59
+ }
60
+ sections.push(
61
+ [
62
+ "## Web Search",
63
+ "You have access to web search. When the user asks to search, look up, or find current/latest information,",
64
+ "you MUST use the web_search tool. Do NOT answer from training data when the user explicitly asks to search.",
65
+ "Always prefer web search for: news, latest versions, current events, live documentation."
66
+ ].join("\n")
67
+ );
68
+ const toolsSection = buildToolsSection(toolDescriptions);
69
+ if (toolsSection.length > 0) {
70
+ sections.push(toolsSection);
71
+ }
72
+ return sections.join("\n\n");
73
+ }
74
+
75
+ // src/assembly/create-tools.ts
76
+ import {
77
+ bashTool,
78
+ readTool,
79
+ writeTool,
80
+ editTool,
81
+ globTool,
82
+ grepTool,
83
+ webFetchTool,
84
+ webSearchTool
85
+ } from "@robota-sdk/agent-tools";
86
+ var DEFAULT_TOOL_DESCRIPTIONS = [
87
+ "Bash \u2014 execute shell commands",
88
+ "Read \u2014 read file contents with line numbers",
89
+ "Write \u2014 write content to a file",
90
+ "Edit \u2014 replace a string in a file",
91
+ "Glob \u2014 find files matching a pattern",
92
+ "Grep \u2014 search file contents with regex",
93
+ "WebSearch \u2014 search the internet (Anthropic built-in)"
94
+ ];
95
+ function createDefaultTools() {
96
+ return [
97
+ bashTool,
98
+ readTool,
99
+ writeTool,
100
+ editTool,
101
+ globTool,
102
+ grepTool,
103
+ webFetchTool,
104
+ webSearchTool
105
+ ];
106
+ }
107
+
108
+ // src/assembly/create-provider.ts
109
+ import { AnthropicProvider } from "@robota-sdk/agent-provider-anthropic";
110
+ function createProvider(config) {
111
+ const apiKey = config.provider.apiKey ?? process.env["ANTHROPIC_API_KEY"];
112
+ if (!apiKey) {
113
+ throw new Error(
114
+ "ANTHROPIC_API_KEY is not set. Set the environment variable or configure provider.apiKey in ~/.robota/settings.json"
115
+ );
116
+ }
117
+ return new AnthropicProvider({ apiKey });
118
+ }
119
+
120
+ // src/assembly/create-session.ts
121
+ function createSession(options) {
122
+ const provider = options.provider ?? createProvider(options.config);
123
+ const defaultTools = createDefaultTools();
124
+ const tools = [...defaultTools, ...options.additionalTools ?? []];
125
+ const buildPrompt = options.systemPromptBuilder ?? buildSystemPrompt;
126
+ const systemMessage = buildPrompt({
127
+ agentsMd: options.context.agentsMd,
128
+ claudeMd: options.context.claudeMd,
129
+ toolDescriptions: options.toolDescriptions ?? DEFAULT_TOOL_DESCRIPTIONS,
130
+ trustLevel: options.config.defaultTrustLevel,
131
+ projectInfo: options.projectInfo ?? { type: "unknown", language: "unknown" }
132
+ });
133
+ return new Session({
134
+ tools,
135
+ provider,
136
+ systemMessage,
137
+ terminal: options.terminal,
138
+ permissions: options.config.permissions,
139
+ hooks: options.config.hooks,
140
+ permissionMode: options.permissionMode,
141
+ defaultTrustLevel: options.config.defaultTrustLevel,
142
+ model: options.config.provider.model,
143
+ maxTurns: options.maxTurns,
144
+ sessionStore: options.sessionStore,
145
+ permissionHandler: options.permissionHandler,
146
+ onTextDelta: options.onTextDelta,
147
+ promptForApproval: options.promptForApproval,
148
+ onCompact: options.onCompact,
149
+ compactInstructions: options.compactInstructions ?? options.context.compactInstructions,
150
+ sessionLogger: options.sessionLogger
151
+ });
152
+ }
153
+
154
+ // src/index.ts
155
+ import { Session as Session2 } from "@robota-sdk/agent-sessions";
156
+ import { FileSessionLogger, SilentSessionLogger } from "@robota-sdk/agent-sessions";
8
157
  import { SessionStore } from "@robota-sdk/agent-sessions";
9
158
 
10
159
  // src/config/config-loader.ts
@@ -270,77 +419,6 @@ async function detectProject(cwd) {
270
419
  };
271
420
  }
272
421
 
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
422
  // src/permissions/permission-prompt.ts
345
423
  import chalk from "chalk";
346
424
  var PERMISSION_OPTIONS = ["Allow", "Deny"];
@@ -384,7 +462,7 @@ async function query(prompt, options) {
384
462
  }, update: () => {
385
463
  } })
386
464
  };
387
- const session = new Session2({
465
+ const session = createSession({
388
466
  config,
389
467
  context,
390
468
  terminal: noopTerminal,
@@ -396,40 +474,38 @@ async function query(prompt, options) {
396
474
  onTextDelta: options?.onTextDelta,
397
475
  onCompact: options?.onCompact,
398
476
  compactInstructions: context.compactInstructions,
399
- systemPromptBuilder: buildSystemPrompt,
400
477
  promptForApproval
401
478
  });
402
479
  return session.run(prompt);
403
480
  }
404
481
 
405
- // src/permissions/permission-gate.ts
482
+ // src/index.ts
406
483
  import { evaluatePermission } from "@robota-sdk/agent-core";
407
-
408
- // src/hooks/hook-runner.ts
409
484
  import { runHooks } from "@robota-sdk/agent-core";
410
485
 
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";
486
+ // src/paths.ts
487
+ import { join as join4 } from "path";
488
+ import { homedir } from "os";
489
+ function projectPaths(cwd) {
490
+ const base = join4(cwd, ".robota");
491
+ return {
492
+ settings: join4(base, "settings.json"),
493
+ settingsLocal: join4(base, "settings.local.json"),
494
+ logs: join4(base, "logs"),
495
+ sessions: join4(base, "sessions")
496
+ };
497
+ }
498
+ function userPaths() {
499
+ const base = join4(homedir(), ".robota");
500
+ return {
501
+ settings: join4(base, "settings.json"),
502
+ sessions: join4(base, "sessions")
503
+ };
504
+ }
428
505
 
429
506
  // src/tools/agent-tool.ts
430
507
  import { z as z2 } from "zod";
431
508
  import { createZodFunctionTool } from "@robota-sdk/agent-tools";
432
- import { Session as Session3 } from "@robota-sdk/agent-sessions";
433
509
  function asZodSchema(schema) {
434
510
  return schema;
435
511
  }
@@ -450,26 +526,26 @@ async function runAgent(args) {
450
526
  };
451
527
  return JSON.stringify(result);
452
528
  }
453
- const subSession = new Session3({
529
+ const noopTerminal = {
530
+ write: () => {
531
+ },
532
+ writeLine: () => {
533
+ },
534
+ writeMarkdown: () => {
535
+ },
536
+ writeError: () => {
537
+ },
538
+ prompt: () => Promise.resolve(""),
539
+ select: () => Promise.resolve(0),
540
+ spinner: () => ({ stop: () => {
541
+ }, update: () => {
542
+ } })
543
+ };
544
+ const subSession = createSession({
454
545
  config: agentToolDeps.config,
455
546
  context: agentToolDeps.context,
456
547
  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
- },
548
+ terminal: noopTerminal,
473
549
  // Sub-agents bypass permissions — they inherit parent's trust
474
550
  permissionMode: "bypassPermissions"
475
551
  });
@@ -498,24 +574,40 @@ var agentTool = createZodFunctionTool(
498
574
  return runAgent(params);
499
575
  }
500
576
  );
577
+
578
+ // src/index.ts
579
+ import { bashTool as bashTool2 } from "@robota-sdk/agent-tools";
580
+ import { readTool as readTool2 } from "@robota-sdk/agent-tools";
581
+ import { writeTool as writeTool2 } from "@robota-sdk/agent-tools";
582
+ import { editTool as editTool2 } from "@robota-sdk/agent-tools";
583
+ import { globTool as globTool2 } from "@robota-sdk/agent-tools";
584
+ import { grepTool as grepTool2 } from "@robota-sdk/agent-tools";
501
585
  export {
502
- Session,
586
+ DEFAULT_TOOL_DESCRIPTIONS,
587
+ FileSessionLogger,
588
+ Session2 as Session,
503
589
  SessionStore,
590
+ SilentSessionLogger,
504
591
  TRUST_TO_MODE,
505
592
  agentTool,
506
- bashTool,
593
+ bashTool2 as bashTool,
507
594
  buildSystemPrompt,
595
+ createDefaultTools,
596
+ createProvider,
597
+ createSession,
508
598
  detectProject,
509
- editTool,
599
+ editTool2 as editTool,
510
600
  evaluatePermission,
511
- globTool,
512
- grepTool,
601
+ globTool2 as globTool,
602
+ grepTool2 as grepTool,
513
603
  loadConfig,
514
604
  loadContext,
605
+ projectPaths,
515
606
  promptForApproval,
516
607
  query,
517
- readTool,
608
+ readTool2 as readTool,
518
609
  runHooks,
519
610
  setAgentToolDeps,
520
- writeTool
611
+ userPaths,
612
+ writeTool2 as writeTool
521
613
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robota-sdk/agent-sdk",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.4",
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.2",
28
- "@robota-sdk/agent-provider-anthropic": "3.0.0-beta.2",
29
- "@robota-sdk/agent-sessions": "3.0.0-beta.2",
30
- "@robota-sdk/agent-tools": "3.0.0-beta.2"
27
+ "@robota-sdk/agent-core": "3.0.0-beta.4",
28
+ "@robota-sdk/agent-provider-anthropic": "3.0.0-beta.4",
29
+ "@robota-sdk/agent-sessions": "3.0.0-beta.4",
30
+ "@robota-sdk/agent-tools": "3.0.0-beta.4"
31
31
  },
32
32
  "devDependencies": {
33
33
  "rimraf": "^5.0.5",