openpond-sdk 0.3.3 → 0.4.0
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/TASKSETS.md +55 -0
- package/dist/actions-local.js +67 -118
- package/dist/actions-local.js.map +4 -4
- package/dist/actions.js +4 -92
- package/dist/actions.js.map +4 -4
- package/dist/chunk-27ETSPHQ.js +83 -0
- package/dist/chunk-27ETSPHQ.js.map +7 -0
- package/dist/chunk-5PRP457R.js +477 -0
- package/dist/chunk-5PRP457R.js.map +7 -0
- package/dist/chunk-65D4C7HP.js +273 -0
- package/dist/chunk-65D4C7HP.js.map +7 -0
- package/dist/chunk-747CMU2Y.js +222 -0
- package/dist/chunk-747CMU2Y.js.map +7 -0
- package/dist/chunk-7O5X7DBU.js +80 -0
- package/dist/chunk-7O5X7DBU.js.map +7 -0
- package/dist/chunk-A4ZDOZKP.js +115 -0
- package/dist/chunk-A4ZDOZKP.js.map +7 -0
- package/dist/chunk-APHPXQEA.js +155 -0
- package/dist/chunk-APHPXQEA.js.map +7 -0
- package/dist/chunk-AVW35YOH.js +574 -0
- package/dist/chunk-AVW35YOH.js.map +7 -0
- package/dist/chunk-AZUCY3E5.js +2395 -0
- package/dist/chunk-AZUCY3E5.js.map +7 -0
- package/dist/chunk-IVEXCIHO.js +1373 -0
- package/dist/chunk-IVEXCIHO.js.map +7 -0
- package/dist/chunk-K5ZCYOZO.js +49 -0
- package/dist/chunk-K5ZCYOZO.js.map +7 -0
- package/dist/chunk-LLHE4BOD.js +220 -0
- package/dist/chunk-LLHE4BOD.js.map +7 -0
- package/dist/chunk-LXXQVGQY.js +1 -0
- package/dist/chunk-LXXQVGQY.js.map +7 -0
- package/dist/chunk-P27DQ65Z.js +138 -0
- package/dist/chunk-P27DQ65Z.js.map +7 -0
- package/dist/chunk-QLEJOCQX.js +72 -0
- package/dist/chunk-QLEJOCQX.js.map +7 -0
- package/dist/chunk-S7I45WJQ.js +57 -0
- package/dist/chunk-S7I45WJQ.js.map +7 -0
- package/dist/chunk-ZPCK222K.js +586 -0
- package/dist/chunk-ZPCK222K.js.map +7 -0
- package/dist/index.js +33 -2488
- package/dist/index.js.map +4 -4
- package/dist/learning.js +16 -2042
- package/dist/learning.js.map +4 -4
- package/dist/model-batch-review.js +5 -42
- package/dist/model-batch-review.js.map +3 -3
- package/dist/model-projects.js +29 -430
- package/dist/model-projects.js.map +3 -3
- package/dist/model-starter-attempts.js +53 -310
- package/dist/model-starter-attempts.js.map +4 -4
- package/dist/model-starter-catalog.js +17 -460
- package/dist/model-starter-catalog.js.map +4 -4
- package/dist/model-starters.js +32 -709
- package/dist/model-starters.js.map +4 -4
- package/dist/model-taskset-authoring.js +11 -44
- package/dist/model-taskset-authoring.js.map +3 -3
- package/dist/profile-actions.js +4 -211
- package/dist/profile-actions.js.map +3 -3
- package/dist/project-actions.js +4 -224
- package/dist/project-actions.js.map +3 -3
- package/dist/refiner.js +14 -554
- package/dist/refiner.js.map +4 -4
- package/dist/taskset-catalog.js +9 -104
- package/dist/taskset-catalog.js.map +3 -3
- package/dist/taskset-drafts.js +465 -0
- package/dist/taskset-drafts.js.map +7 -0
- package/dist/taskset-packages.js +946 -3089
- package/dist/taskset-packages.js.map +4 -4
- package/dist/training.js +43 -822
- package/dist/training.js.map +4 -4
- package/dist/types/packages/sdk/src/index.d.ts +3 -3
- package/dist/types/packages/sdk/src/index.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/learning-client.d.ts +130 -0
- package/dist/types/packages/sdk/src/learning-client.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/learning.d.ts +1 -129
- package/dist/types/packages/sdk/src/learning.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/taskset-authored-contracts.d.ts +1170 -0
- package/dist/types/packages/sdk/src/taskset-authored-contracts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-files.d.ts +560 -0
- package/dist/types/packages/sdk/src/taskset-authored-files.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-portable-release.d.ts +92 -0
- package/dist/types/packages/sdk/src/taskset-authored-portable-release.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-tool-environment.d.ts +15 -0
- package/dist/types/packages/sdk/src/taskset-authored-tool-environment.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-validation.d.ts +18 -0
- package/dist/types/packages/sdk/src/taskset-authored-validation.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-api-contracts.d.ts +1681 -0
- package/dist/types/packages/sdk/src/taskset-draft-api-contracts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-authoring.d.ts +19 -0
- package/dist/types/packages/sdk/src/taskset-draft-authoring.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-client.d.ts +2713 -0
- package/dist/types/packages/sdk/src/taskset-draft-client.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-core.d.ts +1000 -0
- package/dist/types/packages/sdk/src/taskset-draft-core.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-artifacts.d.ts +429 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-artifacts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-sources.d.ts +284 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-sources.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-document.d.ts +846 -0
- package/dist/types/packages/sdk/src/taskset-draft-document.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-files.d.ts +8 -0
- package/dist/types/packages/sdk/src/taskset-draft-files.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-harness-actions.d.ts +28 -0
- package/dist/types/packages/sdk/src/taskset-draft-harness-actions.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-manifests.d.ts +8 -0
- package/dist/types/packages/sdk/src/taskset-draft-manifests.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-package-compiler.d.ts +967 -0
- package/dist/types/packages/sdk/src/taskset-draft-package-compiler.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-publication.d.ts +10 -0
- package/dist/types/packages/sdk/src/taskset-draft-publication.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-source.d.ts +1297 -0
- package/dist/types/packages/sdk/src/taskset-draft-source.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-workspace.d.ts +1597 -0
- package/dist/types/packages/sdk/src/taskset-draft-workspace.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-drafts.d.ts +16 -0
- package/dist/types/packages/sdk/src/taskset-drafts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-package-grader-projection.d.ts +64 -0
- package/dist/types/packages/sdk/src/taskset-package-grader-projection.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-package-projection.d.ts +1514 -0
- package/dist/types/packages/sdk/src/taskset-package-projection.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-packages.d.ts +6 -0
- package/dist/types/packages/sdk/src/taskset-packages.d.ts.map +1 -1
- package/dist/workflows.js +4 -221
- package/dist/workflows.js.map +3 -3
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import {
|
|
2
|
+
OpenPondLearningClient,
|
|
3
|
+
OpenPondLearningError
|
|
4
|
+
} from "./chunk-LLHE4BOD.js";
|
|
5
|
+
import "./chunk-IVEXCIHO.js";
|
|
6
|
+
import {
|
|
7
|
+
OpenPondProjectActionsClient
|
|
8
|
+
} from "./chunk-27ETSPHQ.js";
|
|
9
|
+
import {
|
|
10
|
+
OpenPondProfileActionsClient
|
|
11
|
+
} from "./chunk-QLEJOCQX.js";
|
|
12
|
+
import {
|
|
13
|
+
OpenPondWorkflowsClient
|
|
14
|
+
} from "./chunk-7O5X7DBU.js";
|
|
15
|
+
import {
|
|
16
|
+
OpenPondApiError,
|
|
17
|
+
apiFetch,
|
|
18
|
+
readApiJson
|
|
19
|
+
} from "./chunk-APHPXQEA.js";
|
|
20
|
+
import "./chunk-LXXQVGQY.js";
|
|
21
|
+
import {
|
|
22
|
+
DEFAULT_REFINER_REVIEW_PROFILE,
|
|
23
|
+
REFINER_CORE_VERSION,
|
|
24
|
+
RefinerBindingSchema,
|
|
25
|
+
RefinerReleaseSchema,
|
|
26
|
+
RefinerReviewInstructionSchema,
|
|
27
|
+
RefinerReviewProfileSchema,
|
|
28
|
+
RefinerTransitionReceiptSchema,
|
|
29
|
+
createRefinerRelease,
|
|
30
|
+
defineReviewProfile,
|
|
31
|
+
refinerProfilePrompt,
|
|
32
|
+
serializeReviewProfile
|
|
33
|
+
} from "./chunk-ZPCK222K.js";
|
|
18
34
|
|
|
19
35
|
// ../cloud/dist/sandbox/client-handles.js
|
|
20
36
|
function createSandboxRuntimeNamespace(client) {
|
|
@@ -517,155 +533,6 @@ function asyncRequestHeaders(options = {}) {
|
|
|
517
533
|
return options.async || options.respondAsync ? { Prefer: "respond-async" } : void 0;
|
|
518
534
|
}
|
|
519
535
|
|
|
520
|
-
// ../cloud/dist/api/core.js
|
|
521
|
-
var DEFAULT_API_TIMEOUT_MS = 3e4;
|
|
522
|
-
var DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
523
|
-
var LONG_STREAM_API_OPTIONS = { timeoutMs: 15 * 60 * 1e3, maxResponseBytes: 64 * 1024 * 1024 };
|
|
524
|
-
var ApiTimeoutError = class extends Error {
|
|
525
|
-
timeoutMs;
|
|
526
|
-
requestUrl;
|
|
527
|
-
code = "OPENPOND_API_TIMEOUT";
|
|
528
|
-
constructor(timeoutMs, requestUrl) {
|
|
529
|
-
super(`API request timed out after ${timeoutMs}ms: ${requestUrl}`);
|
|
530
|
-
this.timeoutMs = timeoutMs;
|
|
531
|
-
this.requestUrl = requestUrl;
|
|
532
|
-
this.name = "ApiTimeoutError";
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
var ApiResponseTooLargeError = class extends Error {
|
|
536
|
-
maximumBytes;
|
|
537
|
-
requestUrl;
|
|
538
|
-
code = "OPENPOND_API_RESPONSE_TOO_LARGE";
|
|
539
|
-
constructor(maximumBytes, requestUrl) {
|
|
540
|
-
super(`API response exceeded ${maximumBytes} bytes: ${requestUrl}`);
|
|
541
|
-
this.maximumBytes = maximumBytes;
|
|
542
|
-
this.requestUrl = requestUrl;
|
|
543
|
-
this.name = "ApiResponseTooLargeError";
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
var OpenPondApiError = class extends Error {
|
|
547
|
-
status;
|
|
548
|
-
apiMessage;
|
|
549
|
-
code;
|
|
550
|
-
constructor(status, errorCode, label, apiMessage = null) {
|
|
551
|
-
const detail = apiMessage || errorCode;
|
|
552
|
-
super(`${label} failed: ${status}${detail ? ` ${detail}` : ""}`);
|
|
553
|
-
this.status = status;
|
|
554
|
-
this.apiMessage = apiMessage;
|
|
555
|
-
this.name = "OpenPondApiError";
|
|
556
|
-
this.code = errorCode || "OPENPOND_API_ERROR";
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
async function apiFetch(baseUrl, token, requestPath, options = {}) {
|
|
560
|
-
const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;
|
|
561
|
-
const requestUrl = `${baseUrl}${requestPath}`;
|
|
562
|
-
const headers = new Headers(init.headers);
|
|
563
|
-
headers.set("Content-Type", "application/json");
|
|
564
|
-
const apiKey = process.env.OPENPOND_API_KEY;
|
|
565
|
-
const trimmedToken = token?.trim() || "";
|
|
566
|
-
const tokenIsApiKey = trimmedToken.startsWith("opk_");
|
|
567
|
-
const effectiveApiKey = apiKey || (tokenIsApiKey ? trimmedToken : null);
|
|
568
|
-
if (effectiveApiKey && !headers.has("openpond-api-key"))
|
|
569
|
-
headers.set("openpond-api-key", effectiveApiKey);
|
|
570
|
-
if (token) {
|
|
571
|
-
headers.set("Authorization", tokenIsApiKey ? `ApiKey ${trimmedToken}` : `Bearer ${token}`);
|
|
572
|
-
} else if (apiKey && !headers.has("Authorization")) {
|
|
573
|
-
headers.set("Authorization", `ApiKey ${apiKey}`);
|
|
574
|
-
}
|
|
575
|
-
const timeoutController = new AbortController();
|
|
576
|
-
const timeoutError = new ApiTimeoutError(timeoutMs, requestUrl);
|
|
577
|
-
const timer = timeoutMs > 0 ? setTimeout(() => timeoutController.abort(timeoutError), timeoutMs) : null;
|
|
578
|
-
timer?.unref?.();
|
|
579
|
-
const signal = composedSignal(init.signal, timeoutController.signal, timeoutMs);
|
|
580
|
-
const cleanup = () => {
|
|
581
|
-
if (timer)
|
|
582
|
-
clearTimeout(timer);
|
|
583
|
-
};
|
|
584
|
-
try {
|
|
585
|
-
const response = await fetch(requestUrl, { ...init, headers, signal });
|
|
586
|
-
return boundedResponse(response, {
|
|
587
|
-
cleanup,
|
|
588
|
-
maximumBytes: maxResponseBytes,
|
|
589
|
-
requestUrl,
|
|
590
|
-
timeoutController,
|
|
591
|
-
timeoutError
|
|
592
|
-
});
|
|
593
|
-
} catch (error) {
|
|
594
|
-
cleanup();
|
|
595
|
-
if (timeoutController.signal.aborted)
|
|
596
|
-
throw timeoutError;
|
|
597
|
-
throw error;
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
async function readApiJson(response, label) {
|
|
601
|
-
let payload;
|
|
602
|
-
try {
|
|
603
|
-
const text = await response.text();
|
|
604
|
-
payload = text ? JSON.parse(text) : {};
|
|
605
|
-
} catch (error) {
|
|
606
|
-
if (error instanceof ApiTimeoutError || error instanceof ApiResponseTooLargeError)
|
|
607
|
-
throw error;
|
|
608
|
-
payload = {};
|
|
609
|
-
}
|
|
610
|
-
if (!response.ok) {
|
|
611
|
-
const errorCode = typeof payload.error === "string" ? payload.error : null;
|
|
612
|
-
const apiMessage = typeof payload.message === "string" ? payload.message : null;
|
|
613
|
-
throw new OpenPondApiError(response.status, errorCode, label, apiMessage);
|
|
614
|
-
}
|
|
615
|
-
return payload;
|
|
616
|
-
}
|
|
617
|
-
function boundedResponse(response, input) {
|
|
618
|
-
if (!response.body) {
|
|
619
|
-
input.cleanup();
|
|
620
|
-
return response;
|
|
621
|
-
}
|
|
622
|
-
const contentLength = Number(response.headers.get("content-length"));
|
|
623
|
-
if (input.maximumBytes > 0 && Number.isFinite(contentLength) && contentLength > input.maximumBytes) {
|
|
624
|
-
input.cleanup();
|
|
625
|
-
void response.body.cancel();
|
|
626
|
-
throw new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl);
|
|
627
|
-
}
|
|
628
|
-
const reader = response.body.getReader();
|
|
629
|
-
let receivedBytes = 0;
|
|
630
|
-
const body = new ReadableStream({
|
|
631
|
-
async pull(controller) {
|
|
632
|
-
try {
|
|
633
|
-
const result = await reader.read();
|
|
634
|
-
if (result.done) {
|
|
635
|
-
input.cleanup();
|
|
636
|
-
controller.close();
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
receivedBytes += result.value.byteLength;
|
|
640
|
-
if (input.maximumBytes > 0 && receivedBytes > input.maximumBytes) {
|
|
641
|
-
input.cleanup();
|
|
642
|
-
await reader.cancel();
|
|
643
|
-
controller.error(new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl));
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
controller.enqueue(result.value);
|
|
647
|
-
} catch (error) {
|
|
648
|
-
input.cleanup();
|
|
649
|
-
controller.error(input.timeoutController.signal.aborted ? input.timeoutError : error);
|
|
650
|
-
}
|
|
651
|
-
},
|
|
652
|
-
async cancel(reason) {
|
|
653
|
-
input.cleanup();
|
|
654
|
-
await reader.cancel(reason);
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
return new Response(body, {
|
|
658
|
-
headers: response.headers,
|
|
659
|
-
status: response.status,
|
|
660
|
-
statusText: response.statusText
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
function composedSignal(callerSignal, timeoutSignal, timeoutMs) {
|
|
664
|
-
if (timeoutMs <= 0)
|
|
665
|
-
return callerSignal ?? void 0;
|
|
666
|
-
return callerSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : timeoutSignal;
|
|
667
|
-
}
|
|
668
|
-
|
|
669
536
|
// ../cloud/dist/urls.js
|
|
670
537
|
var DEFAULT_OPENPOND_WEB_BASE_URL = "https://openpond.ai";
|
|
671
538
|
var DEFAULT_OPENPOND_API_BASE_URL = "https://api.openpond.ai";
|
|
@@ -2497,2328 +2364,6 @@ function sleep2(milliseconds, signal) {
|
|
|
2497
2364
|
});
|
|
2498
2365
|
}
|
|
2499
2366
|
|
|
2500
|
-
// src/project-actions.ts
|
|
2501
|
-
import { promises as fs } from "node:fs";
|
|
2502
|
-
var OpenPondProjectActionsClient = class {
|
|
2503
|
-
#apiKey;
|
|
2504
|
-
#apiBaseUrl;
|
|
2505
|
-
constructor(input) {
|
|
2506
|
-
this.#apiKey = input.apiKey;
|
|
2507
|
-
this.#apiBaseUrl = input.apiBaseUrl.replace(/\/+$/, "");
|
|
2508
|
-
}
|
|
2509
|
-
async list(input) {
|
|
2510
|
-
const response = await apiFetch(
|
|
2511
|
-
this.#apiBaseUrl,
|
|
2512
|
-
this.#apiKey,
|
|
2513
|
-
projectActionPath(input.projectId, "releases", input.teamId)
|
|
2514
|
-
);
|
|
2515
|
-
return (await readApiJson(response, "List Project Action releases")).releases;
|
|
2516
|
-
}
|
|
2517
|
-
async catalog(input) {
|
|
2518
|
-
const response = await apiFetch(
|
|
2519
|
-
this.#apiBaseUrl,
|
|
2520
|
-
this.#apiKey,
|
|
2521
|
-
projectActionPath(input.projectId, "catalog", input.teamId)
|
|
2522
|
-
);
|
|
2523
|
-
return (await readApiJson(response, "Get Project Action catalog")).catalog;
|
|
2524
|
-
}
|
|
2525
|
-
async publish(input) {
|
|
2526
|
-
const [bundle, runner] = await Promise.all([
|
|
2527
|
-
fs.readFile(input.build.bundlePath),
|
|
2528
|
-
fs.readFile(input.build.runnerPath)
|
|
2529
|
-
]);
|
|
2530
|
-
const response = await apiFetch(
|
|
2531
|
-
this.#apiBaseUrl,
|
|
2532
|
-
this.#apiKey,
|
|
2533
|
-
projectActionPath(input.projectId, "releases", input.teamId),
|
|
2534
|
-
{
|
|
2535
|
-
method: "POST",
|
|
2536
|
-
body: JSON.stringify({
|
|
2537
|
-
sourceRef: input.sourceRef,
|
|
2538
|
-
sourceCommitSha: input.sourceCommitSha,
|
|
2539
|
-
bundleBase64: bundle.toString("base64"),
|
|
2540
|
-
runnerBase64: runner.toString("base64"),
|
|
2541
|
-
registry: input.build.registry,
|
|
2542
|
-
manifest: input.build.manifest,
|
|
2543
|
-
metadata: input.metadata
|
|
2544
|
-
})
|
|
2545
|
-
}
|
|
2546
|
-
);
|
|
2547
|
-
return (await readApiJson(response, "Publish Project Actions")).release;
|
|
2548
|
-
}
|
|
2549
|
-
async run(input) {
|
|
2550
|
-
const response = await apiFetch(
|
|
2551
|
-
this.#apiBaseUrl,
|
|
2552
|
-
this.#apiKey,
|
|
2553
|
-
projectActionPath(input.projectId, `actions/${encodeURIComponent(input.actionId)}`, input.teamId),
|
|
2554
|
-
{
|
|
2555
|
-
method: "POST",
|
|
2556
|
-
body: JSON.stringify({
|
|
2557
|
-
input: input.value ?? {},
|
|
2558
|
-
releaseId: input.releaseId,
|
|
2559
|
-
idempotencyKey: input.idempotencyKey,
|
|
2560
|
-
callerType: input.callerType ?? "sdk",
|
|
2561
|
-
callerId: input.callerId
|
|
2562
|
-
}),
|
|
2563
|
-
signal: input.signal,
|
|
2564
|
-
timeoutMs: 15 * 60 * 1e3
|
|
2565
|
-
}
|
|
2566
|
-
);
|
|
2567
|
-
return (await readApiJson(response, "Run Project Action")).invocation;
|
|
2568
|
-
}
|
|
2569
|
-
};
|
|
2570
|
-
function projectActionPath(projectId, suffix, teamId) {
|
|
2571
|
-
return `/v1/project-actions/${encodeURIComponent(projectId)}/${suffix}?teamId=${encodeURIComponent(teamId)}`;
|
|
2572
|
-
}
|
|
2573
|
-
|
|
2574
|
-
// src/profile-actions.ts
|
|
2575
|
-
var OpenPondProfileActionsClient = class {
|
|
2576
|
-
#apiKey;
|
|
2577
|
-
#apiBaseUrl;
|
|
2578
|
-
constructor(input) {
|
|
2579
|
-
this.#apiKey = input.apiKey;
|
|
2580
|
-
this.#apiBaseUrl = input.apiBaseUrl.replace(/\/+$/, "");
|
|
2581
|
-
}
|
|
2582
|
-
async catalog(input) {
|
|
2583
|
-
const teamId = requiredValue(input.teamId, "teamId");
|
|
2584
|
-
const search = new URLSearchParams({ teamId });
|
|
2585
|
-
if (input.profileId?.trim()) search.set("profileId", input.profileId.trim());
|
|
2586
|
-
if (input.profileName?.trim()) {
|
|
2587
|
-
search.set("profileName", input.profileName.trim());
|
|
2588
|
-
}
|
|
2589
|
-
const response = await apiFetch(
|
|
2590
|
-
this.#apiBaseUrl,
|
|
2591
|
-
this.#apiKey,
|
|
2592
|
-
`/v1/profile/actions?${search.toString()}`
|
|
2593
|
-
);
|
|
2594
|
-
return (await readApiJson(
|
|
2595
|
-
response,
|
|
2596
|
-
"Get Profile Action catalog"
|
|
2597
|
-
)).catalog;
|
|
2598
|
-
}
|
|
2599
|
-
async run(input) {
|
|
2600
|
-
const teamId = requiredValue(input.teamId, "teamId");
|
|
2601
|
-
const actionKey = requiredValue(input.actionKey, "actionKey");
|
|
2602
|
-
const idempotencyKey = requiredValue(input.idempotencyKey, "idempotencyKey");
|
|
2603
|
-
const catalogVersion = requiredValue(input.catalogVersion, "catalogVersion");
|
|
2604
|
-
const response = await apiFetch(
|
|
2605
|
-
this.#apiBaseUrl,
|
|
2606
|
-
this.#apiKey,
|
|
2607
|
-
`/v1/profile/actions/run?${new URLSearchParams({ teamId }).toString()}`,
|
|
2608
|
-
{
|
|
2609
|
-
method: "POST",
|
|
2610
|
-
headers: { "Content-Type": "application/json" },
|
|
2611
|
-
body: JSON.stringify({
|
|
2612
|
-
...input.profileId?.trim() ? { profileId: input.profileId.trim() } : {},
|
|
2613
|
-
...input.profileName?.trim() ? { profileName: input.profileName.trim() } : {},
|
|
2614
|
-
actionKey,
|
|
2615
|
-
value: input.value ?? {},
|
|
2616
|
-
conversationId: input.conversationId ?? null,
|
|
2617
|
-
createConversation: input.createConversation,
|
|
2618
|
-
conversationTitle: input.conversationTitle ?? null,
|
|
2619
|
-
idempotencyKey,
|
|
2620
|
-
catalogVersion,
|
|
2621
|
-
externalCapabilityLeases: input.externalCapabilityLeases
|
|
2622
|
-
})
|
|
2623
|
-
}
|
|
2624
|
-
);
|
|
2625
|
-
return readApiJson(
|
|
2626
|
-
response,
|
|
2627
|
-
"Run Profile Action"
|
|
2628
|
-
);
|
|
2629
|
-
}
|
|
2630
|
-
};
|
|
2631
|
-
function requiredValue(value, name) {
|
|
2632
|
-
const normalized = value.trim();
|
|
2633
|
-
if (!normalized) throw new Error(`${name} is required`);
|
|
2634
|
-
return normalized;
|
|
2635
|
-
}
|
|
2636
|
-
|
|
2637
|
-
// src/workflows.ts
|
|
2638
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
2639
|
-
var OpenPondWorkflowsClient = class {
|
|
2640
|
-
#apiKey;
|
|
2641
|
-
#apiBaseUrl;
|
|
2642
|
-
constructor(input) {
|
|
2643
|
-
this.#apiKey = input.apiKey;
|
|
2644
|
-
this.#apiBaseUrl = input.apiBaseUrl.replace(/\/+$/, "");
|
|
2645
|
-
}
|
|
2646
|
-
async list(options = {}) {
|
|
2647
|
-
return this.#request("", "List Workflows", {
|
|
2648
|
-
signal: options.signal
|
|
2649
|
-
});
|
|
2650
|
-
}
|
|
2651
|
-
async create(input, options = {}) {
|
|
2652
|
-
return this.#request("", "Create Workflow", {
|
|
2653
|
-
method: "POST",
|
|
2654
|
-
body: JSON.stringify({
|
|
2655
|
-
...input,
|
|
2656
|
-
clientRequestId: input.clientRequestId?.trim() || randomUUID2()
|
|
2657
|
-
}),
|
|
2658
|
-
signal: options.signal
|
|
2659
|
-
});
|
|
2660
|
-
}
|
|
2661
|
-
async update(scheduleId, input, options = {}) {
|
|
2662
|
-
return this.#request(
|
|
2663
|
-
`/schedules/${encodeURIComponent(requiredId(scheduleId, "scheduleId"))}`,
|
|
2664
|
-
"Update Workflow",
|
|
2665
|
-
{
|
|
2666
|
-
method: "PATCH",
|
|
2667
|
-
body: JSON.stringify(input),
|
|
2668
|
-
signal: options.signal
|
|
2669
|
-
}
|
|
2670
|
-
);
|
|
2671
|
-
}
|
|
2672
|
-
async delete(scheduleId, options = {}) {
|
|
2673
|
-
return this.#request(
|
|
2674
|
-
`/schedules/${encodeURIComponent(requiredId(scheduleId, "scheduleId"))}`,
|
|
2675
|
-
"Delete Workflow",
|
|
2676
|
-
{ method: "DELETE", signal: options.signal }
|
|
2677
|
-
);
|
|
2678
|
-
}
|
|
2679
|
-
async runNow(scheduleId, input = {}, options = {}) {
|
|
2680
|
-
return this.#request(
|
|
2681
|
-
`/schedules/${encodeURIComponent(requiredId(scheduleId, "scheduleId"))}/run`,
|
|
2682
|
-
"Run Workflow",
|
|
2683
|
-
{
|
|
2684
|
-
method: "POST",
|
|
2685
|
-
body: JSON.stringify({
|
|
2686
|
-
clientRequestId: input.clientRequestId?.trim() || randomUUID2()
|
|
2687
|
-
}),
|
|
2688
|
-
signal: options.signal
|
|
2689
|
-
}
|
|
2690
|
-
);
|
|
2691
|
-
}
|
|
2692
|
-
async #request(suffix, label, options = {}) {
|
|
2693
|
-
const response = await apiFetch(
|
|
2694
|
-
this.#apiBaseUrl,
|
|
2695
|
-
this.#apiKey,
|
|
2696
|
-
`/v1/saved-work${suffix}`,
|
|
2697
|
-
options
|
|
2698
|
-
);
|
|
2699
|
-
return readApiJson(response, label);
|
|
2700
|
-
}
|
|
2701
|
-
};
|
|
2702
|
-
function requiredId(value, label) {
|
|
2703
|
-
const normalized = value.trim();
|
|
2704
|
-
if (!normalized) throw new Error(`${label} is required`);
|
|
2705
|
-
return normalized;
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
// src/learning.ts
|
|
2709
|
-
var learning_exports = {};
|
|
2710
|
-
__export(learning_exports, {
|
|
2711
|
-
LearningBatchPublicationResultSchema: () => LearningBatchPublicationResultSchema,
|
|
2712
|
-
LearningBatchPublicationSchema: () => LearningBatchPublicationSchema,
|
|
2713
|
-
LearningSourceConfigurationRequestSchema: () => LearningSourceConfigurationRequestSchema,
|
|
2714
|
-
LearningSourceConfigurationSchema: () => LearningSourceConfigurationSchema,
|
|
2715
|
-
LearningSourceCredentialCreatedSchema: () => LearningSourceCredentialCreatedSchema,
|
|
2716
|
-
LearningSourceCredentialPageSchema: () => LearningSourceCredentialPageSchema,
|
|
2717
|
-
LearningSourceCredentialRequestSchema: () => LearningSourceCredentialRequestSchema,
|
|
2718
|
-
LearningSourceCredentialSchema: () => LearningSourceCredentialSchema,
|
|
2719
|
-
LearningSourceCredentialSecretSchema: () => LearningSourceCredentialSecretSchema,
|
|
2720
|
-
OpenPondLearningClient: () => OpenPondLearningClient,
|
|
2721
|
-
OpenPondLearningError: () => OpenPondLearningError,
|
|
2722
|
-
assertLearningCredentialExpiry: () => assertLearningCredentialExpiry,
|
|
2723
|
-
createSourceCredentialRequest: () => createSourceCredentialRequest
|
|
2724
|
-
});
|
|
2725
|
-
import { z as z12 } from "zod";
|
|
2726
|
-
import {
|
|
2727
|
-
LearningCommandRequestSchema,
|
|
2728
|
-
LearningOperationResultSchema,
|
|
2729
|
-
LearningReadRequestSchema,
|
|
2730
|
-
TaskEvidenceInspectionResultSchema,
|
|
2731
|
-
sameLearningRef,
|
|
2732
|
-
assertLearningRequestJson,
|
|
2733
|
-
learningResourceSchemas
|
|
2734
|
-
} from "@openpond/evals/learning";
|
|
2735
|
-
import { assertBoundedTaskJson } from "@openpond/evals/task-schema";
|
|
2736
|
-
|
|
2737
|
-
// src/learning-credentials.ts
|
|
2738
|
-
import { z as z11 } from "zod";
|
|
2739
|
-
|
|
2740
|
-
// ../harness/dist/common.js
|
|
2741
|
-
import { z } from "zod";
|
|
2742
|
-
|
|
2743
|
-
// ../harness/dist/sha256.js
|
|
2744
|
-
var INITIAL_STATE = new Uint32Array([
|
|
2745
|
-
1779033703,
|
|
2746
|
-
3144134277,
|
|
2747
|
-
1013904242,
|
|
2748
|
-
2773480762,
|
|
2749
|
-
1359893119,
|
|
2750
|
-
2600822924,
|
|
2751
|
-
528734635,
|
|
2752
|
-
1541459225
|
|
2753
|
-
]);
|
|
2754
|
-
var ROUND_CONSTANTS = new Uint32Array([
|
|
2755
|
-
1116352408,
|
|
2756
|
-
1899447441,
|
|
2757
|
-
3049323471,
|
|
2758
|
-
3921009573,
|
|
2759
|
-
961987163,
|
|
2760
|
-
1508970993,
|
|
2761
|
-
2453635748,
|
|
2762
|
-
2870763221,
|
|
2763
|
-
3624381080,
|
|
2764
|
-
310598401,
|
|
2765
|
-
607225278,
|
|
2766
|
-
1426881987,
|
|
2767
|
-
1925078388,
|
|
2768
|
-
2162078206,
|
|
2769
|
-
2614888103,
|
|
2770
|
-
3248222580,
|
|
2771
|
-
3835390401,
|
|
2772
|
-
4022224774,
|
|
2773
|
-
264347078,
|
|
2774
|
-
604807628,
|
|
2775
|
-
770255983,
|
|
2776
|
-
1249150122,
|
|
2777
|
-
1555081692,
|
|
2778
|
-
1996064986,
|
|
2779
|
-
2554220882,
|
|
2780
|
-
2821834349,
|
|
2781
|
-
2952996808,
|
|
2782
|
-
3210313671,
|
|
2783
|
-
3336571891,
|
|
2784
|
-
3584528711,
|
|
2785
|
-
113926993,
|
|
2786
|
-
338241895,
|
|
2787
|
-
666307205,
|
|
2788
|
-
773529912,
|
|
2789
|
-
1294757372,
|
|
2790
|
-
1396182291,
|
|
2791
|
-
1695183700,
|
|
2792
|
-
1986661051,
|
|
2793
|
-
2177026350,
|
|
2794
|
-
2456956037,
|
|
2795
|
-
2730485921,
|
|
2796
|
-
2820302411,
|
|
2797
|
-
3259730800,
|
|
2798
|
-
3345764771,
|
|
2799
|
-
3516065817,
|
|
2800
|
-
3600352804,
|
|
2801
|
-
4094571909,
|
|
2802
|
-
275423344,
|
|
2803
|
-
430227734,
|
|
2804
|
-
506948616,
|
|
2805
|
-
659060556,
|
|
2806
|
-
883997877,
|
|
2807
|
-
958139571,
|
|
2808
|
-
1322822218,
|
|
2809
|
-
1537002063,
|
|
2810
|
-
1747873779,
|
|
2811
|
-
1955562222,
|
|
2812
|
-
2024104815,
|
|
2813
|
-
2227730452,
|
|
2814
|
-
2361852424,
|
|
2815
|
-
2428436474,
|
|
2816
|
-
2756734187,
|
|
2817
|
-
3204031479,
|
|
2818
|
-
3329325298
|
|
2819
|
-
]);
|
|
2820
|
-
function sha256Hex(value) {
|
|
2821
|
-
const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
|
|
2822
|
-
const paddedLength = Math.ceil((bytes.byteLength + 9) / 64) * 64;
|
|
2823
|
-
const padded = new Uint8Array(paddedLength);
|
|
2824
|
-
padded.set(bytes);
|
|
2825
|
-
padded[bytes.byteLength] = 128;
|
|
2826
|
-
const bitLength = bytes.byteLength * 8;
|
|
2827
|
-
const view = new DataView(padded.buffer);
|
|
2828
|
-
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296), false);
|
|
2829
|
-
view.setUint32(paddedLength - 4, bitLength >>> 0, false);
|
|
2830
|
-
const state = new Uint32Array(INITIAL_STATE);
|
|
2831
|
-
const words = new Uint32Array(64);
|
|
2832
|
-
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
2833
|
-
for (let index = 0; index < 16; index += 1) {
|
|
2834
|
-
words[index] = view.getUint32(offset + index * 4, false);
|
|
2835
|
-
}
|
|
2836
|
-
for (let index = 16; index < 64; index += 1) {
|
|
2837
|
-
const previous = words[index - 15];
|
|
2838
|
-
const recent = words[index - 2];
|
|
2839
|
-
const sigma0 = rotateRight(previous, 7) ^ rotateRight(previous, 18) ^ previous >>> 3;
|
|
2840
|
-
const sigma1 = rotateRight(recent, 17) ^ rotateRight(recent, 19) ^ recent >>> 10;
|
|
2841
|
-
words[index] = words[index - 16] + sigma0 + words[index - 7] + sigma1 >>> 0;
|
|
2842
|
-
}
|
|
2843
|
-
let a = state[0];
|
|
2844
|
-
let b = state[1];
|
|
2845
|
-
let c = state[2];
|
|
2846
|
-
let d = state[3];
|
|
2847
|
-
let e = state[4];
|
|
2848
|
-
let f = state[5];
|
|
2849
|
-
let g = state[6];
|
|
2850
|
-
let h = state[7];
|
|
2851
|
-
for (let index = 0; index < 64; index += 1) {
|
|
2852
|
-
const choice = e & f ^ ~e & g;
|
|
2853
|
-
const majority = a & b ^ a & c ^ b & c;
|
|
2854
|
-
const sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
2855
|
-
const sum1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
|
|
2856
|
-
const first = h + sum1 + choice + ROUND_CONSTANTS[index] + words[index] >>> 0;
|
|
2857
|
-
const second = sum0 + majority >>> 0;
|
|
2858
|
-
h = g;
|
|
2859
|
-
g = f;
|
|
2860
|
-
f = e;
|
|
2861
|
-
e = d + first >>> 0;
|
|
2862
|
-
d = c;
|
|
2863
|
-
c = b;
|
|
2864
|
-
b = a;
|
|
2865
|
-
a = first + second >>> 0;
|
|
2866
|
-
}
|
|
2867
|
-
state[0] = state[0] + a >>> 0;
|
|
2868
|
-
state[1] = state[1] + b >>> 0;
|
|
2869
|
-
state[2] = state[2] + c >>> 0;
|
|
2870
|
-
state[3] = state[3] + d >>> 0;
|
|
2871
|
-
state[4] = state[4] + e >>> 0;
|
|
2872
|
-
state[5] = state[5] + f >>> 0;
|
|
2873
|
-
state[6] = state[6] + g >>> 0;
|
|
2874
|
-
state[7] = state[7] + h >>> 0;
|
|
2875
|
-
}
|
|
2876
|
-
return Array.from(state, (word) => word.toString(16).padStart(8, "0")).join("");
|
|
2877
|
-
}
|
|
2878
|
-
function rotateRight(value, bits) {
|
|
2879
|
-
return value >>> bits | value << 32 - bits;
|
|
2880
|
-
}
|
|
2881
|
-
|
|
2882
|
-
// ../harness/dist/common.js
|
|
2883
|
-
var MAX_PORTABLE_PATH_BYTES = 2e3;
|
|
2884
|
-
var MAX_PORTABLE_ASSET_BYTES = 25e7;
|
|
2885
|
-
var ReleaseIdSchema = z.string().trim().min(1).max(240);
|
|
2886
|
-
var ReleaseHashSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
2887
|
-
var ReleaseTimestampSchema = z.string().datetime({ offset: true });
|
|
2888
|
-
var MetadataSchema = z.record(z.string(), z.unknown()).default({});
|
|
2889
|
-
var ImmutableReleaseRefSchema = z.object({
|
|
2890
|
-
id: ReleaseIdSchema,
|
|
2891
|
-
contentHash: ReleaseHashSchema
|
|
2892
|
-
}).strict();
|
|
2893
|
-
var ImmutableAssetRefSchema = z.object({
|
|
2894
|
-
id: ReleaseIdSchema,
|
|
2895
|
-
path: z.string().trim().min(1).max(MAX_PORTABLE_PATH_BYTES).refine(safeRelativePath),
|
|
2896
|
-
contentHash: ReleaseHashSchema,
|
|
2897
|
-
sizeBytes: z.number().int().nonnegative().max(MAX_PORTABLE_ASSET_BYTES),
|
|
2898
|
-
mediaType: z.string().trim().min(1).max(200),
|
|
2899
|
-
visibility: z.enum(["policy", "verifier", "host_private"])
|
|
2900
|
-
}).strict();
|
|
2901
|
-
var ImmutableArtifactRefSchema = z.object({
|
|
2902
|
-
id: ReleaseIdSchema,
|
|
2903
|
-
contentHash: ReleaseHashSchema,
|
|
2904
|
-
mediaType: z.string().trim().min(1).max(200).nullable().default(null),
|
|
2905
|
-
sizeBytes: z.number().int().nonnegative().max(MAX_PORTABLE_ASSET_BYTES).nullable().default(null)
|
|
2906
|
-
}).strict();
|
|
2907
|
-
var FailureClassSchema = z.enum([
|
|
2908
|
-
"policy_failure",
|
|
2909
|
-
"grader_failure",
|
|
2910
|
-
"environment_failure",
|
|
2911
|
-
"infrastructure_failure",
|
|
2912
|
-
"timeout",
|
|
2913
|
-
"cancelled"
|
|
2914
|
-
]);
|
|
2915
|
-
function canonicalJson(value) {
|
|
2916
|
-
return `${JSON.stringify(sortValue(value), null, 2)}
|
|
2917
|
-
`;
|
|
2918
|
-
}
|
|
2919
|
-
function sha256(value) {
|
|
2920
|
-
return sha256Hex(value);
|
|
2921
|
-
}
|
|
2922
|
-
function contentHash(value) {
|
|
2923
|
-
return sha256(canonicalJson(value));
|
|
2924
|
-
}
|
|
2925
|
-
function safeRelativePath(value) {
|
|
2926
|
-
const normalized = value.replaceAll("\\", "/");
|
|
2927
|
-
if (!normalized || normalized.startsWith("/") || normalized.includes("\0"))
|
|
2928
|
-
return false;
|
|
2929
|
-
return !normalized.split("/").some((part) => !part || part === "." || part === "..");
|
|
2930
|
-
}
|
|
2931
|
-
function sortValue(value) {
|
|
2932
|
-
if (Array.isArray(value))
|
|
2933
|
-
return value.map(sortValue);
|
|
2934
|
-
if (!value || typeof value !== "object")
|
|
2935
|
-
return value;
|
|
2936
|
-
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortValue(child)]));
|
|
2937
|
-
}
|
|
2938
|
-
|
|
2939
|
-
// ../harness/dist/evaluation-review.js
|
|
2940
|
-
import { z as z2 } from "zod";
|
|
2941
|
-
var BoundedTextSchema = z2.string().trim().min(1).max(1e5);
|
|
2942
|
-
var HarnessEvaluationReviewClassificationSchema = z2.enum([
|
|
2943
|
-
"no_action",
|
|
2944
|
-
"harness_maintenance",
|
|
2945
|
-
"runtime",
|
|
2946
|
-
"product",
|
|
2947
|
-
"taskset",
|
|
2948
|
-
"model_improvement"
|
|
2949
|
-
]);
|
|
2950
|
-
var HarnessEvaluationReviewAuthoritySchema = z2.enum([
|
|
2951
|
-
"none",
|
|
2952
|
-
"runtime_service",
|
|
2953
|
-
"product_team",
|
|
2954
|
-
"human_review",
|
|
2955
|
-
"evaluation_system",
|
|
2956
|
-
"training_system"
|
|
2957
|
-
]);
|
|
2958
|
-
var HarnessReviewEvidenceKindSchema = z2.enum([
|
|
2959
|
-
"observation",
|
|
2960
|
-
"trigger",
|
|
2961
|
-
"route_decision",
|
|
2962
|
-
"refiner_outcome",
|
|
2963
|
-
"proposal",
|
|
2964
|
-
"validation",
|
|
2965
|
-
"apply_receipt",
|
|
2966
|
-
"harness_advance",
|
|
2967
|
-
"rollback",
|
|
2968
|
-
"work_outcome",
|
|
2969
|
-
"taskset",
|
|
2970
|
-
"evaluation",
|
|
2971
|
-
"training_qualification",
|
|
2972
|
-
"model_candidate"
|
|
2973
|
-
]);
|
|
2974
|
-
var HarnessReviewOwnerScopeSchema = z2.object({
|
|
2975
|
-
kind: z2.enum(["personal", "team"]),
|
|
2976
|
-
id: ReleaseIdSchema
|
|
2977
|
-
}).strict();
|
|
2978
|
-
var HarnessReviewSourcePolicyRefSchema = z2.object({
|
|
2979
|
-
policy: ImmutableReleaseRefSchema,
|
|
2980
|
-
state: z2.enum(["authorized", "revoked", "deleted", "expired"]),
|
|
2981
|
-
checkedAt: ReleaseTimestampSchema
|
|
2982
|
-
}).strict();
|
|
2983
|
-
var HarnessReviewEvidenceRefSchema = z2.object({
|
|
2984
|
-
evidence: ImmutableReleaseRefSchema,
|
|
2985
|
-
kind: HarnessReviewEvidenceKindSchema,
|
|
2986
|
-
sourceRef: ReleaseIdSchema,
|
|
2987
|
-
sourcePolicy: HarnessReviewSourcePolicyRefSchema,
|
|
2988
|
-
occurrenceKey: ReleaseHashSchema,
|
|
2989
|
-
occurredAt: ReleaseTimestampSchema
|
|
2990
|
-
}).strict();
|
|
2991
|
-
var HarnessReviewExcludedEvidenceSchema = z2.object({
|
|
2992
|
-
evidence: ImmutableReleaseRefSchema,
|
|
2993
|
-
sourcePolicy: HarnessReviewSourcePolicyRefSchema.nullable(),
|
|
2994
|
-
reason: z2.enum([
|
|
2995
|
-
"outside_scope",
|
|
2996
|
-
"before_watermark",
|
|
2997
|
-
"duplicate",
|
|
2998
|
-
"resolved",
|
|
2999
|
-
"revoked",
|
|
3000
|
-
"deleted",
|
|
3001
|
-
"expired",
|
|
3002
|
-
"sensitive",
|
|
3003
|
-
"unverified",
|
|
3004
|
-
"budget"
|
|
3005
|
-
])
|
|
3006
|
-
}).strict();
|
|
3007
|
-
var HarnessReviewWatermarkSchema = z2.object({
|
|
3008
|
-
cursor: ReleaseHashSchema,
|
|
3009
|
-
throughCreatedAt: ReleaseTimestampSchema
|
|
3010
|
-
}).strict();
|
|
3011
|
-
var HarnessReviewClaimSchema = z2.object({
|
|
3012
|
-
fingerprint: ReleaseHashSchema,
|
|
3013
|
-
recurrenceFamily: z2.string().trim().min(1).max(1e3),
|
|
3014
|
-
statement: BoundedTextSchema,
|
|
3015
|
-
candidateDisposition: z2.enum(["observe", "confirm"]).optional(),
|
|
3016
|
-
independentOccurrences: z2.number().int().positive().max(1e6),
|
|
3017
|
-
unresolvedOccurrences: z2.number().int().positive().max(1e6)
|
|
3018
|
-
}).strict().refine((claim) => claim.unresolvedOccurrences <= claim.independentOccurrences, "unresolved occurrences cannot exceed independent occurrences");
|
|
3019
|
-
var HarnessReviewTriageLayerSchema = z2.enum([
|
|
3020
|
-
"harness",
|
|
3021
|
-
"runtime",
|
|
3022
|
-
"product",
|
|
3023
|
-
"retrieval",
|
|
3024
|
-
"tools",
|
|
3025
|
-
"evaluation",
|
|
3026
|
-
"model"
|
|
3027
|
-
]);
|
|
3028
|
-
var HarnessReviewTriageDecisionSchema = z2.object({
|
|
3029
|
-
layer: HarnessReviewTriageLayerSchema,
|
|
3030
|
-
status: z2.enum(["not_applicable", "unresolved", "resolved", "blocked"]),
|
|
3031
|
-
reason: BoundedTextSchema,
|
|
3032
|
-
evidenceRefs: z2.array(ImmutableReleaseRefSchema).max(1e3)
|
|
3033
|
-
}).strict();
|
|
3034
|
-
var HarnessEvaluationReviewReceiptContentSchema = z2.object({
|
|
3035
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewReceipt.v1"),
|
|
3036
|
-
id: ReleaseIdSchema,
|
|
3037
|
-
ownerScope: HarnessReviewOwnerScopeSchema,
|
|
3038
|
-
workspaceRef: ReleaseIdSchema,
|
|
3039
|
-
harnessRelease: ImmutableReleaseRefSchema,
|
|
3040
|
-
previousWatermark: HarnessReviewWatermarkSchema.nullable(),
|
|
3041
|
-
nextWatermark: HarnessReviewWatermarkSchema,
|
|
3042
|
-
selectedEvidence: z2.array(HarnessReviewEvidenceRefSchema).max(1e4),
|
|
3043
|
-
excludedEvidence: z2.array(HarnessReviewExcludedEvidenceSchema).max(1e4),
|
|
3044
|
-
claim: HarnessReviewClaimSchema.nullable(),
|
|
3045
|
-
classification: HarnessEvaluationReviewClassificationSchema,
|
|
3046
|
-
triage: z2.array(HarnessReviewTriageDecisionSchema).max(16),
|
|
3047
|
-
reason: BoundedTextSchema,
|
|
3048
|
-
nextAuthority: HarnessEvaluationReviewAuthoritySchema,
|
|
3049
|
-
maxEstimatedCostUsd: z2.number().finite().nonnegative(),
|
|
3050
|
-
tasksetProposal: ImmutableReleaseRefSchema.nullable(),
|
|
3051
|
-
evaluation: ImmutableReleaseRefSchema.nullable(),
|
|
3052
|
-
trainingQualification: ImmutableReleaseRefSchema.nullable(),
|
|
3053
|
-
policyVersion: ReleaseIdSchema,
|
|
3054
|
-
createdAt: ReleaseTimestampSchema,
|
|
3055
|
-
metadata: MetadataSchema
|
|
3056
|
-
}).strict().superRefine((receipt, context) => {
|
|
3057
|
-
const selectedKeys = receipt.selectedEvidence.map((item) => `${item.evidence.id}:${item.evidence.contentHash}`);
|
|
3058
|
-
if (new Set(selectedKeys).size !== selectedKeys.length) {
|
|
3059
|
-
context.addIssue({
|
|
3060
|
-
code: "custom",
|
|
3061
|
-
message: "selected review evidence must be unique",
|
|
3062
|
-
path: ["selectedEvidence"]
|
|
3063
|
-
});
|
|
3064
|
-
}
|
|
3065
|
-
if (receipt.selectedEvidence.some((item) => item.sourcePolicy.state !== "authorized")) {
|
|
3066
|
-
context.addIssue({
|
|
3067
|
-
code: "custom",
|
|
3068
|
-
message: "selected review evidence must be authorized at review time",
|
|
3069
|
-
path: ["selectedEvidence"]
|
|
3070
|
-
});
|
|
3071
|
-
}
|
|
3072
|
-
if (receipt.classification === "no_action") {
|
|
3073
|
-
if (receipt.nextAuthority !== "none") {
|
|
3074
|
-
context.addIssue({
|
|
3075
|
-
code: "custom",
|
|
3076
|
-
message: "no-action review receipts require no next authority",
|
|
3077
|
-
path: ["nextAuthority"]
|
|
3078
|
-
});
|
|
3079
|
-
}
|
|
3080
|
-
if (receipt.tasksetProposal || receipt.evaluation || receipt.trainingQualification) {
|
|
3081
|
-
context.addIssue({
|
|
3082
|
-
code: "custom",
|
|
3083
|
-
message: "no-action review receipts cannot carry downstream refs"
|
|
3084
|
-
});
|
|
3085
|
-
}
|
|
3086
|
-
} else if (!receipt.claim || receipt.selectedEvidence.length === 0) {
|
|
3087
|
-
context.addIssue({
|
|
3088
|
-
code: "custom",
|
|
3089
|
-
message: "actionable review receipts require a claim and selected evidence"
|
|
3090
|
-
});
|
|
3091
|
-
}
|
|
3092
|
-
if (receipt.classification === "runtime" && receipt.nextAuthority !== "runtime_service") {
|
|
3093
|
-
context.addIssue({
|
|
3094
|
-
code: "custom",
|
|
3095
|
-
message: "runtime classifications route to runtime-service authority",
|
|
3096
|
-
path: ["nextAuthority"]
|
|
3097
|
-
});
|
|
3098
|
-
}
|
|
3099
|
-
if (receipt.classification === "product" && receipt.nextAuthority !== "product_team") {
|
|
3100
|
-
context.addIssue({
|
|
3101
|
-
code: "custom",
|
|
3102
|
-
message: "product classifications route to product-team authority",
|
|
3103
|
-
path: ["nextAuthority"]
|
|
3104
|
-
});
|
|
3105
|
-
}
|
|
3106
|
-
if (receipt.classification === "taskset" && receipt.nextAuthority !== "human_review") {
|
|
3107
|
-
context.addIssue({
|
|
3108
|
-
code: "custom",
|
|
3109
|
-
message: "Taskset classifications require human review"
|
|
3110
|
-
});
|
|
3111
|
-
}
|
|
3112
|
-
if (receipt.classification === "model_improvement" && (!receipt.evaluation || !receipt.trainingQualification || !["human_review", "training_system"].includes(receipt.nextAuthority))) {
|
|
3113
|
-
context.addIssue({
|
|
3114
|
-
code: "custom",
|
|
3115
|
-
message: "model-improvement classifications require Evaluation and qualification refs plus explicit authority"
|
|
3116
|
-
});
|
|
3117
|
-
}
|
|
3118
|
-
});
|
|
3119
|
-
var HarnessEvaluationReviewReceiptSchema = HarnessEvaluationReviewReceiptContentSchema.extend({
|
|
3120
|
-
contentHash: ReleaseHashSchema
|
|
3121
|
-
}).strict();
|
|
3122
|
-
var HarnessEvaluationReviewModelEvidenceSchema = z2.object({
|
|
3123
|
-
id: ReleaseIdSchema,
|
|
3124
|
-
evidence: ImmutableReleaseRefSchema,
|
|
3125
|
-
kind: HarnessReviewEvidenceKindSchema,
|
|
3126
|
-
sourceRef: ReleaseIdSchema,
|
|
3127
|
-
occurredAt: ReleaseTimestampSchema,
|
|
3128
|
-
payload: z2.record(z2.string(), z2.unknown())
|
|
3129
|
-
}).strict();
|
|
3130
|
-
var HarnessEvaluationReviewModelNoActionSchema = z2.object({
|
|
3131
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewModelDecision.v2"),
|
|
3132
|
-
decision: z2.literal("no_action"),
|
|
3133
|
-
reason: BoundedTextSchema,
|
|
3134
|
-
ignoredEvidence: z2.array(z2.object({
|
|
3135
|
-
id: ReleaseIdSchema,
|
|
3136
|
-
reason: z2.string().trim().min(1).max(2e3)
|
|
3137
|
-
}).strict()).max(1e3)
|
|
3138
|
-
}).strict();
|
|
3139
|
-
var HarnessEvaluationReviewModelActionSchema = z2.object({
|
|
3140
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewModelDecision.v2"),
|
|
3141
|
-
decision: z2.literal("review"),
|
|
3142
|
-
classification: z2.enum([
|
|
3143
|
-
"harness_maintenance",
|
|
3144
|
-
"runtime",
|
|
3145
|
-
"product",
|
|
3146
|
-
"taskset"
|
|
3147
|
-
]),
|
|
3148
|
-
selectedEvidenceIds: z2.array(ReleaseIdSchema).min(1).max(1e3),
|
|
3149
|
-
ignoredEvidence: z2.array(z2.object({
|
|
3150
|
-
id: ReleaseIdSchema,
|
|
3151
|
-
reason: z2.string().trim().min(1).max(2e3)
|
|
3152
|
-
}).strict()).max(1e3),
|
|
3153
|
-
recurrenceFamily: z2.string().trim().min(1).max(1e3),
|
|
3154
|
-
statement: BoundedTextSchema,
|
|
3155
|
-
triageLayer: HarnessReviewTriageLayerSchema,
|
|
3156
|
-
expectedOutcome: BoundedTextSchema,
|
|
3157
|
-
counterevidence: z2.string().trim().max(1e4),
|
|
3158
|
-
confidence: z2.number().min(0).max(1),
|
|
3159
|
-
candidateDisposition: z2.enum(["observe", "confirm"]).nullable(),
|
|
3160
|
-
reason: BoundedTextSchema
|
|
3161
|
-
}).strict().superRefine((decision, context) => {
|
|
3162
|
-
const requiresDisposition = decision.classification === "harness_maintenance";
|
|
3163
|
-
if (requiresDisposition !== (decision.candidateDisposition !== null)) {
|
|
3164
|
-
context.addIssue({
|
|
3165
|
-
code: "custom",
|
|
3166
|
-
message: "Harness maintenance requires a candidate disposition; external routes require null",
|
|
3167
|
-
path: ["candidateDisposition"]
|
|
3168
|
-
});
|
|
3169
|
-
}
|
|
3170
|
-
});
|
|
3171
|
-
var HarnessEvaluationReviewModelResolutionSchema = z2.object({
|
|
3172
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewModelDecision.v2"),
|
|
3173
|
-
decision: z2.literal("resolve_candidate"),
|
|
3174
|
-
candidateId: ReleaseIdSchema,
|
|
3175
|
-
candidateFingerprint: ReleaseHashSchema,
|
|
3176
|
-
selectedEvidenceIds: z2.array(ReleaseIdSchema).min(1).max(1e3),
|
|
3177
|
-
ignoredEvidence: z2.array(z2.object({
|
|
3178
|
-
id: ReleaseIdSchema,
|
|
3179
|
-
reason: z2.string().trim().min(1).max(2e3)
|
|
3180
|
-
}).strict()).max(1e3),
|
|
3181
|
-
confidence: z2.number().min(0).max(1),
|
|
3182
|
-
reason: BoundedTextSchema
|
|
3183
|
-
}).strict();
|
|
3184
|
-
var HarnessEvaluationReviewModelDecisionSchema = z2.discriminatedUnion("decision", [
|
|
3185
|
-
HarnessEvaluationReviewModelNoActionSchema,
|
|
3186
|
-
HarnessEvaluationReviewModelActionSchema,
|
|
3187
|
-
HarnessEvaluationReviewModelResolutionSchema
|
|
3188
|
-
]);
|
|
3189
|
-
var HarnessEvaluationReviewNavigationDecisionSchema = z2.object({
|
|
3190
|
-
schemaVersion: z2.literal("openpond.harnessEvaluationReviewNavigationDecision.v1"),
|
|
3191
|
-
selectedEvidenceIds: z2.array(ReleaseIdSchema).min(1).max(50),
|
|
3192
|
-
reason: BoundedTextSchema
|
|
3193
|
-
}).strict();
|
|
3194
|
-
|
|
3195
|
-
// ../harness/dist/harness.js
|
|
3196
|
-
import { z as z4 } from "zod";
|
|
3197
|
-
|
|
3198
|
-
// ../harness/dist/tools.js
|
|
3199
|
-
import { z as z3 } from "zod";
|
|
3200
|
-
var ToolDeclarationSchema = z3.object({
|
|
3201
|
-
name: z3.string().trim().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/),
|
|
3202
|
-
description: z3.string().trim().min(1).max(2e3),
|
|
3203
|
-
inputSchema: z3.record(z3.string(), z3.unknown()),
|
|
3204
|
-
inputSchemaHash: ReleaseHashSchema,
|
|
3205
|
-
sideEffect: z3.enum(["read", "write"]),
|
|
3206
|
-
timeoutMs: z3.number().int().positive().max(36e5)
|
|
3207
|
-
}).strict();
|
|
3208
|
-
var CapabilityRequirementSchema = z3.object({
|
|
3209
|
-
id: ReleaseIdSchema,
|
|
3210
|
-
required: z3.boolean(),
|
|
3211
|
-
scopes: z3.array(z3.string().trim().min(1).max(500)).max(100).default([]),
|
|
3212
|
-
portability: z3.enum(["portable", "host_adapter", "local_only", "hosted_only"])
|
|
3213
|
-
}).strict();
|
|
3214
|
-
|
|
3215
|
-
// ../harness/dist/harness.js
|
|
3216
|
-
var PortabilityReportSchema = z4.object({
|
|
3217
|
-
portable: z4.boolean(),
|
|
3218
|
-
blockers: z4.array(z4.string().trim().min(1).max(2e3)).max(1e3),
|
|
3219
|
-
localOnlyAssetRefs: z4.array(ReleaseIdSchema).max(1e4),
|
|
3220
|
-
hostPrivateAssetRefs: z4.array(ReleaseIdSchema).max(1e4)
|
|
3221
|
-
}).strict();
|
|
3222
|
-
var AgentSnapshotContentSchema = z4.object({
|
|
3223
|
-
schemaVersion: z4.literal("openpond.agentSnapshot.v2"),
|
|
3224
|
-
id: ReleaseIdSchema,
|
|
3225
|
-
sourceRelease: ImmutableReleaseRefSchema.nullable(),
|
|
3226
|
-
instructions: z4.array(ImmutableAssetRefSchema).max(1e4),
|
|
3227
|
-
skills: z4.array(ImmutableAssetRefSchema).max(1e4),
|
|
3228
|
-
agents: z4.array(ImmutableAssetRefSchema).max(1e4),
|
|
3229
|
-
toolDeclarations: z4.array(ToolDeclarationSchema).max(200),
|
|
3230
|
-
capabilityRequirements: z4.array(CapabilityRequirementSchema).max(200),
|
|
3231
|
-
dependencyLock: ImmutableAssetRefSchema,
|
|
3232
|
-
portability: PortabilityReportSchema,
|
|
3233
|
-
metadata: MetadataSchema
|
|
3234
|
-
}).strict();
|
|
3235
|
-
var AgentSnapshotSchema = AgentSnapshotContentSchema.extend({ contentHash: ReleaseHashSchema }).strict();
|
|
3236
|
-
var LifecycleContractSchema = z4.object({
|
|
3237
|
-
create: z4.literal(true),
|
|
3238
|
-
reset: z4.literal(true),
|
|
3239
|
-
step: z4.literal(true),
|
|
3240
|
-
collect: z4.literal(true),
|
|
3241
|
-
destroy: z4.literal(true),
|
|
3242
|
-
resetScope: z4.enum(["task", "attempt"])
|
|
3243
|
-
}).strict();
|
|
3244
|
-
var GraderInterfaceContractSchema = z4.object({
|
|
3245
|
-
visibleEvidence: z4.array(ReleaseIdSchema).max(1e3),
|
|
3246
|
-
privilegedEvidence: z4.array(ReleaseIdSchema).max(1e3),
|
|
3247
|
-
privateVerifierIsolation: z4.boolean()
|
|
3248
|
-
}).strict();
|
|
3249
|
-
var HarnessReleaseContentSchema = z4.object({
|
|
3250
|
-
schemaVersion: z4.literal("openpond.harnessRelease.v2"),
|
|
3251
|
-
id: ReleaseIdSchema,
|
|
3252
|
-
agentSnapshot: ImmutableReleaseRefSchema,
|
|
3253
|
-
program: ImmutableAssetRefSchema,
|
|
3254
|
-
tools: z4.array(ToolDeclarationSchema).max(200),
|
|
3255
|
-
lifecycle: LifecycleContractSchema,
|
|
3256
|
-
graderInterface: GraderInterfaceContractSchema,
|
|
3257
|
-
files: z4.array(ImmutableAssetRefSchema).max(1e5),
|
|
3258
|
-
metadata: MetadataSchema
|
|
3259
|
-
}).strict();
|
|
3260
|
-
var HarnessReleaseSchema = HarnessReleaseContentSchema.extend({ contentHash: ReleaseHashSchema }).strict();
|
|
3261
|
-
var ModelActionSchema = z4.object({
|
|
3262
|
-
id: ReleaseIdSchema,
|
|
3263
|
-
turn: z4.number().int().nonnegative(),
|
|
3264
|
-
kind: z4.enum(["message", "tool_call", "terminal"]),
|
|
3265
|
-
name: ReleaseIdSchema.nullable(),
|
|
3266
|
-
arguments: z4.record(z4.string(), z4.unknown()),
|
|
3267
|
-
content: z4.string().max(1e6).nullable()
|
|
3268
|
-
}).strict();
|
|
3269
|
-
var ToolObservationSchema = z4.object({
|
|
3270
|
-
actionId: ReleaseIdSchema,
|
|
3271
|
-
turn: z4.number().int().nonnegative(),
|
|
3272
|
-
terminal: z4.boolean(),
|
|
3273
|
-
output: z4.record(z4.string(), z4.unknown()),
|
|
3274
|
-
artifactRefs: z4.array(ImmutableArtifactRefSchema).max(1e5)
|
|
3275
|
-
}).strict();
|
|
3276
|
-
var HarnessLifecycleEventSchema = z4.object({
|
|
3277
|
-
sequence: z4.number().int().nonnegative(),
|
|
3278
|
-
type: z4.enum(["created", "reset", "action", "observation", "terminal", "failure", "collected", "destroyed"]),
|
|
3279
|
-
payloadHash: ReleaseHashSchema,
|
|
3280
|
-
metadata: MetadataSchema
|
|
3281
|
-
}).strict();
|
|
3282
|
-
var HarnessTraceSchema = z4.object({
|
|
3283
|
-
schemaVersion: z4.literal("openpond.harnessTrace.v1"),
|
|
3284
|
-
manifest: ImmutableReleaseRefSchema,
|
|
3285
|
-
taskId: ReleaseIdSchema,
|
|
3286
|
-
seed: z4.string().trim().min(1).max(500),
|
|
3287
|
-
events: z4.array(HarnessLifecycleEventSchema).max(1e6),
|
|
3288
|
-
actions: z4.array(ModelActionSchema).max(1e5),
|
|
3289
|
-
observations: z4.array(ToolObservationSchema).max(1e5),
|
|
3290
|
-
terminal: z4.boolean(),
|
|
3291
|
-
failureClass: FailureClassSchema.nullable(),
|
|
3292
|
-
output: z4.record(z4.string(), z4.unknown()),
|
|
3293
|
-
contentHash: ReleaseHashSchema
|
|
3294
|
-
}).strict();
|
|
3295
|
-
|
|
3296
|
-
// ../harness/dist/harness-improvements.js
|
|
3297
|
-
import { z as z6 } from "zod";
|
|
3298
|
-
|
|
3299
|
-
// ../harness/dist/harness-workspaces.js
|
|
3300
|
-
import { z as z5 } from "zod";
|
|
3301
|
-
var MetadataSchema2 = z5.record(z5.string(), z5.unknown()).default({});
|
|
3302
|
-
var RevisionSchema = z5.number().int().nonnegative();
|
|
3303
|
-
var BoundedTextSchema2 = z5.string().trim().min(1).max(1e5);
|
|
3304
|
-
var HarnessOwnerScopeSchema = z5.object({
|
|
3305
|
-
kind: z5.enum(["personal", "team"]),
|
|
3306
|
-
id: ReleaseIdSchema
|
|
3307
|
-
}).strict();
|
|
3308
|
-
var HarnessCurrentChannelSchema = z5.object({
|
|
3309
|
-
name: ReleaseIdSchema,
|
|
3310
|
-
release: ImmutableReleaseRefSchema.nullable(),
|
|
3311
|
-
revision: RevisionSchema
|
|
3312
|
-
}).strict();
|
|
3313
|
-
var HarnessWorkspaceSchema = z5.object({
|
|
3314
|
-
schemaVersion: z5.literal("openpond.harnessWorkspace.v1"),
|
|
3315
|
-
id: ReleaseIdSchema,
|
|
3316
|
-
ownerScope: HarnessOwnerScopeSchema,
|
|
3317
|
-
name: z5.string().trim().min(1).max(240),
|
|
3318
|
-
location: z5.enum(["local", "hosted"]),
|
|
3319
|
-
sourceRevision: z5.string().trim().min(1).max(500),
|
|
3320
|
-
revision: RevisionSchema,
|
|
3321
|
-
dirty: z5.boolean(),
|
|
3322
|
-
currentChannel: HarnessCurrentChannelSchema,
|
|
3323
|
-
createdAt: ReleaseTimestampSchema,
|
|
3324
|
-
updatedAt: ReleaseTimestampSchema,
|
|
3325
|
-
metadata: MetadataSchema2
|
|
3326
|
-
}).strict();
|
|
3327
|
-
var HarnessImprovementRouteSchema = z5.enum([
|
|
3328
|
-
"runtime",
|
|
3329
|
-
"memory",
|
|
3330
|
-
"prompt",
|
|
3331
|
-
"skill",
|
|
3332
|
-
"agent",
|
|
3333
|
-
"product",
|
|
3334
|
-
"taskset",
|
|
3335
|
-
"training"
|
|
3336
|
-
]);
|
|
3337
|
-
var HarnessChangeEffectSchema = z5.enum([
|
|
3338
|
-
"text_instruction",
|
|
3339
|
-
"memory",
|
|
3340
|
-
"dependency_selection",
|
|
3341
|
-
"executable_code",
|
|
3342
|
-
"business_logic",
|
|
3343
|
-
"financial_logic",
|
|
3344
|
-
"permission",
|
|
3345
|
-
"connected_app",
|
|
3346
|
-
"publication",
|
|
3347
|
-
"deployment",
|
|
3348
|
-
"training",
|
|
3349
|
-
"model_binding",
|
|
3350
|
-
"team_or_global"
|
|
3351
|
-
]);
|
|
3352
|
-
var HarnessOverlayEditSchema = z5.object({
|
|
3353
|
-
id: ReleaseIdSchema,
|
|
3354
|
-
route: HarnessImprovementRouteSchema,
|
|
3355
|
-
operation: z5.enum(["create", "update", "delete"]),
|
|
3356
|
-
target: z5.string().trim().min(1).max(2e3),
|
|
3357
|
-
summary: z5.string().trim().min(1).max(2e3),
|
|
3358
|
-
content: z5.string().max(1e6).nullable(),
|
|
3359
|
-
contentHash: ReleaseHashSchema.nullable(),
|
|
3360
|
-
effects: z5.array(HarnessChangeEffectSchema).min(1).max(20)
|
|
3361
|
-
}).strict().superRefine((edit, context) => {
|
|
3362
|
-
if (edit.operation === "delete") {
|
|
3363
|
-
if (edit.content !== null || edit.contentHash !== null) {
|
|
3364
|
-
context.addIssue({
|
|
3365
|
-
code: "custom",
|
|
3366
|
-
message: "delete edits cannot include replacement content",
|
|
3367
|
-
path: ["content"]
|
|
3368
|
-
});
|
|
3369
|
-
}
|
|
3370
|
-
return;
|
|
3371
|
-
}
|
|
3372
|
-
if (edit.content === null || edit.contentHash === null) {
|
|
3373
|
-
context.addIssue({
|
|
3374
|
-
code: "custom",
|
|
3375
|
-
message: "create and update edits require content and contentHash",
|
|
3376
|
-
path: ["content"]
|
|
3377
|
-
});
|
|
3378
|
-
return;
|
|
3379
|
-
}
|
|
3380
|
-
const expected = contentHash(edit.content);
|
|
3381
|
-
if (edit.contentHash !== expected) {
|
|
3382
|
-
context.addIssue({
|
|
3383
|
-
code: "custom",
|
|
3384
|
-
message: `edit contentHash is ${edit.contentHash}; expected ${expected}`,
|
|
3385
|
-
path: ["contentHash"]
|
|
3386
|
-
});
|
|
3387
|
-
}
|
|
3388
|
-
});
|
|
3389
|
-
var HarnessWorkspaceRevisionRefSchema = z5.object({
|
|
3390
|
-
workspaceId: ReleaseIdSchema,
|
|
3391
|
-
revision: RevisionSchema,
|
|
3392
|
-
sourceRevision: z5.string().trim().min(1).max(500),
|
|
3393
|
-
channelRevision: RevisionSchema
|
|
3394
|
-
}).strict();
|
|
3395
|
-
var HarnessOverlaySnapshotRefSchema = z5.object({
|
|
3396
|
-
id: ReleaseIdSchema,
|
|
3397
|
-
revision: RevisionSchema,
|
|
3398
|
-
contentHash: ReleaseHashSchema
|
|
3399
|
-
}).strict();
|
|
3400
|
-
var HarnessTurnSnapshotSchema = z5.object({
|
|
3401
|
-
schemaVersion: z5.literal("openpond.harnessTurnSnapshot.v1"),
|
|
3402
|
-
workspaceId: ReleaseIdSchema,
|
|
3403
|
-
workspaceRevision: RevisionSchema,
|
|
3404
|
-
sourceRevision: z5.string().trim().min(1).max(500),
|
|
3405
|
-
channelName: ReleaseIdSchema,
|
|
3406
|
-
channelRevision: RevisionSchema,
|
|
3407
|
-
harnessRelease: ImmutableReleaseRefSchema,
|
|
3408
|
-
toolCatalogHash: ReleaseHashSchema.nullable().optional(),
|
|
3409
|
-
overlay: HarnessOverlaySnapshotRefSchema.nullable().optional().default(null)
|
|
3410
|
-
}).strict();
|
|
3411
|
-
var HarnessRunOverlayContentSchema = z5.object({
|
|
3412
|
-
schemaVersion: z5.literal("openpond.harnessRunOverlay.v1"),
|
|
3413
|
-
id: ReleaseIdSchema,
|
|
3414
|
-
runId: ReleaseIdSchema,
|
|
3415
|
-
baseHarnessRelease: ImmutableReleaseRefSchema,
|
|
3416
|
-
workspace: HarnessWorkspaceRevisionRefSchema,
|
|
3417
|
-
revision: RevisionSchema,
|
|
3418
|
-
status: z5.enum(["active", "frozen", "abandoned"]),
|
|
3419
|
-
edits: z5.array(HarnessOverlayEditSchema).max(1e3),
|
|
3420
|
-
createdAt: ReleaseTimestampSchema,
|
|
3421
|
-
updatedAt: ReleaseTimestampSchema,
|
|
3422
|
-
metadata: MetadataSchema2
|
|
3423
|
-
}).strict();
|
|
3424
|
-
var HarnessRunOverlaySchema = HarnessRunOverlayContentSchema.extend({
|
|
3425
|
-
contentHash: ReleaseHashSchema
|
|
3426
|
-
}).strict();
|
|
3427
|
-
var HarnessProposalEvidenceRefSchema = z5.object({
|
|
3428
|
-
kind: z5.enum([
|
|
3429
|
-
"tool_event",
|
|
3430
|
-
"recovery",
|
|
3431
|
-
"validation",
|
|
3432
|
-
"user_turn",
|
|
3433
|
-
"work_output",
|
|
3434
|
-
"work_receipt"
|
|
3435
|
-
]),
|
|
3436
|
-
id: ReleaseIdSchema,
|
|
3437
|
-
contentHash: ReleaseHashSchema.nullable()
|
|
3438
|
-
}).strict();
|
|
3439
|
-
var HarnessValidationPlanItemSchema = z5.object({
|
|
3440
|
-
id: ReleaseIdSchema,
|
|
3441
|
-
kind: z5.enum([
|
|
3442
|
-
"dependency",
|
|
3443
|
-
"schema",
|
|
3444
|
-
"package",
|
|
3445
|
-
"file_render",
|
|
3446
|
-
"skill",
|
|
3447
|
-
"prompt",
|
|
3448
|
-
"business_formula",
|
|
3449
|
-
"targeted_evaluation",
|
|
3450
|
-
"observed_recovery",
|
|
3451
|
-
"memory",
|
|
3452
|
-
"component_activation"
|
|
3453
|
-
]),
|
|
3454
|
-
description: BoundedTextSchema2,
|
|
3455
|
-
required: z5.boolean()
|
|
3456
|
-
}).strict();
|
|
3457
|
-
var HarnessImprovementProposalContentSchema = z5.object({
|
|
3458
|
-
schemaVersion: z5.literal("openpond.harnessImprovementProposal.v1"),
|
|
3459
|
-
id: ReleaseIdSchema,
|
|
3460
|
-
overlay: HarnessOverlaySnapshotRefSchema,
|
|
3461
|
-
baseHarnessRelease: ImmutableReleaseRefSchema,
|
|
3462
|
-
expectedWorkspace: HarnessWorkspaceRevisionRefSchema,
|
|
3463
|
-
requestedScope: z5.enum(["personal", "team", "global"]),
|
|
3464
|
-
route: HarnessImprovementRouteSchema,
|
|
3465
|
-
risk: z5.enum(["low", "review", "restricted"]),
|
|
3466
|
-
effects: z5.array(HarnessChangeEffectSchema).min(1).max(20),
|
|
3467
|
-
evidence: z5.array(HarnessProposalEvidenceRefSchema).min(1).max(1e3),
|
|
3468
|
-
edits: z5.array(HarnessOverlayEditSchema).min(1).max(1e3),
|
|
3469
|
-
validationPlan: z5.array(HarnessValidationPlanItemSchema).min(1).max(100),
|
|
3470
|
-
expectedOutcome: BoundedTextSchema2,
|
|
3471
|
-
createdAt: ReleaseTimestampSchema,
|
|
3472
|
-
metadata: MetadataSchema2
|
|
3473
|
-
}).strict().superRefine((proposal, context) => {
|
|
3474
|
-
const declaredEffects = new Set(proposal.effects);
|
|
3475
|
-
for (const [index, edit] of proposal.edits.entries()) {
|
|
3476
|
-
if (edit.route !== proposal.route) {
|
|
3477
|
-
context.addIssue({
|
|
3478
|
-
code: "custom",
|
|
3479
|
-
message: "every edit route must match the proposal route",
|
|
3480
|
-
path: ["edits", index, "route"]
|
|
3481
|
-
});
|
|
3482
|
-
}
|
|
3483
|
-
for (const effect of edit.effects) {
|
|
3484
|
-
if (!declaredEffects.has(effect)) {
|
|
3485
|
-
context.addIssue({
|
|
3486
|
-
code: "custom",
|
|
3487
|
-
message: `edit effect ${effect} is missing from proposal effects`,
|
|
3488
|
-
path: ["edits", index, "effects"]
|
|
3489
|
-
});
|
|
3490
|
-
}
|
|
3491
|
-
}
|
|
3492
|
-
}
|
|
3493
|
-
if (new Set(proposal.validationPlan.map((item) => item.id)).size !== proposal.validationPlan.length) {
|
|
3494
|
-
context.addIssue({
|
|
3495
|
-
code: "custom",
|
|
3496
|
-
message: "validation plan ids must be unique",
|
|
3497
|
-
path: ["validationPlan"]
|
|
3498
|
-
});
|
|
3499
|
-
}
|
|
3500
|
-
});
|
|
3501
|
-
var HarnessImprovementProposalSchema = HarnessImprovementProposalContentSchema.extend({
|
|
3502
|
-
contentHash: ReleaseHashSchema
|
|
3503
|
-
}).strict();
|
|
3504
|
-
var HarnessTargetedValidationReceiptContentSchema = z5.object({
|
|
3505
|
-
schemaVersion: z5.literal("openpond.harnessTargetedValidationReceipt.v1"),
|
|
3506
|
-
id: ReleaseIdSchema,
|
|
3507
|
-
proposal: ImmutableReleaseRefSchema,
|
|
3508
|
-
validationId: ReleaseIdSchema,
|
|
3509
|
-
kind: HarnessValidationPlanItemSchema.shape.kind,
|
|
3510
|
-
status: z5.enum(["passed", "failed", "blocked", "skipped"]),
|
|
3511
|
-
summary: BoundedTextSchema2,
|
|
3512
|
-
evidenceRefs: z5.array(HarnessProposalEvidenceRefSchema).max(1e3),
|
|
3513
|
-
createdAt: ReleaseTimestampSchema,
|
|
3514
|
-
metadata: MetadataSchema2
|
|
3515
|
-
}).strict();
|
|
3516
|
-
var HarnessTargetedValidationReceiptSchema = HarnessTargetedValidationReceiptContentSchema.extend({
|
|
3517
|
-
contentHash: ReleaseHashSchema
|
|
3518
|
-
}).strict();
|
|
3519
|
-
var HarnessAdvanceDecisionSchema = z5.enum([
|
|
3520
|
-
"advanced",
|
|
3521
|
-
"retained",
|
|
3522
|
-
"conflict",
|
|
3523
|
-
"rolled_back"
|
|
3524
|
-
]);
|
|
3525
|
-
var HarnessAdvanceReceiptContentSchema = z5.object({
|
|
3526
|
-
schemaVersion: z5.literal("openpond.harnessAdvanceReceipt.v1"),
|
|
3527
|
-
id: ReleaseIdSchema,
|
|
3528
|
-
workspaceId: ReleaseIdSchema,
|
|
3529
|
-
ownerScope: HarnessOwnerScopeSchema,
|
|
3530
|
-
proposal: ImmutableReleaseRefSchema.nullable(),
|
|
3531
|
-
expectedWorkspaceRevision: RevisionSchema,
|
|
3532
|
-
observedWorkspaceRevision: RevisionSchema,
|
|
3533
|
-
previousChannelRevision: RevisionSchema,
|
|
3534
|
-
nextChannelRevision: RevisionSchema,
|
|
3535
|
-
previousRelease: ImmutableReleaseRefSchema.nullable(),
|
|
3536
|
-
nextRelease: ImmutableReleaseRefSchema.nullable(),
|
|
3537
|
-
validationReceipts: z5.array(ImmutableReleaseRefSchema).max(100),
|
|
3538
|
-
decision: HarnessAdvanceDecisionSchema,
|
|
3539
|
-
reason: BoundedTextSchema2,
|
|
3540
|
-
rollbackOf: ImmutableReleaseRefSchema.nullable(),
|
|
3541
|
-
createdAt: ReleaseTimestampSchema,
|
|
3542
|
-
metadata: MetadataSchema2
|
|
3543
|
-
}).strict().superRefine((receipt, context) => {
|
|
3544
|
-
const changed = receipt.nextChannelRevision === receipt.previousChannelRevision + 1;
|
|
3545
|
-
if (["advanced", "rolled_back"].includes(receipt.decision) !== changed) {
|
|
3546
|
-
context.addIssue({
|
|
3547
|
-
code: "custom",
|
|
3548
|
-
message: "only successful advancement or rollback increments the channel revision",
|
|
3549
|
-
path: ["nextChannelRevision"]
|
|
3550
|
-
});
|
|
3551
|
-
}
|
|
3552
|
-
if (receipt.decision === "rolled_back" && receipt.rollbackOf === null) {
|
|
3553
|
-
context.addIssue({
|
|
3554
|
-
code: "custom",
|
|
3555
|
-
message: "rollback receipts require rollbackOf",
|
|
3556
|
-
path: ["rollbackOf"]
|
|
3557
|
-
});
|
|
3558
|
-
}
|
|
3559
|
-
if (receipt.decision !== "rolled_back" && receipt.rollbackOf !== null) {
|
|
3560
|
-
context.addIssue({
|
|
3561
|
-
code: "custom",
|
|
3562
|
-
message: "rollbackOf is only valid for rollback receipts",
|
|
3563
|
-
path: ["rollbackOf"]
|
|
3564
|
-
});
|
|
3565
|
-
}
|
|
3566
|
-
});
|
|
3567
|
-
var HarnessAdvanceReceiptSchema = HarnessAdvanceReceiptContentSchema.extend({
|
|
3568
|
-
contentHash: ReleaseHashSchema
|
|
3569
|
-
}).strict();
|
|
3570
|
-
var HarnessOverlayMergeReceiptContentSchema = z5.object({
|
|
3571
|
-
schemaVersion: z5.literal("openpond.harnessOverlayMergeReceipt.v1"),
|
|
3572
|
-
id: ReleaseIdSchema,
|
|
3573
|
-
workspaceId: ReleaseIdSchema,
|
|
3574
|
-
baseHarnessRelease: ImmutableReleaseRefSchema,
|
|
3575
|
-
leftOverlay: HarnessOverlaySnapshotRefSchema,
|
|
3576
|
-
rightOverlay: HarnessOverlaySnapshotRefSchema,
|
|
3577
|
-
decision: z5.enum(["merged", "conflict"]),
|
|
3578
|
-
mergedOverlay: HarnessOverlaySnapshotRefSchema.nullable(),
|
|
3579
|
-
conflictTargets: z5.array(z5.string().trim().min(1).max(2e3)).max(1e3),
|
|
3580
|
-
requiresRevalidation: z5.literal(true),
|
|
3581
|
-
createdAt: ReleaseTimestampSchema,
|
|
3582
|
-
metadata: MetadataSchema2
|
|
3583
|
-
}).strict().superRefine((receipt, context) => {
|
|
3584
|
-
if (receipt.decision === "merged" !== (receipt.mergedOverlay !== null)) {
|
|
3585
|
-
context.addIssue({
|
|
3586
|
-
code: "custom",
|
|
3587
|
-
message: "merged decisions require a merged overlay; conflicts cannot provide one",
|
|
3588
|
-
path: ["mergedOverlay"]
|
|
3589
|
-
});
|
|
3590
|
-
}
|
|
3591
|
-
if (receipt.decision === "conflict" !== receipt.conflictTargets.length > 0) {
|
|
3592
|
-
context.addIssue({
|
|
3593
|
-
code: "custom",
|
|
3594
|
-
message: "conflict decisions require conflict targets and merged decisions cannot include them",
|
|
3595
|
-
path: ["conflictTargets"]
|
|
3596
|
-
});
|
|
3597
|
-
}
|
|
3598
|
-
});
|
|
3599
|
-
var HarnessOverlayMergeReceiptSchema = HarnessOverlayMergeReceiptContentSchema.extend({
|
|
3600
|
-
contentHash: ReleaseHashSchema
|
|
3601
|
-
}).strict();
|
|
3602
|
-
|
|
3603
|
-
// ../harness/dist/harness-improvements.js
|
|
3604
|
-
var BoundedTextSchema3 = z6.string().trim().min(1).max(1e5);
|
|
3605
|
-
var MetadataSchema3 = z6.record(z6.string(), z6.unknown()).default({});
|
|
3606
|
-
var ImprovementSafeBoundaryKindSchema = z6.enum([
|
|
3607
|
-
"completed_tool_batch",
|
|
3608
|
-
"before_model_step",
|
|
3609
|
-
"turn_completed",
|
|
3610
|
-
"turn_paused"
|
|
3611
|
-
]);
|
|
3612
|
-
var ImprovementSafeBoundarySchema = z6.object({
|
|
3613
|
-
kind: ImprovementSafeBoundaryKindSchema,
|
|
3614
|
-
eventSequence: z6.number().int().nonnegative(),
|
|
3615
|
-
occurredAt: ReleaseTimestampSchema
|
|
3616
|
-
}).strict();
|
|
3617
|
-
var ImprovementEventRefSchema = z6.object({
|
|
3618
|
-
id: ReleaseIdSchema,
|
|
3619
|
-
sequence: z6.number().int().nonnegative().nullable(),
|
|
3620
|
-
contentHash: ReleaseHashSchema
|
|
3621
|
-
}).strict();
|
|
3622
|
-
var ImprovementObservationKindSchema = z6.enum([
|
|
3623
|
-
"tool_failure",
|
|
3624
|
-
"retry",
|
|
3625
|
-
"recovery",
|
|
3626
|
-
"validation",
|
|
3627
|
-
"user_turn",
|
|
3628
|
-
"reusable_success",
|
|
3629
|
-
"completion_detour"
|
|
3630
|
-
]);
|
|
3631
|
-
var ImprovementObservationStateSchema = z6.enum([
|
|
3632
|
-
"open",
|
|
3633
|
-
"recovered",
|
|
3634
|
-
"terminal"
|
|
3635
|
-
]);
|
|
3636
|
-
var ImprovementToolIdentitySchema = z6.object({
|
|
3637
|
-
name: z6.string().trim().min(1).max(500),
|
|
3638
|
-
invocationKey: ReleaseHashSchema
|
|
3639
|
-
}).strict();
|
|
3640
|
-
var ImprovementObservationContentSchema = z6.object({
|
|
3641
|
-
schemaVersion: z6.literal("openpond.improvementObservation.v1"),
|
|
3642
|
-
id: ReleaseIdSchema,
|
|
3643
|
-
runRef: ReleaseIdSchema,
|
|
3644
|
-
turnId: ReleaseIdSchema,
|
|
3645
|
-
harnessRelease: ImmutableReleaseRefSchema,
|
|
3646
|
-
overlay: HarnessOverlaySnapshotRefSchema.nullable(),
|
|
3647
|
-
eventRefs: z6.array(ImprovementEventRefSchema).min(1).max(100),
|
|
3648
|
-
kind: ImprovementObservationKindSchema,
|
|
3649
|
-
state: ImprovementObservationStateSchema,
|
|
3650
|
-
tool: ImprovementToolIdentitySchema.nullable(),
|
|
3651
|
-
deterministicClass: z6.string().trim().min(1).max(500).nullable(),
|
|
3652
|
-
summary: BoundedTextSchema3,
|
|
3653
|
-
createdAt: ReleaseTimestampSchema,
|
|
3654
|
-
metadata: MetadataSchema3
|
|
3655
|
-
}).strict().superRefine((observation, context) => {
|
|
3656
|
-
if (new Set(observation.eventRefs.map((reference) => reference.id)).size !== observation.eventRefs.length) {
|
|
3657
|
-
context.addIssue({
|
|
3658
|
-
code: "custom",
|
|
3659
|
-
message: "observation event refs must be unique",
|
|
3660
|
-
path: ["eventRefs"]
|
|
3661
|
-
});
|
|
3662
|
-
}
|
|
3663
|
-
if (["tool_failure", "retry", "recovery", "completion_detour"].includes(observation.kind) && observation.tool === null) {
|
|
3664
|
-
context.addIssue({
|
|
3665
|
-
code: "custom",
|
|
3666
|
-
message: `${observation.kind} observations require a tool identity`,
|
|
3667
|
-
path: ["tool"]
|
|
3668
|
-
});
|
|
3669
|
-
}
|
|
3670
|
-
});
|
|
3671
|
-
var ImprovementObservationSchema = ImprovementObservationContentSchema.extend({
|
|
3672
|
-
contentHash: ReleaseHashSchema
|
|
3673
|
-
}).strict();
|
|
3674
|
-
var RefinementTriggerPolicySchema = z6.object({
|
|
3675
|
-
schemaVersion: z6.literal("openpond.refinementTriggerPolicy.v1"),
|
|
3676
|
-
maxEstimatedCostUsd: z6.number().finite().nonnegative(),
|
|
3677
|
-
cooldownMs: z6.number().int().nonnegative(),
|
|
3678
|
-
maxPendingPlans: z6.number().int().min(1).max(100),
|
|
3679
|
-
maxEvidenceEvents: z6.number().int().min(1).max(1e3),
|
|
3680
|
-
maxProposalEdits: z6.number().int().min(1).max(1e3),
|
|
3681
|
-
maxProposalBytes: z6.number().int().min(1).max(1e7)
|
|
3682
|
-
}).strict();
|
|
3683
|
-
var RefinementTriggerDecisionKindSchema = z6.enum([
|
|
3684
|
-
"no_action",
|
|
3685
|
-
"route_deterministically",
|
|
3686
|
-
"queue_refiner"
|
|
3687
|
-
]);
|
|
3688
|
-
var RefinementTriggerDecisionContentSchema = z6.object({
|
|
3689
|
-
schemaVersion: z6.literal("openpond.refinementTriggerDecision.v1"),
|
|
3690
|
-
id: ReleaseIdSchema,
|
|
3691
|
-
runRef: ReleaseIdSchema,
|
|
3692
|
-
turnId: ReleaseIdSchema,
|
|
3693
|
-
harnessRelease: ImmutableReleaseRefSchema,
|
|
3694
|
-
overlay: HarnessOverlaySnapshotRefSchema.nullable(),
|
|
3695
|
-
observations: z6.array(ImmutableReleaseRefSchema).max(100),
|
|
3696
|
-
decision: RefinementTriggerDecisionKindSchema,
|
|
3697
|
-
deterministicRoute: HarnessImprovementRouteSchema.nullable(),
|
|
3698
|
-
suggestedRoutes: z6.array(HarnessImprovementRouteSchema).max(8),
|
|
3699
|
-
reason: BoundedTextSchema3,
|
|
3700
|
-
deduplicationKey: ReleaseHashSchema,
|
|
3701
|
-
policy: RefinementTriggerPolicySchema,
|
|
3702
|
-
estimatedMaxCostUsd: z6.number().finite().nonnegative(),
|
|
3703
|
-
pendingPlanCount: z6.number().int().nonnegative(),
|
|
3704
|
-
boundary: ImprovementSafeBoundarySchema,
|
|
3705
|
-
cooldownUntil: ReleaseTimestampSchema.nullable(),
|
|
3706
|
-
createdAt: ReleaseTimestampSchema,
|
|
3707
|
-
metadata: MetadataSchema3
|
|
3708
|
-
}).strict().superRefine((trigger, context) => {
|
|
3709
|
-
if (trigger.estimatedMaxCostUsd > trigger.policy.maxEstimatedCostUsd) {
|
|
3710
|
-
context.addIssue({
|
|
3711
|
-
code: "custom",
|
|
3712
|
-
message: "estimated Refiner cost exceeds the trigger policy budget",
|
|
3713
|
-
path: ["estimatedMaxCostUsd"]
|
|
3714
|
-
});
|
|
3715
|
-
}
|
|
3716
|
-
if (trigger.pendingPlanCount > trigger.policy.maxPendingPlans) {
|
|
3717
|
-
context.addIssue({
|
|
3718
|
-
code: "custom",
|
|
3719
|
-
message: "pending plan count exceeds the trigger policy limit",
|
|
3720
|
-
path: ["pendingPlanCount"]
|
|
3721
|
-
});
|
|
3722
|
-
}
|
|
3723
|
-
if (trigger.observations.length > trigger.policy.maxEvidenceEvents) {
|
|
3724
|
-
context.addIssue({
|
|
3725
|
-
code: "custom",
|
|
3726
|
-
message: "trigger observations exceed the evidence budget",
|
|
3727
|
-
path: ["observations"]
|
|
3728
|
-
});
|
|
3729
|
-
}
|
|
3730
|
-
if (trigger.decision === "route_deterministically" && trigger.deterministicRoute === null) {
|
|
3731
|
-
context.addIssue({
|
|
3732
|
-
code: "custom",
|
|
3733
|
-
message: "deterministic decisions require a route",
|
|
3734
|
-
path: ["deterministicRoute"]
|
|
3735
|
-
});
|
|
3736
|
-
}
|
|
3737
|
-
if (trigger.decision !== "route_deterministically" && trigger.deterministicRoute !== null) {
|
|
3738
|
-
context.addIssue({
|
|
3739
|
-
code: "custom",
|
|
3740
|
-
message: "only deterministic decisions may declare a deterministic route",
|
|
3741
|
-
path: ["deterministicRoute"]
|
|
3742
|
-
});
|
|
3743
|
-
}
|
|
3744
|
-
if (trigger.decision === "no_action" && trigger.suggestedRoutes.length > 0) {
|
|
3745
|
-
context.addIssue({
|
|
3746
|
-
code: "custom",
|
|
3747
|
-
message: "no-action decisions cannot suggest routes",
|
|
3748
|
-
path: ["suggestedRoutes"]
|
|
3749
|
-
});
|
|
3750
|
-
}
|
|
3751
|
-
if (trigger.decision !== "no_action" && trigger.observations.length === 0) {
|
|
3752
|
-
context.addIssue({
|
|
3753
|
-
code: "custom",
|
|
3754
|
-
message: "actionable trigger decisions require observations",
|
|
3755
|
-
path: ["observations"]
|
|
3756
|
-
});
|
|
3757
|
-
}
|
|
3758
|
-
});
|
|
3759
|
-
var RefinementTriggerDecisionSchema = RefinementTriggerDecisionContentSchema.extend({
|
|
3760
|
-
contentHash: ReleaseHashSchema
|
|
3761
|
-
}).strict();
|
|
3762
|
-
var ImprovementRouteAuthoritySchema = z6.enum([
|
|
3763
|
-
"runtime_service",
|
|
3764
|
-
"refiner_model",
|
|
3765
|
-
"human_review",
|
|
3766
|
-
"evaluation_system",
|
|
3767
|
-
"training_system"
|
|
3768
|
-
]);
|
|
3769
|
-
var ImprovementRouteDecisionContentSchema = z6.object({
|
|
3770
|
-
schemaVersion: z6.literal("openpond.improvementRouteDecision.v1"),
|
|
3771
|
-
id: ReleaseIdSchema,
|
|
3772
|
-
trigger: ImmutableReleaseRefSchema,
|
|
3773
|
-
route: HarnessImprovementRouteSchema,
|
|
3774
|
-
authority: ImprovementRouteAuthoritySchema,
|
|
3775
|
-
automatic: z6.boolean(),
|
|
3776
|
-
reason: BoundedTextSchema3,
|
|
3777
|
-
createdAt: ReleaseTimestampSchema,
|
|
3778
|
-
metadata: MetadataSchema3
|
|
3779
|
-
}).strict().superRefine((decision, context) => {
|
|
3780
|
-
if (decision.automatic && ["human_review", "evaluation_system", "training_system"].includes(decision.authority)) {
|
|
3781
|
-
context.addIssue({
|
|
3782
|
-
code: "custom",
|
|
3783
|
-
message: `${decision.authority} routes cannot be marked automatic`,
|
|
3784
|
-
path: ["automatic"]
|
|
3785
|
-
});
|
|
3786
|
-
}
|
|
3787
|
-
if (decision.route === "training" && decision.automatic && decision.authority !== "training_system") {
|
|
3788
|
-
context.addIssue({
|
|
3789
|
-
code: "custom",
|
|
3790
|
-
message: "automatic training routes require training-system authority",
|
|
3791
|
-
path: ["authority"]
|
|
3792
|
-
});
|
|
3793
|
-
}
|
|
3794
|
-
});
|
|
3795
|
-
var ImprovementRouteDecisionSchema = ImprovementRouteDecisionContentSchema.extend({
|
|
3796
|
-
contentHash: ReleaseHashSchema
|
|
3797
|
-
}).strict();
|
|
3798
|
-
var HarnessRefinerOutcomeContentSchema = z6.object({
|
|
3799
|
-
schemaVersion: z6.literal("openpond.harnessRefinerOutcome.v1"),
|
|
3800
|
-
id: ReleaseIdSchema,
|
|
3801
|
-
trigger: ImmutableReleaseRefSchema,
|
|
3802
|
-
decision: z6.enum(["no_action", "proposed"]),
|
|
3803
|
-
proposal: ImmutableReleaseRefSchema.nullable(),
|
|
3804
|
-
reason: BoundedTextSchema3,
|
|
3805
|
-
evidenceRefs: z6.array(ImmutableReleaseRefSchema).max(100),
|
|
3806
|
-
estimatedCostUsd: z6.number().finite().nonnegative(),
|
|
3807
|
-
createdAt: ReleaseTimestampSchema,
|
|
3808
|
-
metadata: MetadataSchema3
|
|
3809
|
-
}).strict().superRefine((outcome, context) => {
|
|
3810
|
-
if (outcome.decision === "proposed" !== (outcome.proposal !== null)) {
|
|
3811
|
-
context.addIssue({
|
|
3812
|
-
code: "custom",
|
|
3813
|
-
message: "proposed Refiner outcomes require a proposal; no-action outcomes cannot include one",
|
|
3814
|
-
path: ["proposal"]
|
|
3815
|
-
});
|
|
3816
|
-
}
|
|
3817
|
-
});
|
|
3818
|
-
var HarnessRefinerOutcomeSchema = HarnessRefinerOutcomeContentSchema.extend({
|
|
3819
|
-
contentHash: ReleaseHashSchema
|
|
3820
|
-
}).strict();
|
|
3821
|
-
var ImprovementApplyDecisionSchema = z6.enum([
|
|
3822
|
-
"applied",
|
|
3823
|
-
"retained",
|
|
3824
|
-
"declined",
|
|
3825
|
-
"conflict",
|
|
3826
|
-
"rolled_back"
|
|
3827
|
-
]);
|
|
3828
|
-
var ImprovementApplyReceiptContentSchema = z6.object({
|
|
3829
|
-
schemaVersion: z6.literal("openpond.improvementApplyReceipt.v1"),
|
|
3830
|
-
id: ReleaseIdSchema,
|
|
3831
|
-
proposal: ImmutableReleaseRefSchema,
|
|
3832
|
-
beforeOverlay: HarnessOverlaySnapshotRefSchema,
|
|
3833
|
-
afterOverlay: HarnessOverlaySnapshotRefSchema.nullable(),
|
|
3834
|
-
decision: ImprovementApplyDecisionSchema,
|
|
3835
|
-
boundary: ImprovementSafeBoundarySchema,
|
|
3836
|
-
validationRefs: z6.array(ImmutableReleaseRefSchema).max(100),
|
|
3837
|
-
outcomeEvidenceRefs: z6.array(ImprovementEventRefSchema).max(1e3),
|
|
3838
|
-
rollbackOf: ImmutableReleaseRefSchema.nullable(),
|
|
3839
|
-
createdAt: ReleaseTimestampSchema,
|
|
3840
|
-
metadata: MetadataSchema3
|
|
3841
|
-
}).strict().superRefine((receipt, context) => {
|
|
3842
|
-
if (receipt.decision === "applied" !== (receipt.afterOverlay !== null)) {
|
|
3843
|
-
context.addIssue({
|
|
3844
|
-
code: "custom",
|
|
3845
|
-
message: "applied receipts require an after-overlay; other decisions cannot include one",
|
|
3846
|
-
path: ["afterOverlay"]
|
|
3847
|
-
});
|
|
3848
|
-
}
|
|
3849
|
-
if (receipt.decision === "rolled_back" !== (receipt.rollbackOf !== null)) {
|
|
3850
|
-
context.addIssue({
|
|
3851
|
-
code: "custom",
|
|
3852
|
-
message: "only rollback receipts require rollbackOf",
|
|
3853
|
-
path: ["rollbackOf"]
|
|
3854
|
-
});
|
|
3855
|
-
}
|
|
3856
|
-
});
|
|
3857
|
-
var ImprovementApplyReceiptSchema = ImprovementApplyReceiptContentSchema.extend({
|
|
3858
|
-
contentHash: ReleaseHashSchema
|
|
3859
|
-
}).strict();
|
|
3860
|
-
|
|
3861
|
-
// ../harness/dist/models.js
|
|
3862
|
-
import { z as z7 } from "zod";
|
|
3863
|
-
var ModelRefSchema = z7.object({
|
|
3864
|
-
provider: ReleaseIdSchema,
|
|
3865
|
-
model: ReleaseIdSchema,
|
|
3866
|
-
revision: z7.string().trim().min(1).max(500).nullable().default(null),
|
|
3867
|
-
artifactHash: ReleaseHashSchema.nullable().default(null),
|
|
3868
|
-
tokenizerRevision: z7.string().trim().min(1).max(500).nullable().default(null),
|
|
3869
|
-
chatTemplateHash: ReleaseHashSchema.nullable().default(null)
|
|
3870
|
-
}).strict();
|
|
3871
|
-
|
|
3872
|
-
// ../harness/dist/refiner.js
|
|
3873
|
-
import { z as z9 } from "zod";
|
|
3874
|
-
|
|
3875
|
-
// ../harness/dist/refiner-profiles.js
|
|
3876
|
-
import { z as z8 } from "zod";
|
|
3877
|
-
var RefinerProposalRouteSchema = z8.enum(["memory", "prompt", "skill", "agent"]);
|
|
3878
|
-
var RefinerExternalRouteSchema = z8.enum(["runtime", "product", "taskset", "training"]);
|
|
3879
|
-
var RefinerReviewInstructionSchema = z8.object({
|
|
3880
|
-
id: z8.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
|
|
3881
|
-
text: z8.string().trim().min(1).max(1e4)
|
|
3882
|
-
}).strict();
|
|
3883
|
-
var RefinerReviewProfileSchema = z8.object({
|
|
3884
|
-
schemaVersion: z8.literal("openpond.refinerReviewProfile.v1"),
|
|
3885
|
-
id: z8.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
|
|
3886
|
-
version: z8.string().trim().min(1).max(120),
|
|
3887
|
-
name: z8.string().trim().min(1).max(200),
|
|
3888
|
-
objective: z8.string().trim().min(1).max(1e4),
|
|
3889
|
-
instructions: z8.array(RefinerReviewInstructionSchema).max(100),
|
|
3890
|
-
allowedProposalRoutes: z8.array(RefinerProposalRouteSchema).max(4),
|
|
3891
|
-
allowedExternalRoutes: z8.array(RefinerExternalRouteSchema).max(4)
|
|
3892
|
-
}).strict().superRefine((profile, context) => {
|
|
3893
|
-
const instructionIds = profile.instructions.map((instruction) => instruction.id);
|
|
3894
|
-
if (new Set(instructionIds).size !== instructionIds.length) {
|
|
3895
|
-
context.addIssue({ code: "custom", message: "instruction IDs must be unique", path: ["instructions"] });
|
|
3896
|
-
}
|
|
3897
|
-
if (new Set(profile.allowedProposalRoutes).size !== profile.allowedProposalRoutes.length) {
|
|
3898
|
-
context.addIssue({ code: "custom", message: "proposal routes must be unique", path: ["allowedProposalRoutes"] });
|
|
3899
|
-
}
|
|
3900
|
-
if (new Set(profile.allowedExternalRoutes).size !== profile.allowedExternalRoutes.length) {
|
|
3901
|
-
context.addIssue({ code: "custom", message: "external routes must be unique", path: ["allowedExternalRoutes"] });
|
|
3902
|
-
}
|
|
3903
|
-
});
|
|
3904
|
-
var DEFAULT_REFINER_REVIEW_PROFILE = {
|
|
3905
|
-
schemaVersion: "openpond.refinerReviewProfile.v1",
|
|
3906
|
-
id: "openpond.default",
|
|
3907
|
-
version: "1",
|
|
3908
|
-
name: "OpenPond default review",
|
|
3909
|
-
objective: "Find the smallest reusable change that improves future work without learning task-specific facts.",
|
|
3910
|
-
instructions: [],
|
|
3911
|
-
allowedProposalRoutes: ["memory", "prompt", "skill", "agent"],
|
|
3912
|
-
allowedExternalRoutes: ["runtime", "product", "taskset", "training"]
|
|
3913
|
-
};
|
|
3914
|
-
var RefinerReleaseSchema = z8.object({
|
|
3915
|
-
schemaVersion: z8.literal("openpond.refinerRelease.v1"),
|
|
3916
|
-
id: z8.string().trim().min(1).max(240),
|
|
3917
|
-
coreVersion: z8.string().trim().min(1).max(120),
|
|
3918
|
-
coreHash: ReleaseHashSchema,
|
|
3919
|
-
profile: RefinerReviewProfileSchema,
|
|
3920
|
-
profileHash: ReleaseHashSchema,
|
|
3921
|
-
composedPromptHash: ReleaseHashSchema,
|
|
3922
|
-
createdAt: ReleaseTimestampSchema,
|
|
3923
|
-
contentHash: ReleaseHashSchema
|
|
3924
|
-
}).strict();
|
|
3925
|
-
var RefinerBindingSchema = z8.object({
|
|
3926
|
-
schemaVersion: z8.literal("openpond.refinerBinding.v1"),
|
|
3927
|
-
channel: z8.literal("active"),
|
|
3928
|
-
revision: z8.number().int().nonnegative(),
|
|
3929
|
-
release: ImmutableReleaseRefSchema,
|
|
3930
|
-
updatedAt: ReleaseTimestampSchema
|
|
3931
|
-
}).strict();
|
|
3932
|
-
var RefinerTransitionReceiptSchema = z8.object({
|
|
3933
|
-
schemaVersion: z8.literal("openpond.refinerTransitionReceipt.v1"),
|
|
3934
|
-
id: z8.string().trim().min(1).max(240),
|
|
3935
|
-
operation: z8.enum(["initialize", "update", "activate", "rollback"]),
|
|
3936
|
-
bindingChanged: z8.boolean(),
|
|
3937
|
-
previousRelease: ImmutableReleaseRefSchema.nullable(),
|
|
3938
|
-
nextRelease: ImmutableReleaseRefSchema,
|
|
3939
|
-
actor: z8.string().trim().min(1).max(240),
|
|
3940
|
-
reason: z8.string().trim().min(1).max(1e4),
|
|
3941
|
-
authoringSkillHash: ReleaseHashSchema.nullable(),
|
|
3942
|
-
validation: z8.object({ valid: z8.boolean(), messages: z8.array(z8.string().max(2e3)).max(100) }).strict(),
|
|
3943
|
-
createdAt: ReleaseTimestampSchema,
|
|
3944
|
-
contentHash: ReleaseHashSchema
|
|
3945
|
-
}).strict();
|
|
3946
|
-
function defineReviewProfile(profile) {
|
|
3947
|
-
return RefinerReviewProfileSchema.parse(profile);
|
|
3948
|
-
}
|
|
3949
|
-
function createRefinerRelease(input) {
|
|
3950
|
-
const profile = RefinerReviewProfileSchema.parse(input.profile);
|
|
3951
|
-
const createdAt = input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
3952
|
-
const coreHash = contentHash({ coreVersion: input.coreVersion, corePrompt: input.corePrompt });
|
|
3953
|
-
const profileHash = contentHash(profile);
|
|
3954
|
-
const composedPromptHash = contentHash({ coreHash, profile });
|
|
3955
|
-
const releaseWithoutHash = {
|
|
3956
|
-
schemaVersion: "openpond.refinerRelease.v1",
|
|
3957
|
-
id: `refiner-${composedPromptHash.slice(0, 24)}`,
|
|
3958
|
-
coreVersion: input.coreVersion,
|
|
3959
|
-
coreHash,
|
|
3960
|
-
profile,
|
|
3961
|
-
profileHash,
|
|
3962
|
-
composedPromptHash,
|
|
3963
|
-
createdAt
|
|
3964
|
-
};
|
|
3965
|
-
return RefinerReleaseSchema.parse({
|
|
3966
|
-
...releaseWithoutHash,
|
|
3967
|
-
contentHash: contentHash(releaseWithoutHash)
|
|
3968
|
-
});
|
|
3969
|
-
}
|
|
3970
|
-
function refinerProfilePrompt(profile) {
|
|
3971
|
-
const parsed = RefinerReviewProfileSchema.parse(profile);
|
|
3972
|
-
return [
|
|
3973
|
-
`Review profile: ${parsed.name} (${parsed.id}@${parsed.version})`,
|
|
3974
|
-
`Objective: ${parsed.objective}`,
|
|
3975
|
-
`Allowed Harness proposal routes: ${parsed.allowedProposalRoutes.join(", ")}.`,
|
|
3976
|
-
`Allowed external routes: ${parsed.allowedExternalRoutes.join(", ")}.`,
|
|
3977
|
-
...parsed.instructions.map((instruction) => `[${instruction.id}] ${instruction.text}`)
|
|
3978
|
-
].join("\n");
|
|
3979
|
-
}
|
|
3980
|
-
function serializeReviewProfile(profile) {
|
|
3981
|
-
return canonicalJson(RefinerReviewProfileSchema.parse(profile));
|
|
3982
|
-
}
|
|
3983
|
-
|
|
3984
|
-
// ../harness/dist/refiner.js
|
|
3985
|
-
var RefinerNoActionDecisionSchema = z9.object({
|
|
3986
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v1"),
|
|
3987
|
-
decision: z9.literal("no_action"),
|
|
3988
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
3989
|
-
}).strip();
|
|
3990
|
-
var RefinerExternalRouteDecisionSchema = z9.object({
|
|
3991
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v1"),
|
|
3992
|
-
decision: z9.literal("route"),
|
|
3993
|
-
route: z9.enum(["runtime", "product", "taskset", "training"]),
|
|
3994
|
-
summary: z9.string().trim().min(1).max(2e3),
|
|
3995
|
-
expectedOutcome: z9.string().trim().min(1).max(1e4),
|
|
3996
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
3997
|
-
}).strip();
|
|
3998
|
-
var RefinerProposalDecisionSchema = z9.object({
|
|
3999
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v1"),
|
|
4000
|
-
decision: z9.literal("propose"),
|
|
4001
|
-
route: z9.enum(["memory", "prompt", "skill", "agent"]),
|
|
4002
|
-
operation: z9.enum(["create", "update", "delete"]),
|
|
4003
|
-
target: z9.string().trim().min(1).max(2e3),
|
|
4004
|
-
summary: z9.string().trim().min(1).max(2e3),
|
|
4005
|
-
createContent: z9.string().min(1).max(2e4).nullable(),
|
|
4006
|
-
find: z9.string().min(1).max(8e3).nullable(),
|
|
4007
|
-
replace: z9.string().max(8e3).nullable(),
|
|
4008
|
-
expectedOutcome: z9.string().trim().min(1).max(1e4),
|
|
4009
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
4010
|
-
}).strip().superRefine((decision, context) => {
|
|
4011
|
-
if (decision.operation === "create" && (decision.createContent === null || decision.find !== null || decision.replace !== null)) {
|
|
4012
|
-
context.addIssue({
|
|
4013
|
-
code: "custom",
|
|
4014
|
-
message: "create proposals require createContent and null find/replace",
|
|
4015
|
-
path: ["createContent"]
|
|
4016
|
-
});
|
|
4017
|
-
}
|
|
4018
|
-
if (decision.operation === "update" && (decision.createContent !== null || decision.find === null || decision.replace === null)) {
|
|
4019
|
-
context.addIssue({
|
|
4020
|
-
code: "custom",
|
|
4021
|
-
message: "update proposals require one exact find/replace edit and null createContent",
|
|
4022
|
-
path: ["find"]
|
|
4023
|
-
});
|
|
4024
|
-
}
|
|
4025
|
-
if (decision.operation === "delete" && (decision.createContent !== null || decision.find !== null || decision.replace !== null)) {
|
|
4026
|
-
context.addIssue({
|
|
4027
|
-
code: "custom",
|
|
4028
|
-
message: "delete proposals require null createContent/find/replace",
|
|
4029
|
-
path: ["createContent"]
|
|
4030
|
-
});
|
|
4031
|
-
}
|
|
4032
|
-
});
|
|
4033
|
-
var LocalHarnessRefinerDecisionSchema = z9.discriminatedUnion("decision", [
|
|
4034
|
-
RefinerNoActionDecisionSchema,
|
|
4035
|
-
RefinerExternalRouteDecisionSchema,
|
|
4036
|
-
RefinerProposalDecisionSchema
|
|
4037
|
-
]);
|
|
4038
|
-
var LocalHarnessRefinerDecisionV1Schema = LocalHarnessRefinerDecisionSchema;
|
|
4039
|
-
var HarnessRefinerEvidenceBasisSchema = z9.object({
|
|
4040
|
-
kind: z9.enum(["single_deterministic", "recurrent_independent"]),
|
|
4041
|
-
supportingEvidenceIds: z9.array(z9.string().trim().min(1).max(2e3)).min(1).max(100),
|
|
4042
|
-
counterevidence: z9.array(z9.string().trim().min(1).max(2e3)).max(20)
|
|
4043
|
-
}).strict().superRefine((basis, context) => {
|
|
4044
|
-
if (new Set(basis.supportingEvidenceIds).size !== basis.supportingEvidenceIds.length) {
|
|
4045
|
-
context.addIssue({
|
|
4046
|
-
code: "custom",
|
|
4047
|
-
message: "supporting evidence IDs must be unique",
|
|
4048
|
-
path: ["supportingEvidenceIds"]
|
|
4049
|
-
});
|
|
4050
|
-
}
|
|
4051
|
-
if (basis.kind === "recurrent_independent" && basis.supportingEvidenceIds.length < 2) {
|
|
4052
|
-
context.addIssue({
|
|
4053
|
-
code: "custom",
|
|
4054
|
-
message: "recurrent independent evidence requires at least two supplied incidents",
|
|
4055
|
-
path: ["supportingEvidenceIds"]
|
|
4056
|
-
});
|
|
4057
|
-
}
|
|
4058
|
-
});
|
|
4059
|
-
var RefinerNoActionDecisionV2Schema = z9.object({
|
|
4060
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
4061
|
-
decision: z9.literal("no_action"),
|
|
4062
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
4063
|
-
}).strict();
|
|
4064
|
-
var RefinerExternalRouteDecisionV2Schema = z9.object({
|
|
4065
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
4066
|
-
decision: z9.literal("route"),
|
|
4067
|
-
route: z9.enum(["runtime", "product", "taskset", "training"]),
|
|
4068
|
-
summary: z9.string().trim().min(1).max(2e3),
|
|
4069
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema,
|
|
4070
|
-
expectedOutcome: z9.string().trim().min(1).max(1e4),
|
|
4071
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
4072
|
-
}).strict();
|
|
4073
|
-
var RefinerProposalDecisionV2Schema = z9.object({
|
|
4074
|
-
schemaVersion: z9.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
4075
|
-
decision: z9.literal("propose"),
|
|
4076
|
-
route: z9.enum(["memory", "prompt", "skill", "agent"]),
|
|
4077
|
-
operation: z9.enum(["create", "update", "delete"]),
|
|
4078
|
-
target: z9.string().trim().min(1).max(2e3),
|
|
4079
|
-
summary: z9.string().trim().min(1).max(2e3),
|
|
4080
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema,
|
|
4081
|
-
createContent: z9.string().min(1).max(2e4).nullable(),
|
|
4082
|
-
find: z9.string().min(1).max(8e3).nullable(),
|
|
4083
|
-
replace: z9.string().max(8e3).nullable(),
|
|
4084
|
-
expectedOutcome: z9.string().trim().min(1).max(1e4),
|
|
4085
|
-
reason: z9.string().trim().min(1).max(1e4)
|
|
4086
|
-
}).strict().superRefine((decision, context) => {
|
|
4087
|
-
if (decision.operation === "create" && (decision.createContent === null || decision.find !== null || decision.replace !== null)) {
|
|
4088
|
-
context.addIssue({
|
|
4089
|
-
code: "custom",
|
|
4090
|
-
message: "create proposals require createContent and null find/replace",
|
|
4091
|
-
path: ["createContent"]
|
|
4092
|
-
});
|
|
4093
|
-
}
|
|
4094
|
-
if (decision.operation === "update" && (decision.createContent !== null || decision.find === null || decision.replace === null)) {
|
|
4095
|
-
context.addIssue({
|
|
4096
|
-
code: "custom",
|
|
4097
|
-
message: "update proposals require one exact find/replace edit and null createContent",
|
|
4098
|
-
path: ["find"]
|
|
4099
|
-
});
|
|
4100
|
-
}
|
|
4101
|
-
if (decision.operation === "delete" && (decision.createContent !== null || decision.find !== null || decision.replace !== null)) {
|
|
4102
|
-
context.addIssue({
|
|
4103
|
-
code: "custom",
|
|
4104
|
-
message: "delete proposals require null createContent/find/replace",
|
|
4105
|
-
path: ["createContent"]
|
|
4106
|
-
});
|
|
4107
|
-
}
|
|
4108
|
-
});
|
|
4109
|
-
var LocalHarnessRefinerDecisionV2Schema = z9.discriminatedUnion("decision", [
|
|
4110
|
-
RefinerNoActionDecisionV2Schema,
|
|
4111
|
-
RefinerExternalRouteDecisionV2Schema,
|
|
4112
|
-
RefinerProposalDecisionV2Schema
|
|
4113
|
-
]);
|
|
4114
|
-
var LocalHarnessRefinerDecisionAnySchema = z9.union([
|
|
4115
|
-
LocalHarnessRefinerDecisionV1Schema,
|
|
4116
|
-
LocalHarnessRefinerDecisionV2Schema
|
|
4117
|
-
]);
|
|
4118
|
-
var HarnessRefinerCapabilitiesSchema = z9.object({
|
|
4119
|
-
memory: z9.boolean(),
|
|
4120
|
-
prompt: z9.boolean(),
|
|
4121
|
-
skill: z9.boolean(),
|
|
4122
|
-
agent: z9.boolean()
|
|
4123
|
-
}).strict();
|
|
4124
|
-
var SourceKindSchema = z9.enum(["memory", "instruction", "skill", "agent"]);
|
|
4125
|
-
var RefinerSourceFileSchema = z9.object({
|
|
4126
|
-
path: z9.string().trim().min(1).max(2e3),
|
|
4127
|
-
kind: SourceKindSchema,
|
|
4128
|
-
content: z9.string().max(6e4),
|
|
4129
|
-
loaded: z9.boolean()
|
|
4130
|
-
}).strict();
|
|
4131
|
-
var RefinerSourceCatalogEntrySchema = z9.object({
|
|
4132
|
-
path: z9.string().trim().min(1).max(2e3),
|
|
4133
|
-
kind: SourceKindSchema,
|
|
4134
|
-
loaded: z9.boolean()
|
|
4135
|
-
}).strict();
|
|
4136
|
-
var LocalHarnessRefinerEvidenceSchema = z9.object({
|
|
4137
|
-
capabilities: HarnessRefinerCapabilitiesSchema,
|
|
4138
|
-
trigger: z9.record(z9.string(), z9.unknown()),
|
|
4139
|
-
observations: z9.array(z9.record(z9.string(), z9.unknown())).max(20),
|
|
4140
|
-
admissibleEvidenceIds: z9.array(z9.string().trim().min(1).max(2e3)).max(1e4),
|
|
4141
|
-
reviewPacket: z9.object({
|
|
4142
|
-
currentTurn: z9.object({
|
|
4143
|
-
id: z9.string().trim().min(1).max(2e3),
|
|
4144
|
-
status: z9.string().trim().min(1).max(100).nullable(),
|
|
4145
|
-
error: z9.string().max(2100).nullable(),
|
|
4146
|
-
prompt: z9.string().max(8100).nullable(),
|
|
4147
|
-
assistantOutput: z9.string().max(8100).nullable(),
|
|
4148
|
-
assistantOutputLinkCount: z9.number().int().nonnegative()
|
|
4149
|
-
}).strict(),
|
|
4150
|
-
priorConversation: z9.array(z9.object({
|
|
4151
|
-
turnId: z9.string().trim().min(1).max(2e3),
|
|
4152
|
-
status: z9.string().trim().min(1).max(100).nullable(),
|
|
4153
|
-
prompt: z9.string().max(3100).nullable(),
|
|
4154
|
-
assistantOutput: z9.string().max(3100).nullable()
|
|
4155
|
-
}).strict()).max(3),
|
|
4156
|
-
timeline: z9.array(z9.record(z9.string(), z9.unknown())).max(60),
|
|
4157
|
-
artifacts: z9.array(z9.record(z9.string(), z9.unknown())).max(30),
|
|
4158
|
-
artifactDiagnostics: z9.array(z9.record(z9.string(), z9.unknown())).max(20),
|
|
4159
|
-
executionProfile: z9.object({
|
|
4160
|
-
modelRequestCount: z9.number().int().nonnegative(),
|
|
4161
|
-
failedModelRequestCount: z9.number().int().nonnegative(),
|
|
4162
|
-
promptTokens: z9.number().int().nonnegative(),
|
|
4163
|
-
completionTokens: z9.number().int().nonnegative(),
|
|
4164
|
-
totalTokens: z9.number().int().nonnegative(),
|
|
4165
|
-
toolFailureCount: z9.number().int().nonnegative(),
|
|
4166
|
-
retryCount: z9.number().int().nonnegative(),
|
|
4167
|
-
recoveryCount: z9.number().int().nonnegative()
|
|
4168
|
-
}).strict(),
|
|
4169
|
-
priorIncidents: z9.array(z9.record(z9.string(), z9.unknown())).max(3),
|
|
4170
|
-
truncation: z9.object({
|
|
4171
|
-
timelineEventCount: z9.number().int().nonnegative(),
|
|
4172
|
-
includedTimelineEventCount: z9.number().int().nonnegative(),
|
|
4173
|
-
timelineTruncated: z9.boolean()
|
|
4174
|
-
}).strict()
|
|
4175
|
-
}).strict(),
|
|
4176
|
-
runtimeActivation: z9.object({
|
|
4177
|
-
admittedRelease: ImmutableReleaseRefSchema,
|
|
4178
|
-
currentRelease: ImmutableReleaseRefSchema,
|
|
4179
|
-
rebasedOntoCurrent: z9.boolean(),
|
|
4180
|
-
admittedSourceFiles: z9.array(RefinerSourceFileSchema).max(100),
|
|
4181
|
-
admittedSourceCatalog: z9.array(RefinerSourceCatalogEntrySchema).max(1e3)
|
|
4182
|
-
}).strict(),
|
|
4183
|
-
sourceFiles: z9.array(RefinerSourceFileSchema).max(100),
|
|
4184
|
-
sourceCatalog: z9.array(RefinerSourceCatalogEntrySchema).max(1e3),
|
|
4185
|
-
additionalEvidence: z9.unknown().nullable().optional()
|
|
4186
|
-
}).strict();
|
|
4187
|
-
var REFINER_CORE_VERSION = "openpond.refinerCore.v2";
|
|
4188
|
-
var OverlayRefSchema = z9.object({
|
|
4189
|
-
id: z9.string().trim().min(1).max(240),
|
|
4190
|
-
revision: z9.number().int().nonnegative(),
|
|
4191
|
-
contentHash: ReleaseHashSchema
|
|
4192
|
-
}).strict();
|
|
4193
|
-
var HostedHarnessRefinerRequestSchema = z9.object({
|
|
4194
|
-
schemaVersion: z9.literal("openpond.hostedHarnessRefinerRequest.v2"),
|
|
4195
|
-
requestId: z9.string().trim().min(1).max(240),
|
|
4196
|
-
idempotencyKey: z9.string().trim().min(1).max(240),
|
|
4197
|
-
evidenceHash: ReleaseHashSchema,
|
|
4198
|
-
harness: z9.object({
|
|
4199
|
-
admittedRelease: ImmutableReleaseRefSchema,
|
|
4200
|
-
currentRelease: ImmutableReleaseRefSchema,
|
|
4201
|
-
overlay: OverlayRefSchema,
|
|
4202
|
-
workspace: z9.object({
|
|
4203
|
-
id: z9.string().trim().min(1).max(240),
|
|
4204
|
-
revision: z9.number().int().nonnegative(),
|
|
4205
|
-
sourceRevision: ReleaseHashSchema,
|
|
4206
|
-
channelRevision: z9.number().int().nonnegative()
|
|
4207
|
-
}).strict(),
|
|
4208
|
-
capabilities: HarnessRefinerCapabilitiesSchema
|
|
4209
|
-
}).strict(),
|
|
4210
|
-
evidence: LocalHarnessRefinerEvidenceSchema
|
|
4211
|
-
}).strict();
|
|
4212
|
-
var HostedHarnessRefinerUsageSchema = z9.object({
|
|
4213
|
-
promptTokens: z9.number().int().nonnegative(),
|
|
4214
|
-
completionTokens: z9.number().int().nonnegative(),
|
|
4215
|
-
totalTokens: z9.number().int().nonnegative()
|
|
4216
|
-
}).strict();
|
|
4217
|
-
var HostedHarnessRefinerResponseSchema = z9.object({
|
|
4218
|
-
schemaVersion: z9.literal("openpond.hostedHarnessRefinerResponse.v2"),
|
|
4219
|
-
requestId: z9.string().trim().min(1).max(240),
|
|
4220
|
-
evidenceHash: ReleaseHashSchema,
|
|
4221
|
-
admittedRelease: ImmutableReleaseRefSchema,
|
|
4222
|
-
currentRelease: ImmutableReleaseRefSchema,
|
|
4223
|
-
decision: LocalHarnessRefinerDecisionV2Schema,
|
|
4224
|
-
serviceRevision: z9.string().trim().min(1).max(240),
|
|
4225
|
-
usage: HostedHarnessRefinerUsageSchema
|
|
4226
|
-
}).strict();
|
|
4227
|
-
|
|
4228
|
-
// ../harness/dist/refinement-lifecycle.js
|
|
4229
|
-
import { z as z10 } from "zod";
|
|
4230
|
-
var ShortTextSchema = z10.string().trim().min(1).max(2e3);
|
|
4231
|
-
var BoundedTextSchema4 = z10.string().trim().min(1).max(1e5);
|
|
4232
|
-
var HarnessRefinerOperationSchema = z10.enum(["create", "update", "delete"]);
|
|
4233
|
-
var HarnessRefinerInternalRouteSchema = z10.enum([
|
|
4234
|
-
"memory",
|
|
4235
|
-
"prompt",
|
|
4236
|
-
"skill",
|
|
4237
|
-
"agent"
|
|
4238
|
-
]);
|
|
4239
|
-
var HarnessRefinerExternalRouteSchema = z10.enum([
|
|
4240
|
-
"runtime",
|
|
4241
|
-
"product",
|
|
4242
|
-
"taskset",
|
|
4243
|
-
"training"
|
|
4244
|
-
]);
|
|
4245
|
-
var HarnessRefinerActivityResultSchema = z10.enum([
|
|
4246
|
-
"no_action",
|
|
4247
|
-
"routed",
|
|
4248
|
-
"applied",
|
|
4249
|
-
"retained",
|
|
4250
|
-
"failed"
|
|
4251
|
-
]);
|
|
4252
|
-
var HarnessRefinerCritiqueStatusSchema = z10.enum([
|
|
4253
|
-
"not_applicable",
|
|
4254
|
-
"pending",
|
|
4255
|
-
"passed",
|
|
4256
|
-
"rejected",
|
|
4257
|
-
"failed"
|
|
4258
|
-
]);
|
|
4259
|
-
var HarnessRefinerValidationStatusSchema = z10.enum([
|
|
4260
|
-
"not_applicable",
|
|
4261
|
-
"pending",
|
|
4262
|
-
"passed",
|
|
4263
|
-
"failed"
|
|
4264
|
-
]);
|
|
4265
|
-
var HarnessRefinerActivityReceiptContentSchema = z10.object({
|
|
4266
|
-
schemaVersion: z10.literal("openpond.harnessRefinerActivityReceipt.v1"),
|
|
4267
|
-
id: ReleaseIdSchema,
|
|
4268
|
-
runRef: ReleaseIdSchema,
|
|
4269
|
-
turnId: ReleaseIdSchema,
|
|
4270
|
-
result: HarnessRefinerActivityResultSchema,
|
|
4271
|
-
decision: z10.enum(["no_action", "route", "propose"]).nullable(),
|
|
4272
|
-
route: HarnessImprovementRouteSchema.nullable(),
|
|
4273
|
-
operation: HarnessRefinerOperationSchema.nullable(),
|
|
4274
|
-
target: z10.string().trim().min(1).max(2e3).nullable(),
|
|
4275
|
-
summary: ShortTextSchema,
|
|
4276
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema.nullable(),
|
|
4277
|
-
critiqueStatus: HarnessRefinerCritiqueStatusSchema,
|
|
4278
|
-
validationStatus: HarnessRefinerValidationStatusSchema,
|
|
4279
|
-
trigger: ImmutableReleaseRefSchema,
|
|
4280
|
-
outcome: ImmutableReleaseRefSchema.nullable(),
|
|
4281
|
-
proposal: ImmutableReleaseRefSchema.nullable(),
|
|
4282
|
-
applyReceipt: ImmutableReleaseRefSchema.nullable(),
|
|
4283
|
-
inputHarness: ImmutableReleaseRefSchema,
|
|
4284
|
-
outputHarness: ImmutableReleaseRefSchema.nullable(),
|
|
4285
|
-
createdAt: ReleaseTimestampSchema
|
|
4286
|
-
}).strict().superRefine((receipt, context) => {
|
|
4287
|
-
const proposalResult = receipt.result === "applied" || receipt.result === "retained";
|
|
4288
|
-
if (receipt.result === "no_action") {
|
|
4289
|
-
requireFields(context, receipt, {
|
|
4290
|
-
decision: "no_action",
|
|
4291
|
-
route: null,
|
|
4292
|
-
operation: null,
|
|
4293
|
-
target: null,
|
|
4294
|
-
evidenceBasis: null,
|
|
4295
|
-
proposal: null,
|
|
4296
|
-
applyReceipt: null,
|
|
4297
|
-
outputHarness: null,
|
|
4298
|
-
critiqueStatus: "not_applicable",
|
|
4299
|
-
validationStatus: "not_applicable"
|
|
4300
|
-
});
|
|
4301
|
-
} else if (receipt.result === "routed") {
|
|
4302
|
-
if (receipt.decision !== "route" || !HarnessRefinerExternalRouteSchema.safeParse(receipt.route).success || receipt.operation !== null || receipt.target !== null || receipt.evidenceBasis === null || receipt.proposal !== null || receipt.applyReceipt !== null || receipt.outputHarness !== null) {
|
|
4303
|
-
context.addIssue({
|
|
4304
|
-
code: "custom",
|
|
4305
|
-
message: "routed activity requires an external route and evidence basis without proposal state"
|
|
4306
|
-
});
|
|
4307
|
-
}
|
|
4308
|
-
requireFields(context, receipt, {
|
|
4309
|
-
critiqueStatus: "not_applicable",
|
|
4310
|
-
validationStatus: "not_applicable"
|
|
4311
|
-
});
|
|
4312
|
-
} else if (proposalResult) {
|
|
4313
|
-
if (receipt.decision !== "propose" || !HarnessRefinerInternalRouteSchema.safeParse(receipt.route).success || receipt.operation === null || receipt.target === null || receipt.evidenceBasis === null || receipt.proposal === null || receipt.applyReceipt === null) {
|
|
4314
|
-
context.addIssue({
|
|
4315
|
-
code: "custom",
|
|
4316
|
-
message: "applied and retained activity requires complete proposal state"
|
|
4317
|
-
});
|
|
4318
|
-
}
|
|
4319
|
-
if (receipt.result === "applied" && receipt.outputHarness === null) {
|
|
4320
|
-
context.addIssue({
|
|
4321
|
-
code: "custom",
|
|
4322
|
-
message: "applied activity requires the advanced Harness release",
|
|
4323
|
-
path: ["outputHarness"]
|
|
4324
|
-
});
|
|
4325
|
-
}
|
|
4326
|
-
if (receipt.result === "applied" && (receipt.critiqueStatus !== "passed" || receipt.validationStatus !== "passed")) {
|
|
4327
|
-
context.addIssue({
|
|
4328
|
-
code: "custom",
|
|
4329
|
-
message: "applied activity requires passed critique and validation"
|
|
4330
|
-
});
|
|
4331
|
-
}
|
|
4332
|
-
if (receipt.result === "retained" && receipt.outputHarness !== null) {
|
|
4333
|
-
context.addIssue({
|
|
4334
|
-
code: "custom",
|
|
4335
|
-
message: "retained activity cannot report a new Harness release",
|
|
4336
|
-
path: ["outputHarness"]
|
|
4337
|
-
});
|
|
4338
|
-
}
|
|
4339
|
-
} else if (receipt.decision !== null || receipt.route !== null || receipt.operation !== null || receipt.target !== null || receipt.evidenceBasis !== null || receipt.outcome !== null || receipt.proposal !== null || receipt.applyReceipt !== null || receipt.outputHarness !== null) {
|
|
4340
|
-
context.addIssue({
|
|
4341
|
-
code: "custom",
|
|
4342
|
-
message: "failed activity cannot claim a decision, route, proposal, or release transition"
|
|
4343
|
-
});
|
|
4344
|
-
}
|
|
4345
|
-
if (receipt.result !== "failed" && receipt.outcome === null) {
|
|
4346
|
-
context.addIssue({
|
|
4347
|
-
code: "custom",
|
|
4348
|
-
message: "terminal Refiner decisions require an outcome reference",
|
|
4349
|
-
path: ["outcome"]
|
|
4350
|
-
});
|
|
4351
|
-
}
|
|
4352
|
-
});
|
|
4353
|
-
var HarnessRefinerActivityReceiptSchema = HarnessRefinerActivityReceiptContentSchema.extend({
|
|
4354
|
-
contentHash: ReleaseHashSchema
|
|
4355
|
-
}).strict();
|
|
4356
|
-
var HarnessRefinementCandidateStatusSchema = z10.enum([
|
|
4357
|
-
"unresolved",
|
|
4358
|
-
"confirmed",
|
|
4359
|
-
"resolved",
|
|
4360
|
-
"rejected",
|
|
4361
|
-
"expired"
|
|
4362
|
-
]);
|
|
4363
|
-
var HarnessRefinementCandidateResolutionSchema = z10.object({
|
|
4364
|
-
kind: z10.enum([
|
|
4365
|
-
"applied_change",
|
|
4366
|
-
"later_success",
|
|
4367
|
-
"manual_rejection",
|
|
4368
|
-
"source_revoked",
|
|
4369
|
-
"expired"
|
|
4370
|
-
]),
|
|
4371
|
-
reason: BoundedTextSchema4,
|
|
4372
|
-
evidenceRefs: z10.array(ImmutableReleaseRefSchema).max(1e3),
|
|
4373
|
-
resolvedAt: ReleaseTimestampSchema
|
|
4374
|
-
}).strict();
|
|
4375
|
-
var HarnessRefinementCandidateContentSchema = z10.object({
|
|
4376
|
-
schemaVersion: z10.literal("openpond.harnessRefinementCandidate.v1"),
|
|
4377
|
-
id: ReleaseIdSchema,
|
|
4378
|
-
ownerScope: HarnessReviewOwnerScopeSchema,
|
|
4379
|
-
workspaceRef: ReleaseIdSchema,
|
|
4380
|
-
fingerprint: ReleaseHashSchema,
|
|
4381
|
-
recurrenceFamily: z10.string().trim().min(1).max(1e3),
|
|
4382
|
-
statement: BoundedTextSchema4,
|
|
4383
|
-
status: HarnessRefinementCandidateStatusSchema,
|
|
4384
|
-
occurrences: z10.array(HarnessReviewEvidenceRefSchema).max(1e3),
|
|
4385
|
-
counterevidence: z10.array(HarnessReviewEvidenceRefSchema).max(1e3),
|
|
4386
|
-
sourceReviews: z10.array(ImmutableReleaseRefSchema).min(1).max(100),
|
|
4387
|
-
relatedHarnessReleases: z10.array(ImmutableReleaseRefSchema).max(100),
|
|
4388
|
-
firstSeenAt: ReleaseTimestampSchema,
|
|
4389
|
-
lastSeenAt: ReleaseTimestampSchema,
|
|
4390
|
-
lastReviewedAt: ReleaseTimestampSchema,
|
|
4391
|
-
expiresAt: ReleaseTimestampSchema,
|
|
4392
|
-
resolution: HarnessRefinementCandidateResolutionSchema.nullable(),
|
|
4393
|
-
createdAt: ReleaseTimestampSchema,
|
|
4394
|
-
updatedAt: ReleaseTimestampSchema
|
|
4395
|
-
}).strict().superRefine((candidate, context) => {
|
|
4396
|
-
requireUniqueRefs(context, candidate.occurrences, "occurrences");
|
|
4397
|
-
requireUniqueRefs(context, candidate.counterevidence, "counterevidence");
|
|
4398
|
-
requireUniqueRefs(context, candidate.sourceReviews, "sourceReviews");
|
|
4399
|
-
requireUniqueRefs(context, candidate.relatedHarnessReleases, "relatedHarnessReleases");
|
|
4400
|
-
const supportingKeys = new Set(candidate.occurrences.map((item) => item.occurrenceKey));
|
|
4401
|
-
if (candidate.counterevidence.some((item) => supportingKeys.has(item.occurrenceKey))) {
|
|
4402
|
-
context.addIssue({
|
|
4403
|
-
code: "custom",
|
|
4404
|
-
message: "supporting occurrences and counterevidence must be disjoint",
|
|
4405
|
-
path: ["counterevidence"]
|
|
4406
|
-
});
|
|
4407
|
-
}
|
|
4408
|
-
const actionable = candidate.status === "unresolved" || candidate.status === "confirmed";
|
|
4409
|
-
if (actionable && candidate.occurrences.length === 0) {
|
|
4410
|
-
context.addIssue({
|
|
4411
|
-
code: "custom",
|
|
4412
|
-
message: "actionable candidates require at least one supporting occurrence",
|
|
4413
|
-
path: ["occurrences"]
|
|
4414
|
-
});
|
|
4415
|
-
}
|
|
4416
|
-
if (actionable && [...candidate.occurrences, ...candidate.counterevidence].some((item) => item.sourcePolicy.state !== "authorized")) {
|
|
4417
|
-
context.addIssue({
|
|
4418
|
-
code: "custom",
|
|
4419
|
-
message: "actionable candidates may contain only currently authorized evidence",
|
|
4420
|
-
path: ["occurrences"]
|
|
4421
|
-
});
|
|
4422
|
-
}
|
|
4423
|
-
if (actionable !== (candidate.resolution === null)) {
|
|
4424
|
-
context.addIssue({
|
|
4425
|
-
code: "custom",
|
|
4426
|
-
message: "only resolved, rejected, or expired candidates require a resolution",
|
|
4427
|
-
path: ["resolution"]
|
|
4428
|
-
});
|
|
4429
|
-
}
|
|
4430
|
-
if (candidate.status === "expired" && candidate.resolution?.kind !== "expired") {
|
|
4431
|
-
context.addIssue({
|
|
4432
|
-
code: "custom",
|
|
4433
|
-
message: "expired candidates require an expired resolution",
|
|
4434
|
-
path: ["resolution", "kind"]
|
|
4435
|
-
});
|
|
4436
|
-
}
|
|
4437
|
-
if (candidate.status === "rejected" && candidate.resolution && !["manual_rejection", "source_revoked"].includes(candidate.resolution.kind)) {
|
|
4438
|
-
context.addIssue({
|
|
4439
|
-
code: "custom",
|
|
4440
|
-
message: "rejected candidates require a rejection or revocation resolution",
|
|
4441
|
-
path: ["resolution", "kind"]
|
|
4442
|
-
});
|
|
4443
|
-
}
|
|
4444
|
-
if (candidate.status === "resolved" && candidate.resolution && !["applied_change", "later_success"].includes(candidate.resolution.kind)) {
|
|
4445
|
-
context.addIssue({
|
|
4446
|
-
code: "custom",
|
|
4447
|
-
message: "resolved candidates require applied-change or later-success evidence",
|
|
4448
|
-
path: ["resolution", "kind"]
|
|
4449
|
-
});
|
|
4450
|
-
}
|
|
4451
|
-
requireChronology(context, candidate);
|
|
4452
|
-
});
|
|
4453
|
-
var HarnessRefinementCandidateSchema = HarnessRefinementCandidateContentSchema.extend({
|
|
4454
|
-
contentHash: ReleaseHashSchema
|
|
4455
|
-
}).strict();
|
|
4456
|
-
var HarnessRefinementCandidateLifecycleDecisionSchema = z10.enum([
|
|
4457
|
-
"created",
|
|
4458
|
-
"merged",
|
|
4459
|
-
"rejected",
|
|
4460
|
-
"expired",
|
|
4461
|
-
"reopened",
|
|
4462
|
-
"resolved"
|
|
4463
|
-
]);
|
|
4464
|
-
var HarnessRefinementCandidateLifecycleReceiptContentSchema = z10.object({
|
|
4465
|
-
schemaVersion: z10.literal("openpond.harnessRefinementCandidateLifecycleReceipt.v1"),
|
|
4466
|
-
id: ReleaseIdSchema,
|
|
4467
|
-
candidateId: ReleaseIdSchema,
|
|
4468
|
-
decision: HarnessRefinementCandidateLifecycleDecisionSchema,
|
|
4469
|
-
beforeCandidate: ImmutableReleaseRefSchema.nullable(),
|
|
4470
|
-
afterCandidate: ImmutableReleaseRefSchema,
|
|
4471
|
-
review: ImmutableReleaseRefSchema,
|
|
4472
|
-
addedEvidence: z10.array(HarnessReviewEvidenceRefSchema).max(1e3),
|
|
4473
|
-
removedEvidence: z10.array(ImmutableReleaseRefSchema).max(1e3),
|
|
4474
|
-
reason: BoundedTextSchema4,
|
|
4475
|
-
createdAt: ReleaseTimestampSchema
|
|
4476
|
-
}).strict().superRefine((receipt, context) => {
|
|
4477
|
-
if (receipt.decision === "created" !== (receipt.beforeCandidate === null)) {
|
|
4478
|
-
context.addIssue({
|
|
4479
|
-
code: "custom",
|
|
4480
|
-
message: "only candidate creation omits the previous candidate reference",
|
|
4481
|
-
path: ["beforeCandidate"]
|
|
4482
|
-
});
|
|
4483
|
-
}
|
|
4484
|
-
if (receipt.beforeCandidate && receipt.beforeCandidate.contentHash === receipt.afterCandidate.contentHash) {
|
|
4485
|
-
context.addIssue({
|
|
4486
|
-
code: "custom",
|
|
4487
|
-
message: "candidate lifecycle transitions must change candidate content",
|
|
4488
|
-
path: ["afterCandidate"]
|
|
4489
|
-
});
|
|
4490
|
-
}
|
|
4491
|
-
if (["created", "reopened"].includes(receipt.decision) && receipt.addedEvidence.length === 0) {
|
|
4492
|
-
context.addIssue({
|
|
4493
|
-
code: "custom",
|
|
4494
|
-
message: `${receipt.decision} candidate transitions require added evidence`,
|
|
4495
|
-
path: ["addedEvidence"]
|
|
4496
|
-
});
|
|
4497
|
-
}
|
|
4498
|
-
if (receipt.addedEvidence.some((item) => item.sourcePolicy.state !== "authorized")) {
|
|
4499
|
-
context.addIssue({
|
|
4500
|
-
code: "custom",
|
|
4501
|
-
message: "candidate transitions may add only authorized evidence",
|
|
4502
|
-
path: ["addedEvidence"]
|
|
4503
|
-
});
|
|
4504
|
-
}
|
|
4505
|
-
requireUniqueRefs(context, receipt.addedEvidence, "addedEvidence");
|
|
4506
|
-
requireUniqueRefs(context, receipt.removedEvidence, "removedEvidence");
|
|
4507
|
-
const removedKeys = new Set(receipt.removedEvidence.map((item) => refKey(item)));
|
|
4508
|
-
if (receipt.addedEvidence.some((item) => removedKeys.has(refKey(item.evidence)))) {
|
|
4509
|
-
context.addIssue({
|
|
4510
|
-
code: "custom",
|
|
4511
|
-
message: "candidate lifecycle evidence cannot be added and removed together",
|
|
4512
|
-
path: ["removedEvidence"]
|
|
4513
|
-
});
|
|
4514
|
-
}
|
|
4515
|
-
});
|
|
4516
|
-
var HarnessRefinementCandidateLifecycleReceiptSchema = HarnessRefinementCandidateLifecycleReceiptContentSchema.extend({
|
|
4517
|
-
contentHash: ReleaseHashSchema
|
|
4518
|
-
}).strict();
|
|
4519
|
-
var HarnessCrossRunRefinementRequestContentSchema = z10.object({
|
|
4520
|
-
schemaVersion: z10.literal("openpond.harnessCrossRunRefinementRequest.v1"),
|
|
4521
|
-
id: ReleaseIdSchema,
|
|
4522
|
-
ownerScope: HarnessReviewOwnerScopeSchema,
|
|
4523
|
-
workspaceRef: ReleaseIdSchema,
|
|
4524
|
-
candidate: ImmutableReleaseRefSchema,
|
|
4525
|
-
candidateFingerprint: ReleaseHashSchema,
|
|
4526
|
-
review: ImmutableReleaseRefSchema,
|
|
4527
|
-
admittedHarness: ImmutableReleaseRefSchema,
|
|
4528
|
-
evidence: z10.array(HarnessReviewEvidenceRefSchema).min(1).max(1e3),
|
|
4529
|
-
capabilities: HarnessRefinerCapabilitiesSchema,
|
|
4530
|
-
deduplicationKey: ReleaseHashSchema,
|
|
4531
|
-
createdAt: ReleaseTimestampSchema
|
|
4532
|
-
}).strict().superRefine((request, context) => {
|
|
4533
|
-
if (request.evidence.some((item) => item.sourcePolicy.state !== "authorized")) {
|
|
4534
|
-
context.addIssue({
|
|
4535
|
-
code: "custom",
|
|
4536
|
-
message: "cross-run refinement requires currently authorized evidence",
|
|
4537
|
-
path: ["evidence"]
|
|
4538
|
-
});
|
|
4539
|
-
}
|
|
4540
|
-
requireUniqueRefs(context, request.evidence, "evidence");
|
|
4541
|
-
if (!Object.values(request.capabilities).some(Boolean)) {
|
|
4542
|
-
context.addIssue({
|
|
4543
|
-
code: "custom",
|
|
4544
|
-
message: "cross-run refinement requires at least one available Harness capability",
|
|
4545
|
-
path: ["capabilities"]
|
|
4546
|
-
});
|
|
4547
|
-
}
|
|
4548
|
-
const expected = harnessCrossRunRefinementDeduplicationKey(request);
|
|
4549
|
-
if (request.deduplicationKey !== expected) {
|
|
4550
|
-
context.addIssue({
|
|
4551
|
-
code: "custom",
|
|
4552
|
-
message: `cross-run refinement deduplicationKey is ${request.deduplicationKey}; expected ${expected}`,
|
|
4553
|
-
path: ["deduplicationKey"]
|
|
4554
|
-
});
|
|
4555
|
-
}
|
|
4556
|
-
});
|
|
4557
|
-
var HarnessCrossRunRefinementRequestSchema = HarnessCrossRunRefinementRequestContentSchema.extend({
|
|
4558
|
-
contentHash: ReleaseHashSchema
|
|
4559
|
-
}).strict();
|
|
4560
|
-
function harnessCrossRunRefinementDeduplicationKey(input) {
|
|
4561
|
-
return contentHash({
|
|
4562
|
-
schemaVersion: "openpond.harnessCrossRunRefinementIdentity.v1",
|
|
4563
|
-
workspaceRef: input.workspaceRef,
|
|
4564
|
-
candidateFingerprint: input.candidateFingerprint,
|
|
4565
|
-
admittedHarness: input.admittedHarness
|
|
4566
|
-
});
|
|
4567
|
-
}
|
|
4568
|
-
function requireFields(context, value, expected) {
|
|
4569
|
-
for (const [key, expectedValue] of Object.entries(expected)) {
|
|
4570
|
-
if (value[key] === expectedValue)
|
|
4571
|
-
continue;
|
|
4572
|
-
context.addIssue({
|
|
4573
|
-
code: "custom",
|
|
4574
|
-
message: `${key} must be ${String(expectedValue)}`,
|
|
4575
|
-
path: [key]
|
|
4576
|
-
});
|
|
4577
|
-
}
|
|
4578
|
-
}
|
|
4579
|
-
function requireUniqueRefs(context, values, path) {
|
|
4580
|
-
const keys = values.map((value) => refKey(value));
|
|
4581
|
-
if (new Set(keys).size === keys.length)
|
|
4582
|
-
return;
|
|
4583
|
-
context.addIssue({
|
|
4584
|
-
code: "custom",
|
|
4585
|
-
message: `${path} references must be unique`,
|
|
4586
|
-
path: [path]
|
|
4587
|
-
});
|
|
4588
|
-
}
|
|
4589
|
-
function refKey(value) {
|
|
4590
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
4591
|
-
return String(value);
|
|
4592
|
-
const record = value;
|
|
4593
|
-
if (typeof record.occurrenceKey === "string")
|
|
4594
|
-
return record.occurrenceKey;
|
|
4595
|
-
const nested = record.evidence;
|
|
4596
|
-
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
4597
|
-
const evidence = nested;
|
|
4598
|
-
return `${String(evidence.id)}:${String(evidence.contentHash)}`;
|
|
4599
|
-
}
|
|
4600
|
-
return `${String(record.id)}:${String(record.contentHash)}`;
|
|
4601
|
-
}
|
|
4602
|
-
function requireChronology(context, candidate) {
|
|
4603
|
-
const chronology = [
|
|
4604
|
-
["firstSeenAt", candidate.firstSeenAt],
|
|
4605
|
-
["lastSeenAt", candidate.lastSeenAt],
|
|
4606
|
-
["lastReviewedAt", candidate.lastReviewedAt],
|
|
4607
|
-
["updatedAt", candidate.updatedAt],
|
|
4608
|
-
["expiresAt", candidate.expiresAt]
|
|
4609
|
-
];
|
|
4610
|
-
for (let index = 1; index < chronology.length; index += 1) {
|
|
4611
|
-
const previous = chronology[index - 1];
|
|
4612
|
-
const current = chronology[index];
|
|
4613
|
-
if (Date.parse(previous[1]) <= Date.parse(current[1]))
|
|
4614
|
-
continue;
|
|
4615
|
-
context.addIssue({
|
|
4616
|
-
code: "custom",
|
|
4617
|
-
message: `${current[0]} must not precede ${previous[0]}`,
|
|
4618
|
-
path: [current[0]]
|
|
4619
|
-
});
|
|
4620
|
-
}
|
|
4621
|
-
if (Date.parse(candidate.createdAt) > Date.parse(candidate.updatedAt)) {
|
|
4622
|
-
context.addIssue({
|
|
4623
|
-
code: "custom",
|
|
4624
|
-
message: "updatedAt must not precede createdAt",
|
|
4625
|
-
path: ["updatedAt"]
|
|
4626
|
-
});
|
|
4627
|
-
}
|
|
4628
|
-
}
|
|
4629
|
-
|
|
4630
|
-
// src/learning-credentials.ts
|
|
4631
|
-
import { LearningRevisionRefSchema } from "@openpond/evals/learning";
|
|
4632
|
-
import { TaskSplitSchema } from "@openpond/evals/tasksets";
|
|
4633
|
-
var LearningSourceCredentialSchema = z11.object({
|
|
4634
|
-
id: ReleaseIdSchema,
|
|
4635
|
-
scope: ReleaseIdSchema,
|
|
4636
|
-
sourceId: ReleaseIdSchema,
|
|
4637
|
-
name: z11.string().trim().min(1).max(100),
|
|
4638
|
-
keyPrefix: z11.string().min(1).max(100),
|
|
4639
|
-
createdAt: z11.iso.datetime(),
|
|
4640
|
-
expiresAt: z11.iso.datetime(),
|
|
4641
|
-
revokedAt: z11.iso.datetime().nullable()
|
|
4642
|
-
}).strict();
|
|
4643
|
-
var LearningSourceCredentialSecretSchema = z11.string().regex(/^opk_key_[A-Za-z0-9]{16}_[A-Za-z0-9]{48}$/);
|
|
4644
|
-
var LearningSourceCredentialRequestSchema = z11.discriminatedUnion("action", [
|
|
4645
|
-
z11.object({ action: z11.literal("create"), scope: ReleaseIdSchema, sourceId: ReleaseIdSchema, name: z11.string().trim().min(1).max(100), expiresAt: z11.iso.datetime(), operationId: ReleaseIdSchema, apiKey: LearningSourceCredentialSecretSchema }).strict(),
|
|
4646
|
-
z11.object({ action: z11.literal("list"), scope: ReleaseIdSchema, sourceId: ReleaseIdSchema, afterId: ReleaseIdSchema.optional(), limit: z11.number().int().min(1).max(100).default(30) }).strict(),
|
|
4647
|
-
z11.object({ action: z11.literal("revoke"), scope: ReleaseIdSchema, sourceId: ReleaseIdSchema, id: ReleaseIdSchema }).strict()
|
|
4648
|
-
]);
|
|
4649
|
-
var LearningSourceCredentialCreatedSchema = z11.object({ credential: LearningSourceCredentialSchema, apiKey: LearningSourceCredentialSecretSchema }).strict();
|
|
4650
|
-
var LearningSourceCredentialPageSchema = z11.object({ items: z11.array(LearningSourceCredentialSchema).max(100), nextCursor: ReleaseIdSchema.nullable() }).strict();
|
|
4651
|
-
var LearningSourceConfigurationRequestSchema = z11.object({ scope: ReleaseIdSchema, sourceId: ReleaseIdSchema }).strict();
|
|
4652
|
-
var LearningSourceConfigurationSchema = z11.object({
|
|
4653
|
-
scope: ReleaseIdSchema,
|
|
4654
|
-
source: LearningRevisionRefSchema,
|
|
4655
|
-
taskDefinition: LearningRevisionRefSchema,
|
|
4656
|
-
enabled: z11.boolean(),
|
|
4657
|
-
allowedSplits: z11.array(TaskSplitSchema).min(1).max(4)
|
|
4658
|
-
}).strict();
|
|
4659
|
-
function createSourceCredentialRequest(input) {
|
|
4660
|
-
return { ...input, operationId: crypto.randomUUID(), apiKey: `opk_key_${randomToken(16)}_${randomToken(48)}` };
|
|
4661
|
-
}
|
|
4662
|
-
function randomToken(length) {
|
|
4663
|
-
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
4664
|
-
let value = "";
|
|
4665
|
-
while (value.length < length) {
|
|
4666
|
-
for (const byte of crypto.getRandomValues(new Uint8Array(64))) {
|
|
4667
|
-
if (byte < 248) value += alphabet[byte % 62];
|
|
4668
|
-
if (value.length === length) return value;
|
|
4669
|
-
}
|
|
4670
|
-
}
|
|
4671
|
-
return value;
|
|
4672
|
-
}
|
|
4673
|
-
function assertLearningCredentialExpiry(expiresAt, now) {
|
|
4674
|
-
const expires = Date.parse(z11.iso.datetime().parse(expiresAt));
|
|
4675
|
-
if (expires <= now.getTime() || expires > now.getTime() + 90 * 24 * 60 * 60 * 1e3) throw new Error("Source credentials must expire within 90 days.");
|
|
4676
|
-
}
|
|
4677
|
-
|
|
4678
|
-
// src/learning.ts
|
|
4679
|
-
__reExport(learning_exports, learning_star);
|
|
4680
|
-
__reExport(learning_exports, rewards_star);
|
|
4681
|
-
import * as learning_star from "@openpond/evals/learning";
|
|
4682
|
-
import * as rewards_star from "@openpond/evals/rewards";
|
|
4683
|
-
var LearningBatchPublicationSchema = z12.object({
|
|
4684
|
-
batchId: z12.string().trim().min(1).max(500),
|
|
4685
|
-
modelProjectId: z12.string().trim().min(1).max(500)
|
|
4686
|
-
}).strict();
|
|
4687
|
-
var LearningBatchPublicationResultSchema = z12.object({
|
|
4688
|
-
batchId: z12.string().min(1),
|
|
4689
|
-
projectId: z12.string().min(1),
|
|
4690
|
-
tasksetId: z12.string().min(1),
|
|
4691
|
-
releaseId: z12.string().min(1),
|
|
4692
|
-
revision: z12.number().int().positive(),
|
|
4693
|
-
contentHash: z12.string().regex(/^[a-f0-9]{64}$/)
|
|
4694
|
-
}).strict();
|
|
4695
|
-
var OpenPondLearningError = class extends Error {
|
|
4696
|
-
constructor(status, code, message, details) {
|
|
4697
|
-
super(message);
|
|
4698
|
-
this.status = status;
|
|
4699
|
-
this.code = code;
|
|
4700
|
-
this.details = details;
|
|
4701
|
-
this.name = "OpenPondLearningError";
|
|
4702
|
-
}
|
|
4703
|
-
status;
|
|
4704
|
-
code;
|
|
4705
|
-
details;
|
|
4706
|
-
};
|
|
4707
|
-
var OpenPondLearningClient = class {
|
|
4708
|
-
#options;
|
|
4709
|
-
constructor(options) {
|
|
4710
|
-
if (!options.apiKey.trim() || !options.scope.trim()) throw new Error("Learning API key and scope are required.");
|
|
4711
|
-
const url = new URL(options.baseUrl);
|
|
4712
|
-
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash) throw new Error("Learning base URL must be an HTTP(S) endpoint without credentials, query, or fragment.");
|
|
4713
|
-
this.#options = { ...options, baseUrl: url.toString().replace(/\/+$/, "") };
|
|
4714
|
-
}
|
|
4715
|
-
async command(command, options = {}) {
|
|
4716
|
-
assertLearningRequestJson(command);
|
|
4717
|
-
const request = LearningCommandRequestSchema.parse({ scope: this.#options.scope, command });
|
|
4718
|
-
const result = LearningOperationResultSchema.parse(await this.#request("commands", request, options));
|
|
4719
|
-
if (result.operationId !== command.operationId) throw new OpenPondLearningError(502, "operation_identity_mismatch", "Learning response did not match the submitted operation.", null);
|
|
4720
|
-
return result;
|
|
4721
|
-
}
|
|
4722
|
-
submitExample(example, options = {}) {
|
|
4723
|
-
return this.command({ action: "submit_example", operationId: example.idempotencyKey, example }, options);
|
|
4724
|
-
}
|
|
4725
|
-
submitFeedback(feedback, options = {}) {
|
|
4726
|
-
return this.command({ action: "submit_feedback", operationId: feedback.idempotencyKey, feedback }, options);
|
|
4727
|
-
}
|
|
4728
|
-
async get(kind, id, revision, options = {}) {
|
|
4729
|
-
const request = LearningReadRequestSchema.parse({ action: "get", scope: this.#options.scope, kind, id, ...revision === void 0 ? {} : { revision } });
|
|
4730
|
-
return learningResourceSchemas[kind].parse(await this.#request("read", request, options));
|
|
4731
|
-
}
|
|
4732
|
-
async inspectEvidence(evidence, options = {}) {
|
|
4733
|
-
const request = LearningReadRequestSchema.parse({ action: "inspect_evidence", scope: this.#options.scope, evidence });
|
|
4734
|
-
const result = TaskEvidenceInspectionResultSchema.parse(await this.#request("read", request, options));
|
|
4735
|
-
if (!sameLearningRef(result.evidence, evidence)) throw new OpenPondLearningError(502, "evidence_identity_mismatch", "Inspection did not match the requested evidence release.", null);
|
|
4736
|
-
return result;
|
|
4737
|
-
}
|
|
4738
|
-
/** Prepare once with createSourceCredentialRequest and reuse it for retries. */
|
|
4739
|
-
async createSourceCredential(input, options = {}) {
|
|
4740
|
-
const request = LearningSourceCredentialRequestSchema.parse({ ...input, action: "create", scope: this.#options.scope });
|
|
4741
|
-
const result = LearningSourceCredentialCreatedSchema.parse(await this.#request("credentials", request, options));
|
|
4742
|
-
this.#assertCredentialScope(result.credential, input.sourceId);
|
|
4743
|
-
if (result.apiKey !== input.apiKey || !input.apiKey.startsWith(`${result.credential.keyPrefix}_`)) throw new OpenPondLearningError(502, "credential_identity_mismatch", "Credential response did not match the prepared credential.", null);
|
|
4744
|
-
return result;
|
|
4745
|
-
}
|
|
4746
|
-
async listSourceCredentials(sourceId, query = {}, options = {}) {
|
|
4747
|
-
const request = LearningSourceCredentialRequestSchema.parse({ ...query, action: "list", scope: this.#options.scope, sourceId });
|
|
4748
|
-
const result = LearningSourceCredentialPageSchema.parse(await this.#request("credentials", request, options));
|
|
4749
|
-
if (result.items.length > (query.limit ?? 30)) throw new OpenPondLearningError(502, "credential_page_invalid", "Credential response exceeded the requested page size.", null);
|
|
4750
|
-
for (const item of result.items) this.#assertCredentialScope(item, sourceId);
|
|
4751
|
-
return result;
|
|
4752
|
-
}
|
|
4753
|
-
async revokeSourceCredential(sourceId, id, options = {}) {
|
|
4754
|
-
const request = LearningSourceCredentialRequestSchema.parse({ action: "revoke", scope: this.#options.scope, sourceId, id });
|
|
4755
|
-
const result = LearningSourceCredentialSchema.parse(await this.#request("credentials", request, options));
|
|
4756
|
-
this.#assertCredentialScope(result, sourceId);
|
|
4757
|
-
if (result.id !== id || result.revokedAt === null) throw new OpenPondLearningError(502, "credential_revocation_mismatch", "Credential revocation did not match the requested credential.", null);
|
|
4758
|
-
return result;
|
|
4759
|
-
}
|
|
4760
|
-
async sourceConfiguration(sourceId, options = {}) {
|
|
4761
|
-
const request = LearningSourceConfigurationRequestSchema.parse({ scope: this.#options.scope, sourceId });
|
|
4762
|
-
const result = LearningSourceConfigurationSchema.parse(await this.#request("source-config", request, options));
|
|
4763
|
-
if (result.scope !== this.#options.scope || result.source.id !== sourceId) throw new OpenPondLearningError(502, "source_identity_mismatch", "Source configuration did not match the requested source.", null);
|
|
4764
|
-
return result;
|
|
4765
|
-
}
|
|
4766
|
-
#assertCredentialScope(value, sourceId) {
|
|
4767
|
-
if (value.scope !== this.#options.scope || value.sourceId !== sourceId) throw new OpenPondLearningError(502, "credential_scope_mismatch", "Credential response did not match the requested source.", null);
|
|
4768
|
-
}
|
|
4769
|
-
async list(kind, query = {}, options = {}) {
|
|
4770
|
-
const request = LearningReadRequestSchema.parse({ action: "list", scope: this.#options.scope, kind, ...query });
|
|
4771
|
-
return z12.object({ items: z12.array(learningResourceSchemas[kind]).max(100), nextCursor: z12.string().nullable() }).strict().parse(await this.#request("read", request, options));
|
|
4772
|
-
}
|
|
4773
|
-
/** Hosted publication only: stores an immutable package and attaches it, without starting training. */
|
|
4774
|
-
async publishBatch(input, options = {}) {
|
|
4775
|
-
const request = LearningBatchPublicationSchema.parse(input);
|
|
4776
|
-
const result = LearningBatchPublicationResultSchema.parse(await this.#request("publish-batch", { ...request, scope: this.#options.scope }, options));
|
|
4777
|
-
if (result.batchId !== request.batchId) throw new OpenPondLearningError(502, "batch_identity_mismatch", "Published batch response did not match the requested batch.", null);
|
|
4778
|
-
return result;
|
|
4779
|
-
}
|
|
4780
|
-
async #request(endpoint, body, options) {
|
|
4781
|
-
assertBoundedTaskJson(body, 16777216);
|
|
4782
|
-
const response = await (this.#options.fetch ?? globalThis.fetch)(`${this.#options.baseUrl}/v1/learning/${endpoint}`, {
|
|
4783
|
-
method: "POST",
|
|
4784
|
-
headers: { Authorization: `Bearer ${this.#options.apiKey}`, "Content-Type": "application/json", Accept: "application/json", "X-OpenPond-Team-Id": this.#options.scope },
|
|
4785
|
-
body: JSON.stringify(body),
|
|
4786
|
-
signal: options.signal,
|
|
4787
|
-
redirect: "error"
|
|
4788
|
-
});
|
|
4789
|
-
const payload = await readBoundedLearningResponse(response);
|
|
4790
|
-
if (!response.ok) {
|
|
4791
|
-
const error = z12.object({ code: z12.string().optional(), error: z12.string().optional() }).passthrough().safeParse(payload);
|
|
4792
|
-
throw new OpenPondLearningError(response.status, error.success ? error.data.code ?? "learning_request_failed" : "learning_request_failed", error.success ? error.data.error ?? `Learning request failed (${response.status}).` : `Learning request failed (${response.status}).`, payload);
|
|
4793
|
-
}
|
|
4794
|
-
return payload;
|
|
4795
|
-
}
|
|
4796
|
-
};
|
|
4797
|
-
async function readBoundedLearningResponse(response) {
|
|
4798
|
-
const maximumBytes = 16777216;
|
|
4799
|
-
const reader = response.body?.getReader();
|
|
4800
|
-
if (!reader) throw new OpenPondLearningError(response.status, "empty_response", "Learning response was empty.", null);
|
|
4801
|
-
const decoder = new TextDecoder();
|
|
4802
|
-
let bytes = 0;
|
|
4803
|
-
let text = "";
|
|
4804
|
-
try {
|
|
4805
|
-
while (true) {
|
|
4806
|
-
const next = await reader.read();
|
|
4807
|
-
if (next.done) break;
|
|
4808
|
-
bytes += next.value.byteLength;
|
|
4809
|
-
if (bytes > maximumBytes) throw new OpenPondLearningError(response.status, "response_too_large", "Learning response exceeded 16 MiB; request a smaller page.", null);
|
|
4810
|
-
text += decoder.decode(next.value, { stream: true });
|
|
4811
|
-
}
|
|
4812
|
-
text += decoder.decode();
|
|
4813
|
-
const value = JSON.parse(text);
|
|
4814
|
-
assertBoundedTaskJson(value, maximumBytes);
|
|
4815
|
-
return value;
|
|
4816
|
-
} finally {
|
|
4817
|
-
await reader.cancel();
|
|
4818
|
-
reader.releaseLock();
|
|
4819
|
-
}
|
|
4820
|
-
}
|
|
4821
|
-
|
|
4822
2367
|
// ../cloud/dist/sandbox/types/runtime-profiles.js
|
|
4823
2368
|
var SANDBOX_RUNTIME_PROFILE_IDS = [
|
|
4824
2369
|
"openpond-generic-v1",
|