openzoo 0.39.4 → 0.40.0
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/lib/boxes.js +45 -9
- package/lib/podagent.mjs +6 -3
- package/package.json +1 -1
package/lib/boxes.js
CHANGED
|
@@ -173,7 +173,39 @@ export async function reapExpired() {
|
|
|
173
173
|
return { reaped };
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
/**
|
|
177
|
+
* MACHINE TIERS — a menu, not one size.
|
|
178
|
+
*
|
|
179
|
+
* A box that only runs a shell is fine on 2 vCPU, but a grokbot agent that
|
|
180
|
+
* builds a site, runs a dev server, or compiles wants real muscle — and some
|
|
181
|
+
* tasks want a GPU. So the orchestrator quotes SEVERAL tiers per timeframe and
|
|
182
|
+
* the user picks. GPU is a DELIBERATE tier here, never an accident: the guard
|
|
183
|
+
* below refuses GPU fields on a CPU tier, so a cpu tier can't silently 100x the
|
|
184
|
+
* bill, while a gpu tier carries them on purpose.
|
|
185
|
+
*
|
|
186
|
+
* $/hr are approximate RunPod secure-cloud rates for sizing the quote; the real
|
|
187
|
+
* charge is whatever RunPod bills. estUsdHr is labelled approximate for that.
|
|
188
|
+
*/
|
|
189
|
+
export const BOX_TIERS = {
|
|
190
|
+
'cpu-sm': { label: 'CPU · 2 vCPU', compute: 'CPU', vcpu: 2, disk: 20, estUsdHr: 0.06 },
|
|
191
|
+
'cpu-md': { label: 'CPU · 4 vCPU', compute: 'CPU', vcpu: 4, disk: 40, estUsdHr: 0.12 },
|
|
192
|
+
'cpu-lg': { label: 'CPU · 8 vCPU', compute: 'CPU', vcpu: 8, disk: 60, estUsdHr: 0.24 },
|
|
193
|
+
'gpu-4090':{ label: 'GPU · 1× RTX 4090', compute: 'GPU', gpuTypeIds: ['NVIDIA GeForce RTX 4090'], gpuCount: 1, disk: 60, estUsdHr: 0.44 },
|
|
194
|
+
'gpu-a100':{ label: 'GPU · 1× A100 80GB', compute: 'GPU', gpuTypeIds: ['NVIDIA A100 80GB PCIe'], gpuCount: 1, disk: 80, estUsdHr: 1.64 },
|
|
195
|
+
};
|
|
196
|
+
export const DEFAULT_TIER = 'cpu-sm';
|
|
197
|
+
|
|
198
|
+
/** The quote menu the orchestrator shows: every tier priced for `days`. */
|
|
199
|
+
export function quoteTiers(days = 1) {
|
|
200
|
+
const hrs = ttlHours(days);
|
|
201
|
+
return Object.entries(BOX_TIERS).map(([key, t]) => ({
|
|
202
|
+
tier: key, label: t.label, days: Math.round(hrs / 24 * 10) / 10,
|
|
203
|
+
estUsd: Math.round(t.estUsdHr * hrs * 100) / 100, estUsdHr: t.estUsdHr, gpu: t.compute === 'GPU',
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export async function spawnBox({ name = 'bot', days = 1, tier = DEFAULT_TIER, walletJson, pubkey } = {}) {
|
|
208
|
+
const spec = BOX_TIERS[tier] || BOX_TIERS[DEFAULT_TIER];
|
|
177
209
|
const expiresAt = new Date(Date.now() + ttlHours(days) * 3600 * 1000);
|
|
178
210
|
const unix = Math.floor(expiresAt.getTime() / 1000);
|
|
179
211
|
const rand = Math.random().toString(36).slice(2, 6);
|
|
@@ -181,19 +213,20 @@ export async function spawnBox({ name = 'bot', days = 1, vcpu = 2, walletJson, p
|
|
|
181
213
|
|
|
182
214
|
const body = {
|
|
183
215
|
name: full,
|
|
184
|
-
computeType:
|
|
216
|
+
computeType: spec.compute,
|
|
185
217
|
cloudType: 'SECURE',
|
|
186
|
-
vcpuCount: Math.max(1, Math.min(Number(vcpu) || 2, 4)),
|
|
187
|
-
cpuFlavorIds: CPU_FLAVORS,
|
|
188
|
-
cpuFlavorPriority: 'availability',
|
|
189
218
|
imageName: BOX_IMAGE,
|
|
190
|
-
containerDiskInGb:
|
|
219
|
+
containerDiskInGb: spec.disk,
|
|
191
220
|
volumeInGb: 10,
|
|
192
221
|
volumeMountPath: '/workspace',
|
|
193
222
|
ports: BOX_PORTS,
|
|
194
223
|
dockerStartCmd: ENTRYPOINT,
|
|
224
|
+
...(spec.compute === 'CPU'
|
|
225
|
+
? { vcpuCount: spec.vcpu, cpuFlavorIds: CPU_FLAVORS, cpuFlavorPriority: 'availability' }
|
|
226
|
+
: { gpuCount: spec.gpuCount, gpuTypeIds: spec.gpuTypeIds }),
|
|
195
227
|
env: {
|
|
196
228
|
OPENZOO_BOX: '1',
|
|
229
|
+
OPENZOO_TIER: tier,
|
|
197
230
|
OPENZOO_EXPIRES_UNIX: String(unix),
|
|
198
231
|
OPENZOO_NO_TUNNEL: '1', // the runpod proxy already fronts it
|
|
199
232
|
OPENZOO_BIND: '0.0.0.0', // else the runpod proxy can't reach :8402
|
|
@@ -203,13 +236,16 @@ export async function spawnBox({ name = 'bot', days = 1, vcpu = 2, walletJson, p
|
|
|
203
236
|
OZ_PODAGENT_B64: podAgentB64(),
|
|
204
237
|
},
|
|
205
238
|
};
|
|
206
|
-
//
|
|
239
|
+
// GPU ONLY ON A GPU TIER. A cpu tier must never carry GPU fields — that would
|
|
240
|
+
// be a silent 100x. Enforced on the serialized payload, not a literal.
|
|
207
241
|
const wire = JSON.stringify(body);
|
|
208
|
-
if (/"gpu(Count|TypeIds)"/.test(wire))
|
|
242
|
+
if (spec.compute === 'CPU' && /"gpu(Count|TypeIds)"/.test(wire)) {
|
|
243
|
+
throw new Error('refusing to spawn: GPU fields on a CPU tier');
|
|
244
|
+
}
|
|
209
245
|
|
|
210
246
|
const created = await rp('/pods', { method: 'POST', body: wire });
|
|
211
247
|
if (!created.ok) return { ok: false, error: created.data?.error || `spawn ${created.status}` };
|
|
212
|
-
return { ok: true, box: serializeBox(created.data), expiresAt: expiresAt.toISOString() };
|
|
248
|
+
return { ok: true, tier, box: serializeBox(created.data), expiresAt: expiresAt.toISOString() };
|
|
213
249
|
}
|
|
214
250
|
|
|
215
251
|
/** Poll until the box answers on its proxy — npx has to fetch the shim first. */
|
package/lib/podagent.mjs
CHANGED
|
@@ -44,9 +44,12 @@ let probedOnce = false;
|
|
|
44
44
|
* us the real schema, which is the whole point. */
|
|
45
45
|
function pushExec(cmd) {
|
|
46
46
|
const id = `oz-${Date.now().toString(36)}`;
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
|
|
47
|
+
// THE COMMAND FRAME IS kind:"shell", NOT "exec". Decoded from the app bundle:
|
|
48
|
+
// the daemon's receive-union has kind "shell" (run), "sequence", "abort"; the
|
|
49
|
+
// proto is {command: scalar, args, cwd, env}. Our first probe used "exec"
|
|
50
|
+
// (which appears once in the bundle) and the daemon silently ignored it,
|
|
51
|
+
// sending only pings. "shell" is what it actually runs.
|
|
52
|
+
const frame = { frames: [{ kind: 'shell', id, command: cmd, cwd: '/tmp', supervised: true }] };
|
|
50
53
|
const payload = `data: ${JSON.stringify(frame)}\n\n`;
|
|
51
54
|
for (const res of execStreams) { try { res.write(payload); } catch { /* dead stream */ } }
|
|
52
55
|
record({ t: new Date().toISOString(), port: 1340, method: 'SSE-PUSH', path: '/local-exec/requests',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openzoo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "Local x402-paying proxy + MCP server for openzoo.fun — point any OpenAI-compatible harness (Cursor, Claude Code, aider, SDKs) at localhost and it pays per call from a local burner wallet. Solana and Base rails live; Robinhood experimental.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|