openpond-sdk 0.1.4 → 0.1.6
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/LEARNING.md +45 -0
- package/dist/index.js +1846 -418
- package/dist/index.js.map +4 -4
- package/dist/learning.js +1950 -15
- package/dist/learning.js.map +4 -4
- package/dist/types/packages/sdk/src/learning-credentials.d.ts +100 -0
- package/dist/types/packages/sdk/src/learning-credentials.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/learning.d.ts +59 -0
- package/dist/types/packages/sdk/src/learning.d.ts.map +1 -1
- package/examples/learning/submit.py +1 -1
- package/examples/learning/submit.ts +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2710,12 +2710,19 @@ var learning_exports = {};
|
|
|
2710
2710
|
__export(learning_exports, {
|
|
2711
2711
|
LearningBatchPublicationResultSchema: () => LearningBatchPublicationResultSchema,
|
|
2712
2712
|
LearningBatchPublicationSchema: () => LearningBatchPublicationSchema,
|
|
2713
|
+
LearningSourceConfigurationRequestSchema: () => LearningSourceConfigurationRequestSchema,
|
|
2714
|
+
LearningSourceConfigurationSchema: () => LearningSourceConfigurationSchema,
|
|
2715
|
+
LearningSourceCredentialCreatedSchema: () => LearningSourceCredentialCreatedSchema,
|
|
2716
|
+
LearningSourceCredentialPageSchema: () => LearningSourceCredentialPageSchema,
|
|
2717
|
+
LearningSourceCredentialRequestSchema: () => LearningSourceCredentialRequestSchema,
|
|
2718
|
+
LearningSourceCredentialSchema: () => LearningSourceCredentialSchema,
|
|
2719
|
+
LearningSourceCredentialSecretSchema: () => LearningSourceCredentialSecretSchema,
|
|
2713
2720
|
OpenPondLearningClient: () => OpenPondLearningClient,
|
|
2714
|
-
OpenPondLearningError: () => OpenPondLearningError
|
|
2721
|
+
OpenPondLearningError: () => OpenPondLearningError,
|
|
2722
|
+
assertLearningCredentialExpiry: () => assertLearningCredentialExpiry,
|
|
2723
|
+
createSourceCredentialRequest: () => createSourceCredentialRequest
|
|
2715
2724
|
});
|
|
2716
|
-
|
|
2717
|
-
__reExport(learning_exports, rewards_star);
|
|
2718
|
-
import { z } from "zod";
|
|
2725
|
+
import { z as z12 } from "zod";
|
|
2719
2726
|
import {
|
|
2720
2727
|
LearningCommandRequestSchema,
|
|
2721
2728
|
LearningOperationResultSchema,
|
|
@@ -2726,121 +2733,12 @@ import {
|
|
|
2726
2733
|
learningResourceSchemas
|
|
2727
2734
|
} from "@openpond/evals/learning";
|
|
2728
2735
|
import { assertBoundedTaskJson } from "@openpond/evals/task-schema";
|
|
2729
|
-
import * as learning_star from "@openpond/evals/learning";
|
|
2730
|
-
import * as rewards_star from "@openpond/evals/rewards";
|
|
2731
|
-
var LearningBatchPublicationSchema = z.object({
|
|
2732
|
-
batchId: z.string().trim().min(1).max(500),
|
|
2733
|
-
modelProjectId: z.string().trim().min(1).max(500)
|
|
2734
|
-
}).strict();
|
|
2735
|
-
var LearningBatchPublicationResultSchema = z.object({
|
|
2736
|
-
batchId: z.string().min(1),
|
|
2737
|
-
projectId: z.string().min(1),
|
|
2738
|
-
tasksetId: z.string().min(1),
|
|
2739
|
-
releaseId: z.string().min(1),
|
|
2740
|
-
revision: z.number().int().positive(),
|
|
2741
|
-
contentHash: z.string().regex(/^[a-f0-9]{64}$/)
|
|
2742
|
-
}).strict();
|
|
2743
|
-
var OpenPondLearningError = class extends Error {
|
|
2744
|
-
constructor(status, code, message, details) {
|
|
2745
|
-
super(message);
|
|
2746
|
-
this.status = status;
|
|
2747
|
-
this.code = code;
|
|
2748
|
-
this.details = details;
|
|
2749
|
-
this.name = "OpenPondLearningError";
|
|
2750
|
-
}
|
|
2751
|
-
status;
|
|
2752
|
-
code;
|
|
2753
|
-
details;
|
|
2754
|
-
};
|
|
2755
|
-
var OpenPondLearningClient = class {
|
|
2756
|
-
#options;
|
|
2757
|
-
constructor(options) {
|
|
2758
|
-
if (!options.apiKey.trim() || !options.scope.trim()) throw new Error("Learning API key and scope are required.");
|
|
2759
|
-
const url = new URL(options.baseUrl);
|
|
2760
|
-
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.");
|
|
2761
|
-
this.#options = { ...options, baseUrl: url.toString().replace(/\/+$/, "") };
|
|
2762
|
-
}
|
|
2763
|
-
async command(command, options = {}) {
|
|
2764
|
-
assertLearningRequestJson(command);
|
|
2765
|
-
const request = LearningCommandRequestSchema.parse({ scope: this.#options.scope, command });
|
|
2766
|
-
const result = LearningOperationResultSchema.parse(await this.#request("commands", request, options));
|
|
2767
|
-
if (result.operationId !== command.operationId) throw new OpenPondLearningError(502, "operation_identity_mismatch", "Learning response did not match the submitted operation.", null);
|
|
2768
|
-
return result;
|
|
2769
|
-
}
|
|
2770
|
-
submitExample(example, options = {}) {
|
|
2771
|
-
return this.command({ action: "submit_example", operationId: example.idempotencyKey, example }, options);
|
|
2772
|
-
}
|
|
2773
|
-
submitFeedback(feedback, options = {}) {
|
|
2774
|
-
return this.command({ action: "submit_feedback", operationId: feedback.idempotencyKey, feedback }, options);
|
|
2775
|
-
}
|
|
2776
|
-
async get(kind, id, revision, options = {}) {
|
|
2777
|
-
const request = LearningReadRequestSchema.parse({ action: "get", scope: this.#options.scope, kind, id, ...revision === void 0 ? {} : { revision } });
|
|
2778
|
-
return learningResourceSchemas[kind].parse(await this.#request("read", request, options));
|
|
2779
|
-
}
|
|
2780
|
-
async inspectEvidence(evidence, options = {}) {
|
|
2781
|
-
const request = LearningReadRequestSchema.parse({ action: "inspect_evidence", scope: this.#options.scope, evidence });
|
|
2782
|
-
const result = TaskEvidenceInspectionResultSchema.parse(await this.#request("read", request, options));
|
|
2783
|
-
if (!sameLearningRef(result.evidence, evidence)) throw new OpenPondLearningError(502, "evidence_identity_mismatch", "Inspection did not match the requested evidence release.", null);
|
|
2784
|
-
return result;
|
|
2785
|
-
}
|
|
2786
|
-
async list(kind, query = {}, options = {}) {
|
|
2787
|
-
const request = LearningReadRequestSchema.parse({ action: "list", scope: this.#options.scope, kind, ...query });
|
|
2788
|
-
return z.object({ items: z.array(learningResourceSchemas[kind]).max(100), nextCursor: z.string().nullable() }).strict().parse(await this.#request("read", request, options));
|
|
2789
|
-
}
|
|
2790
|
-
/** Hosted publication only: stores an immutable package and attaches it, without starting training. */
|
|
2791
|
-
async publishBatch(input, options = {}) {
|
|
2792
|
-
const request = LearningBatchPublicationSchema.parse(input);
|
|
2793
|
-
const result = LearningBatchPublicationResultSchema.parse(await this.#request("publish-batch", { ...request, scope: this.#options.scope }, options));
|
|
2794
|
-
if (result.batchId !== request.batchId) throw new OpenPondLearningError(502, "batch_identity_mismatch", "Published batch response did not match the requested batch.", null);
|
|
2795
|
-
return result;
|
|
2796
|
-
}
|
|
2797
|
-
async #request(endpoint, body, options) {
|
|
2798
|
-
assertBoundedTaskJson(body, 16777216);
|
|
2799
|
-
const response = await (this.#options.fetch ?? globalThis.fetch)(`${this.#options.baseUrl}/v1/learning/${endpoint}`, {
|
|
2800
|
-
method: "POST",
|
|
2801
|
-
headers: { Authorization: `Bearer ${this.#options.apiKey}`, "Content-Type": "application/json", Accept: "application/json", "X-OpenPond-Team-Id": this.#options.scope },
|
|
2802
|
-
body: JSON.stringify(body),
|
|
2803
|
-
signal: options.signal,
|
|
2804
|
-
redirect: "error"
|
|
2805
|
-
});
|
|
2806
|
-
const payload = await readBoundedLearningResponse(response);
|
|
2807
|
-
if (!response.ok) {
|
|
2808
|
-
const error = z.object({ code: z.string().optional(), error: z.string().optional() }).passthrough().safeParse(payload);
|
|
2809
|
-
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);
|
|
2810
|
-
}
|
|
2811
|
-
return payload;
|
|
2812
|
-
}
|
|
2813
|
-
};
|
|
2814
|
-
async function readBoundedLearningResponse(response) {
|
|
2815
|
-
const maximumBytes = 16777216;
|
|
2816
|
-
const reader = response.body?.getReader();
|
|
2817
|
-
if (!reader) throw new OpenPondLearningError(response.status, "empty_response", "Learning response was empty.", null);
|
|
2818
|
-
const decoder = new TextDecoder();
|
|
2819
|
-
let bytes = 0;
|
|
2820
|
-
let text = "";
|
|
2821
|
-
try {
|
|
2822
|
-
while (true) {
|
|
2823
|
-
const next = await reader.read();
|
|
2824
|
-
if (next.done) break;
|
|
2825
|
-
bytes += next.value.byteLength;
|
|
2826
|
-
if (bytes > maximumBytes) throw new OpenPondLearningError(response.status, "response_too_large", "Learning response exceeded 16 MiB; request a smaller page.", null);
|
|
2827
|
-
text += decoder.decode(next.value, { stream: true });
|
|
2828
|
-
}
|
|
2829
|
-
text += decoder.decode();
|
|
2830
|
-
const value = JSON.parse(text);
|
|
2831
|
-
assertBoundedTaskJson(value, maximumBytes);
|
|
2832
|
-
return value;
|
|
2833
|
-
} finally {
|
|
2834
|
-
await reader.cancel();
|
|
2835
|
-
reader.releaseLock();
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
2736
|
|
|
2839
|
-
//
|
|
2840
|
-
import { z as
|
|
2737
|
+
// src/learning-credentials.ts
|
|
2738
|
+
import { z as z11 } from "zod";
|
|
2841
2739
|
|
|
2842
2740
|
// ../harness/dist/common.js
|
|
2843
|
-
import { z
|
|
2741
|
+
import { z } from "zod";
|
|
2844
2742
|
|
|
2845
2743
|
// ../harness/dist/sha256.js
|
|
2846
2744
|
var INITIAL_STATE = new Uint32Array([
|
|
@@ -2984,29 +2882,29 @@ function rotateRight(value, bits) {
|
|
|
2984
2882
|
// ../harness/dist/common.js
|
|
2985
2883
|
var MAX_PORTABLE_PATH_BYTES = 2e3;
|
|
2986
2884
|
var MAX_PORTABLE_ASSET_BYTES = 25e7;
|
|
2987
|
-
var ReleaseIdSchema =
|
|
2988
|
-
var ReleaseHashSchema =
|
|
2989
|
-
var ReleaseTimestampSchema =
|
|
2990
|
-
var MetadataSchema =
|
|
2991
|
-
var ImmutableReleaseRefSchema =
|
|
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({
|
|
2992
2890
|
id: ReleaseIdSchema,
|
|
2993
2891
|
contentHash: ReleaseHashSchema
|
|
2994
2892
|
}).strict();
|
|
2995
|
-
var ImmutableAssetRefSchema =
|
|
2893
|
+
var ImmutableAssetRefSchema = z.object({
|
|
2996
2894
|
id: ReleaseIdSchema,
|
|
2997
|
-
path:
|
|
2895
|
+
path: z.string().trim().min(1).max(MAX_PORTABLE_PATH_BYTES).refine(safeRelativePath),
|
|
2998
2896
|
contentHash: ReleaseHashSchema,
|
|
2999
|
-
sizeBytes:
|
|
3000
|
-
mediaType:
|
|
3001
|
-
visibility:
|
|
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"])
|
|
3002
2900
|
}).strict();
|
|
3003
|
-
var ImmutableArtifactRefSchema =
|
|
2901
|
+
var ImmutableArtifactRefSchema = z.object({
|
|
3004
2902
|
id: ReleaseIdSchema,
|
|
3005
2903
|
contentHash: ReleaseHashSchema,
|
|
3006
|
-
mediaType:
|
|
3007
|
-
sizeBytes:
|
|
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)
|
|
3008
2906
|
}).strict();
|
|
3009
|
-
var FailureClassSchema =
|
|
2907
|
+
var FailureClassSchema = z.enum([
|
|
3010
2908
|
"policy_failure",
|
|
3011
2909
|
"grader_failure",
|
|
3012
2910
|
"environment_failure",
|
|
@@ -3038,359 +2936,1889 @@ function sortValue(value) {
|
|
|
3038
2936
|
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortValue(child)]));
|
|
3039
2937
|
}
|
|
3040
2938
|
|
|
3041
|
-
// ../harness/dist/
|
|
3042
|
-
import { z as
|
|
3043
|
-
var
|
|
3044
|
-
var
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
};
|
|
3080
|
-
var RefinerReleaseSchema = z3.object({
|
|
3081
|
-
schemaVersion: z3.literal("openpond.refinerRelease.v1"),
|
|
3082
|
-
id: z3.string().trim().min(1).max(240),
|
|
3083
|
-
coreVersion: z3.string().trim().min(1).max(120),
|
|
3084
|
-
coreHash: ReleaseHashSchema,
|
|
3085
|
-
profile: RefinerReviewProfileSchema,
|
|
3086
|
-
profileHash: ReleaseHashSchema,
|
|
3087
|
-
composedPromptHash: ReleaseHashSchema,
|
|
3088
|
-
createdAt: ReleaseTimestampSchema,
|
|
3089
|
-
contentHash: ReleaseHashSchema
|
|
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
|
|
3090
2977
|
}).strict();
|
|
3091
|
-
var
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
release: ImmutableReleaseRefSchema,
|
|
3096
|
-
updatedAt: ReleaseTimestampSchema
|
|
2978
|
+
var HarnessReviewSourcePolicyRefSchema = z2.object({
|
|
2979
|
+
policy: ImmutableReleaseRefSchema,
|
|
2980
|
+
state: z2.enum(["authorized", "revoked", "deleted", "expired"]),
|
|
2981
|
+
checkedAt: ReleaseTimestampSchema
|
|
3097
2982
|
}).strict();
|
|
3098
|
-
var
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
actor: z3.string().trim().min(1).max(240),
|
|
3106
|
-
reason: z3.string().trim().min(1).max(1e4),
|
|
3107
|
-
authoringSkillHash: ReleaseHashSchema.nullable(),
|
|
3108
|
-
validation: z3.object({ valid: z3.boolean(), messages: z3.array(z3.string().max(2e3)).max(100) }).strict(),
|
|
3109
|
-
createdAt: ReleaseTimestampSchema,
|
|
3110
|
-
contentHash: ReleaseHashSchema
|
|
2983
|
+
var HarnessReviewEvidenceRefSchema = z2.object({
|
|
2984
|
+
evidence: ImmutableReleaseRefSchema,
|
|
2985
|
+
kind: HarnessReviewEvidenceKindSchema,
|
|
2986
|
+
sourceRef: ReleaseIdSchema,
|
|
2987
|
+
sourcePolicy: HarnessReviewSourcePolicyRefSchema,
|
|
2988
|
+
occurrenceKey: ReleaseHashSchema,
|
|
2989
|
+
occurredAt: ReleaseTimestampSchema
|
|
3111
2990
|
}).strict();
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
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) {
|
|
3178
3059
|
context.addIssue({
|
|
3179
3060
|
code: "custom",
|
|
3180
|
-
message: "
|
|
3181
|
-
path: ["
|
|
3061
|
+
message: "selected review evidence must be unique",
|
|
3062
|
+
path: ["selectedEvidence"]
|
|
3182
3063
|
});
|
|
3183
3064
|
}
|
|
3184
|
-
if (
|
|
3065
|
+
if (receipt.selectedEvidence.some((item) => item.sourcePolicy.state !== "authorized")) {
|
|
3185
3066
|
context.addIssue({
|
|
3186
3067
|
code: "custom",
|
|
3187
|
-
message: "
|
|
3188
|
-
path: ["
|
|
3068
|
+
message: "selected review evidence must be authorized at review time",
|
|
3069
|
+
path: ["selectedEvidence"]
|
|
3189
3070
|
});
|
|
3190
3071
|
}
|
|
3191
|
-
if (
|
|
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) {
|
|
3192
3087
|
context.addIssue({
|
|
3193
3088
|
code: "custom",
|
|
3194
|
-
message: "
|
|
3195
|
-
path: ["createContent"]
|
|
3089
|
+
message: "actionable review receipts require a claim and selected evidence"
|
|
3196
3090
|
});
|
|
3197
3091
|
}
|
|
3198
|
-
|
|
3199
|
-
var LocalHarnessRefinerDecisionSchema = z4.discriminatedUnion("decision", [
|
|
3200
|
-
RefinerNoActionDecisionSchema,
|
|
3201
|
-
RefinerExternalRouteDecisionSchema,
|
|
3202
|
-
RefinerProposalDecisionSchema
|
|
3203
|
-
]);
|
|
3204
|
-
var LocalHarnessRefinerDecisionV1Schema = LocalHarnessRefinerDecisionSchema;
|
|
3205
|
-
var HarnessRefinerEvidenceBasisSchema = z4.object({
|
|
3206
|
-
kind: z4.enum(["single_deterministic", "recurrent_independent"]),
|
|
3207
|
-
supportingEvidenceIds: z4.array(z4.string().trim().min(1).max(2e3)).min(1).max(100),
|
|
3208
|
-
counterevidence: z4.array(z4.string().trim().min(1).max(2e3)).max(20)
|
|
3209
|
-
}).strict().superRefine((basis, context) => {
|
|
3210
|
-
if (new Set(basis.supportingEvidenceIds).size !== basis.supportingEvidenceIds.length) {
|
|
3092
|
+
if (receipt.classification === "runtime" && receipt.nextAuthority !== "runtime_service") {
|
|
3211
3093
|
context.addIssue({
|
|
3212
3094
|
code: "custom",
|
|
3213
|
-
message: "
|
|
3214
|
-
path: ["
|
|
3095
|
+
message: "runtime classifications route to runtime-service authority",
|
|
3096
|
+
path: ["nextAuthority"]
|
|
3215
3097
|
});
|
|
3216
3098
|
}
|
|
3217
|
-
if (
|
|
3099
|
+
if (receipt.classification === "product" && receipt.nextAuthority !== "product_team") {
|
|
3218
3100
|
context.addIssue({
|
|
3219
3101
|
code: "custom",
|
|
3220
|
-
message: "
|
|
3221
|
-
path: ["
|
|
3102
|
+
message: "product classifications route to product-team authority",
|
|
3103
|
+
path: ["nextAuthority"]
|
|
3222
3104
|
});
|
|
3223
3105
|
}
|
|
3224
|
-
|
|
3225
|
-
var RefinerNoActionDecisionV2Schema = z4.object({
|
|
3226
|
-
schemaVersion: z4.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
3227
|
-
decision: z4.literal("no_action"),
|
|
3228
|
-
reason: z4.string().trim().min(1).max(1e4)
|
|
3229
|
-
}).strict();
|
|
3230
|
-
var RefinerExternalRouteDecisionV2Schema = z4.object({
|
|
3231
|
-
schemaVersion: z4.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
3232
|
-
decision: z4.literal("route"),
|
|
3233
|
-
route: z4.enum(["runtime", "product", "taskset", "training"]),
|
|
3234
|
-
summary: z4.string().trim().min(1).max(2e3),
|
|
3235
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema,
|
|
3236
|
-
expectedOutcome: z4.string().trim().min(1).max(1e4),
|
|
3237
|
-
reason: z4.string().trim().min(1).max(1e4)
|
|
3238
|
-
}).strict();
|
|
3239
|
-
var RefinerProposalDecisionV2Schema = z4.object({
|
|
3240
|
-
schemaVersion: z4.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
3241
|
-
decision: z4.literal("propose"),
|
|
3242
|
-
route: z4.enum(["memory", "prompt", "skill", "agent"]),
|
|
3243
|
-
operation: z4.enum(["create", "update", "delete"]),
|
|
3244
|
-
target: z4.string().trim().min(1).max(2e3),
|
|
3245
|
-
summary: z4.string().trim().min(1).max(2e3),
|
|
3246
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema,
|
|
3247
|
-
createContent: z4.string().min(1).max(2e4).nullable(),
|
|
3248
|
-
find: z4.string().min(1).max(8e3).nullable(),
|
|
3249
|
-
replace: z4.string().max(8e3).nullable(),
|
|
3250
|
-
expectedOutcome: z4.string().trim().min(1).max(1e4),
|
|
3251
|
-
reason: z4.string().trim().min(1).max(1e4)
|
|
3252
|
-
}).strict().superRefine((decision, context) => {
|
|
3253
|
-
if (decision.operation === "create" && (decision.createContent === null || decision.find !== null || decision.replace !== null)) {
|
|
3106
|
+
if (receipt.classification === "taskset" && receipt.nextAuthority !== "human_review") {
|
|
3254
3107
|
context.addIssue({
|
|
3255
3108
|
code: "custom",
|
|
3256
|
-
message: "
|
|
3257
|
-
path: ["createContent"]
|
|
3109
|
+
message: "Taskset classifications require human review"
|
|
3258
3110
|
});
|
|
3259
3111
|
}
|
|
3260
|
-
if (
|
|
3112
|
+
if (receipt.classification === "model_improvement" && (!receipt.evaluation || !receipt.trainingQualification || !["human_review", "training_system"].includes(receipt.nextAuthority))) {
|
|
3261
3113
|
context.addIssue({
|
|
3262
3114
|
code: "custom",
|
|
3263
|
-
message: "
|
|
3264
|
-
path: ["find"]
|
|
3115
|
+
message: "model-improvement classifications require Evaluation and qualification refs plus explicit authority"
|
|
3265
3116
|
});
|
|
3266
3117
|
}
|
|
3267
|
-
|
|
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)) {
|
|
3268
3164
|
context.addIssue({
|
|
3269
3165
|
code: "custom",
|
|
3270
|
-
message: "
|
|
3271
|
-
path: ["
|
|
3166
|
+
message: "Harness maintenance requires a candidate disposition; external routes require null",
|
|
3167
|
+
path: ["candidateDisposition"]
|
|
3272
3168
|
});
|
|
3273
3169
|
}
|
|
3274
3170
|
});
|
|
3275
|
-
var
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
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
|
|
3283
3188
|
]);
|
|
3284
|
-
var
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
agent: z4.boolean()
|
|
3289
|
-
}).strict();
|
|
3290
|
-
var SourceKindSchema = z4.enum(["memory", "instruction", "skill", "agent"]);
|
|
3291
|
-
var RefinerSourceFileSchema = z4.object({
|
|
3292
|
-
path: z4.string().trim().min(1).max(2e3),
|
|
3293
|
-
kind: SourceKindSchema,
|
|
3294
|
-
content: z4.string().max(6e4),
|
|
3295
|
-
loaded: z4.boolean()
|
|
3189
|
+
var HarnessEvaluationReviewNavigationDecisionSchema = z2.object({
|
|
3190
|
+
schemaVersion: z2.literal("openpond.harnessEvaluationReviewNavigationDecision.v1"),
|
|
3191
|
+
selectedEvidenceIds: z2.array(ReleaseIdSchema).min(1).max(50),
|
|
3192
|
+
reason: BoundedTextSchema
|
|
3296
3193
|
}).strict();
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
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)
|
|
3301
3207
|
}).strict();
|
|
3302
|
-
var
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
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()
|
|
3341
4175
|
}).strict(),
|
|
3342
|
-
runtimeActivation:
|
|
4176
|
+
runtimeActivation: z9.object({
|
|
3343
4177
|
admittedRelease: ImmutableReleaseRefSchema,
|
|
3344
4178
|
currentRelease: ImmutableReleaseRefSchema,
|
|
3345
|
-
rebasedOntoCurrent:
|
|
3346
|
-
admittedSourceFiles:
|
|
3347
|
-
admittedSourceCatalog:
|
|
4179
|
+
rebasedOntoCurrent: z9.boolean(),
|
|
4180
|
+
admittedSourceFiles: z9.array(RefinerSourceFileSchema).max(100),
|
|
4181
|
+
admittedSourceCatalog: z9.array(RefinerSourceCatalogEntrySchema).max(1e3)
|
|
3348
4182
|
}).strict(),
|
|
3349
|
-
sourceFiles:
|
|
3350
|
-
sourceCatalog:
|
|
3351
|
-
additionalEvidence:
|
|
4183
|
+
sourceFiles: z9.array(RefinerSourceFileSchema).max(100),
|
|
4184
|
+
sourceCatalog: z9.array(RefinerSourceCatalogEntrySchema).max(1e3),
|
|
4185
|
+
additionalEvidence: z9.unknown().nullable().optional()
|
|
3352
4186
|
}).strict();
|
|
3353
4187
|
var REFINER_CORE_VERSION = "openpond.refinerCore.v2";
|
|
3354
|
-
var OverlayRefSchema =
|
|
3355
|
-
id:
|
|
3356
|
-
revision:
|
|
4188
|
+
var OverlayRefSchema = z9.object({
|
|
4189
|
+
id: z9.string().trim().min(1).max(240),
|
|
4190
|
+
revision: z9.number().int().nonnegative(),
|
|
3357
4191
|
contentHash: ReleaseHashSchema
|
|
3358
4192
|
}).strict();
|
|
3359
|
-
var HostedHarnessRefinerRequestSchema =
|
|
3360
|
-
schemaVersion:
|
|
3361
|
-
requestId:
|
|
3362
|
-
idempotencyKey:
|
|
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),
|
|
3363
4197
|
evidenceHash: ReleaseHashSchema,
|
|
3364
|
-
harness:
|
|
4198
|
+
harness: z9.object({
|
|
3365
4199
|
admittedRelease: ImmutableReleaseRefSchema,
|
|
3366
4200
|
currentRelease: ImmutableReleaseRefSchema,
|
|
3367
4201
|
overlay: OverlayRefSchema,
|
|
3368
|
-
workspace:
|
|
3369
|
-
id:
|
|
3370
|
-
revision:
|
|
4202
|
+
workspace: z9.object({
|
|
4203
|
+
id: z9.string().trim().min(1).max(240),
|
|
4204
|
+
revision: z9.number().int().nonnegative(),
|
|
3371
4205
|
sourceRevision: ReleaseHashSchema,
|
|
3372
|
-
channelRevision:
|
|
4206
|
+
channelRevision: z9.number().int().nonnegative()
|
|
3373
4207
|
}).strict(),
|
|
3374
4208
|
capabilities: HarnessRefinerCapabilitiesSchema
|
|
3375
4209
|
}).strict(),
|
|
3376
4210
|
evidence: LocalHarnessRefinerEvidenceSchema
|
|
3377
4211
|
}).strict();
|
|
3378
|
-
var HostedHarnessRefinerUsageSchema =
|
|
3379
|
-
promptTokens:
|
|
3380
|
-
completionTokens:
|
|
3381
|
-
totalTokens:
|
|
4212
|
+
var HostedHarnessRefinerUsageSchema = z9.object({
|
|
4213
|
+
promptTokens: z9.number().int().nonnegative(),
|
|
4214
|
+
completionTokens: z9.number().int().nonnegative(),
|
|
4215
|
+
totalTokens: z9.number().int().nonnegative()
|
|
3382
4216
|
}).strict();
|
|
3383
|
-
var HostedHarnessRefinerResponseSchema =
|
|
3384
|
-
schemaVersion:
|
|
3385
|
-
requestId:
|
|
4217
|
+
var HostedHarnessRefinerResponseSchema = z9.object({
|
|
4218
|
+
schemaVersion: z9.literal("openpond.hostedHarnessRefinerResponse.v2"),
|
|
4219
|
+
requestId: z9.string().trim().min(1).max(240),
|
|
3386
4220
|
evidenceHash: ReleaseHashSchema,
|
|
3387
4221
|
admittedRelease: ImmutableReleaseRefSchema,
|
|
3388
4222
|
currentRelease: ImmutableReleaseRefSchema,
|
|
3389
4223
|
decision: LocalHarnessRefinerDecisionV2Schema,
|
|
3390
|
-
serviceRevision:
|
|
4224
|
+
serviceRevision: z9.string().trim().min(1).max(240),
|
|
3391
4225
|
usage: HostedHarnessRefinerUsageSchema
|
|
3392
4226
|
}).strict();
|
|
3393
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
|
+
|
|
3394
4822
|
// ../cloud/dist/sandbox/types/runtime-profiles.js
|
|
3395
4823
|
var SANDBOX_RUNTIME_PROFILE_IDS = [
|
|
3396
4824
|
"openpond-generic-v1",
|