openpond-sdk 0.0.1 → 0.0.2
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/README.md +3 -1
- package/dist/index.js +20 -48
- package/dist/index.js.map +2 -2
- package/dist/types/packages/cloud/src/api/core.d.ts +6 -0
- package/dist/types/packages/cloud/src/api/core.d.ts.map +1 -1
- package/dist/types/packages/cloud/src/sandbox/smoke.d.ts.map +1 -1
- package/dist/types/packages/cloud/src/sandbox/types/client.d.ts +1 -2
- package/dist/types/packages/cloud/src/sandbox/types/client.d.ts.map +1 -1
- package/dist/types/packages/cloud/src/sandbox/types/core.d.ts +0 -1
- package/dist/types/packages/cloud/src/sandbox/types/core.d.ts.map +1 -1
- package/dist/types/packages/cloud/src/sandbox/types/record.d.ts +1 -2
- package/dist/types/packages/cloud/src/sandbox/types/record.d.ts.map +1 -1
- package/dist/types/packages/cloud/src/sandbox/types/runtime-profiles.d.ts +1 -1
- package/dist/types/packages/cloud/src/sandbox/types/runtime-profiles.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/index.d.ts +2 -1
- package/dist/types/packages/sdk/src/index.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/work.d.ts +0 -8
- package/dist/types/packages/sdk/src/work.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,9 @@ export async function POST(request: Request) {
|
|
|
35
35
|
|
|
36
36
|
`work.run` creates a sandbox when `sandboxId` is omitted. Pass the returned ID into the next turn to continue in the same filesystem. Use `onEvent` to stream sandbox, model, and command progress to a client.
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
If sandbox execution is unavailable, the API fails with the stable `sandbox_runner_unavailable` error instead of returning a successful command result.
|
|
39
|
+
|
|
40
|
+
API failures are exposed as `OpenPondApiError`, with `status` and stable `code` fields for server-side handling. `work.run` propagates these failures instead of asking the model to interpret infrastructure errors.
|
|
39
41
|
|
|
40
42
|
## Raw sandbox API
|
|
41
43
|
|
package/dist/index.js
CHANGED
|
@@ -252,12 +252,6 @@ async function runSandboxSmoke(client, options = {}) {
|
|
|
252
252
|
)
|
|
253
253
|
);
|
|
254
254
|
sandboxId = sandbox.id;
|
|
255
|
-
const expectedRuntimeDriver = options.expectedRuntimeDriver ?? "remote-firecracker";
|
|
256
|
-
if (sandbox.runtimeDriver !== expectedRuntimeDriver) {
|
|
257
|
-
throw new Error(
|
|
258
|
-
`expected ${expectedRuntimeDriver}, got ${sandbox.runtimeDriver}`
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
255
|
const expectedMppMode = options.expectedMppMode;
|
|
262
256
|
if (expectedMppMode && sandbox.reservation.mpp?.mode !== expectedMppMode) {
|
|
263
257
|
throw new Error(
|
|
@@ -608,6 +602,19 @@ var ApiResponseTooLargeError = class extends Error {
|
|
|
608
602
|
requestUrl;
|
|
609
603
|
code = "OPENPOND_API_RESPONSE_TOO_LARGE";
|
|
610
604
|
};
|
|
605
|
+
var OpenPondApiError = class extends Error {
|
|
606
|
+
constructor(status, errorCode, label, apiMessage = null) {
|
|
607
|
+
const detail = apiMessage || errorCode;
|
|
608
|
+
super(`${label} failed: ${status}${detail ? ` ${detail}` : ""}`);
|
|
609
|
+
this.status = status;
|
|
610
|
+
this.apiMessage = apiMessage;
|
|
611
|
+
this.name = "OpenPondApiError";
|
|
612
|
+
this.code = errorCode || "OPENPOND_API_ERROR";
|
|
613
|
+
}
|
|
614
|
+
status;
|
|
615
|
+
apiMessage;
|
|
616
|
+
code;
|
|
617
|
+
};
|
|
611
618
|
async function apiFetch(baseUrl, token, requestPath, options = {}) {
|
|
612
619
|
const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;
|
|
613
620
|
const requestUrl = `${baseUrl}${requestPath}`;
|
|
@@ -656,8 +663,9 @@ async function readApiJson(response, label) {
|
|
|
656
663
|
payload = {};
|
|
657
664
|
}
|
|
658
665
|
if (!response.ok) {
|
|
659
|
-
const
|
|
660
|
-
|
|
666
|
+
const errorCode = typeof payload.error === "string" ? payload.error : null;
|
|
667
|
+
const apiMessage = typeof payload.message === "string" ? payload.message : null;
|
|
668
|
+
throw new OpenPondApiError(response.status, errorCode, label, apiMessage);
|
|
661
669
|
}
|
|
662
670
|
return payload;
|
|
663
671
|
}
|
|
@@ -2313,17 +2321,6 @@ async function* streamHostedChatTurn(options) {
|
|
|
2313
2321
|
var DEFAULT_MODEL = "openpond-chat";
|
|
2314
2322
|
var DEFAULT_MAX_STEPS = 24;
|
|
2315
2323
|
var MAX_TOOL_OUTPUT_CHARS = 4e4;
|
|
2316
|
-
var OpenPondNonExecutingSandboxError = class extends Error {
|
|
2317
|
-
constructor(sandboxId) {
|
|
2318
|
-
super(
|
|
2319
|
-
`Sandbox ${sandboxId} accepted a command without executing it. A real remote runner is required for OpenPond Work.`
|
|
2320
|
-
);
|
|
2321
|
-
this.sandboxId = sandboxId;
|
|
2322
|
-
this.name = "OpenPondNonExecutingSandboxError";
|
|
2323
|
-
}
|
|
2324
|
-
sandboxId;
|
|
2325
|
-
code = "OPENPOND_NON_EXECUTING_SANDBOX";
|
|
2326
|
-
};
|
|
2327
2324
|
var OpenPondWorkClient = class {
|
|
2328
2325
|
#apiKey;
|
|
2329
2326
|
#apiBaseUrl;
|
|
@@ -2342,19 +2339,10 @@ var OpenPondWorkClient = class {
|
|
|
2342
2339
|
const emit = async (event) => input.onEvent?.(event);
|
|
2343
2340
|
await emit({ type: "status", message: "Preparing sandbox" });
|
|
2344
2341
|
const sandbox = await this.#resolveSandbox(input);
|
|
2345
|
-
if (sandbox.runtimeDriver === "simulated-firecracker" && !input.allowSimulated) {
|
|
2346
|
-
if (!input.sandboxId) {
|
|
2347
|
-
await this.#sandboxes.delete(sandbox.id, { async: true }).catch(() => void 0);
|
|
2348
|
-
}
|
|
2349
|
-
throw new Error(
|
|
2350
|
-
"OpenPond Work requires a remote-firecracker sandbox, but this environment returned the non-executing simulated-firecracker driver."
|
|
2351
|
-
);
|
|
2352
|
-
}
|
|
2353
2342
|
await emit({
|
|
2354
2343
|
type: "sandbox",
|
|
2355
2344
|
sandboxId: sandbox.id,
|
|
2356
|
-
state: sandbox.state
|
|
2357
|
-
runtimeDriver: sandbox.runtimeDriver
|
|
2345
|
+
state: sandbox.state
|
|
2358
2346
|
});
|
|
2359
2347
|
const messages = [
|
|
2360
2348
|
{ role: "system", content: systemPrompt(sandbox.id) },
|
|
@@ -2484,18 +2472,6 @@ var OpenPondWorkClient = class {
|
|
|
2484
2472
|
timeoutSeconds: boundedInteger(timeoutSeconds, 1, 900, 180)
|
|
2485
2473
|
});
|
|
2486
2474
|
const output = truncate(response.command.output, MAX_TOOL_OUTPUT_CHARS);
|
|
2487
|
-
if (isNonExecutingSandboxOutput(output)) {
|
|
2488
|
-
await emit({
|
|
2489
|
-
type: "tool",
|
|
2490
|
-
toolCallId,
|
|
2491
|
-
command,
|
|
2492
|
-
status: "failed",
|
|
2493
|
-
output: "Staging accepted the command but did not execute it.",
|
|
2494
|
-
exitCode: response.command.exitCode
|
|
2495
|
-
});
|
|
2496
|
-
await this.#sandboxes.delete(sandboxId, { async: true }).catch(() => void 0);
|
|
2497
|
-
throw new OpenPondNonExecutingSandboxError(sandboxId);
|
|
2498
|
-
}
|
|
2499
2475
|
const status = response.command.status === "succeeded" ? "succeeded" : "failed";
|
|
2500
2476
|
await emit({
|
|
2501
2477
|
type: "tool",
|
|
@@ -2511,7 +2487,7 @@ var OpenPondWorkClient = class {
|
|
|
2511
2487
|
output
|
|
2512
2488
|
});
|
|
2513
2489
|
} catch (error) {
|
|
2514
|
-
if (error instanceof
|
|
2490
|
+
if (error instanceof OpenPondApiError) throw error;
|
|
2515
2491
|
const output = errorMessage(error);
|
|
2516
2492
|
await emit({ type: "tool", toolCallId, command, status: "failed", output });
|
|
2517
2493
|
return toolMessage(toolCallId, { status: "failed", error: output });
|
|
@@ -2560,10 +2536,6 @@ function truncate(value, maximum) {
|
|
|
2560
2536
|
function errorMessage(error) {
|
|
2561
2537
|
return error instanceof Error ? error.message : String(error);
|
|
2562
2538
|
}
|
|
2563
|
-
function isNonExecutingSandboxOutput(output) {
|
|
2564
|
-
const normalized = output.toLowerCase();
|
|
2565
|
-
return normalized.includes("command accepted by simulated-firecracker driver") || normalized.includes("no host command was executed");
|
|
2566
|
-
}
|
|
2567
2539
|
function sleep2(milliseconds, signal) {
|
|
2568
2540
|
return new Promise((resolve, reject) => {
|
|
2569
2541
|
if (signal?.aborted) {
|
|
@@ -2585,7 +2557,7 @@ function sleep2(milliseconds, signal) {
|
|
|
2585
2557
|
|
|
2586
2558
|
// ../cloud/src/sandbox/types/runtime-profiles.ts
|
|
2587
2559
|
var SANDBOX_RUNTIME_PROFILE_IDS = [
|
|
2588
|
-
"openpond-generic-
|
|
2560
|
+
"openpond-generic-v1",
|
|
2589
2561
|
"openpond-work-v1",
|
|
2590
2562
|
"openpond-coding-core-v1",
|
|
2591
2563
|
"openpond-agent-harness-v1"
|
|
@@ -2616,8 +2588,8 @@ function createOpenPondClient(options) {
|
|
|
2616
2588
|
return new OpenPondClient(options);
|
|
2617
2589
|
}
|
|
2618
2590
|
export {
|
|
2591
|
+
OpenPondApiError,
|
|
2619
2592
|
OpenPondClient,
|
|
2620
|
-
OpenPondNonExecutingSandboxError,
|
|
2621
2593
|
OpenPondSandboxClient,
|
|
2622
2594
|
OpenPondWorkClient,
|
|
2623
2595
|
SANDBOX_RUNTIME_PROFILE_IDS,
|