openpond-sdk 0.0.12 → 0.0.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 (41) hide show
  1. package/README.md +28 -0
  2. package/dist/actions-local.js +34 -14551
  3. package/dist/actions-local.js.map +4 -4
  4. package/dist/actions.js +12 -14530
  5. package/dist/actions.js.map +4 -4
  6. package/dist/index.js +582 -29
  7. package/dist/index.js.map +4 -4
  8. package/dist/model-projects.js +215 -0
  9. package/dist/model-projects.js.map +7 -0
  10. package/dist/profile-actions.js +1 -20
  11. package/dist/profile-actions.js.map +3 -3
  12. package/dist/project-actions.js +1 -20
  13. package/dist/project-actions.js.map +3 -3
  14. package/dist/refiner.js +568 -0
  15. package/dist/refiner.js.map +7 -0
  16. package/dist/training.js +470 -0
  17. package/dist/training.js.map +7 -0
  18. package/dist/types/packages/cloud/src/api/core.d.ts.map +1 -1
  19. package/dist/types/packages/cloud/src/hosted-chat.d.ts +20 -0
  20. package/dist/types/packages/cloud/src/hosted-chat.d.ts.map +1 -1
  21. package/dist/types/packages/cloud/src/sandbox/client-handles.d.ts +2 -1
  22. package/dist/types/packages/cloud/src/sandbox/client-handles.d.ts.map +1 -1
  23. package/dist/types/packages/cloud/src/sandbox/client.d.ts +3 -1
  24. package/dist/types/packages/cloud/src/sandbox/client.d.ts.map +1 -1
  25. package/dist/types/packages/cloud/src/sandbox/types/org-project-agent.d.ts +13 -0
  26. package/dist/types/packages/cloud/src/sandbox/types/org-project-agent.d.ts.map +1 -1
  27. package/dist/types/packages/sdk/src/index.d.ts +1 -0
  28. package/dist/types/packages/sdk/src/index.d.ts.map +1 -1
  29. package/dist/types/packages/sdk/src/model-projects.d.ts +804 -0
  30. package/dist/types/packages/sdk/src/model-projects.d.ts.map +1 -0
  31. package/dist/types/packages/sdk/src/refiner.d.ts +6 -0
  32. package/dist/types/packages/sdk/src/refiner.d.ts.map +1 -0
  33. package/dist/types/packages/sdk/src/training.d.ts +682 -0
  34. package/dist/types/packages/sdk/src/training.d.ts.map +1 -0
  35. package/dist/types/packages/sdk/src/types.d.ts +1 -1
  36. package/dist/types/packages/sdk/src/types.d.ts.map +1 -1
  37. package/dist/workflows.js +1 -20
  38. package/dist/workflows.js.map +3 -3
  39. package/package.json +17 -3
  40. package/dist/types/packages/cloud/src/api/vercel-protection.d.ts +0 -2
  41. package/dist/types/packages/cloud/src/api/vercel-protection.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ function createSandboxAgentNamespace(client) {
57
57
  sourceDeployPlan: (agentId, input) => client.getAgentSourceDeployPlan(agentId, input),
58
58
  manifestSnapshots: (agentId, input) => client.listAgentManifestSnapshots(agentId, input),
59
59
  requestSourceChecks: (agentId, input) => client.requestAgentSourceChecks(agentId, input),
60
+ configureSourceSetup: (agentId, input) => client.configureAgentSourceSetup(agentId, input),
60
61
  publishSource: (agentId, input) => client.publishAgentSource(agentId, input)
61
62
  };
62
63
  }
@@ -498,25 +499,6 @@ function asyncRequestHeaders(options = {}) {
498
499
  return options.async || options.respondAsync ? { Prefer: "respond-async" } : void 0;
499
500
  }
500
501
 
501
- // ../cloud/dist/api/vercel-protection.js
502
- var VERCEL_PROTECTION_BYPASS_HEADER = "x-vercel-protection-bypass";
503
- function withVercelProtectionBypass(requestUrl, inputHeaders, env = typeof process === "undefined" ? {} : process.env) {
504
- const headers = new Headers(inputHeaders);
505
- const secret = env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();
506
- if (!secret || !isOpenPondStagingUrl(requestUrl))
507
- return headers;
508
- headers.set(VERCEL_PROTECTION_BYPASS_HEADER, secret);
509
- return headers;
510
- }
511
- function isOpenPondStagingUrl(requestUrl) {
512
- try {
513
- const hostname = new URL(requestUrl).hostname.toLowerCase();
514
- return hostname === "staging.openpond.ai" || hostname === "staging-api.openpond.ai" || hostname.endsWith(".staging-api.openpond.ai");
515
- } catch {
516
- return false;
517
- }
518
- }
519
-
520
502
  // ../cloud/dist/api/core.js
521
503
  var DEFAULT_API_TIMEOUT_MS = 3e4;
522
504
  var DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;
@@ -559,7 +541,7 @@ var OpenPondApiError = class extends Error {
559
541
  async function apiFetch(baseUrl, token, requestPath, options = {}) {
560
542
  const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;
561
543
  const requestUrl = `${baseUrl}${requestPath}`;
562
- const headers = withVercelProtectionBypass(requestUrl, init.headers);
544
+ const headers = new Headers(init.headers);
563
545
  headers.set("Content-Type", "application/json");
564
546
  const apiKey = process.env.OPENPOND_API_KEY;
565
547
  const trimmedToken = token?.trim() || "";
@@ -755,7 +737,7 @@ function apiRootUrlFromSandboxApiUrl(sandboxApiUrl) {
755
737
  return sandboxApiUrl.slice(0, -suffix.length);
756
738
  }
757
739
  function isOpenPondHostedApiHost(hostname) {
758
- return hostname === "api.openpond.ai" || hostname === "staging-api.openpond.ai" || hostname.startsWith("api") && hostname.endsWith(".openpond.ai");
740
+ return hostname === "api.openpond.ai" || hostname.startsWith("api") && hostname.endsWith(".openpond.ai");
759
741
  }
760
742
 
761
743
  // ../cloud/dist/sandbox/sandbox-instance-client.js
@@ -1308,6 +1290,11 @@ var OpenPondSandboxClient = class extends OpenPondSandboxInstanceClient {
1308
1290
  timeoutMs: 15 * 60 * 1e3
1309
1291
  });
1310
1292
  }
1293
+ configureAgentSourceSetup(agentId, input) {
1294
+ const query = new URLSearchParams({ teamId: input.teamId });
1295
+ const { teamId: _teamId, ...body } = input;
1296
+ return this.requestApiRoot(`/agents/${encodeURIComponent(agentId)}/source/setup?${query.toString()}`, { method: "POST", body: JSON.stringify(body) });
1297
+ }
1311
1298
  publishAgentSource(agentId, input) {
1312
1299
  const query = new URLSearchParams({ teamId: input.teamId });
1313
1300
  const { teamId: _teamId, ...body } = input;
@@ -1773,14 +1760,14 @@ function requireToken(value) {
1773
1760
  throw new Error("OpenPond API key is required");
1774
1761
  return trimmed;
1775
1762
  }
1776
- function hostedHeaders(requestUrl, token, accept, requestId) {
1763
+ function hostedHeaders(token, accept, requestId) {
1777
1764
  const headers = new Headers();
1778
1765
  headers.set("Authorization", `Bearer ${requireToken(token)}`);
1779
1766
  headers.set("Content-Type", "application/json");
1780
1767
  headers.set("Accept", accept);
1781
1768
  headers.set("x-openpond-client", "openpond-code");
1782
1769
  headers.set("x-openpond-request-id", requestId || randomUUID());
1783
- return withVercelProtectionBypass(requestUrl, headers);
1770
+ return headers;
1784
1771
  }
1785
1772
  async function readError(response) {
1786
1773
  const text = await response.text().catch(() => "");
@@ -1826,7 +1813,7 @@ async function listOpChatModels(options) {
1826
1813
  const requestUrl = `${apiBaseUrl}/models`;
1827
1814
  const response = await fetch(requestUrl, {
1828
1815
  method: "GET",
1829
- headers: hostedHeaders(requestUrl, options.token, "application/json"),
1816
+ headers: hostedHeaders(options.token, "application/json"),
1830
1817
  signal: options.signal
1831
1818
  });
1832
1819
  if (!response.ok) {
@@ -1839,7 +1826,7 @@ async function getOpChatModel(options) {
1839
1826
  const requestUrl = `${apiBaseUrl}/models/${encodeURIComponent(options.model)}`;
1840
1827
  const response = await fetch(requestUrl, {
1841
1828
  method: "GET",
1842
- headers: hostedHeaders(requestUrl, options.token, "application/json"),
1829
+ headers: hostedHeaders(options.token, "application/json"),
1843
1830
  signal: options.signal
1844
1831
  });
1845
1832
  if (!response.ok) {
@@ -1852,7 +1839,7 @@ async function listOpChatProviders(options) {
1852
1839
  const requestUrl = `${apiBaseUrl}/providers`;
1853
1840
  const response = await fetch(requestUrl, {
1854
1841
  method: "GET",
1855
- headers: hostedHeaders(requestUrl, options.token, "application/json"),
1842
+ headers: hostedHeaders(options.token, "application/json"),
1856
1843
  signal: options.signal
1857
1844
  });
1858
1845
  if (!response.ok) {
@@ -1865,7 +1852,7 @@ async function getOpChatProvider(options) {
1865
1852
  const requestUrl = `${apiBaseUrl}/providers/${encodeURIComponent(options.provider)}`;
1866
1853
  const response = await fetch(requestUrl, {
1867
1854
  method: "GET",
1868
- headers: hostedHeaders(requestUrl, options.token, "application/json"),
1855
+ headers: hostedHeaders(options.token, "application/json"),
1869
1856
  signal: options.signal
1870
1857
  });
1871
1858
  if (!response.ok) {
@@ -1878,7 +1865,7 @@ async function sendHostedChatTurn(options) {
1878
1865
  const requestUrl = `${apiBaseUrl}/chat/completions`;
1879
1866
  const response = await fetch(requestUrl, {
1880
1867
  method: "POST",
1881
- headers: hostedHeaders(requestUrl, options.token, "application/json", options.requestId),
1868
+ headers: hostedHeaders(options.token, "application/json", options.requestId),
1882
1869
  body: JSON.stringify(buildHostedChatBody(options, false)),
1883
1870
  signal: options.signal
1884
1871
  });
@@ -1926,7 +1913,7 @@ async function* streamHostedChatTurn(options) {
1926
1913
  const requestUrl = `${apiBaseUrl}/chat/completions`;
1927
1914
  const response = await fetch(requestUrl, {
1928
1915
  method: "POST",
1929
- headers: hostedHeaders(requestUrl, options.token, "text/event-stream", options.requestId),
1916
+ headers: hostedHeaders(options.token, "text/event-stream", options.requestId),
1930
1917
  body: JSON.stringify(buildHostedChatBody(options, true)),
1931
1918
  signal: options.signal
1932
1919
  });
@@ -2700,6 +2687,561 @@ function requiredId(value, label) {
2700
2687
  return normalized;
2701
2688
  }
2702
2689
 
2690
+ // ../harness/dist/refiner.js
2691
+ import { z as z3 } from "zod";
2692
+
2693
+ // ../harness/dist/common.js
2694
+ import { z } from "zod";
2695
+
2696
+ // ../harness/dist/sha256.js
2697
+ var INITIAL_STATE = new Uint32Array([
2698
+ 1779033703,
2699
+ 3144134277,
2700
+ 1013904242,
2701
+ 2773480762,
2702
+ 1359893119,
2703
+ 2600822924,
2704
+ 528734635,
2705
+ 1541459225
2706
+ ]);
2707
+ var ROUND_CONSTANTS = new Uint32Array([
2708
+ 1116352408,
2709
+ 1899447441,
2710
+ 3049323471,
2711
+ 3921009573,
2712
+ 961987163,
2713
+ 1508970993,
2714
+ 2453635748,
2715
+ 2870763221,
2716
+ 3624381080,
2717
+ 310598401,
2718
+ 607225278,
2719
+ 1426881987,
2720
+ 1925078388,
2721
+ 2162078206,
2722
+ 2614888103,
2723
+ 3248222580,
2724
+ 3835390401,
2725
+ 4022224774,
2726
+ 264347078,
2727
+ 604807628,
2728
+ 770255983,
2729
+ 1249150122,
2730
+ 1555081692,
2731
+ 1996064986,
2732
+ 2554220882,
2733
+ 2821834349,
2734
+ 2952996808,
2735
+ 3210313671,
2736
+ 3336571891,
2737
+ 3584528711,
2738
+ 113926993,
2739
+ 338241895,
2740
+ 666307205,
2741
+ 773529912,
2742
+ 1294757372,
2743
+ 1396182291,
2744
+ 1695183700,
2745
+ 1986661051,
2746
+ 2177026350,
2747
+ 2456956037,
2748
+ 2730485921,
2749
+ 2820302411,
2750
+ 3259730800,
2751
+ 3345764771,
2752
+ 3516065817,
2753
+ 3600352804,
2754
+ 4094571909,
2755
+ 275423344,
2756
+ 430227734,
2757
+ 506948616,
2758
+ 659060556,
2759
+ 883997877,
2760
+ 958139571,
2761
+ 1322822218,
2762
+ 1537002063,
2763
+ 1747873779,
2764
+ 1955562222,
2765
+ 2024104815,
2766
+ 2227730452,
2767
+ 2361852424,
2768
+ 2428436474,
2769
+ 2756734187,
2770
+ 3204031479,
2771
+ 3329325298
2772
+ ]);
2773
+ function sha256Hex(value) {
2774
+ const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
2775
+ const paddedLength = Math.ceil((bytes.byteLength + 9) / 64) * 64;
2776
+ const padded = new Uint8Array(paddedLength);
2777
+ padded.set(bytes);
2778
+ padded[bytes.byteLength] = 128;
2779
+ const bitLength = bytes.byteLength * 8;
2780
+ const view = new DataView(padded.buffer);
2781
+ view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296), false);
2782
+ view.setUint32(paddedLength - 4, bitLength >>> 0, false);
2783
+ const state = new Uint32Array(INITIAL_STATE);
2784
+ const words = new Uint32Array(64);
2785
+ for (let offset = 0; offset < paddedLength; offset += 64) {
2786
+ for (let index = 0; index < 16; index += 1) {
2787
+ words[index] = view.getUint32(offset + index * 4, false);
2788
+ }
2789
+ for (let index = 16; index < 64; index += 1) {
2790
+ const previous = words[index - 15];
2791
+ const recent = words[index - 2];
2792
+ const sigma0 = rotateRight(previous, 7) ^ rotateRight(previous, 18) ^ previous >>> 3;
2793
+ const sigma1 = rotateRight(recent, 17) ^ rotateRight(recent, 19) ^ recent >>> 10;
2794
+ words[index] = words[index - 16] + sigma0 + words[index - 7] + sigma1 >>> 0;
2795
+ }
2796
+ let a = state[0];
2797
+ let b = state[1];
2798
+ let c = state[2];
2799
+ let d = state[3];
2800
+ let e = state[4];
2801
+ let f = state[5];
2802
+ let g = state[6];
2803
+ let h = state[7];
2804
+ for (let index = 0; index < 64; index += 1) {
2805
+ const choice = e & f ^ ~e & g;
2806
+ const majority = a & b ^ a & c ^ b & c;
2807
+ const sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
2808
+ const sum1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
2809
+ const first = h + sum1 + choice + ROUND_CONSTANTS[index] + words[index] >>> 0;
2810
+ const second = sum0 + majority >>> 0;
2811
+ h = g;
2812
+ g = f;
2813
+ f = e;
2814
+ e = d + first >>> 0;
2815
+ d = c;
2816
+ c = b;
2817
+ b = a;
2818
+ a = first + second >>> 0;
2819
+ }
2820
+ state[0] = state[0] + a >>> 0;
2821
+ state[1] = state[1] + b >>> 0;
2822
+ state[2] = state[2] + c >>> 0;
2823
+ state[3] = state[3] + d >>> 0;
2824
+ state[4] = state[4] + e >>> 0;
2825
+ state[5] = state[5] + f >>> 0;
2826
+ state[6] = state[6] + g >>> 0;
2827
+ state[7] = state[7] + h >>> 0;
2828
+ }
2829
+ return Array.from(state, (word) => word.toString(16).padStart(8, "0")).join("");
2830
+ }
2831
+ function rotateRight(value, bits) {
2832
+ return value >>> bits | value << 32 - bits;
2833
+ }
2834
+
2835
+ // ../harness/dist/common.js
2836
+ var MAX_PORTABLE_PATH_BYTES = 2e3;
2837
+ var MAX_PORTABLE_ASSET_BYTES = 25e7;
2838
+ var ReleaseIdSchema = z.string().trim().min(1).max(240);
2839
+ var ReleaseHashSchema = z.string().regex(/^[a-f0-9]{64}$/);
2840
+ var ReleaseTimestampSchema = z.string().datetime({ offset: true });
2841
+ var MetadataSchema = z.record(z.string(), z.unknown()).default({});
2842
+ var ImmutableReleaseRefSchema = z.object({
2843
+ id: ReleaseIdSchema,
2844
+ contentHash: ReleaseHashSchema
2845
+ }).strict();
2846
+ var ImmutableAssetRefSchema = z.object({
2847
+ id: ReleaseIdSchema,
2848
+ path: z.string().trim().min(1).max(MAX_PORTABLE_PATH_BYTES).refine(safeRelativePath),
2849
+ contentHash: ReleaseHashSchema,
2850
+ sizeBytes: z.number().int().nonnegative().max(MAX_PORTABLE_ASSET_BYTES),
2851
+ mediaType: z.string().trim().min(1).max(200),
2852
+ visibility: z.enum(["policy", "verifier", "host_private"])
2853
+ }).strict();
2854
+ var ImmutableArtifactRefSchema = z.object({
2855
+ id: ReleaseIdSchema,
2856
+ contentHash: ReleaseHashSchema,
2857
+ mediaType: z.string().trim().min(1).max(200).nullable().default(null),
2858
+ sizeBytes: z.number().int().nonnegative().max(MAX_PORTABLE_ASSET_BYTES).nullable().default(null)
2859
+ }).strict();
2860
+ var FailureClassSchema = z.enum([
2861
+ "policy_failure",
2862
+ "grader_failure",
2863
+ "environment_failure",
2864
+ "infrastructure_failure",
2865
+ "timeout",
2866
+ "cancelled"
2867
+ ]);
2868
+ function canonicalJson(value) {
2869
+ return `${JSON.stringify(sortValue(value), null, 2)}
2870
+ `;
2871
+ }
2872
+ function sha256(value) {
2873
+ return sha256Hex(value);
2874
+ }
2875
+ function contentHash(value) {
2876
+ return sha256(canonicalJson(value));
2877
+ }
2878
+ function safeRelativePath(value) {
2879
+ const normalized = value.replaceAll("\\", "/");
2880
+ if (!normalized || normalized.startsWith("/") || normalized.includes("\0"))
2881
+ return false;
2882
+ return !normalized.split("/").some((part) => !part || part === "." || part === "..");
2883
+ }
2884
+ function sortValue(value) {
2885
+ if (Array.isArray(value))
2886
+ return value.map(sortValue);
2887
+ if (!value || typeof value !== "object")
2888
+ return value;
2889
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortValue(child)]));
2890
+ }
2891
+
2892
+ // ../harness/dist/refiner-profiles.js
2893
+ import { z as z2 } from "zod";
2894
+ var RefinerProposalRouteSchema = z2.enum(["memory", "prompt", "skill", "agent"]);
2895
+ var RefinerExternalRouteSchema = z2.enum(["runtime", "product", "taskset", "training"]);
2896
+ var RefinerReviewInstructionSchema = z2.object({
2897
+ id: z2.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
2898
+ text: z2.string().trim().min(1).max(1e4)
2899
+ }).strict();
2900
+ var RefinerReviewProfileSchema = z2.object({
2901
+ schemaVersion: z2.literal("openpond.refinerReviewProfile.v1"),
2902
+ id: z2.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
2903
+ version: z2.string().trim().min(1).max(120),
2904
+ name: z2.string().trim().min(1).max(200),
2905
+ objective: z2.string().trim().min(1).max(1e4),
2906
+ instructions: z2.array(RefinerReviewInstructionSchema).max(100),
2907
+ allowedProposalRoutes: z2.array(RefinerProposalRouteSchema).max(4),
2908
+ allowedExternalRoutes: z2.array(RefinerExternalRouteSchema).max(4)
2909
+ }).strict().superRefine((profile, context) => {
2910
+ const instructionIds = profile.instructions.map((instruction) => instruction.id);
2911
+ if (new Set(instructionIds).size !== instructionIds.length) {
2912
+ context.addIssue({ code: "custom", message: "instruction IDs must be unique", path: ["instructions"] });
2913
+ }
2914
+ if (new Set(profile.allowedProposalRoutes).size !== profile.allowedProposalRoutes.length) {
2915
+ context.addIssue({ code: "custom", message: "proposal routes must be unique", path: ["allowedProposalRoutes"] });
2916
+ }
2917
+ if (new Set(profile.allowedExternalRoutes).size !== profile.allowedExternalRoutes.length) {
2918
+ context.addIssue({ code: "custom", message: "external routes must be unique", path: ["allowedExternalRoutes"] });
2919
+ }
2920
+ });
2921
+ var DEFAULT_REFINER_REVIEW_PROFILE = {
2922
+ schemaVersion: "openpond.refinerReviewProfile.v1",
2923
+ id: "openpond.default",
2924
+ version: "1",
2925
+ name: "OpenPond default review",
2926
+ objective: "Find the smallest reusable change that improves future work without learning task-specific facts.",
2927
+ instructions: [],
2928
+ allowedProposalRoutes: ["memory", "prompt", "skill", "agent"],
2929
+ allowedExternalRoutes: ["runtime", "product", "taskset", "training"]
2930
+ };
2931
+ var RefinerReleaseSchema = z2.object({
2932
+ schemaVersion: z2.literal("openpond.refinerRelease.v1"),
2933
+ id: z2.string().trim().min(1).max(240),
2934
+ coreVersion: z2.string().trim().min(1).max(120),
2935
+ coreHash: ReleaseHashSchema,
2936
+ profile: RefinerReviewProfileSchema,
2937
+ profileHash: ReleaseHashSchema,
2938
+ composedPromptHash: ReleaseHashSchema,
2939
+ createdAt: ReleaseTimestampSchema,
2940
+ contentHash: ReleaseHashSchema
2941
+ }).strict();
2942
+ var RefinerBindingSchema = z2.object({
2943
+ schemaVersion: z2.literal("openpond.refinerBinding.v1"),
2944
+ channel: z2.literal("active"),
2945
+ revision: z2.number().int().nonnegative(),
2946
+ release: ImmutableReleaseRefSchema,
2947
+ updatedAt: ReleaseTimestampSchema
2948
+ }).strict();
2949
+ var RefinerTransitionReceiptSchema = z2.object({
2950
+ schemaVersion: z2.literal("openpond.refinerTransitionReceipt.v1"),
2951
+ id: z2.string().trim().min(1).max(240),
2952
+ operation: z2.enum(["initialize", "update", "activate", "rollback"]),
2953
+ bindingChanged: z2.boolean(),
2954
+ previousRelease: ImmutableReleaseRefSchema.nullable(),
2955
+ nextRelease: ImmutableReleaseRefSchema,
2956
+ actor: z2.string().trim().min(1).max(240),
2957
+ reason: z2.string().trim().min(1).max(1e4),
2958
+ authoringSkillHash: ReleaseHashSchema.nullable(),
2959
+ validation: z2.object({ valid: z2.boolean(), messages: z2.array(z2.string().max(2e3)).max(100) }).strict(),
2960
+ createdAt: ReleaseTimestampSchema,
2961
+ contentHash: ReleaseHashSchema
2962
+ }).strict();
2963
+ function defineReviewProfile(profile) {
2964
+ return RefinerReviewProfileSchema.parse(profile);
2965
+ }
2966
+ function createRefinerRelease(input) {
2967
+ const profile = RefinerReviewProfileSchema.parse(input.profile);
2968
+ const createdAt = input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
2969
+ const coreHash = contentHash({ coreVersion: input.coreVersion, corePrompt: input.corePrompt });
2970
+ const profileHash = contentHash(profile);
2971
+ const composedPromptHash = contentHash({ coreHash, profile });
2972
+ const releaseWithoutHash = {
2973
+ schemaVersion: "openpond.refinerRelease.v1",
2974
+ id: `refiner-${composedPromptHash.slice(0, 24)}`,
2975
+ coreVersion: input.coreVersion,
2976
+ coreHash,
2977
+ profile,
2978
+ profileHash,
2979
+ composedPromptHash,
2980
+ createdAt
2981
+ };
2982
+ return RefinerReleaseSchema.parse({
2983
+ ...releaseWithoutHash,
2984
+ contentHash: contentHash(releaseWithoutHash)
2985
+ });
2986
+ }
2987
+ function refinerProfilePrompt(profile) {
2988
+ const parsed = RefinerReviewProfileSchema.parse(profile);
2989
+ return [
2990
+ `Review profile: ${parsed.name} (${parsed.id}@${parsed.version})`,
2991
+ `Objective: ${parsed.objective}`,
2992
+ `Allowed Harness proposal routes: ${parsed.allowedProposalRoutes.join(", ")}.`,
2993
+ `Allowed external routes: ${parsed.allowedExternalRoutes.join(", ")}.`,
2994
+ ...parsed.instructions.map((instruction) => `[${instruction.id}] ${instruction.text}`)
2995
+ ].join("\n");
2996
+ }
2997
+ function serializeReviewProfile(profile) {
2998
+ return canonicalJson(RefinerReviewProfileSchema.parse(profile));
2999
+ }
3000
+
3001
+ // ../harness/dist/refiner.js
3002
+ var RefinerNoActionDecisionSchema = z3.object({
3003
+ schemaVersion: z3.literal("openpond.localHarnessRefinerDecision.v1"),
3004
+ decision: z3.literal("no_action"),
3005
+ reason: z3.string().trim().min(1).max(1e4)
3006
+ }).strip();
3007
+ var RefinerExternalRouteDecisionSchema = z3.object({
3008
+ schemaVersion: z3.literal("openpond.localHarnessRefinerDecision.v1"),
3009
+ decision: z3.literal("route"),
3010
+ route: z3.enum(["runtime", "product", "taskset", "training"]),
3011
+ summary: z3.string().trim().min(1).max(2e3),
3012
+ expectedOutcome: z3.string().trim().min(1).max(1e4),
3013
+ reason: z3.string().trim().min(1).max(1e4)
3014
+ }).strip();
3015
+ var RefinerProposalDecisionSchema = z3.object({
3016
+ schemaVersion: z3.literal("openpond.localHarnessRefinerDecision.v1"),
3017
+ decision: z3.literal("propose"),
3018
+ route: z3.enum(["memory", "prompt", "skill", "agent"]),
3019
+ operation: z3.enum(["create", "update", "delete"]),
3020
+ target: z3.string().trim().min(1).max(2e3),
3021
+ summary: z3.string().trim().min(1).max(2e3),
3022
+ createContent: z3.string().min(1).max(2e4).nullable(),
3023
+ find: z3.string().min(1).max(8e3).nullable(),
3024
+ replace: z3.string().max(8e3).nullable(),
3025
+ expectedOutcome: z3.string().trim().min(1).max(1e4),
3026
+ reason: z3.string().trim().min(1).max(1e4)
3027
+ }).strip().superRefine((decision, context) => {
3028
+ if (decision.operation === "create" && (decision.createContent === null || decision.find !== null || decision.replace !== null)) {
3029
+ context.addIssue({
3030
+ code: "custom",
3031
+ message: "create proposals require createContent and null find/replace",
3032
+ path: ["createContent"]
3033
+ });
3034
+ }
3035
+ if (decision.operation === "update" && (decision.createContent !== null || decision.find === null || decision.replace === null)) {
3036
+ context.addIssue({
3037
+ code: "custom",
3038
+ message: "update proposals require one exact find/replace edit and null createContent",
3039
+ path: ["find"]
3040
+ });
3041
+ }
3042
+ if (decision.operation === "delete" && (decision.createContent !== null || decision.find !== null || decision.replace !== null)) {
3043
+ context.addIssue({
3044
+ code: "custom",
3045
+ message: "delete proposals require null createContent/find/replace",
3046
+ path: ["createContent"]
3047
+ });
3048
+ }
3049
+ });
3050
+ var LocalHarnessRefinerDecisionSchema = z3.discriminatedUnion("decision", [
3051
+ RefinerNoActionDecisionSchema,
3052
+ RefinerExternalRouteDecisionSchema,
3053
+ RefinerProposalDecisionSchema
3054
+ ]);
3055
+ var LocalHarnessRefinerDecisionV1Schema = LocalHarnessRefinerDecisionSchema;
3056
+ var HarnessRefinerEvidenceBasisSchema = z3.object({
3057
+ kind: z3.enum(["single_deterministic", "recurrent_independent"]),
3058
+ supportingEvidenceIds: z3.array(z3.string().trim().min(1).max(2e3)).min(1).max(100),
3059
+ counterevidence: z3.array(z3.string().trim().min(1).max(2e3)).max(20)
3060
+ }).strict().superRefine((basis, context) => {
3061
+ if (new Set(basis.supportingEvidenceIds).size !== basis.supportingEvidenceIds.length) {
3062
+ context.addIssue({
3063
+ code: "custom",
3064
+ message: "supporting evidence IDs must be unique",
3065
+ path: ["supportingEvidenceIds"]
3066
+ });
3067
+ }
3068
+ if (basis.kind === "recurrent_independent" && basis.supportingEvidenceIds.length < 2) {
3069
+ context.addIssue({
3070
+ code: "custom",
3071
+ message: "recurrent independent evidence requires at least two supplied incidents",
3072
+ path: ["supportingEvidenceIds"]
3073
+ });
3074
+ }
3075
+ });
3076
+ var RefinerNoActionDecisionV2Schema = z3.object({
3077
+ schemaVersion: z3.literal("openpond.localHarnessRefinerDecision.v2"),
3078
+ decision: z3.literal("no_action"),
3079
+ reason: z3.string().trim().min(1).max(1e4)
3080
+ }).strict();
3081
+ var RefinerExternalRouteDecisionV2Schema = z3.object({
3082
+ schemaVersion: z3.literal("openpond.localHarnessRefinerDecision.v2"),
3083
+ decision: z3.literal("route"),
3084
+ route: z3.enum(["runtime", "product", "taskset", "training"]),
3085
+ summary: z3.string().trim().min(1).max(2e3),
3086
+ evidenceBasis: HarnessRefinerEvidenceBasisSchema,
3087
+ expectedOutcome: z3.string().trim().min(1).max(1e4),
3088
+ reason: z3.string().trim().min(1).max(1e4)
3089
+ }).strict();
3090
+ var RefinerProposalDecisionV2Schema = z3.object({
3091
+ schemaVersion: z3.literal("openpond.localHarnessRefinerDecision.v2"),
3092
+ decision: z3.literal("propose"),
3093
+ route: z3.enum(["memory", "prompt", "skill", "agent"]),
3094
+ operation: z3.enum(["create", "update", "delete"]),
3095
+ target: z3.string().trim().min(1).max(2e3),
3096
+ summary: z3.string().trim().min(1).max(2e3),
3097
+ evidenceBasis: HarnessRefinerEvidenceBasisSchema,
3098
+ createContent: z3.string().min(1).max(2e4).nullable(),
3099
+ find: z3.string().min(1).max(8e3).nullable(),
3100
+ replace: z3.string().max(8e3).nullable(),
3101
+ expectedOutcome: z3.string().trim().min(1).max(1e4),
3102
+ reason: z3.string().trim().min(1).max(1e4)
3103
+ }).strict().superRefine((decision, context) => {
3104
+ if (decision.operation === "create" && (decision.createContent === null || decision.find !== null || decision.replace !== null)) {
3105
+ context.addIssue({
3106
+ code: "custom",
3107
+ message: "create proposals require createContent and null find/replace",
3108
+ path: ["createContent"]
3109
+ });
3110
+ }
3111
+ if (decision.operation === "update" && (decision.createContent !== null || decision.find === null || decision.replace === null)) {
3112
+ context.addIssue({
3113
+ code: "custom",
3114
+ message: "update proposals require one exact find/replace edit and null createContent",
3115
+ path: ["find"]
3116
+ });
3117
+ }
3118
+ if (decision.operation === "delete" && (decision.createContent !== null || decision.find !== null || decision.replace !== null)) {
3119
+ context.addIssue({
3120
+ code: "custom",
3121
+ message: "delete proposals require null createContent/find/replace",
3122
+ path: ["createContent"]
3123
+ });
3124
+ }
3125
+ });
3126
+ var LocalHarnessRefinerDecisionV2Schema = z3.discriminatedUnion("decision", [
3127
+ RefinerNoActionDecisionV2Schema,
3128
+ RefinerExternalRouteDecisionV2Schema,
3129
+ RefinerProposalDecisionV2Schema
3130
+ ]);
3131
+ var LocalHarnessRefinerDecisionAnySchema = z3.union([
3132
+ LocalHarnessRefinerDecisionV1Schema,
3133
+ LocalHarnessRefinerDecisionV2Schema
3134
+ ]);
3135
+ var HarnessRefinerCapabilitiesSchema = z3.object({
3136
+ memory: z3.boolean(),
3137
+ prompt: z3.boolean(),
3138
+ skill: z3.boolean(),
3139
+ agent: z3.boolean()
3140
+ }).strict();
3141
+ var SourceKindSchema = z3.enum(["memory", "instruction", "skill", "agent"]);
3142
+ var RefinerSourceFileSchema = z3.object({
3143
+ path: z3.string().trim().min(1).max(2e3),
3144
+ kind: SourceKindSchema,
3145
+ content: z3.string().max(6e4),
3146
+ loaded: z3.boolean()
3147
+ }).strict();
3148
+ var RefinerSourceCatalogEntrySchema = z3.object({
3149
+ path: z3.string().trim().min(1).max(2e3),
3150
+ kind: SourceKindSchema,
3151
+ loaded: z3.boolean()
3152
+ }).strict();
3153
+ var LocalHarnessRefinerEvidenceSchema = z3.object({
3154
+ capabilities: HarnessRefinerCapabilitiesSchema,
3155
+ trigger: z3.record(z3.string(), z3.unknown()),
3156
+ observations: z3.array(z3.record(z3.string(), z3.unknown())).max(20),
3157
+ admissibleEvidenceIds: z3.array(z3.string().trim().min(1).max(2e3)).max(1e4),
3158
+ reviewPacket: z3.object({
3159
+ currentTurn: z3.object({
3160
+ id: z3.string().trim().min(1).max(2e3),
3161
+ status: z3.string().trim().min(1).max(100).nullable(),
3162
+ error: z3.string().max(2100).nullable(),
3163
+ prompt: z3.string().max(8100).nullable(),
3164
+ assistantOutput: z3.string().max(8100).nullable(),
3165
+ assistantOutputLinkCount: z3.number().int().nonnegative()
3166
+ }).strict(),
3167
+ priorConversation: z3.array(z3.object({
3168
+ turnId: z3.string().trim().min(1).max(2e3),
3169
+ status: z3.string().trim().min(1).max(100).nullable(),
3170
+ prompt: z3.string().max(3100).nullable(),
3171
+ assistantOutput: z3.string().max(3100).nullable()
3172
+ }).strict()).max(3),
3173
+ timeline: z3.array(z3.record(z3.string(), z3.unknown())).max(60),
3174
+ artifacts: z3.array(z3.record(z3.string(), z3.unknown())).max(30),
3175
+ artifactDiagnostics: z3.array(z3.record(z3.string(), z3.unknown())).max(20),
3176
+ executionProfile: z3.object({
3177
+ modelRequestCount: z3.number().int().nonnegative(),
3178
+ failedModelRequestCount: z3.number().int().nonnegative(),
3179
+ promptTokens: z3.number().int().nonnegative(),
3180
+ completionTokens: z3.number().int().nonnegative(),
3181
+ totalTokens: z3.number().int().nonnegative(),
3182
+ toolFailureCount: z3.number().int().nonnegative(),
3183
+ retryCount: z3.number().int().nonnegative(),
3184
+ recoveryCount: z3.number().int().nonnegative()
3185
+ }).strict(),
3186
+ priorIncidents: z3.array(z3.record(z3.string(), z3.unknown())).max(3),
3187
+ truncation: z3.object({
3188
+ timelineEventCount: z3.number().int().nonnegative(),
3189
+ includedTimelineEventCount: z3.number().int().nonnegative(),
3190
+ timelineTruncated: z3.boolean()
3191
+ }).strict()
3192
+ }).strict(),
3193
+ runtimeActivation: z3.object({
3194
+ admittedRelease: ImmutableReleaseRefSchema,
3195
+ currentRelease: ImmutableReleaseRefSchema,
3196
+ rebasedOntoCurrent: z3.boolean(),
3197
+ admittedSourceFiles: z3.array(RefinerSourceFileSchema).max(100),
3198
+ admittedSourceCatalog: z3.array(RefinerSourceCatalogEntrySchema).max(1e3)
3199
+ }).strict(),
3200
+ sourceFiles: z3.array(RefinerSourceFileSchema).max(100),
3201
+ sourceCatalog: z3.array(RefinerSourceCatalogEntrySchema).max(1e3),
3202
+ additionalEvidence: z3.unknown().nullable().optional()
3203
+ }).strict();
3204
+ var REFINER_CORE_VERSION = "openpond.refinerCore.v2";
3205
+ var OverlayRefSchema = z3.object({
3206
+ id: z3.string().trim().min(1).max(240),
3207
+ revision: z3.number().int().nonnegative(),
3208
+ contentHash: ReleaseHashSchema
3209
+ }).strict();
3210
+ var HostedHarnessRefinerRequestSchema = z3.object({
3211
+ schemaVersion: z3.literal("openpond.hostedHarnessRefinerRequest.v2"),
3212
+ requestId: z3.string().trim().min(1).max(240),
3213
+ idempotencyKey: z3.string().trim().min(1).max(240),
3214
+ evidenceHash: ReleaseHashSchema,
3215
+ harness: z3.object({
3216
+ admittedRelease: ImmutableReleaseRefSchema,
3217
+ currentRelease: ImmutableReleaseRefSchema,
3218
+ overlay: OverlayRefSchema,
3219
+ workspace: z3.object({
3220
+ id: z3.string().trim().min(1).max(240),
3221
+ revision: z3.number().int().nonnegative(),
3222
+ sourceRevision: ReleaseHashSchema,
3223
+ channelRevision: z3.number().int().nonnegative()
3224
+ }).strict(),
3225
+ capabilities: HarnessRefinerCapabilitiesSchema
3226
+ }).strict(),
3227
+ evidence: LocalHarnessRefinerEvidenceSchema
3228
+ }).strict();
3229
+ var HostedHarnessRefinerUsageSchema = z3.object({
3230
+ promptTokens: z3.number().int().nonnegative(),
3231
+ completionTokens: z3.number().int().nonnegative(),
3232
+ totalTokens: z3.number().int().nonnegative()
3233
+ }).strict();
3234
+ var HostedHarnessRefinerResponseSchema = z3.object({
3235
+ schemaVersion: z3.literal("openpond.hostedHarnessRefinerResponse.v2"),
3236
+ requestId: z3.string().trim().min(1).max(240),
3237
+ evidenceHash: ReleaseHashSchema,
3238
+ admittedRelease: ImmutableReleaseRefSchema,
3239
+ currentRelease: ImmutableReleaseRefSchema,
3240
+ decision: LocalHarnessRefinerDecisionV2Schema,
3241
+ serviceRevision: z3.string().trim().min(1).max(240),
3242
+ usage: HostedHarnessRefinerUsageSchema
3243
+ }).strict();
3244
+
2703
3245
  // ../cloud/dist/sandbox/types/runtime-profiles.js
2704
3246
  var SANDBOX_RUNTIME_PROFILE_IDS = [
2705
3247
  "openpond-generic-v1",
@@ -2739,6 +3281,7 @@ function createOpenPondClient(options) {
2739
3281
  return new OpenPondClient(options);
2740
3282
  }
2741
3283
  export {
3284
+ DEFAULT_REFINER_REVIEW_PROFILE,
2742
3285
  OpenPondApiError,
2743
3286
  OpenPondClient,
2744
3287
  OpenPondProfileActionsClient,
@@ -2746,16 +3289,26 @@ export {
2746
3289
  OpenPondSandboxClient,
2747
3290
  OpenPondWorkClient,
2748
3291
  OpenPondWorkflowsClient,
3292
+ REFINER_CORE_VERSION,
3293
+ RefinerBindingSchema,
3294
+ RefinerReleaseSchema,
3295
+ RefinerReviewInstructionSchema,
3296
+ RefinerReviewProfileSchema,
3297
+ RefinerTransitionReceiptSchema,
2749
3298
  SANDBOX_RUNTIME_PROFILE_IDS,
2750
3299
  createOpenPondClient,
2751
3300
  createOpenPondSandboxClient,
3301
+ createRefinerRelease,
3302
+ defineReviewProfile,
2752
3303
  getOpChatModel,
2753
3304
  getOpChatProvider,
2754
3305
  listOpChatModels,
2755
3306
  listOpChatProviders,
2756
3307
  normalizeSandboxApiUrl,
3308
+ refinerProfilePrompt,
2757
3309
  resolveOpChatApiBaseUrl,
2758
3310
  sendHostedChatTurn,
3311
+ serializeReviewProfile,
2759
3312
  streamHostedChatTurn
2760
3313
  };
2761
3314
  //# sourceMappingURL=index.js.map