@agentstep/agent-sdk 0.5.38 → 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.
@@ -104,7 +104,19 @@ function handleCreateInteraction(request) {
104
104
  });
105
105
  const listRes = await handleListAgents(listReq);
106
106
  const listBody = await listRes.json();
107
- const existing = listBody.data?.find((a) => a.name === agentName) ?? (data.agent ? void 0 : listBody.data?.find((a) => a.model?.id === modelId));
107
+ const { listVaults } = await import("./db/vaults.js");
108
+ const { tenantFilter: getTenantFilter } = await import("./auth/scope.js");
109
+ const allVaults = listVaults({ tenantFilter: getTenantFilter(auth) }).filter((v) => !v.archived_at);
110
+ let existing;
111
+ if (data.agent) {
112
+ existing = listBody.data?.find((a) => a.name === agentName);
113
+ } else {
114
+ const modelMatches = listBody.data?.filter((a) => a.model?.id === modelId) ?? [];
115
+ const withVaults = modelMatches.filter(
116
+ (a) => allVaults.some((v) => v.agent_id === a.id || !v.agent_id)
117
+ );
118
+ existing = modelMatches.find((a) => allVaults.some((v) => v.agent_id === a.id)) ?? withVaults[0] ?? modelMatches[0];
119
+ }
108
120
  if (existing) {
109
121
  agentId = existing.id;
110
122
  } else {
@@ -144,12 +156,7 @@ function handleCreateInteraction(request) {
144
156
  }
145
157
  }
146
158
  if (!environmentId) throw badRequest("no environment available");
147
- const { listVaults } = await import("./db/vaults.js");
148
- const { tenantFilter: getTenantFilter } = await import("./auth/scope.js");
149
- const tenantVaults = listVaults({
150
- tenantFilter: getTenantFilter(auth)
151
- });
152
- const vaultIds = tenantVaults.filter((v) => !v.archived_at && (v.agent_id === agentId || !v.agent_id)).map((v) => v.id);
159
+ const vaultIds = allVaults.filter((v) => v.agent_id === agentId || !v.agent_id).map((v) => v.id);
153
160
  const sessReq = new Request(request.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions`), {
154
161
  method: "POST",
155
162
  headers: request.headers,
@@ -4,7 +4,7 @@ import {
4
4
  handleCreateInteraction,
5
5
  handleDeleteInteraction,
6
6
  handleGetInteraction
7
- } from "../../chunk-IS37752C.js";
7
+ } from "../../chunk-KSKJ7IYH.js";
8
8
  import {
9
9
  handleCreateGoogleAgent,
10
10
  handleDeleteGoogleAgent,
@@ -3,7 +3,7 @@ import {
3
3
  handleCreateInteraction,
4
4
  handleDeleteInteraction,
5
5
  handleGetInteraction
6
- } from "../../chunk-IS37752C.js";
6
+ } from "../../chunk-KSKJ7IYH.js";
7
7
  import "../../chunk-RMCBO7K7.js";
8
8
  import "../../chunk-D2XITRN6.js";
9
9
  import "../../chunk-CWB2DQN5.js";
@@ -4,7 +4,7 @@ import {
4
4
  handleCreateInteraction,
5
5
  handleDeleteInteraction,
6
6
  handleGetInteraction
7
- } from "../chunk-IS37752C.js";
7
+ } from "../chunk-KSKJ7IYH.js";
8
8
  import {
9
9
  handleCreateGoogleAgent,
10
10
  handleDeleteGoogleAgent,
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.38",
4
+ "version": "0.5.39",
5
5
  "description": "Core engine for AgentStep Gateway \u2014 backends, sandbox providers, session orchestration, and vault encryption.",
6
6
  "keywords": [
7
7
  "anthropic",