@townco/agent 0.1.104 → 0.1.106

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.
@@ -54,7 +54,7 @@ export declare class AgentAcpAdapter implements acp.Agent {
54
54
  /**
55
55
  * Extract tool metadata from the agent definition for exposing to clients.
56
56
  * This provides basic info about available tools without loading them fully.
57
- * For tool groups (like town_e2b, filesystem), dynamically extracts children
57
+ * For tool groups (like code_sandbox, filesystem), dynamically extracts children
58
58
  * tools info from the actual tool factories.
59
59
  */
60
60
  private getToolsMetadata;
@@ -156,7 +156,7 @@ export class AgentAcpAdapter {
156
156
  /**
157
157
  * Extract tool metadata from the agent definition for exposing to clients.
158
158
  * This provides basic info about available tools without loading them fully.
159
- * For tool groups (like town_e2b, filesystem), dynamically extracts children
159
+ * For tool groups (like code_sandbox, filesystem), dynamically extracts children
160
160
  * tools info from the actual tool factories.
161
161
  */
162
162
  getToolsMetadata() {
@@ -268,9 +268,14 @@ export class AgentAcpAdapter {
268
268
  "url" in result &&
269
269
  typeof result.url === "string") {
270
270
  // Use the citationId from the tool output if available
271
- const citationId = typeof result.citationId === "number"
272
- ? String(result.citationId)
273
- : (session.sourceCounter++, String(session.sourceCounter));
271
+ let citationId;
272
+ if (typeof result.citationId === "number") {
273
+ citationId = String(result.citationId);
274
+ }
275
+ else {
276
+ session.sourceCounter++;
277
+ citationId = String(session.sourceCounter);
278
+ }
274
279
  const url = result.url;
275
280
  const title = typeof result.title === "string" ? result.title : "Untitled";
276
281
  const snippet = typeof result.text === "string"
@@ -409,7 +414,14 @@ export class AgentAcpAdapter {
409
414
  if (!docUrl && !docTitle)
410
415
  return null;
411
416
  // Use document_id as the citation ID if available, otherwise use counter
412
- const citationId = docId || (session.sourceCounter++, String(session.sourceCounter));
417
+ let citationId;
418
+ if (docId) {
419
+ citationId = docId;
420
+ }
421
+ else {
422
+ session.sourceCounter++;
423
+ citationId = String(session.sourceCounter);
424
+ }
413
425
  // Extract snippet from summary or content
414
426
  let snippet;
415
427
  if (typeof doc.summary === "string") {
@@ -1496,8 +1508,10 @@ export class AgentAcpAdapter {
1496
1508
  const toolName = toolCallBlock.title || "unknown";
1497
1509
  const originalContentPath = this.storage.saveToolOriginal(params.sessionId, toolName, outputMsg.toolCallId, compactionMeta.originalContent);
1498
1510
  // _meta is guaranteed to be initialized since actuallyCompacted is true
1499
- toolCallBlock._meta.originalContentPath =
1500
- originalContentPath;
1511
+ if (toolCallBlock._meta) {
1512
+ toolCallBlock._meta.originalContentPath =
1513
+ originalContentPath;
1514
+ }
1501
1515
  logger.info("Saved original content to artifacts", {
1502
1516
  toolCallId: outputMsg.toolCallId,
1503
1517
  toolName,
@@ -9,7 +9,7 @@ export declare const zAgentRunnerParams: z.ZodObject<{
9
9
  suggestedPrompts: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
10
  systemPrompt: z.ZodNullable<z.ZodString>;
11
11
  model: z.ZodString;
12
- tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">, z.ZodLiteral<"town_e2b">]>, z.ZodObject<{
12
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">, z.ZodLiteral<"code_sandbox">]>, z.ZodObject<{
13
13
  type: z.ZodLiteral<"custom">;
14
14
  modulePath: z.ZodString;
15
15
  }, z.core.$strip>, z.ZodObject<{
@@ -47,7 +47,7 @@ export const TOOL_REGISTRY = {
47
47
  town_generate_image: () => makeTownGenerateImageTool(),
48
48
  browser: () => makeBrowserTools(),
49
49
  document_extract: () => makeDocumentExtractTool(),
50
- town_e2b: () => makeTownE2BTools(),
50
+ code_sandbox: () => makeTownE2BTools(),
51
51
  };
52
52
  // ============================================================================
53
53
  // Custom tool loading
@@ -24,7 +24,7 @@ async function getTownE2BApiKey() {
24
24
  _apiKeyFetchPromise = (async () => {
25
25
  const shedAuth = getShedAuth();
26
26
  if (!shedAuth) {
27
- throw new Error("Not logged in. Run 'town login' or set SHED_API_KEY to use the town_e2b tools.");
27
+ throw new Error("Not logged in. Run 'town login' or set SHED_API_KEY to use the code_sandbox tools.");
28
28
  }
29
29
  const response = await fetch(`${shedAuth.shedUrl}/api/e2b/api-key`, {
30
30
  method: "POST",
@@ -123,7 +123,7 @@ function makeE2BToolsInternal(getSandbox) {
123
123
  return `Error executing code: ${error instanceof Error ? error.message : String(error)}`;
124
124
  }
125
125
  }, {
126
- name: "E2B_RunCode",
126
+ name: "Sandbox_RunCode",
127
127
  description: "Execute Python or JavaScript code in a secure cloud sandbox. " +
128
128
  "The sandbox persists across calls in the same session, preserving variables and state. " +
129
129
  "Supports data analysis, file processing, and visualization. " +
@@ -171,7 +171,7 @@ function makeE2BToolsInternal(getSandbox) {
171
171
  return `Error executing command: ${error instanceof Error ? error.message : String(error)}`;
172
172
  }
173
173
  }, {
174
- name: "E2B_RunBash",
174
+ name: "Sandbox_RunBash",
175
175
  description: "Execute a bash command in the cloud sandbox. " +
176
176
  "Use for system operations, package installation, file manipulation, etc. " +
177
177
  "The sandbox filesystem persists across calls in the same session.",
@@ -201,7 +201,7 @@ function makeE2BToolsInternal(getSandbox) {
201
201
  return `Error reading file: ${error instanceof Error ? error.message : String(error)}`;
202
202
  }
203
203
  }, {
204
- name: "E2B_ReadFile",
204
+ name: "Sandbox_ReadFile",
205
205
  description: "Read a file from the cloud sandbox filesystem. " +
206
206
  "Use to retrieve files created by code execution or bash commands.",
207
207
  schema: z.object({
@@ -224,7 +224,7 @@ function makeE2BToolsInternal(getSandbox) {
224
224
  return `Error writing file: ${error instanceof Error ? error.message : String(error)}`;
225
225
  }
226
226
  }, {
227
- name: "E2B_WriteFile",
227
+ name: "Sandbox_WriteFile",
228
228
  description: "Write content to a file in the cloud sandbox filesystem. " +
229
229
  "Use to create data files for code execution or save outputs.",
230
230
  schema: z.object({
@@ -239,7 +239,7 @@ function makeE2BToolsInternal(getSandbox) {
239
239
  // Tool 5: Download File from Sandbox to Artifacts
240
240
  const downloadFromSandbox = tool(async ({ sandboxPath, fileName }) => {
241
241
  if (!hasSessionContext()) {
242
- throw new Error("E2B_DownloadFile requires session context");
242
+ throw new Error("Sandbox_DownloadFile requires session context");
243
243
  }
244
244
  const sandbox = await getSandbox();
245
245
  const toolOutputDir = getToolOutputDir("E2B");
@@ -269,7 +269,7 @@ function makeE2BToolsInternal(getSandbox) {
269
269
  return `Error downloading file: ${error instanceof Error ? error.message : String(error)}`;
270
270
  }
271
271
  }, {
272
- name: "E2B_DownloadFile",
272
+ name: "Sandbox_DownloadFile",
273
273
  description: "Download a file from the cloud sandbox to the session's artifacts directory. " +
274
274
  "Use to save generated files, plots, or outputs for the user to access.",
275
275
  schema: z.object({
@@ -319,7 +319,7 @@ function makeE2BToolsInternal(getSandbox) {
319
319
  return `Error uploading document: ${error instanceof Error ? error.message : String(error)}`;
320
320
  }
321
321
  }, {
322
- name: "E2B_UploadLibraryDocument",
322
+ name: "Sandbox_UploadLibraryDocument",
323
323
  description: "Upload a document from the library to the cloud sandbox. " +
324
324
  "Use this to make library documents available for processing in the sandbox environment.",
325
325
  schema: z.object({
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  /** Built-in tool types. */
3
- export declare const zBuiltInToolType: z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">, z.ZodLiteral<"town_e2b">]>;
3
+ export declare const zBuiltInToolType: z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">, z.ZodLiteral<"code_sandbox">]>;
4
4
  /** Subagent configuration schema for Task tools. */
5
5
  export declare const zSubagentConfig: z.ZodObject<{
6
6
  agentName: z.ZodString;
@@ -23,7 +23,7 @@ declare const zDirectTool: z.ZodObject<{
23
23
  }, z.core.$strip>>>;
24
24
  }, z.core.$strip>;
25
25
  /** Tool type - can be a built-in tool string or custom tool object. */
26
- export declare const zToolType: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">, z.ZodLiteral<"town_e2b">]>, z.ZodObject<{
26
+ export declare const zToolType: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">, z.ZodLiteral<"code_sandbox">]>, z.ZodObject<{
27
27
  type: z.ZodLiteral<"custom">;
28
28
  modulePath: z.ZodString;
29
29
  }, z.core.$strip>, z.ZodObject<{
@@ -11,7 +11,7 @@ export const zBuiltInToolType = z.union([
11
11
  z.literal("town_generate_image"),
12
12
  z.literal("browser"),
13
13
  z.literal("document_extract"),
14
- z.literal("town_e2b"),
14
+ z.literal("code_sandbox"),
15
15
  ]);
16
16
  /** Custom tool schema (loaded from module path). */
17
17
  const zCustomTool = z.object({