openpond-sdk 0.0.3 → 0.0.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.
- package/README.md +98 -8
- package/dist/actions-local.js +15184 -0
- package/dist/actions-local.js.map +7 -0
- package/dist/actions.js +14615 -0
- package/dist/actions.js.map +7 -0
- package/dist/index.js +863 -1031
- package/dist/index.js.map +2 -2
- package/dist/types/packages/actions/src/build.d.ts +9 -0
- package/dist/types/packages/actions/src/build.d.ts.map +1 -0
- package/dist/types/packages/actions/src/catalog.d.ts +4 -0
- package/dist/types/packages/actions/src/catalog.d.ts.map +1 -0
- package/dist/types/packages/actions/src/configuration.d.ts +20 -0
- package/dist/types/packages/actions/src/configuration.d.ts.map +1 -0
- package/dist/types/packages/actions/src/define-action.d.ts +4 -0
- package/dist/types/packages/actions/src/define-action.d.ts.map +1 -0
- package/dist/types/packages/actions/src/discovery.d.ts +9 -0
- package/dist/types/packages/actions/src/discovery.d.ts.map +1 -0
- package/dist/types/packages/actions/src/hash.d.ts +3 -0
- package/dist/types/packages/actions/src/hash.d.ts.map +1 -0
- package/dist/types/packages/actions/src/index.d.ts +4 -0
- package/dist/types/packages/actions/src/index.d.ts.map +1 -0
- package/dist/types/packages/actions/src/local.d.ts +6 -0
- package/dist/types/packages/actions/src/local.d.ts.map +1 -0
- package/dist/types/packages/actions/src/schema.d.ts +4 -0
- package/dist/types/packages/actions/src/schema.d.ts.map +1 -0
- package/dist/types/packages/actions/src/setup.d.ts +4 -0
- package/dist/types/packages/actions/src/setup.d.ts.map +1 -0
- package/dist/types/packages/actions/src/types.d.ts +161 -0
- package/dist/types/packages/actions/src/types.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/actions-local.d.ts +3 -0
- package/dist/types/packages/sdk/src/actions-local.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/actions.d.ts +3 -0
- package/dist/types/packages/sdk/src/actions.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/index.d.ts +7 -7
- package/dist/types/packages/sdk/src/index.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/work.d.ts +52 -2
- package/dist/types/packages/sdk/src/work.d.ts.map +1 -1
- package/package.json +20 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `openpond-sdk`
|
|
2
2
|
|
|
3
|
-
The OpenPond SDK is the server-side TypeScript client for running agentic work in OpenPond sandboxes. It gives Node.js applications, Next.js route handlers, workers, and backend services a small API for creating sandboxes, executing commands, managing files and runtimes, and running a model/tool loop in
|
|
3
|
+
The OpenPond SDK is the server-side TypeScript client for running agentic work in OpenPond sandboxes. It gives Node.js applications, Next.js route handlers, workers, and backend services a small API for creating sandboxes, executing commands, managing files and runtimes, and running a model/tool loop in an isolated workspace.
|
|
4
4
|
|
|
5
5
|
OpenPond is an open-source agent orchestration system for doing durable work with any model, provider, or subscription. The desktop app, CLI/TUI, and this SDK live in the same repository and share the sandbox client implementation. Desktop builds use the workspace source directly; installing this package from npm is only for external applications.
|
|
6
6
|
|
|
@@ -27,13 +27,21 @@ const openpond = createOpenPondClient({
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
export async function POST(request: Request) {
|
|
30
|
-
const { prompt
|
|
31
|
-
const result = await openpond.work.run({
|
|
30
|
+
const { prompt } = await request.json();
|
|
31
|
+
const result = await openpond.work.run({
|
|
32
|
+
prompt,
|
|
33
|
+
cleanup: "delete",
|
|
34
|
+
persistOutput: async ({ output, download }) => {
|
|
35
|
+
const response = await download();
|
|
36
|
+
const bytes = Buffer.from(response.file.contentsBase64, "base64");
|
|
37
|
+
await durableOutputStore.put({ output, bytes });
|
|
38
|
+
},
|
|
39
|
+
});
|
|
32
40
|
return Response.json(result);
|
|
33
41
|
}
|
|
34
42
|
```
|
|
35
43
|
|
|
36
|
-
`work.run` creates a sandbox when `sandboxId` is omitted.
|
|
44
|
+
`work.run` creates a sandbox when `sandboxId` is omitted. Use `onEvent` to stream sandbox, model, command, persistence, and cleanup progress to a client. Keep API keys and the persistence callback in server code.
|
|
37
45
|
|
|
38
46
|
Completed files written under `/workspace/outputs` are collected automatically. The model does not need to publish or register them. Each detected file is emitted as an `output` event and returned in `result.outputs`:
|
|
39
47
|
|
|
@@ -55,7 +63,7 @@ for (const output of result.outputs) {
|
|
|
55
63
|
}
|
|
56
64
|
```
|
|
57
65
|
|
|
58
|
-
Output descriptors include the sandbox path, filename, MIME type, size, modification time, and preview hints. `downloadOutput` remains
|
|
66
|
+
Output descriptors include the sandbox path, filename, MIME type, size, modification time, and preview hints. `downloadOutput` remains available when the sandbox is kept. For ephemeral Work, use the lazy `download` function inside `persistOutput`; it verifies that the complete file arrived before deletion can begin.
|
|
59
67
|
|
|
60
68
|
If sandbox execution is unavailable, the API fails with the stable `sandbox_runner_unavailable` error instead of returning a successful command result.
|
|
61
69
|
|
|
@@ -88,15 +96,97 @@ console.log(result.command.output);
|
|
|
88
96
|
|
|
89
97
|
The package also exports `createOpenPondSandboxClient`, all public sandbox input and response types, and the OpChat helpers used by the Work loop.
|
|
90
98
|
|
|
91
|
-
##
|
|
99
|
+
## Project Actions
|
|
92
100
|
|
|
93
|
-
Work
|
|
101
|
+
Project Actions expose typed business functions from a normal Git Project to local OpenPond Work. The website and action wrapper can import the same neutral domain module, so the harness does not duplicate application logic.
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
// openpond/actions/analytics.ts
|
|
105
|
+
import { defineAction } from "openpond-sdk/actions";
|
|
106
|
+
import { z } from "zod";
|
|
107
|
+
|
|
108
|
+
import { getAnalyticsSummary } from "../../packages/domain/analytics.js";
|
|
109
|
+
|
|
110
|
+
export const getAnalytics = defineAction("analytics.get_summary", {
|
|
111
|
+
description: "Get the current operating summary.",
|
|
112
|
+
input: z.object({ businessId: z.string() }),
|
|
113
|
+
output: z.object({ activeMoves: z.number(), bookedRevenueUsd: z.number() }),
|
|
114
|
+
run(context, input) {
|
|
115
|
+
context.trace("analytics.loaded", { businessId: input.businessId });
|
|
116
|
+
return getAnalyticsSummary(input.businessId);
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The local-only runner does not require an OpenPond API key:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { createLocalActionRunner } from "openpond-sdk/actions/local";
|
|
125
|
+
|
|
126
|
+
const runner = createLocalActionRunner({ projectRoot: process.cwd() });
|
|
127
|
+
const result = await runner.run({
|
|
128
|
+
actionId: "analytics.get_summary",
|
|
129
|
+
input: { businessId: "relocation" },
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The default source directory is `openpond/actions`; generated files live in `.openpond/actions`. Override either path and map explicit runtime setup with `openpond/project-actions.json`:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"sourceDirectory": "src/actions",
|
|
138
|
+
"outputDirectory": ".openpond/project-actions",
|
|
139
|
+
"environment": {
|
|
140
|
+
"apiToken": "CUSTOMER_API_TOKEN"
|
|
141
|
+
},
|
|
142
|
+
"connections": {
|
|
143
|
+
"analytics-db": {
|
|
144
|
+
"values": { "provider": "postgres" },
|
|
145
|
+
"environment": { "url": "CUSTOMER_DATABASE_URL" }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Only declared values are forwarded into the child process. Use `context.env(name)` and `context.connection(name)` inside an action. Output files must be written inside `context.outputDirectory` and registered with `context.output(...)`.
|
|
152
|
+
|
|
153
|
+
## Lifecycle, persistence, and cleanup
|
|
154
|
+
|
|
155
|
+
The generic SDK defaults to `cleanup: "keep"` for backwards compatibility. Applications can choose one of three explicit terminal policies:
|
|
156
|
+
|
|
157
|
+
- `keep` leaves the sandbox running and makes the caller responsible for cleanup.
|
|
158
|
+
- `stop` releases active compute while retaining the sandbox for deliberate resume.
|
|
159
|
+
- `delete` removes ephemeral compute after output persistence succeeds.
|
|
160
|
+
|
|
161
|
+
Deleting a turn that produced outputs requires an awaited `persistOutput` callback. If an application intentionally does not need the files, it must say so with `discardOutputs: true`. A persistence failure stops the sandbox instead of deleting recoverable output state. `result.lifecycle` and `persistence`/`cleanup` events expose the ordering and final observed state.
|
|
162
|
+
|
|
163
|
+
For a follow-up turn on fresh compute, stage selected durable outputs as structured inputs:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
await openpond.work.run({
|
|
167
|
+
prompt: "Revise the report",
|
|
168
|
+
cleanup: "delete",
|
|
169
|
+
inputs: [{
|
|
170
|
+
id: savedOutput.id,
|
|
171
|
+
name: savedOutput.name,
|
|
172
|
+
contentsBase64: savedOutput.contentsBase64,
|
|
173
|
+
mimeType: savedOutput.mimeType,
|
|
174
|
+
checksumSha256: savedOutput.sha256,
|
|
175
|
+
revision: savedOutput.revision,
|
|
176
|
+
}],
|
|
177
|
+
persistOutput: saveOutput,
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Inputs are placed under `/workspace/inputs/previous-outputs/` with a structured manifest at `/workspace/inputs/.openpond-context.json`. Arbitrary scratch files are not retained by ephemeral Work.
|
|
182
|
+
|
|
183
|
+
You can still delete a caller-managed sandbox directly:
|
|
94
184
|
|
|
95
185
|
```ts
|
|
96
186
|
await openpond.work.deleteSandbox(sandboxId);
|
|
97
187
|
```
|
|
98
188
|
|
|
99
|
-
Use conservative budgets and application-level retention. API keys, provider credentials, and bypass secrets must remain in server-side configuration.
|
|
189
|
+
The sandbox's 15-minute idle timeout is crash protection, not the normal successful-turn cleanup path. Use conservative budgets and application-level retention. API keys, provider credentials, and bypass secrets must remain in server-side configuration.
|
|
100
190
|
|
|
101
191
|
## Development
|
|
102
192
|
|