openpond-sdk 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/TRAINING_PROTOCOL.md +25 -0
- package/dist/{chunk-5KA6NN6I.js → chunk-KIBRMKJQ.js} +34 -1
- package/dist/chunk-KIBRMKJQ.js.map +7 -0
- package/dist/dataset-workspaces.js +1 -1
- package/dist/model-starter-catalog.js +1 -1
- package/dist/model-starters.js +1 -1
- package/dist/taskset-drafts.js +1 -1
- package/dist/taskset-packages.js +1 -1
- package/dist/training-bundle.js +1 -1
- package/dist/training-projects.js +11 -2
- package/dist/training-projects.js.map +2 -2
- package/dist/training.js +5 -1
- package/dist/types/packages/sdk/src/training-preparations.d.ts +181 -0
- package/dist/types/packages/sdk/src/training-preparations.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/training-project-client.d.ts +84 -76
- package/dist/types/packages/sdk/src/training-project-client.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/training-project-contracts.d.ts +10 -0
- package/dist/types/packages/sdk/src/training-project-contracts.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/training.d.ts +83 -0
- package/dist/types/packages/sdk/src/training.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-5KA6NN6I.js.map +0 -7
package/TRAINING_PROTOCOL.md
CHANGED
|
@@ -85,6 +85,7 @@ routes through `createTrainingClient`:
|
|
|
85
85
|
|
|
86
86
|
```text
|
|
87
87
|
POST /v1/training/preparations
|
|
88
|
+
GET /v1/training/preparations?state=prepared&limit=25
|
|
88
89
|
GET /v1/training/preparations/{preparationId}?teamId=
|
|
89
90
|
POST /v1/training/preparations/{preparationId}/start
|
|
90
91
|
POST /v1/training/preparations/{preparationId}/cancel
|
|
@@ -106,6 +107,15 @@ cannot start. Once submitted, use the ordinary job cancellation controls.
|
|
|
106
107
|
Reading a preparation does not authorize starting it; the host rechecks scope,
|
|
107
108
|
creator permissions, resource access, runtime availability and spending limits.
|
|
108
109
|
|
|
110
|
+
`listPreparations(teamId, { state, projectId, afterId, limit })` discovers the
|
|
111
|
+
authenticated user's preparations in that workspace. Filters are optional;
|
|
112
|
+
`limit` defaults to 25 and is bounded at 100. Hosts return descending ID order
|
|
113
|
+
and a `nextCursor` identifying the last returned preparation when another page
|
|
114
|
+
exists. A Project filter uses the preparation's saved association. Listing never
|
|
115
|
+
recompiles inputs or starts jobs. The SDK verifies each immutable receipt and
|
|
116
|
+
rejects wrong-workspace, wrong-filter, duplicate or inconsistent cursor pages.
|
|
117
|
+
Resume using `getPreparation` before an explicit start or discard operation.
|
|
118
|
+
|
|
109
119
|
## Deterministic grading identity
|
|
110
120
|
|
|
111
121
|
For portable training bundles, derive `job.rewardSource` with
|
|
@@ -238,3 +248,18 @@ the Taskset and training bundle.
|
|
|
238
248
|
`createTrainingClient().publishHarnessSource(sourcePackage)` publishes a verified, portable, policy-visible `@openpond/harness` source package to the authenticated workspace without starting a Job. `getHarnessSource({ id, contentHash })` retrieves and verifies that exact release. The endpoints are `PUT` and `GET /v1/training/harness-sources/:releaseId/:contentHash`; they use the existing Training media type and read/write scopes.
|
|
239
249
|
|
|
240
250
|
Hosted learning resolves this immutable source with Desktop closed. Publish before selecting the release on a hosted Model. Preparation still checks the Taskset adapter, required tools, private grading boundary and effective context; publication is not training or quality qualification. Existing prepared Jobs retain their captured source when a newer release is published.
|
|
251
|
+
|
|
252
|
+
## Project Profile source binding
|
|
253
|
+
|
|
254
|
+
SDK 0.9 requires `profileRepositoryId` on Training Project `harness` and `suite`
|
|
255
|
+
targets. This is the authorized hosted repository locator; `source.profileId`
|
|
256
|
+
is the Profile name inside that repository and must not be used as a repository
|
|
257
|
+
ID. Keep both identities through preparation and execution. Existing incomplete
|
|
258
|
+
Profile selections must be reselected explicitly; model targets are unchanged.
|
|
259
|
+
|
|
260
|
+
Suite sources must contain unique definitions from one exact Profile source,
|
|
261
|
+
catalog and Harness release. Their environment hashes may differ. A host must
|
|
262
|
+
resolve the repository under the caller's workspace/permissions, verify the
|
|
263
|
+
internal Profile ID and all selected immutable identities, and fail admission
|
|
264
|
+
when they no longer match. Project association does not grant repository access
|
|
265
|
+
or permission to execute a Profile's connected applications.
|
|
@@ -61,6 +61,18 @@ var TrainingPreparationControlSchema = z.object({
|
|
|
61
61
|
planHash: Hash,
|
|
62
62
|
expectedRevision: z.number().int().positive()
|
|
63
63
|
}).strict();
|
|
64
|
+
var TrainingPreparationListQuerySchema = z.object({
|
|
65
|
+
projectId: Id.optional(),
|
|
66
|
+
state: z.enum(["prepared", "submitted", "cancelled"]).optional(),
|
|
67
|
+
afterId: Id.optional(),
|
|
68
|
+
limit: z.number().int().min(1).max(100).default(25)
|
|
69
|
+
}).strict();
|
|
70
|
+
var TrainingPreparationPageSchema = z.object({
|
|
71
|
+
schemaVersion: z.literal("openpond.trainingPreparationPage.v1"),
|
|
72
|
+
teamId: Id,
|
|
73
|
+
items: z.array(TrainingPreparationReceiptSchema).max(100),
|
|
74
|
+
nextCursor: Id.nullable()
|
|
75
|
+
}).strict();
|
|
64
76
|
async function parseAndVerifyTrainingPreparationReceipt(value) {
|
|
65
77
|
const receipt = TrainingPreparationReceiptSchema.parse(value);
|
|
66
78
|
const { contentHash, ...plan } = receipt.plan;
|
|
@@ -77,6 +89,25 @@ function createTrainingPreparationClient(request) {
|
|
|
77
89
|
return receipt;
|
|
78
90
|
}
|
|
79
91
|
return {
|
|
92
|
+
/** Discover the authenticated user's retained preparations without creating jobs. */
|
|
93
|
+
async listPreparations(teamId, input = {}) {
|
|
94
|
+
const scope = Id.parse(teamId);
|
|
95
|
+
const query = TrainingPreparationListQuerySchema.parse(input);
|
|
96
|
+
const params = new URLSearchParams();
|
|
97
|
+
for (const [key, value] of Object.entries(query)) params.set(key, String(value));
|
|
98
|
+
const page = TrainingPreparationPageSchema.parse(await request(`/v1/training/preparations?${params}`));
|
|
99
|
+
if (page.teamId !== scope || page.items.length > query.limit || new Set(page.items.map((item) => item.plan.id)).size !== page.items.length || page.nextCursor !== null && (page.nextCursor !== page.items.at(-1)?.plan.id || page.nextCursor === query.afterId)) {
|
|
100
|
+
throw new OpenPondProtocolError("training_preparation_page_mismatch", "The preparation page does not match its workspace or cursor.");
|
|
101
|
+
}
|
|
102
|
+
const items = await Promise.all(page.items.map(async (item) => {
|
|
103
|
+
const receipt = await read(item, scope);
|
|
104
|
+
if (query.projectId && receipt.plan.request.projectId !== query.projectId || query.state && receipt.state !== query.state) {
|
|
105
|
+
throw new OpenPondProtocolError("training_preparation_page_mismatch", "A preparation does not match the requested Project or state.");
|
|
106
|
+
}
|
|
107
|
+
return receipt;
|
|
108
|
+
}));
|
|
109
|
+
return { ...page, items };
|
|
110
|
+
},
|
|
80
111
|
async prepareRun(input) {
|
|
81
112
|
const parsed = TrainingPreparationRequestSchema.parse(input);
|
|
82
113
|
const receipt = await read(await request("/v1/training/preparations", { method: "POST", body: JSON.stringify(parsed) }), parsed.teamId);
|
|
@@ -909,6 +940,8 @@ export {
|
|
|
909
940
|
TrainingPreparationPlanSchema,
|
|
910
941
|
TrainingPreparationReceiptSchema,
|
|
911
942
|
TrainingPreparationControlSchema,
|
|
943
|
+
TrainingPreparationListQuerySchema,
|
|
944
|
+
TrainingPreparationPageSchema,
|
|
912
945
|
parseAndVerifyTrainingPreparationReceipt,
|
|
913
946
|
TrainingHarnessSourcePublicationSchema,
|
|
914
947
|
TrainingCandidateDecisionRequestSchema,
|
|
@@ -954,4 +987,4 @@ export {
|
|
|
954
987
|
TrainingCapabilitiesSchema,
|
|
955
988
|
createTrainingClient
|
|
956
989
|
};
|
|
957
|
-
//# sourceMappingURL=chunk-
|
|
990
|
+
//# sourceMappingURL=chunk-KIBRMKJQ.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/training.ts", "../src/training-preparations.ts", "../src/training-harness-sources.ts", "../src/training-candidate-decisions.ts", "../src/training-evaluation-results.ts", "../src/training-grading-plan.ts", "../src/training-evaluation-source.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\nimport { createTrainingPreparationClient } from \"./training-preparations.js\";\nexport { TrainingPreparationRequestSchema, TrainingPreparationPlanContentSchema, TrainingPreparationPlanSchema, TrainingPreparationReceiptSchema, TrainingPreparationControlSchema, parseAndVerifyTrainingPreparationReceipt, type TrainingPreparationRequest, type TrainingPreparationPlan, type TrainingPreparationReceipt, type TrainingPreparationControl } from \"./training-preparations.js\";\nexport { TrainingPreparationListQuerySchema, TrainingPreparationPageSchema, type TrainingPreparationListQuery, type TrainingPreparationPage } from \"./training-preparations.js\";\nimport { createTrainingHarnessSourceClient } from \"./training-harness-sources.js\";\nexport { TrainingHarnessSourcePublicationSchema } from \"./training-harness-sources.js\";\nimport { createTrainingCandidateDecisionClient } from \"./training-candidate-decisions.js\";\nexport { TrainingCandidateDecisionRequestSchema, TrainingCandidateDecisionSchema, trainingCandidateDecisionHash, parseAndVerifyTrainingCandidateDecision, type TrainingCandidateDecisionRequest, type TrainingCandidateDecision, type TrainingCandidateDecisionTarget } from \"./training-candidate-decisions.js\";\nimport { parseAndVerifyTrainingEvaluationTaskPage } from \"./training-evaluation-results.js\";\n\nexport { deterministicTrainingRewardSource } from \"./training-grading-plan.js\";\nexport { TRAINING_EVALUATION_SOURCE_PATH, TrainingEvaluationSourceSchema, assertTrainingEvaluationIsolation, trainingEvaluationSourceRef, type TrainingEvaluationSource } from \"./training-evaluation-source.js\";\nexport { TrainingEvaluationTaskResultSchema, TrainingEvaluationTaskPageSchema, trainingEvaluationTaskPageHash, parseAndVerifyTrainingEvaluationTaskPage, type TrainingEvaluationTaskResult, type TrainingEvaluationTaskPage } from \"./training-evaluation-results.js\";\n\nimport {\n ModelProjectBaseModelSchema,\n ModelProjectImmutableRefSchema,\n ModelProjectRecipeDocumentSchema,\n ModelProjectVersionedRefSchema,\n} from \"./model-projects.js\";\nimport {\n OPENPOND_TRAINING_MEDIA_TYPE,\n TRAINING_API_RESPONSE_MAX_BYTES,\n TRAINING_INPUT_ARTIFACT_MAX_BYTES,\n TRAINING_JOB_SUBMISSION_MAX_BYTES,\n OpenPondProtocolError,\n assertCanonicalPayloadSize,\n canonicalSha256,\n parseBoundedJson,\n} from \"./protocol.js\";\n\nexport {\n OPENPOND_TRAINING_MEDIA_TYPE,\n OPENPOND_TRAINING_PROTOCOL_MAJOR,\n TRAINING_API_RESPONSE_MAX_BYTES,\n TRAINING_INPUT_ARTIFACT_MAX_BYTES,\n TRAINING_JOB_SUBMISSION_MAX_BYTES,\n OpenPondProtocolError,\n assertCanonicalPayloadSize,\n canonicalJson,\n canonicalJsonByteLength,\n canonicalSha256,\n parseBoundedJson,\n} from \"./protocol.js\";\n\nconst IdSchema = z.string().trim().min(1).max(500);\nconst HashSchema = z.string().regex(/^[a-f0-9]{64}$/);\nconst TimestampSchema = z.string().datetime({ offset: true });\n\n/**\n * Stages a content-addressed immutable input before Job admission. The payload\n * is deliberately opaque to the transport contract: its declared kind owns\n * the executable schema, while the envelope provides bounded bytes,\n * idempotency, and a stable manifest lookup key.\n */\nexport const TrainingInputArtifactUploadSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingInputArtifactUpload.v2\"),\n kind: z.enum([\"portable_training_bundle\", \"reward_model_dataset\"]),\n idempotencyKey: z.string().trim().min(1).max(500),\n sourceManifest: ModelProjectImmutableRefSchema,\n payload: z.unknown(),\n contentHash: HashSchema,\n })\n .strict();\n\nexport const TrainingInputArtifactSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingInputArtifact.v2\"),\n kind: z.enum([\"portable_training_bundle\", \"reward_model_dataset\"]),\n sourceManifest: ModelProjectImmutableRefSchema,\n artifactRef: z.string().trim().min(1).max(2_000),\n contentHash: HashSchema,\n sizeBytes: z.number().int().positive(),\n createdAt: TimestampSchema,\n })\n .strict();\n\nexport async function trainingInputArtifactUploadHash(\n upload: Omit<TrainingInputArtifactUpload, \"contentHash\"> | TrainingInputArtifactUpload,\n): Promise<string> {\n const { contentHash: _contentHash, ...content } = upload as TrainingInputArtifactUpload;\n return canonicalSha256(content);\n}\n\nexport async function parseAndVerifyTrainingInputArtifactUpload(\n value: unknown,\n): Promise<TrainingInputArtifactUpload> {\n assertCanonicalPayloadSize(\n value,\n TRAINING_INPUT_ARTIFACT_MAX_BYTES,\n \"Training input artifact\",\n );\n const parsed = TrainingInputArtifactUploadSchema.parse(value);\n const expectedHash = await trainingInputArtifactUploadHash(parsed);\n if (parsed.contentHash !== expectedHash) {\n throw new OpenPondProtocolError(\n \"content_hash_mismatch\",\n `Training input artifact contentHash ${parsed.contentHash} does not match ${expectedHash}.`,\n );\n }\n return parsed;\n}\n\nexport const TrainingJobKindSchema = z.enum([\n \"reward_model_train\",\n \"policy_optimize\",\n]);\n\nexport const TrainingJobStateSchema = z.enum([\n \"queued\",\n \"admitting\",\n \"provisioning\",\n \"running\",\n \"stopping\",\n \"cancelling\",\n \"succeeded\",\n \"failed\",\n \"cancelled\",\n]);\n\nexport const TrainingCapabilityRequirementSchema = z\n .object({\n id: IdSchema,\n version: z.string().trim().min(1).max(200).nullable().default(null),\n required: z.boolean().default(true),\n })\n .strict();\n\nexport const TrainingJobSourceSchema = z\n .object({\n modelProject: z\n .object({\n id: IdSchema,\n portableProjectId: IdSchema,\n revision: z.number().int().positive(),\n contentHash: HashSchema,\n })\n .strict(),\n harnessRunManifest: ModelProjectImmutableRefSchema,\n harnessRelease: ModelProjectImmutableRefSchema,\n taskset: ModelProjectVersionedRefSchema,\n tasksetRelease: ModelProjectImmutableRefSchema,\n evaluation: z.object({\n taskset: ModelProjectVersionedRefSchema,\n dataset: ModelProjectImmutableRefSchema,\n }).strict().nullable().optional(),\n dataset: ModelProjectImmutableRefSchema,\n evidenceSets: z.array(ModelProjectImmutableRefSchema).max(10_000),\n })\n .strict();\n\nexport const RewardModelTrainingRequestSchema = z\n .object({\n kind: z.literal(\"reward_model_train\"),\n baseModel: ModelProjectBaseModelSchema,\n preferenceDatasetRelease: ModelProjectImmutableRefSchema,\n processorRelease: ModelProjectImmutableRefSchema,\n recipe: z\n .object({\n schemaVersion: z.literal(\"openpond.rewardModelRecipe.v1\"),\n method: z.literal(\"reward_model\"),\n parameterization: z.literal(\"lora_with_scalar_head\"),\n })\n .catchall(z.unknown()),\n })\n .strict();\n\nconst DeterministicRewardSourceSchema = z\n .object({\n kind: z.literal(\"deterministic\"),\n grader: ModelProjectImmutableRefSchema,\n composer: ModelProjectImmutableRefSchema.nullable().default(null),\n })\n .strict();\n\nconst LearnedRewardSourceSchema = z\n .object({\n kind: z.literal(\"learned_reward\"),\n rewardModelVersion: ModelProjectImmutableRefSchema,\n qualificationReport: ModelProjectImmutableRefSchema.nullable().default(null),\n evaluationReferences: z\n .array(ModelProjectImmutableRefSchema)\n .max(1_000)\n .default([]),\n scorerArtifact: z\n .object({\n artifactRef: z.string().trim().min(1).max(2_000),\n contentHash: HashSchema,\n executionReceipt: ModelProjectImmutableRefSchema,\n })\n .strict(),\n processorRelease: ModelProjectImmutableRefSchema,\n rewardComposerRelease: ModelProjectImmutableRefSchema,\n })\n .strict();\n\nexport const PolicyOptimizationRequestSchema = z\n .object({\n kind: z.literal(\"policy_optimize\"),\n baseModel: ModelProjectBaseModelSchema,\n recipe: ModelProjectRecipeDocumentSchema,\n rewardSource: z.discriminatedUnion(\"kind\", [\n DeterministicRewardSourceSchema,\n LearnedRewardSourceSchema,\n ]),\n resumeFrom: ModelProjectImmutableRefSchema.nullable().default(null),\n })\n .strict();\n\nexport const TrainingJobRequestSchema = z.discriminatedUnion(\"kind\", [\n RewardModelTrainingRequestSchema,\n PolicyOptimizationRequestSchema,\n]);\n\nexport const TrainingJobApprovalSchema = z\n .object({\n approvalHash: HashSchema,\n approvedAt: TimestampSchema,\n exportApproved: z.boolean(),\n maximumSpendUsd: z.number().nonnegative(),\n retentionDays: z.number().int().nonnegative().nullable(),\n region: z.string().trim().min(1).max(200).nullable().default(null),\n })\n .strict();\n\nexport const TrainingJobSubmissionSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingJobSubmission.v2\"),\n idempotencyKey: z.string().trim().min(1).max(500),\n name: z.string().trim().min(1).max(200),\n source: TrainingJobSourceSchema,\n job: TrainingJobRequestSchema,\n requestedCapabilities: z\n .array(TrainingCapabilityRequirementSchema)\n .max(1_000),\n placementObjective: z.enum([\"fast\", \"balanced\", \"economical\"]),\n budget: z\n .object({\n maximumSpendUsd: z.number().nonnegative(),\n maximumWallSeconds: z.number().int().positive(),\n })\n .strict(),\n approval: TrainingJobApprovalSchema,\n contentHash: HashSchema,\n })\n .strict()\n .superRefine((submission, context) => {\n if (submission.approval.maximumSpendUsd !== submission.budget.maximumSpendUsd) {\n context.addIssue({\n code: \"custom\",\n path: [\"approval\", \"maximumSpendUsd\"],\n message: \"Approved spend must equal the immutable Job budget.\",\n });\n }\n });\n\nexport async function trainingJobSubmissionHash(\n submission: Omit<TrainingJobSubmission, \"contentHash\"> | TrainingJobSubmission,\n): Promise<string> {\n const { contentHash: _contentHash, ...content } = submission as TrainingJobSubmission;\n return canonicalSha256(content);\n}\n\nexport async function parseAndVerifyTrainingJobSubmission(\n value: unknown,\n): Promise<TrainingJobSubmission> {\n assertCanonicalPayloadSize(\n value,\n TRAINING_JOB_SUBMISSION_MAX_BYTES,\n \"Training Job submission\",\n );\n const parsed = TrainingJobSubmissionSchema.parse(value);\n const expectedHash = await trainingJobSubmissionHash(parsed);\n if (parsed.contentHash !== expectedHash) {\n throw new OpenPondProtocolError(\n \"content_hash_mismatch\",\n `Training Job contentHash ${parsed.contentHash} does not match ${expectedHash}.`,\n );\n }\n return parsed;\n}\n\nexport const TrainingJobSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingJob.v2\"),\n id: IdSchema,\n teamId: IdSchema,\n kind: TrainingJobKindSchema,\n modelProjectId: IdSchema,\n portableProjectId: IdSchema,\n sourceProjectRevision: z.number().int().positive(),\n submissionHash: HashSchema,\n state: TrainingJobStateSchema,\n phase: z.string().trim().min(1).max(200),\n version: z.number().int().nonnegative(),\n progress: z.number().min(0).max(1),\n rolloutProgress: z\n .object({\n groupsCompleted: z.number().int().nonnegative(),\n groupsTarget: z.number().int().nonnegative(),\n optimizerUpdatesApplied: z.number().int().nonnegative(),\n optimizerUpdatesSkipped: z.number().int().nonnegative(),\n })\n .strict(),\n accruedSpendUsd: z.number().nonnegative(),\n terminalReason: z.string().trim().min(1).max(5_000).nullable(),\n createdAt: TimestampSchema,\n updatedAt: TimestampSchema,\n completedAt: TimestampSchema.nullable(),\n })\n .strict();\n\nexport const TrainingJobPageSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingJobPage.v2\"),\n jobs: z.array(TrainingJobSchema).max(1_000),\n nextCursor: z.string().trim().min(1).max(2_000).nullable(),\n })\n .strict();\n\nexport const TrainingJobEventSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingJobEvent.v2\"),\n id: IdSchema,\n jobId: IdSchema,\n sequence: z.number().int().nonnegative(),\n type: IdSchema,\n phase: z.string().trim().min(1).max(200),\n message: z.string().trim().min(1).max(5_000).nullable(),\n data: z.record(z.string(), z.unknown()).default({}),\n createdAt: TimestampSchema,\n })\n .strict();\n\nexport const TrainingJobLogSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingJobLog.v2\"),\n jobId: IdSchema,\n sequence: z.number().int().nonnegative(),\n level: z.enum([\"debug\", \"info\", \"warning\", \"error\"]),\n message: z.string().max(20_000),\n createdAt: TimestampSchema,\n })\n .strict();\n\nexport const TrainingJobControlRequestSchema = z\n .object({ expectedVersion: z.number().int().nonnegative() })\n .strict();\n\nexport const TrainingJobOutputSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingJobOutput.v2\"),\n id: IdSchema,\n jobId: IdSchema,\n kind: z.enum([\n \"checkpoint\",\n \"adapter\",\n \"scorer\",\n \"metrics\",\n \"evaluation\",\n \"trace\",\n \"receipt\",\n ]),\n artifactRef: z.string().trim().min(1).max(2_000),\n contentHash: HashSchema,\n sizeBytes: z.number().int().nonnegative(),\n metadata: z.record(z.string(), z.unknown()).default({}),\n createdAt: TimestampSchema,\n })\n .strict();\n\nexport const TrainingExecutionReceiptSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingExecutionReceipt.v2\"),\n id: IdSchema,\n teamId: IdSchema,\n jobId: IdSchema,\n submissionHash: HashSchema,\n manifestHash: HashSchema,\n recipeHash: HashSchema,\n capabilityHash: HashSchema,\n runtimeRelease: ModelProjectImmutableRefSchema,\n inputs: z.array(ModelProjectImmutableRefSchema).max(10_000),\n outputs: z.array(ModelProjectImmutableRefSchema).max(10_000),\n spendUsd: z.number().nonnegative(),\n durationSeconds: z.number().nonnegative(),\n cleanupComplete: z.boolean(),\n issuer: IdSchema,\n issuedAt: TimestampSchema,\n signature: z.string().trim().min(1).max(10_000).nullable(),\n })\n .strict();\n\nexport async function trainingExecutionReceiptHash(\n receipt: TrainingExecutionReceipt,\n): Promise<string> {\n return canonicalSha256(TrainingExecutionReceiptSchema.parse(receipt));\n}\n\nexport async function parseAndVerifyTrainingExecutionReceipt(\n value: unknown,\n expected: {\n id: string;\n contentHash: string;\n teamId?: string;\n jobId?: string;\n requireCleanup?: boolean;\n },\n): Promise<TrainingExecutionReceipt> {\n const receipt = TrainingExecutionReceiptSchema.parse(value);\n const expectedId = IdSchema.parse(expected.id);\n const expectedHash = HashSchema.parse(expected.contentHash);\n const actualHash = await trainingExecutionReceiptHash(receipt);\n if (receipt.id !== expectedId || actualHash !== expectedHash) {\n throw new OpenPondProtocolError(\n \"execution_receipt_mismatch\",\n \"The execution receipt identity or canonical content hash did not match.\",\n );\n }\n if (expected.teamId !== undefined && receipt.teamId !== IdSchema.parse(expected.teamId)) {\n throw new OpenPondProtocolError(\n \"execution_receipt_team_mismatch\",\n \"The execution receipt belongs to a different team.\",\n );\n }\n if (expected.jobId !== undefined && receipt.jobId !== IdSchema.parse(expected.jobId)) {\n throw new OpenPondProtocolError(\n \"execution_receipt_job_mismatch\",\n \"The execution receipt belongs to a different Training Job.\",\n );\n }\n if ((expected.requireCleanup ?? true) && !receipt.cleanupComplete) {\n throw new OpenPondProtocolError(\n \"execution_cleanup_incomplete\",\n \"The execution receipt does not attest complete terminal cleanup.\",\n );\n }\n return receipt;\n}\n\nexport const TrainingJobOutputsSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingJobOutputs.v2\"),\n outputs: z.array(TrainingJobOutputSchema).max(10_000),\n receipt: TrainingExecutionReceiptSchema.nullable(),\n })\n .strict();\n\nexport const TrainingApiErrorSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingApiError.v2\"),\n code: z.string().trim().min(1).max(200),\n message: z.string().trim().min(1).max(5_000),\n retryable: z.boolean().default(false),\n requestId: z.string().trim().min(1).max(500).nullable().default(null),\n details: z.record(z.string(), z.unknown()).default({}),\n })\n .strict();\n\nexport class OpenPondTrainingApiError extends Error {\n readonly status: number;\n readonly code: string;\n readonly retryable: boolean;\n readonly requestId: string | null;\n readonly details: Record<string, unknown>;\n\n constructor(status: number, error: z.infer<typeof TrainingApiErrorSchema>) {\n super(error.message);\n this.name = \"OpenPondTrainingApiError\";\n this.status = status;\n this.code = error.code;\n this.retryable = error.retryable;\n this.requestId = error.requestId;\n this.details = error.details;\n }\n}\n\nexport const TrainingCapabilitiesSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.trainingCapabilities.v2\"),\n capabilityHash: HashSchema,\n jobKinds: z.array(TrainingJobKindSchema),\n methods: z.array(z.string().trim().min(1).max(200)),\n placements: z.array(\n z.enum([\"local\", \"remote\", \"colocated\", \"provider_native\"]),\n ),\n controls: z\n .object({\n cancel: z.boolean(),\n stopAfterGroup: z.boolean(),\n resumeFromCheckpoint: z.boolean(),\n })\n .strict(),\n limits: z\n .object({\n maximumSpendUsd: z.number().nonnegative(),\n maximumWallSeconds: z.number().int().positive(),\n maximumArtifactBytes: z.number().int().positive(),\n })\n .strict(),\n checkedAt: TimestampSchema,\n expiresAt: TimestampSchema,\n })\n .strict();\n\nexport type TrainingJobSubmission = z.infer<\n typeof TrainingJobSubmissionSchema\n>;\nexport type TrainingInputArtifactUpload = z.infer<\n typeof TrainingInputArtifactUploadSchema\n>;\nexport type TrainingInputArtifact = z.infer<typeof TrainingInputArtifactSchema>;\nexport type TrainingJob = z.infer<typeof TrainingJobSchema>;\nexport type TrainingJobPage = z.infer<typeof TrainingJobPageSchema>;\nexport type TrainingJobEvent = z.infer<typeof TrainingJobEventSchema>;\nexport type TrainingJobLog = z.infer<typeof TrainingJobLogSchema>;\nexport type TrainingJobOutput = z.infer<typeof TrainingJobOutputSchema>;\nexport type TrainingJobOutputs = z.infer<typeof TrainingJobOutputsSchema>;\nexport type TrainingExecutionReceipt = z.infer<\n typeof TrainingExecutionReceiptSchema\n>;\nexport type TrainingCapabilities = z.infer<typeof TrainingCapabilitiesSchema>;\n\nfunction headersRecord(headers: HeadersInit | undefined): Record<string, string> {\n const result: Record<string, string> = {};\n new Headers(headers).forEach((value, key) => {\n result[key] = value;\n });\n return result;\n}\n\nexport function createTrainingClient(input: {\n baseUrl: string;\n fetch?: typeof fetch;\n headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n}) {\n const fetchImpl = input.fetch ?? fetch;\n const baseUrl = input.baseUrl.replace(/\\/$/, \"\");\n\n async function request(pathname: string, init?: RequestInit, responseLimit = TRAINING_API_RESPONSE_MAX_BYTES): Promise<unknown> {\n const readOnly = init?.method === undefined || init.method.toUpperCase() === \"GET\";\n const maximumAttempts = readOnly ? 3 : 1;\n for (let attempt = 1; attempt <= maximumAttempts; attempt += 1) {\n let response: Response;\n try {\n const configuredHeaders =\n typeof input.headers === \"function\"\n ? await input.headers()\n : (input.headers ?? {});\n response = await fetchImpl(`${baseUrl}${pathname}`, {\n ...init,\n headers: {\n accept: OPENPOND_TRAINING_MEDIA_TYPE,\n ...(init?.body ? { \"content-type\": OPENPOND_TRAINING_MEDIA_TYPE } : {}),\n ...headersRecord(configuredHeaders),\n ...headersRecord(init?.headers),\n },\n });\n } catch (error) {\n if (\n attempt === maximumAttempts ||\n init?.signal?.aborted ||\n !trainingReadFailureIsRetryable(null, error)\n ) {\n throw error;\n }\n await new Promise((resolve) => setTimeout(resolve, 250 * 2 ** (attempt - 1)));\n continue;\n }\n const body = parseBoundedJson(\n await response.text(),\n responseLimit,\n \"Training API response\",\n );\n if (response.ok) return body;\n const error = trainingApiError(body, response.status);\n if (\n attempt === maximumAttempts ||\n !trainingReadFailureIsRetryable(response.status, error)\n ) {\n throw error;\n }\n await new Promise((resolve) => setTimeout(resolve, 250 * 2 ** (attempt - 1)));\n }\n throw new OpenPondProtocolError(\n \"training_read_retry_exhausted\",\n \"Training read retry loop exhausted without a response.\",\n );\n }\n\n return {\n ...createTrainingPreparationClient(request),\n ...createTrainingHarnessSourceClient(request),\n ...createTrainingCandidateDecisionClient(request),\n async capabilities() {\n return TrainingCapabilitiesSchema.parse(\n unwrapObject(await request(\"/v1/training/capabilities\"), \"capabilities\"),\n );\n },\n async stageArtifact(upload: TrainingInputArtifactUpload) {\n const parsed = await parseAndVerifyTrainingInputArtifactUpload(upload);\n return TrainingInputArtifactSchema.parse(\n unwrapObject(\n await request(\"/v1/training/artifacts\", {\n method: \"POST\",\n body: JSON.stringify(parsed),\n }),\n \"artifact\",\n ),\n );\n },\n async createJob(submission: TrainingJobSubmission) {\n const parsed = await parseAndVerifyTrainingJobSubmission(submission);\n return TrainingJobSchema.parse(\n unwrapObject(\n await request(\"/v1/training/jobs\", {\n method: \"POST\",\n body: JSON.stringify(parsed),\n }),\n \"job\",\n ),\n );\n },\n async listJobs(options: {\n modelProjectId?: string;\n cursor?: string;\n limit?: number;\n } = {}) {\n const parameters = new URLSearchParams();\n if (options.modelProjectId) {\n parameters.set(\"modelProjectId\", IdSchema.parse(options.modelProjectId));\n }\n if (options.cursor) {\n parameters.set(\"cursor\", z.string().trim().min(1).max(2_000).parse(options.cursor));\n }\n if (options.limit !== undefined) {\n parameters.set(\n \"limit\",\n String(z.number().int().min(1).max(1_000).parse(options.limit)),\n );\n }\n const query = parameters.size > 0 ? `?${parameters.toString()}` : \"\";\n return TrainingJobPageSchema.parse(\n await request(`/v1/training/jobs${query}`),\n );\n },\n async getJob(jobId: string) {\n return TrainingJobSchema.parse(\n unwrapObject(\n await request(`/v1/training/jobs/${encodeURIComponent(IdSchema.parse(jobId))}`),\n \"job\",\n ),\n );\n },\n async cancelJob(jobId: string, expectedVersion: number) {\n const control = TrainingJobControlRequestSchema.parse({ expectedVersion });\n return TrainingJobSchema.parse(\n unwrapObject(\n await request(\n `/v1/training/jobs/${encodeURIComponent(IdSchema.parse(jobId))}/cancel`,\n { method: \"POST\", body: JSON.stringify(control) },\n ),\n \"job\",\n ),\n );\n },\n async stopAfterGroup(jobId: string, expectedVersion: number) {\n const control = TrainingJobControlRequestSchema.parse({ expectedVersion });\n return TrainingJobSchema.parse(\n unwrapObject(\n await request(\n `/v1/training/jobs/${encodeURIComponent(IdSchema.parse(jobId))}/stop-after-group`,\n { method: \"POST\", body: JSON.stringify(control) },\n ),\n \"job\",\n ),\n );\n },\n async events(jobId: string) {\n return z\n .array(TrainingJobEventSchema)\n .parse(\n unwrapObject(\n await request(\n `/v1/training/jobs/${encodeURIComponent(IdSchema.parse(jobId))}/events`,\n ),\n \"events\",\n ),\n );\n },\n async outputs(jobId: string) {\n return TrainingJobOutputsSchema.parse(\n await request(\n `/v1/training/jobs/${encodeURIComponent(IdSchema.parse(jobId))}/outputs`,\n ),\n );\n },\n async evaluationTasks(\n jobId: string,\n evaluation: { id: string; contentHash: string },\n options: { cursor?: string; limit?: number } = {},\n ) {\n const id = IdSchema.parse(jobId);\n const reference = ModelProjectImmutableRefSchema.parse(evaluation);\n const parameters = new URLSearchParams();\n const cursor = options.cursor === undefined ? undefined : z.string().regex(/^[1-9]\\d*$/).parse(options.cursor);\n const offset = cursor === undefined ? 0 : z.number().int().min(1).max(9_999).parse(Number(cursor));\n if (cursor !== undefined) parameters.set(\"cursor\", cursor);\n if (options.limit !== undefined) parameters.set(\"limit\", String(z.number().int().min(1).max(100).parse(options.limit)));\n const query = parameters.size ? `?${parameters.toString()}` : \"\";\n return parseAndVerifyTrainingEvaluationTaskPage(\n await request(`/v1/training/jobs/${encodeURIComponent(id)}/evaluations/${encodeURIComponent(reference.id)}/tasks${query}`),\n { jobId: id, evaluation: reference, offset },\n );\n },\n async logs(jobId: string) {\n return z.array(TrainingJobLogSchema).max(100_000).parse(\n unwrapObject(\n await request(\n `/v1/training/jobs/${encodeURIComponent(IdSchema.parse(jobId))}/logs`,\n ),\n \"logs\",\n ),\n );\n },\n };\n}\n\nfunction trainingReadFailureIsRetryable(status: number | null, error: unknown): boolean {\n if (status !== null) {\n return status === 408 || status === 429 || status >= 500;\n }\n if (error instanceof OpenPondTrainingApiError) return error.retryable;\n if (error instanceof OpenPondProtocolError) {\n return error.code === \"invalid_error_response\";\n }\n return error instanceof TypeError;\n}\n\nfunction unwrapObject(value: unknown, key: string): unknown {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return value;\n return key in value ? (value as Record<string, unknown>)[key] : value;\n}\n\nfunction trainingApiError(value: unknown, status: number): Error {\n const parsed = TrainingApiErrorSchema.safeParse(value);\n if (parsed.success) {\n return new OpenPondTrainingApiError(status, parsed.data);\n }\n return new OpenPondProtocolError(\n \"invalid_error_response\",\n `Training request failed with HTTP ${status} and an invalid error envelope.`,\n );\n}\n", "import { z } from \"zod\";\nimport { ModelProjectVersionedRefSchema } from \"./model-projects.js\";\nimport { TrainingJobSourceSchema } from \"./training.js\";\nimport { canonicalSha256, OpenPondProtocolError } from \"./protocol.js\";\n\nconst Id = z.string().trim().min(1).max(191);\nconst Hash = z.string().regex(/^[a-f0-9]{64}$/);\n\n/** Manual training compiles an already reviewed batch. It creates no recurring policy. */\nexport const TrainingPreparationRequestSchema = z.object({\n schemaVersion: z.literal(\"openpond.trainingPreparationRequest.v1\"),\n teamId: Id,\n operationId: Id,\n projectId: Id.nullable(),\n configuration: z.object({ id: Id, expectedRevision: z.number().int().positive(), expectedEtag: Hash }).strict(),\n batch: ModelProjectVersionedRefSchema,\n name: z.string().trim().min(1).max(191),\n maximumSpendUsd: z.number().finite().positive().max(1_000_000),\n}).strict();\nexport const TrainingPreparationPlanContentSchema = z.object({\n schemaVersion: z.literal(\"openpond.trainingPreparationPlan.v1\"),\n id: Id,\n creatorUserId: Id,\n request: TrainingPreparationRequestSchema,\n requestHash: Hash,\n source: z.lazy(() => TrainingJobSourceSchema),\n submissionHash: Hash,\n createdAt: z.string().datetime({ offset: true }),\n}).strict();\nexport const TrainingPreparationPlanSchema = TrainingPreparationPlanContentSchema.extend({ contentHash: Hash }).strict();\nexport const TrainingPreparationReceiptSchema = z.object({\n schemaVersion: z.literal(\"openpond.trainingPreparationReceipt.v1\"),\n plan: TrainingPreparationPlanSchema,\n revision: z.number().int().positive(),\n state: z.enum([\"prepared\", \"submitted\", \"cancelled\"]),\n jobId: Id.nullable(),\n}).strict().superRefine((value, context) => {\n if ((value.state === \"submitted\") !== Boolean(value.jobId)) context.addIssue({ code: \"custom\", path: [\"jobId\"], message: \"Only submitted preparations identify a job.\" });\n});\nexport const TrainingPreparationControlSchema = z.object({\n teamId: Id, planHash: Hash, expectedRevision: z.number().int().positive(),\n}).strict();\nexport const TrainingPreparationListQuerySchema = z.object({\n projectId: Id.optional(),\n state: z.enum([\"prepared\", \"submitted\", \"cancelled\"]).optional(),\n afterId: Id.optional(),\n limit: z.number().int().min(1).max(100).default(25),\n}).strict();\nexport const TrainingPreparationPageSchema = z.object({\n schemaVersion: z.literal(\"openpond.trainingPreparationPage.v1\"),\n teamId: Id,\n items: z.array(TrainingPreparationReceiptSchema).max(100),\n nextCursor: Id.nullable(),\n}).strict();\nexport type TrainingPreparationRequest = z.infer<typeof TrainingPreparationRequestSchema>;\nexport type TrainingPreparationPlan = z.infer<typeof TrainingPreparationPlanSchema>;\nexport type TrainingPreparationReceipt = z.infer<typeof TrainingPreparationReceiptSchema>;\nexport type TrainingPreparationControl = z.infer<typeof TrainingPreparationControlSchema>;\nexport type TrainingPreparationListQuery = z.input<typeof TrainingPreparationListQuerySchema>;\nexport type TrainingPreparationPage = z.infer<typeof TrainingPreparationPageSchema>;\n\nexport async function parseAndVerifyTrainingPreparationReceipt(value: unknown) {\n const receipt = TrainingPreparationReceiptSchema.parse(value);\n const { contentHash, ...plan } = receipt.plan;\n if (await canonicalSha256(plan) !== contentHash || await canonicalSha256(plan.request) !== plan.requestHash\n || plan.source.modelProject.id !== plan.request.configuration.id) {\n throw new OpenPondProtocolError(\"training_preparation_mismatch\", \"The prepared training inputs changed.\");\n }\n return receipt;\n}\n\nexport function createTrainingPreparationClient(request: (path: string, init?: RequestInit) => Promise<unknown>) {\n async function read(value: unknown, teamId: string, id?: string) {\n const receipt = await parseAndVerifyTrainingPreparationReceipt(value);\n if (receipt.plan.request.teamId !== teamId || (id && receipt.plan.id !== id))\n throw new OpenPondProtocolError(\"training_preparation_scope_mismatch\", \"The training preparation belongs to a different workspace or request.\");\n return receipt;\n }\n return {\n /** Discover the authenticated user's retained preparations without creating jobs. */\n async listPreparations(teamId: string, input: TrainingPreparationListQuery = {}) {\n const scope = Id.parse(teamId);\n const query = TrainingPreparationListQuerySchema.parse(input);\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) params.set(key, String(value));\n const page = TrainingPreparationPageSchema.parse(await request(`/v1/training/preparations?${params}`));\n if (page.teamId !== scope || page.items.length > query.limit\n || new Set(page.items.map(item => item.plan.id)).size !== page.items.length\n || (page.nextCursor !== null && (page.nextCursor !== page.items.at(-1)?.plan.id || page.nextCursor === query.afterId))) {\n throw new OpenPondProtocolError(\"training_preparation_page_mismatch\", \"The preparation page does not match its workspace or cursor.\");\n }\n const items = await Promise.all(page.items.map(async item => {\n const receipt = await read(item, scope);\n if ((query.projectId && receipt.plan.request.projectId !== query.projectId)\n || (query.state && receipt.state !== query.state)) {\n throw new OpenPondProtocolError(\"training_preparation_page_mismatch\", \"A preparation does not match the requested Project or state.\");\n }\n return receipt;\n }));\n return { ...page, items };\n },\n async prepareRun(input: TrainingPreparationRequest) {\n const parsed = TrainingPreparationRequestSchema.parse(input);\n const receipt = await read(await request(\"/v1/training/preparations\", { method: \"POST\", body: JSON.stringify(parsed) }), parsed.teamId);\n if (receipt.plan.requestHash !== await canonicalSha256(parsed))\n throw new OpenPondProtocolError(\"training_preparation_request_mismatch\", \"The preparation does not match the requested run.\");\n return receipt;\n },\n async getPreparation(teamId: string, id: string) {\n return read(await request(`/v1/training/preparations/${encodeURIComponent(Id.parse(id))}`), Id.parse(teamId), id);\n },\n async startPreparation(id: string, input: TrainingPreparationControl) {\n const parsed = TrainingPreparationControlSchema.parse(input);\n const receipt = await read(await request(`/v1/training/preparations/${encodeURIComponent(Id.parse(id))}/start`, { method: \"POST\", body: JSON.stringify(parsed) }), parsed.teamId, id);\n if (receipt.plan.contentHash !== parsed.planHash || receipt.state !== \"submitted\")\n throw new OpenPondProtocolError(\"training_preparation_start_mismatch\", \"The submitted run does not match the approved preparation.\");\n return receipt;\n },\n async cancelPreparation(id: string, input: TrainingPreparationControl) {\n const parsed = TrainingPreparationControlSchema.parse(input);\n const receipt = await read(await request(`/v1/training/preparations/${encodeURIComponent(Id.parse(id))}/cancel`, { method: \"POST\", body: JSON.stringify(parsed) }), parsed.teamId, id);\n if (receipt.plan.contentHash !== parsed.planHash || receipt.state !== \"cancelled\")\n throw new OpenPondProtocolError(\"training_preparation_cancel_mismatch\", \"The preparation cancellation could not be verified.\");\n return receipt;\n },\n };\n}\n", "import { z } from \"zod\";\nimport { ImmutableReleaseRefSchema, validateHarnessSourcePackage, type HarnessSourcePackage, type ImmutableReleaseRef } from \"@openpond/harness\";\nimport { assertCanonicalPayloadSize, TRAINING_INPUT_ARTIFACT_MAX_BYTES } from \"./protocol.js\";\n\nexport const TrainingHarnessSourcePublicationSchema = z.object({\n schemaVersion: z.literal(\"openpond.trainingHarnessSourcePublication.v1\"),\n harnessRelease: ImmutableReleaseRefSchema,\n sourcePackageHash: z.string().regex(/^[a-f0-9]{64}$/),\n sizeBytes: z.number().int().positive().max(TRAINING_INPUT_ARTIFACT_MAX_BYTES),\n}).strict();\n\n/** Publication stores immutable source only; it never starts training. */\nexport function createTrainingHarnessSourceClient(request: (path: string, init?: RequestInit, responseLimit?: number) => Promise<unknown>) {\n const route = (reference: ImmutableReleaseRef) => {\n const ref = ImmutableReleaseRefSchema.parse(reference);\n return `/v1/training/harness-sources/${encodeURIComponent(ref.id)}/${ref.contentHash}`;\n };\n return {\n async publishHarnessSource(value: HarnessSourcePackage) {\n assertCanonicalPayloadSize(value, TRAINING_INPUT_ARTIFACT_MAX_BYTES, \"Training Harness source\");\n const source = validateHarnessSourcePackage(value);\n const portability = source.agentSnapshot.portability;\n if (!portability.portable || portability.blockers.length || portability.localOnlyAssetRefs.length || portability.hostPrivateAssetRefs.length || source.harnessRelease.files.some(file => file.visibility !== \"policy\")) {\n throw new Error(\"Hosted training Harness publication requires portable, policy-visible source.\");\n }\n const result = TrainingHarnessSourcePublicationSchema.parse(await request(route({ id: source.harnessRelease.id, contentHash: source.harnessRelease.contentHash }), { method: \"PUT\", body: JSON.stringify(source) }));\n if (result.harnessRelease.id !== source.harnessRelease.id || result.harnessRelease.contentHash !== source.harnessRelease.contentHash || result.sourcePackageHash !== source.contentHash) {\n throw new Error(\"Published Harness source differs from the selected immutable package.\");\n }\n return result;\n },\n async getHarnessSource(reference: ImmutableReleaseRef) {\n const value = await request(route(reference), undefined, TRAINING_INPUT_ARTIFACT_MAX_BYTES);\n assertCanonicalPayloadSize(value, TRAINING_INPUT_ARTIFACT_MAX_BYTES, \"Training Harness source\");\n return validateHarnessSourcePackage(value, reference);\n },\n };\n}\n", "import { z } from \"zod\";\nimport { ModelProjectImmutableRefSchema } from \"./model-projects.js\";\nimport {\n OpenPondProtocolError,\n assertCanonicalPayloadSize,\n canonicalSha256,\n} from \"./protocol.js\";\n\nconst IdSchema = /* @__PURE__ */ (() => z.string().trim().min(1).max(500))();\nconst HashSchema = /* @__PURE__ */ (() => z.string().regex(/^[a-f0-9]{64}$/))();\n\n/** A reviewed candidate decision never activates serving or alters training evidence. */\nexport const TrainingCandidateDecisionRequestSchema = /* @__PURE__ */ (() => z.object({\n schemaVersion: z.literal(\"openpond.trainingCandidateDecisionRequest.v1\"),\n teamId: IdSchema,\n jobId: IdSchema,\n artifact: ModelProjectImmutableRefSchema,\n evaluation: ModelProjectImmutableRefSchema,\n executionReceipt: ModelProjectImmutableRefSchema,\n decision: z.enum([\"accepted\", \"rejected\"]),\n reason: z.string().trim().min(1).max(5_000),\n idempotencyKey: IdSchema,\n expectedDecision: ModelProjectImmutableRefSchema.nullable(),\n}).strict())();\n\n/** Append-only, authenticated hosted record. Hash verification is not a signature. */\nexport const TrainingCandidateDecisionSchema = /* @__PURE__ */ (() => z.object({\n schemaVersion: z.literal(\"openpond.trainingCandidateDecision.v1\"),\n id: IdSchema,\n request: TrainingCandidateDecisionRequestSchema,\n revision: z.number().int().positive(),\n actor: z.object({ userId: IdSchema, kind: z.enum([\"user\", \"api_key\", \"agent_delegate\"]), id: IdSchema }).strict(),\n decidedAt: z.string().datetime({ offset: true }),\n contentHash: HashSchema,\n}).strict().superRefine((value, context) => {\n if ((value.revision === 1) !== (value.request.expectedDecision === null)) {\n context.addIssue({ code: \"custom\", path: [\"revision\"], message: \"A first decision has no predecessor; later decisions must reference the prior decision.\" });\n }\n if (value.request.expectedDecision?.id === value.id) {\n context.addIssue({ code: \"custom\", path: [\"request\", \"expectedDecision\"], message: \"A decision cannot supersede itself.\" });\n }\n}))();\n\nexport type TrainingCandidateDecisionRequest = z.infer<typeof TrainingCandidateDecisionRequestSchema>;\nexport type TrainingCandidateDecision = z.infer<typeof TrainingCandidateDecisionSchema>;\nexport type TrainingCandidateDecisionTarget = Pick<TrainingCandidateDecisionRequest, \"teamId\" | \"jobId\" | \"artifact\">;\n\nexport async function trainingCandidateDecisionHash(\n value: Omit<TrainingCandidateDecision, \"contentHash\"> | TrainingCandidateDecision,\n): Promise<string> {\n const { contentHash: _contentHash, ...content } = value as TrainingCandidateDecision;\n return canonicalSha256(content);\n}\n\nexport async function parseAndVerifyTrainingCandidateDecision(\n value: unknown,\n expected: TrainingCandidateDecisionTarget & { request?: TrainingCandidateDecisionRequest },\n): Promise<TrainingCandidateDecision> {\n assertCanonicalPayloadSize(value, 32_768, \"Training candidate decision\");\n const parsed = TrainingCandidateDecisionSchema.parse(value);\n if (parsed.contentHash !== await trainingCandidateDecisionHash(parsed)) {\n throw new OpenPondProtocolError(\"content_hash_mismatch\", \"Training candidate decision content hash does not match.\");\n }\n if (parsed.request.teamId !== expected.teamId || parsed.request.jobId !== expected.jobId\n || parsed.request.artifact.id !== expected.artifact.id\n || parsed.request.artifact.contentHash !== expected.artifact.contentHash) {\n throw new OpenPondProtocolError(\"candidate_decision_identity_mismatch\", \"Training candidate decision belongs to a different team, Job or artifact.\");\n }\n if (expected.request && await canonicalSha256(parsed.request) !== await canonicalSha256(TrainingCandidateDecisionRequestSchema.parse(expected.request))) {\n throw new OpenPondProtocolError(\"candidate_decision_request_mismatch\", \"Training candidate decision does not match the submitted review.\");\n }\n return parsed;\n}\n\nexport function createTrainingCandidateDecisionClient(\n request: (path: string, init?: RequestInit) => Promise<unknown>,\n) {\n function route(target: TrainingCandidateDecisionTarget) {\n return `/v1/training/jobs/${encodeURIComponent(IdSchema.parse(target.jobId))}/candidates/${encodeURIComponent(ModelProjectImmutableRefSchema.parse(target.artifact).id)}/decision`;\n }\n return {\n async candidateDecision(\n target: TrainingCandidateDecisionTarget,\n options: { decision?: { id: string; contentHash: string } } = {},\n ): Promise<TrainingCandidateDecision | null> {\n IdSchema.parse(target.teamId);\n const reference = options.decision ? ModelProjectImmutableRefSchema.parse(options.decision) : undefined;\n const query = reference ? `?decisionId=${encodeURIComponent(reference.id)}` : \"\";\n const response = z.object({ decision: z.unknown().nullable() }).strict().parse(await request(`${route(target)}${query}`));\n if (response.decision === null && !reference) return null;\n const decision = await parseAndVerifyTrainingCandidateDecision(response.decision, target);\n if (reference && (decision.id !== reference.id || decision.contentHash !== reference.contentHash)) {\n throw new OpenPondProtocolError(\"candidate_decision_identity_mismatch\", \"Training candidate decision does not match the requested history entry.\");\n }\n return decision;\n },\n async recordCandidateDecision(input: TrainingCandidateDecisionRequest): Promise<TrainingCandidateDecision> {\n const parsed = TrainingCandidateDecisionRequestSchema.parse(input);\n const response = await request(route(parsed), { method: \"POST\", body: JSON.stringify(parsed) });\n return parseAndVerifyTrainingCandidateDecision(response, { ...parsed, request: parsed });\n },\n };\n}\n", "import { z } from \"zod\";\nimport { ModelProjectImmutableRefSchema, ModelProjectVersionedRefSchema } from \"./model-projects.js\";\nimport {\n OpenPondProtocolError,\n TRAINING_API_RESPONSE_MAX_BYTES,\n assertCanonicalPayloadSize,\n canonicalSha256,\n} from \"./protocol.js\";\n\nconst IdSchema = /* @__PURE__ */ (() => z.string().trim().min(1).max(500))();\nconst HashSchema = /* @__PURE__ */ (() => z.string().regex(/^[a-f0-9]{64}$/))();\n\n/** Reviewer-facing evidence only: never a worker response or training sample. */\nexport const TrainingEvaluationTaskResultSchema = /* @__PURE__ */ (() => z.object({\n taskId: IdSchema,\n taskSha256: HashSchema,\n resultSha256: HashSchema,\n input: z.object({\n instruction: z.string().max(1_000_000),\n context: z.record(z.string(), z.unknown()),\n }).strict(),\n output: z.string().max(1_000_000),\n outputSha256: HashSchema,\n score: z.number().finite().min(0).max(1),\n evidence: z.object({\n kind: z.enum([\"worker_command\", \"hosted_trace\", \"local_trace\"]),\n id: IdSchema,\n }).strict(),\n}).strict())();\n\n/** Supplements an existing evaluation; does not replace its terminal receipt. */\nexport const TrainingEvaluationTaskPageSchema = /* @__PURE__ */ (() => z.object({\n schemaVersion: z.literal(\"openpond.trainingEvaluationTaskPage.v1\"),\n jobId: IdSchema,\n teamId: IdSchema,\n evaluation: ModelProjectImmutableRefSchema,\n kind: z.enum([\"baseline\", \"candidate\"]),\n policyVersion: z.number().int().nonnegative(),\n taskset: ModelProjectVersionedRefSchema,\n panelSha256: HashSchema,\n offset: z.number().int().nonnegative(),\n total: z.number().int().min(1).max(10_000),\n tasks: z.array(TrainingEvaluationTaskResultSchema).min(1).max(100),\n nextCursor: z.string().regex(/^[1-9]\\d*$/).nullable(),\n contentHash: HashSchema,\n}).strict().superRefine((page, context) => {\n const end = page.offset + page.tasks.length;\n const expectedCursor = end < page.total ? String(end) : null;\n if (end > page.total || page.nextCursor !== expectedCursor) {\n context.addIssue({ code: \"custom\", path: [\"nextCursor\"], message: \"Evaluation pagination must cover consecutive task positions.\" });\n }\n if (new Set(page.tasks.map((task) => task.taskId)).size !== page.tasks.length) {\n context.addIssue({ code: \"custom\", path: [\"tasks\"], message: \"Evaluation task identities must be unique.\" });\n }\n}))();\n\nexport type TrainingEvaluationTaskResult = z.infer<typeof TrainingEvaluationTaskResultSchema>;\nexport type TrainingEvaluationTaskPage = z.infer<typeof TrainingEvaluationTaskPageSchema>;\n\nexport async function trainingEvaluationTaskPageHash(\n value: Omit<TrainingEvaluationTaskPage, \"contentHash\"> | TrainingEvaluationTaskPage,\n): Promise<string> {\n const { contentHash: _contentHash, ...content } = value as TrainingEvaluationTaskPage;\n return canonicalSha256(content);\n}\n\nexport async function parseAndVerifyTrainingEvaluationTaskPage(\n value: unknown,\n expected: {\n jobId: string;\n evaluation: { id: string; contentHash: string };\n offset?: number;\n teamId?: string;\n },\n): Promise<TrainingEvaluationTaskPage> {\n assertCanonicalPayloadSize(value, TRAINING_API_RESPONSE_MAX_BYTES, \"Training evaluation task page\");\n const page = TrainingEvaluationTaskPageSchema.parse(value);\n const reference = ModelProjectImmutableRefSchema.parse(expected.evaluation);\n if (page.jobId !== IdSchema.parse(expected.jobId)\n || page.evaluation.id !== reference.id\n || page.evaluation.contentHash !== reference.contentHash\n || page.offset !== (expected.offset ?? 0)\n || (expected.teamId !== undefined && page.teamId !== IdSchema.parse(expected.teamId))) {\n throw new OpenPondProtocolError(\"evaluation_page_identity_mismatch\", \"Evaluation results differ from the requested Job, evaluation, or page.\");\n }\n if (await trainingEvaluationTaskPageHash(page) !== page.contentHash) {\n throw new OpenPondProtocolError(\"evaluation_page_hash_mismatch\", \"Evaluation task page content hash did not match.\");\n }\n for (const task of page.tasks) {\n if (await canonicalSha256(task.output) !== task.outputSha256) {\n throw new OpenPondProtocolError(\"evaluation_output_hash_mismatch\", \"A retained evaluation output hash did not match.\");\n }\n }\n return page;\n}\n", "import { z } from \"zod\";\nimport { compileBoundGraders, RewardBindingSchema, RewardReleaseSchema } from \"@openpond/evals/rewards\";\nimport { canonicalSha256 } from \"./protocol.js\";\n\nconst GradersSchema = z.array(z.object({ id: z.string().trim().min(1) }).catchall(z.unknown())).min(1).max(1_000);\nconst RewardExecutionSchema = z.object({\n binding: RewardBindingSchema,\n rewards: z.array(RewardReleaseSchema).min(1).max(100),\n}).strict();\n\n/**\n * The grader reference identifies the entire executed set, including order and\n * configuration. A bound plan additionally identifies its immutable composer,\n * whose sources pin roles, normalization, gates and required-score semantics.\n * Callers must obtain these inputs from their verified immutable bundle.\n */\nexport async function deterministicTrainingRewardSource(input: {\n graders: unknown;\n rewardExecution?: unknown;\n}) {\n const execution = input.rewardExecution ? RewardExecutionSchema.parse(input.rewardExecution) : null;\n const graders = GradersSchema.parse(execution\n ? compileBoundGraders(execution.binding, execution.rewards)\n : input.graders);\n if (new Set(graders.map(grader => grader.id)).size !== graders.length) {\n throw new Error(\"Training grader identities must be unique.\");\n }\n const hash = await canonicalSha256({ schemaVersion: \"openpond.trainingGraderSet.v1\", graders });\n return {\n kind: \"deterministic\" as const,\n grader: { id: `training-graders-${hash.slice(0, 32)}`, contentHash: hash },\n composer: execution ? { id: execution.binding.id, contentHash: execution.binding.contentHash } : null,\n };\n}\n", "import { z } from \"zod\";\nimport { ModelProjectVersionedRefSchema } from \"./model-projects.js\";\nimport { canonicalSha256 } from \"./protocol.js\";\n\nexport const TRAINING_EVALUATION_SOURCE_PATH = \"evaluation-source.json\";\n\nconst TaskIdentitySchema = z.object({\n id: z.string().trim().min(1),\n clusterKey: z.string().trim().min(1),\n split: z.enum([\"train\", \"validation\", \"frozen_eval\"]),\n}).passthrough();\n\n/** Evaluator-only payload. The enclosing resolved bundle pins every byte. */\nexport const TrainingEvaluationSourceSchema = z.object({\n schemaVersion: z.literal(\"openpond.trainingEvaluationSource.v1\"),\n taskset: ModelProjectVersionedRefSchema,\n tasks: z.array(TaskIdentitySchema).min(1).max(10_000),\n assets: z.array(z.object({\n path: z.string().trim().min(1).max(2_000),\n sha256: z.string().regex(/^[a-f0-9]{64}$/),\n sizeBytes: z.number().int().nonnegative(),\n encoding: z.literal(\"base64\"),\n content: z.string().max(32 * 1024 * 1024),\n }).strict()).max(10_000),\n}).strict().superRefine((source, context) => {\n const ids = new Set<string>();\n source.tasks.forEach((task, index) => {\n if (task.split === \"train\") context.addIssue({ code: \"custom\", path: [\"tasks\", index, \"split\"], message: \"Evaluation sources require held-out tasks.\" });\n if (ids.has(task.id)) context.addIssue({ code: \"custom\", path: [\"tasks\", index, \"id\"], message: \"Evaluation task identities must be unique.\" });\n ids.add(task.id);\n });\n});\n\nexport type TrainingEvaluationSource = z.infer<typeof TrainingEvaluationSourceSchema>;\n\nexport function assertTrainingEvaluationIsolation(trainingTasks: unknown, evaluationTasks: unknown): void {\n const training = z.array(TaskIdentitySchema).min(1).max(10_000).parse(trainingTasks);\n const evaluation = z.array(TaskIdentitySchema).min(1).max(10_000).parse(evaluationTasks);\n const trainIds = new Set<string>();\n const trainFamilies = new Set<string>();\n for (const task of training) {\n if (task.split !== \"train\") throw new Error(\"The training population contains a held-out task.\");\n if (trainIds.has(task.id)) throw new Error(\"Training task identities must be unique.\");\n trainIds.add(task.id);\n trainFamilies.add(task.clusterKey);\n }\n const evaluationIds = new Set<string>();\n for (const task of evaluation) {\n if (task.split === \"train\") throw new Error(\"The evaluation population contains a training task.\");\n if (evaluationIds.has(task.id)) throw new Error(\"Evaluation task identities must be unique.\");\n if (trainIds.has(task.id) || trainFamilies.has(task.clusterKey)) {\n throw new Error(\"Training and evaluation tasks or families overlap.\");\n }\n evaluationIds.add(task.id);\n }\n}\n\nexport async function trainingEvaluationSourceRef(input: unknown) {\n const source = TrainingEvaluationSourceSchema.parse(input);\n const hash = await canonicalSha256(source);\n return { taskset: source.taskset, dataset: { id: `training-evaluation-${hash.slice(0, 32)}`, contentHash: hash } };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAKlB,IAAM,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAC3C,IAAM,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB;AAGvC,IAAM,mCAAmC,EAAE,OAAO;AAAA,EACvD,eAAe,EAAE,QAAQ,wCAAwC;AAAA,EACjE,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,WAAW,GAAG,SAAS;AAAA,EACvB,eAAe,EAAE,OAAO,EAAE,IAAI,IAAI,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,cAAc,KAAK,CAAC,EAAE,OAAO;AAAA,EAC9G,OAAO;AAAA,EACP,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,EACtC,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,GAAS;AAC/D,CAAC,EAAE,OAAO;AACH,IAAM,uCAAuC,EAAE,OAAO;AAAA,EAC3D,eAAe,EAAE,QAAQ,qCAAqC;AAAA,EAC9D,IAAI;AAAA,EACJ,eAAe;AAAA,EACf,SAAS;AAAA,EACT,aAAa;AAAA,EACb,QAAQ,EAAE,KAAK,MAAM,uBAAuB;AAAA,EAC5C,gBAAgB;AAAA,EAChB,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,KAAK,CAAC;AACjD,CAAC,EAAE,OAAO;AACH,IAAM,gCAAgC,qCAAqC,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O,WAAW,OAAO,UAAU;AAAA,EACvD;AACA,MAAI,iBAAiB,yBAA0B,QAAO,MAAM;AAC5D,MAAI,iBAAiB,uBAAuB;AAC1C,WAAO,MAAM,SAAS;AAAA,EACxB;AACA,SAAO,iBAAiB;AAC1B;AAEA,SAAS,aAAa,OAAgB,KAAsB;AAC1D,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AACxE,SAAO,OAAO,QAAS,MAAkC,GAAG,IAAI;AAClE;AAEA,SAAS,iBAAiB,OAAgB,QAAuB;AAC/D,QAAM,SAAS,uBAAuB,UAAU,KAAK;AACrD,MAAI,OAAO,SAAS;AAClB,WAAO,IAAI,yBAAyB,QAAQ,OAAO,IAAI;AAAA,EACzD;AACA,SAAO,IAAI;AAAA,IACT;AAAA,IACA,qCAAqC,MAAM;AAAA,EAC7C;AACF;",
|
|
6
|
+
"names": ["z", "z", "z", "z", "z", "z", "IdSchema", "z", "HashSchema", "z", "z", "z", "z", "IdSchema", "z", "HashSchema", "error"]
|
|
7
|
+
}
|
|
@@ -9,7 +9,7 @@ import "./chunk-DT7FRNIZ.js";
|
|
|
9
9
|
import "./chunk-LGEF4S5I.js";
|
|
10
10
|
import "./chunk-WOPM32SE.js";
|
|
11
11
|
import "./chunk-2U54EOXJ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-KIBRMKJQ.js";
|
|
13
13
|
import "./chunk-TCHAWJMB.js";
|
|
14
14
|
import "./chunk-3KXDH6OB.js";
|
|
15
15
|
import {
|
package/dist/model-starters.js
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
verifyModelStarterEnvironmentAttempt
|
|
32
32
|
} from "./chunk-WOPM32SE.js";
|
|
33
33
|
import "./chunk-2U54EOXJ.js";
|
|
34
|
-
import "./chunk-
|
|
34
|
+
import "./chunk-KIBRMKJQ.js";
|
|
35
35
|
import "./chunk-TCHAWJMB.js";
|
|
36
36
|
import "./chunk-3KXDH6OB.js";
|
|
37
37
|
import "./chunk-Y4NGWGTA.js";
|
package/dist/taskset-drafts.js
CHANGED
|
@@ -108,7 +108,7 @@ import {
|
|
|
108
108
|
TasksetDraftFilePathSchema,
|
|
109
109
|
TasksetDraftFileSchema
|
|
110
110
|
} from "./chunk-2U54EOXJ.js";
|
|
111
|
-
import "./chunk-
|
|
111
|
+
import "./chunk-KIBRMKJQ.js";
|
|
112
112
|
import "./chunk-TCHAWJMB.js";
|
|
113
113
|
import "./chunk-3KXDH6OB.js";
|
|
114
114
|
import "./chunk-A4ZDOZKP.js";
|
package/dist/taskset-packages.js
CHANGED
|
@@ -75,7 +75,7 @@ import {
|
|
|
75
75
|
TasksetDraftFilePathSchema,
|
|
76
76
|
TasksetDraftFileSchema
|
|
77
77
|
} from "./chunk-2U54EOXJ.js";
|
|
78
|
-
import "./chunk-
|
|
78
|
+
import "./chunk-KIBRMKJQ.js";
|
|
79
79
|
import "./chunk-TCHAWJMB.js";
|
|
80
80
|
import "./chunk-3KXDH6OB.js";
|
|
81
81
|
import "./chunk-A4ZDOZKP.js";
|
package/dist/training-bundle.js
CHANGED
|
@@ -24,8 +24,17 @@ var TrainingTargetSchema = z.discriminatedUnion("kind", [
|
|
|
24
24
|
artifact: ImmutableReleaseRefSchema.nullable(),
|
|
25
25
|
messages: z.array(z.object({ role: z.enum(["system", "user", "assistant"]), content: z.string().max(1e5) }).strict()).max(100)
|
|
26
26
|
}).strict(),
|
|
27
|
-
z.object({ kind: z.literal("harness"), source: ProfileEvaluationRunSourceSchema }).strict(),
|
|
28
|
-
z.object({ kind: z.literal("suite"), suiteId: Id, sources: z.array(ProfileEvaluationRunSourceSchema).min(1).max(1e3) }).strict()
|
|
27
|
+
z.object({ kind: z.literal("harness"), profileRepositoryId: Id, source: ProfileEvaluationRunSourceSchema }).strict(),
|
|
28
|
+
z.object({ kind: z.literal("suite"), profileRepositoryId: Id, suiteId: Id, sources: z.array(ProfileEvaluationRunSourceSchema).min(1).max(1e3) }).strict().superRefine((value, ctx) => {
|
|
29
|
+
const first = value.sources[0];
|
|
30
|
+
const identities = /* @__PURE__ */ new Set();
|
|
31
|
+
for (const [index, source] of value.sources.entries()) {
|
|
32
|
+
if (identities.has(source.definitionId)) ctx.addIssue({ code: "custom", path: ["sources", index], message: "Suite definitions must be unique." });
|
|
33
|
+
identities.add(source.definitionId);
|
|
34
|
+
if (source.profileId !== first.profileId || source.sourceRevision !== first.sourceRevision || source.catalogHash !== first.catalogHash || contentHash(source.harnessRelease) !== contentHash(first.harnessRelease))
|
|
35
|
+
ctx.addIssue({ code: "custom", path: ["sources", index], message: "Suite checks must belong to the same pinned Profile source and Harness release." });
|
|
36
|
+
}
|
|
37
|
+
})
|
|
29
38
|
]);
|
|
30
39
|
var TrainingProjectContentSchema = z.object({
|
|
31
40
|
name: z.string().trim().min(1).max(200),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/training-project-contracts.ts", "../src/training-project-client.ts"],
|
|
4
|
-
"sourcesContent": ["import { ProfileEvaluationRunSourceSchema } from \"@openpond/evals\";\nimport { z } from \"zod\";\nimport { ImmutableReleaseRefSchema, contentHash } from \"@openpond/harness\";\n\nconst Id = z.string().trim().min(1).max(240);\nconst Revision = z.number().int().positive();\nexport const TrainingResourceKindSchema = z.enum([\"dataset\", \"evaluator\", \"model\", \"training_configuration\", \"training_run\", \"harness\", \"environment\", \"experiment\", \"learning_policy\", \"deployment\"]);\nexport const TrainingResourceLinkSchema = z.object({\n kind: TrainingResourceKindSchema, resourceId: Id, release: ImmutableReleaseRefSchema.nullable(),\n role: z.enum([\"training\", \"validation\", \"holdout\", \"target\", \"reward\", \"evaluation\", \"serving\", \"source\"]),\n}).strict();\nexport const TrainingTargetSchema = z.discriminatedUnion(\"kind\", [\n z.object({ kind: z.literal(\"model\"), providerId: Id, modelId: Id, artifact: ImmutableReleaseRefSchema.nullable(),\n messages: z.array(z.object({ role: z.enum([\"system\", \"user\", \"assistant\"]), content: z.string().max(100_000) }).strict()).max(100) }).strict(),\n z.object({ kind: z.literal(\"harness\"), source: ProfileEvaluationRunSourceSchema }).strict(),\n z.object({ kind: z.literal(\"suite\"), suiteId: Id, sources: z.array(ProfileEvaluationRunSourceSchema).min(1).max(1_000) }).strict(),\n]);\nexport const TrainingProjectContentSchema = z.object({\n name: z.string().trim().min(1).max(200), description: z.string().max(10_000),\n targets: z.array(z.object({ id: Id, name: z.string().trim().min(1).max(200), target: TrainingTargetSchema }).strict()).max(100),\n defaultTargetId: Id.nullable(), resources: z.array(TrainingResourceLinkSchema).max(1_000),\n}).strict().superRefine((value, ctx) => {\n if (new Set(value.targets.map(t => t.id)).size !== value.targets.length) ctx.addIssue({ code: \"custom\", path: [\"targets\"], message: \"Target identities must be unique.\" });\n if (value.defaultTargetId && !value.targets.some(t => t.id === value.defaultTargetId)) ctx.addIssue({ code: \"custom\", path: [\"defaultTargetId\"], message: \"Default target must belong to this Project.\" });\n if (new Set(value.resources.map(r => contentHash(r))).size !== value.resources.length) ctx.addIssue({ code: \"custom\", path: [\"resources\"], message: \"Resource links must be unique.\" });\n});\nexport const TrainingProjectSchema = z.object({\n schemaVersion: z.literal(\"openpond.trainingProject.v1\"), id: Id, teamId: Id, creatorUserId: Id,\n revision: Revision, content: TrainingProjectContentSchema, archived: z.boolean(),\n createdAt: z.string().datetime(), updatedAt: z.string().datetime(),\n}).strict();\nexport const TrainingProjectWriteSchema = z.object({\n operationId: Id, id: Id, expectedRevision: z.number().int().nonnegative(), content: TrainingProjectContentSchema,\n}).strict();\nexport const TrainingProjectArchiveSchema = z.object({ operationId: Id, expectedRevision: Revision, archived: z.boolean() }).strict();\nexport const TrainingProjectListSchema = z.object({ teamId: Id, projects: z.array(TrainingProjectSchema).max(100), nextCursor: Id.nullable() }).strict();\nexport const TrainingOperationReadinessSchema = z.object({\n operation: z.enum([\"evaluate\", \"train\", \"enable_learning\", \"accept_candidate\", \"serve\"]),\n support: z.enum([\"supported\", \"unsupported\"]), state: z.enum([\"ready\", \"needs_setup\", \"blocked\"]),\n reasons: z.array(z.object({ code: Id, message: z.string().min(1).max(2_000), field: z.string().nullable(),\n action: z.enum([\"choose_target\", \"choose_data\", \"choose_evaluator\", \"configure_runtime\", \"request_access\", \"configure_budget\", \"wait\", \"review_evidence\"]).nullable() }).strict()).max(100),\n}).strict().superRefine((value, ctx) => {\n if (value.state === \"ready\" && (value.support !== \"supported\" || value.reasons.length)) ctx.addIssue({ code: \"custom\", message: \"Ready operations must be supported with no blockers.\" });\n if (value.state !== \"ready\" && !value.reasons.length) ctx.addIssue({ code: \"custom\", message: \"Unavailable operations must explain the next step.\" });\n});\nexport type TrainingProject = z.infer<typeof TrainingProjectSchema>;\nexport type TrainingProjectContent = z.infer<typeof TrainingProjectContentSchema>;\nexport type TrainingProjectWrite = z.infer<typeof TrainingProjectWriteSchema>;\nexport type TrainingResourceLink = z.infer<typeof TrainingResourceLinkSchema>;\nexport type TrainingTarget = z.infer<typeof TrainingTargetSchema>;\n", "import { contentHash } from \"@openpond/harness\";\nimport { TrainingProjectSchema, TrainingProjectWriteSchema, TrainingProjectArchiveSchema, TrainingProjectListSchema, type TrainingProjectWrite } from \"./training-project-contracts.js\";\n\nexport class OpenPondTrainingProjectClient {\n private readonly baseUrl: string;\n constructor(private readonly options: { baseUrl: string; apiKey: string; teamId: string; fetch?: typeof fetch }) {\n const url = new URL(options.baseUrl);\n if (![\"http:\", \"https:\"].includes(url.protocol) || url.username || url.password || url.search || url.hash || !options.apiKey.trim() || !options.teamId.trim()) throw new Error(\"A clean API origin and workspace credentials are required.\");\n this.baseUrl = url.toString().replace(/\\/+$/, \"\");\n }\n async list(options: { cursor?: string; signal?: AbortSignal } = {}) {\n const result = TrainingProjectListSchema.parse(await this.request(`?${new URLSearchParams(options.cursor ? { cursor: options.cursor } : {})}`, \"GET\", undefined, options.signal));\n if (result.teamId !== this.options.teamId || result.projects.some(p => p.teamId !== this.options.teamId)) throw new Error(\"Project list workspace mismatch.\");\n return result;\n }\n async get(id: string, signal?: AbortSignal) { return this.readback(await this.request(`/${encodeURIComponent(id)}`, \"GET\", undefined, signal), id); }\n async save(input: TrainingProjectWrite, signal?: AbortSignal) {\n const request = TrainingProjectWriteSchema.parse(input);\n const result = this.readback(await this.request(`/${encodeURIComponent(request.id)}`, \"PUT\", request, signal), request.id);\n if (result.revision !== request.expectedRevision + 1 || contentHash(result.content) !== contentHash(request.content)) throw new Error(\"Project write revision mismatch.\");\n return result;\n }\n async archive(id: string, input: { operationId: string; expectedRevision: number; archived: boolean }, signal?: AbortSignal) {\n const request = TrainingProjectArchiveSchema.parse(input);\n const result = this.readback(await this.request(`/${encodeURIComponent(id)}/archive`, \"POST\", request, signal), id);\n if (result.revision !== request.expectedRevision + 1 || result.archived !== request.archived) throw new Error(\"Project archive receipt mismatch.\");\n return result;\n }\n private readback(value: unknown, id: string) {\n const result = TrainingProjectSchema.parse(value);\n if (result.id !== id || result.teamId !== this.options.teamId) throw new Error(\"Project identity mismatch.\");\n return result;\n }\n private async request(path: string, method: string, body?: unknown, signal?: AbortSignal): Promise<unknown> {\n const response = await (this.options.fetch ?? fetch)(`${this.baseUrl}/v1/training-projects${path}`, {\n method, signal, redirect: \"error\", headers: { Authorization: `Bearer ${this.options.apiKey}`, \"X-OpenPond-Team-Id\": this.options.teamId, \"Content-Type\": \"application/json\" },\n ...(body === undefined ? {} : { body: JSON.stringify(body) }),\n });\n if (!response.ok) throw new Error(`Project request failed (${response.status}).`);\n return response.json();\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAAA,SAAS,wCAAwC;AACjD,SAAS,SAAS;AAGlB,IAAM,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAC3C,IAAM,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AACpC,IAAM,6BAA6B,EAAE,KAAK,CAAC,WAAW,aAAa,SAAS,0BAA0B,gBAAgB,WAAW,eAAe,cAAc,mBAAmB,YAAY,CAAC;AAC9L,IAAM,6BAA6B,EAAE,OAAO;AAAA,EACjD,MAAM;AAAA,EAA4B,YAAY;AAAA,EAAI,SAAS,0BAA0B,SAAS;AAAA,EAC9F,MAAM,EAAE,KAAK,CAAC,YAAY,cAAc,WAAW,UAAU,UAAU,cAAc,WAAW,QAAQ,CAAC;AAC3G,CAAC,EAAE,OAAO;AACH,IAAM,uBAAuB,EAAE,mBAAmB,QAAQ;AAAA,EAC/D,EAAE,OAAO;AAAA,IAAE,MAAM,EAAE,QAAQ,OAAO;AAAA,IAAG,YAAY;AAAA,IAAI,SAAS;AAAA,IAAI,UAAU,0BAA0B,SAAS;AAAA,IAC7G,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,QAAQ,WAAW,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,IAAI,GAAO,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,IAAI,GAAG;AAAA,EAAE,CAAC,EAAE,OAAO;AAAA,EAC/I,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAS,GAAG,QAAQ,iCAAiC,CAAC,EAAE,OAAO;AAAA,
|
|
4
|
+
"sourcesContent": ["import { ProfileEvaluationRunSourceSchema } from \"@openpond/evals\";\nimport { z } from \"zod\";\nimport { ImmutableReleaseRefSchema, contentHash } from \"@openpond/harness\";\n\nconst Id = z.string().trim().min(1).max(240);\nconst Revision = z.number().int().positive();\nexport const TrainingResourceKindSchema = z.enum([\"dataset\", \"evaluator\", \"model\", \"training_configuration\", \"training_run\", \"harness\", \"environment\", \"experiment\", \"learning_policy\", \"deployment\"]);\nexport const TrainingResourceLinkSchema = z.object({\n kind: TrainingResourceKindSchema, resourceId: Id, release: ImmutableReleaseRefSchema.nullable(),\n role: z.enum([\"training\", \"validation\", \"holdout\", \"target\", \"reward\", \"evaluation\", \"serving\", \"source\"]),\n}).strict();\nexport const TrainingTargetSchema = z.discriminatedUnion(\"kind\", [\n z.object({ kind: z.literal(\"model\"), providerId: Id, modelId: Id, artifact: ImmutableReleaseRefSchema.nullable(),\n messages: z.array(z.object({ role: z.enum([\"system\", \"user\", \"assistant\"]), content: z.string().max(100_000) }).strict()).max(100) }).strict(),\n z.object({ kind: z.literal(\"harness\"), profileRepositoryId: Id, source: ProfileEvaluationRunSourceSchema }).strict(),\n z.object({ kind: z.literal(\"suite\"), profileRepositoryId: Id, suiteId: Id, sources: z.array(ProfileEvaluationRunSourceSchema).min(1).max(1_000) }).strict().superRefine((value, ctx) => {\n const first = value.sources[0]!;\n const identities = new Set<string>();\n for (const [index, source] of value.sources.entries()) {\n if (identities.has(source.definitionId)) ctx.addIssue({ code: \"custom\", path: [\"sources\", index], message: \"Suite definitions must be unique.\" });\n identities.add(source.definitionId);\n if (source.profileId !== first.profileId || source.sourceRevision !== first.sourceRevision || source.catalogHash !== first.catalogHash || contentHash(source.harnessRelease) !== contentHash(first.harnessRelease))\n ctx.addIssue({ code: \"custom\", path: [\"sources\", index], message: \"Suite checks must belong to the same pinned Profile source and Harness release.\" });\n }\n }),\n]);\nexport const TrainingProjectContentSchema = z.object({\n name: z.string().trim().min(1).max(200), description: z.string().max(10_000),\n targets: z.array(z.object({ id: Id, name: z.string().trim().min(1).max(200), target: TrainingTargetSchema }).strict()).max(100),\n defaultTargetId: Id.nullable(), resources: z.array(TrainingResourceLinkSchema).max(1_000),\n}).strict().superRefine((value, ctx) => {\n if (new Set(value.targets.map(t => t.id)).size !== value.targets.length) ctx.addIssue({ code: \"custom\", path: [\"targets\"], message: \"Target identities must be unique.\" });\n if (value.defaultTargetId && !value.targets.some(t => t.id === value.defaultTargetId)) ctx.addIssue({ code: \"custom\", path: [\"defaultTargetId\"], message: \"Default target must belong to this Project.\" });\n if (new Set(value.resources.map(r => contentHash(r))).size !== value.resources.length) ctx.addIssue({ code: \"custom\", path: [\"resources\"], message: \"Resource links must be unique.\" });\n});\nexport const TrainingProjectSchema = z.object({\n schemaVersion: z.literal(\"openpond.trainingProject.v1\"), id: Id, teamId: Id, creatorUserId: Id,\n revision: Revision, content: TrainingProjectContentSchema, archived: z.boolean(),\n createdAt: z.string().datetime(), updatedAt: z.string().datetime(),\n}).strict();\nexport const TrainingProjectWriteSchema = z.object({\n operationId: Id, id: Id, expectedRevision: z.number().int().nonnegative(), content: TrainingProjectContentSchema,\n}).strict();\nexport const TrainingProjectArchiveSchema = z.object({ operationId: Id, expectedRevision: Revision, archived: z.boolean() }).strict();\nexport const TrainingProjectListSchema = z.object({ teamId: Id, projects: z.array(TrainingProjectSchema).max(100), nextCursor: Id.nullable() }).strict();\nexport const TrainingOperationReadinessSchema = z.object({\n operation: z.enum([\"evaluate\", \"train\", \"enable_learning\", \"accept_candidate\", \"serve\"]),\n support: z.enum([\"supported\", \"unsupported\"]), state: z.enum([\"ready\", \"needs_setup\", \"blocked\"]),\n reasons: z.array(z.object({ code: Id, message: z.string().min(1).max(2_000), field: z.string().nullable(),\n action: z.enum([\"choose_target\", \"choose_data\", \"choose_evaluator\", \"configure_runtime\", \"request_access\", \"configure_budget\", \"wait\", \"review_evidence\"]).nullable() }).strict()).max(100),\n}).strict().superRefine((value, ctx) => {\n if (value.state === \"ready\" && (value.support !== \"supported\" || value.reasons.length)) ctx.addIssue({ code: \"custom\", message: \"Ready operations must be supported with no blockers.\" });\n if (value.state !== \"ready\" && !value.reasons.length) ctx.addIssue({ code: \"custom\", message: \"Unavailable operations must explain the next step.\" });\n});\nexport type TrainingProject = z.infer<typeof TrainingProjectSchema>;\nexport type TrainingProjectContent = z.infer<typeof TrainingProjectContentSchema>;\nexport type TrainingProjectWrite = z.infer<typeof TrainingProjectWriteSchema>;\nexport type TrainingResourceLink = z.infer<typeof TrainingResourceLinkSchema>;\nexport type TrainingTarget = z.infer<typeof TrainingTargetSchema>;\n", "import { contentHash } from \"@openpond/harness\";\nimport { TrainingProjectSchema, TrainingProjectWriteSchema, TrainingProjectArchiveSchema, TrainingProjectListSchema, type TrainingProjectWrite } from \"./training-project-contracts.js\";\n\nexport class OpenPondTrainingProjectClient {\n private readonly baseUrl: string;\n constructor(private readonly options: { baseUrl: string; apiKey: string; teamId: string; fetch?: typeof fetch }) {\n const url = new URL(options.baseUrl);\n if (![\"http:\", \"https:\"].includes(url.protocol) || url.username || url.password || url.search || url.hash || !options.apiKey.trim() || !options.teamId.trim()) throw new Error(\"A clean API origin and workspace credentials are required.\");\n this.baseUrl = url.toString().replace(/\\/+$/, \"\");\n }\n async list(options: { cursor?: string; signal?: AbortSignal } = {}) {\n const result = TrainingProjectListSchema.parse(await this.request(`?${new URLSearchParams(options.cursor ? { cursor: options.cursor } : {})}`, \"GET\", undefined, options.signal));\n if (result.teamId !== this.options.teamId || result.projects.some(p => p.teamId !== this.options.teamId)) throw new Error(\"Project list workspace mismatch.\");\n return result;\n }\n async get(id: string, signal?: AbortSignal) { return this.readback(await this.request(`/${encodeURIComponent(id)}`, \"GET\", undefined, signal), id); }\n async save(input: TrainingProjectWrite, signal?: AbortSignal) {\n const request = TrainingProjectWriteSchema.parse(input);\n const result = this.readback(await this.request(`/${encodeURIComponent(request.id)}`, \"PUT\", request, signal), request.id);\n if (result.revision !== request.expectedRevision + 1 || contentHash(result.content) !== contentHash(request.content)) throw new Error(\"Project write revision mismatch.\");\n return result;\n }\n async archive(id: string, input: { operationId: string; expectedRevision: number; archived: boolean }, signal?: AbortSignal) {\n const request = TrainingProjectArchiveSchema.parse(input);\n const result = this.readback(await this.request(`/${encodeURIComponent(id)}/archive`, \"POST\", request, signal), id);\n if (result.revision !== request.expectedRevision + 1 || result.archived !== request.archived) throw new Error(\"Project archive receipt mismatch.\");\n return result;\n }\n private readback(value: unknown, id: string) {\n const result = TrainingProjectSchema.parse(value);\n if (result.id !== id || result.teamId !== this.options.teamId) throw new Error(\"Project identity mismatch.\");\n return result;\n }\n private async request(path: string, method: string, body?: unknown, signal?: AbortSignal): Promise<unknown> {\n const response = await (this.options.fetch ?? fetch)(`${this.baseUrl}/v1/training-projects${path}`, {\n method, signal, redirect: \"error\", headers: { Authorization: `Bearer ${this.options.apiKey}`, \"X-OpenPond-Team-Id\": this.options.teamId, \"Content-Type\": \"application/json\" },\n ...(body === undefined ? {} : { body: JSON.stringify(body) }),\n });\n if (!response.ok) throw new Error(`Project request failed (${response.status}).`);\n return response.json();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAAA,SAAS,wCAAwC;AACjD,SAAS,SAAS;AAGlB,IAAM,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAC3C,IAAM,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AACpC,IAAM,6BAA6B,EAAE,KAAK,CAAC,WAAW,aAAa,SAAS,0BAA0B,gBAAgB,WAAW,eAAe,cAAc,mBAAmB,YAAY,CAAC;AAC9L,IAAM,6BAA6B,EAAE,OAAO;AAAA,EACjD,MAAM;AAAA,EAA4B,YAAY;AAAA,EAAI,SAAS,0BAA0B,SAAS;AAAA,EAC9F,MAAM,EAAE,KAAK,CAAC,YAAY,cAAc,WAAW,UAAU,UAAU,cAAc,WAAW,QAAQ,CAAC;AAC3G,CAAC,EAAE,OAAO;AACH,IAAM,uBAAuB,EAAE,mBAAmB,QAAQ;AAAA,EAC/D,EAAE,OAAO;AAAA,IAAE,MAAM,EAAE,QAAQ,OAAO;AAAA,IAAG,YAAY;AAAA,IAAI,SAAS;AAAA,IAAI,UAAU,0BAA0B,SAAS;AAAA,IAC7G,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,QAAQ,WAAW,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,IAAI,GAAO,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,IAAI,GAAG;AAAA,EAAE,CAAC,EAAE,OAAO;AAAA,EAC/I,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAS,GAAG,qBAAqB,IAAI,QAAQ,iCAAi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Aa,QAAQ,SAAU,OAAM,IAAI,MAAM,mCAAmC;AACjJ,WAAO;AAAA,EACT;AAAA,EACQ,SAAS,OAAgB,IAAY;AAC3C,UAAM,SAAS,sBAAsB,MAAM,KAAK;AAChD,QAAI,OAAO,OAAO,MAAM,OAAO,WAAW,KAAK,QAAQ,OAAQ,OAAM,IAAI,MAAM,4BAA4B;AAC3G,WAAO;AAAA,EACT;AAAA,EACA,MAAc,QAAQ,MAAc,QAAgB,MAAgB,QAAwC;AAC1G,UAAM,WAAW,OAAO,KAAK,QAAQ,SAAS,OAAO,GAAG,KAAK,OAAO,wBAAwB,IAAI,IAAI;AAAA,MAClG;AAAA,MAAQ;AAAA,MAAQ,UAAU;AAAA,MAAS,SAAS,EAAE,eAAe,UAAU,KAAK,QAAQ,MAAM,IAAI,sBAAsB,KAAK,QAAQ,QAAQ,gBAAgB,mBAAmB;AAAA,MAC5K,GAAI,SAAS,SAAY,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,IAAI,EAAE;AAAA,IAC7D,CAAC;AACD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,2BAA2B,SAAS,MAAM,IAAI;AAChF,WAAO,SAAS,KAAK;AAAA,EACvB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/training.js
CHANGED
|
@@ -29,6 +29,8 @@ import {
|
|
|
29
29
|
TrainingJobStateSchema,
|
|
30
30
|
TrainingJobSubmissionSchema,
|
|
31
31
|
TrainingPreparationControlSchema,
|
|
32
|
+
TrainingPreparationListQuerySchema,
|
|
33
|
+
TrainingPreparationPageSchema,
|
|
32
34
|
TrainingPreparationPlanContentSchema,
|
|
33
35
|
TrainingPreparationPlanSchema,
|
|
34
36
|
TrainingPreparationReceiptSchema,
|
|
@@ -48,7 +50,7 @@ import {
|
|
|
48
50
|
trainingExecutionReceiptHash,
|
|
49
51
|
trainingInputArtifactUploadHash,
|
|
50
52
|
trainingJobSubmissionHash
|
|
51
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-KIBRMKJQ.js";
|
|
52
54
|
import {
|
|
53
55
|
OPENPOND_TRAINING_MEDIA_TYPE,
|
|
54
56
|
OPENPOND_TRAINING_PROTOCOL_MAJOR,
|
|
@@ -102,6 +104,8 @@ export {
|
|
|
102
104
|
TrainingJobStateSchema,
|
|
103
105
|
TrainingJobSubmissionSchema,
|
|
104
106
|
TrainingPreparationControlSchema,
|
|
107
|
+
TrainingPreparationListQuerySchema,
|
|
108
|
+
TrainingPreparationPageSchema,
|
|
105
109
|
TrainingPreparationPlanContentSchema,
|
|
106
110
|
TrainingPreparationPlanSchema,
|
|
107
111
|
TrainingPreparationReceiptSchema,
|