@tryvira/sdk 0.1.43 → 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 +126 -2
- package/dist/js-client.d.ts +67 -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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// sdks/js-client.ts
|
|
1
|
+
// ../../sdks/js-client.ts
|
|
2
2
|
var ViraApiError = class extends Error {
|
|
3
3
|
status;
|
|
4
4
|
body;
|
|
@@ -52,6 +52,7 @@ var ViraClient = class {
|
|
|
52
52
|
retries;
|
|
53
53
|
failureMode;
|
|
54
54
|
defaultHeaders;
|
|
55
|
+
boundConnectionId;
|
|
55
56
|
constructor(options) {
|
|
56
57
|
this.baseUrl = normalizeBaseUrl(options.baseUrl, options.allowInsecureLocalhost === true);
|
|
57
58
|
this.apiKey = options.apiKey;
|
|
@@ -63,6 +64,7 @@ var ViraClient = class {
|
|
|
63
64
|
this.retries = Math.max(0, Math.min(options.retries ?? 2, 5));
|
|
64
65
|
this.failureMode = options.failureMode ?? "throw";
|
|
65
66
|
this.defaultHeaders = options.defaultHeaders ?? {};
|
|
67
|
+
this.boundConnectionId = options.connectionId;
|
|
66
68
|
this.evaluations = {
|
|
67
69
|
createPlan: (input, options2 = {}) => this.createEvaluationPlan(input, options2),
|
|
68
70
|
get: (id) => this.getEvaluation(id),
|
|
@@ -204,6 +206,8 @@ var ViraClient = class {
|
|
|
204
206
|
idempotencyKey: input.idempotencyKey
|
|
205
207
|
});
|
|
206
208
|
if (!connectionResult) return null;
|
|
209
|
+
const connectedId = String(connectionResult.body.connection?.id ?? "").trim();
|
|
210
|
+
if (connectedId) this.boundConnectionId = connectedId;
|
|
207
211
|
return {
|
|
208
212
|
status: connectionResult.status,
|
|
209
213
|
requestId: connectionResult.requestId,
|
|
@@ -628,6 +632,47 @@ var ViraClient = class {
|
|
|
628
632
|
body: {}
|
|
629
633
|
});
|
|
630
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
|
+
}
|
|
631
676
|
listBehaviorPrograms() {
|
|
632
677
|
return this.request({
|
|
633
678
|
method: "GET",
|
|
@@ -1074,6 +1119,73 @@ function buildObservationRequest(event) {
|
|
|
1074
1119
|
body: Object.freeze({ ...event })
|
|
1075
1120
|
});
|
|
1076
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
|
+
}
|
|
1077
1189
|
export {
|
|
1078
1190
|
ViraApiError,
|
|
1079
1191
|
ViraClient,
|
|
@@ -1081,5 +1193,17 @@ export {
|
|
|
1081
1193
|
buildDocsQueryRequest,
|
|
1082
1194
|
buildObservationRequest,
|
|
1083
1195
|
buildPublicContentRequest,
|
|
1084
|
-
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
|
|
1085
1209
|
};
|
package/dist/js-client.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface ViraClientOptions {
|
|
|
24
24
|
retries?: number;
|
|
25
25
|
failureMode?: SdkFailureMode;
|
|
26
26
|
defaultHeaders?: Readonly<Record<string, string>>;
|
|
27
|
+
/** Connection selected by connectOnce or supplied by the host integration. */
|
|
28
|
+
connectionId?: string;
|
|
27
29
|
}
|
|
28
30
|
export interface ViraResponse<T = unknown> {
|
|
29
31
|
status: number;
|
|
@@ -51,6 +53,51 @@ export interface RuntimeResolution {
|
|
|
51
53
|
projectionMode?: "active" | "unavailable" | "not-applicable";
|
|
52
54
|
[key: string]: unknown;
|
|
53
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
|
+
}
|
|
54
101
|
export interface ConnectOnceResult {
|
|
55
102
|
system: ClientBody;
|
|
56
103
|
connection: ClientBody;
|
|
@@ -131,6 +178,7 @@ export declare class ViraClient {
|
|
|
131
178
|
private readonly retries;
|
|
132
179
|
private readonly failureMode;
|
|
133
180
|
private readonly defaultHeaders;
|
|
181
|
+
private boundConnectionId?;
|
|
134
182
|
constructor(options: ViraClientOptions);
|
|
135
183
|
private request;
|
|
136
184
|
connectSystem(input: {
|
|
@@ -375,6 +423,25 @@ export declare class ViraClient {
|
|
|
375
423
|
getStrategyExecutionTrace(executionId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
376
424
|
continueStrategyExecution(executionId: string, continuation?: string | StrategyContinuationInput): Promise<ViraResponse<ClientBody> | null>;
|
|
377
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>;
|
|
378
445
|
listBehaviorPrograms(): Promise<ViraResponse<{
|
|
379
446
|
programs: readonly ClientBody[];
|
|
380
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"
|