openpond-sdk 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-6T23L3LH.js → chunk-2DMYAJLS.js} +2 -2
- package/dist/{chunk-22RMONJA.js → chunk-CEZEVILU.js} +4 -4
- package/dist/chunk-CEZEVILU.js.map +7 -0
- package/dist/{chunk-FJ7IMEG5.js → chunk-IWT6JUZD.js} +2 -2
- package/dist/{chunk-JHKNPQD5.js → chunk-MEKWESBF.js} +2 -2
- package/dist/index.js +9 -7
- package/dist/index.js.map +2 -2
- package/dist/profile-actions.js +2 -2
- package/dist/project-actions.js +2 -2
- package/dist/types/packages/cloud/src/api/core.d.ts +2 -1
- package/dist/types/packages/cloud/src/api/core.d.ts.map +1 -1
- package/dist/workflows.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-22RMONJA.js.map +0 -7
- /package/dist/{chunk-6T23L3LH.js.map → chunk-2DMYAJLS.js.map} +0 -0
- /package/dist/{chunk-FJ7IMEG5.js.map → chunk-IWT6JUZD.js.map} +0 -0
- /package/dist/{chunk-JHKNPQD5.js.map → chunk-MEKWESBF.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
apiFetch,
|
|
3
3
|
readApiJson
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CEZEVILU.js";
|
|
5
5
|
|
|
6
6
|
// src/profile-actions.ts
|
|
7
7
|
var OpenPondProfileActionsClient = class {
|
|
@@ -69,4 +69,4 @@ function requiredValue(value, name) {
|
|
|
69
69
|
export {
|
|
70
70
|
OpenPondProfileActionsClient
|
|
71
71
|
};
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-2DMYAJLS.js.map
|
|
@@ -38,13 +38,13 @@ var OpenPondApiError = class extends Error {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
async function apiFetch(baseUrl, token, requestPath, options = {}) {
|
|
41
|
-
const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES,
|
|
41
|
+
const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, explicitBearerAuth = false, ...init } = options;
|
|
42
42
|
const requestUrl = `${baseUrl}${requestPath}`;
|
|
43
43
|
const headers = new Headers(init.headers);
|
|
44
44
|
headers.set("Content-Type", "application/json");
|
|
45
|
-
const apiKey =
|
|
45
|
+
const apiKey = !explicitBearerAuth ? process.env.OPENPOND_API_KEY : void 0;
|
|
46
46
|
const trimmedToken = token?.trim() || "";
|
|
47
|
-
const tokenIsApiKey = trimmedToken.startsWith("opk_");
|
|
47
|
+
const tokenIsApiKey = !explicitBearerAuth && trimmedToken.startsWith("opk_");
|
|
48
48
|
const effectiveApiKey = apiKey || (tokenIsApiKey ? trimmedToken : null);
|
|
49
49
|
if (effectiveApiKey && !headers.has("openpond-api-key"))
|
|
50
50
|
headers.set("openpond-api-key", effectiveApiKey);
|
|
@@ -152,4 +152,4 @@ export {
|
|
|
152
152
|
apiFetch,
|
|
153
153
|
readApiJson
|
|
154
154
|
};
|
|
155
|
-
//# sourceMappingURL=chunk-
|
|
155
|
+
//# sourceMappingURL=chunk-CEZEVILU.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../cloud/src/api/core.ts"],
|
|
4
|
+
"sourcesContent": ["const DEFAULT_API_TIMEOUT_MS = 30_000;\nconst DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;\nexport const LONG_STREAM_API_OPTIONS = { timeoutMs: 15 * 60 * 1000, maxResponseBytes: 64 * 1024 * 1024 } as const;\n\nexport type ApiFetchOptions = RequestInit & {\n /** Generic services always use their explicit bearer token, regardless of prefix. */\n explicitBearerAuth?: boolean;\n timeoutMs?: number;\n maxResponseBytes?: number;\n};\n\nexport class ApiTimeoutError extends Error {\n readonly code = \"OPENPOND_API_TIMEOUT\";\n\n constructor(readonly timeoutMs: number, readonly requestUrl: string) {\n super(`API request timed out after ${timeoutMs}ms: ${requestUrl}`);\n this.name = \"ApiTimeoutError\";\n }\n}\n\nexport class ApiResponseTooLargeError extends Error {\n readonly code = \"OPENPOND_API_RESPONSE_TOO_LARGE\";\n\n constructor(readonly maximumBytes: number, readonly requestUrl: string) {\n super(`API response exceeded ${maximumBytes} bytes: ${requestUrl}`);\n this.name = \"ApiResponseTooLargeError\";\n }\n}\n\nexport class OpenPondApiError extends Error {\n readonly code: string;\n\n constructor(\n readonly status: number,\n errorCode: string | null,\n label: string,\n readonly apiMessage: string | null = null,\n ) {\n const detail = apiMessage || errorCode;\n super(`${label} failed: ${status}${detail ? ` ${detail}` : \"\"}`);\n this.name = \"OpenPondApiError\";\n this.code = errorCode || \"OPENPOND_API_ERROR\";\n }\n}\n\nexport async function apiFetch(\n baseUrl: string,\n token: string | null,\n requestPath: string,\n options: ApiFetchOptions = {},\n): Promise<Response> {\n const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, explicitBearerAuth = false, ...init } = options;\n const requestUrl = `${baseUrl}${requestPath}`;\n const headers = new Headers(init.headers);\n headers.set(\"Content-Type\", \"application/json\");\n const apiKey = !explicitBearerAuth ? process.env.OPENPOND_API_KEY : undefined;\n const trimmedToken = token?.trim() || \"\";\n const tokenIsApiKey = !explicitBearerAuth && trimmedToken.startsWith(\"opk_\");\n const effectiveApiKey = apiKey || (tokenIsApiKey ? trimmedToken : null);\n if (effectiveApiKey && !headers.has(\"openpond-api-key\")) headers.set(\"openpond-api-key\", effectiveApiKey);\n if (token) {\n headers.set(\"Authorization\", tokenIsApiKey ? `ApiKey ${trimmedToken}` : `Bearer ${token}`);\n } else if (apiKey && !headers.has(\"Authorization\")) {\n headers.set(\"Authorization\", `ApiKey ${apiKey}`);\n }\n\n const timeoutController = new AbortController();\n const timeoutError = new ApiTimeoutError(timeoutMs, requestUrl);\n const timer = timeoutMs > 0\n ? setTimeout(() => timeoutController.abort(timeoutError), timeoutMs)\n : null;\n timer?.unref?.();\n const signal = composedSignal(init.signal, timeoutController.signal, timeoutMs);\n const cleanup = () => {\n if (timer) clearTimeout(timer);\n };\n\n try {\n const response = await fetch(requestUrl, { ...init, headers, signal });\n return boundedResponse(response, {\n cleanup,\n maximumBytes: maxResponseBytes,\n requestUrl,\n timeoutController,\n timeoutError,\n });\n } catch (error) {\n cleanup();\n if (timeoutController.signal.aborted) throw timeoutError;\n throw error;\n }\n}\n\nexport async function readApiJson<T>(response: Response, label: string): Promise<T> {\n let payload: T & { error?: unknown; message?: unknown };\n try {\n const text = await response.text();\n payload = (text ? JSON.parse(text) : {}) as T & { error?: unknown; message?: unknown };\n } catch (error) {\n if (error instanceof ApiTimeoutError || error instanceof ApiResponseTooLargeError) throw error;\n payload = {} as T & { error?: unknown; message?: unknown };\n }\n if (!response.ok) {\n const errorCode = typeof payload.error === \"string\" ? payload.error : null;\n const apiMessage =\n typeof payload.message === \"string\" ? payload.message : null;\n throw new OpenPondApiError(response.status, errorCode, label, apiMessage);\n }\n return payload as T;\n}\n\nfunction boundedResponse(\n response: Response,\n input: {\n cleanup: () => void;\n maximumBytes: number;\n requestUrl: string;\n timeoutController: AbortController;\n timeoutError: ApiTimeoutError;\n },\n): Response {\n if (!response.body) {\n input.cleanup();\n return response;\n }\n const contentLength = Number(response.headers.get(\"content-length\"));\n if (input.maximumBytes > 0 && Number.isFinite(contentLength) && contentLength > input.maximumBytes) {\n input.cleanup();\n void response.body.cancel();\n throw new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl);\n }\n\n const reader = response.body.getReader();\n let receivedBytes = 0;\n const body = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const result = await reader.read();\n if (result.done) {\n input.cleanup();\n controller.close();\n return;\n }\n receivedBytes += result.value.byteLength;\n if (input.maximumBytes > 0 && receivedBytes > input.maximumBytes) {\n input.cleanup();\n await reader.cancel();\n controller.error(new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl));\n return;\n }\n controller.enqueue(result.value);\n } catch (error) {\n input.cleanup();\n controller.error(input.timeoutController.signal.aborted ? input.timeoutError : error);\n }\n },\n async cancel(reason) {\n input.cleanup();\n await reader.cancel(reason);\n },\n });\n return new Response(body, {\n headers: response.headers,\n status: response.status,\n statusText: response.statusText,\n });\n}\n\nfunction composedSignal(\n callerSignal: AbortSignal | null | undefined,\n timeoutSignal: AbortSignal,\n timeoutMs: number,\n): AbortSignal | undefined {\n if (timeoutMs <= 0) return callerSignal ?? undefined;\n return callerSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : timeoutSignal;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,IAAM,yBAAyB;AAC/B,IAAM,6BAA6B,IAAI,OAAO;AACvC,IAAM,0BAA0B,EAAE,WAAW,KAAK,KAAK,KAAM,kBAAkB,KAAK,OAAO,KAAI;AAShG,IAAO,kBAAP,cAA+B,MAAK;EAGnB;EAA4B;EAFxC,OAAO;EAEhB,YAAqB,WAA4B,YAAkB;AACjE,UAAM,+BAA+B,SAAS,OAAO,UAAU,EAAE;AAD9C,SAAA,YAAA;AAA4B,SAAA,aAAA;AAE/C,SAAK,OAAO;EACd;;AAGI,IAAO,2BAAP,cAAwC,MAAK;EAG5B;EAA+B;EAF3C,OAAO;EAEhB,YAAqB,cAA+B,YAAkB;AACpE,UAAM,yBAAyB,YAAY,WAAW,UAAU,EAAE;AAD/C,SAAA,eAAA;AAA+B,SAAA,aAAA;AAElD,SAAK,OAAO;EACd;;AAGI,IAAO,mBAAP,cAAgC,MAAK;EAI9B;EAGA;EANF;EAET,YACW,QACT,WACA,OACS,aAA4B,MAAI;AAEzC,UAAM,SAAS,cAAc;AAC7B,UAAM,GAAG,KAAK,YAAY,MAAM,GAAG,SAAS,IAAI,MAAM,KAAK,EAAE,EAAE;AANtD,SAAA,SAAA;A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qBAAW,MAAM,IAAI,yBAAyB,MAAM,cAAc,MAAM,UAAU,CAAC;AACnF;QACF;AACA,mBAAW,QAAQ,OAAO,KAAK;MACjC,SAAS,OAAO;AACd,cAAM,QAAO;AACb,mBAAW,MAAM,MAAM,kBAAkB,OAAO,UAAU,MAAM,eAAe,KAAK;MACtF;IACF;IACA,MAAM,OAAO,QAAM;AACjB,YAAM,QAAO;AACb,YAAM,OAAO,OAAO,MAAM;IAC5B;GACD;AACD,SAAO,IAAI,SAAS,MAAM;IACxB,SAAS,SAAS;IAClB,QAAQ,SAAS;IACjB,YAAY,SAAS;GACtB;AACH;AAEA,SAAS,eACP,cACA,eACA,WAAiB;AAEjB,MAAI,aAAa;AAAG,WAAO,gBAAgB;AAC3C,SAAO,eAAe,YAAY,IAAI,CAAC,cAAc,aAAa,CAAC,IAAI;AACzE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
apiFetch,
|
|
3
3
|
readApiJson
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CEZEVILU.js";
|
|
5
5
|
|
|
6
6
|
// src/project-actions.ts
|
|
7
7
|
import { promises as fs } from "node:fs";
|
|
@@ -80,4 +80,4 @@ function projectActionPath(projectId, suffix, teamId) {
|
|
|
80
80
|
export {
|
|
81
81
|
OpenPondProjectActionsClient
|
|
82
82
|
};
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
83
|
+
//# sourceMappingURL=chunk-IWT6JUZD.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
apiFetch,
|
|
3
3
|
readApiJson
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CEZEVILU.js";
|
|
5
5
|
|
|
6
6
|
// src/workflows.ts
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
@@ -77,4 +77,4 @@ function requiredId(value, label) {
|
|
|
77
77
|
export {
|
|
78
78
|
OpenPondWorkflowsClient
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-MEKWESBF.js.map
|
package/dist/index.js
CHANGED
|
@@ -5,18 +5,18 @@ import {
|
|
|
5
5
|
import "./chunk-5FBPNWT4.js";
|
|
6
6
|
import {
|
|
7
7
|
OpenPondProjectActionsClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-IWT6JUZD.js";
|
|
9
9
|
import {
|
|
10
10
|
OpenPondProfileActionsClient
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2DMYAJLS.js";
|
|
12
12
|
import {
|
|
13
13
|
OpenPondWorkflowsClient
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-MEKWESBF.js";
|
|
15
15
|
import {
|
|
16
16
|
OpenPondApiError,
|
|
17
17
|
apiFetch,
|
|
18
18
|
readApiJson
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CEZEVILU.js";
|
|
20
20
|
import "./chunk-LXXQVGQY.js";
|
|
21
21
|
import {
|
|
22
22
|
DEFAULT_REFINER_REVIEW_PROFILE,
|
|
@@ -943,11 +943,11 @@ var OpenPondSandboxInstanceClient = class {
|
|
|
943
943
|
});
|
|
944
944
|
}
|
|
945
945
|
async request(path, init = {}) {
|
|
946
|
-
const response = await apiFetch(this.sandboxApiUrl, this.apiKey, path, this.customEndpoint ? { ...init,
|
|
946
|
+
const response = await apiFetch(this.sandboxApiUrl, this.apiKey, path, this.customEndpoint ? { ...init, explicitBearerAuth: true, redirect: "error" } : init);
|
|
947
947
|
return readApiJson(response, "Sandbox request");
|
|
948
948
|
}
|
|
949
949
|
async requestApiRoot(path, init = {}) {
|
|
950
|
-
const response = await apiFetch(this.apiRootUrl, this.apiKey, path, this.customEndpoint ? { ...init,
|
|
950
|
+
const response = await apiFetch(this.apiRootUrl, this.apiKey, path, this.customEndpoint ? { ...init, explicitBearerAuth: true, redirect: "error" } : init);
|
|
951
951
|
return readApiJson(response, "OpenPond API request");
|
|
952
952
|
}
|
|
953
953
|
};
|
|
@@ -2297,7 +2297,9 @@ function systemPrompt(sandboxId, hasInputs) {
|
|
|
2297
2297
|
"You are OpenPond Work, a careful coding agent operating in an isolated Linux sandbox.",
|
|
2298
2298
|
`The active sandbox is ${sandboxId}.`,
|
|
2299
2299
|
...hasInputs ? [
|
|
2300
|
-
`
|
|
2300
|
+
`The authoritative saved files for this turn are staged under /workspace/${WORK_INPUT_DIRECTORY}; their manifest is /workspace/${WORK_INPUT_MANIFEST}.`,
|
|
2301
|
+
"Before revising a previous output, read its staged file and manifest. Copy the staged input into the output directory before editing it; previous output paths may not exist in this sandbox.",
|
|
2302
|
+
"Preserve the actual file bytes. Never reconstruct a saved file from the conversation or claim to have preserved it without reading the staged input."
|
|
2301
2303
|
] : [],
|
|
2302
2304
|
"Use run_command to inspect the workspace, edit files, and validate your work.",
|
|
2303
2305
|
`Place completed user-facing files in ${WORK_OUTPUT_DIRECTORY}. The runtime collects new and revised files there automatically when the turn completes.`,
|