@tryvira/sdk 0.1.67 → 0.1.69

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/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @tryvira/sdk
2
2
 
3
+ Canonical integration helpers use verb-noun names such as `connectAiSystem`,
4
+ `recordUserFeedback`, and `recordBusinessOutcome`. The older `connectOnce`,
5
+ `feedback`, and `outcome` methods remain supported as source-compatible aliases.
6
+
3
7
  The official JavaScript and TypeScript client for Vira. Use it to connect an AI
4
8
  application, record observations, author governed behavior, evaluate changes, release
5
9
  approved behavior, and resolve it at runtime.
package/dist/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  // ../../sdks/js-client.ts
2
+ var listQuery = (options) => ({
3
+ ...options.limit === void 0 ? {} : { limit: String(options.limit) },
4
+ ...options.cursor ? { cursor: options.cursor } : {},
5
+ ...options.status ? { status: options.status } : {},
6
+ ...options.search ? { search: options.search } : {}
7
+ });
2
8
  var ViraApiError = class extends Error {
3
9
  status;
4
10
  body;
@@ -222,8 +228,8 @@ var ViraClient = class {
222
228
  idempotencyKey: input.idempotencyKey
223
229
  });
224
230
  }
225
- listAISystems() {
226
- return this.request({ method: "GET", path: "/v1/ai-systems" });
231
+ listAISystems(options = {}) {
232
+ return this.request({ method: "GET", path: "/v1/ai-systems", query: listQuery(options) });
227
233
  }
228
234
  async deleteAISystem(systemId, options = {}) {
229
235
  required(systemId, "SDK_SYSTEM_ID_REQUIRED");
@@ -312,6 +318,10 @@ var ViraClient = class {
312
318
  }
313
319
  };
314
320
  }
321
+ /** Canonical verb-noun name; connectOnce remains for source compatibility. */
322
+ connectAiSystem(input) {
323
+ return this.connectOnce(input);
324
+ }
315
325
  observe(event, options = {}) {
316
326
  buildObservationRequest(event);
317
327
  return (async () => {
@@ -341,6 +351,12 @@ var ViraClient = class {
341
351
  feedback(event, options = {}) {
342
352
  return this.observe({ ...event, eventType: "feedback.user" }, options);
343
353
  }
354
+ recordBusinessOutcome(event, options = {}) {
355
+ return this.outcome(event, options);
356
+ }
357
+ recordUserFeedback(event, options = {}) {
358
+ return this.feedback(event, options);
359
+ }
344
360
  observeBatch(events, options = {}) {
345
361
  if (!Array.isArray(events) || events.length < 1 || events.length > 100)
346
362
  throw new Error("SDK_OBSERVATION_BATCH_INVALID");
@@ -421,10 +437,11 @@ var ViraClient = class {
421
437
  path: `/v1/ai-systems/${encodeURIComponent(systemId)}/inventory`
422
438
  });
423
439
  }
424
- listPacks() {
440
+ listPacks(options = {}) {
425
441
  return this.request({
426
442
  method: "GET",
427
- path: "/v1/packs"
443
+ path: "/v1/packs",
444
+ query: listQuery(options)
428
445
  });
429
446
  }
430
447
  async deletePack(packId, options = {}) {
@@ -630,10 +647,11 @@ var ViraClient = class {
630
647
  required(input.confirmation.acknowledgedAt, "SDK_ACTION_CONFIRMATION_TIME_REQUIRED");
631
648
  return this.request({ method: "POST", path: "/v1/runtime/actions/approvals", body: { sessionId: input.sessionId, dataVersion: input.dataVersion, proposal: input.proposal, confirmation: input.confirmation, ...input.ttlSeconds !== void 0 ? { ttlSeconds: input.ttlSeconds } : {} } });
632
649
  }
633
- listBehaviorStrategies() {
650
+ listBehaviorStrategies(options = {}) {
634
651
  return this.request({
635
652
  method: "GET",
636
- path: "/v1/behavior-strategies"
653
+ path: "/v1/behavior-strategies",
654
+ query: listQuery(options)
637
655
  });
638
656
  }
639
657
  async deleteBehaviorStrategy(strategyId, options = {}) {
@@ -656,8 +674,8 @@ var ViraClient = class {
656
674
  body: { definition, ...id ? { id } : {} }
657
675
  });
658
676
  }
659
- listSemanticTasks() {
660
- return this.request({ method: "GET", path: "/v1/semantic-tasks" });
677
+ listSemanticTasks(options = {}) {
678
+ return this.request({ method: "GET", path: "/v1/semantic-tasks", query: listQuery(options) });
661
679
  }
662
680
  async deleteSemanticTask(taskId, options = {}) {
663
681
  required(taskId, "SDK_SEMANTIC_TASK_ID_REQUIRED");
@@ -669,8 +687,8 @@ var ViraClient = class {
669
687
  const body = { ...task, ...options.id ? { id: options.id } : {} };
670
688
  return this.request({ method: "POST", path: "/v1/semantic-tasks", body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:semantic-task:${task.taskKey}`, body) });
671
689
  }
672
- listBehaviorPoints() {
673
- return this.request({ method: "GET", path: "/v1/behavior-points" });
690
+ listBehaviorPoints(options = {}) {
691
+ return this.request({ method: "GET", path: "/v1/behavior-points", query: listQuery(options) });
674
692
  }
675
693
  async deleteBehaviorPoint(pointId, options = {}) {
676
694
  required(pointId, "SDK_BEHAVIOR_POINT_ID_REQUIRED");
@@ -825,10 +843,11 @@ var ViraClient = class {
825
843
  if (!Number.isInteger(expectedVersion) || expectedVersion < 0) throw new Error("SDK_TASKRUN_STATE_VERSION_REQUIRED");
826
844
  return this.request({ method: "POST", path: `/v1/task-runs/${encodeURIComponent(taskRunId)}/retry`, body: { expectedVersion } }, { idempotencyKey: options.idempotencyKey ?? `sdk:task-run:retry:${taskRunId}:${expectedVersion}` });
827
845
  }
828
- listBehaviorPrograms() {
846
+ listBehaviorPrograms(options = {}) {
829
847
  return this.request({
830
848
  method: "GET",
831
- path: "/v1/behavior-programs"
849
+ path: "/v1/behavior-programs",
850
+ query: listQuery(options)
832
851
  });
833
852
  }
834
853
  listCapabilities(options = {}) {
@@ -8,7 +8,7 @@ export interface RuntimeRequest {
8
8
  expiresAt: number;
9
9
  }
10
10
  export interface SdkRequest {
11
- method: "GET" | "POST" | "DELETE";
11
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
12
12
  path: string;
13
13
  query?: Readonly<Record<string, string>>;
14
14
  body?: Readonly<Record<string, unknown>>;
@@ -54,6 +54,12 @@ export interface RuntimeResolution {
54
54
  [key: string]: unknown;
55
55
  }
56
56
  export type TaskRunMode = "SINGLE" | "STRATEGY" | "COMPOUND" | "HYBRID";
57
+ export interface ScopedListOptions {
58
+ limit?: number;
59
+ cursor?: string;
60
+ status?: string;
61
+ search?: string;
62
+ }
57
63
  export type TaskRunRequestedMode = TaskRunMode | "AUTO";
58
64
  export interface TaskRunChildMode {
59
65
  semanticTaskKey: string;
@@ -186,7 +192,7 @@ type ClientObservation = ClientObservationScope & {
186
192
  };
187
193
  export interface ViraHttpRequestOptions {
188
194
  apiKey?: string;
189
- method: "GET" | "POST" | "DELETE";
195
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
190
196
  body?: unknown;
191
197
  idempotencyKey?: string;
192
198
  fetcher?: typeof fetch;
@@ -221,7 +227,7 @@ export declare class ViraClient {
221
227
  }): Promise<ViraResponse<{
222
228
  system: ClientBody;
223
229
  }> | null>;
224
- listAISystems(): Promise<ViraResponse<ClientBody> | null>;
230
+ listAISystems(options?: ScopedListOptions): Promise<ViraResponse<ClientBody> | null>;
225
231
  deleteAISystem(systemId: string, options?: {
226
232
  confirm?: boolean;
227
233
  idempotencyKey?: string;
@@ -257,6 +263,8 @@ export declare class ViraClient {
257
263
  idempotencyKey?: string;
258
264
  reuseExistingConnectionOnConflict?: boolean;
259
265
  }): Promise<ViraResponse<ConnectOnceResult> | null>;
266
+ /** Canonical verb-noun name; connectOnce remains for source compatibility. */
267
+ connectAiSystem(input: Parameters<ViraClient['connectOnce']>[0]): Promise<ViraResponse<ConnectOnceResult> | null>;
260
268
  observe(event: ClientObservation, options?: {
261
269
  idempotencyKey?: string;
262
270
  }): Promise<ViraResponse<ClientBody> | null>;
@@ -292,6 +300,12 @@ export declare class ViraClient {
292
300
  }, options?: {
293
301
  idempotencyKey?: string;
294
302
  }): Promise<ViraResponse<ClientBody> | null>;
303
+ recordBusinessOutcome(event: Parameters<ViraClient['outcome']>[0], options?: {
304
+ idempotencyKey?: string;
305
+ }): Promise<ViraResponse<ClientBody> | null>;
306
+ recordUserFeedback(event: Parameters<ViraClient['feedback']>[0], options?: {
307
+ idempotencyKey?: string;
308
+ }): Promise<ViraResponse<ClientBody> | null>;
295
309
  observeBatch(events: readonly (ClientObservationScope & {
296
310
  eventId: string;
297
311
  eventType: string;
@@ -327,7 +341,7 @@ export declare class ViraClient {
327
341
  getConnection(connectionId: string): Promise<ViraResponse<ClientBody> | null>;
328
342
  listSystemConnections(systemId: string): Promise<ViraResponse<ClientBody> | null>;
329
343
  inventory(systemId: string): Promise<ViraResponse<ClientBody> | null>;
330
- listPacks(): Promise<ViraResponse<{
344
+ listPacks(options?: ScopedListOptions): Promise<ViraResponse<{
331
345
  packs: readonly ClientBody[];
332
346
  }> | null>;
333
347
  deletePack(packId: string, options?: {
@@ -431,14 +445,14 @@ export declare class ViraClient {
431
445
  };
432
446
  ttlSeconds?: number;
433
447
  }): Promise<ViraResponse<ClientBody> | null>;
434
- listBehaviorStrategies(): Promise<ViraResponse<ClientBody> | null>;
448
+ listBehaviorStrategies(options?: ScopedListOptions): Promise<ViraResponse<ClientBody> | null>;
435
449
  deleteBehaviorStrategy(strategyId: string, options?: {
436
450
  confirm?: boolean;
437
451
  idempotencyKey?: string;
438
452
  }): Promise<ViraResponse<ClientBody> | null>;
439
453
  getBehaviorStrategy(strategyId: string): Promise<ViraResponse<ClientBody> | null>;
440
454
  createBehaviorStrategy(definition: Record<string, unknown>, id?: string): Promise<ViraResponse<ClientBody> | null>;
441
- listSemanticTasks(): Promise<ViraResponse<ClientBody> | null>;
455
+ listSemanticTasks(options?: ScopedListOptions): Promise<ViraResponse<ClientBody> | null>;
442
456
  deleteSemanticTask(taskId: string, options?: {
443
457
  confirm?: boolean;
444
458
  idempotencyKey?: string;
@@ -454,7 +468,7 @@ export declare class ViraClient {
454
468
  id?: string;
455
469
  idempotencyKey?: string;
456
470
  }): Promise<ViraResponse<ClientBody> | null>;
457
- listBehaviorPoints(): Promise<ViraResponse<ClientBody> | null>;
471
+ listBehaviorPoints(options?: ScopedListOptions): Promise<ViraResponse<ClientBody> | null>;
458
472
  deleteBehaviorPoint(pointId: string, options?: {
459
473
  confirm?: boolean;
460
474
  idempotencyKey?: string;
@@ -519,7 +533,7 @@ export declare class ViraClient {
519
533
  retryTaskRun(taskRunId: string, expectedVersion: number, options?: {
520
534
  idempotencyKey?: string;
521
535
  }): Promise<ViraResponse<ClientBody> | null>;
522
- listBehaviorPrograms(): Promise<ViraResponse<{
536
+ listBehaviorPrograms(options?: ScopedListOptions): Promise<ViraResponse<{
523
537
  programs: readonly ClientBody[];
524
538
  }> | null>;
525
539
  listCapabilities(options?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/sdk",
3
- "version": "0.1.67",
3
+ "version": "0.1.69",
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"},