@tryvira/sdk 0.1.108 → 0.1.110
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 +1 -1
- package/dist/index.js +89 -29
- package/dist/sdks/js-client.d.ts +134 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Compound execution plans can be persisted with `saveCompoundTaskPlan(plan, {idem
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install @tryvira/sdk@0.1.
|
|
18
|
+
npm install @tryvira/sdk@0.1.110
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Configure the organization, project, and environment for every request. Keep the API
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// sdks/js-client.ts
|
|
2
2
|
var listQuery = (options) => ({
|
|
3
3
|
...options.limit === void 0 ? {} : { limit: String(options.limit) },
|
|
4
4
|
...options.cursor ? { cursor: options.cursor } : {},
|
|
@@ -182,8 +182,8 @@ var ViraClient = class {
|
|
|
182
182
|
if (!actorId.trim()) throw new Error("SDK_ACTOR_ID_REQUIRED");
|
|
183
183
|
return this.request({ method: "POST", path: `/v1/organization/billing-admins/${encodeURIComponent(actorId)}`, body: { status } }, { idempotencyKey: options.idempotencyKey ?? `sdk:billing-admin:${globalThis.crypto.randomUUID()}`, enforcing: true });
|
|
184
184
|
}
|
|
185
|
-
getAICreditWallet() {
|
|
186
|
-
return this.request({ method: "GET", path: "/v1/billing/credits" });
|
|
185
|
+
getAICreditWallet(input = {}) {
|
|
186
|
+
return this.request({ method: "GET", path: "/v1/billing/credits", ...input.includeCommercial === true ? { query: { includeCommercial: "true" } } : {} });
|
|
187
187
|
}
|
|
188
188
|
listAICreditBudgets() {
|
|
189
189
|
return this.request({ method: "GET", path: "/v1/billing/credits/budgets" });
|
|
@@ -273,7 +273,7 @@ var ViraClient = class {
|
|
|
273
273
|
...this.defaultHeaders
|
|
274
274
|
};
|
|
275
275
|
if (request.body) headers["content-type"] = "application/json";
|
|
276
|
-
const operatorOperation = /^\/v1\/(?:billing\/legacy-pricing\/(?:inspect|propose|approve)|behavior-policy-bindings\/reconciliation\/(?:inspect|propose|approve|history|remediation-inspect|remediation-propose|remediation-approve|remediation-history)|signals\/subject-consent\/(?:inspect|grant|withdraw)|teach\/subject-evidence\/(?:admit|withdraw|history))$/.test(request.path);
|
|
276
|
+
const operatorOperation = /^\/v1\/(?:billing\/legacy-pricing\/(?:inspect|propose|approve)|behavior-policy-bindings\/reconciliation\/(?:inspect|propose|approve|history|remediation-inspect|remediation-propose|remediation-approve|remediation-history)|signals\/subject-consent\/(?:inspect|grant|withdraw|inventory|history)|connections\/[^/]+\/revoke|teach\/subject-evidence\/(?:admit|withdraw|history))$/.test(request.path);
|
|
277
277
|
if (operatorOperation) {
|
|
278
278
|
if (Object.keys(headers).some((key) => ["authorization", "x-vira-api-key", "x-vira-delegation", "x-vira-taskrun-delegation", "x-vira-optimizer-grant", "cookie"].includes(key.toLowerCase())))
|
|
279
279
|
throw new Error("SDK_OPERATOR_MIXED_AUTHORITY_FORBIDDEN");
|
|
@@ -728,7 +728,7 @@ var ViraClient = class {
|
|
|
728
728
|
if (!listed) throw error;
|
|
729
729
|
const systems = Array.isArray(listed?.body?.systems) ? listed.body.systems : [];
|
|
730
730
|
const reused = systems.find(
|
|
731
|
-
(system) => String(system.name ?? "") === input.name && String(system.systemType ?? "") === input.systemType && String(system.organizationId ?? "") === input.organizationId && String(system.projectId ?? "") === input.projectId && String(system.environmentId ?? "") === input.environmentId
|
|
731
|
+
(system) => system.status === "ACTIVE" && String(system.name ?? "") === input.name && String(system.systemType ?? "") === input.systemType && String(system.organizationId ?? "") === input.organizationId && String(system.projectId ?? "") === input.projectId && String(system.environmentId ?? "") === input.environmentId
|
|
732
732
|
);
|
|
733
733
|
if (!reused) throw error;
|
|
734
734
|
systemResult = { status: listed.status, requestId: listed.requestId, body: { system: reused } };
|
|
@@ -751,11 +751,11 @@ var ViraClient = class {
|
|
|
751
751
|
const listed = await this.listSystemConnections(systemId);
|
|
752
752
|
const connections = Array.isArray(listed?.body?.connections) ? listed.body.connections : [];
|
|
753
753
|
const requested = new Set((input.capabilities ?? []).map(String));
|
|
754
|
-
const reused = connections.find((connection) => String(connection.adapterType ?? "") === input.adapterType && requested.size <= new Set(Array.isArray(connection.capabilities) ? connection.capabilities.map(String) : []).size && [...requested].every((capability) => (Array.isArray(connection.capabilities) ? connection.capabilities.map(String) : []).includes(capability)));
|
|
754
|
+
const reused = connections.find((connection) => connection.status === "CONNECTED" && connection.aiSystemId === systemId && String(connection.adapterType ?? "") === input.adapterType && requested.size <= new Set(Array.isArray(connection.capabilities) ? connection.capabilities.map(String) : []).size && [...requested].every((capability) => (Array.isArray(connection.capabilities) ? connection.capabilities.map(String) : []).includes(capability)));
|
|
755
755
|
if (!reused) throw error;
|
|
756
756
|
const verified = await this.getConnection(String(reused.id ?? ""));
|
|
757
757
|
const verifiedConnection = verified?.body?.connection && typeof verified.body.connection === "object" ? verified.body.connection : null;
|
|
758
|
-
if (!verifiedConnection || String(verifiedConnection.adapterType ?? "") !== input.adapterType) throw error;
|
|
758
|
+
if (!verifiedConnection || verifiedConnection.status !== "CONNECTED" || verifiedConnection.id !== reused.id || verifiedConnection.aiSystemId !== systemId || String(verifiedConnection.adapterType ?? "") !== input.adapterType) throw error;
|
|
759
759
|
const verifiedCapabilities = Array.isArray(verifiedConnection.capabilities) ? verifiedConnection.capabilities.map(String) : [];
|
|
760
760
|
if (![...requested].every((capability) => verifiedCapabilities.includes(capability))) throw error;
|
|
761
761
|
const fromVersion = String(verifiedConnection.adapterVersion ?? "");
|
|
@@ -764,7 +764,8 @@ var ViraClient = class {
|
|
|
764
764
|
}
|
|
765
765
|
if (!connectionResult) return null;
|
|
766
766
|
const connectedId = String(connectionResult.body.connection.id ?? "").trim();
|
|
767
|
-
if (connectedId
|
|
767
|
+
if (!connectedId || connectionResult.body.connection.status !== "CONNECTED" || connectionResult.body.connection.aiSystemId !== systemId) throw Error("SDK_CONNECTION_AUTHORITY_INVALID");
|
|
768
|
+
this.boundConnectionId = connectedId;
|
|
768
769
|
return {
|
|
769
770
|
status: connectionResult.status,
|
|
770
771
|
requestId: connectionResult.requestId,
|
|
@@ -1012,6 +1013,26 @@ var ViraClient = class {
|
|
|
1012
1013
|
query: { ...options.reviewState ? { reviewState: options.reviewState } : {}, ...listQuery(normalized) }
|
|
1013
1014
|
});
|
|
1014
1015
|
}
|
|
1016
|
+
listReusableEvaluationDatasets(systemId, cursor) {
|
|
1017
|
+
return this.request({ method: "GET", path: `/v1/ai-systems/${encodeURIComponent(systemId)}/evaluation-datasets`, query: cursor ? { cursor } : {} }, { enforcing: true });
|
|
1018
|
+
}
|
|
1019
|
+
getReusableEvaluationDataset(systemId, datasetId, datasetDigest) {
|
|
1020
|
+
return this.request({ method: "GET", path: `/v1/ai-systems/${encodeURIComponent(systemId)}/evaluation-datasets/${encodeURIComponent(datasetId)}`, query: { datasetDigest } }, { enforcing: true });
|
|
1021
|
+
}
|
|
1022
|
+
getFeatureCreditPreview(systemId, feature, model) {
|
|
1023
|
+
return this.request({ method: "GET", path: `/v1/ai-systems/${encodeURIComponent(systemId)}/ai-credit-preview/${encodeURIComponent(feature)}`, ...model ? { query: { providerId: model.providerId, modelId: model.modelId } } : {} }, { enforcing: true });
|
|
1024
|
+
}
|
|
1025
|
+
getDiscoveryWorkerHealth() {
|
|
1026
|
+
return this.request({ method: "GET", path: "/v1/discovery/worker-health" }, { enforcing: true });
|
|
1027
|
+
}
|
|
1028
|
+
getDiscoveryDispatch(eventId) {
|
|
1029
|
+
required(eventId, "SDK_OBSERVATION_EVENT_ID_REQUIRED");
|
|
1030
|
+
return this.request({ method: "GET", path: `/v1/discovery/observations/${encodeURIComponent(eventId)}/dispatch` }, { enforcing: true });
|
|
1031
|
+
}
|
|
1032
|
+
async queueDiscoveryDispatch(eventId, options = {}) {
|
|
1033
|
+
required(eventId, "SDK_OBSERVATION_EVENT_ID_REQUIRED");
|
|
1034
|
+
return this.request({ method: "POST", path: `/v1/discovery/observations/${encodeURIComponent(eventId)}/dispatch`, body: {} }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey("sdk:discovery-dispatch", { eventId }), enforcing: true });
|
|
1035
|
+
}
|
|
1015
1036
|
async reviewDiscoveryCandidate(kind, key, input, options = {}) {
|
|
1016
1037
|
required(kind, "SDK_DISCOVERY_CANDIDATE_KIND_REQUIRED");
|
|
1017
1038
|
required(key, "SDK_DISCOVERY_CANDIDATE_KEY_REQUIRED");
|
|
@@ -1025,6 +1046,15 @@ var ViraClient = class {
|
|
|
1025
1046
|
const invocationId = globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1026
1047
|
return this.request({ method: "POST", path, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:discovery-review:${kind}:${key}`, { invocationId, body }), enforcing: true });
|
|
1027
1048
|
}
|
|
1049
|
+
/** Create a review-only department draft from approved semantic evidence. */
|
|
1050
|
+
async createDepartmentDiscoveryDraft(key, input, options = {}) {
|
|
1051
|
+
required(key, "SDK_DISCOVERY_CANDIDATE_KEY_REQUIRED");
|
|
1052
|
+
required(input.candidateId, "SDK_DISCOVERY_CANDIDATE_ID_REQUIRED");
|
|
1053
|
+
required(input.aiSystemId, "SDK_AI_SYSTEM_ID_REQUIRED");
|
|
1054
|
+
if (!Array.isArray(input.evidenceIds) || !input.evidenceIds.length || input.evidenceIds.length > 200 || input.evidenceIds.some((id2) => typeof id2 !== "string" || !id2.trim()) || new Set(input.evidenceIds).size !== input.evidenceIds.length) throw Error("SDK_DISCOVERY_DRAFT_EVIDENCE_INVALID");
|
|
1055
|
+
const body = { candidateId: input.candidateId, aiSystemId: input.aiSystemId, evidenceIds: [...input.evidenceIds] };
|
|
1056
|
+
return this.request({ method: "POST", path: `/v1/discovery/candidates/semantic_task/${encodeURIComponent(key)}/department-draft`, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:discovery-draft:${key}`, body), enforcing: true });
|
|
1057
|
+
}
|
|
1028
1058
|
/** Explicit canonical publication; API approval and scope checks still apply. */
|
|
1029
1059
|
publishDiscoveryCandidate(kind, key, input = {}, options = {}) {
|
|
1030
1060
|
required(kind, "SDK_DISCOVERY_CANDIDATE_KIND_REQUIRED");
|
|
@@ -1161,7 +1191,8 @@ var ViraClient = class {
|
|
|
1161
1191
|
}
|
|
1162
1192
|
async approvePack(packId, options = {}) {
|
|
1163
1193
|
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
1164
|
-
const
|
|
1194
|
+
const approval = options.manualApproval ? { manualApproval: true, reason: required(options.reason ?? "", "SDK_MANUAL_PACK_APPROVAL_REASON_REQUIRED") } : {};
|
|
1195
|
+
const body = { ...approval, ...options.expectedPackDigest === void 0 ? {} : { expectedPackDigest: options.expectedPackDigest } };
|
|
1165
1196
|
return this.request(
|
|
1166
1197
|
{
|
|
1167
1198
|
method: "POST",
|
|
@@ -1171,15 +1202,16 @@ var ViraClient = class {
|
|
|
1171
1202
|
{ idempotencyKey: await contentIdempotencyKey(`sdk:pack:approve:${packId}`, body) }
|
|
1172
1203
|
);
|
|
1173
1204
|
}
|
|
1174
|
-
async releasePack(packId) {
|
|
1205
|
+
async releasePack(packId, options = {}) {
|
|
1175
1206
|
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
1207
|
+
const body = options.expectedPackDigest === void 0 ? {} : { expectedPackDigest: options.expectedPackDigest };
|
|
1176
1208
|
return this.request(
|
|
1177
1209
|
{
|
|
1178
1210
|
method: "POST",
|
|
1179
1211
|
path: `/v1/packs/${encodeURIComponent(packId)}/release`,
|
|
1180
|
-
body
|
|
1212
|
+
body
|
|
1181
1213
|
},
|
|
1182
|
-
{ idempotencyKey: await contentIdempotencyKey(`sdk:pack:release:${packId}`,
|
|
1214
|
+
{ idempotencyKey: await contentIdempotencyKey(`sdk:pack:release:${packId}`, body) }
|
|
1183
1215
|
);
|
|
1184
1216
|
}
|
|
1185
1217
|
async previewPackUpgrade(packId, incoming) {
|
|
@@ -1296,6 +1328,19 @@ var ViraClient = class {
|
|
|
1296
1328
|
historyLegacyRecordRemediation(input = {}) {
|
|
1297
1329
|
return this.request({ method: "POST", path: "/v1/behavior-policy-bindings/reconciliation/remediation-history", body: input }, { enforcing: true });
|
|
1298
1330
|
}
|
|
1331
|
+
/** Native operator delegation only; never a machine key or MCP mutation. */
|
|
1332
|
+
revokeConnection(connectionId, input) {
|
|
1333
|
+
required(connectionId, "SDK_CONNECTION_ID_REQUIRED");
|
|
1334
|
+
required(input.aiSystemId, "SDK_SYSTEM_ID_REQUIRED");
|
|
1335
|
+
if (input.confirm !== true) throw Error("SDK_CONNECTION_REVOCATION_CONFIRMATION_REQUIRED");
|
|
1336
|
+
return this.request({ method: "POST", path: `/v1/connections/${encodeURIComponent(connectionId)}/revoke`, body: { aiSystemId: input.aiSystemId, confirm: true } }, { enforcing: true });
|
|
1337
|
+
}
|
|
1338
|
+
inventorySubjectSignalConsent() {
|
|
1339
|
+
return this.request({ method: "POST", path: "/v1/signals/subject-consent/inventory", body: {} }, { enforcing: true });
|
|
1340
|
+
}
|
|
1341
|
+
historySubjectSignalConsent() {
|
|
1342
|
+
return this.request({ method: "POST", path: "/v1/signals/subject-consent/history", body: {} }, { enforcing: true });
|
|
1343
|
+
}
|
|
1299
1344
|
inspectSubjectSignalConsent(input) {
|
|
1300
1345
|
return this.request({ method: "POST", path: "/v1/signals/subject-consent/inspect", body: input }, { enforcing: true });
|
|
1301
1346
|
}
|
|
@@ -1960,7 +2005,7 @@ var ViraClient = class {
|
|
|
1960
2005
|
return this.request({ method: "POST", path: "/v1/teach/conversations", body: { ...evidence, privacy: evidence.privacy ?? "CONSENTED_TENANT" } }, { idempotencyKey: options.idempotencyKey });
|
|
1961
2006
|
}
|
|
1962
2007
|
listConversationArchive(input = {}) {
|
|
1963
|
-
return this.request({ method: "GET", path: "/v1/teach/conversations", query: { ...input.limit === void 0 ? {} : { limit: String(input.limit) }, ...input.cursor ? { cursor: input.cursor } : {} } });
|
|
2008
|
+
return this.request({ method: "GET", path: "/v1/teach/conversations", query: { ...input.limit === void 0 ? {} : { limit: String(input.limit) }, ...input.cursor ? { cursor: input.cursor } : {}, ...input.aiSystemId ? { aiSystemId: input.aiSystemId } : {} } });
|
|
1964
2009
|
}
|
|
1965
2010
|
importConversationArchive(conversations, options = {}) {
|
|
1966
2011
|
if (!Array.isArray(conversations) || !conversations.length) throw new Error("SDK_CONVERSATION_IMPORT_REQUIRED");
|
|
@@ -2009,10 +2054,12 @@ var ViraClient = class {
|
|
|
2009
2054
|
required(teachRunId, "SDK_TEACH_RUN_ID_REQUIRED");
|
|
2010
2055
|
return this.request({ method: "GET", path: `/v1/teach/runs/${encodeURIComponent(teachRunId)}/recommendation` });
|
|
2011
2056
|
}
|
|
2012
|
-
acceptTeachRecommendation(teachRunId, actorId, options = {}) {
|
|
2057
|
+
async acceptTeachRecommendation(teachRunId, actorId, options = {}) {
|
|
2013
2058
|
required(teachRunId, "SDK_TEACH_RUN_ID_REQUIRED");
|
|
2014
|
-
required(actorId, "SDK_TEACH_RECOMMENDATION_ACTOR_REQUIRED");
|
|
2015
|
-
|
|
2059
|
+
if (actorId !== void 0) required(actorId, "SDK_TEACH_RECOMMENDATION_ACTOR_REQUIRED");
|
|
2060
|
+
if ((options.basePackId !== void 0 || options.basePackDigest !== void 0) && (!options.basePackId?.trim() || !options.basePackDigest || !/^[a-f0-9]{64}$/.test(options.basePackDigest))) throw Error("SDK_TEACH_BASE_PACK_INVALID");
|
|
2061
|
+
const body = { ...actorId === void 0 ? {} : { actorId }, ...options.basePackId === void 0 ? {} : { basePackId: options.basePackId, basePackDigest: options.basePackDigest } };
|
|
2062
|
+
return this.request({ method: "POST", path: `/v1/teach/runs/${encodeURIComponent(teachRunId)}/recommendation/accept`, body }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:teach:recommendation:accept:${teachRunId}`, body) });
|
|
2016
2063
|
}
|
|
2017
2064
|
rejectTeachRecommendation(teachRunId, reason, options = {}) {
|
|
2018
2065
|
required(teachRunId, "SDK_TEACH_RUN_ID_REQUIRED");
|
|
@@ -2041,6 +2088,10 @@ var ViraClient = class {
|
|
|
2041
2088
|
{ idempotencyKey: options.idempotencyKey }
|
|
2042
2089
|
);
|
|
2043
2090
|
}
|
|
2091
|
+
/** Run scoped normal-Pack quality evaluation; does not publish or verify live runtime. */
|
|
2092
|
+
startWholePackQualityEvaluation(input, options = {}) {
|
|
2093
|
+
return this.startEvaluation({ id: input.id, aiSystemId: input.aiSystemId, packId: input.packId, packDigest: input.packDigest, dataset: input.dataset.map((c) => ({ id: c.id, programId: c.programId, input: c.input, rubric: [...c.rubric] })), wholePackEvaluation: true, ...input.modelSelection ? { modelSelection: input.modelSelection } : {} }, options);
|
|
2094
|
+
}
|
|
2044
2095
|
/** Request a server-executed OFF/current-ON/candidate-ON comparison.
|
|
2045
2096
|
* The server owns arm execution and receipts; callers cannot submit outputs.
|
|
2046
2097
|
*/
|
|
@@ -2063,7 +2114,7 @@ var ViraClient = class {
|
|
|
2063
2114
|
});
|
|
2064
2115
|
}
|
|
2065
2116
|
listEvaluations(input = {}) {
|
|
2066
|
-
return this.request({ method: "GET", path: "/v1/evaluations", query: { ...input.limit === void 0 ? {} : { limit: String(input.limit) }, ...input.cursor ? { cursor: input.cursor } : {}, ...input.status ? { status: input.status } : {} } });
|
|
2117
|
+
return this.request({ method: "GET", path: "/v1/evaluations", query: { ...input.limit === void 0 ? {} : { limit: String(input.limit) }, ...input.cursor ? { cursor: input.cursor } : {}, ...input.status ? { status: input.status } : {}, ...input.search ? { search: input.search } : {} } });
|
|
2067
2118
|
}
|
|
2068
2119
|
getEvaluationComparison(evaluationId) {
|
|
2069
2120
|
required(evaluationId, "SDK_EVALUATION_ID_REQUIRED");
|
|
@@ -2115,9 +2166,9 @@ var ViraClient = class {
|
|
|
2115
2166
|
if (!Array.isArray(input.dataset) || input.dataset.length === 0) throw new Error("SDK_CANDIDATE_EVALUATION_DATASET_REQUIRED");
|
|
2116
2167
|
return this.request({ method: "POST", path: `/v1/behavior-revision-candidates/${encodeURIComponent(candidateId)}/evaluate`, body: input }, { idempotencyKey: options.idempotencyKey ?? `sdk:behavior-candidate:evaluate:${candidateId}` });
|
|
2117
2168
|
}
|
|
2118
|
-
transitionBehaviorRevisionCandidate(candidateId, transition, input = {}, options = {}) {
|
|
2169
|
+
async transitionBehaviorRevisionCandidate(candidateId, transition, input = {}, options = {}) {
|
|
2119
2170
|
required(candidateId, "SDK_BEHAVIOR_CANDIDATE_ID_REQUIRED");
|
|
2120
|
-
return this.request({ method: "POST", path: `/v1/behavior-revision-candidates/${encodeURIComponent(candidateId)}/${transition}`, body: input }, { idempotencyKey: options.idempotencyKey ?? `sdk:behavior-candidate:${transition}:${candidateId}
|
|
2171
|
+
return this.request({ method: "POST", path: `/v1/behavior-revision-candidates/${encodeURIComponent(candidateId)}/${transition}`, body: input }, { idempotencyKey: options.idempotencyKey ?? await contentIdempotencyKey(`sdk:behavior-candidate:${transition}:${candidateId}`, input) });
|
|
2121
2172
|
}
|
|
2122
2173
|
createPackRevision(input, options = {}) {
|
|
2123
2174
|
return this.request({ method: "POST", path: "/v1/pack-revisions", body: input }, { idempotencyKey: options.idempotencyKey });
|
|
@@ -2242,6 +2293,9 @@ var ViraClient = class {
|
|
|
2242
2293
|
freezeDepartmentOptimizationDataset(input) {
|
|
2243
2294
|
return this.request({ method: "POST", path: "/v1/optimization/dataset-freeze", body: input }, { enforcing: true });
|
|
2244
2295
|
}
|
|
2296
|
+
inspectDepartmentOptimizationDataset(input) {
|
|
2297
|
+
return this.request({ method: "POST", path: "/v1/optimization/dataset-inspect", body: input }, { enforcing: true });
|
|
2298
|
+
}
|
|
2245
2299
|
listDepartmentOptimizationDatasets(input) {
|
|
2246
2300
|
return this.request({ method: "POST", path: "/v1/optimization/dataset-options", body: input }, { enforcing: true });
|
|
2247
2301
|
}
|
|
@@ -2422,7 +2476,7 @@ function buildObservationRequest(event) {
|
|
|
2422
2476
|
});
|
|
2423
2477
|
}
|
|
2424
2478
|
|
|
2425
|
-
//
|
|
2479
|
+
// sdks/framework-adapters.ts
|
|
2426
2480
|
function createFrameworkRuntimeCore(client) {
|
|
2427
2481
|
if (!client) throw new Error("SDK_FRAMEWORK_CLIENT_REQUIRED");
|
|
2428
2482
|
return Object.freeze({
|
|
@@ -2506,10 +2560,10 @@ function createFrameworkAdapters(client) {
|
|
|
2506
2560
|
return Object.freeze(Object.fromEntries(["openai-agents", "vercel-ai", "langchain", "langgraph", "otel", "mcp"].map((name) => [name, createFrameworkObservationAdapter(client, name)])));
|
|
2507
2561
|
}
|
|
2508
2562
|
|
|
2509
|
-
//
|
|
2563
|
+
// sdks/host-lifecycle.ts
|
|
2510
2564
|
import { createHash as createHash2 } from "node:crypto";
|
|
2511
2565
|
|
|
2512
|
-
//
|
|
2566
|
+
// sdks/host-taskrun-handoff.ts
|
|
2513
2567
|
import { createHash } from "node:crypto";
|
|
2514
2568
|
var record = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
2515
2569
|
var nonempty = (v) => typeof v === "string" && v.length > 0 && v === v.trim();
|
|
@@ -2532,7 +2586,7 @@ function readHostTaskRunState(response, expected, admission = false) {
|
|
|
2532
2586
|
return { taskRunId: expected.taskRunId, requestId: run.requestId, stateVersion: Number(run.stateVersion), mode: run.mode, status: run.status, planDigest: run.planDigest, authorityDigest: run.authorityDigest, selectedTaskKeys: tasks, checkpointExecutionDigest };
|
|
2533
2587
|
}
|
|
2534
2588
|
|
|
2535
|
-
//
|
|
2589
|
+
// contracts/external-host-commercial-v1.ts
|
|
2536
2590
|
var externalHostCommercialEvidence = Object.freeze({
|
|
2537
2591
|
schemaVersion: 1,
|
|
2538
2592
|
chargeClass: "byok",
|
|
@@ -2541,7 +2595,7 @@ var externalHostCommercialEvidence = Object.freeze({
|
|
|
2541
2595
|
managedCreditEligible: false
|
|
2542
2596
|
});
|
|
2543
2597
|
|
|
2544
|
-
//
|
|
2598
|
+
// sdks/host-lifecycle.ts
|
|
2545
2599
|
function resolveHostToolBinding(bindings, hostToolName) {
|
|
2546
2600
|
const name = hostToolName.trim();
|
|
2547
2601
|
if (!name) return null;
|
|
@@ -2632,15 +2686,18 @@ function createViraHostRuntime(client, config) {
|
|
|
2632
2686
|
if (mode === "enforce" && typeof config.authorizeAction !== "function") throw new Error("SDK_HOST_ACTION_AUTHORIZER_REQUIRED");
|
|
2633
2687
|
let connected = null;
|
|
2634
2688
|
let connectionIdentity = null;
|
|
2689
|
+
let connectionGeneration = 0;
|
|
2635
2690
|
const projections = /* @__PURE__ */ new Map();
|
|
2636
2691
|
const activeToolSessions = /* @__PURE__ */ new Map();
|
|
2637
2692
|
const connectOnce = async (options = {}) => {
|
|
2638
2693
|
if (mode === "off" || !config.connect) return null;
|
|
2639
2694
|
if (options.force) {
|
|
2695
|
+
++connectionGeneration;
|
|
2640
2696
|
connected = null;
|
|
2641
2697
|
connectionIdentity = null;
|
|
2642
2698
|
}
|
|
2643
2699
|
if (!connected) {
|
|
2700
|
+
const generation = ++connectionGeneration;
|
|
2644
2701
|
const attempt = withTimeout(client.connectOnce(config.connect), timeoutMs, "SDK_HOST_CONNECT_TIMEOUT").then((result) => {
|
|
2645
2702
|
const body = bodyOf(result);
|
|
2646
2703
|
const system = body.system && typeof body.system === "object" ? body.system : {};
|
|
@@ -2648,13 +2705,16 @@ function createViraHostRuntime(client, config) {
|
|
|
2648
2705
|
const aiSystemId = typeof system.id === "string" ? system.id.trim() : "";
|
|
2649
2706
|
const connectionId = typeof connection.id === "string" ? connection.id.trim() : "";
|
|
2650
2707
|
if (!aiSystemId || !connectionId) throw new Error("SDK_HOST_CONNECT_IDENTITY_MISSING");
|
|
2708
|
+
if (generation !== connectionGeneration) throw Error("SDK_HOST_CONNECT_SUPERSEDED");
|
|
2651
2709
|
connectionIdentity = { aiSystemId, connectionId };
|
|
2652
2710
|
return result;
|
|
2653
2711
|
});
|
|
2654
2712
|
let cachedAttempt;
|
|
2655
2713
|
cachedAttempt = attempt.catch((error) => {
|
|
2656
|
-
if (connected === cachedAttempt
|
|
2657
|
-
|
|
2714
|
+
if (connected === cachedAttempt && generation === connectionGeneration) {
|
|
2715
|
+
connected = null;
|
|
2716
|
+
connectionIdentity = null;
|
|
2717
|
+
}
|
|
2658
2718
|
throw error;
|
|
2659
2719
|
});
|
|
2660
2720
|
connected = cachedAttempt;
|
|
@@ -2837,7 +2897,7 @@ function createViraHostRuntime(client, config) {
|
|
|
2837
2897
|
return Object.freeze({ mode, capabilities, connectOnce, reconnect, getConnectionIdentity: () => connectionIdentity, beforeModel, beforeTool, afterTool, executeTool, cancelTool, endSession, getProjection: (identity) => projections.get(sessionKey({ ...identity, requestId: "projection", input: "" })), supportsPostModelVerification: capabilities.canInterceptResponseBeforeDisplay });
|
|
2838
2898
|
}
|
|
2839
2899
|
|
|
2840
|
-
//
|
|
2900
|
+
// sdks/host-completion.ts
|
|
2841
2901
|
import { createHash as createHash3, createHmac, timingSafeEqual } from "node:crypto";
|
|
2842
2902
|
var obj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
2843
2903
|
var id = (v) => typeof v === "string" && v.length > 0 && v.length <= 500 && v === v.trim();
|
|
@@ -3039,7 +3099,7 @@ async function checkHostCompletionCapabilities(input) {
|
|
|
3039
3099
|
return { verified: true, bindingDigest: b.bindingDigest, providerRecovery: value.providerRecovery };
|
|
3040
3100
|
}
|
|
3041
3101
|
|
|
3042
|
-
//
|
|
3102
|
+
// sdks/host-completion-postgres.ts
|
|
3043
3103
|
var HOST_COMPLETION_POSTGRES_SCHEMA = `
|
|
3044
3104
|
CREATE TABLE IF NOT EXISTS vira_host_completion_v1 (
|
|
3045
3105
|
invocation_id text PRIMARY KEY,
|
|
@@ -3105,7 +3165,7 @@ function createPostgresHostCompletionStore(db) {
|
|
|
3105
3165
|
};
|
|
3106
3166
|
}
|
|
3107
3167
|
|
|
3108
|
-
//
|
|
3168
|
+
// sdks/host-completion-adapters.ts
|
|
3109
3169
|
var object = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
3110
3170
|
function decodeHostEffectResult(value) {
|
|
3111
3171
|
if (!object(value) || typeof value.providerInvocationId !== "string" || !value.providerInvocationId.trim() || !Object.hasOwn(value, "result")) throw Error("HOST_COMPLETION_PROVIDER_EVIDENCE_REQUIRED");
|
package/dist/sdks/js-client.d.ts
CHANGED
|
@@ -675,6 +675,15 @@ export interface DiscoveryCandidate extends ClientBody {
|
|
|
675
675
|
label?: string;
|
|
676
676
|
evidenceIds?: string[];
|
|
677
677
|
}
|
|
678
|
+
export interface DiscoveryDispatchResult {
|
|
679
|
+
eventId: string;
|
|
680
|
+
aiSystemId: string;
|
|
681
|
+
connectionId: string;
|
|
682
|
+
jobId: string;
|
|
683
|
+
state: 'NOT_QUEUED' | 'QUEUED' | 'RUNNING' | 'SUCCEEDED' | 'FAILED';
|
|
684
|
+
attempts: number;
|
|
685
|
+
availableAt: string | null;
|
|
686
|
+
}
|
|
678
687
|
export interface DiscoveryCandidateListResult {
|
|
679
688
|
candidates: readonly DiscoveryCandidate[];
|
|
680
689
|
limit: number;
|
|
@@ -847,12 +856,68 @@ export interface AICreditReservationRecord {
|
|
|
847
856
|
ledgerEntryId: string | null;
|
|
848
857
|
usageReceiptId: string | null;
|
|
849
858
|
}
|
|
859
|
+
export interface AICreditFundingLot {
|
|
860
|
+
grantId: string;
|
|
861
|
+
kind: "included" | "purchased";
|
|
862
|
+
grantedMicrocredits: number;
|
|
863
|
+
remainingMicrocredits: number;
|
|
864
|
+
reservedMicrocredits: number;
|
|
865
|
+
expiresAt: string;
|
|
866
|
+
expired: boolean;
|
|
867
|
+
}
|
|
868
|
+
export interface AICreditFundingView {
|
|
869
|
+
status: "ALLOCATED" | "LEGACY_UNALLOCATED";
|
|
870
|
+
lots: readonly AICreditFundingLot[];
|
|
871
|
+
totals: {
|
|
872
|
+
balance: number;
|
|
873
|
+
reserved: number;
|
|
874
|
+
spendable: number;
|
|
875
|
+
expiredUnspent: number;
|
|
876
|
+
included: number;
|
|
877
|
+
purchased: number;
|
|
878
|
+
} | null;
|
|
879
|
+
}
|
|
880
|
+
export interface ManualCommercialWalletSummary {
|
|
881
|
+
status: "AVAILABLE" | "NO_ACCOUNT";
|
|
882
|
+
hasMore: boolean;
|
|
883
|
+
items: readonly {
|
|
884
|
+
id: string;
|
|
885
|
+
kind: string;
|
|
886
|
+
planVersion: string;
|
|
887
|
+
currency: string;
|
|
888
|
+
totalMinor: string;
|
|
889
|
+
startAt: string;
|
|
890
|
+
endAt: string;
|
|
891
|
+
status: string;
|
|
892
|
+
accessCurrent: boolean;
|
|
893
|
+
paymentStatus: string;
|
|
894
|
+
collectedMinor: string;
|
|
895
|
+
outstandingMinor: string;
|
|
896
|
+
overdueMinor: string;
|
|
897
|
+
creditFulfillment?: {
|
|
898
|
+
grantedAt: string;
|
|
899
|
+
expiresAt: string;
|
|
900
|
+
microcredits: string;
|
|
901
|
+
remainingMicrocredits: string;
|
|
902
|
+
reservedMicrocredits: string;
|
|
903
|
+
consumedMicrocredits: string;
|
|
904
|
+
consumedRefundMicrocredits?: string;
|
|
905
|
+
expiredRefundMicrocredits?: string;
|
|
906
|
+
recollectedRefundMinor?: string;
|
|
907
|
+
reversedMicrocredits: string;
|
|
908
|
+
expiredMicrocredits: string;
|
|
909
|
+
reversalStatus: "NONE" | "PARTIAL" | "FULL";
|
|
910
|
+
};
|
|
911
|
+
}[];
|
|
912
|
+
}
|
|
850
913
|
export interface AICreditWalletResult {
|
|
851
914
|
organizationId: string;
|
|
852
915
|
billingAccountId: string;
|
|
853
916
|
balanceMicrocredits: number;
|
|
854
917
|
entries: readonly AICreditLedgerEntry[];
|
|
855
918
|
source: "ai-credit-wallet-ledger";
|
|
919
|
+
funding?: AICreditFundingView;
|
|
920
|
+
commercial?: ManualCommercialWalletSummary;
|
|
856
921
|
}
|
|
857
922
|
export interface AICreditReservationResult {
|
|
858
923
|
organizationId: string;
|
|
@@ -1083,7 +1148,9 @@ export declare class ViraClient {
|
|
|
1083
1148
|
setOrganizationBillingAdmin(actorId: string, status?: "ACTIVE" | "REVOKED", options?: {
|
|
1084
1149
|
idempotencyKey?: string;
|
|
1085
1150
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1086
|
-
getAICreditWallet(
|
|
1151
|
+
getAICreditWallet(input?: {
|
|
1152
|
+
includeCommercial?: boolean;
|
|
1153
|
+
}): Promise<ViraResponse<AICreditWalletResult> | null>;
|
|
1087
1154
|
listAICreditBudgets(): Promise<ViraResponse<AICreditBudgetList> | null>;
|
|
1088
1155
|
listAIUsageReceipts(input?: {
|
|
1089
1156
|
organizationUnitId?: string;
|
|
@@ -1415,6 +1482,7 @@ export declare class ViraClient {
|
|
|
1415
1482
|
listOptimizationTargets(input: {
|
|
1416
1483
|
aiSystemId: string;
|
|
1417
1484
|
connectionId: string;
|
|
1485
|
+
runCursor?: string;
|
|
1418
1486
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1419
1487
|
previewOptimizationTarget(input: {
|
|
1420
1488
|
aiSystemId: string;
|
|
@@ -1481,9 +1549,32 @@ export declare class ViraClient {
|
|
|
1481
1549
|
cursor?: string;
|
|
1482
1550
|
search?: string;
|
|
1483
1551
|
}): Promise<ViraResponse<DiscoveryCandidateListResult> | null>;
|
|
1552
|
+
listReusableEvaluationDatasets(systemId: string, cursor?: string): Promise<ViraResponse<ClientBody> | null>;
|
|
1553
|
+
getReusableEvaluationDataset(systemId: string, datasetId: string, datasetDigest: string): Promise<ViraResponse<ClientBody> | null>;
|
|
1554
|
+
getFeatureCreditPreview(systemId: string, feature: string, model?: {
|
|
1555
|
+
providerId: string;
|
|
1556
|
+
modelId: string;
|
|
1557
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1558
|
+
getDiscoveryWorkerHealth(): Promise<ViraResponse<{
|
|
1559
|
+
status: "RECENT_SCAN" | "SCANNING" | "STALE" | "FAILED" | "UNAVAILABLE";
|
|
1560
|
+
lastSuccessfulScanAt: string | null;
|
|
1561
|
+
observedAt: string;
|
|
1562
|
+
}> | null>;
|
|
1563
|
+
getDiscoveryDispatch(eventId: string): Promise<ViraResponse<DiscoveryDispatchResult> | null>;
|
|
1564
|
+
queueDiscoveryDispatch(eventId: string, options?: {
|
|
1565
|
+
idempotencyKey?: string;
|
|
1566
|
+
}): Promise<ViraResponse<DiscoveryDispatchResult> | null>;
|
|
1484
1567
|
reviewDiscoveryCandidate(kind: string, key: string, input: ClientBody, options?: {
|
|
1485
1568
|
idempotencyKey?: string;
|
|
1486
1569
|
}): Promise<ViraResponse<DiscoveryCandidateReviewResult> | null>;
|
|
1570
|
+
/** Create a review-only department draft from approved semantic evidence. */
|
|
1571
|
+
createDepartmentDiscoveryDraft(key: string, input: {
|
|
1572
|
+
candidateId: string;
|
|
1573
|
+
aiSystemId: string;
|
|
1574
|
+
evidenceIds: readonly string[];
|
|
1575
|
+
}, options?: {
|
|
1576
|
+
idempotencyKey?: string;
|
|
1577
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1487
1578
|
/** Explicit canonical publication; API approval and scope checks still apply. */
|
|
1488
1579
|
publishDiscoveryCandidate(kind: string, key: string, input?: {
|
|
1489
1580
|
taskId?: string;
|
|
@@ -1544,8 +1635,11 @@ export declare class ViraClient {
|
|
|
1544
1635
|
approvePack(packId: string, options?: {
|
|
1545
1636
|
manualApproval?: boolean;
|
|
1546
1637
|
reason?: string;
|
|
1638
|
+
expectedPackDigest?: string;
|
|
1639
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1640
|
+
releasePack(packId: string, options?: {
|
|
1641
|
+
expectedPackDigest?: string;
|
|
1547
1642
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1548
|
-
releasePack(packId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
1549
1643
|
previewPackUpgrade(packId: string, incoming: ClientBody): Promise<ViraResponse<ClientBody> | null>;
|
|
1550
1644
|
executeRuntime(input: RuntimeRequest & Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
1551
1645
|
resolveRuntime(input: {
|
|
@@ -1608,6 +1702,13 @@ export declare class ViraClient {
|
|
|
1608
1702
|
proposeLegacyRecordRemediation(input: ClientBody): Promise<ViraResponse<ClientBody> | null>;
|
|
1609
1703
|
approveLegacyRecordRemediation(input: ClientBody): Promise<ViraResponse<ClientBody> | null>;
|
|
1610
1704
|
historyLegacyRecordRemediation(input?: ClientBody): Promise<ViraResponse<ClientBody> | null>;
|
|
1705
|
+
/** Native operator delegation only; never a machine key or MCP mutation. */
|
|
1706
|
+
revokeConnection(connectionId: string, input: {
|
|
1707
|
+
aiSystemId: string;
|
|
1708
|
+
confirm: true;
|
|
1709
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1710
|
+
inventorySubjectSignalConsent(): Promise<ViraResponse<ClientBody> | null>;
|
|
1711
|
+
historySubjectSignalConsent(): Promise<ViraResponse<ClientBody> | null>;
|
|
1611
1712
|
inspectSubjectSignalConsent(input: {
|
|
1612
1713
|
eventId: string;
|
|
1613
1714
|
mappingId: string;
|
|
@@ -2024,6 +2125,7 @@ export declare class ViraClient {
|
|
|
2024
2125
|
listConversationArchive(input?: {
|
|
2025
2126
|
limit?: number;
|
|
2026
2127
|
cursor?: string;
|
|
2128
|
+
aiSystemId?: string;
|
|
2027
2129
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2028
2130
|
importConversationArchive(conversations: readonly ClientBody[], options?: {
|
|
2029
2131
|
idempotencyKey?: string;
|
|
@@ -2057,8 +2159,10 @@ export declare class ViraClient {
|
|
|
2057
2159
|
status?: string;
|
|
2058
2160
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2059
2161
|
getTeachRunRecommendation(teachRunId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
2060
|
-
acceptTeachRecommendation(teachRunId: string, actorId
|
|
2162
|
+
acceptTeachRecommendation(teachRunId: string, actorId?: string, options?: {
|
|
2061
2163
|
idempotencyKey?: string;
|
|
2164
|
+
basePackId?: string;
|
|
2165
|
+
basePackDigest?: string;
|
|
2062
2166
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2063
2167
|
rejectTeachRecommendation(teachRunId: string, reason: string, options?: {
|
|
2064
2168
|
idempotencyKey?: string;
|
|
@@ -2080,6 +2184,31 @@ export declare class ViraClient {
|
|
|
2080
2184
|
startEvaluation(input: ClientBody, options?: {
|
|
2081
2185
|
idempotencyKey?: string;
|
|
2082
2186
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2187
|
+
/** Run scoped normal-Pack quality evaluation; does not publish or verify live runtime. */
|
|
2188
|
+
startWholePackQualityEvaluation(input: {
|
|
2189
|
+
id: string;
|
|
2190
|
+
aiSystemId: string;
|
|
2191
|
+
packId: string;
|
|
2192
|
+
packDigest: string;
|
|
2193
|
+
modelSelection?: {
|
|
2194
|
+
generation: {
|
|
2195
|
+
providerId: string;
|
|
2196
|
+
modelId: string;
|
|
2197
|
+
};
|
|
2198
|
+
judge: {
|
|
2199
|
+
providerId: string;
|
|
2200
|
+
modelId: string;
|
|
2201
|
+
};
|
|
2202
|
+
};
|
|
2203
|
+
dataset: readonly {
|
|
2204
|
+
id: string;
|
|
2205
|
+
programId: string;
|
|
2206
|
+
input: string;
|
|
2207
|
+
rubric: readonly string[];
|
|
2208
|
+
}[];
|
|
2209
|
+
}, options?: {
|
|
2210
|
+
idempotencyKey?: string;
|
|
2211
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2083
2212
|
/** Request a server-executed OFF/current-ON/candidate-ON comparison.
|
|
2084
2213
|
* The server owns arm execution and receipts; callers cannot submit outputs.
|
|
2085
2214
|
*/
|
|
@@ -2096,6 +2225,7 @@ export declare class ViraClient {
|
|
|
2096
2225
|
limit?: number;
|
|
2097
2226
|
cursor?: string;
|
|
2098
2227
|
status?: string;
|
|
2228
|
+
search?: string;
|
|
2099
2229
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2100
2230
|
getEvaluationComparison(evaluationId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
2101
2231
|
reviewComparativeFinding(evaluationId: string, findingId: string, input: {
|
|
@@ -2199,6 +2329,7 @@ export declare class ViraClient {
|
|
|
2199
2329
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2200
2330
|
listVerifiedHostInvocationResults(systemId: string, input?: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2201
2331
|
freezeDepartmentOptimizationDataset(input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2332
|
+
inspectDepartmentOptimizationDataset(input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2202
2333
|
listDepartmentOptimizationDatasets(input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2203
2334
|
prepareFrozenOptimizationRun(input: Record<string, unknown>, options?: {
|
|
2204
2335
|
idempotencyKey?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryvira/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.110",
|
|
4
4
|
"description": "Typed Vira SDK for connect-once, observation and governed runtime execution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vira",
|
|
@@ -45,5 +45,6 @@
|
|
|
45
45
|
"prepublishOnly": "npm run pack:check && npm run public:surface:smoke",
|
|
46
46
|
"publish:public": "npm run pack:check && npm run public:surface:smoke && npm publish --access public"
|
|
47
47
|
},
|
|
48
|
-
"license": "MIT"
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"gitHead": "def3fd5193cedfd38504f231b00727b0fb34dea0"
|
|
49
50
|
}
|