@townco/agent 0.1.98 → 0.1.102

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.
@@ -45,4 +45,10 @@ export declare function makeTownE2BTools(): readonly [import("langchain").Dynami
45
45
  }, {
46
46
  sandboxPath: string;
47
47
  fileName?: string | undefined;
48
+ }, string>, import("langchain").DynamicStructuredTool<z.ZodObject<{
49
+ document_id: z.ZodString;
50
+ }, z.core.$strip>, {
51
+ document_id: string;
52
+ }, {
53
+ document_id: string;
48
54
  }, string>];
@@ -284,12 +284,67 @@ function makeE2BToolsInternal(getSandbox) {
284
284
  downloadFromSandbox.prettyName = "Download from Sandbox";
285
285
  // biome-ignore lint/suspicious/noExplicitAny: Need to add custom properties to LangChain tool
286
286
  downloadFromSandbox.icon = "Download";
287
+ // Tool 6: Upload Library Document to Sandbox
288
+ const uploadLibraryDocument = tool(async ({ document_id }) => {
289
+ const sandbox = await getSandbox();
290
+ try {
291
+ const libraryApiUrl = process.env.LIBRARY_API_URL;
292
+ const libraryApiKey = process.env.LIBRARY_ROOT_API_KEY;
293
+ if (!libraryApiUrl || !libraryApiKey) {
294
+ throw new Error("LIBRARY_API_URL and LIBRARY_ROOT_API_KEY environment variables are required");
295
+ }
296
+ const response = await fetch(`${libraryApiUrl}/sandbox/upload_document_to_sandbox`, {
297
+ method: "POST",
298
+ headers: {
299
+ "Content-Type": "application/json",
300
+ Authorization: `Bearer ${libraryApiKey}`,
301
+ },
302
+ body: JSON.stringify({
303
+ document_id,
304
+ sandbox_id: sandbox.sandboxId,
305
+ }),
306
+ });
307
+ if (!response.ok) {
308
+ const text = await response.text();
309
+ throw new Error(`Library API error: ${response.status} - ${text}`);
310
+ }
311
+ const result = await response.json();
312
+ return result.path;
313
+ }
314
+ catch (error) {
315
+ logger.error("Error uploading library document to sandbox", {
316
+ error,
317
+ document_id,
318
+ });
319
+ return `Error uploading document: ${error instanceof Error ? error.message : String(error)}`;
320
+ }
321
+ }, {
322
+ name: "E2B_UploadLibraryDocument",
323
+ description: "Upload a document from the library to the cloud sandbox. " +
324
+ "Use this to make library documents available for processing in the sandbox environment.",
325
+ schema: z.object({
326
+ document_id: z
327
+ .string()
328
+ .describe("The ID of the document to upload from the library"),
329
+ }),
330
+ });
331
+ // biome-ignore lint/suspicious/noExplicitAny: Need to add custom properties to LangChain tool
332
+ uploadLibraryDocument.prettyName = "Upload Library Document";
333
+ // biome-ignore lint/suspicious/noExplicitAny: Need to add custom properties to LangChain tool
334
+ uploadLibraryDocument.icon = "Upload";
335
+ // biome-ignore lint/suspicious/noExplicitAny: Need to add custom properties to LangChain tool
336
+ uploadLibraryDocument.verbiage = {
337
+ active: "Uploading document {document_id}",
338
+ past: "Uploaded document {document_id}",
339
+ paramKey: "document_id",
340
+ };
287
341
  return [
288
342
  runCode,
289
343
  runBash,
290
344
  readSandboxFile,
291
345
  writeSandboxFile,
292
346
  downloadFromSandbox,
347
+ uploadLibraryDocument,
293
348
  ];
294
349
  }
295
350
  /**