@agentstep/agent-sdk 0.5.4 → 0.5.6
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-DDHJHSIR.js → chunk-IN3EHQ4Z.js} +1 -1
- package/dist/{chunk-V5EEO7MU.js → chunk-IUJ6IDXX.js} +65 -13
- package/dist/{chunk-T7NQMCDT.js → chunk-JP4HHXHY.js} +50 -2
- package/dist/dreaming/review.js +1 -1
- package/dist/handlers/index.js +6 -2
- package/dist/handlers/memory.js +5 -1
- package/dist/handlers/skills-write.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -120,7 +120,7 @@ Analyze the sessions above and propose memory changes using the update_memories
|
|
|
120
120
|
"anthropic-version": "2023-06-01"
|
|
121
121
|
},
|
|
122
122
|
body: JSON.stringify({
|
|
123
|
-
model: "claude-sonnet-4-
|
|
123
|
+
model: opts.model || "claude-sonnet-4-6",
|
|
124
124
|
max_tokens: 4096,
|
|
125
125
|
system: DREAMING_SYSTEM_PROMPT,
|
|
126
126
|
tools: [UPDATE_MEMORIES_TOOL],
|
|
@@ -23,6 +23,32 @@ import {
|
|
|
23
23
|
|
|
24
24
|
// src/handlers/skills-write.ts
|
|
25
25
|
import { z } from "zod";
|
|
26
|
+
import { inflateRawSync } from "zlib";
|
|
27
|
+
function extractFromZip(buffer) {
|
|
28
|
+
const files = /* @__PURE__ */ new Map();
|
|
29
|
+
let offset = 0;
|
|
30
|
+
while (offset + 30 <= buffer.length) {
|
|
31
|
+
const sig = buffer.readUInt32LE(offset);
|
|
32
|
+
if (sig !== 67324752) break;
|
|
33
|
+
const compMethod = buffer.readUInt16LE(offset + 8);
|
|
34
|
+
const compSize = buffer.readUInt32LE(offset + 18);
|
|
35
|
+
const uncompSize = buffer.readUInt32LE(offset + 22);
|
|
36
|
+
const nameLen = buffer.readUInt16LE(offset + 26);
|
|
37
|
+
const extraLen = buffer.readUInt16LE(offset + 28);
|
|
38
|
+
const name = buffer.toString("utf8", offset + 30, offset + 30 + nameLen);
|
|
39
|
+
const dataStart = offset + 30 + nameLen + extraLen;
|
|
40
|
+
if (compMethod === 0) {
|
|
41
|
+
const content = buffer.toString("utf8", dataStart, dataStart + uncompSize);
|
|
42
|
+
files.set(name, content);
|
|
43
|
+
} else if (compMethod === 8) {
|
|
44
|
+
const compressed = buffer.subarray(dataStart, dataStart + compSize);
|
|
45
|
+
const content = inflateRawSync(compressed).toString("utf8");
|
|
46
|
+
files.set(name, content);
|
|
47
|
+
}
|
|
48
|
+
offset = dataStart + compSize;
|
|
49
|
+
}
|
|
50
|
+
return files;
|
|
51
|
+
}
|
|
26
52
|
var CreateSkillSchema = z.object({
|
|
27
53
|
name: z.string().min(1).max(256),
|
|
28
54
|
description: z.string().max(2048).optional(),
|
|
@@ -36,20 +62,46 @@ var CreateVersionSchema = z.object({
|
|
|
36
62
|
});
|
|
37
63
|
function handleCreateSkill(request) {
|
|
38
64
|
return routeWrap(request, async ({ auth }) => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
const contentType = request.headers.get("content-type") ?? "";
|
|
66
|
+
let name;
|
|
67
|
+
let description;
|
|
68
|
+
let content;
|
|
69
|
+
let tenantId;
|
|
70
|
+
if (contentType.includes("multipart/form-data")) {
|
|
71
|
+
const formData = await request.formData();
|
|
72
|
+
name = (formData.get("display_title") ?? "").trim() || "untitled";
|
|
73
|
+
const file = formData.get("files[]") ?? formData.get("files") ?? formData.get("file");
|
|
74
|
+
if (!file || !(file instanceof File)) {
|
|
75
|
+
throw badRequest("Missing file in multipart upload");
|
|
76
|
+
}
|
|
77
|
+
const buffer = Buffer.from(await file.arrayBuffer());
|
|
78
|
+
if (file.name?.toLowerCase().endsWith(".zip")) {
|
|
79
|
+
const zipFiles = extractFromZip(buffer);
|
|
80
|
+
const skillEntry = [...zipFiles.entries()].find(
|
|
81
|
+
([k]) => k.endsWith("SKILL.md") || k.endsWith("skill.md")
|
|
82
|
+
);
|
|
83
|
+
if (!skillEntry) {
|
|
84
|
+
throw badRequest("No SKILL.md found in zip archive");
|
|
85
|
+
}
|
|
86
|
+
content = skillEntry[1];
|
|
87
|
+
} else {
|
|
88
|
+
content = buffer.toString("utf-8");
|
|
89
|
+
}
|
|
90
|
+
tenantId = resolveCreateTenant(auth, void 0);
|
|
91
|
+
} else {
|
|
92
|
+
const body = await request.json().catch(() => null);
|
|
93
|
+
const parsed = CreateSkillSchema.safeParse(body);
|
|
94
|
+
if (!parsed.success) {
|
|
95
|
+
throw badRequest(
|
|
96
|
+
`invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
name = parsed.data.name;
|
|
100
|
+
description = parsed.data.description;
|
|
101
|
+
content = parsed.data.content;
|
|
102
|
+
tenantId = resolveCreateTenant(auth, parsed.data.tenant_id);
|
|
45
103
|
}
|
|
46
|
-
const
|
|
47
|
-
const skill = createSkill({
|
|
48
|
-
name: parsed.data.name,
|
|
49
|
-
description: parsed.data.description,
|
|
50
|
-
content: parsed.data.content,
|
|
51
|
-
tenantId
|
|
52
|
-
});
|
|
104
|
+
const skill = createSkill({ name, description, content, tenantId });
|
|
53
105
|
return jsonOk(skill, 201);
|
|
54
106
|
});
|
|
55
107
|
}
|
|
@@ -2,6 +2,9 @@ import {
|
|
|
2
2
|
assertResourceTenant,
|
|
3
3
|
tenantFilter
|
|
4
4
|
} from "./chunk-23UKWXJH.js";
|
|
5
|
+
import {
|
|
6
|
+
reviewSessions
|
|
7
|
+
} from "./chunk-IN3EHQ4Z.js";
|
|
5
8
|
import {
|
|
6
9
|
archiveMemoryStore,
|
|
7
10
|
createMemoryStore,
|
|
@@ -23,6 +26,9 @@ import {
|
|
|
23
26
|
paginatedOk,
|
|
24
27
|
routeWrap
|
|
25
28
|
} from "./chunk-IYVGGJMH.js";
|
|
29
|
+
import {
|
|
30
|
+
getConfig
|
|
31
|
+
} from "./chunk-P2NWS65Y.js";
|
|
26
32
|
import {
|
|
27
33
|
getDb,
|
|
28
34
|
init_client
|
|
@@ -30,7 +36,8 @@ import {
|
|
|
30
36
|
import {
|
|
31
37
|
badRequest,
|
|
32
38
|
conflict,
|
|
33
|
-
notFound
|
|
39
|
+
notFound,
|
|
40
|
+
tooManyRequests
|
|
34
41
|
} from "./chunk-EZYKRG4W.js";
|
|
35
42
|
|
|
36
43
|
// src/handlers/memory.ts
|
|
@@ -220,6 +227,46 @@ function handleArchiveMemoryStore(request, storeId) {
|
|
|
220
227
|
return jsonOk(store);
|
|
221
228
|
});
|
|
222
229
|
}
|
|
230
|
+
var DreamRequestSchema = z.object({
|
|
231
|
+
lookback_hours: z.number().min(1).max(720).default(24),
|
|
232
|
+
dry_run: z.boolean().default(false),
|
|
233
|
+
model: z.string().optional(),
|
|
234
|
+
api_key: z.string().optional()
|
|
235
|
+
});
|
|
236
|
+
var dreamCooldowns = /* @__PURE__ */ new Map();
|
|
237
|
+
var DREAM_COOLDOWN_MS = 5 * 60 * 1e3;
|
|
238
|
+
function handleDreamMemoryStore(request, storeId) {
|
|
239
|
+
return routeWrap(request, async ({ auth }) => {
|
|
240
|
+
loadStoreForCaller(auth, storeId);
|
|
241
|
+
const body = await request.json();
|
|
242
|
+
const parsed = DreamRequestSchema.safeParse(body);
|
|
243
|
+
if (!parsed.success) throw badRequest(parsed.error.message);
|
|
244
|
+
const lastDreamed = dreamCooldowns.get(storeId);
|
|
245
|
+
if (lastDreamed !== void 0 && Date.now() - lastDreamed < DREAM_COOLDOWN_MS) {
|
|
246
|
+
const retryAfterSec = Math.ceil((DREAM_COOLDOWN_MS - (Date.now() - lastDreamed)) / 1e3);
|
|
247
|
+
throw tooManyRequests(`dream was triggered recently; retry after ${retryAfterSec}s`);
|
|
248
|
+
}
|
|
249
|
+
const apiKey = parsed.data.api_key || getConfig().anthropicApiKey;
|
|
250
|
+
if (!apiKey) {
|
|
251
|
+
throw badRequest("No Anthropic API key available. Provide api_key in the request body or set ANTHROPIC_API_KEY.");
|
|
252
|
+
}
|
|
253
|
+
const result = await reviewSessions({
|
|
254
|
+
storeId,
|
|
255
|
+
lookbackMs: parsed.data.lookback_hours * 36e5,
|
|
256
|
+
dryRun: parsed.data.dry_run,
|
|
257
|
+
apiKey,
|
|
258
|
+
model: parsed.data.model
|
|
259
|
+
});
|
|
260
|
+
dreamCooldowns.set(storeId, Date.now());
|
|
261
|
+
return jsonOk({
|
|
262
|
+
type: "dream_result",
|
|
263
|
+
memory_store_id: storeId,
|
|
264
|
+
session_count: result.sessionCount,
|
|
265
|
+
proposed_changes: result.proposedChanges,
|
|
266
|
+
applied: result.applied
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
}
|
|
223
270
|
|
|
224
271
|
export {
|
|
225
272
|
handleCreateMemoryStore,
|
|
@@ -235,5 +282,6 @@ export {
|
|
|
235
282
|
handleListMemoryVersions,
|
|
236
283
|
handleGetMemoryVersion,
|
|
237
284
|
handleRedactMemoryVersion,
|
|
238
|
-
handleArchiveMemoryStore
|
|
285
|
+
handleArchiveMemoryStore,
|
|
286
|
+
handleDreamMemoryStore
|
|
239
287
|
};
|
package/dist/dreaming/review.js
CHANGED
package/dist/handlers/index.js
CHANGED
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
handleGetSkill,
|
|
55
55
|
handleGetSkillVersion,
|
|
56
56
|
handleListSkillVersions
|
|
57
|
-
} from "../chunk-
|
|
57
|
+
} from "../chunk-IUJ6IDXX.js";
|
|
58
58
|
import {
|
|
59
59
|
handleGetSkillsCatalog,
|
|
60
60
|
handleGetSkillsFeed,
|
|
@@ -96,6 +96,7 @@ import {
|
|
|
96
96
|
handleCreateMemoryStore,
|
|
97
97
|
handleDeleteMemory,
|
|
98
98
|
handleDeleteMemoryStore,
|
|
99
|
+
handleDreamMemoryStore,
|
|
99
100
|
handleGetMemory,
|
|
100
101
|
handleGetMemoryStore,
|
|
101
102
|
handleGetMemoryVersion,
|
|
@@ -105,7 +106,7 @@ import {
|
|
|
105
106
|
handleRedactMemoryVersion,
|
|
106
107
|
handleUpdateMemory,
|
|
107
108
|
handleUpdateMemoryStore
|
|
108
|
-
} from "../chunk-
|
|
109
|
+
} from "../chunk-JP4HHXHY.js";
|
|
109
110
|
import {
|
|
110
111
|
handleGetApiMetrics,
|
|
111
112
|
handleGetMetrics
|
|
@@ -184,6 +185,8 @@ import "../chunk-DC2UMEQH.js";
|
|
|
184
185
|
import "../chunk-I2WVMCYN.js";
|
|
185
186
|
import "../chunk-CBPO2P4I.js";
|
|
186
187
|
import "../chunk-7346CKTF.js";
|
|
188
|
+
import "../chunk-IN3EHQ4Z.js";
|
|
189
|
+
import "../chunk-3LUY2POB.js";
|
|
187
190
|
import "../chunk-FSQ6I3C7.js";
|
|
188
191
|
import "../chunk-PVVJCRII.js";
|
|
189
192
|
import "../chunk-2N2KL4KM.js";
|
|
@@ -318,6 +321,7 @@ export {
|
|
|
318
321
|
handleDeleteSkillVersion,
|
|
319
322
|
handleDeleteUpstreamKey,
|
|
320
323
|
handleDeleteVault,
|
|
324
|
+
handleDreamMemoryStore,
|
|
321
325
|
handleExportTrace,
|
|
322
326
|
handleGetAgent,
|
|
323
327
|
handleGetApiKey,
|
package/dist/handlers/memory.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
handleCreateMemoryStore,
|
|
5
5
|
handleDeleteMemory,
|
|
6
6
|
handleDeleteMemoryStore,
|
|
7
|
+
handleDreamMemoryStore,
|
|
7
8
|
handleGetMemory,
|
|
8
9
|
handleGetMemoryStore,
|
|
9
10
|
handleGetMemoryVersion,
|
|
@@ -13,8 +14,10 @@ import {
|
|
|
13
14
|
handleRedactMemoryVersion,
|
|
14
15
|
handleUpdateMemory,
|
|
15
16
|
handleUpdateMemoryStore
|
|
16
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-JP4HHXHY.js";
|
|
17
18
|
import "../chunk-23UKWXJH.js";
|
|
19
|
+
import "../chunk-IN3EHQ4Z.js";
|
|
20
|
+
import "../chunk-3LUY2POB.js";
|
|
18
21
|
import "../chunk-FSQ6I3C7.js";
|
|
19
22
|
import "../chunk-IYVGGJMH.js";
|
|
20
23
|
import "../chunk-D2XITRN6.js";
|
|
@@ -115,6 +118,7 @@ export {
|
|
|
115
118
|
handleCreateMemoryStore,
|
|
116
119
|
handleDeleteMemory,
|
|
117
120
|
handleDeleteMemoryStore,
|
|
121
|
+
handleDreamMemoryStore,
|
|
118
122
|
handleGetMemory,
|
|
119
123
|
handleGetMemoryStore,
|
|
120
124
|
handleGetMemoryVersion,
|
package/dist/index.js
CHANGED
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.5.
|
|
4
|
+
"version": "0.5.6",
|
|
5
5
|
"description": "Core engine for AgentStep Gateway \u2014 backends, sandbox providers, session orchestration, and vault encryption.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"anthropic",
|