@tryvira/sdk 0.1.101 → 0.1.103
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 +219 -46
- package/dist/sdks/host-lifecycle.d.ts +5 -0
- package/dist/sdks/host-taskrun-handoff.d.ts +68 -0
- package/dist/sdks/js-client.d.ts +206 -5
- package/package.json +1 -1
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.103
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Configure the organization, project, and environment for every request. Keep the API
|
package/dist/index.js
CHANGED
|
@@ -43,8 +43,8 @@ var contentIdempotencyKey = async (operation, request) => {
|
|
|
43
43
|
if (!globalThis.crypto?.subtle) throw new Error("SDK_IDEMPOTENCY_CRYPTO_UNAVAILABLE");
|
|
44
44
|
const bytes = new TextEncoder().encode(canonicalJson(request));
|
|
45
45
|
const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
46
|
-
const
|
|
47
|
-
return `${operation}:${
|
|
46
|
+
const hex3 = [...new Uint8Array(digest2)].map((value) => value.toString(16).padStart(2, "0")).join("");
|
|
47
|
+
return `${operation}:${hex3}`;
|
|
48
48
|
};
|
|
49
49
|
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
50
50
|
var retryAfterMs = (value, now = Date.now()) => {
|
|
@@ -932,6 +932,14 @@ var ViraClient = class {
|
|
|
932
932
|
for (const [key, value] of Object.entries(query)) if (value !== void 0) params.set(key, String(value));
|
|
933
933
|
return this.request({ method: "GET", path: `/v1/runtime/traces/search${params.size ? `?${params.toString()}` : ""}` });
|
|
934
934
|
}
|
|
935
|
+
listOptimizationTargets(input) {
|
|
936
|
+
for (const value of [input.aiSystemId, input.connectionId]) required(value, "SDK_OPTIMIZATION_TARGET_REQUIRED");
|
|
937
|
+
return this.request({ method: "POST", path: "/v1/optimization/target-options", body: input }, { enforcing: true });
|
|
938
|
+
}
|
|
939
|
+
previewOptimizationTarget(input) {
|
|
940
|
+
for (const value of [input.aiSystemId, input.connectionId, input.canonicalRevisionId, input.sourceReleaseId]) required(value, "SDK_OPTIMIZATION_TARGET_REQUIRED");
|
|
941
|
+
return this.request({ method: "POST", path: "/v1/optimization/target-preview", body: input }, { enforcing: true });
|
|
942
|
+
}
|
|
935
943
|
startOptimization(input, options = {}) {
|
|
936
944
|
const key = typeof input.idempotencyKey === "string" ? input.idempotencyKey.trim() : "";
|
|
937
945
|
if (!key) throw new Error("SDK_IDEMPOTENCY_KEY_REQUIRED");
|
|
@@ -1122,6 +1130,23 @@ var ViraClient = class {
|
|
|
1122
1130
|
{ idempotencyKey: await contentIdempotencyKey(`sdk:pack:install:${packId}`, body) }
|
|
1123
1131
|
);
|
|
1124
1132
|
}
|
|
1133
|
+
async revokeSignalMapping(mappingId, expectedMappingDigest) {
|
|
1134
|
+
required(mappingId, "SDK_SIGNAL_MAPPING_ID_REQUIRED");
|
|
1135
|
+
if (!/^[a-f0-9]{64}$/.test(expectedMappingDigest)) throw Error("SDK_SIGNAL_MAPPING_DIGEST_INVALID");
|
|
1136
|
+
const body = { expectedMappingDigest };
|
|
1137
|
+
return this.request({ method: "POST", path: `/v1/signals/mappings/${encodeURIComponent(mappingId)}/revoke`, body }, { idempotencyKey: await contentIdempotencyKey(`sdk:signal-mapping:revoke:${mappingId}`, body), enforcing: true });
|
|
1138
|
+
}
|
|
1139
|
+
getPackSignalReadiness(packId) {
|
|
1140
|
+
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
1141
|
+
return this.request({ method: "GET", path: `/v1/packs/${encodeURIComponent(packId)}/doctor` });
|
|
1142
|
+
}
|
|
1143
|
+
async bindPackSignalMappings(packId, input) {
|
|
1144
|
+
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
1145
|
+
required(input.aiSystemId, "SDK_AI_SYSTEM_REQUIRED");
|
|
1146
|
+
required(input.connectionId, "SDK_CONNECTION_REQUIRED");
|
|
1147
|
+
const body = { aiSystemId: input.aiSystemId, connectionId: input.connectionId, approve: input.approve === true };
|
|
1148
|
+
return this.request({ method: "POST", path: `/v1/packs/${encodeURIComponent(packId)}/signal-mappings`, body }, { idempotencyKey: await contentIdempotencyKey(`sdk:pack:signal-mappings:${packId}`, body) });
|
|
1149
|
+
}
|
|
1125
1150
|
async diagnosePack(packId, input = {}) {
|
|
1126
1151
|
required(packId, "SDK_PACK_ID_REQUIRED");
|
|
1127
1152
|
const body = { runtimeBindings: [...input.runtimeBindings ?? []], knownVerifiers: [...input.knownVerifiers ?? []] };
|
|
@@ -1194,6 +1219,10 @@ var ViraClient = class {
|
|
|
1194
1219
|
method: "POST",
|
|
1195
1220
|
path: "/v1/runtime/resolve",
|
|
1196
1221
|
body: {
|
|
1222
|
+
...input.aiSystemId ? { aiSystemId: input.aiSystemId } : {},
|
|
1223
|
+
...input.provider !== void 0 ? { provider: input.provider } : {},
|
|
1224
|
+
...input.model !== void 0 ? { model: input.model } : {},
|
|
1225
|
+
...input.protocol !== void 0 ? { protocol: input.protocol } : {},
|
|
1197
1226
|
...input.behaviorPoint ? { behaviorPoint: input.behaviorPoint } : {},
|
|
1198
1227
|
...input.executionBoundary ? { executionBoundary: input.executionBoundary } : {},
|
|
1199
1228
|
...input.semanticContext ? { semanticContext: input.semanticContext } : {},
|
|
@@ -1213,6 +1242,10 @@ var ViraClient = class {
|
|
|
1213
1242
|
if (!input.executionBoundary || typeof input.executionBoundary !== "object")
|
|
1214
1243
|
throw new Error("SDK_EXECUTION_BOUNDARY_REQUIRED");
|
|
1215
1244
|
return this.resolveRuntime({
|
|
1245
|
+
aiSystemId: input.aiSystemId,
|
|
1246
|
+
provider: input.provider,
|
|
1247
|
+
model: input.model,
|
|
1248
|
+
protocol: input.protocol,
|
|
1216
1249
|
executionBoundary: input.executionBoundary,
|
|
1217
1250
|
...input.semanticContext ? { semanticContext: input.semanticContext } : {},
|
|
1218
1251
|
idempotencyKey: input.idempotencyKey
|
|
@@ -1340,6 +1373,10 @@ var ViraClient = class {
|
|
|
1340
1373
|
const firstCapsule = capsules.find((value) => value && typeof value === "object" && String(value.behaviorKey ?? "").trim() === receipt.taskKey) && typeof capsules.find((value) => value && typeof value === "object" && String(value.behaviorKey ?? "").trim() === receipt.taskKey) === "object" ? capsules.find((value) => value && typeof value === "object" && String(value.behaviorKey ?? "").trim() === receipt.taskKey) : capsules[0] && typeof capsules[0] === "object" ? capsules[0] : {};
|
|
1341
1374
|
const behaviorPoint = typeof firstCapsule.behaviorKey === "string" && firstCapsule.behaviorKey.trim() ? firstCapsule.behaviorKey : receipt.taskKey;
|
|
1342
1375
|
const runtime = input.executionBoundary ? await this.resolveBoundary({
|
|
1376
|
+
aiSystemId: input.aiSystemId,
|
|
1377
|
+
provider: input.provider,
|
|
1378
|
+
model: input.model,
|
|
1379
|
+
protocol: input.protocol,
|
|
1343
1380
|
executionBoundary: input.executionBoundary,
|
|
1344
1381
|
semanticContext: {
|
|
1345
1382
|
taskKey: receipt.taskKey,
|
|
@@ -1352,6 +1389,10 @@ var ViraClient = class {
|
|
|
1352
1389
|
},
|
|
1353
1390
|
idempotencyKey: input.idempotencyKey ? `sdk:runtime:${input.idempotencyKey}` : void 0
|
|
1354
1391
|
}) : await this.resolveRuntime({
|
|
1392
|
+
aiSystemId: input.aiSystemId,
|
|
1393
|
+
provider: input.provider,
|
|
1394
|
+
model: input.model,
|
|
1395
|
+
protocol: input.protocol,
|
|
1355
1396
|
semanticContext: { taskKey: receipt.taskKey, behaviorPoint, capsule: firstCapsule, ...input.revisionId ? { revisionId: input.revisionId } : {}, ...input.requestId ? { requestId: input.requestId } : {}, ...input.sessionId ? { conversationId: input.sessionId } : {}, ...input.signalAttestationRefs ? { signalAttestationRefs: input.signalAttestationRefs } : {} },
|
|
1356
1397
|
idempotencyKey: input.idempotencyKey ? `sdk:runtime:${input.idempotencyKey}` : void 0
|
|
1357
1398
|
});
|
|
@@ -1367,7 +1408,7 @@ var ViraClient = class {
|
|
|
1367
1408
|
return this.request({
|
|
1368
1409
|
method: "POST",
|
|
1369
1410
|
path: "/v1/runtime/actions/authorize",
|
|
1370
|
-
body: { executionId: input.executionId, sessionId: input.sessionId, dataVersion: input.dataVersion, scope: input.scope, context: input.context, proposal: input.proposal, ...input.approval ? { approval: input.approval } : {}, ...input.signalAttestationRefs?.length ? { signalAttestationRefs: input.signalAttestationRefs } : {}, ...input.aiSystemId ? { aiSystemId: input.aiSystemId } : {} }
|
|
1411
|
+
body: { executionId: input.executionId, sessionId: input.sessionId, dataVersion: input.dataVersion, scope: input.scope, context: input.context, proposal: input.proposal, ...input.approval ? { approval: input.approval } : {}, ...input.signalAttestationRefs?.length ? { signalAttestationRefs: input.signalAttestationRefs } : {}, ...input.aiSystemId ? { aiSystemId: input.aiSystemId } : {}, ...input.connectionId ? { connectionId: input.connectionId } : {} }
|
|
1371
1412
|
});
|
|
1372
1413
|
}
|
|
1373
1414
|
/** Queue the approved SINGLE effect on the worker, never execute it locally. */
|
|
@@ -1459,24 +1500,44 @@ var ViraClient = class {
|
|
|
1459
1500
|
{ idempotencyKey: options.idempotencyKey }
|
|
1460
1501
|
);
|
|
1461
1502
|
}
|
|
1462
|
-
|
|
1503
|
+
/** Create a separate immutable draft revision against a specific observed parent.
|
|
1504
|
+
* This never activates or releases the draft. */
|
|
1505
|
+
reviseBehaviorStrategy(strategyId, definition, parent, options = {}) {
|
|
1506
|
+
required(strategyId, "SDK_STRATEGY_ID_REQUIRED");
|
|
1507
|
+
if (!definition || typeof definition !== "object" || Array.isArray(definition))
|
|
1508
|
+
throw new Error("SDK_STRATEGY_VARIANT_REQUIRED");
|
|
1509
|
+
if (!parent || typeof parent.variantId !== "string" || !parent.variantId.trim() || parent.variantId.trim() !== parent.variantId || parent.variantId.length > 512 || typeof parent.artifactDigest !== "string" || !/^[a-f0-9]{64}$/.test(parent.artifactDigest) || typeof parent.definitionDigest !== "string" || !/^[a-f0-9]{64}$/.test(parent.definitionDigest))
|
|
1510
|
+
throw new Error("SDK_STRATEGY_PARENT_INVALID");
|
|
1511
|
+
return this.createBehaviorStrategyVariant(strategyId, {
|
|
1512
|
+
definition,
|
|
1513
|
+
studioBoundAuthoring: true,
|
|
1514
|
+
expectedParentVariantId: parent.variantId,
|
|
1515
|
+
expectedParentArtifactDigest: parent.artifactDigest,
|
|
1516
|
+
expectedParentDefinitionDigest: parent.definitionDigest
|
|
1517
|
+
}, options);
|
|
1518
|
+
}
|
|
1519
|
+
validateBehaviorStrategy(strategyId, options = {}) {
|
|
1463
1520
|
required(strategyId, "SDK_STRATEGY_ID_REQUIRED");
|
|
1521
|
+
if (options.variantId !== void 0 && (typeof options.variantId !== "string" || !options.variantId.trim() || options.variantId.trim() !== options.variantId || options.variantId.length > 512))
|
|
1522
|
+
throw new Error("SDK_STRATEGY_VARIANT_ID_INVALID");
|
|
1464
1523
|
return this.request({
|
|
1465
1524
|
method: "POST",
|
|
1466
1525
|
path: `/v1/behavior-strategies/${encodeURIComponent(strategyId)}/validate`,
|
|
1467
|
-
body: {}
|
|
1526
|
+
body: options.variantId === void 0 ? {} : { variantId: options.variantId }
|
|
1468
1527
|
});
|
|
1469
1528
|
}
|
|
1470
1529
|
activateBehaviorStrategy(strategyId) {
|
|
1471
1530
|
required(strategyId, "SDK_STRATEGY_ID_REQUIRED");
|
|
1472
1531
|
return this.request({ method: "POST", path: `/v1/behavior-strategies/${encodeURIComponent(strategyId)}/activate`, body: {} });
|
|
1473
1532
|
}
|
|
1474
|
-
simulateBehaviorStrategy(strategyId, initialState = {}) {
|
|
1533
|
+
simulateBehaviorStrategy(strategyId, initialState = {}, options = {}) {
|
|
1475
1534
|
required(strategyId, "SDK_STRATEGY_ID_REQUIRED");
|
|
1535
|
+
if (options.variantId !== void 0 && (typeof options.variantId !== "string" || !options.variantId.trim() || options.variantId.trim() !== options.variantId || options.variantId.length > 512))
|
|
1536
|
+
throw new Error("SDK_STRATEGY_VARIANT_ID_INVALID");
|
|
1476
1537
|
return this.request({
|
|
1477
1538
|
method: "POST",
|
|
1478
1539
|
path: `/v1/behavior-strategies/${encodeURIComponent(strategyId)}/simulate`,
|
|
1479
|
-
body: { initialState }
|
|
1540
|
+
body: { initialState, ...options.variantId === void 0 ? {} : { variantId: options.variantId } }
|
|
1480
1541
|
});
|
|
1481
1542
|
}
|
|
1482
1543
|
startStrategyExecution(input) {
|
|
@@ -1568,22 +1629,25 @@ var ViraClient = class {
|
|
|
1568
1629
|
continueStrategyExecution(executionId, continuation) {
|
|
1569
1630
|
required(executionId, "SDK_EXECUTION_ID_REQUIRED");
|
|
1570
1631
|
const input = typeof continuation === "string" ? { authorityDigest: continuation } : continuation ?? {};
|
|
1632
|
+
if (input.expectedSequence !== void 0 && (!Number.isSafeInteger(input.expectedSequence) || input.expectedSequence < 0)) throw Error("SDK_STRATEGY_SEQUENCE_INVALID");
|
|
1571
1633
|
return this.request({
|
|
1572
1634
|
method: "POST",
|
|
1573
1635
|
path: `/v1/runtime/strategy-executions/${encodeURIComponent(executionId)}/continue`,
|
|
1574
1636
|
body: {
|
|
1575
1637
|
...input.authorityDigest ? { authorityDigest: input.authorityDigest } : {},
|
|
1638
|
+
...input.expectedSequence !== void 0 ? { expectedSequence: input.expectedSequence } : {},
|
|
1576
1639
|
...input.state ? { state: input.state } : {},
|
|
1577
1640
|
...input.references ? { references: input.references } : {}
|
|
1578
1641
|
}
|
|
1579
1642
|
});
|
|
1580
1643
|
}
|
|
1581
|
-
cancelStrategyExecution(executionId) {
|
|
1644
|
+
cancelStrategyExecution(executionId, options = {}) {
|
|
1582
1645
|
required(executionId, "SDK_EXECUTION_ID_REQUIRED");
|
|
1646
|
+
if (options.expectedSequence !== void 0 && (!Number.isSafeInteger(options.expectedSequence) || options.expectedSequence < 0)) throw Error("SDK_STRATEGY_SEQUENCE_INVALID");
|
|
1583
1647
|
return this.request({
|
|
1584
1648
|
method: "POST",
|
|
1585
1649
|
path: `/v1/runtime/strategy-executions/${encodeURIComponent(executionId)}/cancel`,
|
|
1586
|
-
body: {}
|
|
1650
|
+
body: { ...options.authorityDigest !== void 0 ? { authorityDigest: options.authorityDigest } : {}, ...options.expectedSequence !== void 0 ? { expectedSequence: options.expectedSequence } : {} }
|
|
1587
1651
|
});
|
|
1588
1652
|
}
|
|
1589
1653
|
listCompoundTaskPlans(options = {}) {
|
|
@@ -1622,13 +1686,24 @@ var ViraClient = class {
|
|
|
1622
1686
|
const requestId = input.requestId ?? `sdk-task-run-${id2()}`;
|
|
1623
1687
|
return this.startTaskRun({ taskRunId: input.taskRunId ?? `task-run-${id2()}`, requestId, aiSystemId: input.aiSystemId, 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 } : {}, ...input.hostCapabilities ? { hostCapabilities: [...input.hostCapabilities] } : {} }, options);
|
|
1624
1688
|
}
|
|
1689
|
+
/** Read authorized history; partial without a cursor is not complete. */
|
|
1690
|
+
listTaskRuns(options = {}) {
|
|
1691
|
+
const limit = options.limit === void 0 ? 50 : options.limit;
|
|
1692
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100) throw new Error("SDK_TASKRUN_HISTORY_LIMIT_INVALID");
|
|
1693
|
+
const cursor = options.cursor;
|
|
1694
|
+
if (cursor !== void 0 && (typeof cursor !== "string" || !cursor.length || cursor.length > 256 || cursor !== cursor.trim())) throw new Error("SDK_TASKRUN_HISTORY_CURSOR_INVALID");
|
|
1695
|
+
const { aiSystemId, conversationId } = options;
|
|
1696
|
+
const scoped = aiSystemId !== void 0 || conversationId !== void 0;
|
|
1697
|
+
if (scoped && [aiSystemId, conversationId].some((value) => typeof value !== "string" || !value.length || value.length > 256 || value !== value.trim())) throw Error("SDK_TASKRUN_HISTORY_SESSION_SELECTION_INVALID");
|
|
1698
|
+
return this.request({ method: "GET", path: "/v1/task-runs", query: { limit: String(limit), ...cursor !== void 0 ? { cursor } : {}, ...scoped ? { aiSystemId, conversationId } : {} } });
|
|
1699
|
+
}
|
|
1625
1700
|
getTaskRun(taskRunId) {
|
|
1626
1701
|
required(taskRunId, "SDK_TASKRUN_ID_REQUIRED");
|
|
1627
1702
|
return this.request({ method: "GET", path: `/v1/task-runs/${encodeURIComponent(taskRunId)}` });
|
|
1628
1703
|
}
|
|
1629
|
-
getTaskRunEvidence(taskRunId) {
|
|
1704
|
+
getTaskRunEvidence(taskRunId, options = {}) {
|
|
1630
1705
|
required(taskRunId, "SDK_TASKRUN_ID_REQUIRED");
|
|
1631
|
-
return this.request({ method: "GET", path: `/v1/task-runs/${encodeURIComponent(taskRunId)}/evidence
|
|
1706
|
+
return this.request({ method: "GET", path: `/v1/task-runs/${encodeURIComponent(taskRunId)}/evidence`, ...options.includeResult === true ? { query: { includeResult: "true" } } : {} });
|
|
1632
1707
|
}
|
|
1633
1708
|
listTaskRunEvents(taskRunId) {
|
|
1634
1709
|
required(taskRunId, "SDK_TASKRUN_ID_REQUIRED");
|
|
@@ -2160,6 +2235,66 @@ var ViraClient = class {
|
|
|
2160
2235
|
if (!aiSystemId.trim() || !unitId.trim()) throw new Error("SDK_AI_SYSTEM_UNIT_GRANT_REQUIRED");
|
|
2161
2236
|
return this.request({ method: "DELETE", path: `/v1/ai-systems/${encodeURIComponent(aiSystemId)}/unit-grants/${encodeURIComponent(unitId)}`, body: {} }, { idempotencyKey: options.idempotencyKey ?? `sdk:ai-system-unit-revoke:${globalThis.crypto.randomUUID()}`, enforcing: true });
|
|
2162
2237
|
}
|
|
2238
|
+
listVerifiedHostInvocationResults(systemId, input = {}) {
|
|
2239
|
+
required(systemId, "SDK_AI_SYSTEM_ID_REQUIRED");
|
|
2240
|
+
return this.request({ method: "POST", path: `/v1/ai-systems/${encodeURIComponent(systemId)}/clone-cutover/route/reconcile/host-candidates`, body: input }, { enforcing: true });
|
|
2241
|
+
}
|
|
2242
|
+
freezeDepartmentOptimizationDataset(input) {
|
|
2243
|
+
return this.request({ method: "POST", path: "/v1/optimization/dataset-freeze", body: input }, { enforcing: true });
|
|
2244
|
+
}
|
|
2245
|
+
listDepartmentOptimizationDatasets(input) {
|
|
2246
|
+
return this.request({ method: "POST", path: "/v1/optimization/dataset-options", body: input }, { enforcing: true });
|
|
2247
|
+
}
|
|
2248
|
+
prepareFrozenOptimizationRun(input, options = {}) {
|
|
2249
|
+
return this.request({ method: "POST", path: "/v1/optimization/prepare-frozen", body: input }, { idempotencyKey: options.idempotencyKey, enforcing: true });
|
|
2250
|
+
}
|
|
2251
|
+
executeFrozenOptimizationRun(input, options = {}) {
|
|
2252
|
+
return this.request({ method: "POST", path: "/v1/optimization/execute-frozen", body: input }, { idempotencyKey: options.idempotencyKey, enforcing: true });
|
|
2253
|
+
}
|
|
2254
|
+
proposeNativePolicyScenarios(input) {
|
|
2255
|
+
return this.request({ method: "POST", path: "/v1/evaluations/policy-scenarios", body: input }, { enforcing: true });
|
|
2256
|
+
}
|
|
2257
|
+
previewNativePolicyScenarios(input) {
|
|
2258
|
+
return this.request({ method: "POST", path: "/v1/evaluations/policy-preview", body: input }, { enforcing: true });
|
|
2259
|
+
}
|
|
2260
|
+
admitNativeEvaluationTeachFeedback(evaluationId, input, options = {}) {
|
|
2261
|
+
required(evaluationId, "SDK_EVALUATION_ID_REQUIRED");
|
|
2262
|
+
return this.request({ method: "POST", path: `/v1/evaluations/${encodeURIComponent(evaluationId)}/teach-feedback`, body: input }, { idempotencyKey: options.idempotencyKey, enforcing: true });
|
|
2263
|
+
}
|
|
2264
|
+
previewNativeTeachDraftRevision(proposalId, input) {
|
|
2265
|
+
required(proposalId, "SDK_PROPOSAL_ID_REQUIRED");
|
|
2266
|
+
return this.request({ method: "POST", path: `/v1/behavior-improvement-proposals/${encodeURIComponent(proposalId)}/native-draft-preview`, body: input }, { enforcing: true });
|
|
2267
|
+
}
|
|
2268
|
+
applyNativeTeachDraftRevision(proposalId, input, options = {}) {
|
|
2269
|
+
required(proposalId, "SDK_PROPOSAL_ID_REQUIRED");
|
|
2270
|
+
return this.request({ method: "POST", path: `/v1/behavior-improvement-proposals/${encodeURIComponent(proposalId)}/native-draft-apply`, body: input }, { idempotencyKey: options.idempotencyKey, enforcing: true });
|
|
2271
|
+
}
|
|
2272
|
+
compareNativeTeachRevision(input) {
|
|
2273
|
+
return this.request({ method: "POST", path: "/v1/evaluations/native-revision-comparison", body: input }, { enforcing: true });
|
|
2274
|
+
}
|
|
2275
|
+
getNativeTeachRevisionHistory(proposalId) {
|
|
2276
|
+
required(proposalId, "SDK_PROPOSAL_ID_REQUIRED");
|
|
2277
|
+
return this.request({ method: "GET", path: `/v1/behavior-improvement-proposals/${encodeURIComponent(proposalId)}/native-draft-history` });
|
|
2278
|
+
}
|
|
2279
|
+
getNativeRevisionComparisonSource(candidatePackId) {
|
|
2280
|
+
required(candidatePackId, "SDK_CANDIDATE_PACK_ID_REQUIRED");
|
|
2281
|
+
return this.request({ method: "GET", path: `/v1/evaluations/native-revision-source/${encodeURIComponent(candidatePackId)}` });
|
|
2282
|
+
}
|
|
2283
|
+
listStrategyConnectionOptions(input) {
|
|
2284
|
+
required(input.aiSystemId, "SDK_AI_SYSTEM_ID_REQUIRED");
|
|
2285
|
+
return this.request({ method: "GET", path: "/v1/task-runs/strategy-connections/options", query: { aiSystemId: input.aiSystemId } });
|
|
2286
|
+
}
|
|
2287
|
+
listOptimizationReviewOptions(input) {
|
|
2288
|
+
return this.request({ method: "POST", path: "/v1/optimization/review-options", body: input }, { enforcing: true });
|
|
2289
|
+
}
|
|
2290
|
+
listOptimizerEvaluationHistory(runId) {
|
|
2291
|
+
required(runId, "SDK_OPTIMIZATION_RUN_ID_REQUIRED");
|
|
2292
|
+
return this.request({ method: "GET", path: `/v1/optimization/runs/${encodeURIComponent(runId)}/evaluation-history` });
|
|
2293
|
+
}
|
|
2294
|
+
previewOptimizerStrategyPromotion(runId, input, options = {}) {
|
|
2295
|
+
required(runId, "SDK_OPTIMIZATION_RUN_ID_REQUIRED");
|
|
2296
|
+
return this.request({ method: "POST", path: `/v1/optimization/runs/${encodeURIComponent(runId)}/promote-preview`, body: input }, { idempotencyKey: options.idempotencyKey, enforcing: true });
|
|
2297
|
+
}
|
|
2163
2298
|
};
|
|
2164
2299
|
function buildRuntimeRequest(input, options = {}) {
|
|
2165
2300
|
const {
|
|
@@ -2372,7 +2507,30 @@ function createFrameworkAdapters(client) {
|
|
|
2372
2507
|
}
|
|
2373
2508
|
|
|
2374
2509
|
// ../../sdks/host-lifecycle.ts
|
|
2510
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
2511
|
+
|
|
2512
|
+
// ../../sdks/host-taskrun-handoff.ts
|
|
2375
2513
|
import { createHash } from "node:crypto";
|
|
2514
|
+
var record = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
2515
|
+
var nonempty = (v) => typeof v === "string" && v.length > 0 && v === v.trim();
|
|
2516
|
+
var hex = (v) => typeof v === "string" && /^[a-f0-9]{64}$/.test(v) && v !== "0".repeat(64);
|
|
2517
|
+
var statuses = ["PLANNED", "ADMITTED", "RUNNING", "WAITING_USER", "WAITING_HOST", "WAITING_APPROVAL", "PARTIAL", "COMPLETED", "FAILED", "BLOCKED", "CANCELLED"];
|
|
2518
|
+
function stableHostTaskRunRequest(identity, messageId, input) {
|
|
2519
|
+
if (![identity.organizationId, identity.projectId, identity.environmentId, identity.aiSystemId, identity.conversationId, messageId, input].every(nonempty)) throw Error("HOST_TASKRUN_MESSAGE_IDENTITY_REQUIRED");
|
|
2520
|
+
return "host-turn:" + createHash("sha256").update(JSON.stringify([identity.organizationId, identity.projectId, identity.environmentId, identity.organizationUnitId ?? null, identity.aiSystemId, identity.conversationId, identity.sessionId ?? identity.conversationId, messageId, input])).digest("hex");
|
|
2521
|
+
}
|
|
2522
|
+
function readHostTaskRunState(response, expected, admission = false) {
|
|
2523
|
+
const envelope = record(response), body = record(envelope.body), run = record(body.taskRun);
|
|
2524
|
+
if (envelope.status !== (admission ? 201 : 200) || admission && body.proposalOnly !== false || run.taskRunId !== expected.taskRunId || run.aiSystemId !== expected.aiSystemId || run.conversationId !== expected.conversationId || ["organizationId", "projectId", "environmentId", "organizationUnitId"].some((key) => run[key] !== expected[key]) || !nonempty(run.requestId) || expected.requestId !== void 0 && run.requestId !== expected.requestId || !Number.isSafeInteger(run.stateVersion) || Number(run.stateVersion) < (expected.minimumVersion ?? 0) || !hex(run.planDigest) || !hex(run.authorityDigest) || expected.planDigest !== void 0 && run.planDigest !== expected.planDigest || expected.authorityDigest !== void 0 && run.authorityDigest !== expected.authorityDigest || !["COMPOUND", "HYBRID"].includes(String(run.mode)) || expected.mode !== void 0 && run.mode !== expected.mode || !statuses.includes(run.status)) throw Error("HOST_TASKRUN_HANDOFF_EVIDENCE_INVALID");
|
|
2525
|
+
if (expected.status !== void 0 && run.stateVersion === expected.minimumVersion && run.status !== expected.status) throw Error("HOST_TASKRUN_HANDOFF_EVIDENCE_INVALID");
|
|
2526
|
+
const tasks = run.selectedTaskKeys;
|
|
2527
|
+
if (!Array.isArray(tasks) || tasks.length < 2 || tasks.some((t) => !nonempty(t)) || new Set(tasks).size !== tasks.length || expected.selectedTaskKeys !== void 0 && (tasks.length !== expected.selectedTaskKeys.length || expected.selectedTaskKeys.some((t) => !tasks.includes(t)))) throw Error("HOST_TASKRUN_HANDOFF_TASK_SET_MISMATCH");
|
|
2528
|
+
if (admission && run.status !== "ADMITTED") throw Error("HOST_TASKRUN_NOT_ADMITTED");
|
|
2529
|
+
const checkpoint = record(run.checkpoint), checkpointExecutionDigest = checkpoint.executionDigest;
|
|
2530
|
+
if (checkpointExecutionDigest !== void 0 && !hex(checkpointExecutionDigest)) throw Error("HOST_TASKRUN_HANDOFF_EVIDENCE_INVALID");
|
|
2531
|
+
if (!admission && run.stateVersion === expected.minimumVersion && Object.hasOwn(expected, "checkpointExecutionDigest") && checkpointExecutionDigest !== expected.checkpointExecutionDigest) throw Error("HOST_TASKRUN_HANDOFF_EVIDENCE_INVALID");
|
|
2532
|
+
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
|
+
}
|
|
2376
2534
|
|
|
2377
2535
|
// ../../contracts/external-host-commercial-v1.ts
|
|
2378
2536
|
var externalHostCommercialEvidence = Object.freeze({
|
|
@@ -2458,7 +2616,7 @@ var bodyOf = (response) => {
|
|
|
2458
2616
|
};
|
|
2459
2617
|
var isAllow = (decision) => decision.decision === "ALLOW" && /^[a-f0-9]{64}$/.test(decision.authorityReceiptDigest ?? "") && /^[a-f0-9]{64}$/.test(decision.decisionDigest ?? "");
|
|
2460
2618
|
var canonical = (value) => Array.isArray(value) ? `[${value.map(canonical).join(",")}]` : value && typeof value === "object" ? `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, child]) => `${JSON.stringify(key)}:${canonical(child)}`).join(",")}}` : JSON.stringify(value);
|
|
2461
|
-
var digest = (value) =>
|
|
2619
|
+
var digest = (value) => createHash2("sha256").update(canonical(value), "utf8").digest("hex");
|
|
2462
2620
|
function createViraHostRuntime(client, config) {
|
|
2463
2621
|
if (!client) throw new Error("SDK_HOST_CLIENT_REQUIRED");
|
|
2464
2622
|
const mode = config.mode ?? "off";
|
|
@@ -2518,8 +2676,18 @@ function createViraHostRuntime(client, config) {
|
|
|
2518
2676
|
const profile = request.profile || {};
|
|
2519
2677
|
const existingHierarchy = profile.scopeHierarchy && typeof profile.scopeHierarchy === "object" && !Array.isArray(profile.scopeHierarchy) ? profile.scopeHierarchy : {};
|
|
2520
2678
|
const scopedProfile = request.workspaceId || request.userId ? { ...profile, scopeHierarchy: { ...existingHierarchy, ...request.workspaceId ? { workspaceId: request.workspaceId } : {}, ...request.userId ? { userId: request.userId } : {}, sessionId: request.sessionId ?? request.conversationId } } : request.profile;
|
|
2521
|
-
const
|
|
2679
|
+
const target = profile.model && typeof profile.model === "object" && !Array.isArray(profile.model) ? profile.model : {};
|
|
2680
|
+
const provider = typeof target.provider === "string" && target.provider.trim() ? target.provider.trim() : void 0;
|
|
2681
|
+
const model = typeof target.name === "string" && target.name.trim() ? target.name.trim() : void 0;
|
|
2682
|
+
const protocol = target.protocol === "openai-chat" || target.protocol === "anthropic-messages" || target.protocol === "generic-chat" ? target.protocol : void 0;
|
|
2683
|
+
const semantic = await withTimeout(client.resolveSemanticRuntime({ input: request.input, aiSystemId: request.aiSystemId, ...provider ? { provider } : {}, ...model ? { model } : {}, ...protocol ? { protocol } : {}, profile: scopedProfile, revisionId: request.revisionId, sessionId: request.sessionId ?? request.conversationId, requestId: request.requestId, signalAttestationRefs: request.signalAttestationRefs }), timeoutMs, "SDK_HOST_RESOLVE_TIMEOUT");
|
|
2522
2684
|
if (!semantic) return { status: "unavailable", reasonCode: "VIRA_SEMANTIC_UNAVAILABLE" };
|
|
2685
|
+
if (semantic.multiTask === true && config.multiTaskHandoff === "server-owned") {
|
|
2686
|
+
projections.delete(sessionKey(request));
|
|
2687
|
+
if (mode === "observe") return { status: "abstain", selectedTaskKeys: semantic.taskKeys, reasonCode: "HOST_TASKRUN_OBSERVE_ONLY" };
|
|
2688
|
+
if (!Array.isArray(semantic.taskKeys) || semantic.taskKeys.length < 2 || typeof client.startTaskRunFromPrompt !== "function") return { status: "unavailable", reasonCode: "HOST_TASKRUN_HANDOFF_UNAVAILABLE" };
|
|
2689
|
+
if (!request.hostMessageId?.trim()) return { status: "unavailable", reasonCode: "HOST_TASKRUN_MESSAGE_IDENTITY_REQUIRED" };
|
|
2690
|
+
}
|
|
2523
2691
|
if (semantic.multiTask === true && semantic.taskKeys?.length > 1 && typeof client.startTaskRunFromPrompt === "function") {
|
|
2524
2692
|
try {
|
|
2525
2693
|
const hostCapabilities = [
|
|
@@ -2529,7 +2697,12 @@ function createViraHostRuntime(client, config) {
|
|
|
2529
2697
|
...capabilities.canPreventSideEffect ? ["external_action"] : [],
|
|
2530
2698
|
...capabilities.canInspectToolAfter ? ["tool_result"] : []
|
|
2531
2699
|
];
|
|
2532
|
-
const
|
|
2700
|
+
const admissionRequestId = config.multiTaskHandoff === "server-owned" ? stableHostTaskRunRequest(request, request.hostMessageId, request.input) : request.requestId;
|
|
2701
|
+
const admitted = await withTimeout(client.startTaskRunFromPrompt({ aiSystemId: request.aiSystemId, input: request.input, taskRunId: `host-task-run-${admissionRequestId}`, requestId: admissionRequestId, conversationId: request.conversationId, traceRootRef: request.traceId, ...request.connectionId ? { connectionId: request.connectionId } : {}, hostCapabilities }), timeoutMs, "SDK_HOST_TASKRUN_ADMISSION_TIMEOUT");
|
|
2702
|
+
if (config.multiTaskHandoff === "server-owned") {
|
|
2703
|
+
const verified = readHostTaskRunState(admitted, { ...request, taskRunId: `host-task-run-${admissionRequestId}`, requestId: admissionRequestId, selectedTaskKeys: semantic.taskKeys }, true);
|
|
2704
|
+
return { status: "task_run", response: admitted, taskRunId: verified.taskRunId, taskRunStateVersion: verified.stateVersion, selectedTaskKeys: verified.selectedTaskKeys };
|
|
2705
|
+
}
|
|
2533
2706
|
const admittedBody = bodyOf(admitted);
|
|
2534
2707
|
const taskRun = admittedBody.taskRun && typeof admittedBody.taskRun === "object" ? admittedBody.taskRun : {};
|
|
2535
2708
|
const taskRunId = typeof taskRun.taskRunId === "string" ? taskRun.taskRunId : `host-task-run-${request.requestId}`;
|
|
@@ -2665,10 +2838,10 @@ function createViraHostRuntime(client, config) {
|
|
|
2665
2838
|
}
|
|
2666
2839
|
|
|
2667
2840
|
// ../../sdks/host-completion.ts
|
|
2668
|
-
import { createHash as
|
|
2841
|
+
import { createHash as createHash3, createHmac, timingSafeEqual } from "node:crypto";
|
|
2669
2842
|
var obj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
2670
2843
|
var id = (v) => typeof v === "string" && v.length > 0 && v.length <= 500 && v === v.trim();
|
|
2671
|
-
var
|
|
2844
|
+
var hex2 = (v) => typeof v === "string" && /^[a-f0-9]{64}$/.test(v);
|
|
2672
2845
|
var scopeKeys = ["organizationId", "projectId", "environmentId", "organizationUnitId"];
|
|
2673
2846
|
var validScope = (v) => obj(v) && Object.keys(v).length === 4 && scopeKeys.every((k) => id(v[k]));
|
|
2674
2847
|
var sameScope = (a, b) => validScope(a) && scopeKeys.every((k) => a[k] === b[k]);
|
|
@@ -2693,10 +2866,10 @@ function canonicalHostCompletionJson(v) {
|
|
|
2693
2866
|
const encode = (x) => Array.isArray(x) ? "[" + x.map(encode).join(",") + "]" : x !== null && typeof x === "object" ? "{" + Object.keys(x).sort().map((k) => JSON.stringify(k) + ":" + encode(x[k])).join(",") + "}" : JSON.stringify(x);
|
|
2694
2867
|
return encode(v);
|
|
2695
2868
|
}
|
|
2696
|
-
var hostCompletionDigest = (v) =>
|
|
2697
|
-
var constantEqual = (a, b) => timingSafeEqual(
|
|
2869
|
+
var hostCompletionDigest = (v) => createHash3("sha256").update(canonicalHostCompletionJson(v)).digest("hex");
|
|
2870
|
+
var constantEqual = (a, b) => timingSafeEqual(createHash3("sha256").update(a).digest(), createHash3("sha256").update(b).digest());
|
|
2698
2871
|
function signHostCompletion(request, requestDigest, outcome, key) {
|
|
2699
|
-
if (key.length < 32 || !
|
|
2872
|
+
if (key.length < 32 || !hex2(requestDigest) || requestDigest !== hostCompletionDigest(request) || !id(outcome.providerInvocationId)) throw Error("HOST_COMPLETION_SIGNING_INVALID");
|
|
2700
2873
|
assertJson(outcome.result);
|
|
2701
2874
|
const receipt = { schemaVersion: 1, status: "COMPLETED", invocationId: request.invocationId, requestDigest, providerInvocationId: outcome.providerInvocationId, resultDigest: hostCompletionDigest(outcome.result) };
|
|
2702
2875
|
const completion = { receipt, signature: createHmac("sha256", key).update(canonicalHostCompletionJson(receipt)).digest("hex"), result: outcome.result };
|
|
@@ -2704,27 +2877,27 @@ function signHostCompletion(request, requestDigest, outcome, key) {
|
|
|
2704
2877
|
if (Buffer.byteLength(JSON.stringify(completion), "utf8") > 128 * 1024) throw Error("HOST_COMPLETION_RECEIPT_LIMIT");
|
|
2705
2878
|
return completion;
|
|
2706
2879
|
}
|
|
2707
|
-
function verifyStored(
|
|
2708
|
-
const { request, requestDigest, completion } =
|
|
2880
|
+
function verifyStored(record2, binding) {
|
|
2881
|
+
const { request, requestDigest, completion } = record2;
|
|
2709
2882
|
validateRequest(request, binding);
|
|
2710
2883
|
if (requestDigest !== hostCompletionDigest(request)) throw Error("HOST_COMPLETION_STORE_CORRUPT");
|
|
2711
2884
|
if (completion) {
|
|
2712
2885
|
const expected = signHostCompletion(request, requestDigest, { providerInvocationId: completion.receipt.providerInvocationId, result: completion.result }, binding.receiptKey);
|
|
2713
2886
|
if (!constantEqual(expected.signature, completion.signature) || hostCompletionDigest(expected) !== hostCompletionDigest(completion)) throw Error("HOST_COMPLETION_STORE_CORRUPT");
|
|
2714
2887
|
}
|
|
2715
|
-
return
|
|
2888
|
+
return record2;
|
|
2716
2889
|
}
|
|
2717
2890
|
function validateRequest(value, b) {
|
|
2718
|
-
if (!obj(value) || value.schemaVersion !== 1 || !sameScope(value.scope, b.scope) || value.aiSystemId !== b.aiSystemId || value.toolKey !== b.toolKey || value.bindingDigest !== b.bindingDigest || !id(value.actorId) || !id(value.runtimeReceiptId) || !
|
|
2891
|
+
if (!obj(value) || value.schemaVersion !== 1 || !sameScope(value.scope, b.scope) || value.aiSystemId !== b.aiSystemId || value.toolKey !== b.toolKey || value.bindingDigest !== b.bindingDigest || !id(value.actorId) || !id(value.runtimeReceiptId) || !hex2(value.authorizationDigest) || !hex2(value.argumentsDigest)) throw Error("HOST_COMPLETION_REQUEST_BINDING_INVALID");
|
|
2719
2892
|
const scope = [b.scope.organizationId, b.scope.projectId, b.scope.environmentId, b.scope.organizationUnitId];
|
|
2720
2893
|
if (b.kind === "SINGLE") {
|
|
2721
|
-
if (!id(value.taskRunId) || !id(value.childRunId) || !id(value.connectionId) || value.connectionId !== b.connectionId || value.semanticTaskKey !== b.semanticTaskKey || !["planDigest", "authorityDigest", "artifactDigest", "policyDigest", "inputDigest"].every((k) =>
|
|
2894
|
+
if (!id(value.taskRunId) || !id(value.childRunId) || !id(value.connectionId) || value.connectionId !== b.connectionId || value.semanticTaskKey !== b.semanticTaskKey || !["planDigest", "authorityDigest", "artifactDigest", "policyDigest", "inputDigest"].every((k) => hex2(value[k])) || value.invocationId !== "single-host:" + hostCompletionDigest([...scope, value.taskRunId, value.childRunId])) throw Error("HOST_COMPLETION_SINGLE_BINDING_INVALID");
|
|
2722
2895
|
} else if (b.kind === "RECOVERY") {
|
|
2723
|
-
if (!id(value.operationId) || !id(value.stateId) || !id(value.trajectoryKey) || !id(value.violationReceiptId) || value.connectionId !== b.connectionId || value.planDigest !== b.recoveryPlanDigest || value.stepType !== b.recoveryStepType || value.operationKey !== b.toolKey || !
|
|
2896
|
+
if (!id(value.operationId) || !id(value.stateId) || !id(value.trajectoryKey) || !id(value.violationReceiptId) || value.connectionId !== b.connectionId || value.planDigest !== b.recoveryPlanDigest || value.stepType !== b.recoveryStepType || value.operationKey !== b.toolKey || !hex2(value.authorityDigest) || value.authorizationDigest !== value.authorityDigest || !Number.isSafeInteger(value.stepIndex) || Number(value.stepIndex) < 0 || !Number.isSafeInteger(value.attempt) || Number(value.attempt) < 1 || Number(value.attempt) > 8 || ["invoke_compensation_action", "cancel_pending", "require_approval", "escalate", "terminate_trajectory"].includes(String(value.stepType)) && value.attempt !== 1 || value.operationId !== "recovery-step:" + hostCompletionDigest([...scope, null, value.stateId, value.trajectoryKey, value.authorityDigest, value.planDigest, value.stepIndex, value.operationKey, value.attempt]) || value.invocationId !== "recovery-host:" + hostCompletionDigest([...scope, value.operationId, b.toolKey]) || value.stepType === "invoke_compensation_action" && !id(value.originalEffectReceiptId) || value.terminalFailureDigest !== void 0 && (value.stepType !== "escalate" || value.attempt !== 1 || !hex2(value.terminalFailureDigest))) throw Error("HOST_COMPLETION_RECOVERY_BINDING_INVALID");
|
|
2724
2897
|
} else if (!id(value.executionId) || !id(value.stepKey) || value.stepSequence !== void 0 && (!Number.isSafeInteger(value.stepSequence) || Number(value.stepSequence) < 0) || value.invocationId !== "strategy-host:" + hostCompletionDigest([...scope, value.executionId, value.stepKey, b.toolKey, ...value.stepSequence === void 0 ? [] : [value.stepSequence]])) throw Error("HOST_COMPLETION_STRATEGY_BINDING_INVALID");
|
|
2725
2898
|
}
|
|
2726
2899
|
function validateBinding(b) {
|
|
2727
|
-
if (!["SINGLE", "STRATEGY", "RECOVERY"].includes(b.kind) || !validScope(b.scope) || !id(b.aiSystemId) || !id(b.toolKey) || !
|
|
2900
|
+
if (!["SINGLE", "STRATEGY", "RECOVERY"].includes(b.kind) || !validScope(b.scope) || !id(b.aiSystemId) || !id(b.toolKey) || !hex2(b.bindingDigest) || ![b.dispatchToken, b.readbackToken, b.receiptKey].every((x) => typeof x === "string" && x.length >= 32) || (/* @__PURE__ */ new Set([b.dispatchToken, b.readbackToken, b.receiptKey])).size !== 3 || b.kind === "SINGLE" && (!id(b.connectionId) || !id(b.semanticTaskKey)) || b.kind === "RECOVERY" && (!id(b.connectionId) || !hex2(b.recoveryPlanDigest) || !["retry", "restore_checkpoint", "invoke_compensation_action", "cancel_pending", "require_approval", "escalate", "terminate_trajectory"].includes(b.recoveryStepType ?? ""))) throw Error("HOST_COMPLETION_CONFIG_INVALID");
|
|
2728
2901
|
}
|
|
2729
2902
|
function createHostCompletionBinding(input) {
|
|
2730
2903
|
const url = (v) => {
|
|
@@ -2747,9 +2920,9 @@ function createHostCompletionAuthority(input) {
|
|
|
2747
2920
|
validateBinding(input.binding);
|
|
2748
2921
|
const binding = { ...input.binding, scope: { ...input.binding.scope } };
|
|
2749
2922
|
const { store, tool } = input;
|
|
2750
|
-
const seal = async (
|
|
2751
|
-
const signed = signHostCompletion(
|
|
2752
|
-
const saved = verifyStored(await store.complete(
|
|
2923
|
+
const seal = async (record2, outcome) => {
|
|
2924
|
+
const signed = signHostCompletion(record2.request, record2.requestDigest, outcome, binding.receiptKey);
|
|
2925
|
+
const saved = verifyStored(await store.complete(record2.request, record2.requestDigest, signed), binding);
|
|
2753
2926
|
if (!saved.completion || hostCompletionDigest(saved.completion) !== hostCompletionDigest(signed)) throw Error("HOST_COMPLETION_CONFLICT");
|
|
2754
2927
|
return saved.completion;
|
|
2755
2928
|
};
|
|
@@ -2765,13 +2938,13 @@ function createHostCompletionAuthority(input) {
|
|
|
2765
2938
|
if (input2.idempotencyKey !== request.invocationId || body.requestDigest !== hostCompletionDigest(request) || request.argumentsDigest !== hostCompletionDigest(body.arguments)) throw Error("HOST_COMPLETION_REQUEST_DIGEST_INVALID");
|
|
2766
2939
|
if (input2.signal?.aborted) return { status: 409, body: { error: "HOST_COMPLETION_DISPATCH_CANCELLED" } };
|
|
2767
2940
|
const claim = await store.claim(request, body.requestDigest);
|
|
2768
|
-
const
|
|
2769
|
-
if (
|
|
2770
|
-
if (claim.claimed && !
|
|
2941
|
+
const record2 = verifyStored(claim.record, binding);
|
|
2942
|
+
if (record2.requestDigest !== body.requestDigest) throw Error("HOST_COMPLETION_IDEMPOTENCY_CONFLICT");
|
|
2943
|
+
if (claim.claimed && !record2.completion) {
|
|
2771
2944
|
try {
|
|
2772
2945
|
input2.signal?.throwIfAborted();
|
|
2773
2946
|
const outcome = await tool.execute({ request: structuredClone(request), arguments: structuredClone(body.arguments), idempotencyKey: request.invocationId, ...input2.signal ? { signal: input2.signal } : {} });
|
|
2774
|
-
await seal(
|
|
2947
|
+
await seal(record2, outcome);
|
|
2775
2948
|
} catch {
|
|
2776
2949
|
return { status: 202, body: { status: "PENDING", invocationId: request.invocationId } };
|
|
2777
2950
|
}
|
|
@@ -2781,14 +2954,14 @@ function createHostCompletionAuthority(input) {
|
|
|
2781
2954
|
async readback(input2) {
|
|
2782
2955
|
if (!auth(input2.authorization, binding.readbackToken)) return { status: 401, body: { error: "HOST_COMPLETION_UNAUTHORIZED" } };
|
|
2783
2956
|
if (!id(input2.invocationId)) return { status: 400, body: { error: "HOST_COMPLETION_INVOCATION_INVALID" } };
|
|
2784
|
-
const
|
|
2785
|
-
if (!
|
|
2786
|
-
verifyStored(
|
|
2787
|
-
if (
|
|
2788
|
-
let completion =
|
|
2957
|
+
const record2 = await store.get(input2.invocationId, binding.bindingDigest);
|
|
2958
|
+
if (!record2) return { status: 404, body: { error: "HOST_COMPLETION_NOT_FOUND" } };
|
|
2959
|
+
verifyStored(record2, binding);
|
|
2960
|
+
if (record2.request.invocationId !== input2.invocationId) throw Error("HOST_COMPLETION_STORE_CORRUPT");
|
|
2961
|
+
let completion = record2.completion;
|
|
2789
2962
|
if (!completion && tool.recover) {
|
|
2790
|
-
const outcome = await tool.recover({ request: structuredClone(
|
|
2791
|
-
if (outcome) completion = await seal(
|
|
2963
|
+
const outcome = await tool.recover({ request: structuredClone(record2.request), idempotencyKey: record2.request.invocationId });
|
|
2964
|
+
if (outcome) completion = await seal(record2, outcome);
|
|
2792
2965
|
}
|
|
2793
2966
|
return completion ? { status: 200, body: completion } : { status: 202, body: { status: "PENDING" } };
|
|
2794
2967
|
},
|
|
@@ -2916,18 +3089,18 @@ function createPostgresHostCompletionStore(db) {
|
|
|
2916
3089
|
const { rows } = await db.query("INSERT INTO vira_host_completion_v1(invocation_id,binding_digest,request_digest,request_json) VALUES($1,$2,$3,$4) ON CONFLICT(invocation_id) DO NOTHING RETURNING " + columns, [request.invocationId, request.bindingDigest, requestDigest, JSON.stringify(request)]);
|
|
2917
3090
|
if (rows.length > 1) throw Error("HOST_COMPLETION_STORE_CORRUPT");
|
|
2918
3091
|
if (rows[0]) return { claimed: true, record: decode(rows[0]) };
|
|
2919
|
-
const
|
|
2920
|
-
if (!
|
|
2921
|
-
return { claimed: false, record };
|
|
3092
|
+
const record2 = await get(request.invocationId, request.bindingDigest);
|
|
3093
|
+
if (!record2 || record2.requestDigest !== requestDigest) throw Error("HOST_COMPLETION_IDEMPOTENCY_CONFLICT");
|
|
3094
|
+
return { claimed: false, record: record2 };
|
|
2922
3095
|
},
|
|
2923
3096
|
async complete(request, requestDigest, completion) {
|
|
2924
3097
|
if (hostCompletionDigest(request) !== requestDigest || completion.receipt.invocationId !== request.invocationId || completion.receipt.requestDigest !== requestDigest) throw Error("HOST_COMPLETION_REQUEST_DIGEST_INVALID");
|
|
2925
3098
|
const digest2 = hostCompletionDigest(completion);
|
|
2926
3099
|
const { rows } = await db.query("UPDATE vira_host_completion_v1 SET completion_json=$4,completion_digest=$5,completed_at=CURRENT_TIMESTAMP WHERE invocation_id=$1 AND binding_digest=$2 AND request_digest=$3 AND completion_json IS NULL RETURNING " + columns, [request.invocationId, request.bindingDigest, requestDigest, JSON.stringify(completion), digest2]);
|
|
2927
3100
|
if (rows.length > 1) throw Error("HOST_COMPLETION_STORE_CORRUPT");
|
|
2928
|
-
const
|
|
2929
|
-
if (!
|
|
2930
|
-
return
|
|
3101
|
+
const record2 = rows[0] ? decode(rows[0]) : await get(request.invocationId, request.bindingDigest);
|
|
3102
|
+
if (!record2 || record2.requestDigest !== requestDigest || !record2.completion || hostCompletionDigest(record2.completion) !== digest2) throw Error("HOST_COMPLETION_CONFLICT");
|
|
3103
|
+
return record2;
|
|
2931
3104
|
}
|
|
2932
3105
|
};
|
|
2933
3106
|
}
|
|
@@ -19,6 +19,7 @@ export interface HostSessionIdentity {
|
|
|
19
19
|
organizationId: string;
|
|
20
20
|
projectId: string;
|
|
21
21
|
environmentId: string;
|
|
22
|
+
organizationUnitId?: string;
|
|
22
23
|
/** Optional members of the composed workspace/user scope. */
|
|
23
24
|
workspaceId?: string;
|
|
24
25
|
userId?: string;
|
|
@@ -27,6 +28,8 @@ export interface HostSessionIdentity {
|
|
|
27
28
|
}
|
|
28
29
|
export interface HostModelRequest extends HostSessionIdentity {
|
|
29
30
|
requestId: string;
|
|
31
|
+
/** Stable host message identity, separate from the per-model invocation ID. */
|
|
32
|
+
hostMessageId?: string;
|
|
30
33
|
input: string;
|
|
31
34
|
traceId?: string;
|
|
32
35
|
turnId?: string;
|
|
@@ -90,6 +93,8 @@ export interface HostActionAuthorization {
|
|
|
90
93
|
export interface HostLifecycleConfig {
|
|
91
94
|
mode?: HostLifecycleMode;
|
|
92
95
|
capabilities: HostCapabilities;
|
|
96
|
+
/** Opt-in for hosts that must never execute a second local model after server admission. */
|
|
97
|
+
multiTaskHandoff?: 'server-owned';
|
|
93
98
|
connect?: Parameters<ViraClient['connectOnce']>[0];
|
|
94
99
|
authorizeAction?: (proposal: HostToolProposal) => Promise<HostActionAuthorization> | HostActionAuthorization;
|
|
95
100
|
projectionMaxBytes?: number;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
type Identity = {
|
|
2
|
+
organizationId: string;
|
|
3
|
+
projectId: string;
|
|
4
|
+
environmentId: string;
|
|
5
|
+
organizationUnitId?: string;
|
|
6
|
+
aiSystemId: string;
|
|
7
|
+
conversationId: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
};
|
|
10
|
+
type Expected = Identity & {
|
|
11
|
+
taskRunId: string;
|
|
12
|
+
requestId?: string;
|
|
13
|
+
minimumVersion?: number;
|
|
14
|
+
selectedTaskKeys?: readonly string[];
|
|
15
|
+
planDigest?: string;
|
|
16
|
+
authorityDigest?: string;
|
|
17
|
+
checkpointExecutionDigest?: string;
|
|
18
|
+
mode?: 'COMPOUND' | 'HYBRID';
|
|
19
|
+
status?: typeof statuses[number];
|
|
20
|
+
};
|
|
21
|
+
declare const statuses: readonly ["PLANNED", "ADMITTED", "RUNNING", "WAITING_USER", "WAITING_HOST", "WAITING_APPROVAL", "PARTIAL", "COMPLETED", "FAILED", "BLOCKED", "CANCELLED"];
|
|
22
|
+
export declare function stableHostTaskRunRequest(identity: Identity, messageId: string, input: string): string;
|
|
23
|
+
export declare function readHostTaskRunState(response: unknown, expected: Expected, admission?: boolean): {
|
|
24
|
+
taskRunId: string;
|
|
25
|
+
requestId: string;
|
|
26
|
+
stateVersion: number;
|
|
27
|
+
mode: "COMPOUND" | "HYBRID";
|
|
28
|
+
status: (typeof statuses)[number];
|
|
29
|
+
planDigest: string;
|
|
30
|
+
authorityDigest: string;
|
|
31
|
+
selectedTaskKeys: string[];
|
|
32
|
+
checkpointExecutionDigest: string | undefined;
|
|
33
|
+
};
|
|
34
|
+
export declare function hostTaskRunTerminal(status: string): boolean;
|
|
35
|
+
/** Terminal evidence is read separately from lifecycle state. It is not the
|
|
36
|
+
* customer output and must never authorize a local model or tool execution. */
|
|
37
|
+
export declare function readHostTaskRunTerminalEvidence(response: unknown, run: Identity & ReturnType<typeof readHostTaskRunState>): Readonly<{
|
|
38
|
+
taskRunId: string;
|
|
39
|
+
stateVersion: number;
|
|
40
|
+
mode: "COMPOUND" | "HYBRID";
|
|
41
|
+
status: "PLANNED" | "ADMITTED" | "RUNNING" | "WAITING_USER" | "WAITING_HOST" | "WAITING_APPROVAL" | "PARTIAL" | "COMPLETED" | "FAILED" | "BLOCKED" | "CANCELLED";
|
|
42
|
+
planDigest: string;
|
|
43
|
+
authorityDigest: string;
|
|
44
|
+
checkpointExecutionDigest: string | null;
|
|
45
|
+
outputAvailable: false;
|
|
46
|
+
clientExecutionAllowed: false;
|
|
47
|
+
}>;
|
|
48
|
+
/** Verify the opt-in result independently of the redacted lifecycle response. */
|
|
49
|
+
export declare function readHostTaskRunResult(response: unknown, run: Identity & ReturnType<typeof readHostTaskRunState>): Readonly<{
|
|
50
|
+
outputAvailable: true;
|
|
51
|
+
resultDigest: unknown;
|
|
52
|
+
outputs: {
|
|
53
|
+
nodeKey: string;
|
|
54
|
+
semanticTaskKey: string;
|
|
55
|
+
receiptId: string;
|
|
56
|
+
outputDigest: string;
|
|
57
|
+
output: {};
|
|
58
|
+
}[];
|
|
59
|
+
taskRunId: string;
|
|
60
|
+
stateVersion: number;
|
|
61
|
+
mode: "COMPOUND" | "HYBRID";
|
|
62
|
+
status: "PLANNED" | "ADMITTED" | "RUNNING" | "WAITING_USER" | "WAITING_HOST" | "WAITING_APPROVAL" | "PARTIAL" | "COMPLETED" | "FAILED" | "BLOCKED" | "CANCELLED";
|
|
63
|
+
planDigest: string;
|
|
64
|
+
authorityDigest: string;
|
|
65
|
+
checkpointExecutionDigest: string | null;
|
|
66
|
+
clientExecutionAllowed: false;
|
|
67
|
+
}>;
|
|
68
|
+
export {};
|
package/dist/sdks/js-client.d.ts
CHANGED
|
@@ -142,6 +142,24 @@ export interface RuntimeTraceSearchResult {
|
|
|
142
142
|
nextCursor: string | null;
|
|
143
143
|
source: "postgres-control-plane-read-model";
|
|
144
144
|
}
|
|
145
|
+
export interface BehaviorStrategyValidationResult {
|
|
146
|
+
valid: true;
|
|
147
|
+
artifactDigest: string;
|
|
148
|
+
strategyDigest: string;
|
|
149
|
+
persisted: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface BehaviorStrategySimulationResult {
|
|
152
|
+
simulation: true;
|
|
153
|
+
simulationMode: "STRUCTURAL_DRY_RUN";
|
|
154
|
+
artifactDigest: string;
|
|
155
|
+
result: {
|
|
156
|
+
status: "not_executed";
|
|
157
|
+
modelCalls: 0;
|
|
158
|
+
toolCalls: 0;
|
|
159
|
+
decisionCalls: 0;
|
|
160
|
+
reason: string;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
145
163
|
export interface StrategyExecutionRecord {
|
|
146
164
|
id: string | null;
|
|
147
165
|
traceId: string | null;
|
|
@@ -248,11 +266,25 @@ export interface StrategyExecutionList {
|
|
|
248
266
|
limit: number;
|
|
249
267
|
nextCursor?: string;
|
|
250
268
|
}
|
|
269
|
+
export interface StrategyAnswerField {
|
|
270
|
+
key: string;
|
|
271
|
+
kind: 'text' | 'boolean' | 'number' | 'integer' | 'json';
|
|
272
|
+
maxBytes: number;
|
|
273
|
+
}
|
|
274
|
+
export interface StrategyAnswerDescriptor {
|
|
275
|
+
executionId: string;
|
|
276
|
+
authorityDigest: string;
|
|
277
|
+
sequence: number;
|
|
278
|
+
stepKey: string;
|
|
279
|
+
fields: StrategyAnswerField[];
|
|
280
|
+
maxBytes: number;
|
|
281
|
+
}
|
|
251
282
|
export interface StrategyExecutionTrace {
|
|
252
283
|
execution: StrategyExecutionRecord;
|
|
253
284
|
receipts: StrategyStepReceipt[];
|
|
254
285
|
credit?: StrategyExecutionCreditReadback;
|
|
255
286
|
release?: StrategyExecutionReleaseReadback | null;
|
|
287
|
+
answerDescriptor?: StrategyAnswerDescriptor | null;
|
|
256
288
|
}
|
|
257
289
|
export interface StrategyExecutionQueued {
|
|
258
290
|
queued: true;
|
|
@@ -292,8 +324,18 @@ export interface ProjectionReceipt {
|
|
|
292
324
|
receiptDigest: string;
|
|
293
325
|
[key: string]: unknown;
|
|
294
326
|
}
|
|
327
|
+
export interface RuntimeProgramSelection {
|
|
328
|
+
sourceProgramId: string;
|
|
329
|
+
sourceProgramDigest: string;
|
|
330
|
+
selectionAuthority: "department-optimizer-program-publication";
|
|
331
|
+
releaseId: string;
|
|
332
|
+
pointerVersion: number;
|
|
333
|
+
artifactDigest: string;
|
|
334
|
+
aiSystemId: string;
|
|
335
|
+
}
|
|
295
336
|
export interface RuntimeResolution {
|
|
296
337
|
behaviorPoint: string;
|
|
338
|
+
programSelection?: RuntimeProgramSelection;
|
|
297
339
|
strategySelection?: ClientBody | null;
|
|
298
340
|
behaviorProjection?: BehaviorProjection;
|
|
299
341
|
projectionReceipt?: ProjectionReceipt;
|
|
@@ -308,6 +350,26 @@ export interface ScopedListOptions {
|
|
|
308
350
|
search?: string;
|
|
309
351
|
}
|
|
310
352
|
export type TaskRunRequestedMode = TaskRunMode | "AUTO";
|
|
353
|
+
export interface TaskRunHistorySummary {
|
|
354
|
+
taskRunId: string;
|
|
355
|
+
aiSystemId: string;
|
|
356
|
+
mode: TaskRunMode;
|
|
357
|
+
status: "PLANNED" | "ADMITTED" | "RUNNING" | "WAITING_USER" | "WAITING_HOST" | "WAITING_APPROVAL" | "PARTIAL" | "COMPLETED" | "FAILED" | "BLOCKED" | "CANCELLED";
|
|
358
|
+
stateVersion: number;
|
|
359
|
+
selectedTaskKeys: readonly string[];
|
|
360
|
+
createdAt?: string;
|
|
361
|
+
updatedAt?: string;
|
|
362
|
+
}
|
|
363
|
+
export interface TaskRunHistoryResult {
|
|
364
|
+
taskRuns: readonly TaskRunHistorySummary[];
|
|
365
|
+
limit: number;
|
|
366
|
+
partial: boolean;
|
|
367
|
+
nextCursor?: string;
|
|
368
|
+
sessionSelection?: {
|
|
369
|
+
aiSystemId: string;
|
|
370
|
+
conversationId: string;
|
|
371
|
+
};
|
|
372
|
+
}
|
|
311
373
|
export interface TaskRunChildMode {
|
|
312
374
|
semanticTaskKey: string;
|
|
313
375
|
mode: "SINGLE" | "STRATEGY";
|
|
@@ -463,7 +525,30 @@ export type TaskRunCommercialUsagePreview = Readonly<{
|
|
|
463
525
|
}> | Readonly<{
|
|
464
526
|
status: "SHADOW_UNAVAILABLE";
|
|
465
527
|
}>;
|
|
528
|
+
export type TaskRunCompoundTerminalLedger = Readonly<{
|
|
529
|
+
success: false;
|
|
530
|
+
commercialEvidenceStatus: 'NOT_CHARGEABLE';
|
|
531
|
+
}> & (Readonly<{
|
|
532
|
+
status: 'RECONCILIATION_REQUIRED';
|
|
533
|
+
receiptId: null;
|
|
534
|
+
manifestStatus?: 'NOT_RECONCILED';
|
|
535
|
+
}> | Readonly<{
|
|
536
|
+
status: 'COMMITTED';
|
|
537
|
+
receiptId: string;
|
|
538
|
+
manifestStatus?: 'NOT_RECONCILED';
|
|
539
|
+
}> | Readonly<{
|
|
540
|
+
status: 'TERMINAL_RECONCILED';
|
|
541
|
+
receiptId: string;
|
|
542
|
+
manifestStatus?: 'LEGACY_UNBOUND';
|
|
543
|
+
}> | Readonly<{
|
|
544
|
+
status: 'TERMINAL_RECONCILED';
|
|
545
|
+
receiptId: string;
|
|
546
|
+
manifestStatus: 'VERIFIED';
|
|
547
|
+
manifestDigest: string;
|
|
548
|
+
nodeCount: number;
|
|
549
|
+
}>);
|
|
466
550
|
export interface TaskRunEvidence {
|
|
551
|
+
compoundTerminalLedger?: TaskRunCompoundTerminalLedger;
|
|
467
552
|
/** Optional measurement only. Not an invoice, quota decision or execution permission. */
|
|
468
553
|
commercialUsagePreview?: TaskRunCommercialUsagePreview;
|
|
469
554
|
taskRunId: string;
|
|
@@ -479,8 +564,34 @@ export interface TaskRunEvidence {
|
|
|
479
564
|
children: TaskRunChildEvidence[];
|
|
480
565
|
source: 'postgres-taskrun-strategy-release-credit-evidence';
|
|
481
566
|
}
|
|
567
|
+
export interface HostTaskRunResult {
|
|
568
|
+
taskRunId: string;
|
|
569
|
+
requestId: string;
|
|
570
|
+
organizationId: string;
|
|
571
|
+
projectId: string;
|
|
572
|
+
environmentId: string;
|
|
573
|
+
organizationUnitId: string;
|
|
574
|
+
aiSystemId: string;
|
|
575
|
+
conversationId: string;
|
|
576
|
+
mode: 'COMPOUND' | 'HYBRID';
|
|
577
|
+
status: 'COMPLETED';
|
|
578
|
+
stateVersion: number;
|
|
579
|
+
planDigest: string;
|
|
580
|
+
authorityDigest: string;
|
|
581
|
+
checkpointExecutionDigest: string;
|
|
582
|
+
outputs: readonly {
|
|
583
|
+
nodeKey: string;
|
|
584
|
+
semanticTaskKey: string;
|
|
585
|
+
receiptId: string;
|
|
586
|
+
outputDigest: string;
|
|
587
|
+
output: unknown;
|
|
588
|
+
}[];
|
|
589
|
+
clientExecutionAllowed: false;
|
|
590
|
+
resultDigest: string;
|
|
591
|
+
}
|
|
482
592
|
export interface TaskRunEvidenceResult {
|
|
483
593
|
evidence: TaskRunEvidence;
|
|
594
|
+
result?: HostTaskRunResult;
|
|
484
595
|
}
|
|
485
596
|
export interface TaskRunPromptRequest {
|
|
486
597
|
aiSystemId: string;
|
|
@@ -501,7 +612,10 @@ export interface ConnectOnceResult {
|
|
|
501
612
|
}
|
|
502
613
|
export interface StrategyContinuationInput {
|
|
503
614
|
authorityDigest?: string;
|
|
615
|
+
expectedSequence?: number;
|
|
616
|
+
/** @deprecated Nonempty checkpoint state patches are rejected by the server. */
|
|
504
617
|
state?: Readonly<Record<string, unknown>>;
|
|
618
|
+
/** Only actionArguments.answers for the active ask_user step is writable. */
|
|
505
619
|
references?: Readonly<Record<string, unknown>>;
|
|
506
620
|
}
|
|
507
621
|
export type ViraLearningNamespaces = {
|
|
@@ -1298,6 +1412,18 @@ export declare class ViraClient {
|
|
|
1298
1412
|
query?: string;
|
|
1299
1413
|
event?: string;
|
|
1300
1414
|
}): Promise<ViraResponse<RuntimeTraceSearchResult> | null>;
|
|
1415
|
+
listOptimizationTargets(input: {
|
|
1416
|
+
aiSystemId: string;
|
|
1417
|
+
connectionId: string;
|
|
1418
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1419
|
+
previewOptimizationTarget(input: {
|
|
1420
|
+
aiSystemId: string;
|
|
1421
|
+
connectionId: string;
|
|
1422
|
+
canonicalRevisionId: string;
|
|
1423
|
+
sourceReleaseId: string;
|
|
1424
|
+
strategyId?: string;
|
|
1425
|
+
stepKey?: string;
|
|
1426
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1301
1427
|
startOptimization(input: Record<string, unknown>, options?: {
|
|
1302
1428
|
idempotencyKey?: string;
|
|
1303
1429
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
@@ -1401,6 +1527,13 @@ export declare class ViraClient {
|
|
|
1401
1527
|
idempotencyKey?: string;
|
|
1402
1528
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1403
1529
|
installPack(packId: string, variables?: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
1530
|
+
revokeSignalMapping(mappingId: string, expectedMappingDigest: string): Promise<ViraResponse<ClientBody> | null>;
|
|
1531
|
+
getPackSignalReadiness(packId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
1532
|
+
bindPackSignalMappings(packId: string, input: {
|
|
1533
|
+
aiSystemId: string;
|
|
1534
|
+
connectionId: string;
|
|
1535
|
+
approve?: boolean;
|
|
1536
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1404
1537
|
diagnosePack(packId: string, input?: {
|
|
1405
1538
|
runtimeBindings?: readonly string[];
|
|
1406
1539
|
knownVerifiers?: readonly string[];
|
|
@@ -1416,6 +1549,10 @@ export declare class ViraClient {
|
|
|
1416
1549
|
previewPackUpgrade(packId: string, incoming: ClientBody): Promise<ViraResponse<ClientBody> | null>;
|
|
1417
1550
|
executeRuntime(input: RuntimeRequest & Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
1418
1551
|
resolveRuntime(input: {
|
|
1552
|
+
aiSystemId?: string;
|
|
1553
|
+
provider?: string;
|
|
1554
|
+
model?: string;
|
|
1555
|
+
protocol?: "openai-chat" | "anthropic-messages" | "generic-chat";
|
|
1419
1556
|
behaviorPoint?: string;
|
|
1420
1557
|
executionBoundary?: Record<string, unknown>;
|
|
1421
1558
|
semanticContext?: Record<string, unknown>;
|
|
@@ -1428,6 +1565,10 @@ export declare class ViraClient {
|
|
|
1428
1565
|
}): Promise<ViraResponse<RuntimeResolution> | null>;
|
|
1429
1566
|
/** Resolve a runtime route from a governed execution boundary and semantic context. */
|
|
1430
1567
|
resolveBoundary(input: {
|
|
1568
|
+
aiSystemId?: string;
|
|
1569
|
+
provider?: string;
|
|
1570
|
+
model?: string;
|
|
1571
|
+
protocol?: "openai-chat" | "anthropic-messages" | "generic-chat";
|
|
1431
1572
|
executionBoundary: Record<string, unknown>;
|
|
1432
1573
|
semanticContext?: Record<string, unknown>;
|
|
1433
1574
|
idempotencyKey?: string;
|
|
@@ -1517,7 +1658,7 @@ export declare class ViraClient {
|
|
|
1517
1658
|
aiSystemId: string;
|
|
1518
1659
|
connectionId: string;
|
|
1519
1660
|
operationId: string;
|
|
1520
|
-
model
|
|
1661
|
+
model?: string;
|
|
1521
1662
|
messages: readonly Record<string, unknown>[];
|
|
1522
1663
|
max_tokens?: number;
|
|
1523
1664
|
max_completion_tokens?: number;
|
|
@@ -1544,6 +1685,9 @@ export declare class ViraClient {
|
|
|
1544
1685
|
resolveSemanticRuntime(input: {
|
|
1545
1686
|
input: string;
|
|
1546
1687
|
aiSystemId?: string;
|
|
1688
|
+
provider?: string;
|
|
1689
|
+
model?: string;
|
|
1690
|
+
protocol?: "openai-chat" | "anthropic-messages" | "generic-chat";
|
|
1547
1691
|
profile?: Record<string, unknown>;
|
|
1548
1692
|
sessionId?: string;
|
|
1549
1693
|
timeoutMs?: number;
|
|
@@ -1582,6 +1726,7 @@ export declare class ViraClient {
|
|
|
1582
1726
|
eventId: string;
|
|
1583
1727
|
}[];
|
|
1584
1728
|
aiSystemId?: string;
|
|
1729
|
+
connectionId?: string;
|
|
1585
1730
|
}): Promise<ViraResponse<HostActionAuthorizationResult> | null>;
|
|
1586
1731
|
/** Queue the approved SINGLE effect on the worker, never execute it locally. */
|
|
1587
1732
|
queueTaskRunHostDispatch(input: {
|
|
@@ -1656,9 +1801,22 @@ export declare class ViraClient {
|
|
|
1656
1801
|
createBehaviorStrategyVariant(strategyId: string, variant: Record<string, unknown>, options?: {
|
|
1657
1802
|
idempotencyKey?: string;
|
|
1658
1803
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1659
|
-
|
|
1804
|
+
/** Create a separate immutable draft revision against a specific observed parent.
|
|
1805
|
+
* This never activates or releases the draft. */
|
|
1806
|
+
reviseBehaviorStrategy(strategyId: string, definition: Record<string, unknown>, parent: {
|
|
1807
|
+
variantId: string;
|
|
1808
|
+
artifactDigest: string;
|
|
1809
|
+
definitionDigest: string;
|
|
1810
|
+
}, options?: {
|
|
1811
|
+
idempotencyKey?: string;
|
|
1812
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1813
|
+
validateBehaviorStrategy(strategyId: string, options?: {
|
|
1814
|
+
variantId?: string;
|
|
1815
|
+
}): Promise<ViraResponse<BehaviorStrategyValidationResult> | null>;
|
|
1660
1816
|
activateBehaviorStrategy(strategyId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
1661
|
-
simulateBehaviorStrategy(strategyId: string, initialState?: Record<string, unknown
|
|
1817
|
+
simulateBehaviorStrategy(strategyId: string, initialState?: Record<string, unknown>, options?: {
|
|
1818
|
+
variantId?: string;
|
|
1819
|
+
}): Promise<ViraResponse<BehaviorStrategySimulationResult> | null>;
|
|
1662
1820
|
startStrategyExecution(input: {
|
|
1663
1821
|
artifactDigest: string;
|
|
1664
1822
|
/** Optional explicitly selected release; server validates its approved lineage. */
|
|
@@ -1716,7 +1874,10 @@ export declare class ViraClient {
|
|
|
1716
1874
|
}): Promise<ViraResponse<StrategyExecutionList> | null>;
|
|
1717
1875
|
getStrategyExecutionTrace(executionId: string): Promise<ViraResponse<StrategyExecutionTrace> | null>;
|
|
1718
1876
|
continueStrategyExecution(executionId: string, continuation?: string | StrategyContinuationInput): Promise<ViraResponse<StrategyExecutionResult> | null>;
|
|
1719
|
-
cancelStrategyExecution(executionId: string
|
|
1877
|
+
cancelStrategyExecution(executionId: string, options?: {
|
|
1878
|
+
authorityDigest?: string;
|
|
1879
|
+
expectedSequence?: number;
|
|
1880
|
+
}): Promise<ViraResponse<StrategyExecutionEnvelope> | null>;
|
|
1720
1881
|
listCompoundTaskPlans(options?: {
|
|
1721
1882
|
limit?: number;
|
|
1722
1883
|
cursor?: string;
|
|
@@ -1732,8 +1893,17 @@ export declare class ViraClient {
|
|
|
1732
1893
|
startTaskRunFromPrompt(input: TaskRunPromptRequest, options?: {
|
|
1733
1894
|
idempotencyKey?: string;
|
|
1734
1895
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
1896
|
+
/** Read authorized history; partial without a cursor is not complete. */
|
|
1897
|
+
listTaskRuns(options?: {
|
|
1898
|
+
limit?: number;
|
|
1899
|
+
cursor?: string;
|
|
1900
|
+
aiSystemId?: string;
|
|
1901
|
+
conversationId?: string;
|
|
1902
|
+
}): Promise<ViraResponse<TaskRunHistoryResult> | null>;
|
|
1735
1903
|
getTaskRun(taskRunId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
1736
|
-
getTaskRunEvidence(taskRunId: string
|
|
1904
|
+
getTaskRunEvidence(taskRunId: string, options?: {
|
|
1905
|
+
includeResult?: boolean;
|
|
1906
|
+
}): Promise<ViraResponse<TaskRunEvidenceResult> | null>;
|
|
1737
1907
|
listTaskRunEvents(taskRunId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
1738
1908
|
continueTaskRun(taskRunId: string, expectedVersion: number, options?: {
|
|
1739
1909
|
cursor?: string;
|
|
@@ -2001,6 +2171,7 @@ export declare class ViraClient {
|
|
|
2001
2171
|
idempotencyKey?: string;
|
|
2002
2172
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2003
2173
|
compileBehaviorCapsule(input: {
|
|
2174
|
+
aiSystemId?: string;
|
|
2004
2175
|
programId: string;
|
|
2005
2176
|
input: string;
|
|
2006
2177
|
selection?: Record<string, unknown>;
|
|
@@ -2008,6 +2179,7 @@ export declare class ViraClient {
|
|
|
2008
2179
|
idempotencyKey?: string;
|
|
2009
2180
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2010
2181
|
serveBehaviorProjection(input: {
|
|
2182
|
+
aiSystemId?: string;
|
|
2011
2183
|
programId?: string;
|
|
2012
2184
|
input: string;
|
|
2013
2185
|
provider: string;
|
|
@@ -2025,6 +2197,35 @@ export declare class ViraClient {
|
|
|
2025
2197
|
revokeAISystemUnitAccess(aiSystemId: string, unitId: string, options?: {
|
|
2026
2198
|
idempotencyKey?: string;
|
|
2027
2199
|
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2200
|
+
listVerifiedHostInvocationResults(systemId: string, input?: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2201
|
+
freezeDepartmentOptimizationDataset(input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2202
|
+
listDepartmentOptimizationDatasets(input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2203
|
+
prepareFrozenOptimizationRun(input: Record<string, unknown>, options?: {
|
|
2204
|
+
idempotencyKey?: string;
|
|
2205
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2206
|
+
executeFrozenOptimizationRun(input: Record<string, unknown>, options?: {
|
|
2207
|
+
idempotencyKey?: string;
|
|
2208
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2209
|
+
proposeNativePolicyScenarios(input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2210
|
+
previewNativePolicyScenarios(input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2211
|
+
admitNativeEvaluationTeachFeedback(evaluationId: string, input: Record<string, unknown>, options?: {
|
|
2212
|
+
idempotencyKey?: string;
|
|
2213
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2214
|
+
previewNativeTeachDraftRevision(proposalId: string, input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2215
|
+
applyNativeTeachDraftRevision(proposalId: string, input: Record<string, unknown>, options?: {
|
|
2216
|
+
idempotencyKey?: string;
|
|
2217
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2218
|
+
compareNativeTeachRevision(input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2219
|
+
getNativeTeachRevisionHistory(proposalId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
2220
|
+
getNativeRevisionComparisonSource(candidatePackId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
2221
|
+
listStrategyConnectionOptions(input: {
|
|
2222
|
+
aiSystemId: string;
|
|
2223
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2224
|
+
listOptimizationReviewOptions(input: Record<string, unknown>): Promise<ViraResponse<ClientBody> | null>;
|
|
2225
|
+
listOptimizerEvaluationHistory(runId: string): Promise<ViraResponse<ClientBody> | null>;
|
|
2226
|
+
previewOptimizerStrategyPromotion(runId: string, input: Record<string, unknown>, options?: {
|
|
2227
|
+
idempotencyKey?: string;
|
|
2228
|
+
}): Promise<ViraResponse<ClientBody> | null>;
|
|
2028
2229
|
}
|
|
2029
2230
|
export declare function buildRuntimeRequest(input: RuntimeRequest & Record<string, unknown>, options?: {
|
|
2030
2231
|
includeAIIdentity?: boolean;
|