@agentstep/agent-sdk 0.4.34 → 0.4.36
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/{chunk-CTR6EUXT.js → chunk-2PNZELEJ.js} +1 -1
- package/dist/{chunk-PQFQAUDE.js → chunk-2RQCMWUR.js} +1 -1
- package/dist/{chunk-BYDG6ESH.js → chunk-4ODMO275.js} +1 -1
- package/dist/{chunk-N6JXE6F7.js → chunk-6LLDT3F3.js} +2 -2
- package/dist/{chunk-BG75HBSJ.js → chunk-7QLYJIKK.js} +1 -1
- package/dist/{chunk-ZIGTEOKH.js → chunk-CD7SK6XL.js} +1 -1
- package/dist/{chunk-33T7CXNO.js → chunk-CZZP4UTX.js} +1 -1
- package/dist/{chunk-UKK256CD.js → chunk-D4ONR4AQ.js} +1 -1
- package/dist/{chunk-FLZY57OW.js → chunk-H6HEGKCW.js} +1 -1
- package/dist/{chunk-IQFCD5LB.js → chunk-HZNJ5U2B.js} +2 -2
- package/dist/{chunk-UKN2FATI.js → chunk-I5X7ERAU.js} +1 -1
- package/dist/{chunk-2HHJMH7Y.js → chunk-JID2FSDR.js} +1 -1
- package/dist/{chunk-S4USSG25.js → chunk-LVDYHS7N.js} +1 -1
- package/dist/{chunk-ZRTU5LSJ.js → chunk-M24MZZDW.js} +1 -1
- package/dist/{chunk-DHSEH44K.js → chunk-MKATGKGM.js} +1 -1
- package/dist/{chunk-KUJYDAWD.js → chunk-NDIBNZ5J.js} +1 -1
- package/dist/{chunk-FVVK6ZOP.js → chunk-O3IPK2YQ.js} +1 -1
- package/dist/{chunk-LE3XJK5J.js → chunk-P6RXTR4X.js} +1 -1
- package/dist/{chunk-KOLBALYY.js → chunk-PCJTXF5I.js} +1 -1
- package/dist/{chunk-R7DSCB4M.js → chunk-PIZGJG3H.js} +1 -1
- package/dist/{chunk-5CCJVWDQ.js → chunk-QB23B7L5.js} +12 -0
- package/dist/{chunk-GYX4GTAJ.js → chunk-R2RI5S3Q.js} +1 -1
- package/dist/{chunk-RRYSUT4G.js → chunk-RONZU5AQ.js} +1 -1
- package/dist/{chunk-53XO5VOW.js → chunk-TGTPTLBM.js} +1 -1
- package/dist/{chunk-OPYXKFR3.js → chunk-W5QHJGLU.js} +1 -1
- package/dist/{chunk-KE6ILZ5Z.js → chunk-WOWJPX7E.js} +1 -1
- package/dist/{chunk-OZ4GCKDV.js → chunk-XNDCK2A7.js} +1 -1
- package/dist/{chunk-YVNA2TSG.js → chunk-Y35PFFL2.js} +1 -1
- package/dist/handlers/agents.js +4 -4
- package/dist/handlers/api_keys.js +4 -4
- package/dist/handlers/audit.js +4 -4
- package/dist/handlers/batch.js +4 -4
- package/dist/handlers/credentials.js +5 -5
- package/dist/handlers/environments.js +4 -4
- package/dist/handlers/events.js +4 -4
- package/dist/handlers/files.js +4 -4
- package/dist/handlers/index.js +28 -28
- package/dist/handlers/license.js +4 -4
- package/dist/handlers/memory.js +4 -4
- package/dist/handlers/metrics.js +4 -4
- package/dist/handlers/models.js +4 -4
- package/dist/handlers/providers.js +4 -4
- package/dist/handlers/resources.js +4 -4
- package/dist/handlers/sessions.js +4 -4
- package/dist/handlers/settings.js +4 -4
- package/dist/handlers/skills-write.js +4 -4
- package/dist/handlers/skills.js +4 -4
- package/dist/handlers/stream.js +3 -3
- package/dist/handlers/tenants.js +4 -4
- package/dist/handlers/threads.js +4 -4
- package/dist/handlers/traces.js +4 -4
- package/dist/handlers/upstream_keys.js +4 -4
- package/dist/handlers/vaults.js +4 -4
- package/dist/handlers/whoami.js +4 -4
- package/dist/http.js +3 -3
- package/dist/index.js +3 -3
- package/dist/init.js +2 -2
- package/dist/sessions/driver.js +1 -1
- package/dist/sessions/threads.js +1 -1
- package/dist/sync/container-file-sync.js +51 -27
- package/package.json +1 -1
|
@@ -30,18 +30,8 @@ var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
30
30
|
".dylib",
|
|
31
31
|
".bin",
|
|
32
32
|
".wasm",
|
|
33
|
-
".png",
|
|
34
|
-
".jpg",
|
|
35
|
-
".jpeg",
|
|
36
|
-
".gif",
|
|
37
|
-
".ico",
|
|
38
|
-
".svg",
|
|
39
33
|
".mp3",
|
|
40
|
-
".mp4"
|
|
41
|
-
".zip",
|
|
42
|
-
".tar",
|
|
43
|
-
".gz",
|
|
44
|
-
".pdf"
|
|
34
|
+
".mp4"
|
|
45
35
|
]);
|
|
46
36
|
var BLOCKED_PREFIXES = [
|
|
47
37
|
"/proc/",
|
|
@@ -63,6 +53,7 @@ function extractFilePaths(sessionId) {
|
|
|
63
53
|
const seen = /* @__PURE__ */ new Set();
|
|
64
54
|
const paths = [];
|
|
65
55
|
let sawFileTools = false;
|
|
56
|
+
let sawBash = false;
|
|
66
57
|
for (const evt of events) {
|
|
67
58
|
if (evt.type !== "agent.tool_use") continue;
|
|
68
59
|
let payload;
|
|
@@ -77,6 +68,8 @@ function extractFilePaths(sessionId) {
|
|
|
77
68
|
if (FILE_TOOLS.has(toolName ?? "") && payload.input) {
|
|
78
69
|
sawFileTools = true;
|
|
79
70
|
filePath = payload.input.file_path ?? payload.input.filePath ?? payload.input.path;
|
|
71
|
+
} else if (toolName === "Bash" || toolName === "bash") {
|
|
72
|
+
sawBash = true;
|
|
80
73
|
} else if (toolName === "apply_patch" && payload.input) {
|
|
81
74
|
sawFileTools = true;
|
|
82
75
|
const patch = payload.input.patchText;
|
|
@@ -89,7 +82,7 @@ function extractFilePaths(sessionId) {
|
|
|
89
82
|
seen.add(resolved);
|
|
90
83
|
paths.push(resolved);
|
|
91
84
|
}
|
|
92
|
-
return { paths, sawFileTools };
|
|
85
|
+
return { paths, sawFileTools, sawBash };
|
|
93
86
|
}
|
|
94
87
|
function isPathSafe(p) {
|
|
95
88
|
if (!p.startsWith("/")) return false;
|
|
@@ -105,7 +98,7 @@ async function discoverChangedFiles(sandboxName, provider, secrets) {
|
|
|
105
98
|
const result = await provider.exec(
|
|
106
99
|
sandboxName,
|
|
107
100
|
["sh", "-c", [
|
|
108
|
-
"find /home /root /workspace /mnt",
|
|
101
|
+
"find /home /root /workspace /mnt /tmp",
|
|
109
102
|
"-maxdepth 4 -type f -mmin -30 -size +0c",
|
|
110
103
|
"! -path '*/.git/*' ! -path '*/node_modules/*' ! -path '*/.npm/*'",
|
|
111
104
|
"! -path '*/.config/*' ! -path '*/.local/*' ! -path '*/.cache/*'",
|
|
@@ -126,8 +119,11 @@ async function syncContainerFiles(opts) {
|
|
|
126
119
|
const { sessionId, sandboxName, provider, secrets } = opts;
|
|
127
120
|
const extracted = extractFilePaths(sessionId);
|
|
128
121
|
let allPaths = extracted.paths;
|
|
129
|
-
if (
|
|
130
|
-
|
|
122
|
+
if (extracted.sawFileTools || extracted.sawBash) {
|
|
123
|
+
const discovered = await discoverChangedFiles(sandboxName, provider, secrets);
|
|
124
|
+
for (const p of discovered) {
|
|
125
|
+
if (!allPaths.includes(p)) allPaths.push(p);
|
|
126
|
+
}
|
|
131
127
|
}
|
|
132
128
|
if (allPaths.length === 0) return { synced: 0, skipped: 0 };
|
|
133
129
|
const validPaths = [];
|
|
@@ -152,24 +148,42 @@ async function syncContainerFiles(opts) {
|
|
|
152
148
|
validPaths.length = MAX_FILES_PER_SYNC;
|
|
153
149
|
}
|
|
154
150
|
let synced = 0;
|
|
151
|
+
const BINARY_READ_EXTS = /* @__PURE__ */ new Set([
|
|
152
|
+
".docx",
|
|
153
|
+
".xlsx",
|
|
154
|
+
".pptx",
|
|
155
|
+
".pdf",
|
|
156
|
+
".zip",
|
|
157
|
+
".tar",
|
|
158
|
+
".gz",
|
|
159
|
+
".png",
|
|
160
|
+
".jpg",
|
|
161
|
+
".jpeg",
|
|
162
|
+
".gif",
|
|
163
|
+
".ico",
|
|
164
|
+
".webp",
|
|
165
|
+
".woff",
|
|
166
|
+
".woff2",
|
|
167
|
+
".ttf",
|
|
168
|
+
".otf",
|
|
169
|
+
".eot"
|
|
170
|
+
]);
|
|
155
171
|
for (const filePath of validPaths) {
|
|
156
172
|
try {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
{ secrets, timeoutMs: 15e3 }
|
|
161
|
-
);
|
|
173
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
174
|
+
const isBinary = BINARY_READ_EXTS.has(ext);
|
|
175
|
+
const result = isBinary ? await provider.exec(sandboxName, ["base64", "-w", "0", "--", filePath], { secrets, timeoutMs: 15e3 }) : await provider.exec(sandboxName, ["cat", "--", filePath], { secrets, timeoutMs: 15e3 });
|
|
162
176
|
if (result.exit_code !== 0 || !result.stdout) {
|
|
163
177
|
skipped++;
|
|
164
178
|
continue;
|
|
165
179
|
}
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
180
|
+
const raw = result.stdout.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
|
|
181
|
+
const data = isBinary ? Buffer.from(raw.trim(), "base64") : Buffer.from(raw, "utf8");
|
|
182
|
+
if (data.length > MAX_FILE_SIZE) {
|
|
169
183
|
skipped++;
|
|
170
184
|
continue;
|
|
171
185
|
}
|
|
172
|
-
const hash = createHash("sha256").update(
|
|
186
|
+
const hash = createHash("sha256").update(data).digest("hex");
|
|
173
187
|
const existing = findFileByContainerPath(sessionId, filePath, hash);
|
|
174
188
|
if (existing) {
|
|
175
189
|
skipped++;
|
|
@@ -177,10 +191,9 @@ async function syncContainerFiles(opts) {
|
|
|
177
191
|
}
|
|
178
192
|
const fileId = newId("file");
|
|
179
193
|
const filename = path.basename(filePath);
|
|
180
|
-
const data = Buffer.from(content, "utf8");
|
|
181
194
|
const storagePath = storeFile(fileId, filename, data);
|
|
182
|
-
const
|
|
183
|
-
const contentType = MIME_MAP[
|
|
195
|
+
const fileExt = path.extname(filename).toLowerCase();
|
|
196
|
+
const contentType = MIME_MAP[fileExt] ?? "text/plain";
|
|
184
197
|
createFile({
|
|
185
198
|
filename,
|
|
186
199
|
size: data.length,
|
|
@@ -219,6 +232,17 @@ var MIME_MAP = {
|
|
|
219
232
|
".xml": "text/xml",
|
|
220
233
|
".sql": "text/x-sql",
|
|
221
234
|
".txt": "text/plain",
|
|
235
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
236
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
237
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
238
|
+
".pdf": "application/pdf",
|
|
239
|
+
".zip": "application/zip",
|
|
240
|
+
".png": "image/png",
|
|
241
|
+
".jpg": "image/jpeg",
|
|
242
|
+
".jpeg": "image/jpeg",
|
|
243
|
+
".gif": "image/gif",
|
|
244
|
+
".svg": "image/svg+xml",
|
|
245
|
+
".csv": "text/csv",
|
|
222
246
|
".c": "text/x-c",
|
|
223
247
|
".cpp": "text/x-c++",
|
|
224
248
|
".h": "text/x-c",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"license": "Apache-2.0",
|
|
3
3
|
"name": "@agentstep/agent-sdk",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.36",
|
|
5
5
|
"description": "Core engine for AgentStep Gateway \u2014 backends, sandbox providers, session orchestration, and vault encryption.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"anthropic",
|