@agentstep/gateway 0.5.37 → 0.5.39
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 +26 -20
- package/package.json +1 -1
package/dist/gateway.js
CHANGED
|
@@ -219721,7 +219721,7 @@ var init_vaults = __esm({
|
|
|
219721
219721
|
}
|
|
219722
219722
|
});
|
|
219723
219723
|
|
|
219724
|
-
// ../agent-sdk/dist/chunk-
|
|
219724
|
+
// ../agent-sdk/dist/chunk-VSDPZ77X.js
|
|
219725
219725
|
function getAgentTenantId2(id) {
|
|
219726
219726
|
const row = getDb().prepare(`SELECT tenant_id FROM agents WHERE id = ?`).get(id);
|
|
219727
219727
|
return row?.tenant_id;
|
|
@@ -219839,7 +219839,7 @@ function handleCreateSession(request2) {
|
|
|
219839
219839
|
const vaultRow = getDb().prepare(`SELECT agent_id, tenant_id FROM vaults WHERE id = ?`).get(vid);
|
|
219840
219840
|
if (!vaultRow) throw badRequest(`vault not found: ${vid}`);
|
|
219841
219841
|
assertResourceTenant(auth, vaultRow.tenant_id, `vault not found: ${vid}`);
|
|
219842
|
-
if (vaultRow.agent_id !== agent.id) {
|
|
219842
|
+
if (vaultRow.agent_id && vaultRow.agent_id !== agent.id) {
|
|
219843
219843
|
throw badRequest(
|
|
219844
219844
|
`vault ${vid} belongs to a different agent \u2014 vaults are scoped per-agent`
|
|
219845
219845
|
);
|
|
@@ -220225,8 +220225,8 @@ function parseMs(v2) {
|
|
|
220225
220225
|
return Number.isFinite(t2) ? t2 : void 0;
|
|
220226
220226
|
}
|
|
220227
220227
|
var ALLOWED_STATUSES, AgentRef, ResourceSchema, CreateSchema2, UpdateSchema2;
|
|
220228
|
-
var
|
|
220229
|
-
"../agent-sdk/dist/chunk-
|
|
220228
|
+
var init_chunk_VSDPZ77X = __esm({
|
|
220229
|
+
"../agent-sdk/dist/chunk-VSDPZ77X.js"() {
|
|
220230
220230
|
"use strict";
|
|
220231
220231
|
init_chunk_VCU64NHY();
|
|
220232
220232
|
init_chunk_ZBWKJ42J();
|
|
@@ -220321,7 +220321,7 @@ __export(sessions_exports, {
|
|
|
220321
220321
|
var init_sessions = __esm({
|
|
220322
220322
|
"../agent-sdk/dist/handlers/sessions.js"() {
|
|
220323
220323
|
"use strict";
|
|
220324
|
-
|
|
220324
|
+
init_chunk_VSDPZ77X();
|
|
220325
220325
|
init_chunk_VCU64NHY();
|
|
220326
220326
|
init_chunk_ZBWKJ42J();
|
|
220327
220327
|
init_chunk_23UKWXJH();
|
|
@@ -221785,7 +221785,7 @@ var init_bus = __esm({
|
|
|
221785
221785
|
}
|
|
221786
221786
|
});
|
|
221787
221787
|
|
|
221788
|
-
// ../agent-sdk/dist/chunk-
|
|
221788
|
+
// ../agent-sdk/dist/chunk-KSKJ7IYH.js
|
|
221789
221789
|
function ensureTable() {
|
|
221790
221790
|
const db = getDb();
|
|
221791
221791
|
db.exec(`
|
|
@@ -221853,17 +221853,29 @@ function handleCreateInteraction(request2) {
|
|
|
221853
221853
|
).run(interactionId2, sessionId2, seq, result2.status, environmentId ?? null, (/* @__PURE__ */ new Date()).toISOString());
|
|
221854
221854
|
return jsonOk(buildResponse(interactionId2, result2, environmentId));
|
|
221855
221855
|
}
|
|
221856
|
-
const
|
|
221856
|
+
const modelId = data.model || "gemini-2.5-flash";
|
|
221857
|
+
const agentName = data.agent || `auto-${modelId.replace(/[^a-z0-9-]/g, "-")}`;
|
|
221857
221858
|
const listReq = new Request(request2.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/agents?limit=1000`), {
|
|
221858
221859
|
headers: request2.headers
|
|
221859
221860
|
});
|
|
221860
221861
|
const listRes = await handleListAgents2(listReq);
|
|
221861
221862
|
const listBody = await listRes.json();
|
|
221862
|
-
const
|
|
221863
|
+
const { listVaults: listVaults2 } = await Promise.resolve().then(() => (init_vaults(), vaults_exports));
|
|
221864
|
+
const { tenantFilter: getTenantFilter } = await Promise.resolve().then(() => (init_scope2(), scope_exports));
|
|
221865
|
+
const allVaults = listVaults2({ tenantFilter: getTenantFilter(auth) }).filter((v2) => !v2.archived_at);
|
|
221866
|
+
let existing;
|
|
221867
|
+
if (data.agent) {
|
|
221868
|
+
existing = listBody.data?.find((a) => a.name === agentName);
|
|
221869
|
+
} else {
|
|
221870
|
+
const modelMatches = listBody.data?.filter((a) => a.model?.id === modelId) ?? [];
|
|
221871
|
+
const withVaults = modelMatches.filter(
|
|
221872
|
+
(a) => allVaults.some((v2) => v2.agent_id === a.id || !v2.agent_id)
|
|
221873
|
+
);
|
|
221874
|
+
existing = modelMatches.find((a) => allVaults.some((v2) => v2.agent_id === a.id)) ?? withVaults[0] ?? modelMatches[0];
|
|
221875
|
+
}
|
|
221863
221876
|
if (existing) {
|
|
221864
221877
|
agentId = existing.id;
|
|
221865
221878
|
} else {
|
|
221866
|
-
const modelId = data.model || "gemini-2.5-flash";
|
|
221867
221879
|
const createReq = new Request(request2.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/agents`), {
|
|
221868
221880
|
method: "POST",
|
|
221869
221881
|
headers: request2.headers,
|
|
@@ -221900,13 +221912,7 @@ function handleCreateInteraction(request2) {
|
|
|
221900
221912
|
}
|
|
221901
221913
|
}
|
|
221902
221914
|
if (!environmentId) throw badRequest("no environment available");
|
|
221903
|
-
const
|
|
221904
|
-
const { tenantFilter: getTenantFilter } = await Promise.resolve().then(() => (init_scope2(), scope_exports));
|
|
221905
|
-
const tenantVaults = listVaults2({
|
|
221906
|
-
tenantFilter: getTenantFilter(auth)
|
|
221907
|
-
});
|
|
221908
|
-
const agentVaults = tenantVaults.filter((v2) => v2.agent_id === agentId || !v2.agent_id);
|
|
221909
|
-
const vaultIds = agentVaults.filter((v2) => !v2.archived_at).map((v2) => v2.id);
|
|
221915
|
+
const vaultIds = allVaults.filter((v2) => v2.agent_id === agentId || !v2.agent_id).map((v2) => v2.id);
|
|
221910
221916
|
const sessReq = new Request(request2.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions`), {
|
|
221911
221917
|
method: "POST",
|
|
221912
221918
|
headers: request2.headers,
|
|
@@ -222168,8 +222174,8 @@ function buildResponse(id, result, environmentId) {
|
|
|
222168
222174
|
};
|
|
222169
222175
|
}
|
|
222170
222176
|
var CreateSchema4;
|
|
222171
|
-
var
|
|
222172
|
-
"../agent-sdk/dist/chunk-
|
|
222177
|
+
var init_chunk_KSKJ7IYH = __esm({
|
|
222178
|
+
"../agent-sdk/dist/chunk-KSKJ7IYH.js"() {
|
|
222173
222179
|
"use strict";
|
|
222174
222180
|
init_chunk_RMCBO7K7();
|
|
222175
222181
|
init_chunk_F4WUVOLE();
|
|
@@ -226886,7 +226892,7 @@ __export(handlers_exports, {
|
|
|
226886
226892
|
var init_handlers3 = __esm({
|
|
226887
226893
|
"../agent-sdk/dist/handlers/index.js"() {
|
|
226888
226894
|
"use strict";
|
|
226889
|
-
|
|
226895
|
+
init_chunk_KSKJ7IYH();
|
|
226890
226896
|
init_chunk_2HTAIROL();
|
|
226891
226897
|
init_chunk_PULMO5OO();
|
|
226892
226898
|
init_chunk_3CDJ2VQN();
|
|
@@ -226906,7 +226912,7 @@ var init_handlers3 = __esm({
|
|
|
226906
226912
|
init_chunk_CCNG7D6Y();
|
|
226907
226913
|
init_chunk_R7MZNZNC();
|
|
226908
226914
|
init_chunk_DQIQBMC2();
|
|
226909
|
-
|
|
226915
|
+
init_chunk_VSDPZ77X();
|
|
226910
226916
|
init_chunk_VCU64NHY();
|
|
226911
226917
|
init_chunk_52K3LOFD();
|
|
226912
226918
|
init_chunk_2E43SH4Y();
|
package/package.json
CHANGED