@agentstep/gateway 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/gateway.js +125 -27
- package/package.json +1 -1
package/dist/gateway.js
CHANGED
|
@@ -20052,7 +20052,7 @@ var init_chunk_K2UJFAGD = __esm({
|
|
|
20052
20052
|
}
|
|
20053
20053
|
});
|
|
20054
20054
|
|
|
20055
|
-
// ../agent-sdk/dist/chunk-
|
|
20055
|
+
// ../agent-sdk/dist/chunk-IN3EHQ4Z.js
|
|
20056
20056
|
function extractSessionSummary(sessionId, title, events2) {
|
|
20057
20057
|
const parts = [];
|
|
20058
20058
|
const errors = [];
|
|
@@ -20148,7 +20148,7 @@ Analyze the sessions above and propose memory changes using the update_memories
|
|
|
20148
20148
|
"anthropic-version": "2023-06-01"
|
|
20149
20149
|
},
|
|
20150
20150
|
body: JSON.stringify({
|
|
20151
|
-
model: "claude-sonnet-4-
|
|
20151
|
+
model: opts.model || "claude-sonnet-4-6",
|
|
20152
20152
|
max_tokens: 4096,
|
|
20153
20153
|
system: DREAMING_SYSTEM_PROMPT,
|
|
20154
20154
|
tools: [UPDATE_MEMORIES_TOOL],
|
|
@@ -20186,8 +20186,8 @@ Analyze the sessions above and propose memory changes using the update_memories
|
|
|
20186
20186
|
};
|
|
20187
20187
|
}
|
|
20188
20188
|
var MAX_SESSIONS, MAX_EVENTS_PER_SESSION, RELEVANT_EVENT_TYPES;
|
|
20189
|
-
var
|
|
20190
|
-
"../agent-sdk/dist/chunk-
|
|
20189
|
+
var init_chunk_IN3EHQ4Z = __esm({
|
|
20190
|
+
"../agent-sdk/dist/chunk-IN3EHQ4Z.js"() {
|
|
20191
20191
|
"use strict";
|
|
20192
20192
|
init_chunk_3LUY2POB();
|
|
20193
20193
|
init_chunk_FSQ6I3C7();
|
|
@@ -217399,7 +217399,7 @@ var init_dist2 = __esm({
|
|
|
217399
217399
|
init_chunk_I2WVMCYN();
|
|
217400
217400
|
init_chunk_CBPO2P4I();
|
|
217401
217401
|
init_chunk_7346CKTF();
|
|
217402
|
-
|
|
217402
|
+
init_chunk_IN3EHQ4Z();
|
|
217403
217403
|
init_chunk_3LUY2POB();
|
|
217404
217404
|
init_chunk_FSQ6I3C7();
|
|
217405
217405
|
init_chunk_PVVJCRII();
|
|
@@ -219913,23 +219913,75 @@ var init_chunk_KYLDNVV7 = __esm({
|
|
|
219913
219913
|
}
|
|
219914
219914
|
});
|
|
219915
219915
|
|
|
219916
|
-
// ../agent-sdk/dist/chunk-
|
|
219916
|
+
// ../agent-sdk/dist/chunk-IUJ6IDXX.js
|
|
219917
|
+
import { inflateRawSync } from "zlib";
|
|
219918
|
+
function extractFromZip(buffer) {
|
|
219919
|
+
const files2 = /* @__PURE__ */ new Map();
|
|
219920
|
+
let offset = 0;
|
|
219921
|
+
while (offset + 30 <= buffer.length) {
|
|
219922
|
+
const sig = buffer.readUInt32LE(offset);
|
|
219923
|
+
if (sig !== 67324752) break;
|
|
219924
|
+
const compMethod = buffer.readUInt16LE(offset + 8);
|
|
219925
|
+
const compSize = buffer.readUInt32LE(offset + 18);
|
|
219926
|
+
const uncompSize = buffer.readUInt32LE(offset + 22);
|
|
219927
|
+
const nameLen = buffer.readUInt16LE(offset + 26);
|
|
219928
|
+
const extraLen = buffer.readUInt16LE(offset + 28);
|
|
219929
|
+
const name = buffer.toString("utf8", offset + 30, offset + 30 + nameLen);
|
|
219930
|
+
const dataStart = offset + 30 + nameLen + extraLen;
|
|
219931
|
+
if (compMethod === 0) {
|
|
219932
|
+
const content = buffer.toString("utf8", dataStart, dataStart + uncompSize);
|
|
219933
|
+
files2.set(name, content);
|
|
219934
|
+
} else if (compMethod === 8) {
|
|
219935
|
+
const compressed = buffer.subarray(dataStart, dataStart + compSize);
|
|
219936
|
+
const content = inflateRawSync(compressed).toString("utf8");
|
|
219937
|
+
files2.set(name, content);
|
|
219938
|
+
}
|
|
219939
|
+
offset = dataStart + compSize;
|
|
219940
|
+
}
|
|
219941
|
+
return files2;
|
|
219942
|
+
}
|
|
219917
219943
|
function handleCreateSkill(request2) {
|
|
219918
219944
|
return routeWrap(request2, async ({ auth }) => {
|
|
219919
|
-
const
|
|
219920
|
-
|
|
219921
|
-
|
|
219922
|
-
|
|
219923
|
-
|
|
219924
|
-
|
|
219945
|
+
const contentType = request2.headers.get("content-type") ?? "";
|
|
219946
|
+
let name;
|
|
219947
|
+
let description;
|
|
219948
|
+
let content;
|
|
219949
|
+
let tenantId;
|
|
219950
|
+
if (contentType.includes("multipart/form-data")) {
|
|
219951
|
+
const formData = await request2.formData();
|
|
219952
|
+
name = (formData.get("display_title") ?? "").trim() || "untitled";
|
|
219953
|
+
const file = formData.get("files[]") ?? formData.get("files") ?? formData.get("file");
|
|
219954
|
+
if (!file || !(file instanceof File)) {
|
|
219955
|
+
throw badRequest("Missing file in multipart upload");
|
|
219956
|
+
}
|
|
219957
|
+
const buffer = Buffer.from(await file.arrayBuffer());
|
|
219958
|
+
if (file.name?.toLowerCase().endsWith(".zip")) {
|
|
219959
|
+
const zipFiles = extractFromZip(buffer);
|
|
219960
|
+
const skillEntry = [...zipFiles.entries()].find(
|
|
219961
|
+
([k2]) => k2.endsWith("SKILL.md") || k2.endsWith("skill.md")
|
|
219962
|
+
);
|
|
219963
|
+
if (!skillEntry) {
|
|
219964
|
+
throw badRequest("No SKILL.md found in zip archive");
|
|
219965
|
+
}
|
|
219966
|
+
content = skillEntry[1];
|
|
219967
|
+
} else {
|
|
219968
|
+
content = buffer.toString("utf-8");
|
|
219969
|
+
}
|
|
219970
|
+
tenantId = resolveCreateTenant(auth, void 0);
|
|
219971
|
+
} else {
|
|
219972
|
+
const body = await request2.json().catch(() => null);
|
|
219973
|
+
const parsed = CreateSkillSchema.safeParse(body);
|
|
219974
|
+
if (!parsed.success) {
|
|
219975
|
+
throw badRequest(
|
|
219976
|
+
`invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`
|
|
219977
|
+
);
|
|
219978
|
+
}
|
|
219979
|
+
name = parsed.data.name;
|
|
219980
|
+
description = parsed.data.description;
|
|
219981
|
+
content = parsed.data.content;
|
|
219982
|
+
tenantId = resolveCreateTenant(auth, parsed.data.tenant_id);
|
|
219925
219983
|
}
|
|
219926
|
-
const
|
|
219927
|
-
const skill = createSkill({
|
|
219928
|
-
name: parsed.data.name,
|
|
219929
|
-
description: parsed.data.description,
|
|
219930
|
-
content: parsed.data.content,
|
|
219931
|
-
tenantId
|
|
219932
|
-
});
|
|
219984
|
+
const skill = createSkill({ name, description, content, tenantId });
|
|
219933
219985
|
return jsonOk(skill, 201);
|
|
219934
219986
|
});
|
|
219935
219987
|
}
|
|
@@ -219998,8 +220050,8 @@ function handleDeleteSkillVersion(request2, skillId, version3) {
|
|
|
219998
220050
|
});
|
|
219999
220051
|
}
|
|
220000
220052
|
var CreateSkillSchema, CreateVersionSchema;
|
|
220001
|
-
var
|
|
220002
|
-
"../agent-sdk/dist/chunk-
|
|
220053
|
+
var init_chunk_IUJ6IDXX = __esm({
|
|
220054
|
+
"../agent-sdk/dist/chunk-IUJ6IDXX.js"() {
|
|
220003
220055
|
"use strict";
|
|
220004
220056
|
init_chunk_KYLDNVV7();
|
|
220005
220057
|
init_chunk_23UKWXJH();
|
|
@@ -221474,7 +221526,7 @@ var init_chunk_5WY3LSCS = __esm({
|
|
|
221474
221526
|
}
|
|
221475
221527
|
});
|
|
221476
221528
|
|
|
221477
|
-
// ../agent-sdk/dist/chunk-
|
|
221529
|
+
// ../agent-sdk/dist/chunk-JP4HHXHY.js
|
|
221478
221530
|
function assertStoreTenant(auth, storeAgentId) {
|
|
221479
221531
|
if (storeAgentId == null) {
|
|
221480
221532
|
if (!auth.isGlobalAdmin) throw notFound("memory store not found");
|
|
@@ -221641,13 +221693,47 @@ function handleArchiveMemoryStore(request2, storeId) {
|
|
|
221641
221693
|
return jsonOk(store2);
|
|
221642
221694
|
});
|
|
221643
221695
|
}
|
|
221644
|
-
|
|
221645
|
-
|
|
221646
|
-
|
|
221696
|
+
function handleDreamMemoryStore(request2, storeId) {
|
|
221697
|
+
return routeWrap(request2, async ({ auth }) => {
|
|
221698
|
+
loadStoreForCaller(auth, storeId);
|
|
221699
|
+
const body = await request2.json();
|
|
221700
|
+
const parsed = DreamRequestSchema.safeParse(body);
|
|
221701
|
+
if (!parsed.success) throw badRequest(parsed.error.message);
|
|
221702
|
+
const lastDreamed = dreamCooldowns.get(storeId);
|
|
221703
|
+
if (lastDreamed !== void 0 && Date.now() - lastDreamed < DREAM_COOLDOWN_MS) {
|
|
221704
|
+
const retryAfterSec = Math.ceil((DREAM_COOLDOWN_MS - (Date.now() - lastDreamed)) / 1e3);
|
|
221705
|
+
throw tooManyRequests(`dream was triggered recently; retry after ${retryAfterSec}s`);
|
|
221706
|
+
}
|
|
221707
|
+
const apiKey = parsed.data.api_key || getConfig().anthropicApiKey;
|
|
221708
|
+
if (!apiKey) {
|
|
221709
|
+
throw badRequest("No Anthropic API key available. Provide api_key in the request body or set ANTHROPIC_API_KEY.");
|
|
221710
|
+
}
|
|
221711
|
+
const result = await reviewSessions({
|
|
221712
|
+
storeId,
|
|
221713
|
+
lookbackMs: parsed.data.lookback_hours * 36e5,
|
|
221714
|
+
dryRun: parsed.data.dry_run,
|
|
221715
|
+
apiKey,
|
|
221716
|
+
model: parsed.data.model
|
|
221717
|
+
});
|
|
221718
|
+
dreamCooldowns.set(storeId, Date.now());
|
|
221719
|
+
return jsonOk({
|
|
221720
|
+
type: "dream_result",
|
|
221721
|
+
memory_store_id: storeId,
|
|
221722
|
+
session_count: result.sessionCount,
|
|
221723
|
+
proposed_changes: result.proposedChanges,
|
|
221724
|
+
applied: result.applied
|
|
221725
|
+
});
|
|
221726
|
+
});
|
|
221727
|
+
}
|
|
221728
|
+
var CreateStoreSchema, UpdateStoreSchema, CreateMemorySchema, UpdateMemorySchema, DreamRequestSchema, dreamCooldowns, DREAM_COOLDOWN_MS;
|
|
221729
|
+
var init_chunk_JP4HHXHY = __esm({
|
|
221730
|
+
"../agent-sdk/dist/chunk-JP4HHXHY.js"() {
|
|
221647
221731
|
"use strict";
|
|
221648
221732
|
init_chunk_23UKWXJH();
|
|
221733
|
+
init_chunk_IN3EHQ4Z();
|
|
221649
221734
|
init_chunk_FSQ6I3C7();
|
|
221650
221735
|
init_chunk_IYVGGJMH();
|
|
221736
|
+
init_chunk_P2NWS65Y();
|
|
221651
221737
|
init_chunk_W3YXUIPS();
|
|
221652
221738
|
init_chunk_EZYKRG4W();
|
|
221653
221739
|
init_zod();
|
|
@@ -221670,6 +221756,14 @@ var init_chunk_T7NQMCDT = __esm({
|
|
|
221670
221756
|
content: external_exports.string(),
|
|
221671
221757
|
content_sha256: external_exports.string().optional()
|
|
221672
221758
|
});
|
|
221759
|
+
DreamRequestSchema = external_exports.object({
|
|
221760
|
+
lookback_hours: external_exports.number().min(1).max(720).default(24),
|
|
221761
|
+
dry_run: external_exports.boolean().default(false),
|
|
221762
|
+
model: external_exports.string().optional(),
|
|
221763
|
+
api_key: external_exports.string().optional()
|
|
221764
|
+
});
|
|
221765
|
+
dreamCooldowns = /* @__PURE__ */ new Map();
|
|
221766
|
+
DREAM_COOLDOWN_MS = 5 * 60 * 1e3;
|
|
221673
221767
|
}
|
|
221674
221768
|
});
|
|
221675
221769
|
|
|
@@ -223542,6 +223636,7 @@ __export(handlers_exports, {
|
|
|
223542
223636
|
handleDeleteSkillVersion: () => handleDeleteSkillVersion,
|
|
223543
223637
|
handleDeleteUpstreamKey: () => handleDeleteUpstreamKey,
|
|
223544
223638
|
handleDeleteVault: () => handleDeleteVault,
|
|
223639
|
+
handleDreamMemoryStore: () => handleDreamMemoryStore,
|
|
223545
223640
|
handleExportTrace: () => handleExportTrace,
|
|
223546
223641
|
handleGetAgent: () => handleGetAgent,
|
|
223547
223642
|
handleGetApiKey: () => handleGetApiKey,
|
|
@@ -223634,7 +223729,7 @@ var init_handlers3 = __esm({
|
|
|
223634
223729
|
init_chunk_TXOB3PZH();
|
|
223635
223730
|
init_chunk_MFSO7IGE();
|
|
223636
223731
|
init_chunk_JPONGXV5();
|
|
223637
|
-
|
|
223732
|
+
init_chunk_IUJ6IDXX();
|
|
223638
223733
|
init_chunk_H355W724();
|
|
223639
223734
|
init_chunk_DAKCDGWV();
|
|
223640
223735
|
init_chunk_GOFQ63N3();
|
|
@@ -223643,7 +223738,7 @@ var init_handlers3 = __esm({
|
|
|
223643
223738
|
init_chunk_DMROEZYE();
|
|
223644
223739
|
init_chunk_UKCIGI3T();
|
|
223645
223740
|
init_chunk_5WY3LSCS();
|
|
223646
|
-
|
|
223741
|
+
init_chunk_JP4HHXHY();
|
|
223647
223742
|
init_chunk_DYRGMJTC();
|
|
223648
223743
|
init_chunk_R6M4V3IG();
|
|
223649
223744
|
init_chunk_7OM5LP3K();
|
|
@@ -223669,6 +223764,8 @@ var init_handlers3 = __esm({
|
|
|
223669
223764
|
init_chunk_I2WVMCYN();
|
|
223670
223765
|
init_chunk_CBPO2P4I();
|
|
223671
223766
|
init_chunk_7346CKTF();
|
|
223767
|
+
init_chunk_IN3EHQ4Z();
|
|
223768
|
+
init_chunk_3LUY2POB();
|
|
223672
223769
|
init_chunk_FSQ6I3C7();
|
|
223673
223770
|
init_chunk_PVVJCRII();
|
|
223674
223771
|
init_chunk_2N2KL4KM();
|
|
@@ -238266,6 +238363,7 @@ var init_src = __esm({
|
|
|
238266
238363
|
app.post("/v1/memory_stores", (c2) => handleCreateMemoryStore(c2.req.raw));
|
|
238267
238364
|
app.get("/v1/memory_stores", (c2) => handleListMemoryStores(c2.req.raw));
|
|
238268
238365
|
app.post("/v1/memory_stores/:id/archive", (c2) => handleArchiveMemoryStore(c2.req.raw, c2.req.param("id")));
|
|
238366
|
+
app.post("/v1/memory_stores/:id/dream", (c2) => handleDreamMemoryStore(c2.req.raw, c2.req.param("id")));
|
|
238269
238367
|
app.get("/v1/memory_stores/:id/memory_versions", (c2) => handleListMemoryVersions(c2.req.raw, c2.req.param("id")));
|
|
238270
238368
|
app.get("/v1/memory_stores/:id/memory_versions/:vid", (c2) => handleGetMemoryVersion(c2.req.raw, c2.req.param("id"), c2.req.param("vid")));
|
|
238271
238369
|
app.post("/v1/memory_stores/:id/memory_versions/:vid/redact", (c2) => handleRedactMemoryVersion(c2.req.raw, c2.req.param("id"), c2.req.param("vid")));
|
package/package.json
CHANGED