@volter/world-core 2.0.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/LICENSE +202 -0
- package/README.md +29 -0
- package/app-route.cjs +154 -0
- package/app-route.d.cts +7 -0
- package/attach.cjs +80 -0
- package/dist/app-route.cjs +154 -0
- package/dist/app-route.d.cts +7 -0
- package/dist/attach.cjs +80 -0
- package/dist/generated/pack-facts.json +4306 -0
- package/dist/inject.cjs +1097 -0
- package/dist/network-policy.cjs +92 -0
- package/dist/network-policy.d.cts +10 -0
- package/dist/src/actions.d.ts +276 -0
- package/dist/src/actions.js +436 -0
- package/dist/src/ancestry.d.ts +22 -0
- package/dist/src/ancestry.js +238 -0
- package/dist/src/args.d.ts +3 -0
- package/dist/src/args.js +12 -0
- package/dist/src/blob-store.d.ts +55 -0
- package/dist/src/blob-store.js +186 -0
- package/dist/src/brand-tokens.d.ts +2 -0
- package/dist/src/brand-tokens.js +17 -0
- package/dist/src/changeset.d.ts +431 -0
- package/dist/src/changeset.js +0 -0
- package/dist/src/client-bundle.d.ts +1 -0
- package/dist/src/client-bundle.js +28 -0
- package/dist/src/credential.d.ts +38 -0
- package/dist/src/credential.js +114 -0
- package/dist/src/derived-core.d.ts +452 -0
- package/dist/src/derived-core.js +782 -0
- package/dist/src/derived.d.ts +84 -0
- package/dist/src/derived.js +122 -0
- package/dist/src/emit.d.ts +106 -0
- package/dist/src/emit.js +157 -0
- package/dist/src/executor.d.ts +120 -0
- package/dist/src/executor.js +387 -0
- package/dist/src/file-response.d.ts +3 -0
- package/dist/src/file-response.js +22 -0
- package/dist/src/fork.d.ts +26 -0
- package/dist/src/fork.js +68 -0
- package/dist/src/git/history.d.ts +36 -0
- package/dist/src/git/history.js +298 -0
- package/dist/src/git/index.d.ts +6 -0
- package/dist/src/git/index.js +6 -0
- package/dist/src/git/inflate.d.ts +11 -0
- package/dist/src/git/inflate.js +194 -0
- package/dist/src/git/objects.d.ts +64 -0
- package/dist/src/git/objects.js +161 -0
- package/dist/src/git/pack.d.ts +14 -0
- package/dist/src/git/pack.js +199 -0
- package/dist/src/git/refs.d.ts +19 -0
- package/dist/src/git/refs.js +35 -0
- package/dist/src/git/smart-http.d.ts +45 -0
- package/dist/src/git/smart-http.js +223 -0
- package/dist/src/hash.d.ts +38 -0
- package/dist/src/hash.js +48 -0
- package/dist/src/head.d.ts +140 -0
- package/dist/src/head.js +313 -0
- package/dist/src/history.d.ts +76 -0
- package/dist/src/history.js +322 -0
- package/dist/src/index.d.ts +73 -0
- package/dist/src/index.js +98 -0
- package/dist/src/lifecycle.d.ts +1 -0
- package/dist/src/lifecycle.js +8 -0
- package/dist/src/log.d.ts +254 -0
- package/dist/src/log.js +801 -0
- package/dist/src/mirror-shell.d.ts +2 -0
- package/dist/src/mirror-shell.js +13 -0
- package/dist/src/observe.d.ts +49 -0
- package/dist/src/observe.js +148 -0
- package/dist/src/pack-assets.d.ts +30 -0
- package/dist/src/pack-assets.js +88 -0
- package/dist/src/packRegistry.d.ts +374 -0
- package/dist/src/packRegistry.js +142 -0
- package/dist/src/placeholder-remote.d.ts +22 -0
- package/dist/src/placeholder-remote.js +86 -0
- package/dist/src/proxy.d.ts +25 -0
- package/dist/src/proxy.js +155 -0
- package/dist/src/rateBudget.d.ts +367 -0
- package/dist/src/rateBudget.js +925 -0
- package/dist/src/references.d.ts +18 -0
- package/dist/src/references.js +27 -0
- package/dist/src/remote-execute.d.ts +22 -0
- package/dist/src/remote-execute.js +1 -0
- package/dist/src/resource-blob.d.ts +10 -0
- package/dist/src/resource-blob.js +56 -0
- package/dist/src/scenario.d.ts +197 -0
- package/dist/src/scenario.js +425 -0
- package/dist/src/schemas.d.ts +78 -0
- package/dist/src/schemas.js +50 -0
- package/dist/src/serve-http.d.ts +48 -0
- package/dist/src/serve-http.js +340 -0
- package/dist/src/serve.d.ts +147 -0
- package/dist/src/serve.js +507 -0
- package/dist/src/shared-blob-index.d.ts +4 -0
- package/dist/src/shared-blob-index.js +126 -0
- package/dist/src/state-system.d.ts +70 -0
- package/dist/src/state-system.js +90 -0
- package/dist/src/storage.d.ts +101 -0
- package/dist/src/storage.js +337 -0
- package/dist/src/twin-fetch.d.ts +64 -0
- package/dist/src/twin-fetch.js +91 -0
- package/dist/src/types.d.ts +40 -0
- package/dist/src/types.js +1 -0
- package/dist/src/v1-removed.d.ts +159 -0
- package/dist/src/v1-removed.js +124 -0
- package/dist/src/volter-home.d.ts +5 -0
- package/dist/src/volter-home.js +10 -0
- package/dist/src/world-clock.d.ts +4 -0
- package/dist/src/world-clock.js +32 -0
- package/dist/src/world-env.d.ts +3 -0
- package/dist/src/world-env.js +22 -0
- package/dist/src/world-store-sql.d.ts +27 -0
- package/dist/src/world-store-sql.js +86 -0
- package/dist/src/world-store.d.ts +168 -0
- package/dist/src/world-store.js +475 -0
- package/dist/src/worldConfig.d.ts +9 -0
- package/dist/src/worldConfig.js +17 -0
- package/dist/stream-bridge.cjs +80 -0
- package/dist/vendor-hosts.cjs +200 -0
- package/generated/pack-facts.json +4306 -0
- package/inject.cjs +1097 -0
- package/network-policy.cjs +92 -0
- package/network-policy.d.cts +10 -0
- package/package.json +103 -0
- package/src/actions.ts +564 -0
- package/src/ancestry.ts +213 -0
- package/src/args.ts +14 -0
- package/src/blob-store.ts +185 -0
- package/src/brand-tokens.ts +17 -0
- package/src/changeset.ts +1032 -0
- package/src/client-bundle.ts +29 -0
- package/src/credential.ts +140 -0
- package/src/derived-core.ts +1004 -0
- package/src/derived.ts +176 -0
- package/src/emit.ts +242 -0
- package/src/executor.ts +431 -0
- package/src/file-response.ts +22 -0
- package/src/fork.ts +89 -0
- package/src/git/history.ts +177 -0
- package/src/git/index.ts +6 -0
- package/src/git/inflate.ts +125 -0
- package/src/git/objects.ts +110 -0
- package/src/git/pack.ts +105 -0
- package/src/git/refs.ts +25 -0
- package/src/git/smart-http.ts +149 -0
- package/src/hash.ts +66 -0
- package/src/head.ts +318 -0
- package/src/history.ts +246 -0
- package/src/index.ts +323 -0
- package/src/lifecycle.ts +8 -0
- package/src/log.ts +793 -0
- package/src/mirror-shell.ts +15 -0
- package/src/observe.ts +130 -0
- package/src/pack-assets.ts +81 -0
- package/src/packRegistry.ts +408 -0
- package/src/placeholder-remote.ts +81 -0
- package/src/proxy.ts +183 -0
- package/src/rateBudget.ts +1115 -0
- package/src/references.ts +46 -0
- package/src/remote-execute.ts +26 -0
- package/src/resource-blob.ts +57 -0
- package/src/scenario.ts +479 -0
- package/src/schemas.ts +56 -0
- package/src/serve-http.ts +299 -0
- package/src/serve.ts +618 -0
- package/src/shared-blob-index.ts +108 -0
- package/src/state-system.ts +115 -0
- package/src/storage.ts +407 -0
- package/src/twin-fetch.ts +147 -0
- package/src/types.ts +50 -0
- package/src/v1-removed.ts +172 -0
- package/src/volter-home.ts +11 -0
- package/src/world-clock.ts +33 -0
- package/src/world-env.ts +18 -0
- package/src/world-store-sql.ts +118 -0
- package/src/world-store.ts +572 -0
- package/src/worldConfig.ts +27 -0
- package/stream-bridge.cjs +80 -0
- package/vendor-hosts.cjs +200 -0
package/dist/attach.cjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// The rung-2 dormant attach (docs/guides/route-a-cli-through-the-world.md): `import '@volter/world-core/attach'`
|
|
2
|
+
// as line 1 of an entrypoint. A NO-OP unless VOLTER_WORLD is set — production
|
|
3
|
+
// behavior is byte-identical. When set:
|
|
4
|
+
// • a URL ref: fetch the world manifest (blocking child — this runs at
|
|
5
|
+
// module load, before the app constructs SDK clients), apply the attach
|
|
6
|
+
// env (vendor twin URLs, suggested fake credentials, CA trust), then load
|
|
7
|
+
// the injector.
|
|
8
|
+
// • anything else (a local name whose env the launcher already exported, or
|
|
9
|
+
// plain twin-URL env vars): just load the injector.
|
|
10
|
+
// The injector itself remains ./inject.cjs — this file only decides whether
|
|
11
|
+
// and how to arm it.
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const ref = process.env.VOLTER_WORLD;
|
|
15
|
+
if (ref) {
|
|
16
|
+
if (/^https?:\/\//i.test(ref)) {
|
|
17
|
+
const { spawnSync } = require('node:child_process');
|
|
18
|
+
const { mkdtempSync, readFileSync, writeFileSync } = require('node:fs');
|
|
19
|
+
const { tmpdir } = require('node:os');
|
|
20
|
+
const { join } = require('node:path');
|
|
21
|
+
const url = ref.replace(/\/$/, '').endsWith('/.well-known/volter-world')
|
|
22
|
+
? ref.replace(/\/$/, '')
|
|
23
|
+
: `${ref.replace(/\/$/, '')}/.well-known/volter-world`;
|
|
24
|
+
const token = process.env.VOLTER_WORLD_TOKEN;
|
|
25
|
+
// a blocking fetch at module load: spawn a child that prints the manifest
|
|
26
|
+
const probe = spawnSync(
|
|
27
|
+
process.execPath,
|
|
28
|
+
['-e', 'fetch(process.argv[1],process.argv[2]?{headers:{authorization:"Bearer "+process.argv[2]}}:undefined).then(r=>{if(!r.ok)throw new Error(r.status);return r.text()}).then(t=>process.stdout.write(t)).catch(e=>{console.error(String(e));process.exit(1)})', url, ...(token ? [token] : [])],
|
|
29
|
+
// the child must NOT inherit NODE_OPTIONS/VOLTER_WORLD — it would
|
|
30
|
+
// re-run this very file at its own startup (a spawn recursion bomb)
|
|
31
|
+
{ encoding: 'utf8', env: { ...process.env, NODE_OPTIONS: '', VOLTER_WORLD: '' } },
|
|
32
|
+
);
|
|
33
|
+
if (probe.status !== 0) {
|
|
34
|
+
throw new Error(`[twin-attach] could not fetch the world manifest from ${url}: ${(probe.stderr || '').trim()}`);
|
|
35
|
+
}
|
|
36
|
+
const manifest = JSON.parse(probe.stdout);
|
|
37
|
+
for (const [vendor, origin] of Object.entries(manifest.vendors ?? {})) {
|
|
38
|
+
const key = `${vendor.toUpperCase()}_TWIN_URL`;
|
|
39
|
+
if (process.env[key] === undefined) process.env[key] = origin;
|
|
40
|
+
}
|
|
41
|
+
for (const [key, value] of Object.entries(manifest.env ?? {})) {
|
|
42
|
+
if (process.env[key] === undefined) process.env[key] = value;
|
|
43
|
+
}
|
|
44
|
+
// a World's byte-stream doors (a hosted World's smtp, planetscale's mysql): loopback listeners in
|
|
45
|
+
// this process, bridged over WebSocket (./stream-bridge.cjs). The env names the listener now, so the
|
|
46
|
+
// ports are chosen by a blocking child; the listeners bind on the next turn, before any client
|
|
47
|
+
// can connect, and never hold the process open.
|
|
48
|
+
const streams = Object.values(manifest.streams ?? {});
|
|
49
|
+
if (streams.length) {
|
|
50
|
+
const picked = spawnSync(
|
|
51
|
+
process.execPath,
|
|
52
|
+
['-e', 'const n=require("node:net");const k=+process.argv[1];const s=[];const d=()=>{if(s.length<k){const v=n.createServer().listen(0,"127.0.0.1",()=>{s.push(v);d()})}else{process.stdout.write(s.map(v=>v.address().port).join(","));s.forEach(v=>v.close())}};d()', String(streams.length)],
|
|
53
|
+
{ encoding: 'utf8', env: { ...process.env, NODE_OPTIONS: '', VOLTER_WORLD: '' } },
|
|
54
|
+
);
|
|
55
|
+
if (picked.status !== 0) throw new Error(`[twin-attach] could not choose loopback ports for the world's streams: ${(picked.stderr || '').trim()}`);
|
|
56
|
+
const ports = picked.stdout.split(',').map(Number);
|
|
57
|
+
const { bridgeStream, streamEnv } = require('./stream-bridge.cjs');
|
|
58
|
+
const streamToken = token ?? manifest.env?.VOLTER_TWINS_KEY ?? '';
|
|
59
|
+
streams.forEach((stream, i) => {
|
|
60
|
+
for (const [key, value] of Object.entries(streamEnv(stream.env, ports[i]))) {
|
|
61
|
+
if (process.env[key] === undefined) process.env[key] = value;
|
|
62
|
+
}
|
|
63
|
+
bridgeStream(stream.url, streamToken, ports[i]).then((server) => server.unref(), (error) => {
|
|
64
|
+
process.stderr.write(`[twin-attach] ${stream.url}: could not listen on 127.0.0.1:${ports[i]}: ${error.message}\n`);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (manifest.ca) {
|
|
69
|
+
const existingCa = process.env.NODE_EXTRA_CA_CERTS
|
|
70
|
+
? readFileSync(process.env.NODE_EXTRA_CA_CERTS, 'utf8') : '';
|
|
71
|
+
const caFile = join(mkdtempSync(join(tmpdir(), 'twin-attach-')), 'ca.pem');
|
|
72
|
+
writeFileSync(caFile, `${existingCa}\n${manifest.ca}\n`);
|
|
73
|
+
process.env.NODE_EXTRA_CA_CERTS = caFile;
|
|
74
|
+
// NODE_EXTRA_CA_CERTS is read at process START — too late for THIS
|
|
75
|
+
// process's default TLS store. The injector's https forwards accept the
|
|
76
|
+
// session CA explicitly via this env; child processes inherit it fully.
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
require('./inject.cjs');
|
|
80
|
+
}
|