@tryvira/sdk 0.1.48 → 0.1.50
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/host-lifecycle.d.ts +5 -0
- package/dist/index.js +14 -3
- package/dist/js-client.d.ts +2 -0
- package/package.json +1 -1
package/dist/host-lifecycle.d.ts
CHANGED
|
@@ -71,6 +71,10 @@ export interface HostLifecycleConfig {
|
|
|
71
71
|
projectionMaxBytes?: number;
|
|
72
72
|
timeoutMs?: number;
|
|
73
73
|
}
|
|
74
|
+
export interface HostConnectionIdentity {
|
|
75
|
+
aiSystemId: string;
|
|
76
|
+
connectionId: string;
|
|
77
|
+
}
|
|
74
78
|
export interface HostProjectionResult {
|
|
75
79
|
status: 'applied' | 'abstain' | 'off' | 'unavailable';
|
|
76
80
|
response?: ViraResponse<unknown> | null;
|
|
@@ -84,6 +88,7 @@ export declare function createViraHostRuntime(client: ViraClient, config: HostLi
|
|
|
84
88
|
mode: HostLifecycleMode;
|
|
85
89
|
capabilities: HostCapabilities;
|
|
86
90
|
connectOnce: () => Promise<unknown>;
|
|
91
|
+
getConnectionIdentity: () => HostConnectionIdentity | null;
|
|
87
92
|
beforeModel: (request: HostModelRequest) => Promise<HostProjectionResult>;
|
|
88
93
|
beforeTool: (proposal: HostToolProposal) => Promise<HostActionAuthorization>;
|
|
89
94
|
afterTool: (result: HostToolResult) => Promise<unknown>;
|
package/dist/index.js
CHANGED
|
@@ -488,10 +488,11 @@ var ViraClient = class {
|
|
|
488
488
|
required(input.scope.projectId, "SDK_ACTION_PROJECT_REQUIRED");
|
|
489
489
|
required(input.scope.environmentId, "SDK_ACTION_ENVIRONMENT_REQUIRED");
|
|
490
490
|
required(input.executionId, "SDK_ACTION_EXECUTION_REQUIRED");
|
|
491
|
+
required(input.sessionId, "SDK_ACTION_SESSION_REQUIRED");
|
|
491
492
|
return this.request({
|
|
492
493
|
method: "POST",
|
|
493
494
|
path: "/v1/runtime/actions/authorize",
|
|
494
|
-
body: { executionId: input.executionId, scope: input.scope, context: input.context, proposal: input.proposal }
|
|
495
|
+
body: { executionId: input.executionId, sessionId: input.sessionId, scope: input.scope, context: input.context, proposal: input.proposal, ...input.approval ? { approval: input.approval } : {} }
|
|
495
496
|
});
|
|
496
497
|
}
|
|
497
498
|
listBehaviorStrategies() {
|
|
@@ -1250,10 +1251,20 @@ function createViraHostRuntime(client, config) {
|
|
|
1250
1251
|
if (mode === "enforce" && (!capabilities.canInterceptToolBefore || !capabilities.canPreventSideEffect)) throw new Error("SDK_HOST_ENFORCE_CAPABILITY_REQUIRED");
|
|
1251
1252
|
if (mode === "enforce" && typeof config.authorizeAction !== "function") throw new Error("SDK_HOST_ACTION_AUTHORIZER_REQUIRED");
|
|
1252
1253
|
let connected = null;
|
|
1254
|
+
let connectionIdentity = null;
|
|
1253
1255
|
const projections = /* @__PURE__ */ new Map();
|
|
1254
1256
|
const connectOnce = async () => {
|
|
1255
1257
|
if (mode === "off" || !config.connect) return null;
|
|
1256
|
-
if (!connected) connected = withTimeout(client.connectOnce(config.connect), timeoutMs, "SDK_HOST_CONNECT_TIMEOUT")
|
|
1258
|
+
if (!connected) connected = withTimeout(client.connectOnce(config.connect), timeoutMs, "SDK_HOST_CONNECT_TIMEOUT").then((result) => {
|
|
1259
|
+
const body = bodyOf(result);
|
|
1260
|
+
const system = body.system && typeof body.system === "object" ? body.system : {};
|
|
1261
|
+
const connection = body.connection && typeof body.connection === "object" ? body.connection : {};
|
|
1262
|
+
const aiSystemId = typeof system.id === "string" ? system.id.trim() : "";
|
|
1263
|
+
const connectionId = typeof connection.id === "string" ? connection.id.trim() : "";
|
|
1264
|
+
if (!aiSystemId || !connectionId) throw new Error("SDK_HOST_CONNECT_IDENTITY_MISSING");
|
|
1265
|
+
connectionIdentity = { aiSystemId, connectionId };
|
|
1266
|
+
return result;
|
|
1267
|
+
});
|
|
1257
1268
|
return connected;
|
|
1258
1269
|
};
|
|
1259
1270
|
const sessionKey = (request) => `${request.organizationId}:${request.projectId}:${request.environmentId}:${request.conversationId}`;
|
|
@@ -1304,7 +1315,7 @@ function createViraHostRuntime(client, config) {
|
|
|
1304
1315
|
const endSession = (identity) => {
|
|
1305
1316
|
projections.delete(sessionKey({ ...identity, requestId: "session-end", input: "" }));
|
|
1306
1317
|
};
|
|
1307
|
-
return Object.freeze({ mode, capabilities, connectOnce, beforeModel, beforeTool, afterTool, endSession, getProjection: (identity) => projections.get(sessionKey({ ...identity, requestId: "projection", input: "" })), supportsPostModelVerification: capabilities.canInterceptResponseBeforeDisplay });
|
|
1318
|
+
return Object.freeze({ mode, capabilities, connectOnce, getConnectionIdentity: () => connectionIdentity, beforeModel, beforeTool, afterTool, endSession, getProjection: (identity) => projections.get(sessionKey({ ...identity, requestId: "projection", input: "" })), supportsPostModelVerification: capabilities.canInterceptResponseBeforeDisplay });
|
|
1308
1319
|
}
|
|
1309
1320
|
export {
|
|
1310
1321
|
ViraApiError,
|
package/dist/js-client.d.ts
CHANGED
|
@@ -368,6 +368,7 @@ export declare class ViraClient {
|
|
|
368
368
|
} | null>;
|
|
369
369
|
authorizeHostAction(input: {
|
|
370
370
|
executionId: string;
|
|
371
|
+
sessionId: string;
|
|
371
372
|
scope: {
|
|
372
373
|
organizationId: string;
|
|
373
374
|
projectId: string;
|
|
@@ -375,6 +376,7 @@ export declare class ViraClient {
|
|
|
375
376
|
};
|
|
376
377
|
context: Record<string, unknown>;
|
|
377
378
|
proposal: Record<string, unknown>;
|
|
379
|
+
approval?: Record<string, unknown>;
|
|
378
380
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
379
381
|
listBehaviorStrategies(): Promise<ViraResponse<ClientBody> | null>;
|
|
380
382
|
deleteBehaviorStrategy(strategyId: string, options?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryvira/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
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"},
|