@tryvira/sdk 0.1.60 → 0.1.62

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/index.js CHANGED
@@ -197,13 +197,27 @@ var ViraClient = class {
197
197
  );
198
198
  }
199
199
  async connectOnce(input) {
200
- const systemResult = await this.connectSystem(input);
200
+ let systemResult;
201
+ try {
202
+ systemResult = await this.connectSystem(input);
203
+ } catch (error) {
204
+ if (!(input.reuseExistingConnectionOnConflict !== false && error instanceof ViraApiError && error.status === 409)) throw error;
205
+ const listed = await this.listAISystems();
206
+ if (!listed) throw error;
207
+ const systems = Array.isArray(listed?.body?.systems) ? listed.body.systems : [];
208
+ const reused = systems.find(
209
+ (system) => String(system.name ?? "") === input.name && String(system.systemType ?? "") === input.systemType && String(system.organizationId ?? "") === input.organizationId && String(system.projectId ?? "") === input.projectId && String(system.environmentId ?? "") === input.environmentId
210
+ );
211
+ if (!reused) throw error;
212
+ systemResult = { status: listed.status, requestId: listed.requestId, body: { system: reused } };
213
+ }
201
214
  if (!systemResult) return null;
202
215
  const systemId = String(systemResult.body.system.id ?? "");
203
216
  required(systemId, "SDK_SYSTEM_ID_MISSING");
204
217
  let connectionResult;
205
218
  try {
206
219
  connectionResult = await this.connectAdapter(systemId, {
220
+ id: input.id,
207
221
  adapterType: input.adapterType,
208
222
  adapterVersion: input.adapterVersion,
209
223
  capabilities: input.capabilities,
@@ -215,6 +215,7 @@ export declare class ViraClient {
215
215
  }): Promise<ViraResponse<ClientBody> | null>;
216
216
  getAISystem(systemId: string): Promise<ViraResponse<ClientBody> | null>;
217
217
  connectAdapter(systemId: string, input: {
218
+ id?: string;
218
219
  adapterType: string;
219
220
  adapterVersion: string;
220
221
  capabilities?: readonly string[];
@@ -225,6 +226,7 @@ export declare class ViraClient {
225
226
  handshake: ClientBody;
226
227
  }> | null>;
227
228
  connectOnce(input: {
229
+ id?: string;
228
230
  name: string;
229
231
  systemType: string;
230
232
  organizationId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/sdk",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "description": "Typed Vira SDK for connect-once, observation and governed runtime execution.",
5
5
  "keywords": ["vira", "ai-governance", "ai-runtime", "semantic-routing"],
6
6
  "engines": {"node": ">=20"},