@robota-sdk/agent-sdk 3.0.0-beta.16 → 3.0.0-beta.18

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.
@@ -214,6 +214,7 @@ function createSession(options) {
214
214
  sessionStore: options.sessionStore,
215
215
  permissionHandler: options.permissionHandler,
216
216
  onTextDelta: options.onTextDelta,
217
+ onToolExecution: options.onToolExecution,
217
218
  promptForApproval: options.promptForApproval,
218
219
  onCompact: options.onCompact,
219
220
  compactInstructions: options.compactInstructions ?? options.context.compactInstructions,
@@ -288,8 +289,15 @@ function readJsonFile(filePath) {
288
289
  if (!(0, import_fs.existsSync)(filePath)) {
289
290
  return void 0;
290
291
  }
291
- const raw = (0, import_fs.readFileSync)(filePath, "utf-8");
292
- return JSON.parse(raw);
292
+ const raw = (0, import_fs.readFileSync)(filePath, "utf-8").trim();
293
+ if (raw.length === 0) {
294
+ return void 0;
295
+ }
296
+ try {
297
+ return JSON.parse(raw);
298
+ } catch {
299
+ return void 0;
300
+ }
293
301
  }
294
302
  function resolveEnvRef(value) {
295
303
  const ENV_PREFIX = "$ENV:";
@@ -278,6 +278,13 @@ interface ICreateSessionOptions {
278
278
  promptForApproval?: (terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
279
279
  /** Additional tools to register beyond the defaults (e.g. agent-tool) */
280
280
  additionalTools?: IToolWithEventService[];
281
+ /** Callback when a tool starts or finishes execution — enables real-time tool display in UI */
282
+ onToolExecution?: (event: {
283
+ type: 'start' | 'end';
284
+ toolName: string;
285
+ toolArgs?: TToolArgs;
286
+ success?: boolean;
287
+ }) => void;
281
288
  /** Callback when context is compacted */
282
289
  onCompact?: (summary: string) => void;
283
290
  /** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
@@ -278,6 +278,13 @@ interface ICreateSessionOptions {
278
278
  promptForApproval?: (terminal: ITerminalOutput, toolName: string, toolArgs: TToolArgs) => Promise<boolean>;
279
279
  /** Additional tools to register beyond the defaults (e.g. agent-tool) */
280
280
  additionalTools?: IToolWithEventService[];
281
+ /** Callback when a tool starts or finishes execution — enables real-time tool display in UI */
282
+ onToolExecution?: (event: {
283
+ type: 'start' | 'end';
284
+ toolName: string;
285
+ toolArgs?: TToolArgs;
286
+ success?: boolean;
287
+ }) => void;
281
288
  /** Callback when context is compacted */
282
289
  onCompact?: (summary: string) => void;
283
290
  /** Instructions to include in the compaction prompt (e.g. from CLAUDE.md) */
@@ -161,6 +161,7 @@ function createSession(options) {
161
161
  sessionStore: options.sessionStore,
162
162
  permissionHandler: options.permissionHandler,
163
163
  onTextDelta: options.onTextDelta,
164
+ onToolExecution: options.onToolExecution,
164
165
  promptForApproval: options.promptForApproval,
165
166
  onCompact: options.onCompact,
166
167
  compactInstructions: options.compactInstructions ?? options.context.compactInstructions,
@@ -235,8 +236,15 @@ function readJsonFile(filePath) {
235
236
  if (!existsSync(filePath)) {
236
237
  return void 0;
237
238
  }
238
- const raw = readFileSync(filePath, "utf-8");
239
- return JSON.parse(raw);
239
+ const raw = readFileSync(filePath, "utf-8").trim();
240
+ if (raw.length === 0) {
241
+ return void 0;
242
+ }
243
+ try {
244
+ return JSON.parse(raw);
245
+ } catch {
246
+ return void 0;
247
+ }
240
248
  }
241
249
  function resolveEnvRef(value) {
242
250
  const ENV_PREFIX = "$ENV:";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robota-sdk/agent-sdk",
3
- "version": "3.0.0-beta.16",
3
+ "version": "3.0.0-beta.18",
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.16",
28
- "@robota-sdk/agent-provider-anthropic": "3.0.0-beta.16",
29
- "@robota-sdk/agent-tools": "3.0.0-beta.16",
30
- "@robota-sdk/agent-sessions": "3.0.0-beta.16"
27
+ "@robota-sdk/agent-core": "3.0.0-beta.18",
28
+ "@robota-sdk/agent-provider-anthropic": "3.0.0-beta.18",
29
+ "@robota-sdk/agent-sessions": "3.0.0-beta.18",
30
+ "@robota-sdk/agent-tools": "3.0.0-beta.18"
31
31
  },
32
32
  "devDependencies": {
33
33
  "rimraf": "^5.0.5",