@tryvira/sdk 0.1.42 → 0.1.44
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 +63 -1
- package/dist/framework-adapters.d.ts +83 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +228 -70
- package/dist/js-client.d.ts +69 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ approved behavior, and resolve it at runtime.
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @tryvira/sdk@0.1.
|
|
10
|
+
npm install @tryvira/sdk@0.1.44
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Configure the organization, project, and environment for every request. Keep the API
|
|
@@ -125,11 +125,73 @@ await vira.approvePack(packId);
|
|
|
125
125
|
await vira.releasePack(packId);
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
+
If a governed TaskRun is paused, use `continueTaskRun`. If a run is `FAILED`,
|
|
129
|
+
`BLOCKED`, or `PARTIAL`, `retryTaskRun` reuses the server-owned immutable plan
|
|
130
|
+
and queues a new execution. Both operations require the current state version;
|
|
131
|
+
completed and cancelled runs cannot be retried.
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
await vira.continueTaskRun("monthly-report-001", stateVersion, { cursor: "approval-1" });
|
|
135
|
+
await vira.retryTaskRun("monthly-report-001", stateVersion);
|
|
136
|
+
```
|
|
137
|
+
|
|
128
138
|
Never submit a client-created `passed`, `score`, or receipt as release evidence. Vira
|
|
129
139
|
binds evaluation to the materialized Pack digest and immutable release identity. Use
|
|
130
140
|
`previewPackUpgrade` before changing an installed Pack so conflicts and preserved
|
|
131
141
|
overrides are visible first.
|
|
132
142
|
|
|
143
|
+
## Resolve and admit a TaskRun
|
|
144
|
+
|
|
145
|
+
TaskRun routing is server-owned and AUTO is the normal path. Submit the user intent
|
|
146
|
+
with `startTaskRunFromPrompt`; Vira selects a released canonical Task and the
|
|
147
|
+
concrete SINGLE, STRATEGY, COMPOUND, or HYBRID execution mode. The server owns the
|
|
148
|
+
actor, host capabilities, effect classes, and plan authority. This route does not
|
|
149
|
+
invent a Behavior Point, grant tools, or publish a Strategy/Compound artifact.
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
const route = await vira.resolveTaskRun({
|
|
153
|
+
input: "Prepare a customer report and send it for approval",
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (route.body.route !== "ROUTED") {
|
|
157
|
+
// NEEDS_CLARIFICATION, ABSTAIN, DENIED, and UNSUPPORTED_HOST are safe outcomes.
|
|
158
|
+
return route.body;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const admitted = await vira.startTaskRunFromPrompt({
|
|
162
|
+
input: "Prepare a customer report and send it for approval",
|
|
163
|
+
budget: { maxChildren: 4, maxCalls: 6, maxCostMicros: 50000 },
|
|
164
|
+
}, { idempotencyKey: "task-run:customer-report-request-001" });
|
|
165
|
+
|
|
166
|
+
// requestedMode, hybridPlan, hostCapabilities and ownerActorRef remain available
|
|
167
|
+
// as advanced/legacy overrides, but are not needed for the normal integration.
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
After `connectOnce`, the SDK binds the returned connection to later TaskRuns.
|
|
171
|
+
The server then resolves that connected host's verified capability attestation;
|
|
172
|
+
the application does not need to copy an attestation ID into each prompt. If
|
|
173
|
+
an application intentionally manages more than one connection, it may provide
|
|
174
|
+
`connectionId` on the request or in the client options so the server can select
|
|
175
|
+
the correct host while preserving scope checks.
|
|
176
|
+
|
|
177
|
+
`resolveTaskRun` is a proposal-only read. `startTaskRun` is an admission mutation
|
|
178
|
+
and remains subject to the server’s scope, authority, artifact, budget, and release
|
|
179
|
+
gates. If the run pauses, use the persisted state version for continuation or
|
|
180
|
+
cancellation; never guess a version or patch arbitrary state:
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
const current = await vira.getTaskRun("customer-report-run-001");
|
|
184
|
+
const version = Number(current.body.taskRun.stateVersion);
|
|
185
|
+
await vira.continueTaskRun("customer-report-run-001", version, {
|
|
186
|
+
cursor: "approval-answer-001",
|
|
187
|
+
idempotencyKey: "task-run:continue:approval-answer-001",
|
|
188
|
+
});
|
|
189
|
+
await vira.cancelTaskRun("customer-report-run-001", version, {
|
|
190
|
+
idempotencyKey: "task-run:cancel:customer-report-run-001",
|
|
191
|
+
});
|
|
192
|
+
const events = await vira.listTaskRunEvents("customer-report-run-001");
|
|
193
|
+
```
|
|
194
|
+
|
|
133
195
|
## Errors and retries
|
|
134
196
|
|
|
135
197
|
- Send an idempotency key with mutations.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ViraClient } from './js-client.ts';
|
|
2
|
+
export type FrameworkAdapterName = 'openai-agents' | 'vercel-ai' | 'langchain' | 'langgraph' | 'otel' | 'mcp';
|
|
3
|
+
export type FrameworkExecutionMode = 'observe' | 'enforce';
|
|
4
|
+
export interface FrameworkEvent {
|
|
5
|
+
eventId: string;
|
|
6
|
+
aiSystemId: string;
|
|
7
|
+
connectionId: string;
|
|
8
|
+
organizationId: string;
|
|
9
|
+
projectId: string;
|
|
10
|
+
environmentId: string;
|
|
11
|
+
eventType?: string;
|
|
12
|
+
traceId?: string;
|
|
13
|
+
spanId?: string;
|
|
14
|
+
payload?: unknown;
|
|
15
|
+
attributes?: unknown;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
export interface FrameworkObservationAdapter {
|
|
19
|
+
readonly framework: FrameworkAdapterName;
|
|
20
|
+
observe(event: FrameworkEvent, kind: 'trace' | 'outcome' | 'feedback' | 'observation'): Promise<unknown> | unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface FrameworkLifecycleAdapter extends FrameworkObservationAdapter {
|
|
23
|
+
resolveBoundary(input: {
|
|
24
|
+
executionBoundary: Record<string, unknown>;
|
|
25
|
+
semanticContext?: Record<string, unknown>;
|
|
26
|
+
idempotencyKey?: string;
|
|
27
|
+
}): Promise<unknown>;
|
|
28
|
+
start(event: FrameworkEvent): Promise<unknown> | unknown;
|
|
29
|
+
complete(event: FrameworkEvent): Promise<unknown> | unknown;
|
|
30
|
+
error(event: FrameworkEvent & {
|
|
31
|
+
errorCode?: string;
|
|
32
|
+
}): Promise<unknown> | unknown;
|
|
33
|
+
toolStart(event: FrameworkEvent & {
|
|
34
|
+
toolRef: string;
|
|
35
|
+
}): Promise<unknown> | unknown;
|
|
36
|
+
toolComplete(event: FrameworkEvent & {
|
|
37
|
+
toolRef: string;
|
|
38
|
+
resultDigest?: string;
|
|
39
|
+
}): Promise<unknown> | unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface RuntimeHookRequest {
|
|
42
|
+
executionBoundary?: Record<string, unknown>;
|
|
43
|
+
semanticContext?: Record<string, unknown>;
|
|
44
|
+
behaviorPoint?: string;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
export interface RuntimeHookResult {
|
|
48
|
+
resolution: unknown;
|
|
49
|
+
request: RuntimeHookRequest;
|
|
50
|
+
behaviorPoint?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Shared boundary-aware resolver used by every TypeScript framework bridge. */
|
|
53
|
+
export declare function resolveFrameworkBoundary(client: ViraClient, request: RuntimeHookRequest): Promise<RuntimeHookResult>;
|
|
54
|
+
export interface RuntimeHooks {
|
|
55
|
+
resolve(request: RuntimeHookRequest): Promise<RuntimeHookResult>;
|
|
56
|
+
onStart(request: RuntimeHookRequest): Promise<RuntimeHookResult>;
|
|
57
|
+
enrichTrace<T extends Record<string, unknown>>(trace: T, routed: RuntimeHookResult): T & {
|
|
58
|
+
behaviorPoint: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export declare function createGenericRuntimeHooks(client: ViraClient): RuntimeHooks;
|
|
62
|
+
export declare const createOpenAIAgentsHooks: typeof createGenericRuntimeHooks;
|
|
63
|
+
export declare const createLangGraphHooks: typeof createGenericRuntimeHooks;
|
|
64
|
+
export declare const createGenericHttpHooks: typeof createGenericRuntimeHooks;
|
|
65
|
+
export declare const createOpenAICompatibleHooks: typeof createGenericRuntimeHooks;
|
|
66
|
+
export declare const createMastraHooks: typeof createGenericRuntimeHooks;
|
|
67
|
+
export declare const createVercelAIHooks: typeof createGenericRuntimeHooks;
|
|
68
|
+
/** Vercel AI middleware bridge; never discards the boundary route. */
|
|
69
|
+
export declare function createViraMiddleware(client: ViraClient): Readonly<{
|
|
70
|
+
resolve: (request: RuntimeHookRequest) => Promise<RuntimeHookResult>;
|
|
71
|
+
onRequest: (request: RuntimeHookRequest) => Promise<RuntimeHookResult>;
|
|
72
|
+
enrichTrace: <T extends Record<string, unknown>>(trace: T, routed: RuntimeHookResult) => T & {
|
|
73
|
+
behaviorPoint: string;
|
|
74
|
+
};
|
|
75
|
+
}>;
|
|
76
|
+
/** Maps framework callbacks into the existing ViraClient authority boundary. */
|
|
77
|
+
export declare function createFrameworkObservationAdapter(client: ViraClient, framework: FrameworkAdapterName): FrameworkObservationAdapter;
|
|
78
|
+
export declare function createFrameworkLifecycleAdapter(client: ViraClient, framework: FrameworkAdapterName, options?: {
|
|
79
|
+
mode?: FrameworkExecutionMode;
|
|
80
|
+
}): FrameworkLifecycleAdapter & {
|
|
81
|
+
readonly mode: FrameworkExecutionMode;
|
|
82
|
+
};
|
|
83
|
+
export declare function createFrameworkAdapters(client: ViraClient): Readonly<Record<FrameworkAdapterName, FrameworkObservationAdapter>>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -15,6 +15,31 @@ var required = (value, code) => {
|
|
|
15
15
|
if (typeof value !== "string" || !value.trim()) throw new Error(code);
|
|
16
16
|
return value;
|
|
17
17
|
};
|
|
18
|
+
var normalizeBaseUrl = (value, allowInsecureLocalhost = false) => {
|
|
19
|
+
let url;
|
|
20
|
+
try {
|
|
21
|
+
url = new URL(required(value, "SDK_BASE_URL_REQUIRED"));
|
|
22
|
+
} catch {
|
|
23
|
+
throw new Error("SDK_BASE_URL_INVALID");
|
|
24
|
+
}
|
|
25
|
+
const hostname = url.hostname.toLowerCase();
|
|
26
|
+
const loopback = hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
27
|
+
if (url.username || url.password || url.search || url.hash) throw new Error("SDK_BASE_URL_INVALID");
|
|
28
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback && allowInsecureLocalhost))
|
|
29
|
+
throw new Error("SDK_HTTPS_REQUIRED");
|
|
30
|
+
return value.replace(/\/$/, "");
|
|
31
|
+
};
|
|
32
|
+
var canonicalJson = (value) => JSON.stringify(
|
|
33
|
+
value,
|
|
34
|
+
(_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([left], [right]) => left.localeCompare(right))) : item
|
|
35
|
+
);
|
|
36
|
+
var contentIdempotencyKey = async (operation, request) => {
|
|
37
|
+
if (!globalThis.crypto?.subtle) throw new Error("SDK_IDEMPOTENCY_CRYPTO_UNAVAILABLE");
|
|
38
|
+
const bytes = new TextEncoder().encode(canonicalJson(request));
|
|
39
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
40
|
+
const hex = [...new Uint8Array(digest)].map((value) => value.toString(16).padStart(2, "0")).join("");
|
|
41
|
+
return `${operation}:${hex}`;
|
|
42
|
+
};
|
|
18
43
|
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
19
44
|
var ViraClient = class {
|
|
20
45
|
evaluations;
|
|
@@ -27,11 +52,9 @@ var ViraClient = class {
|
|
|
27
52
|
retries;
|
|
28
53
|
failureMode;
|
|
29
54
|
defaultHeaders;
|
|
55
|
+
boundConnectionId;
|
|
30
56
|
constructor(options) {
|
|
31
|
-
this.baseUrl =
|
|
32
|
-
/\/$/,
|
|
33
|
-
""
|
|
34
|
-
);
|
|
57
|
+
this.baseUrl = normalizeBaseUrl(options.baseUrl, options.allowInsecureLocalhost === true);
|
|
35
58
|
this.apiKey = options.apiKey;
|
|
36
59
|
this.fetcher = options.fetcher ?? fetch;
|
|
37
60
|
this.timeoutMs = Math.max(
|
|
@@ -41,6 +64,7 @@ var ViraClient = class {
|
|
|
41
64
|
this.retries = Math.max(0, Math.min(options.retries ?? 2, 5));
|
|
42
65
|
this.failureMode = options.failureMode ?? "throw";
|
|
43
66
|
this.defaultHeaders = options.defaultHeaders ?? {};
|
|
67
|
+
this.boundConnectionId = options.connectionId;
|
|
44
68
|
this.evaluations = {
|
|
45
69
|
createPlan: (input, options2 = {}) => this.createEvaluationPlan(input, options2),
|
|
46
70
|
get: (id) => this.getEvaluation(id),
|
|
@@ -139,13 +163,15 @@ var ViraClient = class {
|
|
|
139
163
|
listAISystems() {
|
|
140
164
|
return this.request({ method: "GET", path: "/v1/ai-systems" });
|
|
141
165
|
}
|
|
142
|
-
deleteAISystem(systemId, options = {}) {
|
|
166
|
+
async deleteAISystem(systemId, options = {}) {
|
|
143
167
|
required(systemId, "SDK_SYSTEM_ID_REQUIRED");
|
|
144
|
-
|
|
168
|
+
const path = `/v1/ai-systems/${encodeURIComponent(systemId)}`, body = { confirm: options.confirm === true };
|
|
169
|
+
return this.request({ method: "DELETE", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:delete:ai-system:${systemId}`, { path, body }) });
|
|
145
170
|
}
|
|
146
|
-
deleteAISystemCascade(systemId, options = {}) {
|
|
171
|
+
async deleteAISystemCascade(systemId, options = {}) {
|
|
147
172
|
required(systemId, "SDK_SYSTEM_ID_REQUIRED");
|
|
148
|
-
|
|
173
|
+
const path = `/v1/ai-systems/${encodeURIComponent(systemId)}/cleanup`, body = { confirm: options.confirm === true, deleteObservations: options.deleteObservations === true };
|
|
174
|
+
return this.request({ method: "DELETE", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:delete:ai-system-cascade:${systemId}`, { path, body }) });
|
|
149
175
|
}
|
|
150
176
|
getAISystem(systemId) {
|
|
151
177
|
required(systemId, "SDK_SYSTEM_ID_REQUIRED");
|
|
@@ -180,6 +206,8 @@ var ViraClient = class {
|
|
|
180
206
|
idempotencyKey: input.idempotencyKey
|
|
181
207
|
});
|
|
182
208
|
if (!connectionResult) return null;
|
|
209
|
+
const connectedId = String(connectionResult.body.connection?.id ?? "").trim();
|
|
210
|
+
if (connectedId) this.boundConnectionId = connectedId;
|
|
183
211
|
return {
|
|
184
212
|
status: connectionResult.status,
|
|
185
213
|
requestId: connectionResult.requestId,
|
|
@@ -236,27 +264,30 @@ var ViraClient = class {
|
|
|
236
264
|
query: reviewState ? { reviewState } : void 0
|
|
237
265
|
});
|
|
238
266
|
}
|
|
239
|
-
createSignalDiscoveryProposal(input, options = {}) {
|
|
240
|
-
return this.request({ method: "POST", path: "/v1/signals/discovery-proposals", body: input }, { idempotencyKey: options.idempotencyKey ??
|
|
267
|
+
async createSignalDiscoveryProposal(input, options = {}) {
|
|
268
|
+
return this.request({ method: "POST", path: "/v1/signals/discovery-proposals", body: input }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey("sdk:signal-discovery-proposal", input) });
|
|
241
269
|
}
|
|
242
|
-
reviewSignalDiscoveryProposal(proposalId, decision, options = {}) {
|
|
270
|
+
async reviewSignalDiscoveryProposal(proposalId, decision, options = {}) {
|
|
243
271
|
required(proposalId, "SDK_SIGNAL_PROPOSAL_ID_REQUIRED");
|
|
244
|
-
|
|
272
|
+
const path = `/v1/signals/discovery-proposals/${encodeURIComponent(proposalId)}/review`, body = { decision };
|
|
273
|
+
return this.request({ method: "POST", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`signal-review:${proposalId}`, body) });
|
|
245
274
|
}
|
|
246
|
-
materializeSignalDiscovery(proposalId, input = {}, options = {}) {
|
|
275
|
+
async materializeSignalDiscovery(proposalId, input = {}, options = {}) {
|
|
247
276
|
required(proposalId, "SDK_SIGNAL_PROPOSAL_ID_REQUIRED");
|
|
248
|
-
|
|
277
|
+
const path = `/v1/signals/discovery-proposals/${encodeURIComponent(proposalId)}/materialize`;
|
|
278
|
+
return this.request({ method: "POST", path, body: input }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`signal-materialize:${proposalId}`, input) });
|
|
249
279
|
}
|
|
250
|
-
createSignalMapping(input, options = {}) {
|
|
251
|
-
return this.request({ method: "POST", path: "/v1/signals/mappings", body: input }, { idempotencyKey: options.idempotencyKey ??
|
|
280
|
+
async createSignalMapping(input, options = {}) {
|
|
281
|
+
return this.request({ method: "POST", path: "/v1/signals/mappings", body: input }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey("sdk:signal-mapping", input) });
|
|
252
282
|
}
|
|
253
283
|
getSignalMapping(mappingId) {
|
|
254
284
|
required(mappingId, "SDK_SIGNAL_MAPPING_ID_REQUIRED");
|
|
255
285
|
return this.request({ method: "GET", path: `/v1/signals/mappings/${encodeURIComponent(mappingId)}` });
|
|
256
286
|
}
|
|
257
|
-
reviewSignalMapping(mappingId, input = {}, options = {}) {
|
|
287
|
+
async reviewSignalMapping(mappingId, input = {}, options = {}) {
|
|
258
288
|
required(mappingId, "SDK_SIGNAL_MAPPING_ID_REQUIRED");
|
|
259
|
-
|
|
289
|
+
const path = `/v1/signals/mappings/${encodeURIComponent(mappingId)}/review`;
|
|
290
|
+
return this.request({ method: "POST", path, body: input }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`signal-mapping-review:${mappingId}`, input) });
|
|
260
291
|
}
|
|
261
292
|
connectionHealth(connectionId) {
|
|
262
293
|
required(connectionId, "SDK_CONNECTION_ID_REQUIRED");
|
|
@@ -292,52 +323,48 @@ var ViraClient = class {
|
|
|
292
323
|
path: "/v1/packs"
|
|
293
324
|
});
|
|
294
325
|
}
|
|
295
|
-
deletePack(packId, options = {}) {
|
|
326
|
+
async deletePack(packId, options = {}) {
|
|
296
327
|
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
297
|
-
|
|
328
|
+
const path = `/v1/packs/${encodeURIComponent(packId)}`;
|
|
329
|
+
const body = { confirm: options.confirm === true };
|
|
330
|
+
return this.request({ method: "DELETE", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:delete:pack:${packId}`, { path, body }) });
|
|
298
331
|
}
|
|
299
|
-
importPack(input) {
|
|
332
|
+
async importPack(input) {
|
|
300
333
|
if (!input?.manifest && !input?.archiveBase64)
|
|
301
334
|
throw new Error("SDK_PACK_MANIFEST_OR_ARCHIVE_REQUIRED");
|
|
302
335
|
if (input.archiveBase64 && !input.fileName)
|
|
303
336
|
throw new Error("SDK_PACK_FILE_NAME_REQUIRED");
|
|
337
|
+
const body = {
|
|
338
|
+
...input.manifest ? { manifest: input.manifest } : {},
|
|
339
|
+
objects: input.objects ?? {},
|
|
340
|
+
...input.archiveBase64 ? { archiveBase64: input.archiveBase64, fileName: input.fileName } : {}
|
|
341
|
+
};
|
|
304
342
|
return this.request(
|
|
305
343
|
{
|
|
306
344
|
method: "POST",
|
|
307
345
|
path: "/v1/packs/import",
|
|
308
|
-
body
|
|
309
|
-
...input.manifest ? { manifest: input.manifest } : {},
|
|
310
|
-
objects: input.objects ?? {},
|
|
311
|
-
...input.archiveBase64 ? { archiveBase64: input.archiveBase64, fileName: input.fileName } : {}
|
|
312
|
-
}
|
|
346
|
+
body
|
|
313
347
|
},
|
|
314
|
-
{ idempotencyKey: input.idempotencyKey ??
|
|
348
|
+
{ idempotencyKey: input.idempotencyKey ?? await contentIdempotencyKey("sdk:pack:import", body) }
|
|
315
349
|
);
|
|
316
350
|
}
|
|
317
|
-
installPack(packId, variables = {}) {
|
|
351
|
+
async installPack(packId, variables = {}) {
|
|
318
352
|
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
353
|
+
const path = `/v1/packs/${encodeURIComponent(packId)}/install`;
|
|
354
|
+
const body = { variables };
|
|
319
355
|
return this.request(
|
|
320
|
-
{
|
|
321
|
-
|
|
322
|
-
path: `/v1/packs/${encodeURIComponent(packId)}/install`,
|
|
323
|
-
body: { variables }
|
|
324
|
-
},
|
|
325
|
-
{ idempotencyKey: `sdk:pack:install:${packId}` }
|
|
356
|
+
{ method: "POST", path, body },
|
|
357
|
+
{ idempotencyKey: await contentIdempotencyKey(`sdk:pack:install:${packId}`, body) }
|
|
326
358
|
);
|
|
327
359
|
}
|
|
328
|
-
evaluatePack(packId, input) {
|
|
360
|
+
async evaluatePack(packId, input) {
|
|
329
361
|
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
330
362
|
required(input?.evaluationId, "SDK_EVALUATION_ID_REQUIRED");
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
path: `/v1/packs/${encodeURIComponent(packId)}/evaluate`,
|
|
335
|
-
body: { evaluationId: input.evaluationId }
|
|
336
|
-
},
|
|
337
|
-
{ idempotencyKey: `sdk:pack:evaluate:${packId}` }
|
|
338
|
-
);
|
|
363
|
+
const path = `/v1/packs/${encodeURIComponent(packId)}/evaluate`;
|
|
364
|
+
const body = { evaluationId: input.evaluationId };
|
|
365
|
+
return this.request({ method: "POST", path, body }, { idempotencyKey: await contentIdempotencyKey(`sdk:pack:evaluate:${packId}`, body) });
|
|
339
366
|
}
|
|
340
|
-
approvePack(packId, options = {}) {
|
|
367
|
+
async approvePack(packId, options = {}) {
|
|
341
368
|
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
342
369
|
const body = options.manualApproval ? { manualApproval: true, reason: required(options.reason ?? "", "SDK_MANUAL_PACK_APPROVAL_REASON_REQUIRED") } : {};
|
|
343
370
|
return this.request(
|
|
@@ -346,10 +373,10 @@ var ViraClient = class {
|
|
|
346
373
|
path: `/v1/packs/${encodeURIComponent(packId)}/approve`,
|
|
347
374
|
body
|
|
348
375
|
},
|
|
349
|
-
{ idempotencyKey: `sdk:pack:approve:${packId}
|
|
376
|
+
{ idempotencyKey: await contentIdempotencyKey(`sdk:pack:approve:${packId}`, body) }
|
|
350
377
|
);
|
|
351
378
|
}
|
|
352
|
-
releasePack(packId) {
|
|
379
|
+
async releasePack(packId) {
|
|
353
380
|
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
354
381
|
return this.request(
|
|
355
382
|
{
|
|
@@ -357,10 +384,10 @@ var ViraClient = class {
|
|
|
357
384
|
path: `/v1/packs/${encodeURIComponent(packId)}/release`,
|
|
358
385
|
body: {}
|
|
359
386
|
},
|
|
360
|
-
{ idempotencyKey: `sdk:pack:release:${packId}
|
|
387
|
+
{ idempotencyKey: await contentIdempotencyKey(`sdk:pack:release:${packId}`, {}) }
|
|
361
388
|
);
|
|
362
389
|
}
|
|
363
|
-
previewPackUpgrade(packId, incoming) {
|
|
390
|
+
async previewPackUpgrade(packId, incoming) {
|
|
364
391
|
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
365
392
|
if (!incoming || typeof incoming !== "object")
|
|
366
393
|
throw new Error("SDK_PACK_UPGRADE_INPUT_REQUIRED");
|
|
@@ -370,7 +397,7 @@ var ViraClient = class {
|
|
|
370
397
|
path: `/v1/packs/${encodeURIComponent(packId)}/upgrade-preview`,
|
|
371
398
|
body: { incoming }
|
|
372
399
|
},
|
|
373
|
-
{ idempotencyKey: `sdk:pack:upgrade-preview:${packId}
|
|
400
|
+
{ idempotencyKey: await contentIdempotencyKey(`sdk:pack:upgrade-preview:${packId}`, { incoming }) }
|
|
374
401
|
);
|
|
375
402
|
}
|
|
376
403
|
executeRuntime(input) {
|
|
@@ -457,9 +484,10 @@ var ViraClient = class {
|
|
|
457
484
|
path: "/v1/behavior-strategies"
|
|
458
485
|
});
|
|
459
486
|
}
|
|
460
|
-
deleteBehaviorStrategy(strategyId, options = {}) {
|
|
487
|
+
async deleteBehaviorStrategy(strategyId, options = {}) {
|
|
461
488
|
required(strategyId, "SDK_STRATEGY_ID_REQUIRED");
|
|
462
|
-
|
|
489
|
+
const path = `/v1/behavior-strategies/${encodeURIComponent(strategyId)}`, body = { confirm: options.confirm === true };
|
|
490
|
+
return this.request({ method: "DELETE", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:delete:strategy:${strategyId}`, { path, body }) });
|
|
463
491
|
}
|
|
464
492
|
getBehaviorStrategy(strategyId) {
|
|
465
493
|
required(strategyId, "SDK_STRATEGY_ID_REQUIRED");
|
|
@@ -479,25 +507,29 @@ var ViraClient = class {
|
|
|
479
507
|
listSemanticTasks() {
|
|
480
508
|
return this.request({ method: "GET", path: "/v1/semantic-tasks" });
|
|
481
509
|
}
|
|
482
|
-
deleteSemanticTask(taskId, options = {}) {
|
|
510
|
+
async deleteSemanticTask(taskId, options = {}) {
|
|
483
511
|
required(taskId, "SDK_SEMANTIC_TASK_ID_REQUIRED");
|
|
484
|
-
|
|
512
|
+
const path = `/v1/semantic-tasks/${encodeURIComponent(taskId)}`, body = { confirm: options.confirm === true };
|
|
513
|
+
return this.request({ method: "DELETE", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:delete:semantic-task:${taskId}`, { path, body }) });
|
|
485
514
|
}
|
|
486
|
-
createSemanticTask(task, options = {}) {
|
|
515
|
+
async createSemanticTask(task, options = {}) {
|
|
487
516
|
required(task?.taskKey, "SDK_SEMANTIC_TASK_KEY_REQUIRED");
|
|
488
|
-
|
|
517
|
+
const body = { ...task, ...options.id ? { id: options.id } : {} };
|
|
518
|
+
return this.request({ method: "POST", path: "/v1/semantic-tasks", body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:semantic-task:${task.taskKey}`, body) });
|
|
489
519
|
}
|
|
490
520
|
listBehaviorPoints() {
|
|
491
521
|
return this.request({ method: "GET", path: "/v1/behavior-points" });
|
|
492
522
|
}
|
|
493
|
-
deleteBehaviorPoint(pointId, options = {}) {
|
|
523
|
+
async deleteBehaviorPoint(pointId, options = {}) {
|
|
494
524
|
required(pointId, "SDK_BEHAVIOR_POINT_ID_REQUIRED");
|
|
495
|
-
|
|
525
|
+
const path = `/v1/behavior-points/${encodeURIComponent(pointId)}`, body = { confirm: options.confirm === true };
|
|
526
|
+
return this.request({ method: "DELETE", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:delete:behavior-point:${pointId}`, { path, body }) });
|
|
496
527
|
}
|
|
497
|
-
createBehaviorPoint(point, options = {}) {
|
|
528
|
+
async createBehaviorPoint(point, options = {}) {
|
|
498
529
|
required(point?.key, "SDK_BEHAVIOR_POINT_KEY_REQUIRED");
|
|
499
530
|
if (!point.taskId && !point.taskIds?.length) throw new Error("SDK_BEHAVIOR_POINT_TASK_REQUIRED");
|
|
500
|
-
|
|
531
|
+
const body = { ...point, ...options.id ? { id: options.id } : {} };
|
|
532
|
+
return this.request({ method: "POST", path: "/v1/behavior-points", body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:behavior-point:${point.key}`, body) });
|
|
501
533
|
}
|
|
502
534
|
createBehaviorStrategyVariant(strategyId, variant, options = {}) {
|
|
503
535
|
required(strategyId, "SDK_STRATEGY_ID_REQUIRED");
|
|
@@ -600,6 +632,47 @@ var ViraClient = class {
|
|
|
600
632
|
body: {}
|
|
601
633
|
});
|
|
602
634
|
}
|
|
635
|
+
resolveTaskRun(input) {
|
|
636
|
+
required(input.input, "SDK_TASKRUN_INPUT_REQUIRED");
|
|
637
|
+
if (input.requestedMode) required(input.requestedMode, "SDK_TASKRUN_MODE_REQUIRED");
|
|
638
|
+
const connectionId = input.connectionId ?? this.boundConnectionId;
|
|
639
|
+
return this.request({ method: "POST", path: "/v1/task-runs/resolve", body: { ...input, ...connectionId ? { connectionId } : {} } }, { idempotencyKey: `sdk:task-run:resolve:${input.input}` });
|
|
640
|
+
}
|
|
641
|
+
startTaskRun(input, options = {}) {
|
|
642
|
+
for (const value of [input.taskRunId, input.requestId]) required(value, "SDK_TASKRUN_ADMISSION_FIELD_REQUIRED");
|
|
643
|
+
if (input.input === void 0 || input.input === null) throw new Error("SDK_TASKRUN_INPUT_REQUIRED");
|
|
644
|
+
const body = { ...input, ...input.ownerActorRef ? { ownerActorRef: input.ownerActorRef } : {}, ...input.requestedMode ? { requestedMode: input.requestedMode } : {}, ...!input.connectionId && this.boundConnectionId ? { connectionId: this.boundConnectionId } : {} };
|
|
645
|
+
return this.request({ method: "POST", path: "/v1/task-runs", body }, { idempotencyKey: options.idempotencyKey ?? `sdk:task-run:start:${input.requestId}` });
|
|
646
|
+
}
|
|
647
|
+
startTaskRunFromPrompt(input, options = {}) {
|
|
648
|
+
if (input.input === void 0 || input.input === null) throw new Error("SDK_TASKRUN_INPUT_REQUIRED");
|
|
649
|
+
const id = () => globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
650
|
+
const requestId = input.requestId ?? `sdk-task-run-${id()}`;
|
|
651
|
+
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);
|
|
652
|
+
}
|
|
653
|
+
getTaskRun(taskRunId) {
|
|
654
|
+
required(taskRunId, "SDK_TASKRUN_ID_REQUIRED");
|
|
655
|
+
return this.request({ method: "GET", path: `/v1/task-runs/${encodeURIComponent(taskRunId)}` });
|
|
656
|
+
}
|
|
657
|
+
listTaskRunEvents(taskRunId) {
|
|
658
|
+
required(taskRunId, "SDK_TASKRUN_ID_REQUIRED");
|
|
659
|
+
return this.request({ method: "GET", path: `/v1/task-runs/${encodeURIComponent(taskRunId)}/events` });
|
|
660
|
+
}
|
|
661
|
+
continueTaskRun(taskRunId, expectedVersion, options = {}) {
|
|
662
|
+
required(taskRunId, "SDK_TASKRUN_ID_REQUIRED");
|
|
663
|
+
if (!Number.isInteger(expectedVersion) || expectedVersion < 0) throw new Error("SDK_TASKRUN_STATE_VERSION_REQUIRED");
|
|
664
|
+
return this.request({ method: "POST", path: `/v1/task-runs/${encodeURIComponent(taskRunId)}/continue`, body: { expectedVersion, ...options.cursor ? { cursor: options.cursor } : {} } }, { idempotencyKey: options.idempotencyKey ?? `sdk:task-run:continue:${taskRunId}:${expectedVersion}` });
|
|
665
|
+
}
|
|
666
|
+
cancelTaskRun(taskRunId, expectedVersion, options = {}) {
|
|
667
|
+
required(taskRunId, "SDK_TASKRUN_ID_REQUIRED");
|
|
668
|
+
if (!Number.isInteger(expectedVersion) || expectedVersion < 0) throw new Error("SDK_TASKRUN_STATE_VERSION_REQUIRED");
|
|
669
|
+
return this.request({ method: "POST", path: `/v1/task-runs/${encodeURIComponent(taskRunId)}/cancel`, body: { expectedVersion } }, { idempotencyKey: options.idempotencyKey ?? `sdk:task-run:cancel:${taskRunId}:${expectedVersion}` });
|
|
670
|
+
}
|
|
671
|
+
retryTaskRun(taskRunId, expectedVersion, options = {}) {
|
|
672
|
+
required(taskRunId, "SDK_TASKRUN_ID_REQUIRED");
|
|
673
|
+
if (!Number.isInteger(expectedVersion) || expectedVersion < 0) throw new Error("SDK_TASKRUN_STATE_VERSION_REQUIRED");
|
|
674
|
+
return this.request({ method: "POST", path: `/v1/task-runs/${encodeURIComponent(taskRunId)}/retry`, body: { expectedVersion } }, { idempotencyKey: options.idempotencyKey ?? `sdk:task-run:retry:${taskRunId}:${expectedVersion}` });
|
|
675
|
+
}
|
|
603
676
|
listBehaviorPrograms() {
|
|
604
677
|
return this.request({
|
|
605
678
|
method: "GET",
|
|
@@ -617,13 +690,15 @@ var ViraClient = class {
|
|
|
617
690
|
path: `/v1/behavior-programs/${encodeURIComponent(programId)}`
|
|
618
691
|
});
|
|
619
692
|
}
|
|
620
|
-
deleteBehaviorProgram(programId, options = {}) {
|
|
693
|
+
async deleteBehaviorProgram(programId, options = {}) {
|
|
621
694
|
required(programId, "SDK_PROGRAM_ID_REQUIRED");
|
|
622
|
-
|
|
695
|
+
const path = `/v1/behavior-programs/${encodeURIComponent(programId)}`, body = { confirm: options.confirm === true };
|
|
696
|
+
return this.request({ method: "DELETE", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:delete:behavior-program:${programId}`, { path, body }) });
|
|
623
697
|
}
|
|
624
|
-
deleteBehaviorProgramCascade(programId, options = {}) {
|
|
698
|
+
async deleteBehaviorProgramCascade(programId, options = {}) {
|
|
625
699
|
required(programId, "SDK_PROGRAM_ID_REQUIRED");
|
|
626
|
-
|
|
700
|
+
const path = `/v1/behavior-programs/${encodeURIComponent(programId)}/cascade`, body = { confirm: options.confirm === true, purgeRuntime: options.purgeRuntime === true };
|
|
701
|
+
return this.request({ method: "DELETE", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:delete:behavior-program-cascade:${programId}`, { path, body }) });
|
|
627
702
|
}
|
|
628
703
|
createBehaviorProgram(program, options = {}) {
|
|
629
704
|
if (!program || typeof program !== "object")
|
|
@@ -898,31 +973,35 @@ var ViraClient = class {
|
|
|
898
973
|
{ idempotencyKey: options.idempotencyKey }
|
|
899
974
|
);
|
|
900
975
|
}
|
|
901
|
-
compileBehaviorCapsule(input) {
|
|
976
|
+
async compileBehaviorCapsule(input) {
|
|
902
977
|
required(input.programId, "SDK_PROGRAM_ID_REQUIRED");
|
|
903
978
|
required(input.input, "SDK_RUNTIME_INPUT_REQUIRED");
|
|
979
|
+
const body = { ...input };
|
|
904
980
|
return this.request(
|
|
905
981
|
{
|
|
906
982
|
method: "POST",
|
|
907
983
|
path: "/v1/runtime/behavior-capsule",
|
|
908
|
-
body
|
|
984
|
+
body
|
|
909
985
|
},
|
|
910
986
|
{
|
|
911
|
-
idempotencyKey: input.idempotencyKey ?? `sdk:capsule:${input.programId}
|
|
987
|
+
idempotencyKey: input.idempotencyKey ?? await contentIdempotencyKey(`sdk:capsule:${input.programId}`, body),
|
|
988
|
+
enforcing: true
|
|
912
989
|
}
|
|
913
990
|
);
|
|
914
991
|
}
|
|
915
|
-
serveBehaviorProjection(input) {
|
|
992
|
+
async serveBehaviorProjection(input) {
|
|
916
993
|
required(input.input, "SDK_RUNTIME_INPUT_REQUIRED");
|
|
917
994
|
required(input.provider, "SDK_PROVIDER_REQUIRED");
|
|
995
|
+
const body = { ...input };
|
|
918
996
|
return this.request(
|
|
919
997
|
{
|
|
920
998
|
method: "POST",
|
|
921
999
|
path: "/v1/runtime/behavior-projection",
|
|
922
|
-
body
|
|
1000
|
+
body
|
|
923
1001
|
},
|
|
924
1002
|
{
|
|
925
|
-
idempotencyKey: input.idempotencyKey ?? `sdk:projection:${input.programId ?? "active"}
|
|
1003
|
+
idempotencyKey: input.idempotencyKey ?? await contentIdempotencyKey(`sdk:projection:${input.programId ?? "active"}`, body),
|
|
1004
|
+
enforcing: true
|
|
926
1005
|
}
|
|
927
1006
|
);
|
|
928
1007
|
}
|
|
@@ -1040,6 +1119,73 @@ function buildObservationRequest(event) {
|
|
|
1040
1119
|
body: Object.freeze({ ...event })
|
|
1041
1120
|
});
|
|
1042
1121
|
}
|
|
1122
|
+
|
|
1123
|
+
// ../../sdks/framework-adapters.ts
|
|
1124
|
+
async function resolveFrameworkBoundary(client, request) {
|
|
1125
|
+
if (!request || typeof request !== "object") throw new Error("SDK_RUNTIME_REQUEST_REQUIRED");
|
|
1126
|
+
const resolution = request.executionBoundary ? await client.resolveBoundary({
|
|
1127
|
+
executionBoundary: request.executionBoundary,
|
|
1128
|
+
...request.semanticContext ? { semanticContext: request.semanticContext } : {}
|
|
1129
|
+
}) : await client.resolveRuntime({
|
|
1130
|
+
...request.behaviorPoint ? { behaviorPoint: request.behaviorPoint } : {},
|
|
1131
|
+
...request.semanticContext ? { semanticContext: request.semanticContext } : {}
|
|
1132
|
+
});
|
|
1133
|
+
const body = resolution && typeof resolution === "object" && "body" in resolution ? resolution.body : resolution;
|
|
1134
|
+
const routed = body && typeof body === "object" && typeof body.behaviorPoint === "string" ? String(body.behaviorPoint) : void 0;
|
|
1135
|
+
if (!routed?.trim()) throw new Error("SDK_RUNTIME_ROUTE_UNRESOLVED");
|
|
1136
|
+
return { resolution, behaviorPoint: routed, request: { ...request, behaviorPoint: routed, semanticContext: { ...request.semanticContext ?? {}, behaviorPoint: routed } } };
|
|
1137
|
+
}
|
|
1138
|
+
function createGenericRuntimeHooks(client) {
|
|
1139
|
+
const resolve = (request) => resolveFrameworkBoundary(client, request);
|
|
1140
|
+
return Object.freeze({
|
|
1141
|
+
resolve,
|
|
1142
|
+
onStart: resolve,
|
|
1143
|
+
enrichTrace: (trace, routed) => ({ ...trace, behaviorPoint: routed.behaviorPoint })
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
var createOpenAIAgentsHooks = createGenericRuntimeHooks;
|
|
1147
|
+
var createLangGraphHooks = createGenericRuntimeHooks;
|
|
1148
|
+
var createGenericHttpHooks = createGenericRuntimeHooks;
|
|
1149
|
+
var createOpenAICompatibleHooks = createGenericRuntimeHooks;
|
|
1150
|
+
var createMastraHooks = createGenericRuntimeHooks;
|
|
1151
|
+
var createVercelAIHooks = createGenericRuntimeHooks;
|
|
1152
|
+
function createViraMiddleware(client) {
|
|
1153
|
+
const hooks = createGenericRuntimeHooks(client);
|
|
1154
|
+
return Object.freeze({
|
|
1155
|
+
resolve: hooks.resolve,
|
|
1156
|
+
onRequest: hooks.onStart,
|
|
1157
|
+
enrichTrace: hooks.enrichTrace
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
var eventType = { trace: "model.response", outcome: "business.outcome", feedback: "feedback.user" };
|
|
1161
|
+
var lifecycleType = { start: "execution.started", complete: "execution.completed", error: "execution.failed", toolStart: "tool.called", toolComplete: "tool.result" };
|
|
1162
|
+
function createFrameworkObservationAdapter(client, framework) {
|
|
1163
|
+
if (!client || !["openai-agents", "vercel-ai", "langchain", "langgraph", "otel", "mcp"].includes(framework)) throw new Error("SDK_FRAMEWORK_ADAPTER_INVALID");
|
|
1164
|
+
return Object.freeze({ framework, observe(event, kind) {
|
|
1165
|
+
if (!event?.eventId || !event.aiSystemId || !event.connectionId || kind === "observation" && !event.eventType) throw new Error("SDK_FRAMEWORK_EVENT_REQUIRED");
|
|
1166
|
+
const input = { ...event, eventType: kind === "observation" ? event.eventType : eventType[kind] };
|
|
1167
|
+
return client.observe(input);
|
|
1168
|
+
} });
|
|
1169
|
+
}
|
|
1170
|
+
function createFrameworkLifecycleAdapter(client, framework, options = {}) {
|
|
1171
|
+
const mode = options.mode ?? "observe";
|
|
1172
|
+
if (mode !== "observe" && mode !== "enforce") throw new Error("SDK_FRAMEWORK_MODE_INVALID");
|
|
1173
|
+
const observation = createFrameworkObservationAdapter(client, framework);
|
|
1174
|
+
const emit = (event, type) => observation.observe({ ...event, eventType: type }, "observation");
|
|
1175
|
+
return Object.freeze({
|
|
1176
|
+
...observation,
|
|
1177
|
+
mode,
|
|
1178
|
+
resolveBoundary: (input) => client.resolveBoundary(input),
|
|
1179
|
+
start: (event) => emit(event, lifecycleType.start),
|
|
1180
|
+
complete: (event) => emit(event, lifecycleType.complete),
|
|
1181
|
+
error: (event) => emit(event, lifecycleType.error),
|
|
1182
|
+
toolStart: (event) => emit(event, lifecycleType.toolStart),
|
|
1183
|
+
toolComplete: (event) => emit(event, lifecycleType.toolComplete)
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
function createFrameworkAdapters(client) {
|
|
1187
|
+
return Object.freeze(Object.fromEntries(["openai-agents", "vercel-ai", "langchain", "langgraph", "otel", "mcp"].map((name) => [name, createFrameworkObservationAdapter(client, name)])));
|
|
1188
|
+
}
|
|
1043
1189
|
export {
|
|
1044
1190
|
ViraApiError,
|
|
1045
1191
|
ViraClient,
|
|
@@ -1047,5 +1193,17 @@ export {
|
|
|
1047
1193
|
buildDocsQueryRequest,
|
|
1048
1194
|
buildObservationRequest,
|
|
1049
1195
|
buildPublicContentRequest,
|
|
1050
|
-
buildRuntimeRequest
|
|
1196
|
+
buildRuntimeRequest,
|
|
1197
|
+
createFrameworkAdapters,
|
|
1198
|
+
createFrameworkLifecycleAdapter,
|
|
1199
|
+
createFrameworkObservationAdapter,
|
|
1200
|
+
createGenericHttpHooks,
|
|
1201
|
+
createGenericRuntimeHooks,
|
|
1202
|
+
createLangGraphHooks,
|
|
1203
|
+
createMastraHooks,
|
|
1204
|
+
createOpenAIAgentsHooks,
|
|
1205
|
+
createOpenAICompatibleHooks,
|
|
1206
|
+
createVercelAIHooks,
|
|
1207
|
+
createViraMiddleware,
|
|
1208
|
+
resolveFrameworkBoundary
|
|
1051
1209
|
};
|
package/dist/js-client.d.ts
CHANGED
|
@@ -16,12 +16,16 @@ export interface SdkRequest {
|
|
|
16
16
|
export type SdkFailureMode = "throw" | "open";
|
|
17
17
|
export interface ViraClientOptions {
|
|
18
18
|
baseUrl: string;
|
|
19
|
+
/** Explicit opt-in for plain HTTP on loopback during local development only. */
|
|
20
|
+
allowInsecureLocalhost?: boolean;
|
|
19
21
|
apiKey?: string;
|
|
20
22
|
fetcher?: typeof fetch;
|
|
21
23
|
timeoutMs?: number;
|
|
22
24
|
retries?: number;
|
|
23
25
|
failureMode?: SdkFailureMode;
|
|
24
26
|
defaultHeaders?: Readonly<Record<string, string>>;
|
|
27
|
+
/** Connection selected by connectOnce or supplied by the host integration. */
|
|
28
|
+
connectionId?: string;
|
|
25
29
|
}
|
|
26
30
|
export interface ViraResponse<T = unknown> {
|
|
27
31
|
status: number;
|
|
@@ -49,6 +53,51 @@ export interface RuntimeResolution {
|
|
|
49
53
|
projectionMode?: "active" | "unavailable" | "not-applicable";
|
|
50
54
|
[key: string]: unknown;
|
|
51
55
|
}
|
|
56
|
+
export type TaskRunMode = "SINGLE" | "STRATEGY" | "COMPOUND" | "HYBRID";
|
|
57
|
+
export type TaskRunRequestedMode = TaskRunMode | "AUTO";
|
|
58
|
+
export interface TaskRunChildMode {
|
|
59
|
+
semanticTaskKey: string;
|
|
60
|
+
mode: "SINGLE" | "STRATEGY";
|
|
61
|
+
}
|
|
62
|
+
export interface TaskRunRouteRequest {
|
|
63
|
+
input: string;
|
|
64
|
+
requestedMode?: TaskRunRequestedMode;
|
|
65
|
+
intentCount?: number;
|
|
66
|
+
hostCapabilities?: readonly string[];
|
|
67
|
+
hybridPlan?: readonly TaskRunChildMode[];
|
|
68
|
+
connectionId?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface TaskRunBudget {
|
|
71
|
+
maxChildren?: number;
|
|
72
|
+
maxCalls?: number;
|
|
73
|
+
maxLatencyMs?: number;
|
|
74
|
+
maxCostMicros?: number;
|
|
75
|
+
}
|
|
76
|
+
export interface TaskRunAdmissionRequest {
|
|
77
|
+
taskRunId: string;
|
|
78
|
+
requestId: string;
|
|
79
|
+
input: unknown;
|
|
80
|
+
ownerActorRef?: string;
|
|
81
|
+
requestedMode?: TaskRunRequestedMode;
|
|
82
|
+
hostCapabilities?: readonly string[];
|
|
83
|
+
hybridPlan?: readonly TaskRunChildMode[];
|
|
84
|
+
compoundPlanId?: string;
|
|
85
|
+
conversationId?: string;
|
|
86
|
+
episodeId?: string;
|
|
87
|
+
traceRootRef?: string;
|
|
88
|
+
budget?: TaskRunBudget;
|
|
89
|
+
connectionId?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface TaskRunPromptRequest {
|
|
92
|
+
input: unknown;
|
|
93
|
+
taskRunId?: string;
|
|
94
|
+
requestId?: string;
|
|
95
|
+
conversationId?: string;
|
|
96
|
+
episodeId?: string;
|
|
97
|
+
traceRootRef?: string;
|
|
98
|
+
budget?: TaskRunBudget;
|
|
99
|
+
connectionId?: string;
|
|
100
|
+
}
|
|
52
101
|
export interface ConnectOnceResult {
|
|
53
102
|
system: ClientBody;
|
|
54
103
|
connection: ClientBody;
|
|
@@ -129,6 +178,7 @@ export declare class ViraClient {
|
|
|
129
178
|
private readonly retries;
|
|
130
179
|
private readonly failureMode;
|
|
131
180
|
private readonly defaultHeaders;
|
|
181
|
+
private boundConnectionId?;
|
|
132
182
|
constructor(options: ViraClientOptions);
|
|
133
183
|
private request;
|
|
134
184
|
connectSystem(input: {
|
|
@@ -373,6 +423,25 @@ export declare class ViraClient {
|
|
|
373
423
|
getStrategyExecutionTrace(executionId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
374
424
|
continueStrategyExecution(executionId: string, continuation?: string | StrategyContinuationInput): Promise<ViraResponse<ClientBody> | null>;
|
|
375
425
|
cancelStrategyExecution(executionId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
426
|
+
resolveTaskRun(input: TaskRunRouteRequest): Promise<ViraResponse<ClientBody> | null>;
|
|
427
|
+
startTaskRun(input: TaskRunAdmissionRequest, options?: {
|
|
428
|
+
idempotencyKey?: string;
|
|
429
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
430
|
+
startTaskRunFromPrompt(input: TaskRunPromptRequest, options?: {
|
|
431
|
+
idempotencyKey?: string;
|
|
432
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
433
|
+
getTaskRun(taskRunId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
434
|
+
listTaskRunEvents(taskRunId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
435
|
+
continueTaskRun(taskRunId: string, expectedVersion: number, options?: {
|
|
436
|
+
cursor?: string;
|
|
437
|
+
idempotencyKey?: string;
|
|
438
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
439
|
+
cancelTaskRun(taskRunId: string, expectedVersion: number, options?: {
|
|
440
|
+
idempotencyKey?: string;
|
|
441
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
442
|
+
retryTaskRun(taskRunId: string, expectedVersion: number, options?: {
|
|
443
|
+
idempotencyKey?: string;
|
|
444
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
376
445
|
listBehaviorPrograms(): Promise<ViraResponse<{
|
|
377
446
|
programs: readonly ClientBody[];
|
|
378
447
|
}> | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryvira/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
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"},
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"main": "./dist/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"exports": {".": {"types": "./dist/index.d.ts", "import": "./dist/index.js"}},
|
|
14
|
-
"files": ["dist/index.js", "dist/index.d.ts", "dist/js-client.d.ts", "README.md"],
|
|
14
|
+
"files": ["dist/index.js", "dist/index.d.ts", "dist/js-client.d.ts", "dist/framework-adapters.d.ts", "README.md"],
|
|
15
15
|
"publishConfig": {"access": "public"},
|
|
16
16
|
"scripts": {"build": "node ../../scripts/build-publishable-packages.mjs sdk", "pack:check": "npm run build && npm pack --dry-run && npm run public:surface:smoke", "public:surface:smoke": "node ../../scripts/public-surface-contract-acceptance.mjs --sdk-package", "prepublishOnly": "npm run pack:check && npm run public:surface:smoke", "publish:public": "npm run pack:check && npm run public:surface:smoke && npm publish --access public"},
|
|
17
17
|
"license": "MIT"
|