deepagentsdk 0.14.0 → 0.15.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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import { St as init_limits, _t as DEFAULT_EVICTION_TOKEN_LIMIT, bt as DEFAULT_SUMMARIZATION_THRESHOLD, gt as CONTEXT_WINDOW, l as estimateMessagesTokens, n as parseModelString, o as createDeepAgent, r as LocalSandbox, t as FileSaver, vt as DEFAULT_KEEP_MESSAGES } from "../file-saver-Hj5so3dV.mjs";
2
+ import { St as init_limits, _t as DEFAULT_EVICTION_TOKEN_LIMIT, bt as DEFAULT_SUMMARIZATION_THRESHOLD, gt as CONTEXT_WINDOW, l as estimateMessagesTokens, n as parseModelString, o as createDeepAgent, r as LocalSandbox, t as FileSaver, vt as DEFAULT_KEEP_MESSAGES } from "../file-saver-CQWTIr8z.mjs";
3
3
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { Box, Text, render, useApp, useInput } from "ink";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  import { Output, ToolLoopAgent, generateText, stepCountIs, streamText, tool, wrapLanguageModel } from "ai";
2
3
  import { z } from "zod";
3
4
  import micromatch from "micromatch";
@@ -18,6 +19,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
18
19
  var __getOwnPropNames = Object.getOwnPropertyNames;
19
20
  var __hasOwnProp = Object.prototype.hasOwnProperty;
20
21
  var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
22
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
21
23
  var __exportAll = (all, symbols) => {
22
24
  let target = {};
23
25
  for (var name in all) {
@@ -46,6 +48,7 @@ var __copyProps = (to, from, except, desc) => {
46
48
  return to;
47
49
  };
48
50
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
51
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
49
52
 
50
53
  //#endregion
51
54
  //#region src/constants/limits.ts
@@ -233,7 +236,7 @@ var init_events = __esmMin((() => {}));
233
236
  * Type guard to check if a backend is a SandboxBackendProtocol.
234
237
  */
235
238
  function isSandboxBackend(backend) {
236
- return typeof backend.execute === "function" && typeof backend.id === "string";
239
+ return typeof backend.execute === "function" && typeof backend.uploadFiles === "function" && typeof backend.downloadFiles === "function" && typeof backend.id === "string";
237
240
  }
238
241
 
239
242
  //#endregion
@@ -2321,7 +2324,7 @@ var DeepAgent = class {
2321
2324
  * Supports both legacy skillsDir and new agentId modes.
2322
2325
  */
2323
2326
  async loadSkills(options) {
2324
- const { listSkills } = await import("./load-BDxe6Cet.mjs");
2327
+ const { listSkills } = await import("./load-DRzSpESX.mjs");
2325
2328
  this.skillsMetadata = (await listSkills(options.agentId ? { agentId: options.agentId } : { projectSkillsDir: options.skillsDir })).map((s) => ({
2326
2329
  name: s.name,
2327
2330
  description: s.description,
@@ -2920,6 +2923,18 @@ function createDeepAgent(params) {
2920
2923
  init_errors();
2921
2924
  init_limits();
2922
2925
  /**
2926
+ * Map error messages to FileOperationError literals.
2927
+ *
2928
+ * This provides structured error handling that LLMs can understand and potentially fix.
2929
+ */
2930
+ function mapErrorToOperationError(errorMessage, path) {
2931
+ const lowerError = errorMessage.toLowerCase();
2932
+ if (lowerError.includes("no such file") || lowerError.includes("not found") || lowerError.includes("cannot find")) return "file_not_found";
2933
+ if (lowerError.includes("permission denied") || lowerError.includes("access denied") || lowerError.includes("read-only")) return "permission_denied";
2934
+ if (lowerError.includes("is a directory") || lowerError.includes("directory not empty")) return "is_directory";
2935
+ return "invalid_path";
2936
+ }
2937
+ /**
2923
2938
  * Encode string to base64 for safe shell transmission.
2924
2939
  */
2925
2940
  function toBase64(str) {
@@ -2958,6 +2973,74 @@ function buildNodeScript(script, args) {
2958
2973
  * ```
2959
2974
  */
2960
2975
  var BaseSandbox = class {
2976
+ /**
2977
+ * Upload multiple files to the sandbox.
2978
+ *
2979
+ * Default implementation uses base64 encoding via shell commands.
2980
+ * Subclasses can override if they have a native file upload API.
2981
+ *
2982
+ * This API is designed to allow partial success - individual uploads may fail
2983
+ * without affecting others. Check the error field in each response.
2984
+ */
2985
+ async uploadFiles(files) {
2986
+ const responses = [];
2987
+ for (const [path, content] of files) try {
2988
+ const base64Content = Buffer.from(content).toString("base64");
2989
+ const escapedPath = path.replace(/'/g, "'\\''");
2990
+ const result = await this.execute(`echo '${base64Content}' | base64 -d > '${escapedPath}'`);
2991
+ if (result.exitCode !== 0) responses.push({
2992
+ path,
2993
+ error: mapErrorToOperationError(result.output, path)
2994
+ });
2995
+ else responses.push({
2996
+ path,
2997
+ error: null
2998
+ });
2999
+ } catch (error) {
3000
+ responses.push({
3001
+ path,
3002
+ error: "permission_denied"
3003
+ });
3004
+ }
3005
+ return responses;
3006
+ }
3007
+ /**
3008
+ * Download multiple files from the sandbox.
3009
+ *
3010
+ * Default implementation uses base64 encoding via shell commands.
3011
+ * Subclasses can override if they have a native file download API.
3012
+ *
3013
+ * This API is designed to allow partial success - individual downloads may fail
3014
+ * without affecting others. Check the error field in each response.
3015
+ */
3016
+ async downloadFiles(paths) {
3017
+ const responses = [];
3018
+ for (const path of paths) try {
3019
+ const escapedPath = path.replace(/'/g, "'\\''");
3020
+ const result = await this.execute(`base64 '${escapedPath}'`);
3021
+ if (result.exitCode !== 0) responses.push({
3022
+ path,
3023
+ content: null,
3024
+ error: mapErrorToOperationError(result.output, path)
3025
+ });
3026
+ else {
3027
+ const base64Content = result.output.trim();
3028
+ const content = Buffer.from(base64Content, "base64");
3029
+ responses.push({
3030
+ path,
3031
+ content,
3032
+ error: null
3033
+ });
3034
+ }
3035
+ } catch (error) {
3036
+ responses.push({
3037
+ path,
3038
+ content: null,
3039
+ error: "permission_denied"
3040
+ });
3041
+ }
3042
+ return responses;
3043
+ }
2961
3044
  /**
2962
3045
  * List files and directories in a path.
2963
3046
  */
@@ -3564,5 +3647,5 @@ var FileSaver = class {
3564
3647
  };
3565
3648
 
3566
3649
  //#endregion
3567
- export { grepMatchesFromFiles as $, createGrepTool as A, DEFAULT_EVICTION_TOKEN_LIMIT as B, htmlToMarkdown as C, createEditFileTool as D, web_search as E, glob as F, shouldEvict as G, estimateTokens as H, grep as I, createFileData as J, StateBackend as K, ls as L, createReadFileTool as M, createWriteFileTool as N, createFilesystemTools as O, edit_file as P, globSearchFiles as Q, read_file as R, fetch_url as S, init_limits as St, init_web as T, evictToolResult as U, createToolResultWrapper as V, init_eviction as W, formatContentWithLineNumbers as X, fileDataToString as Y, formatReadResponse as Z, execute as _, DEFAULT_EVICTION_TOKEN_LIMIT$1 as _t, DeepAgent as a, createTodosTool as at, createWebSearchTool as b, DEFAULT_SUMMARIZATION_THRESHOLD$1 as bt, DEFAULT_SUMMARIZATION_THRESHOLD as c, DEFAULT_GENERAL_PURPOSE_DESCRIPTION as ct, summarizeIfNeeded as d, FILESYSTEM_SYSTEM_PROMPT as dt, performStringReplacement as et, hasDanglingToolCalls as f, TASK_SYSTEM_PROMPT as ft, createExecuteToolFromBackend as g, CONTEXT_WINDOW as gt, createExecuteTool as h, isSandboxBackend as ht, BaseSandbox as i, init_errors as it, createLsTool as j, createGlobTool as k, estimateMessagesTokens as l, DEFAULT_SUBAGENT_PROMPT as lt, createSubagentTool as m, getTaskToolDescription as mt, parseModelString as n, FILE_ALREADY_EXISTS as nt, createDeepAgent as o, write_todos as ot, patchToolCalls as p, TODO_SYSTEM_PROMPT as pt, checkEmptyContent as q, LocalSandbox as r, FILE_NOT_FOUND as rt, DEFAULT_KEEP_MESSAGES as s, BASE_PROMPT as st, FileSaver as t, updateFileData as tt, needsSummarization as u, EXECUTE_SYSTEM_PROMPT as ut, createFetchUrlTool as v, DEFAULT_KEEP_MESSAGES$1 as vt, http_request as w, createWebTools as x, MAX_FILE_SIZE_MB as xt, createHttpRequestTool as y, DEFAULT_READ_LIMIT as yt, write_file as z };
3568
- //# sourceMappingURL=file-saver-Hj5so3dV.mjs.map
3650
+ export { grepMatchesFromFiles as $, createGrepTool as A, DEFAULT_EVICTION_TOKEN_LIMIT as B, htmlToMarkdown as C, __commonJSMin as Ct, createEditFileTool as D, __toCommonJS as Dt, web_search as E, __require as Et, glob as F, shouldEvict as G, estimateTokens as H, grep as I, createFileData as J, StateBackend as K, ls as L, createReadFileTool as M, createWriteFileTool as N, createFilesystemTools as O, edit_file as P, globSearchFiles as Q, read_file as R, fetch_url as S, init_limits as St, init_web as T, __exportAll as Tt, evictToolResult as U, createToolResultWrapper as V, init_eviction as W, formatContentWithLineNumbers as X, fileDataToString as Y, formatReadResponse as Z, execute as _, DEFAULT_EVICTION_TOKEN_LIMIT$1 as _t, DeepAgent as a, createTodosTool as at, createWebSearchTool as b, DEFAULT_SUMMARIZATION_THRESHOLD$1 as bt, DEFAULT_SUMMARIZATION_THRESHOLD as c, DEFAULT_GENERAL_PURPOSE_DESCRIPTION as ct, summarizeIfNeeded as d, FILESYSTEM_SYSTEM_PROMPT as dt, performStringReplacement as et, hasDanglingToolCalls as f, TASK_SYSTEM_PROMPT as ft, createExecuteToolFromBackend as g, CONTEXT_WINDOW as gt, createExecuteTool as h, isSandboxBackend as ht, BaseSandbox as i, init_errors as it, createLsTool as j, createGlobTool as k, estimateMessagesTokens as l, DEFAULT_SUBAGENT_PROMPT as lt, createSubagentTool as m, getTaskToolDescription as mt, parseModelString as n, FILE_ALREADY_EXISTS as nt, createDeepAgent as o, write_todos as ot, patchToolCalls as p, TODO_SYSTEM_PROMPT as pt, checkEmptyContent as q, LocalSandbox as r, FILE_NOT_FOUND as rt, DEFAULT_KEEP_MESSAGES as s, BASE_PROMPT as st, FileSaver as t, updateFileData as tt, needsSummarization as u, EXECUTE_SYSTEM_PROMPT as ut, createFetchUrlTool as v, DEFAULT_KEEP_MESSAGES$1 as vt, http_request as w, __esmMin as wt, createWebTools as x, MAX_FILE_SIZE_MB as xt, createHttpRequestTool as y, DEFAULT_READ_LIMIT as yt, write_file as z };
3651
+ //# sourceMappingURL=file-saver-CQWTIr8z.mjs.map