openzoo 0.51.3 → 0.51.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.
Files changed (54) hide show
  1. package/README.md +2 -0
  2. package/bin/openzoo.js +14 -37
  3. package/lib/chatgpt.js +328 -0
  4. package/lib/config.js +34 -0
  5. package/lib/pay.js +60 -4
  6. package/lib/proxy.js +8 -7
  7. package/lib/stripeOnramp.js +9 -3
  8. package/package.json +4 -7
  9. package/transmute/README.md +0 -385
  10. package/transmute/bin/openzoo-transmute.js +0 -7
  11. package/transmute/docs/OPENZOO_CLI_PATCH.md +0 -139
  12. package/transmute/docs/VERCEL_TO_SOLANA.md +0 -381
  13. package/transmute/lib/build.js +0 -381
  14. package/transmute/lib/cli.js +0 -293
  15. package/transmute/lib/compile/bytecode.js +0 -591
  16. package/transmute/lib/compile/hostids.js +0 -11
  17. package/transmute/lib/compile/index.js +0 -159
  18. package/transmute/lib/compile/ir.js +0 -1634
  19. package/transmute/lib/compile/parse.js +0 -753
  20. package/transmute/lib/compile/rust.js +0 -781
  21. package/transmute/lib/deploy.js +0 -357
  22. package/transmute/lib/eligibility.js +0 -211
  23. package/transmute/lib/gateway.js +0 -710
  24. package/transmute/lib/hub.js +0 -290
  25. package/transmute/lib/solana.js +0 -387
  26. package/transmute/lib/vercel.js +0 -296
  27. package/transmute/lib/wallet.js +0 -41
  28. package/transmute/lib/wire.js +0 -208
  29. package/transmute/prebuilt/zoo_vm.v0.so +0 -0
  30. package/transmute/runtime/zoo-host/Cargo.lock +0 -588
  31. package/transmute/runtime/zoo-host/Cargo.toml +0 -30
  32. package/transmute/runtime/zoo-host/examples/vmrun.rs +0 -43
  33. package/transmute/runtime/zoo-host/src/assets.rs +0 -214
  34. package/transmute/runtime/zoo-host/src/ctx.rs +0 -350
  35. package/transmute/runtime/zoo-host/src/fmt.rs +0 -188
  36. package/transmute/runtime/zoo-host/src/helpers.rs +0 -245
  37. package/transmute/runtime/zoo-host/src/json.rs +0 -263
  38. package/transmute/runtime/zoo-host/src/kv.rs +0 -206
  39. package/transmute/runtime/zoo-host/src/lib.rs +0 -137
  40. package/transmute/runtime/zoo-host/src/site.rs +0 -94
  41. package/transmute/runtime/zoo-host/src/val.rs +0 -1050
  42. package/transmute/runtime/zoo-host/src/vm.rs +0 -902
  43. package/transmute/runtime/zoo-host/src/wire.rs +0 -239
  44. package/transmute/runtime/zoo-vm/Cargo.lock +0 -596
  45. package/transmute/runtime/zoo-vm/Cargo.toml +0 -23
  46. package/transmute/runtime/zoo-vm/src/lib.rs +0 -92
  47. package/transmute/site/.env.production +0 -2
  48. package/transmute/site/api/echo.js +0 -10
  49. package/transmute/site/api/hello.js +0 -12
  50. package/transmute/site/api/hits.js +0 -13
  51. package/transmute/site/api/time.js +0 -5
  52. package/transmute/site/package.json +0 -6
  53. package/transmute/site/public/app.js +0 -16
  54. package/transmute/site/public/index.html +0 -96
@@ -1,159 +0,0 @@
1
- // The transmuter: VercelDeployment → Rust crate + manifest + report.
2
- //
3
- // transmute(deployment, opts) → { crate: { 'Cargo.toml', 'src/lib.rs' }, manifest, report }
4
- // compileFunction(fn, source, opts) → { rust, ir, eligible, reason, ... } (one Lambda, for tests/tools)
5
- import fs from 'node:fs';
6
- import path from 'node:path';
7
- import { Ineligible, functionMetaReason, deploymentWarnings, displayFile } from '../eligibility.js';
8
- import { readModule } from './parse.js';
9
- import { lowerRoute } from './ir.js';
10
- import { emitRoute, emitCrate, RustPrinter, DEFAULT_RUNTIME_PATH, sanitizeCrateName } from './rust.js';
11
- import { emitModule } from './bytecode.js';
12
-
13
- export { readModule, parseModule, stripTypes } from './parse.js';
14
- export { lowerRoute, IR } from './ir.js';
15
- export { emitRoute, emitCrate, RustPrinter, DEFAULT_RUNTIME_PATH, sanitizeCrateName, rustStr } from './rust.js';
16
- export { emitModule, OP } from './bytecode.js';
17
- export { Ineligible } from '../eligibility.js';
18
-
19
- export const MANIFEST_VERSION = 1;
20
-
21
- /**
22
- * Compile one Lambda.
23
- * @param {object} fn VercelFunction-like: { name, routePath, pattern, params, style, sourceFile, methods }
24
- * @param {string} source handler source text
25
- * @param {{ index?: number, file?: string }} opts
26
- */
27
- export function compileFunction(fn, source, opts = {}) {
28
- const file = opts.file || fn.sourceFile || fn.name || 'handler.js';
29
- const index = opts.index ?? 0;
30
- const out = { name: fn.name, file, eligible: false, reason: null, line: null, rust: null, ir: null, kv: false, env: [], envDynamic: false, methods: null, style: null, warnings: [] };
31
- try {
32
- const meta = functionMetaReason(fn);
33
- if (meta) throw new Ineligible(meta, { file });
34
- const mod = readModule(source, { file });
35
- const lowered = lowerRoute(mod, fn, { index, file });
36
- out.ir = lowered.ir;
37
- out.kv = lowered.kv;
38
- out.env = lowered.env;
39
- out.envDynamic = lowered.envDynamic;
40
- out.methods = lowered.methods;
41
- out.style = lowered.style;
42
- out.warnings = lowered.warnings;
43
- out.rust = emitRoute(lowered.ir, { printer: opts.printer || new RustPrinter() });
44
- out.eligible = true;
45
- } catch (e) {
46
- if (e instanceof Ineligible) {
47
- out.reason = e.reason;
48
- out.line = e.line;
49
- out.file = e.file || file;
50
- } else {
51
- out.reason = `transmuter error: ${e.message}`;
52
- out.internalError = e;
53
- }
54
- }
55
- return out;
56
- }
57
-
58
- /**
59
- * Transmute a deployment.
60
- * @param {import('../vercel.js').VercelDeployment} deployment
61
- * @param {{ name?: string, runtimePath?: string, readSource?: (fn) => string }} opts
62
- */
63
- export function transmute(deployment, opts = {}) {
64
- const name = sanitizeCrateName(opts.name || 'zoo_site');
65
- const runtimePath = path.resolve(opts.runtimePath || DEFAULT_RUNTIME_PATH);
66
- const readSource = opts.readSource || ((fn) => fs.readFileSync(fn.sourceFile, 'utf8'));
67
- const report = { eligible: [], ineligible: [], warnings: deploymentWarnings(deployment) };
68
- const routes = [];
69
- const routeSources = [];
70
- const loweredIrs = [];
71
- const mergedEnv = {};
72
- const referencedEnv = new Set();
73
- let envDynamic = false;
74
- const printer = new RustPrinter();
75
-
76
- for (const fn of deployment.functions || []) {
77
- const file = displayFile(fn, deployment.root);
78
- let source;
79
- try {
80
- const meta = functionMetaReason(fn);
81
- if (meta) throw new Ineligible(meta, { file });
82
- source = readSource(fn);
83
- } catch (e) {
84
- if (e instanceof Ineligible) { report.ineligible.push({ name: fn.name, reason: e.reason, file: e.file || file, line: e.line }); continue; }
85
- report.ineligible.push({ name: fn.name, reason: `cannot read source: ${e.message}`, file, line: null });
86
- continue;
87
- }
88
- const index = routes.length;
89
- // one shared printer keeps temp names unique across the crate
90
- const c = compileFunction(fn, source, { index, file, printer });
91
- for (const w of c.warnings) report.warnings.push(`${fn.name}: ${w}`);
92
- if (!c.eligible) {
93
- report.ineligible.push({ name: fn.name, reason: c.reason, file: c.file, line: c.line });
94
- if (c.internalError) report.warnings.push(`${fn.name}: ${c.internalError.stack?.split('\n').slice(0, 2).join(' ') || c.internalError.message}`);
95
- continue;
96
- }
97
- routeSources.push(c.rust);
98
- loweredIrs.push(c.ir);
99
- for (const k of c.env) referencedEnv.add(k);
100
- if (c.envDynamic) envDynamic = true;
101
- Object.assign(mergedEnv, fn.environment || {});
102
- report.eligible.push(fn.name);
103
- routes.push({
104
- index,
105
- name: fn.name,
106
- routePath: fn.routePath,
107
- pattern: fn.pattern,
108
- params: fn.params || [],
109
- methods: c.methods, // null = any method (Node-style handler); list = web-standard method exports
110
- style: fn.style || (c.style === 'node' ? 'pages' : 'app'),
111
- kv: c.kv,
112
- });
113
- }
114
-
115
- // Environment: only what handlers read, unless one reads process.env dynamically.
116
- const envNames = envDynamic ? Object.keys(mergedEnv) : [...referencedEnv].filter((k) => k in mergedEnv);
117
- for (const k of referencedEnv) if (!(k in mergedEnv)) report.warnings.push(`process.env.${k} is read by a handler but not defined in .env/.env.production: it will be undefined on chain`);
118
- if (envNames.length) report.warnings.push(`environment baked into the program (public on chain): ${envNames.join(', ')}`);
119
- const env = envNames.map((k) => [k, String(mergedEnv[k])]);
120
-
121
- const header = [
122
- `${deployment.source || 'deployment'}${deployment.framework ? ` (${deployment.framework})` : ''} — ${routes.length} route(s), ${(deployment.staticFiles || []).length} static file(s)`,
123
- ...routes.map((r) => `route ${r.index}: ${r.routePath}${r.methods ? ' [' + r.methods.join(',') + ']' : ''} ← ${r.name}`),
124
- ].join('\n');
125
- const target = opts.target === 'shared' ? 'shared' : 'program';
126
- let crate = null;
127
- let code = null;
128
- if (target === 'shared') {
129
- // The shared runtime: a bytecode module (a few KB) instead of a crate.
130
- code = emitModule({ routes: loweredIrs.map((ir) => ({ ir })), env });
131
- } else {
132
- const crateFiles = emitCrate({ name, runtimePath, env, routes: routeSources, routeCount: routes.length, header });
133
- crate = { 'Cargo.toml': crateFiles['Cargo.toml'], 'src/lib.rs': crateFiles['src/lib.rs'] };
134
- }
135
-
136
- const manifest = {
137
- version: MANIFEST_VERSION,
138
- framework: deployment.framework || null,
139
- routes,
140
- static: (deployment.staticFiles || []).map((f) => ({ path: f.path, contentType: f.contentType, size: f.size })),
141
- env: envNames,
142
- config: deployment.config,
143
- target,
144
- };
145
- return { crate, code, manifest, report, crateName: crate ? name : null, target };
146
- }
147
-
148
- /** Write a transmuted crate to `dir` (creates src/). Returns the paths written. */
149
- export function writeCrate(crate, dir) {
150
- fs.mkdirSync(path.join(dir, 'src'), { recursive: true });
151
- const written = [];
152
- for (const [rel, text] of Object.entries(crate)) {
153
- const p = path.join(dir, rel);
154
- fs.mkdirSync(path.dirname(p), { recursive: true });
155
- fs.writeFileSync(p, text);
156
- written.push(p);
157
- }
158
- return written;
159
- }