witnora 0.13.10 → 0.13.12
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/dist/cli.js +1 -1
- package/dist/gateway.js +157 -19
- package/dist/internal/control-client/collector-gateway.d.ts +6 -1
- package/dist/internal/control-client/collector-gateway.d.ts.map +1 -1
- package/dist/internal/control-client/collector-gateway.js +2 -0
- package/dist/internal/control-client/remote-collector.d.ts +8 -0
- package/dist/internal/control-client/remote-collector.d.ts.map +1 -1
- package/dist/internal/control-client/remote-collector.js +1 -0
- package/dist/onboard.js +28 -2
- package/dist/vendor/onegent-runtime/business-task-evaluator.d.ts +8 -0
- package/dist/vendor/onegent-runtime/business-task-evaluator.d.ts.map +1 -1
- package/dist/vendor/onegent-runtime/business-task-evaluator.js +35 -3
- package/dist/vendor/onegent-runtime/managed-workflow-harness.d.ts +9 -0
- package/dist/vendor/onegent-runtime/managed-workflow-harness.d.ts.map +1 -1
- package/dist/vendor/onegent-runtime/managed-workflow-harness.js +13 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -246,7 +246,7 @@ else if (command === "gateway") {
|
|
|
246
246
|
maxConcurrency: readFlag("--max-concurrency") ? Number(readFlag("--max-concurrency")) : undefined,
|
|
247
247
|
force: readBoolFlag("--force"),
|
|
248
248
|
});
|
|
249
|
-
process.stdout.write(`Configured the Managed Workflow Harness for ${result.config.workflowIds
|
|
249
|
+
process.stdout.write(`Configured the Managed Workflow Harness for ${result.config.workflowIds?.length ?? "all active"} Workflow Contract(s).\nConfig: ${result.path}\nRestart the managed Gateway to activate it.\n`);
|
|
250
250
|
}
|
|
251
251
|
else {
|
|
252
252
|
throw new Error("Use witnora gateway init|doctor|start|status|logs|restart|stop|run|workflow-harness.");
|
package/dist/gateway.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createHash, createPrivateKey, createPublicKey, randomBytes } from "node:crypto";
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { closeSync, openSync } from "node:fs";
|
|
4
|
-
import { access, chmod, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
5
|
-
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
import { access, chmod, mkdir, readFile, realpath, rename, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
import { loadConnection } from "./credentials.js";
|
|
8
8
|
import { authorizeProjectConnection } from "./device-authorization.js";
|
|
@@ -14,6 +14,7 @@ const CONFIG_SCHEMA = "witnora.customer_gateway_setup.v0.1";
|
|
|
14
14
|
const SECRETS_SCHEMA = "witnora.customer_gateway_local_secrets.v0.1";
|
|
15
15
|
const RUNTIME_SCHEMA = "witnora.managed_gateway_runtime.v0.1";
|
|
16
16
|
const WORKFLOW_HARNESS_SCHEMA = "witnora.managed_workflow_harness.v0.1";
|
|
17
|
+
const MANAGED_WORKFLOW_HARNESS_SCHEMA = "witnora.managed_workflow_harness.v0.2";
|
|
17
18
|
export async function initializeCustomerGateway(options) {
|
|
18
19
|
const repository = resolve(options.repository ?? process.cwd());
|
|
19
20
|
const outDir = resolve(repository, options.outDir ?? ".witnora/gateway");
|
|
@@ -547,6 +548,9 @@ export async function runCustomerGateway(options) {
|
|
|
547
548
|
fixtureReady: false,
|
|
548
549
|
} } : {}),
|
|
549
550
|
} } : {}),
|
|
551
|
+
...(workflowHarnessConfig?.schemaVersion === MANAGED_WORKFLOW_HARNESS_SCHEMA && workflowHarness
|
|
552
|
+
? { assuranceHarness: { status: () => workflowHarness.status() } }
|
|
553
|
+
: {}),
|
|
550
554
|
});
|
|
551
555
|
workflowHarness?.start();
|
|
552
556
|
process.stdout.write(`Witnora customer-owned Gateway listening on ${gateway.baseUrl}\n`);
|
|
@@ -567,10 +571,24 @@ export async function runCustomerGateway(options) {
|
|
|
567
571
|
function configManagedWorkflowHarnessImport() {
|
|
568
572
|
return import(new URL("./vendor/onegent-runtime/managed-workflow-harness.js", import.meta.url).href);
|
|
569
573
|
}
|
|
574
|
+
function configBusinessTaskEvaluatorImport() {
|
|
575
|
+
return import(new URL("./vendor/onegent-runtime/business-task-evaluator.js", import.meta.url).href);
|
|
576
|
+
}
|
|
570
577
|
export async function createConfiguredWorkflowHarness(input) {
|
|
571
578
|
const requestFetch = input.fetch ?? fetch;
|
|
572
|
-
|
|
573
|
-
|
|
579
|
+
let managedEvaluator;
|
|
580
|
+
let credential;
|
|
581
|
+
let evaluatorOrigin;
|
|
582
|
+
if (input.config.schemaVersion === MANAGED_WORKFLOW_HARNESS_SCHEMA) {
|
|
583
|
+
managedEvaluator = await startManagedLocalEvaluator(input.directory, input.config, input.evaluatorKit);
|
|
584
|
+
credential = managedEvaluator.credential;
|
|
585
|
+
evaluatorOrigin = managedEvaluator.origin;
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
credential = await readSecretProviderHandle(input.config.evaluatorCredentialHandle);
|
|
589
|
+
evaluatorOrigin = input.config.evaluatorOrigin;
|
|
590
|
+
}
|
|
591
|
+
const health = await requestFetch(`${evaluatorOrigin}/healthz`, {
|
|
574
592
|
headers: { authorization: `Bearer ${credential}` },
|
|
575
593
|
redirect: "error",
|
|
576
594
|
signal: AbortSignal.timeout(2_000),
|
|
@@ -580,6 +598,7 @@ export async function createConfiguredWorkflowHarness(input) {
|
|
|
580
598
|
|| healthBody.schemaVersion !== "witnora.business_task_evaluator.v0.1"
|
|
581
599
|
|| healthBody.contractSha256 !== input.config.evaluatorContractSha256
|
|
582
600
|
|| healthBody.ready !== true) {
|
|
601
|
+
await managedEvaluator?.close();
|
|
583
602
|
throw new Error("Managed Workflow evaluator health did not match its pinned local contract.");
|
|
584
603
|
}
|
|
585
604
|
const hosted = input.managed.createManagedWorkflowHostedClient({
|
|
@@ -594,7 +613,7 @@ export async function createConfiguredWorkflowHarness(input) {
|
|
|
594
613
|
checkpoints: new input.managed.FileWorkflowEvaluationCheckpointStore(join(input.directory, "data", "workflow-evaluations")),
|
|
595
614
|
maxConcurrency: input.config.maxConcurrency,
|
|
596
615
|
evaluate: async ({ task, evaluation }) => {
|
|
597
|
-
const response = await requestFetch(`${
|
|
616
|
+
const response = await requestFetch(`${evaluatorOrigin}/v1/evaluate`, {
|
|
598
617
|
method: "POST",
|
|
599
618
|
headers: { authorization: `Bearer ${credential}`, "content-type": "application/json" },
|
|
600
619
|
body: JSON.stringify({ schemaVersion: "witnora.business_task_evaluation_request.v0.1", task, evaluation }),
|
|
@@ -610,12 +629,23 @@ export async function createConfiguredWorkflowHarness(input) {
|
|
|
610
629
|
});
|
|
611
630
|
let timer;
|
|
612
631
|
let closing = false;
|
|
632
|
+
let lastTickAt;
|
|
633
|
+
let lastError;
|
|
613
634
|
const tick = async () => {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
635
|
+
try {
|
|
636
|
+
const result = await worker.tick();
|
|
637
|
+
lastTickAt = new Date().toISOString();
|
|
638
|
+
lastError = (result.evaluationsFailed ?? 0) > 0 ? result.limitations?.[0] ?? "One or more evaluations failed closed." : undefined;
|
|
639
|
+
if ((result.evaluationsFailed ?? 0) > 0) {
|
|
640
|
+
process.stderr.write(`Managed Workflow Harness stopped ${result.evaluationsFailed} evaluation(s) fail-closed. ${lastError}\n`);
|
|
641
|
+
}
|
|
642
|
+
return result;
|
|
643
|
+
}
|
|
644
|
+
catch (error) {
|
|
645
|
+
lastTickAt = new Date().toISOString();
|
|
646
|
+
lastError = error instanceof Error ? error.message.slice(0, 500) : "Managed Workflow Harness tick failed.";
|
|
647
|
+
throw error;
|
|
617
648
|
}
|
|
618
|
-
return result;
|
|
619
649
|
};
|
|
620
650
|
return {
|
|
621
651
|
start() {
|
|
@@ -630,10 +660,58 @@ export async function createConfiguredWorkflowHarness(input) {
|
|
|
630
660
|
if (timer)
|
|
631
661
|
clearInterval(timer);
|
|
632
662
|
timer = undefined;
|
|
663
|
+
await managedEvaluator?.close();
|
|
664
|
+
},
|
|
665
|
+
async status() {
|
|
666
|
+
return {
|
|
667
|
+
moduleDigestSha256: input.config.schemaVersion === MANAGED_WORKFLOW_HARNESS_SCHEMA ? input.config.evaluatorModuleSha256 : input.config.evaluatorContractSha256,
|
|
668
|
+
evaluatorContractSha256: input.config.evaluatorContractSha256,
|
|
669
|
+
workerReady: !closing && !lastError,
|
|
670
|
+
...(lastTickAt ? { lastTickAt } : {}),
|
|
671
|
+
...(lastError ? { lastError } : {}),
|
|
672
|
+
};
|
|
633
673
|
},
|
|
634
674
|
tick,
|
|
635
675
|
};
|
|
636
676
|
}
|
|
677
|
+
async function startManagedLocalEvaluator(directory, config, evaluatorKit) {
|
|
678
|
+
const repository = resolve(directory, "..", "..");
|
|
679
|
+
const modulePath = resolve(repository, config.evaluatorModulePath);
|
|
680
|
+
const repositoryRelative = relative(repository, modulePath);
|
|
681
|
+
if (!repositoryRelative || repositoryRelative.startsWith("..") || resolve(repository, repositoryRelative) !== modulePath) {
|
|
682
|
+
throw new Error("Managed evaluator module escaped the Agent repository.");
|
|
683
|
+
}
|
|
684
|
+
const [realRepository, realModulePath] = await Promise.all([realpath(repository), realpath(modulePath)]);
|
|
685
|
+
const realRelative = relative(realRepository, realModulePath);
|
|
686
|
+
if (!realRelative || realRelative.startsWith("..") || resolve(realRepository, realRelative) !== realModulePath) {
|
|
687
|
+
throw new Error("Managed evaluator module symlink escaped the Agent repository.");
|
|
688
|
+
}
|
|
689
|
+
const source = await readFile(modulePath);
|
|
690
|
+
if (createHash("sha256").update(source).digest("hex") !== config.evaluatorModuleSha256) {
|
|
691
|
+
throw new Error("Managed evaluator module digest did not match workflow-harness.json.");
|
|
692
|
+
}
|
|
693
|
+
const imported = await import(`${pathToFileURL(modulePath).href}?sha256=${config.evaluatorModuleSha256}`);
|
|
694
|
+
if (typeof imported.createWitnoraBusinessTaskEvaluatorOptions !== "function") {
|
|
695
|
+
throw new Error("Managed evaluator module did not export createWitnoraBusinessTaskEvaluatorOptions().");
|
|
696
|
+
}
|
|
697
|
+
const customerOptions = await imported.createWitnoraBusinessTaskEvaluatorOptions({
|
|
698
|
+
repository,
|
|
699
|
+
dataDirectory: join(directory, "data", "business-task-evaluator"),
|
|
700
|
+
});
|
|
701
|
+
if (!customerOptions || typeof customerOptions !== "object" || Array.isArray(customerOptions)) {
|
|
702
|
+
throw new Error("Managed evaluator module returned invalid Evaluator Kit options.");
|
|
703
|
+
}
|
|
704
|
+
const credential = randomBytes(32).toString("base64url");
|
|
705
|
+
const evaluator = (evaluatorKit ?? await configBusinessTaskEvaluatorImport()).createBusinessTaskEvaluatorServer({
|
|
706
|
+
...customerOptions,
|
|
707
|
+
credential,
|
|
708
|
+
contractSha256: config.evaluatorContractSha256,
|
|
709
|
+
host: "127.0.0.1",
|
|
710
|
+
port: 0,
|
|
711
|
+
});
|
|
712
|
+
const started = await evaluator.start();
|
|
713
|
+
return { origin: started.origin, credential, close: () => evaluator.close() };
|
|
714
|
+
}
|
|
637
715
|
async function runtimeSandboxFixtureReady(config) {
|
|
638
716
|
try {
|
|
639
717
|
if (config.adapterId !== LOCAL_SANDBOX_ADAPTER_ID || !config.sandboxOrigin || !config.probeTargetCredentialHandle || !config.fixtureContractSha256)
|
|
@@ -1026,16 +1104,20 @@ function parseConfig(raw) {
|
|
|
1026
1104
|
}
|
|
1027
1105
|
export function parseManagedWorkflowHarnessConfig(raw) {
|
|
1028
1106
|
const value = JSON.parse(raw);
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1107
|
+
const workflowIds = value.workflowIds;
|
|
1108
|
+
const workflowIdsValid = workflowIds === undefined || (Array.isArray(workflowIds)
|
|
1109
|
+
&& workflowIds.length > 0
|
|
1110
|
+
&& workflowIds.length <= 100
|
|
1111
|
+
&& new Set(workflowIds).size === workflowIds.length
|
|
1112
|
+
&& workflowIds.every((id) => typeof id === "string" && /^[A-Za-z0-9._:-]{1,200}$/.test(id)));
|
|
1113
|
+
const external = value.schemaVersion === WORKFLOW_HARNESS_SCHEMA
|
|
1114
|
+
&& literalLoopbackOrigin(value.evaluatorOrigin)
|
|
1115
|
+
&& credentialHandle(value.evaluatorCredentialHandle ?? "")
|
|
1116
|
+
&& Array.isArray(workflowIds);
|
|
1117
|
+
const managed = value.schemaVersion === MANAGED_WORKFLOW_HARNESS_SCHEMA
|
|
1118
|
+
&& safeRelativeModulePath(value.evaluatorModulePath)
|
|
1119
|
+
&& validDigest(value.evaluatorModuleSha256 ?? "");
|
|
1120
|
+
if (value.enabled !== true || !validDigest(value.evaluatorContractSha256 ?? "") || !workflowIdsValid || (!external && !managed)) {
|
|
1039
1121
|
throw new Error("workflow-harness.json requires an enabled, digest-pinned literal-loopback evaluator and a local credential handle.");
|
|
1040
1122
|
}
|
|
1041
1123
|
if (value.pollIntervalMs !== undefined && (!Number.isInteger(value.pollIntervalMs) || value.pollIntervalMs < 1_000 || value.pollIntervalMs > 60_000)) {
|
|
@@ -1046,6 +1128,56 @@ export function parseManagedWorkflowHarnessConfig(raw) {
|
|
|
1046
1128
|
}
|
|
1047
1129
|
return value;
|
|
1048
1130
|
}
|
|
1131
|
+
export async function activateManagedWorkflowHarness(options) {
|
|
1132
|
+
const repository = resolve(options.repository ?? process.cwd());
|
|
1133
|
+
const directory = join(repository, ".witnora", "gateway");
|
|
1134
|
+
if (!await exists(join(directory, "gateway.json")))
|
|
1135
|
+
throw new Error("Initialize the customer-owned Gateway before activating its Assurance Harness.");
|
|
1136
|
+
const absoluteModulePath = resolve(repository, options.modulePath ?? "witnora.assurance-harness.mjs");
|
|
1137
|
+
const moduleRelativeToRepository = relative(repository, absoluteModulePath);
|
|
1138
|
+
if (!moduleRelativeToRepository || moduleRelativeToRepository.startsWith("..") || resolve(repository, moduleRelativeToRepository) !== absoluteModulePath) {
|
|
1139
|
+
throw new Error("The customer Assurance Harness module must remain inside the Agent repository.");
|
|
1140
|
+
}
|
|
1141
|
+
const [realRepository, realModulePath] = await Promise.all([realpath(repository), realpath(absoluteModulePath).catch(() => absoluteModulePath)]);
|
|
1142
|
+
const realRelative = relative(realRepository, realModulePath);
|
|
1143
|
+
if (realRelative.startsWith("..") || resolve(realRepository, realRelative) !== realModulePath) {
|
|
1144
|
+
throw new Error("The customer Assurance Harness module symlink must remain inside the Agent repository.");
|
|
1145
|
+
}
|
|
1146
|
+
const source = await readFile(absoluteModulePath, "utf8").catch((error) => {
|
|
1147
|
+
if (error.code === "ENOENT") {
|
|
1148
|
+
throw new Error("No customer Assurance Harness was found. Add witnora.assurance-harness.mjs through the approved Business Task integration before activation.");
|
|
1149
|
+
}
|
|
1150
|
+
throw error;
|
|
1151
|
+
});
|
|
1152
|
+
if (!source.includes("createWitnoraBusinessTaskEvaluatorOptions")) {
|
|
1153
|
+
throw new Error("The customer Assurance Harness must export createWitnoraBusinessTaskEvaluatorOptions().");
|
|
1154
|
+
}
|
|
1155
|
+
const digestSha256 = createHash("sha256").update(source).digest("hex");
|
|
1156
|
+
const evaluatorModulePath = moduleRelativeToRepository.replaceAll("\\", "/");
|
|
1157
|
+
const config = parseManagedWorkflowHarnessConfig(JSON.stringify({
|
|
1158
|
+
schemaVersion: MANAGED_WORKFLOW_HARNESS_SCHEMA,
|
|
1159
|
+
enabled: true,
|
|
1160
|
+
evaluatorModulePath,
|
|
1161
|
+
evaluatorModuleSha256: digestSha256,
|
|
1162
|
+
evaluatorContractSha256: digestSha256,
|
|
1163
|
+
...(options.workflowIds ? { workflowIds: options.workflowIds } : {}),
|
|
1164
|
+
...(options.pollIntervalMs === undefined ? {} : { pollIntervalMs: options.pollIntervalMs }),
|
|
1165
|
+
...(options.maxConcurrency === undefined ? {} : { maxConcurrency: options.maxConcurrency }),
|
|
1166
|
+
}));
|
|
1167
|
+
const path = join(directory, "workflow-harness.json");
|
|
1168
|
+
const serialized = `${JSON.stringify(config, null, 2)}\n`;
|
|
1169
|
+
let created = false;
|
|
1170
|
+
if (await exists(path)) {
|
|
1171
|
+
const current = await readFile(path, "utf8");
|
|
1172
|
+
if (current !== serialized)
|
|
1173
|
+
throw new Error("Existing workflow-harness.json differs from the generated Assurance Harness binding; refusing to overwrite customer configuration.");
|
|
1174
|
+
}
|
|
1175
|
+
else {
|
|
1176
|
+
await writeFile(path, serialized, { encoding: "utf8", mode: 0o600, flag: "wx" });
|
|
1177
|
+
created = true;
|
|
1178
|
+
}
|
|
1179
|
+
return { state: "READY_TO_START", path, modulePath: evaluatorModulePath, config, created };
|
|
1180
|
+
}
|
|
1049
1181
|
export async function configureManagedWorkflowHarness(options) {
|
|
1050
1182
|
const directory = resolve(options.repository ?? process.cwd(), options.dir ?? ".witnora/gateway");
|
|
1051
1183
|
if (!await exists(join(directory, "gateway.json")))
|
|
@@ -1081,6 +1213,12 @@ function literalLoopbackOrigin(value) {
|
|
|
1081
1213
|
return false;
|
|
1082
1214
|
}
|
|
1083
1215
|
}
|
|
1216
|
+
function safeRelativeModulePath(value) {
|
|
1217
|
+
if (typeof value !== "string" || !value || value.length > 500 || !value.endsWith(".mjs"))
|
|
1218
|
+
return false;
|
|
1219
|
+
const normalized = value.replaceAll("\\", "/");
|
|
1220
|
+
return !normalized.startsWith("/") && !/^[A-Za-z]:\//.test(normalized) && normalized.split("/").every((part) => part && part !== "." && part !== "..");
|
|
1221
|
+
}
|
|
1084
1222
|
function validateRuntimeWorkerConfig(value) {
|
|
1085
1223
|
if (value.enabled !== true || !value.adapterModulePath || !/^[a-f0-9]{64}$/.test(value.adapterModuleSha256)
|
|
1086
1224
|
|| !value.probeModulePath || !/^[a-f0-9]{64}$/.test(value.probeModuleSha256)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomerSourceKeyRing, type CustomerSourceSigner, type CollectorRuntimeHeartbeat, type RuntimeReadinessBinding, type RemoteCollectorAck, type RemoteTrustedSourceRecord } from "./remote-collector.js";
|
|
1
|
+
import { CustomerSourceKeyRing, type CustomerSourceSigner, type CollectorRuntimeHeartbeat, type AssuranceHarnessHeartbeat, type RuntimeReadinessBinding, type RemoteCollectorAck, type RemoteTrustedSourceRecord } from "./remote-collector.js";
|
|
2
2
|
export interface RemoteCollectorTransport {
|
|
3
3
|
registerSourceKey(input: {
|
|
4
4
|
collectorId: string;
|
|
@@ -13,6 +13,7 @@ export interface RemoteCollectorTransport {
|
|
|
13
13
|
pendingRecordCount: number;
|
|
14
14
|
lastAckSequence?: number;
|
|
15
15
|
runtime?: CollectorRuntimeHeartbeat;
|
|
16
|
+
assuranceHarness?: AssuranceHarnessHeartbeat;
|
|
16
17
|
}): Promise<Record<string, unknown>>;
|
|
17
18
|
reconcile(runId: string, receipt: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
18
19
|
proposeAction(proposal: Record<string, unknown>, idempotencyKey: string): Promise<Record<string, unknown>>;
|
|
@@ -45,6 +46,9 @@ export interface CustomerOwnedCollectorGatewayOptions {
|
|
|
45
46
|
workerReady?: boolean;
|
|
46
47
|
};
|
|
47
48
|
};
|
|
49
|
+
assuranceHarness?: {
|
|
50
|
+
status(): Promise<AssuranceHarnessHeartbeat>;
|
|
51
|
+
};
|
|
48
52
|
runtimeBinding?: RuntimeReadinessBinding;
|
|
49
53
|
}
|
|
50
54
|
export interface CustomerOwnedCollectorGateway {
|
|
@@ -67,6 +71,7 @@ export interface CollectorGatewayStatus {
|
|
|
67
71
|
lastRemoteSuccessAt?: string;
|
|
68
72
|
lastRemoteError?: string;
|
|
69
73
|
actionWorker?: Record<string, unknown>;
|
|
74
|
+
assuranceHarness?: AssuranceHarnessHeartbeat;
|
|
70
75
|
}
|
|
71
76
|
export declare function startCustomerOwnedCollectorGateway(options: CustomerOwnedCollectorGatewayOptions): Promise<CustomerOwnedCollectorGateway>;
|
|
72
77
|
//# sourceMappingURL=collector-gateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector-gateway.d.ts","sourceRoot":"","sources":["../../../../agentcert-sdk/src/collector-gateway.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,qBAAqB,EAGrB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,wBAAwB;IACvC,iBAAiB,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjJ,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,EAAE,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAClH,SAAS,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,oBAAoB,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,yBAAyB,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"collector-gateway.d.ts","sourceRoot":"","sources":["../../../../agentcert-sdk/src/collector-gateway.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,qBAAqB,EAGrB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,wBAAwB;IACvC,iBAAiB,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,MAA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QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,MAAM,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,kDAAkD,CAAC;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;CAC9C;AAUD,wBAAsB,kCAAkC,CAAC,OAAO,EAAE,oCAAoC,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAqM9I"}
|
|
@@ -89,6 +89,7 @@ export async function startCustomerOwnedCollectorGateway(options) {
|
|
|
89
89
|
lastRemoteSuccessAt,
|
|
90
90
|
lastRemoteError,
|
|
91
91
|
...(options.actionWorker ? { actionWorker: await options.actionWorker.status() } : {}),
|
|
92
|
+
...(options.assuranceHarness ? { assuranceHarness: await options.assuranceHarness.status() } : {}),
|
|
92
93
|
};
|
|
93
94
|
};
|
|
94
95
|
const server = createServer(async (request, response) => {
|
|
@@ -181,6 +182,7 @@ export async function startCustomerOwnedCollectorGateway(options) {
|
|
|
181
182
|
pendingRecordCount: current.pendingRecordCount,
|
|
182
183
|
lastAckSequence: current.lastAckSequence,
|
|
183
184
|
runtime: runtimeBinding && workerStatus ? runtimeHeartbeat(runtimeBinding, workerStatus, options.actionWorker?.runtimeBinding?.fixtureReady) : undefined,
|
|
185
|
+
assuranceHarness: options.assuranceHarness ? await options.assuranceHarness.status() : undefined,
|
|
184
186
|
});
|
|
185
187
|
lastRemoteSuccessAt = new Date().toISOString();
|
|
186
188
|
lastRemoteError = undefined;
|
|
@@ -57,6 +57,13 @@ export interface CollectorRuntimeHeartbeat {
|
|
|
57
57
|
fixtureReady: boolean;
|
|
58
58
|
lastError?: string;
|
|
59
59
|
}
|
|
60
|
+
export interface AssuranceHarnessHeartbeat {
|
|
61
|
+
moduleDigestSha256: string;
|
|
62
|
+
evaluatorContractSha256: string;
|
|
63
|
+
workerReady: boolean;
|
|
64
|
+
lastTickAt?: string;
|
|
65
|
+
lastError?: string;
|
|
66
|
+
}
|
|
60
67
|
export interface RemoteCollectorClientOptions {
|
|
61
68
|
baseUrl: string;
|
|
62
69
|
projectId: string;
|
|
@@ -105,6 +112,7 @@ export declare class RemoteCollectorClient {
|
|
|
105
112
|
lastAckSequence?: number;
|
|
106
113
|
occurredAt?: string;
|
|
107
114
|
runtime?: CollectorRuntimeHeartbeat;
|
|
115
|
+
assuranceHarness?: AssuranceHarnessHeartbeat;
|
|
108
116
|
}): Promise<Record<string, unknown>>;
|
|
109
117
|
reconcile(runId: string, receipt: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
110
118
|
proposeAction(proposal: Record<string, unknown>, idempotencyKey: string): Promise<Record<string, unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-collector.d.ts","sourceRoot":"","sources":["../../../../agentcert-sdk/src/remote-collector.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAeD,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,sCAAsC,CAAC;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE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AAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;YAkB5M,OAAO;YAWP,QAAQ;CAcvB;AAUD,qBAAa,uBAAwB,SAAQ,KAAK;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM;IAAmB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM;gBAAlF,MAAM,EAAE,MAAM,EAAW,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAW,QAAQ,CAAC,EAAE,MAAM,YAAA;CAIxG"}
|
|
@@ -105,6 +105,7 @@ export class RemoteCollectorClient {
|
|
|
105
105
|
pendingRecordCount: input.pendingRecordCount,
|
|
106
106
|
lastAckSequence: input.lastAckSequence,
|
|
107
107
|
runtime: input.runtime,
|
|
108
|
+
assuranceHarness: input.assuranceHarness,
|
|
108
109
|
};
|
|
109
110
|
const payloadSha256 = sha256(canonicalJson(payload));
|
|
110
111
|
return this.json("collector-heartbeats", {
|
package/dist/onboard.js
CHANGED
|
@@ -7,7 +7,7 @@ import { verifyControlPlaneConnection } from "./control-plane.js";
|
|
|
7
7
|
import { inferPrivateCapabilities, runPrivateCapabilityDiscovery } from "./private-discovery.js";
|
|
8
8
|
import { parseAgentTemplate, starterAdapter, starterProfile, starterTripwireConfig } from "./onboarding-templates.js";
|
|
9
9
|
import { writeTryEvidence } from "./try.js";
|
|
10
|
-
import { doctorCustomerGateway, initializeCustomerGateway, inspectLocalRuntimeBinding, inspectCustomerGatewayFiles, startManagedCustomerGateway, stopManagedCustomerGateway, upgradeCustomerGatewayRuntime, RuntimeSetupNotReadyError, } from "./gateway.js";
|
|
10
|
+
import { doctorCustomerGateway, activateManagedWorkflowHarness, initializeCustomerGateway, inspectLocalRuntimeBinding, inspectCustomerGatewayFiles, startManagedCustomerGateway, stopManagedCustomerGateway, upgradeCustomerGatewayRuntime, RuntimeSetupNotReadyError, } from "./gateway.js";
|
|
11
11
|
import { discoverRuntimeReferences, planRuntimeSandboxModules } from "./runtime-sandbox-kit.js";
|
|
12
12
|
import { automaticRuntimeReferencesUsable, bootstrapLocalRuntime, verifyAutomaticRuntimeProbe } from "./runtime-bootstrap.js";
|
|
13
13
|
export async function runOnboard(options) {
|
|
@@ -85,6 +85,11 @@ export async function runOnboard(options) {
|
|
|
85
85
|
let gatewayMigration;
|
|
86
86
|
let managedGateway;
|
|
87
87
|
let runtimeUpgrade;
|
|
88
|
+
let assuranceHarnessReadiness = {
|
|
89
|
+
state: "WAITING_FOR_CUSTOMER_HARNESS",
|
|
90
|
+
limitation: "No approved customer Harness module is bound to this Agent repository.",
|
|
91
|
+
};
|
|
92
|
+
let assuranceHarnessChanged = false;
|
|
88
93
|
await reportInstall(requestFetch, server, token.projectId, token.apiKey, setupPlan.id, { status: "installing", attemptId });
|
|
89
94
|
try {
|
|
90
95
|
generatedFiles.push(...await generateRepositoryConfig(repositoryPath, repository.template, repository.name));
|
|
@@ -183,6 +188,24 @@ export async function runOnboard(options) {
|
|
|
183
188
|
}
|
|
184
189
|
const runtimeConfigured = await gatewayHasRuntimeWorker(repositoryPath);
|
|
185
190
|
generatedFiles.push(...await generateAutopilotFiles(repositoryPath, repository.name, runtimeConfigured));
|
|
191
|
+
try {
|
|
192
|
+
const activation = await activateManagedWorkflowHarness({ repository: repositoryPath });
|
|
193
|
+
if (activation.created)
|
|
194
|
+
generatedFiles.push(activation.path);
|
|
195
|
+
assuranceHarnessChanged = activation.created;
|
|
196
|
+
assuranceHarnessReadiness = { state: "ACTIVE" };
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
const detail = error instanceof Error ? error.message : "The customer Harness could not be activated.";
|
|
200
|
+
if (!detail.startsWith("No customer Assurance Harness was found."))
|
|
201
|
+
throw error;
|
|
202
|
+
assuranceHarnessReadiness = { state: "WAITING_FOR_CUSTOMER_HARNESS", limitation: detail };
|
|
203
|
+
}
|
|
204
|
+
if (assuranceHarnessChanged && gatewayState.status !== "absent") {
|
|
205
|
+
const stopped = await gatewayLifecycle.stop({ repository: repositoryPath, configHome: options.configHome, fetch: requestFetch });
|
|
206
|
+
if (stopped.state !== "STOPPED" && stopped.state !== "STALE")
|
|
207
|
+
throw new Error("The prior managed Gateway process did not stop before Assurance Harness activation.");
|
|
208
|
+
}
|
|
186
209
|
managedGateway = await gatewayLifecycle.start({
|
|
187
210
|
repository: repositoryPath,
|
|
188
211
|
configHome: options.configHome,
|
|
@@ -210,11 +233,14 @@ export async function runOnboard(options) {
|
|
|
210
233
|
output(runtimeReadiness.state === "LOCAL_SANDBOX_READY"
|
|
211
234
|
? "Runtime: LOCAL_SANDBOX_READY. This proves only the generated localhost sandbox loop is ready; it does not establish coverage, CURRENT, or a verified customer outcome.\n"
|
|
212
235
|
: `Runtime: RECORDED_ONLY. ${runtimeReadiness.limitations[0]}\n`);
|
|
236
|
+
output(assuranceHarnessReadiness.state === "ACTIVE"
|
|
237
|
+
? "Assurance Harness: ACTIVE. Nora can dispatch authority-ready Replay and no-write Shadow evaluations without manual Workflow IDs, evaluator origins, credentials, or contract digests.\n"
|
|
238
|
+
: `Assurance Harness: WAITING_FOR_CUSTOMER_HARNESS. ${assuranceHarnessReadiness.limitation}\n`);
|
|
213
239
|
output("The self-test remains isolated. The Gateway is ready in the background; run the agent normally. The first source-signed, server-reconciled Gateway run completes onboarding.\n");
|
|
214
240
|
return { projectId: token.projectId, connectionName: token.connectionName, credentialsPath, template: repository.template,
|
|
215
241
|
repositoryKind: repository.kind, generatedFiles, receiptPath, discovery, setupPlanId: setupPlan.id,
|
|
216
242
|
gatewayDirectory: join(repositoryPath, ".witnora", "gateway"), gatewayArchiveDirectory: gatewayMigration?.archiveDirectory,
|
|
217
|
-
gateway: managedGateway, runtimeReadiness };
|
|
243
|
+
gateway: managedGateway, runtimeReadiness, assuranceHarnessReadiness };
|
|
218
244
|
}
|
|
219
245
|
catch (error) {
|
|
220
246
|
const diagnosis = error instanceof Error ? error.message : String(error);
|
|
@@ -11,6 +11,14 @@ export interface BusinessTaskEvaluationBinding {
|
|
|
11
11
|
agentVersion: string;
|
|
12
12
|
baselineAgentVersion?: string;
|
|
13
13
|
mode: "REPLAY" | "SHADOW";
|
|
14
|
+
scenarioPriority?: {
|
|
15
|
+
source: "PROJECT_HISTORY" | "APPROVED_SUITE";
|
|
16
|
+
prioritizedScenarioIds: string[];
|
|
17
|
+
priorEvaluations: number;
|
|
18
|
+
priorFailures: number;
|
|
19
|
+
priorRecoveries: number;
|
|
20
|
+
reason: string;
|
|
21
|
+
};
|
|
14
22
|
}
|
|
15
23
|
export interface BusinessTaskEvaluatorServerOptions {
|
|
16
24
|
credential: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"business-task-evaluator.d.ts","sourceRoot":"","sources":["../../../../onegent-runtime/src/business-task-evaluator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAGL,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAE3B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,sCAAsC,EAAG,sCAA+C,CAAC;AACtG,eAAO,MAAM,+CAA+C,EAAG,+CAAwD,CAAC;AAExH,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB,EAAE,MAAM,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"business-task-evaluator.d.ts","sourceRoot":"","sources":["../../../../onegent-runtime/src/business-task-evaluator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA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playScenarios(task, binding, signal),
|
|
84
84
|
]);
|
|
85
85
|
return runReplayEvaluation({
|
|
86
|
-
task, harness, tenantId, scenarios,
|
|
86
|
+
task, harness, tenantId, scenarios: prioritizeScenarios(scenarios, binding.scenarioPriority?.prioritizedScenarioIds),
|
|
87
87
|
evaluateCandidate: (scenario) => options.evaluateReplayCandidate(scenario, task, binding, signal),
|
|
88
88
|
});
|
|
89
89
|
}
|
|
@@ -91,7 +91,7 @@ async function evaluate(options, task, binding, signal) {
|
|
|
91
91
|
throw new EvaluatorError(409, "shadow_not_configured");
|
|
92
92
|
return runShadowEvaluation({
|
|
93
93
|
task,
|
|
94
|
-
observations: await options.loadShadowObservations(task, binding, signal),
|
|
94
|
+
observations: prioritizeScenarios(await options.loadShadowObservations(task, binding, signal), binding.scenarioPriority?.prioritizedScenarioIds),
|
|
95
95
|
evaluateCandidate: (context) => options.evaluateShadowCandidate(context, task, binding, signal),
|
|
96
96
|
});
|
|
97
97
|
}
|
|
@@ -101,7 +101,7 @@ function parseRequest(input) {
|
|
|
101
101
|
if (body.schemaVersion !== BUSINESS_TASK_EVALUATION_REQUEST_SCHEMA_VERSION)
|
|
102
102
|
throw new EvaluatorError(422, "invalid_schema");
|
|
103
103
|
const evaluation = object(body.evaluation, "evaluation");
|
|
104
|
-
exactKeys(evaluation, ["nodeId", "taskContractId", "taskContractDigestSha256", "taskKey", "agentId", "agentVersion", "baselineAgentVersion", "mode"], "evaluation");
|
|
104
|
+
exactKeys(evaluation, ["nodeId", "taskContractId", "taskContractDigestSha256", "taskKey", "agentId", "agentVersion", "baselineAgentVersion", "mode", "scenarioPriority"], "evaluation");
|
|
105
105
|
if (evaluation.mode !== "REPLAY" && evaluation.mode !== "SHADOW")
|
|
106
106
|
throw new EvaluatorError(422, "invalid_mode");
|
|
107
107
|
const binding = {
|
|
@@ -110,10 +110,42 @@ function parseRequest(input) {
|
|
|
110
110
|
taskKey: requiredString(evaluation.taskKey), agentId: requiredString(evaluation.agentId),
|
|
111
111
|
agentVersion: requiredString(evaluation.agentVersion),
|
|
112
112
|
...(evaluation.baselineAgentVersion === undefined ? {} : { baselineAgentVersion: requiredString(evaluation.baselineAgentVersion) }),
|
|
113
|
+
...(evaluation.scenarioPriority === undefined ? {} : { scenarioPriority: parseScenarioPriority(evaluation.scenarioPriority) }),
|
|
113
114
|
mode: evaluation.mode,
|
|
114
115
|
};
|
|
115
116
|
return { task: object(body.task, "task"), evaluation: binding };
|
|
116
117
|
}
|
|
118
|
+
function parseScenarioPriority(value) {
|
|
119
|
+
const priority = object(value, "scenario_priority");
|
|
120
|
+
exactKeys(priority, ["source", "prioritizedScenarioIds", "priorEvaluations", "priorFailures", "priorRecoveries", "reason"], "scenario_priority");
|
|
121
|
+
if (priority.source !== "PROJECT_HISTORY" && priority.source !== "APPROVED_SUITE")
|
|
122
|
+
throw new EvaluatorError(422, "invalid_scenario_priority");
|
|
123
|
+
const ids = Array.isArray(priority.prioritizedScenarioIds) ? priority.prioritizedScenarioIds : [];
|
|
124
|
+
if (ids.length > 100 || new Set(ids).size !== ids.length || ids.some((id) => typeof id !== "string" || !id || id.length > 200))
|
|
125
|
+
throw new EvaluatorError(422, "invalid_scenario_priority");
|
|
126
|
+
const counts = [priority.priorEvaluations, priority.priorFailures, priority.priorRecoveries];
|
|
127
|
+
if (counts.some((count) => !Number.isSafeInteger(count) || Number(count) < 0))
|
|
128
|
+
throw new EvaluatorError(422, "invalid_scenario_priority");
|
|
129
|
+
const reason = requiredString(priority.reason);
|
|
130
|
+
if (reason.length > 500)
|
|
131
|
+
throw new EvaluatorError(422, "invalid_scenario_priority");
|
|
132
|
+
return {
|
|
133
|
+
source: priority.source,
|
|
134
|
+
prioritizedScenarioIds: ids,
|
|
135
|
+
priorEvaluations: Number(priority.priorEvaluations),
|
|
136
|
+
priorFailures: Number(priority.priorFailures),
|
|
137
|
+
priorRecoveries: Number(priority.priorRecoveries),
|
|
138
|
+
reason,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function prioritizeScenarios(scenarios, ids) {
|
|
142
|
+
if (!ids?.length)
|
|
143
|
+
return scenarios;
|
|
144
|
+
const order = new Map(ids.map((id, index) => [id, index]));
|
|
145
|
+
return scenarios.map((scenario, index) => ({ scenario, index }))
|
|
146
|
+
.sort((left, right) => (order.get(left.scenario.id) ?? Number.MAX_SAFE_INTEGER) - (order.get(right.scenario.id) ?? Number.MAX_SAFE_INTEGER) || left.index - right.index)
|
|
147
|
+
.map(({ scenario }) => scenario);
|
|
148
|
+
}
|
|
117
149
|
function validateBinding(task, binding) {
|
|
118
150
|
if (task.id !== binding.taskContractId || task.digestSha256 !== binding.taskContractDigestSha256
|
|
119
151
|
|| task.taskKey !== binding.taskKey || task.subject?.agentId !== binding.agentId
|
|
@@ -31,6 +31,14 @@ export interface ManagedWorkflowReadyEvaluation {
|
|
|
31
31
|
agentVersion: string;
|
|
32
32
|
baselineAgentVersion?: string;
|
|
33
33
|
mode: ManagedWorkflowEvaluationMode;
|
|
34
|
+
scenarioPriority?: {
|
|
35
|
+
source: "PROJECT_HISTORY" | "APPROVED_SUITE";
|
|
36
|
+
prioritizedScenarioIds: string[];
|
|
37
|
+
priorEvaluations: number;
|
|
38
|
+
priorFailures: number;
|
|
39
|
+
priorRecoveries: number;
|
|
40
|
+
reason: string;
|
|
41
|
+
};
|
|
34
42
|
}
|
|
35
43
|
export interface ManagedAutopilotDispatchPlan {
|
|
36
44
|
schemaVersion: "witnora.nora_assurance_autopilot.v0.1";
|
|
@@ -50,6 +58,7 @@ export interface ManagedAutopilotDispatchPlan {
|
|
|
50
58
|
changeIds: string[];
|
|
51
59
|
changeSetDigestSha256: string;
|
|
52
60
|
affectedActionPathIds: string[];
|
|
61
|
+
scenarioPriority: NonNullable<ManagedWorkflowReadyEvaluation["scenarioPriority"]>;
|
|
53
62
|
status: "READY" | "RUNNING" | "COMPLETED" | "NEEDS_DECISION" | "BLOCKED";
|
|
54
63
|
}>;
|
|
55
64
|
safety: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managed-workflow-harness.d.ts","sourceRoot":"","sources":["../../../../onegent-runtime/src/managed-workflow-harness.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGzF,MAAM,MAAM,6BAA6B,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhE,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,+CAA+C,CAAC;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAA;KAAE,CAAC;IAC7E,KAAK,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,gBAAgB,GAAG,WAAW,CAAA;KAAE,CAAC,CAAC;IACvG,gBAAgB,EAAE,8BAA8B,EAAE,CAAC;IACnD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE;QAAE,gBAAgB,EAAE,CAAC,CAAC;QAAC,uBAAuB,EAAE,KAAK,CAAC;QAAC,uBAAuB,EAAE,IAAI,CAAA;KAAE,CAAC;IAC/F,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB,EAAE,MAAM,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,IAAI,EAAE,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"managed-workflow-harness.d.ts","s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CAAC;IAI9D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3C;AAED,qBAAa,qCAAsC,YAAW,iCAAiC;IACjF,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,MAAM;IAIxC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAS5D,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,OAAO,CAAC,IAAI;CAGb;AAED,MAAM,WAAW,oCAAoC;IACnD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4BAA4B,EAAE,MAAM,CAAC;IACrC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,qBAAa,8BAA8B;;gBAO7B,OAAO,EAAE;QACnB,MAAM,EAAE,2BAA2B,CAAC;QACpC,WAAW,EAAE,iCAAiC,CAAC;QAC/C,QAAQ,EAAE,CAAC,KAAK,EAAE;YAAE,IAAI,EAAE,sBAAsB,CAAC;YAAC,UAAU,EAAE,8BAA8B,CAAA;SAAE,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACjI,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;IAUD,IAAI,IAAI,OAAO,CAAC,oCAAoC,CAAC;YAMvC,OAAO;CAuFtB"}
|
|
@@ -182,6 +182,7 @@ export class ManagedBusinessWorkflowHarness {
|
|
|
182
182
|
agentVersion: dispatch.candidateAgentVersion,
|
|
183
183
|
baselineAgentVersion: dispatch.baselineAgentVersion,
|
|
184
184
|
mode: dispatch.mode,
|
|
185
|
+
scenarioPriority: structuredClone(dispatch.scenarioPriority),
|
|
185
186
|
};
|
|
186
187
|
const key = `autopilot:${autopilot.projectId}:${dispatch.id}`;
|
|
187
188
|
try {
|
|
@@ -220,12 +221,23 @@ function validateAutopilotPlan(plan) {
|
|
|
220
221
|
if (dispatch.projectId !== plan.projectId || seen.has(dispatch.id) || !/^[a-f0-9]{64}$/.test(dispatch.id)
|
|
221
222
|
|| !/^[a-f0-9]{64}$/.test(dispatch.taskContractDigestSha256) || !/^[a-f0-9]{64}$/.test(dispatch.changeSetDigestSha256)
|
|
222
223
|
|| (dispatch.mode !== "REPLAY" && dispatch.mode !== "SHADOW") || !dispatch.agentId || !dispatch.baselineAgentVersion || !dispatch.candidateAgentVersion
|
|
223
|
-
|| !Array.isArray(dispatch.changeIds) || !dispatch.changeIds.length || !Array.isArray(dispatch.affectedActionPathIds)
|
|
224
|
+
|| !Array.isArray(dispatch.changeIds) || !dispatch.changeIds.length || !Array.isArray(dispatch.affectedActionPathIds)
|
|
225
|
+
|| !validScenarioPriority(dispatch.scenarioPriority)) {
|
|
224
226
|
throw new Error("Managed Workflow Harness rejected an invalid Nora Autopilot dispatch.");
|
|
225
227
|
}
|
|
226
228
|
seen.add(dispatch.id);
|
|
227
229
|
}
|
|
228
230
|
}
|
|
231
|
+
function validScenarioPriority(value) {
|
|
232
|
+
return Boolean(value
|
|
233
|
+
&& (value.source === "PROJECT_HISTORY" || value.source === "APPROVED_SUITE")
|
|
234
|
+
&& Array.isArray(value.prioritizedScenarioIds)
|
|
235
|
+
&& value.prioritizedScenarioIds.length <= 100
|
|
236
|
+
&& new Set(value.prioritizedScenarioIds).size === value.prioritizedScenarioIds.length
|
|
237
|
+
&& value.prioritizedScenarioIds.every((id) => typeof id === "string" && id.length > 0 && id.length <= 200)
|
|
238
|
+
&& [value.priorEvaluations, value.priorFailures, value.priorRecoveries].every((count) => Number.isSafeInteger(count) && count >= 0)
|
|
239
|
+
&& typeof value.reason === "string" && value.reason.length > 0 && value.reason.length <= 500);
|
|
240
|
+
}
|
|
229
241
|
function validatePlan(plan, workflow) {
|
|
230
242
|
if (plan.schemaVersion !== "witnora.business_workflow_execution_plan.v0.1"
|
|
231
243
|
|| plan.workflow.id !== workflow.id
|