@tryvira/sdk 0.1.48 → 0.1.49

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.
@@ -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
@@ -1250,10 +1250,20 @@ function createViraHostRuntime(client, config) {
1250
1250
  if (mode === "enforce" && (!capabilities.canInterceptToolBefore || !capabilities.canPreventSideEffect)) throw new Error("SDK_HOST_ENFORCE_CAPABILITY_REQUIRED");
1251
1251
  if (mode === "enforce" && typeof config.authorizeAction !== "function") throw new Error("SDK_HOST_ACTION_AUTHORIZER_REQUIRED");
1252
1252
  let connected = null;
1253
+ let connectionIdentity = null;
1253
1254
  const projections = /* @__PURE__ */ new Map();
1254
1255
  const connectOnce = async () => {
1255
1256
  if (mode === "off" || !config.connect) return null;
1256
- if (!connected) connected = withTimeout(client.connectOnce(config.connect), timeoutMs, "SDK_HOST_CONNECT_TIMEOUT");
1257
+ if (!connected) connected = withTimeout(client.connectOnce(config.connect), timeoutMs, "SDK_HOST_CONNECT_TIMEOUT").then((result) => {
1258
+ const body = bodyOf(result);
1259
+ const system = body.system && typeof body.system === "object" ? body.system : {};
1260
+ const connection = body.connection && typeof body.connection === "object" ? body.connection : {};
1261
+ const aiSystemId = typeof system.id === "string" ? system.id.trim() : "";
1262
+ const connectionId = typeof connection.id === "string" ? connection.id.trim() : "";
1263
+ if (!aiSystemId || !connectionId) throw new Error("SDK_HOST_CONNECT_IDENTITY_MISSING");
1264
+ connectionIdentity = { aiSystemId, connectionId };
1265
+ return result;
1266
+ });
1257
1267
  return connected;
1258
1268
  };
1259
1269
  const sessionKey = (request) => `${request.organizationId}:${request.projectId}:${request.environmentId}:${request.conversationId}`;
@@ -1304,7 +1314,7 @@ function createViraHostRuntime(client, config) {
1304
1314
  const endSession = (identity) => {
1305
1315
  projections.delete(sessionKey({ ...identity, requestId: "session-end", input: "" }));
1306
1316
  };
1307
- return Object.freeze({ mode, capabilities, connectOnce, beforeModel, beforeTool, afterTool, endSession, getProjection: (identity) => projections.get(sessionKey({ ...identity, requestId: "projection", input: "" })), supportsPostModelVerification: capabilities.canInterceptResponseBeforeDisplay });
1317
+ 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
1318
  }
1309
1319
  export {
1310
1320
  ViraApiError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/sdk",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
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"},