openpond-sdk 0.12.12 → 0.12.13

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.
Files changed (28) hide show
  1. package/dist/{chunk-RIN6Z56W.js → chunk-47I6LT4X.js} +4 -2
  2. package/dist/chunk-47I6LT4X.js.map +1 -0
  3. package/dist/{chunk-NKF5NIML.js → chunk-RN5G3DQN.js} +91 -15
  4. package/dist/chunk-RN5G3DQN.js.map +1 -0
  5. package/dist/experiment-evaluation-schedules.js +1 -1
  6. package/dist/experiments.js +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/model-starter-catalog.js +1 -1
  9. package/dist/model-starters.js +1 -1
  10. package/dist/taskset-packages.js +1 -1
  11. package/dist/tool-learning.js +127 -101
  12. package/dist/tool-learning.js.map +1 -1
  13. package/dist/types/packages/sdk/src/model-ordinary-taskset-reward.d.ts.map +1 -1
  14. package/dist/types/packages/sdk/src/model-supervised-training-defaults.d.ts +7 -0
  15. package/dist/types/packages/sdk/src/model-supervised-training-defaults.d.ts.map +1 -0
  16. package/dist/types/packages/sdk/src/model-taskset-runs.d.ts +216 -216
  17. package/dist/types/packages/sdk/src/model-training-defaults.d.ts +9 -2
  18. package/dist/types/packages/sdk/src/model-training-defaults.d.ts.map +1 -1
  19. package/dist/types/packages/sdk/src/tool-learning-client.d.ts.map +1 -1
  20. package/dist/types/packages/sdk/src/tool-learning-responses.d.ts +713 -0
  21. package/dist/types/packages/sdk/src/tool-learning-responses.d.ts.map +1 -0
  22. package/dist/types/packages/sdk/src/tool-learning.d.ts +1 -0
  23. package/dist/types/packages/sdk/src/tool-learning.d.ts.map +1 -1
  24. package/fixtures/python-foundation/operation-matrix.json +239 -1
  25. package/fixtures/python-foundation/schemas.json +24720 -19214
  26. package/package.json +1 -1
  27. package/dist/chunk-NKF5NIML.js.map +0 -1
  28. package/dist/chunk-RIN6Z56W.js.map +0 -1
@@ -14,14 +14,13 @@ import "./chunk-YLJ4XMA6.js";
14
14
  export * from "@openpond/evals/tool-learning";
15
15
 
16
16
  // src/tool-learning-client.ts
17
- import { z as z2 } from "zod";
17
+ import { z as z3 } from "zod";
18
18
  import { LearningRevisionRefSchema } from "@openpond/evals/learning";
19
19
  import {
20
- TOOL_LEARNING_LIMITS as TOOL_LEARNING_LIMITS2,
20
+ TOOL_LEARNING_LIMITS as TOOL_LEARNING_LIMITS3,
21
21
  ToolLearningRegistrationSchema,
22
- ToolLearningInstallationSchema,
23
- ToolLearningIdSchema,
24
- ToolEpisodeEventSchema as ToolEpisodeEventSchema2,
22
+ ToolLearningInstallationSchema as ToolLearningInstallationSchema2,
23
+ ToolLearningIdSchema as ToolLearningIdSchema2,
25
24
  ToolLearningRefSchema as ToolLearningRefSchema2,
26
25
  ToolLearningDecisionSchema,
27
26
  boundedToolLearningSchema,
@@ -136,85 +135,136 @@ function assembleToolLearningEpisode(raw) {
136
135
  });
137
136
  }
138
137
 
138
+ // src/tool-learning-responses.ts
139
+ import { z as z2 } from "zod";
140
+ import {
141
+ TOOL_LEARNING_LIMITS as TOOL_LEARNING_LIMITS2,
142
+ ToolEpisodeEventSchema as ToolEpisodeEventSchema2,
143
+ ToolLearningIdSchema,
144
+ ToolLearningInstallationSchema,
145
+ ToolLearningScopeSchema
146
+ } from "@openpond/evals/tool-learning";
147
+ var ToolLearningRegistrationReceiptSchema = z2.object({
148
+ installation: ToolLearningInstallationSchema,
149
+ apiKey: LearningSourceCredentialSecretSchema
150
+ }).strict();
151
+ var ToolLearningInstallationPageSchema = z2.object({
152
+ items: z2.array(ToolLearningInstallationSchema).max(30),
153
+ nextCursor: ToolLearningIdSchema.nullable()
154
+ }).strict();
155
+ var ToolLearningEpisodePageSchema = z2.object({
156
+ installationId: ToolLearningIdSchema,
157
+ scope: ToolLearningScopeSchema,
158
+ items: z2.array(
159
+ z2.object({
160
+ episodeId: ToolLearningIdSchema,
161
+ eventCount: z2.number().int().positive(),
162
+ lastReceivedAt: z2.iso.datetime()
163
+ }).strict()
164
+ ).max(30),
165
+ nextCursor: ToolLearningIdSchema.nullable(),
166
+ learningEnrollment: z2.literal(false)
167
+ }).strict();
168
+ var ToolLearningEpisodeDetailSchema = z2.object({
169
+ installationId: ToolLearningIdSchema,
170
+ episodeId: ToolLearningIdSchema,
171
+ scope: ToolLearningScopeSchema,
172
+ events: z2.array(ToolEpisodeEventSchema2).max(TOOL_LEARNING_LIMITS2.eventsPerEpisode),
173
+ state: ToolLearningEpisodeAssemblySchema.shape.state,
174
+ assembly: ToolLearningEpisodeAssemblySchema,
175
+ verificationAuthority: z2.literal("not_granted"),
176
+ learningEnrollment: z2.literal(false)
177
+ }).strict();
178
+ var ToolLearningPurgeRequestSchema = z2.object({
179
+ operationId: ToolLearningIdSchema,
180
+ expectedRevision: z2.number().int().positive()
181
+ }).strict();
182
+ var ToolLearningPurgeReceiptSchema = z2.object({
183
+ installationId: ToolLearningIdSchema,
184
+ operationId: ToolLearningIdSchema,
185
+ purgedEvents: z2.number().int().nonnegative(),
186
+ learningEnrollment: z2.literal(false)
187
+ }).strict();
188
+
139
189
  // src/tool-learning-client.ts
140
190
  var ToolLearningRegistrationRequestSchema = boundedToolLearningSchema(
141
- z2.object({
191
+ z3.object({
142
192
  registration: ToolLearningRegistrationSchema,
143
- credential: z2.object({ apiKey: LearningSourceCredentialSecretSchema, expiresAt: z2.iso.datetime() }).strict()
193
+ credential: z3.object({ apiKey: LearningSourceCredentialSecretSchema, expiresAt: z3.iso.datetime() }).strict()
144
194
  }).strict(),
145
- TOOL_LEARNING_LIMITS2.eventBytes
195
+ TOOL_LEARNING_LIMITS3.eventBytes
146
196
  );
147
197
  var ToolLearningProjectionRequestSchema = boundedToolLearningSchema(
148
- z2.object({
149
- operationId: ToolLearningIdSchema,
150
- expectedRevision: z2.number().int().positive(),
151
- episodeId: ToolLearningIdSchema,
198
+ z3.object({
199
+ operationId: ToolLearningIdSchema2,
200
+ expectedRevision: z3.number().int().positive(),
201
+ episodeId: ToolLearningIdSchema2,
152
202
  failure: ToolLearningRefSchema2,
153
203
  recovery: ToolLearningRefSchema2,
154
204
  taskDefinition: LearningRevisionRefSchema,
155
- familyKey: ToolLearningIdSchema,
156
- split: z2.literal("train"),
205
+ familyKey: ToolLearningIdSchema2,
206
+ split: z3.literal("train"),
157
207
  proposedTarget: ToolLearningDecisionSchema,
158
- saveToPrivateDataset: z2.literal(true),
159
- targetApproval: z2.literal("pending_owner_review")
208
+ saveToPrivateDataset: z3.literal(true),
209
+ targetApproval: z3.literal("pending_owner_review")
160
210
  }).strict(),
161
- TOOL_LEARNING_LIMITS2.eventBytes
211
+ TOOL_LEARNING_LIMITS3.eventBytes
162
212
  );
163
213
  var ToolLearningProjectionReceiptSchema = boundedToolLearningSchema(
164
- z2.object({
165
- installationId: ToolLearningIdSchema,
166
- projectId: ToolLearningIdSchema,
167
- operationId: ToolLearningIdSchema,
214
+ z3.object({
215
+ installationId: ToolLearningIdSchema2,
216
+ projectId: ToolLearningIdSchema2,
217
+ operationId: ToolLearningIdSchema2,
168
218
  source: LearningRevisionRefSchema,
169
219
  evidence: LearningRevisionRefSchema,
170
- originHash: z2.string().regex(/^[a-f0-9]{64}$/),
171
- requestHash: z2.string().regex(/^[a-f0-9]{64}$/),
172
- projectedAt: z2.iso.datetime(),
173
- targetApproval: z2.literal("pending_owner_review"),
174
- learningEnrollment: z2.literal(false)
220
+ originHash: z3.string().regex(/^[a-f0-9]{64}$/),
221
+ requestHash: z3.string().regex(/^[a-f0-9]{64}$/),
222
+ projectedAt: z3.iso.datetime(),
223
+ targetApproval: z3.literal("pending_owner_review"),
224
+ learningEnrollment: z3.literal(false)
175
225
  }).strict(),
176
- TOOL_LEARNING_LIMITS2.eventBytes
226
+ TOOL_LEARNING_LIMITS3.eventBytes
177
227
  );
178
228
  var ToolLearningRoutingRequestSchema = boundedToolLearningSchema(
179
- z2.object({
180
- operationId: ToolLearningIdSchema,
181
- expectedRevision: z2.number().int().nonnegative(),
182
- state: z2.enum(["enabled", "disabled"]),
183
- modelId: ToolLearningIdSchema,
184
- qualification: z2.discriminatedUnion("kind", [
185
- z2.object({ kind: z2.literal("integration"), evaluationRunId: ToolLearningIdSchema }).strict(),
186
- z2.object({
187
- kind: z2.literal("learned"),
188
- evaluationRunId: ToolLearningIdSchema,
189
- baselineRunId: ToolLearningIdSchema,
190
- trainingRunId: ToolLearningIdSchema
229
+ z3.object({
230
+ operationId: ToolLearningIdSchema2,
231
+ expectedRevision: z3.number().int().nonnegative(),
232
+ state: z3.enum(["enabled", "disabled"]),
233
+ modelId: ToolLearningIdSchema2,
234
+ qualification: z3.discriminatedUnion("kind", [
235
+ z3.object({ kind: z3.literal("integration"), evaluationRunId: ToolLearningIdSchema2 }).strict(),
236
+ z3.object({
237
+ kind: z3.literal("learned"),
238
+ evaluationRunId: ToolLearningIdSchema2,
239
+ baselineRunId: ToolLearningIdSchema2,
240
+ trainingRunId: ToolLearningIdSchema2
191
241
  }).strict()
192
242
  ]),
193
- capabilities: z2.array(ToolLearningCapabilitySchema.omit({ qualification: true })).min(1).max(16),
194
- limits: z2.object({
195
- maxOutputTokens: z2.number().int().min(128).max(2048),
196
- maximumCallUsd: z2.number().positive().max(1),
197
- maximumDayUsd: z2.number().positive().max(10),
198
- maximumSessionCalls: z2.number().int().min(1).max(20),
199
- maximumDayCalls: z2.number().int().min(1).max(200)
243
+ capabilities: z3.array(ToolLearningCapabilitySchema.omit({ qualification: true })).min(1).max(16),
244
+ limits: z3.object({
245
+ maxOutputTokens: z3.number().int().min(128).max(2048),
246
+ maximumCallUsd: z3.number().positive().max(1),
247
+ maximumDayUsd: z3.number().positive().max(10),
248
+ maximumSessionCalls: z3.number().int().min(1).max(20),
249
+ maximumDayCalls: z3.number().int().min(1).max(200)
200
250
  }).strict()
201
251
  }).strict(),
202
- TOOL_LEARNING_LIMITS2.eventBytes
252
+ TOOL_LEARNING_LIMITS3.eventBytes
203
253
  );
204
254
  var ToolLearningRoutingSchema = boundedToolLearningSchema(
205
- z2.object({
206
- installationId: ToolLearningIdSchema,
207
- scope: z2.object({ teamId: ToolLearningIdSchema, projectId: ToolLearningIdSchema }).strict(),
208
- revision: z2.number().int().positive(),
209
- operationId: ToolLearningIdSchema,
210
- requestHash: z2.string().regex(/^[a-f0-9]{64}$/),
255
+ z3.object({
256
+ installationId: ToolLearningIdSchema2,
257
+ scope: z3.object({ teamId: ToolLearningIdSchema2, projectId: ToolLearningIdSchema2 }).strict(),
258
+ revision: z3.number().int().positive(),
259
+ operationId: ToolLearningIdSchema2,
260
+ requestHash: z3.string().regex(/^[a-f0-9]{64}$/),
211
261
  configuration: ToolLearningRoutingRequestSchema,
212
262
  modelRelease: ToolLearningRefSchema2,
213
- policySystemPrompt: z2.string().min(1).max(16384),
214
- capabilities: z2.array(ToolLearningCapabilitySchema).max(16),
215
- updatedAt: z2.iso.datetime()
263
+ policySystemPrompt: z3.string().min(1).max(16384),
264
+ capabilities: z3.array(ToolLearningCapabilitySchema).max(16),
265
+ updatedAt: z3.iso.datetime()
216
266
  }).strict(),
217
- TOOL_LEARNING_LIMITS2.eventBytes
267
+ TOOL_LEARNING_LIMITS3.eventBytes
218
268
  );
219
269
  function prepareToolLearningRegistration(registration, expiresAt) {
220
270
  const prepared = createSourceCredentialRequest({
@@ -251,10 +301,9 @@ var OpenPondToolLearningClient = class {
251
301
  const input = ToolLearningRegistrationRequestSchema.parse(value);
252
302
  if (input.registration.projectId !== this.#options.projectId)
253
303
  throw new Error("tool_learning_project_mismatch");
254
- const result = z2.object({
255
- installation: ToolLearningInstallationSchema,
256
- apiKey: LearningSourceCredentialSecretSchema
257
- }).strict().parse(await this.#request("installations", "POST", input, signal));
304
+ const result = ToolLearningRegistrationReceiptSchema.parse(
305
+ await this.#request("installations", "POST", input, signal)
306
+ );
258
307
  this.#installation(result.installation, input.registration.installationId);
259
308
  if (result.apiKey !== input.credential.apiKey)
260
309
  throw new Error("tool_learning_credential_mismatch");
@@ -264,17 +313,14 @@ var OpenPondToolLearningClient = class {
264
313
  return result;
265
314
  }
266
315
  async installation(id, signal) {
267
- const result = ToolLearningInstallationSchema.parse(
316
+ const result = ToolLearningInstallationSchema2.parse(
268
317
  await this.#request(`installations/${encodeURIComponent(id)}`, "GET", void 0, signal)
269
318
  );
270
319
  this.#installation(result, id);
271
320
  return result;
272
321
  }
273
322
  async installations(after, signal) {
274
- const result = z2.object({
275
- items: z2.array(ToolLearningInstallationSchema).max(30),
276
- nextCursor: ToolLearningIdSchema.nullable()
277
- }).strict().parse(
323
+ const result = ToolLearningInstallationPageSchema.parse(
278
324
  await this.#request(
279
325
  `installations?projectId=${encodeURIComponent(this.#options.projectId)}${after ? `&after=${encodeURIComponent(after)}` : ""}`,
280
326
  "GET",
@@ -288,19 +334,7 @@ var OpenPondToolLearningClient = class {
288
334
  return result;
289
335
  }
290
336
  async episodes(installationId, after, signal) {
291
- const result = z2.object({
292
- installationId: ToolLearningIdSchema,
293
- scope: z2.object({ teamId: ToolLearningIdSchema, projectId: ToolLearningIdSchema }).strict(),
294
- items: z2.array(
295
- z2.object({
296
- episodeId: ToolLearningIdSchema,
297
- eventCount: z2.number().int().positive(),
298
- lastReceivedAt: z2.iso.datetime()
299
- }).strict()
300
- ).max(30),
301
- nextCursor: ToolLearningIdSchema.nullable(),
302
- learningEnrollment: z2.literal(false)
303
- }).strict().parse(
337
+ const result = ToolLearningEpisodePageSchema.parse(
304
338
  await this.#request(
305
339
  `installations/${encodeURIComponent(installationId)}/episodes${after ? `?after=${encodeURIComponent(after)}` : ""}`,
306
340
  "GET",
@@ -313,16 +347,7 @@ var OpenPondToolLearningClient = class {
313
347
  return result;
314
348
  }
315
349
  async episode(installationId, episodeId, signal) {
316
- const result = z2.object({
317
- installationId: ToolLearningIdSchema,
318
- episodeId: ToolLearningIdSchema,
319
- scope: z2.object({ teamId: ToolLearningIdSchema, projectId: ToolLearningIdSchema }).strict(),
320
- events: z2.array(ToolEpisodeEventSchema2).max(TOOL_LEARNING_LIMITS2.eventsPerEpisode),
321
- state: ToolLearningEpisodeAssemblySchema.shape.state,
322
- assembly: ToolLearningEpisodeAssemblySchema,
323
- verificationAuthority: z2.literal("not_granted"),
324
- learningEnrollment: z2.literal(false)
325
- }).strict().parse(
350
+ const result = ToolLearningEpisodeDetailSchema.parse(
326
351
  await this.#request(
327
352
  `installations/${encodeURIComponent(installationId)}/episodes/${encodeURIComponent(episodeId)}`,
328
353
  "GET",
@@ -339,13 +364,8 @@ var OpenPondToolLearningClient = class {
339
364
  return result;
340
365
  }
341
366
  async purge(installationId, input, signal) {
342
- const request = z2.object({ operationId: ToolLearningIdSchema, expectedRevision: z2.number().int().positive() }).strict().parse(input);
343
- const result = z2.object({
344
- installationId: ToolLearningIdSchema,
345
- operationId: ToolLearningIdSchema,
346
- purgedEvents: z2.number().int().nonnegative(),
347
- learningEnrollment: z2.literal(false)
348
- }).strict().parse(
367
+ const request = ToolLearningPurgeRequestSchema.parse(input);
368
+ const result = ToolLearningPurgeReceiptSchema.parse(
349
369
  await this.#request(
350
370
  `installations/${encodeURIComponent(installationId)}/purge`,
351
371
  "POST",
@@ -373,7 +393,7 @@ var OpenPondToolLearningClient = class {
373
393
  }
374
394
  async setState(id, value, signal) {
375
395
  const input = ToolLearningInstallationUpdateSchema.parse(value);
376
- const result = ToolLearningInstallationSchema.parse(
396
+ const result = ToolLearningInstallationSchema2.parse(
377
397
  await this.#request(`installations/${encodeURIComponent(id)}`, "PATCH", input, signal)
378
398
  );
379
399
  this.#installation(result, id);
@@ -472,7 +492,7 @@ var OpenPondToolLearningClient = class {
472
492
  if (body !== void 0)
473
493
  assertBoundedTaskJson(
474
494
  body,
475
- TOOL_LEARNING_LIMITS2.eventBytes * TOOL_LEARNING_LIMITS2.eventsPerAppend
495
+ TOOL_LEARNING_LIMITS3.eventBytes * TOOL_LEARNING_LIMITS3.eventsPerAppend
476
496
  );
477
497
  const timeout = AbortSignal.timeout(3e4);
478
498
  const response = await (this.#options.fetch ?? globalThis.fetch)(
@@ -492,12 +512,12 @@ var OpenPondToolLearningClient = class {
492
512
  );
493
513
  const value = await readBoundedJsonResponse(
494
514
  response,
495
- TOOL_LEARNING_LIMITS2.eventBytes * TOOL_LEARNING_LIMITS2.eventsPerAppend,
515
+ TOOL_LEARNING_LIMITS3.eventBytes * TOOL_LEARNING_LIMITS3.eventsPerAppend,
496
516
  "Tool learning response"
497
517
  );
498
518
  if (!response.ok) {
499
- const error = z2.object({
500
- code: z2.string().regex(/^[a-z0-9_]+$/).max(200)
519
+ const error = z3.object({
520
+ code: z3.string().regex(/^[a-z0-9_]+$/).max(200)
501
521
  }).passthrough().safeParse(value);
502
522
  throw new OpenPondToolLearningError(
503
523
  response.status,
@@ -511,8 +531,14 @@ export {
511
531
  OpenPondToolLearningClient,
512
532
  OpenPondToolLearningError,
513
533
  ToolLearningEpisodeAssemblySchema,
534
+ ToolLearningEpisodeDetailSchema,
535
+ ToolLearningEpisodePageSchema,
536
+ ToolLearningInstallationPageSchema,
514
537
  ToolLearningProjectionReceiptSchema,
515
538
  ToolLearningProjectionRequestSchema,
539
+ ToolLearningPurgeReceiptSchema,
540
+ ToolLearningPurgeRequestSchema,
541
+ ToolLearningRegistrationReceiptSchema,
516
542
  ToolLearningRegistrationRequestSchema,
517
543
  ToolLearningRoutingRequestSchema,
518
544
  ToolLearningRoutingSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tool-learning.ts","../src/tool-learning-client.ts","../src/tool-learning-episodes.ts"],"sourcesContent":["/** Portable episode and recovery-consultation protocol; no installation side effects. */\nexport * from \"@openpond/evals/tool-learning\";\nexport * from \"./tool-learning-client.js\";\nexport * from \"./tool-learning-episodes.js\";\n","import { z } from \"zod\";\nimport { contentHash } from \"@openpond/harness\";\nimport { LearningRevisionRefSchema } from \"@openpond/evals/learning\";\nimport {\n TOOL_LEARNING_LIMITS,\n ToolLearningRegistrationSchema,\n ToolLearningInstallationSchema,\n ToolLearningIdSchema,\n ToolEpisodeEventSchema,\n ToolLearningRefSchema,\n ToolLearningDecisionSchema,\n boundedToolLearningSchema,\n ToolLearningInstallationUpdateSchema,\n ToolEpisodeAppendSchema,\n ToolEpisodeAppendReceiptSchema,\n ToolLearningManifestSchema,\n ToolLearningCapabilitySchema,\n ToolLearningConsultationRequestSchema,\n assertToolLearningConsultationResponse,\n type ToolLearningRegistration,\n type ToolEpisodeAppend,\n type ToolLearningConsultationRequest,\n} from \"@openpond/evals/tool-learning\";\nimport {\n LearningSourceCredentialSecretSchema,\n createSourceCredentialRequest,\n} from \"./learning-credentials.js\";\nimport { assertBoundedTaskJson } from \"@openpond/evals/task-schema\";\nimport { readBoundedJsonResponse } from \"./protocol.js\";\nimport { assembleToolLearningEpisode, ToolLearningEpisodeAssemblySchema } from \"./tool-learning-episodes.js\";\n\n/** Prepare and retain this request privately before registration. Retrying the\n * same bytes recovers issuance without storing plaintext on the host. */\nexport const ToolLearningRegistrationRequestSchema = boundedToolLearningSchema(\n z\n .object({\n registration: ToolLearningRegistrationSchema,\n credential: z\n .object({ apiKey: LearningSourceCredentialSecretSchema, expiresAt: z.iso.datetime() })\n .strict(),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\n\nexport const ToolLearningProjectionRequestSchema = boundedToolLearningSchema(\n z\n .object({\n operationId: ToolLearningIdSchema,\n expectedRevision: z.number().int().positive(),\n episodeId: ToolLearningIdSchema,\n failure: ToolLearningRefSchema,\n recovery: ToolLearningRefSchema,\n taskDefinition: LearningRevisionRefSchema,\n familyKey: ToolLearningIdSchema,\n split: z.literal(\"train\"),\n proposedTarget: ToolLearningDecisionSchema,\n saveToPrivateDataset: z.literal(true),\n targetApproval: z.literal(\"pending_owner_review\"),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\nexport const ToolLearningProjectionReceiptSchema = boundedToolLearningSchema(\n z\n .object({\n installationId: ToolLearningIdSchema,\n projectId: ToolLearningIdSchema,\n operationId: ToolLearningIdSchema,\n source: LearningRevisionRefSchema,\n evidence: LearningRevisionRefSchema,\n originHash: z.string().regex(/^[a-f0-9]{64}$/),\n requestHash: z.string().regex(/^[a-f0-9]{64}$/),\n projectedAt: z.iso.datetime(),\n targetApproval: z.literal(\"pending_owner_review\"),\n learningEnrollment: z.literal(false),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\n\n/** Explicit owner selection. Capturing events never authorizes inference spend. */\nexport const ToolLearningRoutingRequestSchema = boundedToolLearningSchema(\n z\n .object({\n operationId: ToolLearningIdSchema,\n expectedRevision: z.number().int().nonnegative(),\n state: z.enum([\"enabled\", \"disabled\"]),\n modelId: ToolLearningIdSchema,\n qualification: z.discriminatedUnion(\"kind\", [\n z\n .object({ kind: z.literal(\"integration\"), evaluationRunId: ToolLearningIdSchema })\n .strict(),\n z\n .object({\n kind: z.literal(\"learned\"),\n evaluationRunId: ToolLearningIdSchema,\n baselineRunId: ToolLearningIdSchema,\n trainingRunId: ToolLearningIdSchema,\n })\n .strict(),\n ]),\n capabilities: z\n .array(ToolLearningCapabilitySchema.omit({ qualification: true }))\n .min(1)\n .max(16),\n limits: z\n .object({\n maxOutputTokens: z.number().int().min(128).max(2048),\n maximumCallUsd: z.number().positive().max(1),\n maximumDayUsd: z.number().positive().max(10),\n maximumSessionCalls: z.number().int().min(1).max(20),\n maximumDayCalls: z.number().int().min(1).max(200),\n })\n .strict(),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\nexport const ToolLearningRoutingSchema = boundedToolLearningSchema(\n z\n .object({\n installationId: ToolLearningIdSchema,\n scope: z.object({ teamId: ToolLearningIdSchema, projectId: ToolLearningIdSchema }).strict(),\n revision: z.number().int().positive(),\n operationId: ToolLearningIdSchema,\n requestHash: z.string().regex(/^[a-f0-9]{64}$/),\n configuration: ToolLearningRoutingRequestSchema,\n modelRelease: ToolLearningRefSchema,\n policySystemPrompt: z.string().min(1).max(16384),\n capabilities: z.array(ToolLearningCapabilitySchema).max(16),\n updatedAt: z.iso.datetime(),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\n\nexport function prepareToolLearningRegistration(\n registration: ToolLearningRegistration,\n expiresAt: string,\n) {\n const prepared = createSourceCredentialRequest({\n sourceId: registration.installationId,\n name: \"Tool learning installation\",\n expiresAt,\n });\n return ToolLearningRegistrationRequestSchema.parse({\n registration,\n credential: { apiKey: prepared.apiKey, expiresAt },\n });\n}\n\nexport class OpenPondToolLearningError extends Error {\n constructor(\n readonly status: number,\n readonly code: string,\n ) {\n super(`Tool learning request failed (${status}): ${code}`);\n this.name = \"OpenPondToolLearningError\";\n }\n}\n\n/** Owner credentials register/control installations. External hooks and MCP\n * use only the separate installation credential returned by registration. */\ntype ToolLearningClientOptions = {\n baseUrl: string;\n apiKey: string;\n teamId: string;\n projectId: string;\n fetch?: typeof globalThis.fetch;\n};\n\nexport class OpenPondToolLearningClient {\n readonly #baseUrl: string;\n readonly #options: ToolLearningClientOptions;\n constructor(options: ToolLearningClientOptions) {\n this.#options = { ...options };\n\n const url = new URL(options.baseUrl);\n if (\n ![\"https:\", \"http:\"].includes(url.protocol) ||\n url.username ||\n url.password ||\n url.search ||\n url.hash ||\n !options.apiKey.trim() ||\n !options.teamId.trim() ||\n !options.projectId.trim()\n )\n throw new Error(\"tool_learning_client_scope_required\");\n this.#baseUrl = url.toString().replace(/\\/+$/, \"\");\n }\n\n async register(\n value: z.input<typeof ToolLearningRegistrationRequestSchema>,\n signal?: AbortSignal,\n ) {\n const input = ToolLearningRegistrationRequestSchema.parse(value);\n if (input.registration.projectId !== this.#options.projectId)\n throw new Error(\"tool_learning_project_mismatch\");\n const result = z\n .object({\n installation: ToolLearningInstallationSchema,\n apiKey: LearningSourceCredentialSecretSchema,\n })\n .strict()\n .parse(await this.#request(\"installations\", \"POST\", input, signal));\n this.#installation(result.installation, input.registration.installationId);\n if (result.apiKey !== input.credential.apiKey)\n throw new Error(\"tool_learning_credential_mismatch\");\n const installation = result.installation;\n if (\n installation.client !== input.registration.client ||\n installation.clientVersion !== input.registration.clientVersion ||\n installation.machineSourceId !== input.registration.machineSourceId ||\n contentHash(installation.adapterRelease) !== contentHash(input.registration.adapterRelease) ||\n contentHash(installation.collectionPolicy) !==\n contentHash(input.registration.collectionPolicy) ||\n installation.collectionPolicyHash !== contentHash(input.registration.collectionPolicy) ||\n installation.credential?.expiresAt !== input.credential.expiresAt\n )\n throw new Error(\"tool_learning_registration_receipt_mismatch\");\n return result;\n }\n\n async installation(id: string, signal?: AbortSignal) {\n const result = ToolLearningInstallationSchema.parse(\n await this.#request(`installations/${encodeURIComponent(id)}`, \"GET\", undefined, signal),\n );\n this.#installation(result, id);\n return result;\n }\n\n async installations(after?: string, signal?: AbortSignal) {\n const result = z\n .object({\n items: z.array(ToolLearningInstallationSchema).max(30),\n nextCursor: ToolLearningIdSchema.nullable(),\n })\n .strict()\n .parse(\n await this.#request(\n `installations?projectId=${encodeURIComponent(this.#options.projectId)}${after ? `&after=${encodeURIComponent(after)}` : \"\"}`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n for (const installation of result.items) this.#installation(installation, installation.id);\n if (result.nextCursor !== null && result.nextCursor !== result.items.at(-1)?.id)\n throw new Error(\"tool_learning_installation_cursor_mismatch\");\n return result;\n }\n\n async episodes(installationId: string, after?: string, signal?: AbortSignal) {\n const result = z\n .object({\n installationId: ToolLearningIdSchema,\n scope: z.object({ teamId: ToolLearningIdSchema, projectId: ToolLearningIdSchema }).strict(),\n items: z\n .array(\n z\n .object({\n episodeId: ToolLearningIdSchema,\n eventCount: z.number().int().positive(),\n lastReceivedAt: z.iso.datetime(),\n })\n .strict(),\n )\n .max(30),\n nextCursor: ToolLearningIdSchema.nullable(),\n learningEnrollment: z.literal(false),\n })\n .strict()\n .parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/episodes${after ? `?after=${encodeURIComponent(after)}` : \"\"}`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n if (\n result.installationId !== installationId ||\n result.scope.teamId !== this.#options.teamId ||\n result.scope.projectId !== this.#options.projectId ||\n (result.nextCursor !== null && result.nextCursor !== result.items.at(-1)?.episodeId)\n )\n throw new Error(\"tool_learning_episode_page_mismatch\");\n return result;\n }\n\n async episode(installationId: string, episodeId: string, signal?: AbortSignal) {\n const result = z\n .object({\n installationId: ToolLearningIdSchema,\n episodeId: ToolLearningIdSchema,\n scope: z.object({ teamId: ToolLearningIdSchema, projectId: ToolLearningIdSchema }).strict(),\n events: z.array(ToolEpisodeEventSchema).max(TOOL_LEARNING_LIMITS.eventsPerEpisode),\n state: ToolLearningEpisodeAssemblySchema.shape.state,\n assembly: ToolLearningEpisodeAssemblySchema,\n verificationAuthority: z.literal(\"not_granted\"),\n learningEnrollment: z.literal(false),\n })\n .strict()\n .parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/episodes/${encodeURIComponent(episodeId)}`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n if (\n result.installationId !== installationId ||\n result.episodeId !== episodeId ||\n result.scope.teamId !== this.#options.teamId ||\n result.scope.projectId !== this.#options.projectId ||\n result.events.some(\n (event) => event.installationId !== installationId || event.episodeId !== episodeId,\n )\n )\n throw new Error(\"tool_learning_episode_scope_mismatch\");\n if (result.state !== result.assembly.state ||\n contentHash(assembleToolLearningEpisode(result.events)) !== contentHash(result.assembly))\n throw new Error(\"tool_learning_episode_assembly_mismatch\");\n return result;\n }\n\n async purge(\n installationId: string,\n input: { operationId: string; expectedRevision: number },\n signal?: AbortSignal,\n ) {\n const request = z\n .object({ operationId: ToolLearningIdSchema, expectedRevision: z.number().int().positive() })\n .strict()\n .parse(input);\n const result = z\n .object({\n installationId: ToolLearningIdSchema,\n operationId: ToolLearningIdSchema,\n purgedEvents: z.number().int().nonnegative(),\n learningEnrollment: z.literal(false),\n })\n .strict()\n .parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/purge`,\n \"POST\",\n request,\n signal,\n ),\n );\n if (result.installationId !== installationId || result.operationId !== request.operationId)\n throw new Error(\"tool_learning_purge_scope_mismatch\");\n return result;\n }\n\n async project(\n installationId: string,\n value: z.input<typeof ToolLearningProjectionRequestSchema>,\n signal?: AbortSignal,\n ) {\n const input = ToolLearningProjectionRequestSchema.parse(value);\n const result = ToolLearningProjectionReceiptSchema.parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/project`,\n \"POST\",\n input,\n signal,\n ),\n );\n if (\n result.installationId !== installationId ||\n result.projectId !== this.#options.projectId ||\n result.operationId !== input.operationId ||\n result.requestHash !== contentHash(input)\n )\n throw new Error(\"tool_learning_projection_scope_mismatch\");\n return result;\n }\n\n async setState(\n id: string,\n value: z.input<typeof ToolLearningInstallationUpdateSchema>,\n signal?: AbortSignal,\n ) {\n const input = ToolLearningInstallationUpdateSchema.parse(value);\n const result = ToolLearningInstallationSchema.parse(\n await this.#request(`installations/${encodeURIComponent(id)}`, \"PATCH\", input, signal),\n );\n this.#installation(result, id);\n if (result.state !== input.state) throw new Error(\"tool_learning_state_mismatch\");\n return result;\n }\n\n async append(value: ToolEpisodeAppend, signal?: AbortSignal) {\n const input = ToolEpisodeAppendSchema.parse(value);\n const result = ToolEpisodeAppendReceiptSchema.parse(\n await this.#request(\"episodes\", \"POST\", input, signal),\n );\n if (\n result.operationId !== input.operationId ||\n result.installationId !== input.installationId ||\n result.teamId !== this.#options.teamId ||\n result.projectId !== this.#options.projectId ||\n result.requestHash !== contentHash(input) ||\n result.events.length !== input.events.length ||\n new Set(result.events.map((event) => event.eventId)).size !== result.events.length\n )\n throw new Error(\"tool_learning_append_receipt_mismatch\");\n for (const event of result.events) {\n const submitted = input.events.find((value) => value.eventId === event.eventId);\n if (!submitted || submitted.contentHash !== event.contentHash)\n throw new Error(\"tool_learning_append_event_mismatch\");\n }\n return result;\n }\n\n async routing(installationId: string, signal?: AbortSignal) {\n return this.#routing(\n installationId,\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/routing`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n }\n\n async configureRouting(\n installationId: string,\n value: z.input<typeof ToolLearningRoutingRequestSchema>,\n signal?: AbortSignal,\n ) {\n const input = ToolLearningRoutingRequestSchema.parse(value);\n const result = this.#routing(\n installationId,\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/routing`,\n \"POST\",\n input,\n signal,\n ),\n );\n if (\n result.operationId !== input.operationId ||\n result.requestHash !== contentHash(input) ||\n contentHash(result.configuration) !== contentHash(input)\n )\n throw new Error(\"tool_learning_routing_receipt_mismatch\");\n return result;\n }\n\n #routing(installationId: string, value: unknown) {\n const result = ToolLearningRoutingSchema.parse(value);\n if (\n result.installationId !== installationId ||\n result.scope.teamId !== this.#options.teamId ||\n result.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_routing_scope_mismatch\");\n return result;\n }\n\n async manifest(installationId: string, signal?: AbortSignal) {\n const result = ToolLearningManifestSchema.parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/manifest`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n if (\n result.installationId !== installationId ||\n result.scope.teamId !== this.#options.teamId ||\n result.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_manifest_scope_mismatch\");\n if (\n Date.parse(result.expiresAt) <= Date.now() ||\n Date.parse(result.issuedAt) > Date.now() + 30000\n )\n throw new Error(\"tool_learning_manifest_expired\");\n return result;\n }\n\n async consult(value: ToolLearningConsultationRequest, signal?: AbortSignal) {\n const input = ToolLearningConsultationRequestSchema.parse(value);\n if (\n input.scope.teamId !== this.#options.teamId ||\n input.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_consultation_scope_mismatch\");\n return assertToolLearningConsultationResponse(\n input,\n await this.#request(\"consultations\", \"POST\", input, signal),\n );\n }\n\n async consultation(value: ToolLearningConsultationRequest, signal?: AbortSignal) {\n const input = ToolLearningConsultationRequestSchema.parse(value);\n if (\n input.scope.teamId !== this.#options.teamId ||\n input.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_consultation_scope_mismatch\");\n return assertToolLearningConsultationResponse(\n input,\n await this.#request(\n `installations/${encodeURIComponent(input.installationId)}/consultations/${encodeURIComponent(input.operationId)}`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n }\n\n #installation(value: z.infer<typeof ToolLearningInstallationSchema>, id: string) {\n if (\n value.id !== id ||\n value.scope.teamId !== this.#options.teamId ||\n value.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_installation_scope_mismatch\");\n }\n\n async #request(\n path: string,\n method: string,\n body: unknown,\n signal?: AbortSignal,\n ): Promise<unknown> {\n if (body !== undefined)\n assertBoundedTaskJson(\n body,\n TOOL_LEARNING_LIMITS.eventBytes * TOOL_LEARNING_LIMITS.eventsPerAppend,\n );\n const timeout = AbortSignal.timeout(30000);\n const response = await (this.#options.fetch ?? globalThis.fetch)(\n `${this.#baseUrl}/v1/tool-learning/${path}`,\n {\n method,\n redirect: \"error\",\n signal: signal ? AbortSignal.any([signal, timeout]) : timeout,\n headers: {\n Authorization: `Bearer ${this.#options.apiKey}`,\n \"X-OpenPond-Team-Id\": this.#options.teamId,\n Accept: \"application/json\",\n ...(body === undefined ? {} : { \"Content-Type\": \"application/json\" }),\n },\n ...(body === undefined ? {} : { body: JSON.stringify(body) }),\n },\n );\n const value = await readBoundedJsonResponse(\n response,\n TOOL_LEARNING_LIMITS.eventBytes * TOOL_LEARNING_LIMITS.eventsPerAppend,\n \"Tool learning response\",\n );\n if (!response.ok) {\n const error = z\n .object({\n code: z\n .string()\n .regex(/^[a-z0-9_]+$/)\n .max(200),\n })\n .passthrough()\n .safeParse(value);\n throw new OpenPondToolLearningError(\n response.status,\n error.success ? error.data.code : \"tool_learning_request_failed\",\n );\n }\n return value;\n }\n}\n","import { z } from \"zod\";\nimport { contentHash } from \"@openpond/harness\";\nimport {\n TOOL_LEARNING_LIMITS,\n ToolEpisodeEventSchema,\n ToolLearningHashSchema,\n ToolLearningRefSchema,\n type ToolEpisodeEvent,\n} from \"@openpond/evals/tool-learning\";\n\nexport const ToolLearningEpisodeAssemblySchema = z.object({\n state: z.enum([\"incomplete\", \"ambiguous\", \"awaiting_owner_review\"]),\n issues: z.array(z.enum([\n \"missing_attempt\", \"missing_observation\", \"completion_not_observed\",\n \"conflicting_observations\", \"reference_mismatch\", \"lineage_mismatch\",\n \"mixed_scope\", \"conflicting_event\",\n ])).max(8),\n groups: z.array(z.object({\n key: ToolLearningHashSchema,\n application: z.string().min(1).max(200),\n applicationVersion: z.string().min(1).max(200),\n tool: z.object({\n name: z.string().min(1).max(200),\n version: z.string().max(200).nullable(),\n server: z.string().max(200).nullable(),\n }).strict(),\n environmentFingerprints: z.array(ToolLearningHashSchema).max(TOOL_LEARNING_LIMITS.eventsPerEpisode),\n attempts: z.array(ToolLearningRefSchema).max(TOOL_LEARNING_LIMITS.eventsPerEpisode),\n }).strict()).max(TOOL_LEARNING_LIMITS.eventsPerEpisode),\n}).strict();\n\ntype Issue = z.infer<typeof ToolLearningEpisodeAssemblySchema>[\"issues\"][number];\ntype Attempt = Extract<ToolEpisodeEvent, { eventKind: \"attempt\" }>;\ntype Observation = Extract<ToolEpisodeEvent, { eventKind: \"observation\" }>;\n\n/** Structural assembly of retained calls, never recovery verification or label\n * approval. Conflicting observations remain visible instead of selecting the\n * most recently received answer. Recovery/verifier claims retain their separate\n * owner authority and are not promoted by this read projection. */\nexport function assembleToolLearningEpisode(raw: readonly ToolEpisodeEvent[]) {\n const events = z.array(ToolEpisodeEventSchema).max(TOOL_LEARNING_LIMITS.eventsPerEpisode).parse(raw);\n const incomplete = new Set<Issue>(), ambiguous = new Set<Issue>();\n const byId = new Map<string, ToolEpisodeEvent>();\n const first = events[0];\n for (const event of events) {\n if (first && (event.installationId !== first.installationId || event.episodeId !== first.episodeId))\n ambiguous.add(\"mixed_scope\");\n if (event.parentSessionId === event.sessionId) ambiguous.add(\"lineage_mismatch\");\n const previous = byId.get(event.eventId);\n if (previous && previous.contentHash !== event.contentHash) ambiguous.add(\"conflicting_event\");\n else byId.set(event.eventId, event);\n }\n const attempts = [...byId.values()].filter((event): event is Attempt => event.eventKind === \"attempt\");\n const observations = new Map<string, Observation[]>();\n const callOwners = new Map<string, string>();\n if (!attempts.length) incomplete.add(\"missing_attempt\");\n for (const event of byId.values()) {\n if (event.eventKind !== \"observation\") continue;\n const attempt = byId.get(event.payload.attempt.id);\n if (!attempt) incomplete.add(\"missing_attempt\");\n else if (attempt.eventKind !== \"attempt\" ||\n attempt.contentHash !== event.payload.attempt.contentHash ||\n attempt.payload.actionHash !== event.payload.actionHash) ambiguous.add(\"reference_mismatch\");\n else if (attempt.sessionId !== event.sessionId || attempt.callId !== event.callId ||\n (attempt.parentSessionId && event.parentSessionId && attempt.parentSessionId !== event.parentSessionId) ||\n (attempt.turnId && event.turnId && attempt.turnId !== event.turnId)) ambiguous.add(\"lineage_mismatch\");\n const values = observations.get(event.payload.attempt.id) ?? [];\n values.push(event);\n observations.set(event.payload.attempt.id, values);\n }\n const grouped = new Map<string, {\n application: string; applicationVersion: string; tool: Attempt[\"payload\"][\"tool\"];\n fingerprints: Set<string>; attempts: Array<{ id: string; contentHash: string }>;\n }>();\n for (const attempt of attempts) {\n const callKey = JSON.stringify([attempt.sessionId, attempt.callId]);\n const previousCall = callOwners.get(callKey);\n if (previousCall && previousCall !== attempt.contentHash) ambiguous.add(\"lineage_mismatch\");\n callOwners.set(callKey, attempt.contentHash);\n const values = observations.get(attempt.eventId) ?? [];\n if (!values.length) incomplete.add(\"missing_observation\");\n else {\n const terminal = values.filter((event) => event.payload.outcome !== \"incomplete\");\n if (!terminal.length) incomplete.add(\"completion_not_observed\");\n if (new Set(terminal.map((event) => contentHash(event.payload))).size > 1)\n ambiguous.add(\"conflicting_observations\");\n }\n const { environment, tool } = attempt.payload;\n const key = contentHash([environment.application, environment.version, tool.name, tool.version, tool.server]);\n const group = grouped.get(key) ?? {\n application: environment.application, applicationVersion: environment.version,\n tool, fingerprints: new Set<string>(), attempts: [],\n };\n group.fingerprints.add(environment.fingerprint);\n group.attempts.push({ id: attempt.eventId, contentHash: attempt.contentHash });\n grouped.set(key, group);\n }\n return ToolLearningEpisodeAssemblySchema.parse({\n state: ambiguous.size ? \"ambiguous\" : incomplete.size ? \"incomplete\" : \"awaiting_owner_review\",\n issues: [...new Set([...ambiguous, ...incomplete])].sort(),\n groups: [...grouped].sort(([a], [b]) => a.localeCompare(b)).map(([key, group]) => ({\n key, application: group.application, applicationVersion: group.applicationVersion, tool: group.tool,\n environmentFingerprints: [...group.fingerprints].sort(),\n attempts: group.attempts.sort((a, b) => a.id.localeCompare(b.id)),\n })),\n });\n}\n"],"mappings":";;;;;;;;;;;;;AACA,cAAc;;;ACDd,SAAS,KAAAA,UAAS;AAElB,SAAS,iCAAiC;AAC1C;AAAA,EACE,wBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,0BAAAC;AAAA,EACA,yBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAKP,SAAS,6BAA6B;;;AC3BtC,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEA,IAAM,oCAAoC,EAAE,OAAO;AAAA,EACxD,OAAO,EAAE,KAAK,CAAC,cAAc,aAAa,uBAAuB,CAAC;AAAA,EAClE,QAAQ,EAAE,MAAM,EAAE,KAAK;AAAA,IACrB;AAAA,IAAmB;AAAA,IAAuB;AAAA,IAC1C;AAAA,IAA4B;AAAA,IAAsB;AAAA,IAClD;AAAA,IAAe;AAAA,EACjB,CAAC,CAAC,EAAE,IAAI,CAAC;AAAA,EACT,QAAQ,EAAE,MAAM,EAAE,OAAO;AAAA,IACvB,KAAK;AAAA,IACL,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,IACtC,oBAAoB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,IAC7C,MAAM,EAAE,OAAO;AAAA,MACb,MAAM,EA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QACA,MACA,QACkB;AAClB,QAAI,SAAS;AACX;AAAA,QACE;AAAA,QACAH,sBAAqB,aAAaA,sBAAqB;AAAA,MACzD;AACF,UAAM,UAAU,YAAY,QAAQ,GAAK;AACzC,UAAM,WAAW,OAAO,KAAK,SAAS,SAAS,WAAW;AAAA,MACxD,GAAG,KAAK,QAAQ,qBAAqB,IAAI;AAAA,MACzC;AAAA,QACE;AAAA,QACA,UAAU;AAAA,QACV,QAAQ,SAAS,YAAY,IAAI,CAAC,QAAQ,OAAO,CAAC,IAAI;AAAA,QACtD,SAAS;AAAA,UACP,eAAe,UAAU,KAAK,SAAS,MAAM;AAAA,UAC7C,sBAAsB,KAAK,SAAS;AAAA,UACpC,QAAQ;AAAA,UACR,GAAI,SAAS,SAAY,CAAC,IAAI,EAAE,gBAAgB,mBAAmB;AAAA,QACrE;AAAA,QACA,GAAI,SAAS,SAAY,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,IAAI,EAAE;AAAA,MAC7D;AAAA,IACF;AACA,UAAM,QAAQ,MAAM;AAAA,MAClB;AAAA,MACAA,sBAAqB,aAAaA,sBAAqB;AAAA,MACvD;AAAA,IACF;AACA,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,QAAQD,GACX,OAAO;AAAA,QACN,MAAMA,GACH,OAAO,EACP,MAAM,cAAc,EACpB,IAAI,GAAG;AAAA,MACZ,CAAC,EACA,YAAY,EACZ,UAAU,KAAK;AAClB,YAAM,IAAI;AAAA,QACR,SAAS;AAAA,QACT,MAAM,UAAU,MAAM,KAAK,OAAO;AAAA,MACpC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":["z","TOOL_LEARNING_LIMITS","ToolEpisodeEventSchema","ToolLearningRefSchema","z","TOOL_LEARNING_LIMITS","ToolLearningRefSchema","ToolEpisodeEventSchema","value"]}
1
+ {"version":3,"sources":["../src/tool-learning.ts","../src/tool-learning-client.ts","../src/tool-learning-episodes.ts","../src/tool-learning-responses.ts"],"sourcesContent":["/** Portable episode and recovery-consultation protocol; no installation side effects. */\nexport * from \"@openpond/evals/tool-learning\";\nexport * from \"./tool-learning-client.js\";\nexport * from \"./tool-learning-episodes.js\";\nexport * from \"./tool-learning-responses.js\";\n","import { z } from \"zod\";\nimport { contentHash } from \"@openpond/harness\";\nimport { LearningRevisionRefSchema } from \"@openpond/evals/learning\";\nimport {\n TOOL_LEARNING_LIMITS,\n ToolLearningRegistrationSchema,\n ToolLearningInstallationSchema,\n ToolLearningIdSchema,\n ToolLearningRefSchema,\n ToolLearningDecisionSchema,\n boundedToolLearningSchema,\n ToolLearningInstallationUpdateSchema,\n ToolEpisodeAppendSchema,\n ToolEpisodeAppendReceiptSchema,\n ToolLearningManifestSchema,\n ToolLearningCapabilitySchema,\n ToolLearningConsultationRequestSchema,\n assertToolLearningConsultationResponse,\n type ToolLearningRegistration,\n type ToolEpisodeAppend,\n type ToolLearningConsultationRequest,\n} from \"@openpond/evals/tool-learning\";\nimport {\n LearningSourceCredentialSecretSchema,\n createSourceCredentialRequest,\n} from \"./learning-credentials.js\";\nimport { assertBoundedTaskJson } from \"@openpond/evals/task-schema\";\nimport { readBoundedJsonResponse } from \"./protocol.js\";\nimport { assembleToolLearningEpisode } from \"./tool-learning-episodes.js\";\nimport {\n ToolLearningRegistrationReceiptSchema,\n ToolLearningInstallationPageSchema,\n ToolLearningEpisodePageSchema,\n ToolLearningEpisodeDetailSchema,\n ToolLearningPurgeRequestSchema,\n ToolLearningPurgeReceiptSchema,\n} from \"./tool-learning-responses.js\";\n\n/** Prepare and retain this request privately before registration. Retrying the\n * same bytes recovers issuance without storing plaintext on the host. */\nexport const ToolLearningRegistrationRequestSchema = boundedToolLearningSchema(\n z\n .object({\n registration: ToolLearningRegistrationSchema,\n credential: z\n .object({ apiKey: LearningSourceCredentialSecretSchema, expiresAt: z.iso.datetime() })\n .strict(),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\n\nexport const ToolLearningProjectionRequestSchema = boundedToolLearningSchema(\n z\n .object({\n operationId: ToolLearningIdSchema,\n expectedRevision: z.number().int().positive(),\n episodeId: ToolLearningIdSchema,\n failure: ToolLearningRefSchema,\n recovery: ToolLearningRefSchema,\n taskDefinition: LearningRevisionRefSchema,\n familyKey: ToolLearningIdSchema,\n split: z.literal(\"train\"),\n proposedTarget: ToolLearningDecisionSchema,\n saveToPrivateDataset: z.literal(true),\n targetApproval: z.literal(\"pending_owner_review\"),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\nexport const ToolLearningProjectionReceiptSchema = boundedToolLearningSchema(\n z\n .object({\n installationId: ToolLearningIdSchema,\n projectId: ToolLearningIdSchema,\n operationId: ToolLearningIdSchema,\n source: LearningRevisionRefSchema,\n evidence: LearningRevisionRefSchema,\n originHash: z.string().regex(/^[a-f0-9]{64}$/),\n requestHash: z.string().regex(/^[a-f0-9]{64}$/),\n projectedAt: z.iso.datetime(),\n targetApproval: z.literal(\"pending_owner_review\"),\n learningEnrollment: z.literal(false),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\n\n/** Explicit owner selection. Capturing events never authorizes inference spend. */\nexport const ToolLearningRoutingRequestSchema = boundedToolLearningSchema(\n z\n .object({\n operationId: ToolLearningIdSchema,\n expectedRevision: z.number().int().nonnegative(),\n state: z.enum([\"enabled\", \"disabled\"]),\n modelId: ToolLearningIdSchema,\n qualification: z.discriminatedUnion(\"kind\", [\n z\n .object({ kind: z.literal(\"integration\"), evaluationRunId: ToolLearningIdSchema })\n .strict(),\n z\n .object({\n kind: z.literal(\"learned\"),\n evaluationRunId: ToolLearningIdSchema,\n baselineRunId: ToolLearningIdSchema,\n trainingRunId: ToolLearningIdSchema,\n })\n .strict(),\n ]),\n capabilities: z\n .array(ToolLearningCapabilitySchema.omit({ qualification: true }))\n .min(1)\n .max(16),\n limits: z\n .object({\n maxOutputTokens: z.number().int().min(128).max(2048),\n maximumCallUsd: z.number().positive().max(1),\n maximumDayUsd: z.number().positive().max(10),\n maximumSessionCalls: z.number().int().min(1).max(20),\n maximumDayCalls: z.number().int().min(1).max(200),\n })\n .strict(),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\nexport const ToolLearningRoutingSchema = boundedToolLearningSchema(\n z\n .object({\n installationId: ToolLearningIdSchema,\n scope: z.object({ teamId: ToolLearningIdSchema, projectId: ToolLearningIdSchema }).strict(),\n revision: z.number().int().positive(),\n operationId: ToolLearningIdSchema,\n requestHash: z.string().regex(/^[a-f0-9]{64}$/),\n configuration: ToolLearningRoutingRequestSchema,\n modelRelease: ToolLearningRefSchema,\n policySystemPrompt: z.string().min(1).max(16384),\n capabilities: z.array(ToolLearningCapabilitySchema).max(16),\n updatedAt: z.iso.datetime(),\n })\n .strict(),\n TOOL_LEARNING_LIMITS.eventBytes,\n);\n\nexport function prepareToolLearningRegistration(\n registration: ToolLearningRegistration,\n expiresAt: string,\n) {\n const prepared = createSourceCredentialRequest({\n sourceId: registration.installationId,\n name: \"Tool learning installation\",\n expiresAt,\n });\n return ToolLearningRegistrationRequestSchema.parse({\n registration,\n credential: { apiKey: prepared.apiKey, expiresAt },\n });\n}\n\nexport class OpenPondToolLearningError extends Error {\n constructor(\n readonly status: number,\n readonly code: string,\n ) {\n super(`Tool learning request failed (${status}): ${code}`);\n this.name = \"OpenPondToolLearningError\";\n }\n}\n\n/** Owner credentials register/control installations. External hooks and MCP\n * use only the separate installation credential returned by registration. */\ntype ToolLearningClientOptions = {\n baseUrl: string;\n apiKey: string;\n teamId: string;\n projectId: string;\n fetch?: typeof globalThis.fetch;\n};\n\nexport class OpenPondToolLearningClient {\n readonly #baseUrl: string;\n readonly #options: ToolLearningClientOptions;\n constructor(options: ToolLearningClientOptions) {\n this.#options = { ...options };\n\n const url = new URL(options.baseUrl);\n if (\n ![\"https:\", \"http:\"].includes(url.protocol) ||\n url.username ||\n url.password ||\n url.search ||\n url.hash ||\n !options.apiKey.trim() ||\n !options.teamId.trim() ||\n !options.projectId.trim()\n )\n throw new Error(\"tool_learning_client_scope_required\");\n this.#baseUrl = url.toString().replace(/\\/+$/, \"\");\n }\n\n async register(\n value: z.input<typeof ToolLearningRegistrationRequestSchema>,\n signal?: AbortSignal,\n ) {\n const input = ToolLearningRegistrationRequestSchema.parse(value);\n if (input.registration.projectId !== this.#options.projectId)\n throw new Error(\"tool_learning_project_mismatch\");\n const result = ToolLearningRegistrationReceiptSchema.parse(\n await this.#request(\"installations\", \"POST\", input, signal),\n );\n this.#installation(result.installation, input.registration.installationId);\n if (result.apiKey !== input.credential.apiKey)\n throw new Error(\"tool_learning_credential_mismatch\");\n const installation = result.installation;\n if (\n installation.client !== input.registration.client ||\n installation.clientVersion !== input.registration.clientVersion ||\n installation.machineSourceId !== input.registration.machineSourceId ||\n contentHash(installation.adapterRelease) !== contentHash(input.registration.adapterRelease) ||\n contentHash(installation.collectionPolicy) !==\n contentHash(input.registration.collectionPolicy) ||\n installation.collectionPolicyHash !== contentHash(input.registration.collectionPolicy) ||\n installation.credential?.expiresAt !== input.credential.expiresAt\n )\n throw new Error(\"tool_learning_registration_receipt_mismatch\");\n return result;\n }\n\n async installation(id: string, signal?: AbortSignal) {\n const result = ToolLearningInstallationSchema.parse(\n await this.#request(`installations/${encodeURIComponent(id)}`, \"GET\", undefined, signal),\n );\n this.#installation(result, id);\n return result;\n }\n\n async installations(after?: string, signal?: AbortSignal) {\n const result = ToolLearningInstallationPageSchema.parse(\n await this.#request(\n `installations?projectId=${encodeURIComponent(this.#options.projectId)}${after ? `&after=${encodeURIComponent(after)}` : \"\"}`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n for (const installation of result.items) this.#installation(installation, installation.id);\n if (result.nextCursor !== null && result.nextCursor !== result.items.at(-1)?.id)\n throw new Error(\"tool_learning_installation_cursor_mismatch\");\n return result;\n }\n\n async episodes(installationId: string, after?: string, signal?: AbortSignal) {\n const result = ToolLearningEpisodePageSchema.parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/episodes${after ? `?after=${encodeURIComponent(after)}` : \"\"}`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n if (\n result.installationId !== installationId ||\n result.scope.teamId !== this.#options.teamId ||\n result.scope.projectId !== this.#options.projectId ||\n (result.nextCursor !== null && result.nextCursor !== result.items.at(-1)?.episodeId)\n )\n throw new Error(\"tool_learning_episode_page_mismatch\");\n return result;\n }\n\n async episode(installationId: string, episodeId: string, signal?: AbortSignal) {\n const result = ToolLearningEpisodeDetailSchema.parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/episodes/${encodeURIComponent(episodeId)}`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n if (\n result.installationId !== installationId ||\n result.episodeId !== episodeId ||\n result.scope.teamId !== this.#options.teamId ||\n result.scope.projectId !== this.#options.projectId ||\n result.events.some(\n (event) => event.installationId !== installationId || event.episodeId !== episodeId,\n )\n )\n throw new Error(\"tool_learning_episode_scope_mismatch\");\n if (\n result.state !== result.assembly.state ||\n contentHash(assembleToolLearningEpisode(result.events)) !== contentHash(result.assembly)\n )\n throw new Error(\"tool_learning_episode_assembly_mismatch\");\n return result;\n }\n\n async purge(\n installationId: string,\n input: { operationId: string; expectedRevision: number },\n signal?: AbortSignal,\n ) {\n const request = ToolLearningPurgeRequestSchema.parse(input);\n const result = ToolLearningPurgeReceiptSchema.parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/purge`,\n \"POST\",\n request,\n signal,\n ),\n );\n if (result.installationId !== installationId || result.operationId !== request.operationId)\n throw new Error(\"tool_learning_purge_scope_mismatch\");\n return result;\n }\n\n async project(\n installationId: string,\n value: z.input<typeof ToolLearningProjectionRequestSchema>,\n signal?: AbortSignal,\n ) {\n const input = ToolLearningProjectionRequestSchema.parse(value);\n const result = ToolLearningProjectionReceiptSchema.parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/project`,\n \"POST\",\n input,\n signal,\n ),\n );\n if (\n result.installationId !== installationId ||\n result.projectId !== this.#options.projectId ||\n result.operationId !== input.operationId ||\n result.requestHash !== contentHash(input)\n )\n throw new Error(\"tool_learning_projection_scope_mismatch\");\n return result;\n }\n\n async setState(\n id: string,\n value: z.input<typeof ToolLearningInstallationUpdateSchema>,\n signal?: AbortSignal,\n ) {\n const input = ToolLearningInstallationUpdateSchema.parse(value);\n const result = ToolLearningInstallationSchema.parse(\n await this.#request(`installations/${encodeURIComponent(id)}`, \"PATCH\", input, signal),\n );\n this.#installation(result, id);\n if (result.state !== input.state) throw new Error(\"tool_learning_state_mismatch\");\n return result;\n }\n\n async append(value: ToolEpisodeAppend, signal?: AbortSignal) {\n const input = ToolEpisodeAppendSchema.parse(value);\n const result = ToolEpisodeAppendReceiptSchema.parse(\n await this.#request(\"episodes\", \"POST\", input, signal),\n );\n if (\n result.operationId !== input.operationId ||\n result.installationId !== input.installationId ||\n result.teamId !== this.#options.teamId ||\n result.projectId !== this.#options.projectId ||\n result.requestHash !== contentHash(input) ||\n result.events.length !== input.events.length ||\n new Set(result.events.map((event) => event.eventId)).size !== result.events.length\n )\n throw new Error(\"tool_learning_append_receipt_mismatch\");\n for (const event of result.events) {\n const submitted = input.events.find((value) => value.eventId === event.eventId);\n if (!submitted || submitted.contentHash !== event.contentHash)\n throw new Error(\"tool_learning_append_event_mismatch\");\n }\n return result;\n }\n\n async routing(installationId: string, signal?: AbortSignal) {\n return this.#routing(\n installationId,\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/routing`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n }\n\n async configureRouting(\n installationId: string,\n value: z.input<typeof ToolLearningRoutingRequestSchema>,\n signal?: AbortSignal,\n ) {\n const input = ToolLearningRoutingRequestSchema.parse(value);\n const result = this.#routing(\n installationId,\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/routing`,\n \"POST\",\n input,\n signal,\n ),\n );\n if (\n result.operationId !== input.operationId ||\n result.requestHash !== contentHash(input) ||\n contentHash(result.configuration) !== contentHash(input)\n )\n throw new Error(\"tool_learning_routing_receipt_mismatch\");\n return result;\n }\n\n #routing(installationId: string, value: unknown) {\n const result = ToolLearningRoutingSchema.parse(value);\n if (\n result.installationId !== installationId ||\n result.scope.teamId !== this.#options.teamId ||\n result.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_routing_scope_mismatch\");\n return result;\n }\n\n async manifest(installationId: string, signal?: AbortSignal) {\n const result = ToolLearningManifestSchema.parse(\n await this.#request(\n `installations/${encodeURIComponent(installationId)}/manifest`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n if (\n result.installationId !== installationId ||\n result.scope.teamId !== this.#options.teamId ||\n result.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_manifest_scope_mismatch\");\n if (\n Date.parse(result.expiresAt) <= Date.now() ||\n Date.parse(result.issuedAt) > Date.now() + 30000\n )\n throw new Error(\"tool_learning_manifest_expired\");\n return result;\n }\n\n async consult(value: ToolLearningConsultationRequest, signal?: AbortSignal) {\n const input = ToolLearningConsultationRequestSchema.parse(value);\n if (\n input.scope.teamId !== this.#options.teamId ||\n input.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_consultation_scope_mismatch\");\n return assertToolLearningConsultationResponse(\n input,\n await this.#request(\"consultations\", \"POST\", input, signal),\n );\n }\n\n async consultation(value: ToolLearningConsultationRequest, signal?: AbortSignal) {\n const input = ToolLearningConsultationRequestSchema.parse(value);\n if (\n input.scope.teamId !== this.#options.teamId ||\n input.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_consultation_scope_mismatch\");\n return assertToolLearningConsultationResponse(\n input,\n await this.#request(\n `installations/${encodeURIComponent(input.installationId)}/consultations/${encodeURIComponent(input.operationId)}`,\n \"GET\",\n undefined,\n signal,\n ),\n );\n }\n\n #installation(value: z.infer<typeof ToolLearningInstallationSchema>, id: string) {\n if (\n value.id !== id ||\n value.scope.teamId !== this.#options.teamId ||\n value.scope.projectId !== this.#options.projectId\n )\n throw new Error(\"tool_learning_installation_scope_mismatch\");\n }\n\n async #request(\n path: string,\n method: string,\n body: unknown,\n signal?: AbortSignal,\n ): Promise<unknown> {\n if (body !== undefined)\n assertBoundedTaskJson(\n body,\n TOOL_LEARNING_LIMITS.eventBytes * TOOL_LEARNING_LIMITS.eventsPerAppend,\n );\n const timeout = AbortSignal.timeout(30000);\n const response = await (this.#options.fetch ?? globalThis.fetch)(\n `${this.#baseUrl}/v1/tool-learning/${path}`,\n {\n method,\n redirect: \"error\",\n signal: signal ? AbortSignal.any([signal, timeout]) : timeout,\n headers: {\n Authorization: `Bearer ${this.#options.apiKey}`,\n \"X-OpenPond-Team-Id\": this.#options.teamId,\n Accept: \"application/json\",\n ...(body === undefined ? {} : { \"Content-Type\": \"application/json\" }),\n },\n ...(body === undefined ? {} : { body: JSON.stringify(body) }),\n },\n );\n const value = await readBoundedJsonResponse(\n response,\n TOOL_LEARNING_LIMITS.eventBytes * TOOL_LEARNING_LIMITS.eventsPerAppend,\n \"Tool learning response\",\n );\n if (!response.ok) {\n const error = z\n .object({\n code: z\n .string()\n .regex(/^[a-z0-9_]+$/)\n .max(200),\n })\n .passthrough()\n .safeParse(value);\n throw new OpenPondToolLearningError(\n response.status,\n error.success ? error.data.code : \"tool_learning_request_failed\",\n );\n }\n return value;\n }\n}\n","import { z } from \"zod\";\nimport { contentHash } from \"@openpond/harness\";\nimport {\n TOOL_LEARNING_LIMITS,\n ToolEpisodeEventSchema,\n ToolLearningHashSchema,\n ToolLearningRefSchema,\n type ToolEpisodeEvent,\n} from \"@openpond/evals/tool-learning\";\n\nexport const ToolLearningEpisodeAssemblySchema = z.object({\n state: z.enum([\"incomplete\", \"ambiguous\", \"awaiting_owner_review\"]),\n issues: z.array(z.enum([\n \"missing_attempt\", \"missing_observation\", \"completion_not_observed\",\n \"conflicting_observations\", \"reference_mismatch\", \"lineage_mismatch\",\n \"mixed_scope\", \"conflicting_event\",\n ])).max(8),\n groups: z.array(z.object({\n key: ToolLearningHashSchema,\n application: z.string().min(1).max(200),\n applicationVersion: z.string().min(1).max(200),\n tool: z.object({\n name: z.string().min(1).max(200),\n version: z.string().max(200).nullable(),\n server: z.string().max(200).nullable(),\n }).strict(),\n environmentFingerprints: z.array(ToolLearningHashSchema).max(TOOL_LEARNING_LIMITS.eventsPerEpisode),\n attempts: z.array(ToolLearningRefSchema).max(TOOL_LEARNING_LIMITS.eventsPerEpisode),\n }).strict()).max(TOOL_LEARNING_LIMITS.eventsPerEpisode),\n}).strict();\n\ntype Issue = z.infer<typeof ToolLearningEpisodeAssemblySchema>[\"issues\"][number];\ntype Attempt = Extract<ToolEpisodeEvent, { eventKind: \"attempt\" }>;\ntype Observation = Extract<ToolEpisodeEvent, { eventKind: \"observation\" }>;\n\n/** Structural assembly of retained calls, never recovery verification or label\n * approval. Conflicting observations remain visible instead of selecting the\n * most recently received answer. Recovery/verifier claims retain their separate\n * owner authority and are not promoted by this read projection. */\nexport function assembleToolLearningEpisode(raw: readonly ToolEpisodeEvent[]) {\n const events = z.array(ToolEpisodeEventSchema).max(TOOL_LEARNING_LIMITS.eventsPerEpisode).parse(raw);\n const incomplete = new Set<Issue>(), ambiguous = new Set<Issue>();\n const byId = new Map<string, ToolEpisodeEvent>();\n const first = events[0];\n for (const event of events) {\n if (first && (event.installationId !== first.installationId || event.episodeId !== first.episodeId))\n ambiguous.add(\"mixed_scope\");\n if (event.parentSessionId === event.sessionId) ambiguous.add(\"lineage_mismatch\");\n const previous = byId.get(event.eventId);\n if (previous && previous.contentHash !== event.contentHash) ambiguous.add(\"conflicting_event\");\n else byId.set(event.eventId, event);\n }\n const attempts = [...byId.values()].filter((event): event is Attempt => event.eventKind === \"attempt\");\n const observations = new Map<string, Observation[]>();\n const callOwners = new Map<string, string>();\n if (!attempts.length) incomplete.add(\"missing_attempt\");\n for (const event of byId.values()) {\n if (event.eventKind !== \"observation\") continue;\n const attempt = byId.get(event.payload.attempt.id);\n if (!attempt) incomplete.add(\"missing_attempt\");\n else if (attempt.eventKind !== \"attempt\" ||\n attempt.contentHash !== event.payload.attempt.contentHash ||\n attempt.payload.actionHash !== event.payload.actionHash) ambiguous.add(\"reference_mismatch\");\n else if (attempt.sessionId !== event.sessionId || attempt.callId !== event.callId ||\n (attempt.parentSessionId && event.parentSessionId && attempt.parentSessionId !== event.parentSessionId) ||\n (attempt.turnId && event.turnId && attempt.turnId !== event.turnId)) ambiguous.add(\"lineage_mismatch\");\n const values = observations.get(event.payload.attempt.id) ?? [];\n values.push(event);\n observations.set(event.payload.attempt.id, values);\n }\n const grouped = new Map<string, {\n application: string; applicationVersion: string; tool: Attempt[\"payload\"][\"tool\"];\n fingerprints: Set<string>; attempts: Array<{ id: string; contentHash: string }>;\n }>();\n for (const attempt of attempts) {\n const callKey = JSON.stringify([attempt.sessionId, attempt.callId]);\n const previousCall = callOwners.get(callKey);\n if (previousCall && previousCall !== attempt.contentHash) ambiguous.add(\"lineage_mismatch\");\n callOwners.set(callKey, attempt.contentHash);\n const values = observations.get(attempt.eventId) ?? [];\n if (!values.length) incomplete.add(\"missing_observation\");\n else {\n const terminal = values.filter((event) => event.payload.outcome !== \"incomplete\");\n if (!terminal.length) incomplete.add(\"completion_not_observed\");\n if (new Set(terminal.map((event) => contentHash(event.payload))).size > 1)\n ambiguous.add(\"conflicting_observations\");\n }\n const { environment, tool } = attempt.payload;\n const key = contentHash([environment.application, environment.version, tool.name, tool.version, tool.server]);\n const group = grouped.get(key) ?? {\n application: environment.application, applicationVersion: environment.version,\n tool, fingerprints: new Set<string>(), attempts: [],\n };\n group.fingerprints.add(environment.fingerprint);\n group.attempts.push({ id: attempt.eventId, contentHash: attempt.contentHash });\n grouped.set(key, group);\n }\n return ToolLearningEpisodeAssemblySchema.parse({\n state: ambiguous.size ? \"ambiguous\" : incomplete.size ? \"incomplete\" : \"awaiting_owner_review\",\n issues: [...new Set([...ambiguous, ...incomplete])].sort(),\n groups: [...grouped].sort(([a], [b]) => a.localeCompare(b)).map(([key, group]) => ({\n key, application: group.application, applicationVersion: group.applicationVersion, tool: group.tool,\n environmentFingerprints: [...group.fingerprints].sort(),\n attempts: group.attempts.sort((a, b) => a.id.localeCompare(b.id)),\n })),\n });\n}\n","import { z } from \"zod\";\nimport {\n TOOL_LEARNING_LIMITS,\n ToolEpisodeEventSchema,\n ToolLearningIdSchema,\n ToolLearningInstallationSchema,\n ToolLearningScopeSchema,\n} from \"@openpond/evals/tool-learning\";\nimport { LearningSourceCredentialSecretSchema } from \"./learning-credentials.js\";\nimport { ToolLearningEpisodeAssemblySchema } from \"./tool-learning-episodes.js\";\n\n/** Shared wire envelopes used by native clients and the Python schema exporter. */\nexport const ToolLearningRegistrationReceiptSchema = z\n .object({\n installation: ToolLearningInstallationSchema,\n apiKey: LearningSourceCredentialSecretSchema,\n })\n .strict();\n\nexport const ToolLearningInstallationPageSchema = z\n .object({\n items: z.array(ToolLearningInstallationSchema).max(30),\n nextCursor: ToolLearningIdSchema.nullable(),\n })\n .strict();\n\nexport const ToolLearningEpisodePageSchema = z\n .object({\n installationId: ToolLearningIdSchema,\n scope: ToolLearningScopeSchema,\n items: z\n .array(\n z\n .object({\n episodeId: ToolLearningIdSchema,\n eventCount: z.number().int().positive(),\n lastReceivedAt: z.iso.datetime(),\n })\n .strict(),\n )\n .max(30),\n nextCursor: ToolLearningIdSchema.nullable(),\n learningEnrollment: z.literal(false),\n })\n .strict();\n\nexport const ToolLearningEpisodeDetailSchema = z\n .object({\n installationId: ToolLearningIdSchema,\n episodeId: ToolLearningIdSchema,\n scope: ToolLearningScopeSchema,\n events: z.array(ToolEpisodeEventSchema).max(TOOL_LEARNING_LIMITS.eventsPerEpisode),\n state: ToolLearningEpisodeAssemblySchema.shape.state,\n assembly: ToolLearningEpisodeAssemblySchema,\n verificationAuthority: z.literal(\"not_granted\"),\n learningEnrollment: z.literal(false),\n })\n .strict();\n\nexport const ToolLearningPurgeRequestSchema = z\n .object({\n operationId: ToolLearningIdSchema,\n expectedRevision: z.number().int().positive(),\n })\n .strict();\n\nexport const ToolLearningPurgeReceiptSchema = z\n .object({\n installationId: ToolLearningIdSchema,\n operationId: ToolLearningIdSchema,\n purgedEvents: z.number().int().nonnegative(),\n learningEnrollment: z.literal(false),\n })\n .strict();\n"],"mappings":";;;;;;;;;;;;;AACA,cAAc;;;ACDd,SAAS,KAAAA,UAAS;AAElB,SAAS,iCAAiC;AAC1C;AAAA,EACE,wBAAAC;AAAA,EACA;AAAA,EACA,kCAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,yBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAKP,SAAS,6BAA6B;;;AC1BtC,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEA,IAAM,oCAAoC,EAAE,OAAO;AAAA,EACxD,OAAO,EAAE,KAAK,CAAC,cAAc,aAAa,uBAAuB,CAAC;AAAA,EAClE,QAAQ,EAAE,MAAM,EAAE,KAAK;AAAA,IACrB;AAAA,IAAmB;AAAA,IAAuB;AAAA,IAC1C;AAAA,IAA4B;AAAA,IAAsB;AAAA,IAClD;AAAA,IAAe;AAAA,EACjB,CAAC,CAAC,EAAE,IAAI,CAAC;AAAA,EACT,QAAQ,EAAE,MAAM,EAAE,OAAO;AAAA,IACvB,KAAK;AAAA,IACL,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,IACtC,oBAAoB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,IAC7C,MAAM,EAAE,OAAO;AAAA,MACb,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,MAC/B,SAAS,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,SAAS;AAAA,MACtC,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,SAAS;AAAA,IACvC,CAAC,EAAE,OAAO;AAAA,IACV,yBAAyB,EAAE,MAAM,sB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AqB;AAAA,MACzD;AACF,UAAM,UAAU,YAAY,QAAQ,GAAK;AACzC,UAAM,WAAW,OAAO,KAAK,SAAS,SAAS,WAAW;AAAA,MACxD,GAAG,KAAK,QAAQ,qBAAqB,IAAI;AAAA,MACzC;AAAA,QACE;AAAA,QACA,UAAU;AAAA,QACV,QAAQ,SAAS,YAAY,IAAI,CAAC,QAAQ,OAAO,CAAC,IAAI;AAAA,QACtD,SAAS;AAAA,UACP,eAAe,UAAU,KAAK,SAAS,MAAM;AAAA,UAC7C,sBAAsB,KAAK,SAAS;AAAA,UACpC,QAAQ;AAAA,UACR,GAAI,SAAS,SAAY,CAAC,IAAI,EAAE,gBAAgB,mBAAmB;AAAA,QACrE;AAAA,QACA,GAAI,SAAS,SAAY,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,IAAI,EAAE;AAAA,MAC7D;AAAA,IACF;AACA,UAAM,QAAQ,MAAM;AAAA,MAClB;AAAA,MACAA,sBAAqB,aAAaA,sBAAqB;AAAA,MACvD;AAAA,IACF;AACA,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,QAAQD,GACX,OAAO;AAAA,QACN,MAAMA,GACH,OAAO,EACP,MAAM,cAAc,EACpB,IAAI,GAAG;AAAA,MACZ,CAAC,EACA,YAAY,EACZ,UAAU,KAAK;AAClB,YAAM,IAAI;AAAA,QACR,SAAS;AAAA,QACT,MAAM,UAAU,MAAM,KAAK,OAAO;AAAA,MACpC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":["z","TOOL_LEARNING_LIMITS","ToolLearningInstallationSchema","ToolLearningIdSchema","ToolLearningRefSchema","z","TOOL_LEARNING_LIMITS","ToolEpisodeEventSchema","z","ToolEpisodeEventSchema","TOOL_LEARNING_LIMITS","z","TOOL_LEARNING_LIMITS","ToolLearningIdSchema","ToolLearningRefSchema","ToolLearningInstallationSchema","value"]}
@@ -1 +1 @@
1
- {"version":3,"file":"model-ordinary-taskset-reward.d.ts","sourceRoot":"","sources":["../../../../../src/model-ordinary-taskset-reward.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmF,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACnJ,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAmF,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAItJ;+EAC+E;AAC/E,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,MAAM,EAAE,cAAc,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B,GAAG,cAAc,CA6CjB"}
1
+ {"version":3,"file":"model-ordinary-taskset-reward.d.ts","sourceRoot":"","sources":["../../../../../src/model-ordinary-taskset-reward.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmF,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACnJ,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAmF,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAItJ;+EAC+E;AAC/E,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,MAAM,EAAE,cAAc,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B,GAAG,cAAc,CAiDjB"}
@@ -0,0 +1,7 @@
1
+ import type { ModelProjectTrainingSetup } from "./model-projects.js";
2
+ type Recipe = NonNullable<ModelProjectTrainingSetup["recipe"]>;
3
+ /** An editable draft, without invented model or dataset bindings. Execution
4
+ * still requires ManagedSftRecipeSchema and authoritative supervised admission. */
5
+ export declare function createSupervisedTrainingRecipeDefaults(saved?: ModelProjectTrainingSetup["recipe"]): Recipe;
6
+ export {};
7
+ //# sourceMappingURL=model-supervised-training-defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-supervised-training-defaults.d.ts","sourceRoot":"","sources":["../../../../../src/model-supervised-training-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE,KAAK,MAAM,GAAG,WAAW,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAK/D;mFACmF;AACnF,wBAAgB,sCAAsC,CAAC,KAAK,CAAC,EAAE,yBAAyB,CAAC,QAAQ,CAAC,GAAG,MAAM,CAyB1G"}