@tryvira/sdk 0.1.62 → 0.1.64
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 +26 -7
- package/dist/js-client.d.ts +1 -0
- 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;
|
|
@@ -506,9 +506,21 @@ var ViraClient = class {
|
|
|
506
506
|
);
|
|
507
507
|
}
|
|
508
508
|
async resolveSemanticRuntime(input) {
|
|
509
|
-
|
|
509
|
+
let semantic = await this.resolveSemantic(input);
|
|
510
510
|
if (!semantic) return null;
|
|
511
|
-
|
|
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
|
+
}
|
|
512
524
|
const receipt = body.receipt && typeof body.receipt === "object" ? body.receipt : {};
|
|
513
525
|
if (receipt.outcome !== "select" || typeof receipt.taskKey !== "string")
|
|
514
526
|
return { semantic, runtime: null, taskKeys: [], capsules: [], multiTask: false };
|
|
@@ -729,7 +741,7 @@ var ViraClient = class {
|
|
|
729
741
|
if (input.input === void 0 || input.input === null) throw new Error("SDK_TASKRUN_INPUT_REQUIRED");
|
|
730
742
|
const id = () => globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
731
743
|
const requestId = input.requestId ?? `sdk-task-run-${id()}`;
|
|
732
|
-
return this.startTaskRun({ taskRunId: input.taskRunId ?? `task-run-${id()}`, requestId, input: input.input, ...input.conversationId ? { conversationId: input.conversationId } : {}, ...input.episodeId ? { episodeId: input.episodeId } : {}, ...input.traceRootRef ? { traceRootRef: input.traceRootRef } : {}, ...input.budget ? { budget: input.budget } : {}, ...input.connectionId ? { connectionId: input.connectionId } : {} }, options);
|
|
744
|
+
return this.startTaskRun({ taskRunId: input.taskRunId ?? `task-run-${id()}`, requestId, input: input.input, ...input.conversationId ? { conversationId: input.conversationId } : {}, ...input.episodeId ? { episodeId: input.episodeId } : {}, ...input.traceRootRef ? { traceRootRef: input.traceRootRef } : {}, ...input.budget ? { budget: input.budget } : {}, ...input.connectionId ? { connectionId: input.connectionId } : {}, ...input.hostCapabilities ? { hostCapabilities: [...input.hostCapabilities] } : {} }, options);
|
|
733
745
|
}
|
|
734
746
|
getTaskRun(taskRunId) {
|
|
735
747
|
required(taskRunId, "SDK_TASKRUN_ID_REQUIRED");
|
|
@@ -1208,7 +1220,7 @@ function buildObservationRequest(event) {
|
|
|
1208
1220
|
});
|
|
1209
1221
|
}
|
|
1210
1222
|
|
|
1211
|
-
//
|
|
1223
|
+
// sdks/framework-adapters.ts
|
|
1212
1224
|
function createFrameworkRuntimeCore(client) {
|
|
1213
1225
|
if (!client) throw new Error("SDK_FRAMEWORK_CLIENT_REQUIRED");
|
|
1214
1226
|
return Object.freeze({
|
|
@@ -1292,7 +1304,7 @@ function createFrameworkAdapters(client) {
|
|
|
1292
1304
|
return Object.freeze(Object.fromEntries(["openai-agents", "vercel-ai", "langchain", "langgraph", "otel", "mcp"].map((name) => [name, createFrameworkObservationAdapter(client, name)])));
|
|
1293
1305
|
}
|
|
1294
1306
|
|
|
1295
|
-
//
|
|
1307
|
+
// sdks/host-lifecycle.ts
|
|
1296
1308
|
import { createHash } from "node:crypto";
|
|
1297
1309
|
function resolveHostToolBinding(bindings, hostToolName) {
|
|
1298
1310
|
const name = hostToolName.trim();
|
|
@@ -1428,7 +1440,14 @@ function createViraHostRuntime(client, config) {
|
|
|
1428
1440
|
if (!semantic) return { status: "unavailable", reasonCode: "VIRA_SEMANTIC_UNAVAILABLE" };
|
|
1429
1441
|
if (semantic.multiTask === true && semantic.taskKeys?.length > 1 && typeof client.startTaskRunFromPrompt === "function") {
|
|
1430
1442
|
try {
|
|
1431
|
-
const
|
|
1443
|
+
const hostCapabilities = [
|
|
1444
|
+
...capabilities.canObserveModel ? ["conversation_input", "conversation_output", "model_call"] : [],
|
|
1445
|
+
...capabilities.canInjectContext ? ["behavior_projection"] : [],
|
|
1446
|
+
...capabilities.canInterceptToolBefore ? ["tool_selection", "tool_execution"] : [],
|
|
1447
|
+
...capabilities.canPreventSideEffect ? ["external_action"] : [],
|
|
1448
|
+
...capabilities.canInspectToolAfter ? ["tool_result"] : []
|
|
1449
|
+
];
|
|
1450
|
+
const admitted = await withTimeout(client.startTaskRunFromPrompt({ input: request.input, taskRunId: `host-task-run-${request.requestId}`, requestId: request.requestId, conversationId: request.conversationId, traceRootRef: request.traceId, hostCapabilities }), timeoutMs, "SDK_HOST_TASKRUN_ADMISSION_TIMEOUT");
|
|
1432
1451
|
const admittedBody = bodyOf(admitted);
|
|
1433
1452
|
const taskRun = admittedBody.taskRun && typeof admittedBody.taskRun === "object" ? admittedBody.taskRun : {};
|
|
1434
1453
|
const taskRunId = typeof taskRun.taskRunId === "string" ? taskRun.taskRunId : `host-task-run-${request.requestId}`;
|
package/dist/js-client.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryvira/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.64",
|
|
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"},
|