@computesdk/promigence 0.0.0-stage → 1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 computesdk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,154 @@
1
- # Temporary Holding Version
1
+ # @computesdk/promigence
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Promigence provider for ComputeSDK - production-grade sandboxes for AI agents, with filesystem and streaming output.
4
+
5
+ [Promigence](https://www.promigence.ai) runs AI agents and their code in sandboxes, each forked from a snapshot and run under a spend cap. A snapshot you build with a test command is stored only once that test passes. With this package, code written against `computesdk` runs on Promigence sandboxes.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @computesdk/promigence
11
+ ```
12
+
13
+ It needs Node.js 20 or later.
14
+
15
+ ## Setup
16
+
17
+ Sign up with the Promigence CLI. It stores an API key on this machine, and the provider uses that key whenever none is passed or set:
18
+
19
+ ```bash
20
+ npm install -g promigence
21
+ promigence signup # or `promigence login` for an account you already have
22
+ ```
23
+
24
+ On a server or in CI, set the key in the environment instead:
25
+
26
+ ```bash
27
+ export PROMIGENCE_API_KEY=prom_api_...
28
+ ```
29
+
30
+ | Environment variable | Meaning |
31
+ |---|---|
32
+ | `PROMIGENCE_API_KEY` | Your API key, when `apiKey` is not passed |
33
+ | `PROMIGENCE_SPEND_CAP` | Optional: the most one sandbox may spend, in US dollars, when `spendCap` is not passed. Unset, your organization's default cap applies |
34
+ | `PROMIGENCE_API_URL` | Optional: the API to use, when `apiUrl` is not passed |
35
+
36
+ ## Quick Start
37
+
38
+ ```typescript
39
+ import { compute } from 'computesdk';
40
+ import { promigence } from '@computesdk/promigence';
41
+
42
+ compute.setConfig({
43
+ provider: promigence({ apiKey: process.env.PROMIGENCE_API_KEY }),
44
+ });
45
+
46
+ const sandbox = await compute.instances.create();
47
+
48
+ const result = await sandbox.runCommand(`python3 - <<'PY'
49
+ print("Hello from Promigence")
50
+ PY`);
51
+ console.log(result.stdout);
52
+
53
+ await sandbox.filesystem.writeFile('/tmp/hello.txt', 'hello');
54
+ console.log(await sandbox.filesystem.readFile('/tmp/hello.txt'));
55
+
56
+ await sandbox.destroy();
57
+ ```
58
+
59
+ You can also call the provider directly:
60
+
61
+ ```typescript
62
+ import { promigence } from '@computesdk/promigence';
63
+
64
+ const provider = promigence({}); // PROMIGENCE_API_KEY, or the key the CLI stored
65
+ const sandbox = await provider.instances.create({ templateId: 'my-app' }); // a snapshot you built, by its alias
66
+ ```
67
+
68
+ ## Configuration
69
+
70
+ ### Configuration Options
71
+
72
+ ```typescript
73
+ interface PromigenceConfig {
74
+ /** Promigence API key - if not provided, uses PROMIGENCE_API_KEY, then the key `promigence login` stored */
75
+ apiKey?: string;
76
+ /** Promigence API URL - if not provided, uses PROMIGENCE_API_URL, then the default Promigence API */
77
+ apiUrl?: string;
78
+ /** The most one sandbox may spend, in US dollars - if not provided, uses PROMIGENCE_SPEND_CAP, then your organization's default cap */
79
+ spendCap?: number;
80
+ /** The snapshot create() starts from when it names none (id, alias or alias@commit); default: the built-in base snapshot */
81
+ snapshot?: string;
82
+ /** Sandbox lifetime in milliseconds when create() sets none; also the bound on a command that sets none */
83
+ timeout?: number;
84
+ /** Size of a sandbox created from an image: 'xsmall', 'small', 'medium', 'large', 'xlarge' or '2xlarge' */
85
+ tier?: string;
86
+ /** 'start' (the default) or 'compute' (long, memory-heavy jobs on the larger tiers) */
87
+ optimizeFor?: 'start' | 'compute';
88
+ /** A client from @promigence/sdk to use instead of one built from apiKey and apiUrl */
89
+ client?: PromigenceClient;
90
+ }
91
+ ```
92
+
93
+ The provider checks this config before it sends anything. A missing key, or a malformed URL, spend cap or timeout, is an error that says what to fix.
94
+
95
+ ### `create()` options
96
+
97
+ | Option | What it does |
98
+ |---|---|
99
+ | `templateId` / `snapshotId` | The snapshot to start from: its id, its alias, `alias@commit`, or the name of a Promigence template (`promigence templates` lists them) |
100
+ | `image` | A container image instead of a snapshot: a tag such as `python:3.12`, or `name@sha256:...`. The first `create()` from an image builds its snapshot, billed per second while it builds; later ones reuse it. Not together with `templateId` / `snapshotId` |
101
+ | `tier`, `registrySecret` | With `image`: the sandbox size, and the name of a stored secret that holds the registry credentials |
102
+ | `timeout` | Sandbox lifetime in milliseconds |
103
+ | `envs` | Environment variables for every command run through this sandbox |
104
+ | `metadata` | Labels on the sandbox (values that are not strings are stored as JSON) |
105
+ | `allowInternetAccess: false` | No network access |
106
+ | `allowHosts: [...]` | Only these destinations can be reached |
107
+ | `spendCap`, `optimizeFor` | Override the provider config for this sandbox |
108
+ | `runtime`, `name`, CPU and memory fields | Ignored: a sandbox has its snapshot's size |
109
+
110
+ ## Features
111
+
112
+ Commands take `cwd`, `env`, `timeout` and `background`, and one that exits non-zero comes back as a normal result with its `exitCode`. Pass `onStdout` or `onStderr` and the output arrives while the command runs. A command that outruns its `timeout` is stopped and reported with exit code 124.
113
+
114
+ The filesystem API reads, writes, lists and removes files, creates directories and checks whether a path exists. Sandboxes are managed with `create`, `getById`, `list` (every sandbox that has not ended) and `destroy`; snapshots with `snapshot.list()` and `snapshot.delete(id)`. Every sandbox runs under a spend cap: yours, `PROMIGENCE_SPEND_CAP`, or your organization's default.
115
+
116
+ ### Supported runtimes
117
+
118
+ The built-in base snapshot comes with Python, Node.js and Go, plus git and common build tools. Any container image works through `image`. So does any snapshot you build with the Promigence CLI, through `templateId`.
119
+
120
+ ### The Promigence SDK underneath
121
+
122
+ `sandbox.getInstance()` returns `{ sandbox, client, config }`: the `Sandbox` from [`@promigence/sdk`](https://www.npmjs.com/package/@promigence/sdk), the client it uses and the provider config. Reach for it when you need something the SDK offers beyond the ComputeSDK interface; the [TypeScript SDK docs](https://www.promigence.ai/docs/sdk) describe it.
123
+
124
+ ## Error Handling
125
+
126
+ A Promigence error is re-thrown with the operation named. It keeps the SDK's `code` and `fix` (what to do next) and the original error as `cause`; every code is listed at [promigence.ai/docs/errors](https://www.promigence.ai/docs/errors).
127
+
128
+ ```typescript
129
+ try {
130
+ await promigence({}).instances.create();
131
+ } catch (error) {
132
+ const { code, fix } = error as { code?: string; fix?: string };
133
+ console.error(code, fix); // for example: auth, and how to pass a key
134
+ }
135
+ ```
136
+
137
+ While `fallbackOnError` is on (the default), `compute.instances.create()` combines the failures of every configured provider into one error. Pass `fallbackOnError: false` to `compute.setConfig()` to receive the Promigence error itself.
138
+
139
+ ## Limitations
140
+
141
+ - There are no preview URLs yet, so `getUrl()` throws. To reach a server in the sandbox, call it from a command in the same sandbox, for example with `curl`.
142
+ - `snapshot.create()` throws: Promigence does not take a snapshot of a running sandbox. Build snapshots with the Promigence CLI (`promigence snapshot create --image <image>`), or pass `image` to `create()`.
143
+ - Templates are snapshots here. The `template` methods throw, and `templateId` on `create()` names a snapshot.
144
+ - `runCommand(cmd, { background: true })` answers at once with exit code 0 and does not collect the command's output.
145
+ - CPU and memory fields on `create()` are ignored. A sandbox has its snapshot's size, and `tier` picks one for a sandbox created from `image`.
146
+ - Environment variables passed to `create()` apply to commands run through the sandbox it returned. A handle from `getById()` or `list()` does not have them, so pass `env` with each command there.
147
+
148
+ ## Support
149
+
150
+ Read the [Promigence documentation](https://www.promigence.ai/docs) and the [error codes](https://www.promigence.ai/docs/errors), or write to support@promigence.ai. Problems with ComputeSDK itself go to [ComputeSDK Issues](https://github.com/computesdk/computesdk/issues).
151
+
152
+ ## License
153
+
154
+ MIT
@@ -0,0 +1,43 @@
1
+ import * as _computesdk_provider from '@computesdk/provider';
2
+ import * as computesdk from 'computesdk';
3
+ import { Tier, OptimizeFor, PromigenceClient, Sandbox } from '@promigence/sdk';
4
+ export { PromigenceClient, PromigenceError, Sandbox as PromigenceSandbox } from '@promigence/sdk';
5
+
6
+ /** Configuration for `promigence(config)`. Every field is optional. */
7
+ interface PromigenceConfig {
8
+ /** Promigence API key. Falls back to `PROMIGENCE_API_KEY`, then to the key `promigence login` stored. */
9
+ apiKey?: string;
10
+ /** Promigence API URL. Falls back to `PROMIGENCE_API_URL`, then to the default Promigence API. */
11
+ apiUrl?: string;
12
+ /**
13
+ * The most one sandbox may spend, in US dollars. Falls back to `PROMIGENCE_SPEND_CAP`, then to
14
+ * your organization's default cap.
15
+ */
16
+ spendCap?: number;
17
+ /**
18
+ * The snapshot `create()` starts from when it names none: its id (`snap_...`), its alias, or
19
+ * `alias@commit`. Default: the built-in base snapshot.
20
+ */
21
+ snapshot?: string;
22
+ /**
23
+ * Sandbox lifetime in milliseconds when `create()` sets none; also the bound on a command that
24
+ * sets none. Default: your account's.
25
+ */
26
+ timeout?: number;
27
+ /** Size of a sandbox created from an `image`. A sandbox from a snapshot has that snapshot's size. */
28
+ tier?: Tier;
29
+ /** `'start'` (the default) or `'compute'` (long, memory-heavy jobs on the larger tiers). */
30
+ optimizeFor?: OptimizeFor;
31
+ /** A Promigence SDK client to use instead of one built from `apiKey` and `apiUrl`. */
32
+ client?: PromigenceClient;
33
+ }
34
+ /** What `sandbox.getInstance()` returns: the Promigence SDK sandbox, its client and the provider config. */
35
+ interface PromigenceInstance {
36
+ sandbox: Sandbox;
37
+ client: PromigenceClient;
38
+ config: PromigenceConfig;
39
+ }
40
+ /** The ComputeSDK provider: `promigence({ apiKey })`, or `promigence({})` to read the environment. */
41
+ declare const promigence: (config: PromigenceConfig) => _computesdk_provider.Provider<PromigenceInstance, any, any, computesdk.Volume>;
42
+
43
+ export { type PromigenceConfig, type PromigenceInstance, promigence };
@@ -0,0 +1,43 @@
1
+ import * as _computesdk_provider from '@computesdk/provider';
2
+ import * as computesdk from 'computesdk';
3
+ import { Tier, OptimizeFor, PromigenceClient, Sandbox } from '@promigence/sdk';
4
+ export { PromigenceClient, PromigenceError, Sandbox as PromigenceSandbox } from '@promigence/sdk';
5
+
6
+ /** Configuration for `promigence(config)`. Every field is optional. */
7
+ interface PromigenceConfig {
8
+ /** Promigence API key. Falls back to `PROMIGENCE_API_KEY`, then to the key `promigence login` stored. */
9
+ apiKey?: string;
10
+ /** Promigence API URL. Falls back to `PROMIGENCE_API_URL`, then to the default Promigence API. */
11
+ apiUrl?: string;
12
+ /**
13
+ * The most one sandbox may spend, in US dollars. Falls back to `PROMIGENCE_SPEND_CAP`, then to
14
+ * your organization's default cap.
15
+ */
16
+ spendCap?: number;
17
+ /**
18
+ * The snapshot `create()` starts from when it names none: its id (`snap_...`), its alias, or
19
+ * `alias@commit`. Default: the built-in base snapshot.
20
+ */
21
+ snapshot?: string;
22
+ /**
23
+ * Sandbox lifetime in milliseconds when `create()` sets none; also the bound on a command that
24
+ * sets none. Default: your account's.
25
+ */
26
+ timeout?: number;
27
+ /** Size of a sandbox created from an `image`. A sandbox from a snapshot has that snapshot's size. */
28
+ tier?: Tier;
29
+ /** `'start'` (the default) or `'compute'` (long, memory-heavy jobs on the larger tiers). */
30
+ optimizeFor?: OptimizeFor;
31
+ /** A Promigence SDK client to use instead of one built from `apiKey` and `apiUrl`. */
32
+ client?: PromigenceClient;
33
+ }
34
+ /** What `sandbox.getInstance()` returns: the Promigence SDK sandbox, its client and the provider config. */
35
+ interface PromigenceInstance {
36
+ sandbox: Sandbox;
37
+ client: PromigenceClient;
38
+ config: PromigenceConfig;
39
+ }
40
+ /** The ComputeSDK provider: `promigence({ apiKey })`, or `promigence({})` to read the environment. */
41
+ declare const promigence: (config: PromigenceConfig) => _computesdk_provider.Provider<PromigenceInstance, any, any, computesdk.Volume>;
42
+
43
+ export { type PromigenceConfig, type PromigenceInstance, promigence };