arcie 0.1.4 → 0.1.6

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.
Files changed (64) hide show
  1. package/dist/agent/index.d.ts +1 -1
  2. package/dist/build-TWNCPXBU.js +82 -0
  3. package/dist/build-TWNCPXBU.js.map +1 -0
  4. package/dist/channels/index.d.ts +1 -1
  5. package/dist/{chunk-2ZSKZYWK.js → chunk-4WSILP75.js} +37 -164
  6. package/dist/chunk-4WSILP75.js.map +1 -0
  7. package/dist/chunk-HVBDOHTL.js +148 -0
  8. package/dist/chunk-HVBDOHTL.js.map +1 -0
  9. package/dist/chunk-HWD2Z2CH.js +742 -0
  10. package/dist/chunk-HWD2Z2CH.js.map +1 -0
  11. package/dist/chunk-KVSX4MLK.js +139 -0
  12. package/dist/chunk-KVSX4MLK.js.map +1 -0
  13. package/dist/chunk-N5R3TEEZ.js +15 -0
  14. package/dist/chunk-N5R3TEEZ.js.map +1 -0
  15. package/dist/chunk-SGWQZZ2A.js +54 -0
  16. package/dist/chunk-SGWQZZ2A.js.map +1 -0
  17. package/dist/chunk-XOFWQUOO.js +30 -0
  18. package/dist/chunk-XOFWQUOO.js.map +1 -0
  19. package/dist/cli/index.d.ts +7 -0
  20. package/dist/cli/index.js +156 -231
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/context/index.d.ts +1 -1
  23. package/dist/dev-ZZDVOWUZ.js +1967 -0
  24. package/dist/dev-ZZDVOWUZ.js.map +1 -0
  25. package/dist/hooks/index.d.ts +1 -1
  26. package/dist/{index-b4NcDl3m.d.ts → index-CElLRVTP.d.ts} +1 -1
  27. package/dist/index.d.ts +4 -4
  28. package/dist/index.js +4 -2
  29. package/dist/index.js.map +1 -1
  30. package/dist/init-5F7CIVLN.js +822 -0
  31. package/dist/init-5F7CIVLN.js.map +1 -0
  32. package/dist/instructions/index.d.ts +1 -1
  33. package/dist/runner/index.d.ts +2 -2
  34. package/dist/runner/index.js +2 -1
  35. package/dist/scaffold-web-chat-OQL5C2GK.js +7 -0
  36. package/dist/scaffold-web-chat-OQL5C2GK.js.map +1 -0
  37. package/dist/schedules/index.d.ts +1 -1
  38. package/dist/skills/index.d.ts +1 -1
  39. package/dist/tools/index.d.ts +1 -1
  40. package/dist/{types-BxOQTzx1.d.ts → types-DwxwdSa2.d.ts} +1 -1
  41. package/package.json +1 -1
  42. package/templates/default/.env.local +12 -0
  43. package/templates/web-chat/.env.local.example +4 -0
  44. package/templates/web-chat/README.md +51 -0
  45. package/templates/web-chat/app/api/chat/route.ts +43 -0
  46. package/templates/web-chat/app/globals.css +65 -0
  47. package/templates/web-chat/app/layout.tsx +15 -0
  48. package/templates/web-chat/app/page.tsx +9 -0
  49. package/templates/web-chat/components/chat.tsx +219 -0
  50. package/templates/web-chat/components/input-bar.tsx +181 -0
  51. package/templates/web-chat/components/message.tsx +123 -0
  52. package/templates/web-chat/components/tool-call.tsx +79 -0
  53. package/templates/web-chat/components/ui/button.tsx +46 -0
  54. package/templates/web-chat/components/ui/input.tsx +19 -0
  55. package/templates/web-chat/components.json +20 -0
  56. package/templates/web-chat/lib/stream.ts +41 -0
  57. package/templates/web-chat/lib/types.ts +62 -0
  58. package/templates/web-chat/lib/utils.ts +6 -0
  59. package/templates/web-chat/next.config.mjs +6 -0
  60. package/templates/web-chat/package.json +33 -0
  61. package/templates/web-chat/postcss.config.mjs +6 -0
  62. package/templates/web-chat/tailwind.config.ts +61 -0
  63. package/templates/web-chat/tsconfig.json +23 -0
  64. package/dist/chunk-2ZSKZYWK.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { A as AgentConfig } from '../types-BxOQTzx1.js';
1
+ import { a as AgentConfig } from '../types-DwxwdSa2.js';
2
2
  import 'zod';
3
3
 
4
4
  declare function defineAgent(config: AgentConfig): AgentConfig;
@@ -0,0 +1,82 @@
1
+ import {
2
+ dimmed,
3
+ grey
4
+ } from "./chunk-N5R3TEEZ.js";
5
+ import {
6
+ loadAgent
7
+ } from "./chunk-KVSX4MLK.js";
8
+ import {
9
+ discoverAgent
10
+ } from "./chunk-6XETPLIF.js";
11
+
12
+ // src/cli/build.ts
13
+ import { mkdirSync, writeFileSync, existsSync } from "fs";
14
+ import { resolve, join } from "path";
15
+ async function buildCommand(options) {
16
+ const agentDirPath = resolve(process.cwd(), options.agentDir);
17
+ const outDir = resolve(process.cwd(), options.outDir);
18
+ console.log(`
19
+ Building agent...
20
+ `);
21
+ if (!existsSync(agentDirPath)) {
22
+ console.error(` Agent directory not found: ${agentDirPath}`);
23
+ process.exit(1);
24
+ }
25
+ const { agent: discovered, diagnostics } = discoverAgent(agentDirPath);
26
+ if (diagnostics.some((d) => d.severity === "error")) {
27
+ for (const d of diagnostics) {
28
+ console.error(` ${grey("\u2716")} ${d.code}: ${d.message}`);
29
+ }
30
+ process.exit(1);
31
+ }
32
+ try {
33
+ const agent = await loadAgent(agentDirPath);
34
+ mkdirSync(outDir, { recursive: true });
35
+ const manifest = {
36
+ config: agent.manifest.config,
37
+ instructions: agent.manifest.instructions,
38
+ tools: Object.keys(agent.manifest.tools),
39
+ skills: Object.keys(agent.manifest.skills),
40
+ hooks: Object.keys(agent.manifest.hooks),
41
+ channels: Object.keys(agent.manifest.channels),
42
+ connections: Object.keys(agent.manifest.connections),
43
+ schedules: Object.keys(agent.manifest.schedules),
44
+ subagents: Object.fromEntries(
45
+ Object.entries(agent.manifest.subagents).map(([id, sub]) => [
46
+ id,
47
+ { description: sub.config.description, tools: Object.keys(sub.tools) }
48
+ ])
49
+ ),
50
+ discovered: {
51
+ tools: discovered.tools.map((t) => t.name),
52
+ skills: discovered.skills.map((s) => s.name),
53
+ hooks: discovered.hooks.map((h) => h.name),
54
+ channels: discovered.channels.map((c) => c.name),
55
+ connections: discovered.connections.map((c) => c.name),
56
+ schedules: discovered.schedules.map((s) => s.name),
57
+ subagents: discovered.subagents.map((s) => s.id)
58
+ },
59
+ session: agent.manifest.session,
60
+ policy: agent.manifest.policy
61
+ };
62
+ writeFileSync(join(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
63
+ console.log(` Written to ${dimmed(`${outDir}/manifest.json`)}`);
64
+ console.log(` ${grey(`\xB7 ${manifest.tools.length} tools`)}`);
65
+ console.log(` ${grey(`\xB7 ${manifest.skills.length} skills`)}`);
66
+ console.log(` ${grey(`\xB7 ${manifest.channels.length} channels`)}`);
67
+ console.log(` ${grey(`\xB7 ${manifest.connections.length} connections`)}`);
68
+ console.log(` ${grey(`\xB7 ${manifest.schedules.length} schedules`)}`);
69
+ console.log(` ${grey(`\xB7 ${Object.keys(manifest.subagents).length} subagents`)}`);
70
+ console.log();
71
+ console.log(` ${grey("\u2500".repeat(50))}`);
72
+ console.log(` ${grey("Build complete.")}`);
73
+ console.log();
74
+ } catch (err) {
75
+ console.error(` Build failed:`, err);
76
+ process.exit(1);
77
+ }
78
+ }
79
+ export {
80
+ buildCommand
81
+ };
82
+ //# sourceMappingURL=build-TWNCPXBU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/build.ts"],"sourcesContent":["import { mkdirSync, writeFileSync, existsSync } from \"node:fs\";\nimport { resolve, join } from \"node:path\";\nimport { loadAgent } from \"../loader\";\nimport { discoverAgent } from \"../discover/index\";\nimport { grey, dimmed } from \"./style\";\n\nexport async function buildCommand(options: {\n agentDir: string;\n outDir: string;\n}): Promise<void> {\n const agentDirPath = resolve(process.cwd(), options.agentDir);\n const outDir = resolve(process.cwd(), options.outDir);\n\n console.log(`\\n Building agent...\\n`);\n\n if (!existsSync(agentDirPath)) {\n console.error(` Agent directory not found: ${agentDirPath}`);\n process.exit(1);\n }\n\n const { agent: discovered, diagnostics } = discoverAgent(agentDirPath);\n\n if (diagnostics.some((d) => d.severity === \"error\")) {\n for (const d of diagnostics) {\n console.error(` ${grey(\"\\u2716\")} ${d.code}: ${d.message}`);\n }\n process.exit(1);\n }\n\n try {\n const agent = await loadAgent(agentDirPath);\n\n mkdirSync(outDir, { recursive: true });\n\n const manifest = {\n config: agent.manifest.config,\n instructions: agent.manifest.instructions,\n tools: Object.keys(agent.manifest.tools),\n skills: Object.keys(agent.manifest.skills),\n hooks: Object.keys(agent.manifest.hooks),\n channels: Object.keys(agent.manifest.channels),\n connections: Object.keys(agent.manifest.connections),\n schedules: Object.keys(agent.manifest.schedules),\n subagents: Object.fromEntries(\n Object.entries(agent.manifest.subagents).map(([id, sub]) => [\n id,\n { description: sub.config.description, tools: Object.keys(sub.tools) },\n ]),\n ),\n discovered: {\n tools: discovered.tools.map((t) => t.name),\n skills: discovered.skills.map((s) => s.name),\n hooks: discovered.hooks.map((h) => h.name),\n channels: discovered.channels.map((c) => c.name),\n connections: discovered.connections.map((c) => c.name),\n schedules: discovered.schedules.map((s) => s.name),\n subagents: discovered.subagents.map((s) => s.id),\n },\n session: agent.manifest.session,\n policy: agent.manifest.policy,\n };\n\n writeFileSync(join(outDir, \"manifest.json\"), JSON.stringify(manifest, null, 2));\n\n console.log(` Written to ${dimmed(`${outDir}/manifest.json`)}`);\n console.log(` ${grey(`\\xB7 ${manifest.tools.length} tools`)}`);\n console.log(` ${grey(`\\xB7 ${manifest.skills.length} skills`)}`);\n console.log(` ${grey(`\\xB7 ${manifest.channels.length} channels`)}`);\n console.log(` ${grey(`\\xB7 ${manifest.connections.length} connections`)}`);\n console.log(` ${grey(`\\xB7 ${manifest.schedules.length} schedules`)}`);\n console.log(` ${grey(`\\xB7 ${Object.keys(manifest.subagents).length} subagents`)}`);\n console.log();\n console.log(` ${grey(\"\\u2500\".repeat(50))}`);\n console.log(` ${grey(\"Build complete.\")}`);\n console.log();\n } catch (err) {\n console.error(` Build failed:`, err);\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,WAAW,eAAe,kBAAkB;AACrD,SAAS,SAAS,YAAY;AAK9B,eAAsB,aAAa,SAGjB;AAChB,QAAM,eAAe,QAAQ,QAAQ,IAAI,GAAG,QAAQ,QAAQ;AAC5D,QAAM,SAAS,QAAQ,QAAQ,IAAI,GA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Z,YAAQ,MAAM,mBAAmB,GAAG;AACpC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- import { C as ChannelConfig } from '../types-BxOQTzx1.js';
1
+ import { d as ChannelConfig } from '../types-DwxwdSa2.js';
2
2
  import 'zod';
3
3
 
4
4
  declare function defineChannel(config: ChannelConfig): ChannelConfig;
@@ -1,3 +1,6 @@
1
+ import {
2
+ loadAgent
3
+ } from "./chunk-KVSX4MLK.js";
1
4
  import {
2
5
  createMessageAppended,
3
6
  createMessageCompleted,
@@ -18,141 +21,6 @@ import {
18
21
  toModelOutput
19
22
  } from "./chunk-PHTJLJOV.js";
20
23
 
21
- // src/loader.ts
22
- import { readFileSync, existsSync, readdirSync, statSync } from "fs";
23
- import { resolve, basename, extname } from "path";
24
- async function loadAgent(agentDir) {
25
- const absDir = resolve(process.cwd(), agentDir);
26
- if (!existsSync(absDir)) {
27
- throw new Error(`Agent directory not found: ${absDir}`);
28
- }
29
- const agentFile = resolve(absDir, "agent.ts");
30
- let config = { model: "gpt-4o" };
31
- if (existsSync(agentFile)) {
32
- try {
33
- const mod = await import(agentFile);
34
- if (mod.default) {
35
- config = { ...config, ...mod.default };
36
- }
37
- } catch (err) {
38
- console.warn(`[arcie] Failed to load agent.ts: ${err.message}. Using defaults.`);
39
- }
40
- }
41
- const instructions = loadInstructionsFile(absDir);
42
- const tools = await loadDirectory(absDir, "tools");
43
- const skills = await loadDirectory(absDir, "skills");
44
- const hooks = await loadDirectory(absDir, "hooks");
45
- const channels = await loadDirectory(absDir, "channels");
46
- const connections = await loadDirectory(absDir, "connections");
47
- const schedules = await loadDirectory(absDir, "schedules");
48
- const subagents = await loadSubagents(absDir);
49
- const session = await loadSessionConfig(absDir);
50
- const policy = await loadPolicyConfig(absDir);
51
- return {
52
- agentDir: absDir,
53
- manifest: {
54
- config,
55
- instructions,
56
- tools,
57
- skills,
58
- hooks,
59
- channels,
60
- connections,
61
- schedules,
62
- subagents,
63
- session: session ?? void 0,
64
- policy: policy ?? void 0
65
- }
66
- };
67
- }
68
- async function loadSubagents(agentDir) {
69
- const dirPath = resolve(agentDir, "subagents");
70
- if (!existsSync(dirPath)) return {};
71
- const result = {};
72
- for (const entry of readdirSync(dirPath, { withFileTypes: true })) {
73
- if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
74
- const id = entry.name;
75
- const subDir = resolve(dirPath, id);
76
- const agentFile = resolve(subDir, "agent.ts");
77
- if (!existsSync(agentFile)) {
78
- throw new Error(`Subagent "${id}" is missing agent.ts`);
79
- }
80
- let mod;
81
- try {
82
- mod = await import(agentFile);
83
- } catch (err) {
84
- throw new Error(`Failed to load subagent "${id}": ${err.message}`);
85
- }
86
- const config = mod.default;
87
- if (!config) {
88
- throw new Error(`Subagent "${id}" agent.ts must have a default export`);
89
- }
90
- if (!config.description) {
91
- throw new Error(`Subagent "${id}" must declare a description in agent.ts`);
92
- }
93
- result[id] = {
94
- config,
95
- instructions: loadInstructionsFile(subDir),
96
- tools: await loadDirectory(subDir, "tools"),
97
- skills: await loadDirectory(subDir, "skills")
98
- };
99
- }
100
- return result;
101
- }
102
- function loadInstructionsFile(agentDir) {
103
- const mdPath = resolve(agentDir, "instructions.md");
104
- if (existsSync(mdPath)) {
105
- return readFileSync(mdPath, "utf-8");
106
- }
107
- return "You are a helpful AI agent.";
108
- }
109
- async function loadDirectory(agentDir, dirName) {
110
- const dirPath = resolve(agentDir, dirName);
111
- if (!existsSync(dirPath)) return {};
112
- const entries = readdirSync(dirPath).filter(
113
- (f) => !f.startsWith(".") && (f.endsWith(".ts") || f.endsWith(".js"))
114
- );
115
- const result = {};
116
- for (const entry of entries) {
117
- const name = basename(entry, extname(entry));
118
- const filePath = resolve(dirPath, entry);
119
- if (statSync(filePath).isFile()) {
120
- try {
121
- const mod = await import(filePath);
122
- if (mod.default) {
123
- result[name] = mod.default;
124
- }
125
- } catch {
126
- }
127
- }
128
- }
129
- return result;
130
- }
131
- async function loadSessionConfig(agentDir) {
132
- const tsPath = resolve(agentDir, "sessions", "config.ts");
133
- if (existsSync(tsPath)) {
134
- try {
135
- const mod = await import(tsPath);
136
- return mod.default ?? null;
137
- } catch {
138
- return null;
139
- }
140
- }
141
- return null;
142
- }
143
- async function loadPolicyConfig(agentDir) {
144
- const tsPath = resolve(agentDir, "policies", "index.ts");
145
- if (existsSync(tsPath)) {
146
- try {
147
- const mod = await import(tsPath);
148
- return mod.default ?? null;
149
- } catch {
150
- return null;
151
- }
152
- }
153
- return null;
154
- }
155
-
156
24
  // src/memory/store.ts
157
25
  var InMemoryStore = class {
158
26
  entries = /* @__PURE__ */ new Map();
@@ -229,13 +97,13 @@ var InMemoryStore = class {
229
97
 
230
98
  // src/memory/sqlite-store.ts
231
99
  import { createClient } from "@libsql/client";
232
- import { resolve as resolve2, dirname } from "path";
100
+ import { resolve, dirname } from "path";
233
101
  import { homedir } from "os";
234
102
  import { mkdirSync } from "fs";
235
103
  var SqliteStore = class {
236
104
  client;
237
105
  constructor(dbPath) {
238
- const path = dbPath ?? resolve2(homedir(), ".arcie", "memory.db");
106
+ const path = dbPath ?? resolve(homedir(), ".arcie", "memory.db");
239
107
  mkdirSync(dirname(path), { recursive: true });
240
108
  this.client = createClient({ url: `file:${path}` });
241
109
  this.init();
@@ -438,26 +306,26 @@ var SqliteStore = class {
438
306
  };
439
307
 
440
308
  // src/memory/file-store.ts
441
- import { readFileSync as readFileSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, writeFileSync } from "fs";
442
- import { resolve as resolve3, dirname as dirname2 } from "path";
309
+ import { readFileSync, existsSync, mkdirSync as mkdirSync2, writeFileSync } from "fs";
310
+ import { resolve as resolve2, dirname as dirname2 } from "path";
443
311
  import { homedir as homedir2 } from "os";
444
312
  var FileStore = class {
445
313
  baseDir;
446
314
  constructor(baseDir) {
447
- this.baseDir = baseDir ?? resolve3(homedir2(), ".arcie", "memory");
315
+ this.baseDir = baseDir ?? resolve2(homedir2(), ".arcie", "memory");
448
316
  }
449
317
  filePath(resourceId, threadId) {
450
- const dir = resolve3(this.baseDir, resourceId);
451
- return resolve3(dir, `${threadId}.json`);
318
+ const dir = resolve2(this.baseDir, resourceId);
319
+ return resolve2(dir, `${threadId}.json`);
452
320
  }
453
321
  threadsPath(resourceId) {
454
- return resolve3(this.baseDir, resourceId, "__threads.json");
322
+ return resolve2(this.baseDir, resourceId, "__threads.json");
455
323
  }
456
324
  read(resourceId, threadId) {
457
325
  const path = this.filePath(resourceId, threadId);
458
- if (!existsSync2(path)) return [];
326
+ if (!existsSync(path)) return [];
459
327
  try {
460
- const raw = readFileSync2(path, "utf-8");
328
+ const raw = readFileSync(path, "utf-8");
461
329
  return JSON.parse(raw);
462
330
  } catch {
463
331
  return [];
@@ -470,9 +338,9 @@ var FileStore = class {
470
338
  }
471
339
  readThreads(resourceId) {
472
340
  const path = this.threadsPath(resourceId);
473
- if (!existsSync2(path)) return [];
341
+ if (!existsSync(path)) return [];
474
342
  try {
475
- const raw = readFileSync2(path, "utf-8");
343
+ const raw = readFileSync(path, "utf-8");
476
344
  return JSON.parse(raw);
477
345
  } catch {
478
346
  return [];
@@ -521,7 +389,7 @@ var FileStore = class {
521
389
  const threads = this.readThreads(resourceId);
522
390
  this.writeThreads(resourceId, threads.filter((t) => t.id !== threadId));
523
391
  const path = this.filePath(resourceId, threadId);
524
- if (existsSync2(path)) writeFileSync(path, "[]", "utf-8");
392
+ if (existsSync(path)) writeFileSync(path, "[]", "utf-8");
525
393
  }
526
394
  async deleteMessages(opts) {
527
395
  let entries = this.read(opts.resourceId, opts.threadId);
@@ -770,8 +638,8 @@ var SummaryStrategy = class {
770
638
  async exclusive(fn) {
771
639
  const prev = this.mutex;
772
640
  let release;
773
- this.mutex = new Promise((resolve5) => {
774
- release = resolve5;
641
+ this.mutex = new Promise((resolve4) => {
642
+ release = resolve4;
775
643
  });
776
644
  await prev;
777
645
  try {
@@ -903,8 +771,8 @@ ${lines.join("\n")}`;
903
771
  };
904
772
 
905
773
  // src/memory/working-memory.ts
906
- import { readFileSync as readFileSync3, existsSync as existsSync3, mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "fs";
907
- import { resolve as resolve4 } from "path";
774
+ import { readFileSync as readFileSync2, existsSync as existsSync2, mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "fs";
775
+ import { resolve as resolve3 } from "path";
908
776
  import { homedir as homedir3 } from "os";
909
777
  import { z } from "zod";
910
778
  var updateWorkingMemorySchema = z.object({
@@ -933,7 +801,7 @@ var WorkingMemory = class {
933
801
  this.template = template ?? DEFAULT_TEMPLATE;
934
802
  this.content = this.template;
935
803
  this.resourceId = resourceId ?? "default";
936
- this.baseDir = baseDir ?? resolve4(homedir3(), ".arcie", "memory", "working");
804
+ this.baseDir = baseDir ?? resolve3(homedir3(), ".arcie", "memory", "working");
937
805
  }
938
806
  ensureDir() {
939
807
  if (!this.initialized) {
@@ -942,13 +810,13 @@ var WorkingMemory = class {
942
810
  }
943
811
  }
944
812
  filePath(resourceId) {
945
- return resolve4(this.baseDir, `${resourceId}.md`);
813
+ return resolve3(this.baseDir, `${resourceId}.md`);
946
814
  }
947
815
  loadFromDisk(resourceId) {
948
816
  this.ensureDir();
949
817
  const path = this.filePath(resourceId);
950
- if (existsSync3(path)) {
951
- this.content = readFileSync3(path, "utf-8");
818
+ if (existsSync2(path)) {
819
+ this.content = readFileSync2(path, "utf-8");
952
820
  } else {
953
821
  this.content = this.template;
954
822
  }
@@ -1466,6 +1334,12 @@ var Memory = class _Memory {
1466
1334
  };
1467
1335
 
1468
1336
  // src/runner/index.ts
1337
+ function truncateBody(body) {
1338
+ if (body.length > 200 && (body.startsWith("<!") || body.startsWith("<html"))) {
1339
+ return body.slice(0, 200) + "... (HTML response truncated)";
1340
+ }
1341
+ return body;
1342
+ }
1469
1343
  var DEFAULT_ENDPOINT = "https://cencori.com/v1";
1470
1344
  async function createChildSession(endpoint, apiKey, agent, subagentId) {
1471
1345
  const sub = agent.manifest.subagents[subagentId];
@@ -1485,7 +1359,7 @@ async function createChildSession(endpoint, apiKey, agent, subagentId) {
1485
1359
  });
1486
1360
  if (!res.ok) {
1487
1361
  const err = await res.text();
1488
- throw new Error(`Subagent session error (${res.status}): ${err}`);
1362
+ throw new Error(`Subagent session error (${res.status}): ${truncateBody(err)}`);
1489
1363
  }
1490
1364
  const data = await res.json();
1491
1365
  return data.id;
@@ -1517,7 +1391,7 @@ async function executeSubagent(endpoint, apiKey, agent, subagentId, input, child
1517
1391
  });
1518
1392
  if (!res.ok) {
1519
1393
  const err = await res.text();
1520
- throw new Error(`Subagent turn error (${res.status}): ${err}`);
1394
+ throw new Error(`Subagent turn error (${res.status}): ${truncateBody(err)}`);
1521
1395
  }
1522
1396
  let output = "";
1523
1397
  let currentEvent = "";
@@ -1572,7 +1446,7 @@ async function createSession(endpoint, apiKey, agent) {
1572
1446
  });
1573
1447
  if (!res.ok) {
1574
1448
  const err = await res.text();
1575
- throw new Error(`Cencori Sessions API error (${res.status}): ${err}`);
1449
+ throw new Error(`Cencori Sessions API error (${res.status}): ${truncateBody(err)}`);
1576
1450
  }
1577
1451
  const data = await res.json();
1578
1452
  return data.id;
@@ -1628,7 +1502,7 @@ async function runAgent(agentDir, input, options = {}) {
1628
1502
  async function* readTurnSSE(response, turnId) {
1629
1503
  if (!response.ok) {
1630
1504
  const error = await response.text();
1631
- throw new Error(`Cencori Sessions API error (${response.status}): ${error}`);
1505
+ throw new Error(`Cencori Sessions API error (${response.status}): ${truncateBody(error)}`);
1632
1506
  }
1633
1507
  const reader = response.body?.getReader();
1634
1508
  if (!reader) return { status: "completed", text: "" };
@@ -1777,7 +1651,7 @@ async function* streamAgent(agentDir, input, options = {}) {
1777
1651
  const error = await response.text();
1778
1652
  yield createTurnCompleted(1, turnId);
1779
1653
  yield createSessionCompleted();
1780
- throw new Error(`Cencori Sessions API error (${response.status}): ${error}`);
1654
+ throw new Error(`Cencori Sessions API error (${response.status}): ${truncateBody(error)}`);
1781
1655
  }
1782
1656
  const approvedTools = /* @__PURE__ */ new Set();
1783
1657
  const allToolCalls = [];
@@ -1874,7 +1748,7 @@ async function* streamAgent(agentDir, input, options = {}) {
1874
1748
  const errText = await approveRes.text();
1875
1749
  yield createTurnCompleted(1, turnId);
1876
1750
  yield createSessionCompleted();
1877
- throw new Error(`Cencori Sessions approve error (${approveRes.status}): ${errText}`);
1751
+ throw new Error(`Cencori Sessions approve error (${approveRes.status}): ${truncateBody(errText)}`);
1878
1752
  }
1879
1753
  response = approveRes;
1880
1754
  }
@@ -1894,8 +1768,7 @@ export {
1894
1768
  WORKING_MEMORY_SYSTEM_INSTRUCTION,
1895
1769
  WorkingMemory,
1896
1770
  Memory,
1897
- loadAgent,
1898
1771
  runAgent,
1899
1772
  streamAgent
1900
1773
  };
1901
- //# sourceMappingURL=chunk-2ZSKZYWK.js.map
1774
+ //# sourceMappingURL=chunk-4WSILP75.js.map