openpond-sdk 0.12.4 → 0.12.5

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 (83) hide show
  1. package/dist/advanced-refiner-evaluations.js +7 -7
  2. package/dist/candidate-evaluations.js +6 -6
  3. package/dist/{chunk-OR3TMIJN.js → chunk-25L5IXHA.js} +2 -2
  4. package/dist/{chunk-VN5V2E2S.js → chunk-6GQ3GIAP.js} +3 -3
  5. package/dist/{chunk-B5XTGEBE.js → chunk-6KKM2XRR.js} +54 -6
  6. package/dist/chunk-6KKM2XRR.js.map +1 -0
  7. package/dist/{chunk-ETX25FTB.js → chunk-6MFFKAU6.js} +2 -2
  8. package/dist/{chunk-DF2QXVZ3.js → chunk-6Y67YHVH.js} +5 -5
  9. package/dist/{chunk-K5LWSWV7.js → chunk-AUNNXJQE.js} +2 -2
  10. package/dist/{chunk-LHX7ENKZ.js → chunk-BGNPKYBJ.js} +3 -3
  11. package/dist/{chunk-I54WQBXL.js → chunk-BJ5MKLWH.js} +6 -6
  12. package/dist/{chunk-24N6A6SF.js → chunk-BYNVSWIQ.js} +2 -2
  13. package/dist/{chunk-HGXVOFCL.js → chunk-CAMLCKSF.js} +2 -2
  14. package/dist/chunk-CAMLCKSF.js.map +1 -0
  15. package/dist/{chunk-53LLNDXF.js → chunk-DBKCSQVH.js} +2 -2
  16. package/dist/{chunk-MO4HAJZG.js → chunk-EJZ7HOIS.js} +3 -3
  17. package/dist/{chunk-MO4HAJZG.js.map → chunk-EJZ7HOIS.js.map} +1 -1
  18. package/dist/{chunk-EFUT3XKW.js → chunk-F4GITADW.js} +2 -2
  19. package/dist/{chunk-CMWZZZGW.js → chunk-FLNWE5ZA.js} +3 -3
  20. package/dist/{chunk-VHGC44HA.js → chunk-GWGDWZVN.js} +2 -2
  21. package/dist/{chunk-LR5CTOC5.js → chunk-HOOHJCE7.js} +3 -3
  22. package/dist/{chunk-XON75UFN.js → chunk-KKL6OICH.js} +2 -2
  23. package/dist/{chunk-QRS7Y3EM.js → chunk-MJELLVQP.js} +2 -2
  24. package/dist/{chunk-U7XWIOSB.js → chunk-O54KGALH.js} +2 -2
  25. package/dist/{chunk-BVMR5OFW.js → chunk-QFBSNSUL.js} +3 -3
  26. package/dist/{chunk-ZHQK3MOM.js → chunk-RE426Q7Y.js} +3 -3
  27. package/dist/{chunk-WMIKJGXW.js → chunk-T3MFWGMX.js} +3 -3
  28. package/dist/{chunk-ZIFZFP5I.js → chunk-VZPNRPXL.js} +3 -3
  29. package/dist/{chunk-RRKRA237.js → chunk-XACJ63U4.js} +3 -3
  30. package/dist/{chunk-GAIDBPFY.js → chunk-ZFYI4P6C.js} +2 -2
  31. package/dist/connected-evidence.js +13 -13
  32. package/dist/dataset-workspaces.js +13 -13
  33. package/dist/experiment-evaluation-schedules.js +17 -17
  34. package/dist/experiment-improvements.js +7 -7
  35. package/dist/experiments.js +16 -16
  36. package/dist/index.js +79 -35
  37. package/dist/index.js.map +1 -1
  38. package/dist/model-projects.js +1 -1
  39. package/dist/model-starter-attempts.js +2 -2
  40. package/dist/model-starter-catalog.js +9 -9
  41. package/dist/model-starters.js +9 -9
  42. package/dist/model-taskset-runs.js +3 -3
  43. package/dist/post-training.js +6 -6
  44. package/dist/taskset-drafts.js +12 -12
  45. package/dist/taskset-packages.js +14 -14
  46. package/dist/training-bundle.js +10 -10
  47. package/dist/training.js +7 -7
  48. package/dist/types/packages/cloud/src/hosted-chat.d.ts +28 -0
  49. package/dist/types/packages/cloud/src/hosted-chat.d.ts.map +1 -1
  50. package/dist/types/packages/sdk/src/model-bound-taskset-authoring.d.ts.map +1 -1
  51. package/dist/types/packages/sdk/src/model-projects.d.ts +20 -0
  52. package/dist/types/packages/sdk/src/model-projects.d.ts.map +1 -1
  53. package/dist/types/packages/sdk/src/post-training.d.ts +8 -0
  54. package/dist/types/packages/sdk/src/post-training.d.ts.map +1 -1
  55. package/dist/types/packages/sdk/src/taskset-draft-client.d.ts +1 -0
  56. package/dist/types/packages/sdk/src/taskset-draft-client.d.ts.map +1 -1
  57. package/dist/types/packages/sdk/src/taskset-package-client.d.ts +12 -0
  58. package/dist/types/packages/sdk/src/taskset-package-client.d.ts.map +1 -1
  59. package/package.json +1 -1
  60. package/dist/chunk-B5XTGEBE.js.map +0 -1
  61. package/dist/chunk-HGXVOFCL.js.map +0 -1
  62. /package/dist/{chunk-OR3TMIJN.js.map → chunk-25L5IXHA.js.map} +0 -0
  63. /package/dist/{chunk-VN5V2E2S.js.map → chunk-6GQ3GIAP.js.map} +0 -0
  64. /package/dist/{chunk-ETX25FTB.js.map → chunk-6MFFKAU6.js.map} +0 -0
  65. /package/dist/{chunk-DF2QXVZ3.js.map → chunk-6Y67YHVH.js.map} +0 -0
  66. /package/dist/{chunk-K5LWSWV7.js.map → chunk-AUNNXJQE.js.map} +0 -0
  67. /package/dist/{chunk-LHX7ENKZ.js.map → chunk-BGNPKYBJ.js.map} +0 -0
  68. /package/dist/{chunk-I54WQBXL.js.map → chunk-BJ5MKLWH.js.map} +0 -0
  69. /package/dist/{chunk-24N6A6SF.js.map → chunk-BYNVSWIQ.js.map} +0 -0
  70. /package/dist/{chunk-53LLNDXF.js.map → chunk-DBKCSQVH.js.map} +0 -0
  71. /package/dist/{chunk-EFUT3XKW.js.map → chunk-F4GITADW.js.map} +0 -0
  72. /package/dist/{chunk-CMWZZZGW.js.map → chunk-FLNWE5ZA.js.map} +0 -0
  73. /package/dist/{chunk-VHGC44HA.js.map → chunk-GWGDWZVN.js.map} +0 -0
  74. /package/dist/{chunk-LR5CTOC5.js.map → chunk-HOOHJCE7.js.map} +0 -0
  75. /package/dist/{chunk-XON75UFN.js.map → chunk-KKL6OICH.js.map} +0 -0
  76. /package/dist/{chunk-QRS7Y3EM.js.map → chunk-MJELLVQP.js.map} +0 -0
  77. /package/dist/{chunk-U7XWIOSB.js.map → chunk-O54KGALH.js.map} +0 -0
  78. /package/dist/{chunk-BVMR5OFW.js.map → chunk-QFBSNSUL.js.map} +0 -0
  79. /package/dist/{chunk-ZHQK3MOM.js.map → chunk-RE426Q7Y.js.map} +0 -0
  80. /package/dist/{chunk-WMIKJGXW.js.map → chunk-T3MFWGMX.js.map} +0 -0
  81. /package/dist/{chunk-ZIFZFP5I.js.map → chunk-VZPNRPXL.js.map} +0 -0
  82. /package/dist/{chunk-RRKRA237.js.map → chunk-XACJ63U4.js.map} +0 -0
  83. /package/dist/{chunk-GAIDBPFY.js.map → chunk-ZFYI4P6C.js.map} +0 -0
package/dist/index.js CHANGED
@@ -66,7 +66,7 @@ import {
66
66
  hashCollectorEligibleBoundaries,
67
67
  summarizeCollectorCoverage,
68
68
  verifyConnectedRecordedExecution
69
- } from "./chunk-24N6A6SF.js";
69
+ } from "./chunk-BYNVSWIQ.js";
70
70
  import {
71
71
  AgentImportCommitRequestSchema,
72
72
  AgentImportFileSchema,
@@ -83,7 +83,7 @@ import {
83
83
  ConnectedStartingAssetsReceiptSchema,
84
84
  ConnectedStartingAssetsRequestSchema,
85
85
  verifyConnectedStartingAssetsReceipt
86
- } from "./chunk-EFUT3XKW.js";
86
+ } from "./chunk-F4GITADW.js";
87
87
  import {
88
88
  CandidateEvaluationControlSchema,
89
89
  CandidateEvaluationOptionSchema,
@@ -91,7 +91,7 @@ import {
91
91
  CandidateEvaluationPreparationSchema,
92
92
  CandidateEvaluationRequestSchema,
93
93
  createCandidateEvaluationClient
94
- } from "./chunk-ETX25FTB.js";
94
+ } from "./chunk-6MFFKAU6.js";
95
95
  import {
96
96
  ExperimentImprovementClient,
97
97
  HostedProfileCandidateCommandSchema,
@@ -99,7 +99,7 @@ import {
99
99
  HostedProfileCandidateReceiptSchema,
100
100
  verifyHostedProfileCandidateExport,
101
101
  verifyHostedProfileCandidateReceipt
102
- } from "./chunk-OR3TMIJN.js";
102
+ } from "./chunk-25L5IXHA.js";
103
103
  import {
104
104
  ExperimentEvaluationFireSchema,
105
105
  ExperimentEvaluationScheduleCommandSchema,
@@ -110,7 +110,7 @@ import {
110
110
  scheduledExperimentHash,
111
111
  sealExperimentEvaluationSchedule,
112
112
  verifyExperimentEvaluationSchedule
113
- } from "./chunk-K5LWSWV7.js";
113
+ } from "./chunk-AUNNXJQE.js";
114
114
  import {
115
115
  AdvancedRefinerEvaluationAccountingSchema,
116
116
  AdvancedRefinerEvaluationCommandSchema,
@@ -125,7 +125,7 @@ import {
125
125
  sealAdvancedRefinerEvaluationPin,
126
126
  sealAdvancedRefinerReviewReceipt,
127
127
  verifyAdvancedRefinerEvaluationPin
128
- } from "./chunk-VHGC44HA.js";
128
+ } from "./chunk-GWGDWZVN.js";
129
129
  import {
130
130
  ExperimentImprovementCommandSchema,
131
131
  ExperimentImprovementHumanOptionsSchema,
@@ -139,39 +139,39 @@ import {
139
139
  sealExperimentImprovementState,
140
140
  verifyExperimentImprovementHumanOptions,
141
141
  verifyExperimentImprovementState
142
- } from "./chunk-XON75UFN.js";
142
+ } from "./chunk-KKL6OICH.js";
143
143
  import "./chunk-3B5KSH3V.js";
144
144
  import {
145
145
  OpenPondExperimentsClient
146
- } from "./chunk-I54WQBXL.js";
147
- import "./chunk-DF2QXVZ3.js";
148
- import "./chunk-BVMR5OFW.js";
146
+ } from "./chunk-BJ5MKLWH.js";
147
+ import "./chunk-6Y67YHVH.js";
148
+ import "./chunk-QFBSNSUL.js";
149
149
  import "./chunk-GPQLBVQC.js";
150
- import "./chunk-CMWZZZGW.js";
151
- import "./chunk-B5XTGEBE.js";
152
- import "./chunk-LR5CTOC5.js";
150
+ import "./chunk-FLNWE5ZA.js";
151
+ import "./chunk-6KKM2XRR.js";
152
+ import "./chunk-HOOHJCE7.js";
153
153
  import "./chunk-Z252BNAZ.js";
154
154
  import "./chunk-WQFU635Q.js";
155
- import "./chunk-GAIDBPFY.js";
155
+ import "./chunk-ZFYI4P6C.js";
156
156
  import {
157
157
  ConnectedDatasetSourceRefSchema,
158
158
  serializeStructuredOutput,
159
159
  structuredOutputTools,
160
160
  structuredToolOutput,
161
161
  validateOutputBytes
162
- } from "./chunk-MO4HAJZG.js";
162
+ } from "./chunk-EJZ7HOIS.js";
163
163
  import "./chunk-TK3DXH7A.js";
164
- import "./chunk-RRKRA237.js";
165
- import "./chunk-ZHQK3MOM.js";
166
- import "./chunk-WMIKJGXW.js";
164
+ import "./chunk-XACJ63U4.js";
165
+ import "./chunk-RE426Q7Y.js";
166
+ import "./chunk-T3MFWGMX.js";
167
167
  import "./chunk-Q4TKI2MV.js";
168
168
  import "./chunk-H3367ISL.js";
169
- import "./chunk-53LLNDXF.js";
169
+ import "./chunk-DBKCSQVH.js";
170
170
  import "./chunk-O6FKHAWN.js";
171
- import "./chunk-QRS7Y3EM.js";
172
- import "./chunk-VN5V2E2S.js";
173
- import "./chunk-U7XWIOSB.js";
174
- import "./chunk-HGXVOFCL.js";
171
+ import "./chunk-MJELLVQP.js";
172
+ import "./chunk-6GQ3GIAP.js";
173
+ import "./chunk-O54KGALH.js";
174
+ import "./chunk-CAMLCKSF.js";
175
175
  import "./chunk-CL3IOOVL.js";
176
176
  import "./chunk-H3JZ3P5T.js";
177
177
  import "./chunk-YLJ4XMA6.js";
@@ -1792,13 +1792,17 @@ function requireToken(value) {
1792
1792
  throw new Error("OpenPond API key is required");
1793
1793
  return trimmed;
1794
1794
  }
1795
- function hostedHeaders(token, accept, requestId) {
1795
+ function hostedHeaders(token, accept, requestId, teamId) {
1796
1796
  const headers = new Headers();
1797
1797
  headers.set("Authorization", `Bearer ${requireToken(token)}`);
1798
1798
  headers.set("Content-Type", "application/json");
1799
1799
  headers.set("Accept", accept);
1800
1800
  headers.set("x-openpond-client", "openpond-code");
1801
- headers.set("x-openpond-request-id", requestId || randomUUID());
1801
+ const operationId = requestId || randomUUID();
1802
+ headers.set("x-openpond-request-id", operationId);
1803
+ headers.set("x-request-id", operationId);
1804
+ if (teamId)
1805
+ headers.set("x-openpond-team-id", teamId);
1802
1806
  return headers;
1803
1807
  }
1804
1808
  async function readError(response) {
@@ -1850,7 +1854,8 @@ async function listOpChatModels(options) {
1850
1854
  const requestUrl = `${apiBaseUrl}/models`;
1851
1855
  const response = await fetch(requestUrl, {
1852
1856
  method: "GET",
1853
- headers: hostedHeaders(options.token, "application/json"),
1857
+ redirect: "error",
1858
+ headers: hostedHeaders(options.token, "application/json", void 0, options.teamId),
1854
1859
  signal: options.signal
1855
1860
  });
1856
1861
  if (!response.ok) {
@@ -1863,7 +1868,8 @@ async function getOpChatModel(options) {
1863
1868
  const requestUrl = `${apiBaseUrl}/models/${encodeURIComponent(options.model)}`;
1864
1869
  const response = await fetch(requestUrl, {
1865
1870
  method: "GET",
1866
- headers: hostedHeaders(options.token, "application/json"),
1871
+ redirect: "error",
1872
+ headers: hostedHeaders(options.token, "application/json", void 0, options.teamId),
1867
1873
  signal: options.signal
1868
1874
  });
1869
1875
  if (!response.ok) {
@@ -1876,7 +1882,8 @@ async function listOpChatProviders(options) {
1876
1882
  const requestUrl = `${apiBaseUrl}/providers`;
1877
1883
  const response = await fetch(requestUrl, {
1878
1884
  method: "GET",
1879
- headers: hostedHeaders(options.token, "application/json"),
1885
+ redirect: "error",
1886
+ headers: hostedHeaders(options.token, "application/json", void 0, options.teamId),
1880
1887
  signal: options.signal
1881
1888
  });
1882
1889
  if (!response.ok) {
@@ -1889,7 +1896,8 @@ async function getOpChatProvider(options) {
1889
1896
  const requestUrl = `${apiBaseUrl}/providers/${encodeURIComponent(options.provider)}`;
1890
1897
  const response = await fetch(requestUrl, {
1891
1898
  method: "GET",
1892
- headers: hostedHeaders(options.token, "application/json"),
1899
+ redirect: "error",
1900
+ headers: hostedHeaders(options.token, "application/json", void 0, options.teamId),
1893
1901
  signal: options.signal
1894
1902
  });
1895
1903
  if (!response.ok) {
@@ -1902,7 +1910,8 @@ async function sendHostedChatTurn(options) {
1902
1910
  const requestUrl = `${apiBaseUrl}/chat/completions`;
1903
1911
  const response = await fetch(requestUrl, {
1904
1912
  method: "POST",
1905
- headers: hostedHeaders(options.token, "application/json", options.requestId),
1913
+ redirect: "error",
1914
+ headers: hostedHeaders(options.token, "application/json", options.requestId, options.teamId),
1906
1915
  body: JSON.stringify(buildHostedChatBody(options, false)),
1907
1916
  signal: options.signal
1908
1917
  });
@@ -1911,10 +1920,11 @@ async function sendHostedChatTurn(options) {
1911
1920
  }
1912
1921
  return await response.json();
1913
1922
  }
1914
- async function* parseOpenAISSE(stream, signal) {
1923
+ async function* parseOpenAISSE(stream, signal, observe) {
1915
1924
  const reader = stream.getReader();
1916
1925
  const decoder = new TextDecoder();
1917
1926
  let buffer = "";
1927
+ let sawDone = false;
1918
1928
  const readAbortError = () => signal?.reason instanceof Error ? signal.reason : new Error("hosted_chat_aborted");
1919
1929
  try {
1920
1930
  while (true) {
@@ -1923,22 +1933,38 @@ async function* parseOpenAISSE(stream, signal) {
1923
1933
  const result = await reader.read();
1924
1934
  if (result.done)
1925
1935
  break;
1936
+ observe?.({ type: "bytes", byteLength: result.value.byteLength });
1926
1937
  buffer += decoder.decode(result.value, { stream: true });
1927
1938
  const lines = buffer.split("\n");
1928
1939
  buffer = lines.pop() || "";
1929
1940
  for (const line of lines) {
1930
1941
  const trimmed = line.trim();
1942
+ if (trimmed.startsWith(":"))
1943
+ observe?.({ type: "comment" });
1931
1944
  if (!trimmed.startsWith("data:"))
1932
1945
  continue;
1933
1946
  const data = trimmed.slice(5).trim();
1934
1947
  if (!data)
1935
1948
  continue;
1936
- if (data === "[DONE]")
1949
+ if (data === "[DONE]") {
1950
+ sawDone = true;
1951
+ observe?.({ type: "done" });
1937
1952
  return;
1938
- yield JSON.parse(data);
1953
+ }
1954
+ const parsed = JSON.parse(data);
1955
+ observe?.({
1956
+ type: "data",
1957
+ errorFrame: Boolean(parsed && typeof parsed === "object" && "error" in parsed)
1958
+ });
1959
+ yield parsed;
1939
1960
  }
1940
1961
  }
1962
+ throw new Error("Hosted chat stream ended before [DONE].");
1941
1963
  } finally {
1964
+ if (!sawDone) {
1965
+ await reader.cancel().catch(() => {
1966
+ });
1967
+ }
1942
1968
  try {
1943
1969
  reader.releaseLock();
1944
1970
  } catch {
@@ -1948,16 +1974,34 @@ async function* parseOpenAISSE(stream, signal) {
1948
1974
  async function* streamHostedChatTurn(options) {
1949
1975
  const apiBaseUrl = normalizeApiBaseUrl(options.apiBaseUrl);
1950
1976
  const requestUrl = `${apiBaseUrl}/chat/completions`;
1977
+ const started = performance.now();
1978
+ const observe = (event) => {
1979
+ try {
1980
+ options.onStreamDiagnostic?.({ ...event, elapsedMs: Math.round(performance.now() - started) });
1981
+ } catch {
1982
+ }
1983
+ };
1984
+ observe({ type: "request" });
1951
1985
  const response = await fetch(requestUrl, {
1952
1986
  method: "POST",
1953
- headers: hostedHeaders(options.token, "text/event-stream", options.requestId),
1987
+ redirect: "error",
1988
+ headers: hostedHeaders(options.token, "text/event-stream", options.requestId, options.teamId),
1954
1989
  body: JSON.stringify(buildHostedChatBody(options, true)),
1955
1990
  signal: options.signal
1956
1991
  });
1992
+ const cacheControl = response.headers.get("cache-control")?.toLowerCase().split(",").map((value) => value.trim()) ?? [];
1993
+ observe({
1994
+ type: "headers",
1995
+ status: response.status,
1996
+ eventStream: response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() === "text/event-stream",
1997
+ noCache: cacheControl.includes("no-cache"),
1998
+ noTransform: cacheControl.includes("no-transform"),
1999
+ bufferingDisabled: response.headers.get("x-accel-buffering")?.toLowerCase() === "no"
2000
+ });
1957
2001
  if (!response.ok || !response.body) {
1958
2002
  throw new Error(`Hosted chat stream failed: ${response.status} ${await readError(response)}`);
1959
2003
  }
1960
- for await (const raw of parseOpenAISSE(response.body, options.signal)) {
2004
+ for await (const raw of parseOpenAISSE(response.body, options.signal, observe)) {
1961
2005
  const chunk = raw;
1962
2006
  if (chunk.error) {
1963
2007
  throw new Error(chunk.error.message || "Hosted chat stream error");