@chatbotkit/agent 1.33.0 → 1.35.0

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.
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.loadAgent = loadAgent;
7
7
  const promises_1 = require("fs/promises");
8
+ const promises_2 = require("fs/promises");
8
9
  const js_yaml_1 = __importDefault(require("js-yaml"));
9
10
  const path_1 = require("path");
10
11
  function parseAgentFile(content) {
@@ -24,9 +25,23 @@ function parseAgentFile(content) {
24
25
  }
25
26
  return { frontMatter, body: match[2].trim() };
26
27
  }
27
- async function loadAgent(filePath) {
28
- const resolvedPath = (0, path_1.resolve)(process.cwd(), filePath);
29
- const content = await (0, promises_1.readFile)(resolvedPath, 'utf-8');
28
+ async function loadAgent(filePath, options) {
29
+ const roots = [process.cwd(), ...(options?.roots ?? [])];
30
+ let resolvedPath;
31
+ for (const root of roots) {
32
+ const candidate = (0, path_1.resolve)(root, filePath);
33
+ try {
34
+ await (0, promises_1.access)(candidate);
35
+ resolvedPath = candidate;
36
+ break;
37
+ }
38
+ catch {
39
+ }
40
+ }
41
+ if (!resolvedPath) {
42
+ throw new Error(`Agent file not found: ${filePath}`);
43
+ }
44
+ const content = await (0, promises_2.readFile)(resolvedPath, 'utf-8');
30
45
  const { frontMatter, body } = parseAgentFile(content);
31
46
  const name = typeof frontMatter.name === 'string' ? frontMatter.name : undefined;
32
47
  const description = typeof frontMatter.description === 'string'
@@ -1,4 +1,4 @@
1
- export function loadAgent(filePath: string): Promise<AgentDefinition>;
1
+ export function loadAgent(filePath: string, options?: LoadAgentOptions): Promise<AgentDefinition>;
2
2
  export type AgentDefinition = {
3
3
  name?: string;
4
4
  description?: string;
@@ -8,3 +8,6 @@ export type AgentDefinition = {
8
8
  skillsetId?: string;
9
9
  datasetId?: string;
10
10
  };
11
+ export type LoadAgentOptions = {
12
+ roots?: string[];
13
+ };
@@ -308,7 +308,7 @@ The goal is to complete the assigned task efficiently and effectively. Follow th
308
308
  if (exitResult) {
309
309
  break;
310
310
  }
311
- if (lastEndReason === 'stop') {
311
+ if (lastEndReason === 'stop' || lastEndReason === 'abort') {
312
312
  exitResult = { code: 0 };
313
313
  break;
314
314
  }
@@ -1,4 +1,4 @@
1
- export function loadAgent(filePath: string): Promise<AgentDefinition>;
1
+ export function loadAgent(filePath: string, options?: LoadAgentOptions): Promise<AgentDefinition>;
2
2
  export type AgentDefinition = {
3
3
  name?: string;
4
4
  description?: string;
@@ -8,3 +8,6 @@ export type AgentDefinition = {
8
8
  skillsetId?: string;
9
9
  datasetId?: string;
10
10
  };
11
+ export type LoadAgentOptions = {
12
+ roots?: string[];
13
+ };
package/dist/esm/agent.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { access } from 'fs/promises';
1
2
  import { readFile } from 'fs/promises';
2
3
  import yaml from 'js-yaml';
3
4
  import { resolve } from 'path';
@@ -18,8 +19,22 @@ function parseAgentFile(content) {
18
19
  }
19
20
  return { frontMatter, body: match[2].trim() };
20
21
  }
21
- export async function loadAgent(filePath) {
22
- const resolvedPath = resolve(process.cwd(), filePath);
22
+ export async function loadAgent(filePath, options) {
23
+ const roots = [process.cwd(), ...(options?.roots ?? [])];
24
+ let resolvedPath;
25
+ for (const root of roots) {
26
+ const candidate = resolve(root, filePath);
27
+ try {
28
+ await access(candidate);
29
+ resolvedPath = candidate;
30
+ break;
31
+ }
32
+ catch {
33
+ }
34
+ }
35
+ if (!resolvedPath) {
36
+ throw new Error(`Agent file not found: ${filePath}`);
37
+ }
23
38
  const content = await readFile(resolvedPath, 'utf-8');
24
39
  const { frontMatter, body } = parseAgentFile(content);
25
40
  const name = typeof frontMatter.name === 'string' ? frontMatter.name : undefined;
@@ -304,7 +304,7 @@ The goal is to complete the assigned task efficiently and effectively. Follow th
304
304
  if (exitResult) {
305
305
  break;
306
306
  }
307
- if (lastEndReason === 'stop') {
307
+ if (lastEndReason === 'stop' || lastEndReason === 'abort') {
308
308
  exitResult = { code: 0 };
309
309
  break;
310
310
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatbotkit/agent",
3
- "version": "1.33.0",
3
+ "version": "1.35.0",
4
4
  "description": "ChatBotKit Agent implementation",
5
5
  "license": "ISC",
6
6
  "engines": {
@@ -139,7 +139,7 @@
139
139
  "js-yaml": "^4.1.0",
140
140
  "zod": "^3.25.76",
141
141
  "zod-to-json-schema": "^3.24.6",
142
- "@chatbotkit/sdk": "1.33.0"
142
+ "@chatbotkit/sdk": "1.35.0"
143
143
  },
144
144
  "devDependencies": {
145
145
  "@types/js-yaml": "^4.0.9",