@tryvira/sdk 0.1.47 → 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
@@ -472,11 +472,13 @@ var ViraClient = class {
472
472
  semanticContext: {
473
473
  taskKey: receipt.taskKey,
474
474
  behaviorPoint,
475
- capsule: firstCapsule
475
+ capsule: firstCapsule,
476
+ ...input.requestId ? { requestId: input.requestId } : {},
477
+ ...input.sessionId ? { conversationId: input.sessionId } : {}
476
478
  },
477
479
  idempotencyKey: input.idempotencyKey ? `sdk:runtime:${input.idempotencyKey}` : void 0
478
480
  }) : await this.resolveRuntime({
479
- semanticContext: { taskKey: receipt.taskKey, behaviorPoint, capsule: firstCapsule },
481
+ semanticContext: { taskKey: receipt.taskKey, behaviorPoint, capsule: firstCapsule, ...input.requestId ? { requestId: input.requestId } : {}, ...input.sessionId ? { conversationId: input.sessionId } : {} },
480
482
  idempotencyKey: input.idempotencyKey ? `sdk:runtime:${input.idempotencyKey}` : void 0
481
483
  });
482
484
  return { semantic, runtime };
@@ -1248,10 +1250,20 @@ function createViraHostRuntime(client, config) {
1248
1250
  if (mode === "enforce" && (!capabilities.canInterceptToolBefore || !capabilities.canPreventSideEffect)) throw new Error("SDK_HOST_ENFORCE_CAPABILITY_REQUIRED");
1249
1251
  if (mode === "enforce" && typeof config.authorizeAction !== "function") throw new Error("SDK_HOST_ACTION_AUTHORIZER_REQUIRED");
1250
1252
  let connected = null;
1253
+ let connectionIdentity = null;
1251
1254
  const projections = /* @__PURE__ */ new Map();
1252
1255
  const connectOnce = async () => {
1253
1256
  if (mode === "off" || !config.connect) return null;
1254
- 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
+ });
1255
1267
  return connected;
1256
1268
  };
1257
1269
  const sessionKey = (request) => `${request.organizationId}:${request.projectId}:${request.environmentId}:${request.conversationId}`;
@@ -1302,7 +1314,7 @@ function createViraHostRuntime(client, config) {
1302
1314
  const endSession = (identity) => {
1303
1315
  projections.delete(sessionKey({ ...identity, requestId: "session-end", input: "" }));
1304
1316
  };
1305
- 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 });
1306
1318
  }
1307
1319
  export {
1308
1320
  ViraApiError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/sdk",
3
- "version": "0.1.47",
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"},