@tryvira/sdk 0.1.61 → 0.1.63
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 +31 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// sdks/js-client.ts
|
|
2
2
|
var ViraApiError = class extends Error {
|
|
3
3
|
status;
|
|
4
4
|
body;
|
|
@@ -197,7 +197,20 @@ var ViraClient = class {
|
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
async connectOnce(input) {
|
|
200
|
-
|
|
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");
|
|
@@ -493,9 +506,21 @@ var ViraClient = class {
|
|
|
493
506
|
);
|
|
494
507
|
}
|
|
495
508
|
async resolveSemanticRuntime(input) {
|
|
496
|
-
|
|
509
|
+
let semantic = await this.resolveSemantic(input);
|
|
497
510
|
if (!semantic) return null;
|
|
498
|
-
|
|
511
|
+
let body = semantic.body;
|
|
512
|
+
if (body.replayed === true && !Array.isArray(body.capsules)) {
|
|
513
|
+
const replayRequestId = `${input.requestId ?? "sdk-semantic"}:rehydrate:${Date.now()}`;
|
|
514
|
+
const refreshed = await this.resolveSemantic({
|
|
515
|
+
...input,
|
|
516
|
+
requestId: replayRequestId,
|
|
517
|
+
idempotencyKey: `sdk:semantic:rehydrate:${replayRequestId}`
|
|
518
|
+
});
|
|
519
|
+
if (refreshed) {
|
|
520
|
+
semantic = refreshed;
|
|
521
|
+
body = refreshed.body;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
499
524
|
const receipt = body.receipt && typeof body.receipt === "object" ? body.receipt : {};
|
|
500
525
|
if (receipt.outcome !== "select" || typeof receipt.taskKey !== "string")
|
|
501
526
|
return { semantic, runtime: null, taskKeys: [], capsules: [], multiTask: false };
|
|
@@ -1195,7 +1220,7 @@ function buildObservationRequest(event) {
|
|
|
1195
1220
|
});
|
|
1196
1221
|
}
|
|
1197
1222
|
|
|
1198
|
-
//
|
|
1223
|
+
// sdks/framework-adapters.ts
|
|
1199
1224
|
function createFrameworkRuntimeCore(client) {
|
|
1200
1225
|
if (!client) throw new Error("SDK_FRAMEWORK_CLIENT_REQUIRED");
|
|
1201
1226
|
return Object.freeze({
|
|
@@ -1279,7 +1304,7 @@ function createFrameworkAdapters(client) {
|
|
|
1279
1304
|
return Object.freeze(Object.fromEntries(["openai-agents", "vercel-ai", "langchain", "langgraph", "otel", "mcp"].map((name) => [name, createFrameworkObservationAdapter(client, name)])));
|
|
1280
1305
|
}
|
|
1281
1306
|
|
|
1282
|
-
//
|
|
1307
|
+
// sdks/host-lifecycle.ts
|
|
1283
1308
|
import { createHash } from "node:crypto";
|
|
1284
1309
|
function resolveHostToolBinding(bindings, hostToolName) {
|
|
1285
1310
|
const name = hostToolName.trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryvira/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.63",
|
|
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"},
|