deepagents 1.5.0 → 1.5.1
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.
- package/dist/index.cjs +111 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -75
- package/dist/index.d.ts +73 -42
- package/dist/index.js +124 -27
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,6 @@ let zod_v4 = require("zod/v4");
|
|
|
31
31
|
let micromatch = require("micromatch");
|
|
32
32
|
micromatch = __toESM(micromatch);
|
|
33
33
|
let path = require("path");
|
|
34
|
-
let zod_v3 = require("zod/v3");
|
|
35
34
|
let _langchain_core_messages = require("@langchain/core/messages");
|
|
36
35
|
let zod = require("zod");
|
|
37
36
|
let yaml = require("yaml");
|
|
@@ -368,6 +367,17 @@ var StateBackend = class {
|
|
|
368
367
|
return formatReadResponse(fileData, offset, limit);
|
|
369
368
|
}
|
|
370
369
|
/**
|
|
370
|
+
* Read file content as raw FileData.
|
|
371
|
+
*
|
|
372
|
+
* @param filePath - Absolute file path
|
|
373
|
+
* @returns Raw file content as FileData
|
|
374
|
+
*/
|
|
375
|
+
readRaw(filePath) {
|
|
376
|
+
const fileData = this.getFiles()[filePath];
|
|
377
|
+
if (!fileData) throw new Error(`File '${filePath}' not found`);
|
|
378
|
+
return fileData;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
371
381
|
* Create a new file with content.
|
|
372
382
|
* Returns WriteResult with filesUpdate to update LangGraph state.
|
|
373
383
|
*/
|
|
@@ -1107,9 +1117,9 @@ function createTaskTool(options) {
|
|
|
1107
1117
|
}, {
|
|
1108
1118
|
name: "task",
|
|
1109
1119
|
description: taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions),
|
|
1110
|
-
schema:
|
|
1111
|
-
description:
|
|
1112
|
-
subagent_type:
|
|
1120
|
+
schema: zod_v4.z.object({
|
|
1121
|
+
description: zod_v4.z.string().describe("The task to execute with the selected agent"),
|
|
1122
|
+
subagent_type: zod_v4.z.string().describe(`Name of the agent to use. Available: ${Object.keys(subagentGraphs).join(", ")}`)
|
|
1113
1123
|
})
|
|
1114
1124
|
});
|
|
1115
1125
|
}
|
|
@@ -1324,6 +1334,11 @@ function formatMemoryContents(contents, sources) {
|
|
|
1324
1334
|
* @returns File content if found, null otherwise.
|
|
1325
1335
|
*/
|
|
1326
1336
|
async function loadMemoryFromBackend(backend, path$4) {
|
|
1337
|
+
if (!backend.downloadFiles) {
|
|
1338
|
+
const content = await backend.read(path$4);
|
|
1339
|
+
if (content.startsWith("Error:")) return null;
|
|
1340
|
+
return content;
|
|
1341
|
+
}
|
|
1327
1342
|
const results = await backend.downloadFiles([path$4]);
|
|
1328
1343
|
if (results.length !== 1) throw new Error(`Expected 1 response for path ${path$4}, got ${results.length}`);
|
|
1329
1344
|
const response = results[0];
|
|
@@ -1588,11 +1603,19 @@ async function listSkillsFromBackend(backend, sourcePath) {
|
|
|
1588
1603
|
for (const entry of entries) {
|
|
1589
1604
|
if (entry.type !== "directory") continue;
|
|
1590
1605
|
const skillMdPath = `${normalizedPath}${entry.name}/SKILL.md`;
|
|
1591
|
-
|
|
1592
|
-
if (
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1606
|
+
let content;
|
|
1607
|
+
if (backend.downloadFiles) {
|
|
1608
|
+
const results = await backend.downloadFiles([skillMdPath]);
|
|
1609
|
+
if (results.length !== 1) continue;
|
|
1610
|
+
const response = results[0];
|
|
1611
|
+
if (response.error != null || response.content == null) continue;
|
|
1612
|
+
content = new TextDecoder().decode(response.content);
|
|
1613
|
+
} else {
|
|
1614
|
+
const readResult = await backend.read(skillMdPath);
|
|
1615
|
+
if (readResult.startsWith("Error:")) continue;
|
|
1616
|
+
content = readResult;
|
|
1617
|
+
}
|
|
1618
|
+
const metadata = parseSkillMetadataFromContent(content, skillMdPath, entry.name);
|
|
1596
1619
|
if (metadata) skills.push(metadata);
|
|
1597
1620
|
}
|
|
1598
1621
|
return skills;
|
|
@@ -1831,16 +1854,25 @@ var StoreBackend = class {
|
|
|
1831
1854
|
*/
|
|
1832
1855
|
async read(filePath, offset = 0, limit = 500) {
|
|
1833
1856
|
try {
|
|
1834
|
-
|
|
1835
|
-
const namespace = this.getNamespace();
|
|
1836
|
-
const item = await store.get(namespace, filePath);
|
|
1837
|
-
if (!item) return `Error: File '${filePath}' not found`;
|
|
1838
|
-
return formatReadResponse(this.convertStoreItemToFileData(item), offset, limit);
|
|
1857
|
+
return formatReadResponse(await this.readRaw(filePath), offset, limit);
|
|
1839
1858
|
} catch (e) {
|
|
1840
1859
|
return `Error: ${e.message}`;
|
|
1841
1860
|
}
|
|
1842
1861
|
}
|
|
1843
1862
|
/**
|
|
1863
|
+
* Read file content as raw FileData.
|
|
1864
|
+
*
|
|
1865
|
+
* @param filePath - Absolute file path
|
|
1866
|
+
* @returns Raw file content as FileData
|
|
1867
|
+
*/
|
|
1868
|
+
async readRaw(filePath) {
|
|
1869
|
+
const store = this.getStore();
|
|
1870
|
+
const namespace = this.getNamespace();
|
|
1871
|
+
const item = await store.get(namespace, filePath);
|
|
1872
|
+
if (!item) throw new Error(`File '${filePath}' not found`);
|
|
1873
|
+
return this.convertStoreItemToFileData(item);
|
|
1874
|
+
}
|
|
1875
|
+
/**
|
|
1844
1876
|
* Create a new file with content.
|
|
1845
1877
|
* Returns WriteResult. External storage sets filesUpdate=null.
|
|
1846
1878
|
*/
|
|
@@ -2144,6 +2176,37 @@ var FilesystemBackend = class {
|
|
|
2144
2176
|
}
|
|
2145
2177
|
}
|
|
2146
2178
|
/**
|
|
2179
|
+
* Read file content as raw FileData.
|
|
2180
|
+
*
|
|
2181
|
+
* @param filePath - Absolute file path
|
|
2182
|
+
* @returns Raw file content as FileData
|
|
2183
|
+
*/
|
|
2184
|
+
async readRaw(filePath) {
|
|
2185
|
+
const resolvedPath = this.resolvePath(filePath);
|
|
2186
|
+
let content;
|
|
2187
|
+
let stat;
|
|
2188
|
+
if (SUPPORTS_NOFOLLOW) {
|
|
2189
|
+
stat = await node_fs_promises.default.stat(resolvedPath);
|
|
2190
|
+
if (!stat.isFile()) throw new Error(`File '${filePath}' not found`);
|
|
2191
|
+
const fd = await node_fs_promises.default.open(resolvedPath, node_fs.default.constants.O_RDONLY | node_fs.default.constants.O_NOFOLLOW);
|
|
2192
|
+
try {
|
|
2193
|
+
content = await fd.readFile({ encoding: "utf-8" });
|
|
2194
|
+
} finally {
|
|
2195
|
+
await fd.close();
|
|
2196
|
+
}
|
|
2197
|
+
} else {
|
|
2198
|
+
stat = await node_fs_promises.default.lstat(resolvedPath);
|
|
2199
|
+
if (stat.isSymbolicLink()) throw new Error(`Symlinks are not allowed: ${filePath}`);
|
|
2200
|
+
if (!stat.isFile()) throw new Error(`File '${filePath}' not found`);
|
|
2201
|
+
content = await node_fs_promises.default.readFile(resolvedPath, "utf-8");
|
|
2202
|
+
}
|
|
2203
|
+
return {
|
|
2204
|
+
content: content.split("\n"),
|
|
2205
|
+
created_at: stat.ctime.toISOString(),
|
|
2206
|
+
modified_at: stat.mtime.toISOString()
|
|
2207
|
+
};
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2147
2210
|
* Create a new file with content.
|
|
2148
2211
|
* Returns WriteResult. External storage sets filesUpdate=null.
|
|
2149
2212
|
*/
|
|
@@ -2551,6 +2614,16 @@ var CompositeBackend = class {
|
|
|
2551
2614
|
return await backend.read(strippedKey, offset, limit);
|
|
2552
2615
|
}
|
|
2553
2616
|
/**
|
|
2617
|
+
* Read file content as raw FileData.
|
|
2618
|
+
*
|
|
2619
|
+
* @param filePath - Absolute file path
|
|
2620
|
+
* @returns Raw file content as FileData
|
|
2621
|
+
*/
|
|
2622
|
+
async readRaw(filePath) {
|
|
2623
|
+
const [backend, strippedKey] = this.getBackendAndKey(filePath);
|
|
2624
|
+
return await backend.readRaw(strippedKey);
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2554
2627
|
* Structured search results or error string for invalid input.
|
|
2555
2628
|
*/
|
|
2556
2629
|
async grepRaw(pattern, path$4 = "/", glob = null) {
|
|
@@ -2657,6 +2730,7 @@ var CompositeBackend = class {
|
|
|
2657
2730
|
});
|
|
2658
2731
|
}
|
|
2659
2732
|
for (const [backend, batch] of batchesByBackend) {
|
|
2733
|
+
if (!backend.uploadFiles) throw new Error("Backend does not support uploadFiles");
|
|
2660
2734
|
const batchFiles = batch.map((b) => [b.path, b.content]);
|
|
2661
2735
|
const batchResponses = await backend.uploadFiles(batchFiles);
|
|
2662
2736
|
for (let i = 0; i < batch.length; i++) {
|
|
@@ -2688,6 +2762,7 @@ var CompositeBackend = class {
|
|
|
2688
2762
|
});
|
|
2689
2763
|
}
|
|
2690
2764
|
for (const [backend, batch] of batchesByBackend) {
|
|
2765
|
+
if (!backend.downloadFiles) throw new Error("Backend does not support downloadFiles");
|
|
2691
2766
|
const batchPaths = batch.map((b) => b.path);
|
|
2692
2767
|
const batchResponses = await backend.downloadFiles(batchPaths);
|
|
2693
2768
|
for (let i = 0; i < batch.length; i++) {
|
|
@@ -2994,6 +3069,28 @@ var BaseSandbox = class {
|
|
|
2994
3069
|
return result.output;
|
|
2995
3070
|
}
|
|
2996
3071
|
/**
|
|
3072
|
+
* Read file content as raw FileData.
|
|
3073
|
+
*
|
|
3074
|
+
* @param filePath - Absolute file path
|
|
3075
|
+
* @returns Raw file content as FileData
|
|
3076
|
+
*/
|
|
3077
|
+
async readRaw(filePath) {
|
|
3078
|
+
const command = buildReadCommand(filePath, 0, Number.MAX_SAFE_INTEGER);
|
|
3079
|
+
const result = await this.execute(command);
|
|
3080
|
+
if (result.exitCode !== 0) throw new Error(`File '${filePath}' not found`);
|
|
3081
|
+
const lines = [];
|
|
3082
|
+
for (const line of result.output.split("\n")) {
|
|
3083
|
+
const tabIndex = line.indexOf(" ");
|
|
3084
|
+
if (tabIndex !== -1) lines.push(line.substring(tabIndex + 1));
|
|
3085
|
+
}
|
|
3086
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3087
|
+
return {
|
|
3088
|
+
content: lines,
|
|
3089
|
+
created_at: now,
|
|
3090
|
+
modified_at: now
|
|
3091
|
+
};
|
|
3092
|
+
}
|
|
3093
|
+
/**
|
|
2997
3094
|
* Structured search results or error string for invalid input.
|
|
2998
3095
|
*/
|
|
2999
3096
|
async grepRaw(pattern, path$4 = "/", glob = null) {
|