@volter/world-core 3.0.161 → 3.0.162
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/dist/generated/pack-facts.json +84 -5
- package/dist/inject.cjs +2 -2
- package/dist/src/derived-core.d.ts +9 -1
- package/dist/src/derived-core.js +120 -57
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.js +3 -1
- package/dist/src/machines.d.ts +4 -16
- package/dist/src/machines.js +10 -44
- package/dist/src/pack-fetch.js +29 -5
- package/dist/src/packRegistry.d.ts +7 -0
- package/dist/src/protobuf.d.ts +4 -0
- package/dist/src/protobuf.js +43 -2
- package/dist/src/request-scope.d.ts +2 -0
- package/dist/src/request-scope.js +9 -0
- package/dist/src/runtime.d.ts +6 -3
- package/dist/src/runtime.js +4 -1
- package/dist/src/serve-http.d.ts +11 -0
- package/dist/src/serve-http.js +132 -0
- package/dist/src/signing.d.ts +30 -7
- package/dist/src/signing.js +32 -16
- package/dist/src/sockets.d.ts +1 -1
- package/dist/src/sockets.js +11 -7
- package/dist/src/world-account-name.d.ts +2 -0
- package/dist/src/world-account-name.js +4 -0
- package/generated/pack-facts.json +84 -5
- package/inject.cjs +2 -2
- package/package.json +1 -1
- package/src/derived-core.ts +125 -63
- package/src/index.ts +5 -2
- package/src/machines.ts +10 -38
- package/src/pack-fetch.ts +27 -5
- package/src/packRegistry.ts +2 -2
- package/src/protobuf.ts +39 -2
- package/src/request-scope.ts +9 -0
- package/src/runtime.ts +8 -3
- package/src/serve-http.ts +111 -0
- package/src/signing.ts +38 -18
- package/src/sockets.ts +12 -9
- package/src/world-account-name.ts +4 -0
package/dist/src/sockets.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runWithStorageTenant, storageTenant } from "./request-scope.js";
|
|
1
2
|
// A vendor's persistent wire (architecture, "Other wires: sockets"): a WebSocket its clients hold open, on which the
|
|
2
3
|
// vendor sends what happens as it happens (Discord's Gateway: a bot identifies, is told the guilds it is in, and is sent
|
|
3
4
|
// each message, member and interaction as it lands). The manifest declares the socket (`sockets`); the pack's engine
|
|
@@ -14,7 +15,7 @@ const nextSession = new Map();
|
|
|
14
15
|
const keyOf = (service, root) => `${service}\0${root ?? ''}`;
|
|
15
16
|
/** The open sessions of one socket of the vendor in a World (a handler reaches them as `ctx.sockets(id)`). */
|
|
16
17
|
export function openSessions(service, root, socket) {
|
|
17
|
-
return [...(sessions.get(keyOf(service, root)) ?? [])].filter((o) => o.session.socket === socket).map((o) => o.session);
|
|
18
|
+
return [...(sessions.get(keyOf(service, root)) ?? [])].filter((o) => o.session.socket === socket && o.tenant === storageTenant(service)).map((o) => o.session);
|
|
18
19
|
}
|
|
19
20
|
/** What a session awaits that the World's clock has run out (a life's `wait` past a relay's timeout), rejected as the
|
|
20
21
|
* machine's clock would reject it; called as the vendor serves a request ("A request answered by a session"). */
|
|
@@ -39,9 +40,11 @@ export function socketWrite(service, root, write) {
|
|
|
39
40
|
return;
|
|
40
41
|
for (const o of open) {
|
|
41
42
|
const { engine } = o;
|
|
43
|
+
if (o.tenant !== storageTenant(service))
|
|
44
|
+
continue;
|
|
42
45
|
if (!engine.write)
|
|
43
46
|
continue;
|
|
44
|
-
o.queue = o.queue.then(async () => engine.write(o.session, write, await o.context())).catch((error) => o.session.close(1011, String(error.message ?? error).slice(0, 120)));
|
|
47
|
+
o.queue = o.queue.then(() => o.run(async () => engine.write(o.session, write, await o.context()))).catch((error) => o.session.close(1011, String(error.message ?? error).slice(0, 120)));
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
/** A declared socket path's parameters for a request's path, or undefined when it does not match: a `{name}` segment
|
|
@@ -66,7 +69,7 @@ function socketParams(declared, path) {
|
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
/** The upgrade the serve seam takes: a request to a declared socket's path (and host) opens a session of its engine. */
|
|
69
|
-
export function socketUpgrade(service, root, decls, engines, context, hostOf, pathOf
|
|
72
|
+
export function socketUpgrade(service, root, decls, engines, context, hostOf, pathOf, decide) {
|
|
70
73
|
const matchFor = (request) => {
|
|
71
74
|
const path = pathOf(request).replace(/\/+$/, '') || '/';
|
|
72
75
|
for (const d of decls) {
|
|
@@ -113,18 +116,19 @@ export function socketUpgrade(service, root, decls, engines, context, hostOf, pa
|
|
|
113
116
|
},
|
|
114
117
|
decide,
|
|
115
118
|
};
|
|
116
|
-
const
|
|
119
|
+
const tenant = storageTenant(service), run = (fn) => runWithStorageTenant(service, tenant, fn);
|
|
120
|
+
const o = { tenant, run, session, engine, context: () => context(request.clone(), decl, params), queue: Promise.resolve(), pending };
|
|
117
121
|
byPeer.set(peer, o);
|
|
118
122
|
(sessions.get(key) ?? sessions.set(key, new Set()).get(key)).add(o);
|
|
119
123
|
if (engine.open)
|
|
120
|
-
o.queue = o.queue.then(async () => engine.open(session, await o.context())).catch((error) => session.close(1011, String(error.message ?? error).slice(0, 120)));
|
|
124
|
+
o.queue = o.queue.then(() => o.run(async () => engine.open(session, await o.context()))).catch((error) => session.close(1011, String(error.message ?? error).slice(0, 120)));
|
|
121
125
|
},
|
|
122
126
|
message: (peer, data) => {
|
|
123
127
|
const o = byPeer.get(peer);
|
|
124
128
|
if (!o)
|
|
125
129
|
return;
|
|
126
130
|
const text = typeof data === 'string' ? data : new TextDecoder().decode(data);
|
|
127
|
-
o.queue = o.queue.then(async () => o.engine.message(o.session, text, await o.context())).catch((error) => o.session.close(1011, String(error.message ?? error).slice(0, 120)));
|
|
131
|
+
o.queue = o.queue.then(() => o.run(async () => o.engine.message(o.session, text, await o.context()))).catch((error) => o.session.close(1011, String(error.message ?? error).slice(0, 120)));
|
|
128
132
|
},
|
|
129
133
|
close: (peer) => {
|
|
130
134
|
const o = byPeer.get(peer);
|
|
@@ -140,7 +144,7 @@ export function socketUpgrade(service, root, decls, engines, context, hostOf, pa
|
|
|
140
144
|
// the end is written after what the session is still doing, over its own context
|
|
141
145
|
// the session is gone, so a failure has no frame to go in: it is reported, never swallowed
|
|
142
146
|
if (o.engine.close)
|
|
143
|
-
o.queue = o.queue.then(async () => o.engine.close(o.session, await o.context())).catch((error) => {
|
|
147
|
+
o.queue = o.queue.then(() => o.run(async () => o.engine.close(o.session, await o.context()))).catch((error) => {
|
|
144
148
|
console.error(`${service}: the ${o.session.socket} socket's end was not written: ${String(error?.message ?? error)}`);
|
|
145
149
|
});
|
|
146
150
|
},
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
"resources": [],
|
|
26
26
|
"endpointEnvNone": "@ai-sdk/gateway calls https://ai-gateway.vercel.sh/v4/ai and an OpenAI client is given https://ai-gateway.vercel.sh/v1 in code; the World claims the host",
|
|
27
27
|
"credentialDoor": {
|
|
28
|
+
"account": {
|
|
29
|
+
"field": "account"
|
|
30
|
+
},
|
|
28
31
|
"path": "/_twin/app-credentials",
|
|
29
32
|
"body": {},
|
|
30
33
|
"fill": {
|
|
@@ -110,6 +113,9 @@
|
|
|
110
113
|
"note": "the SDKs' base URL (the TypeScript and Python SDKs and Claude Code read ANTHROPIC_BASE_URL)"
|
|
111
114
|
},
|
|
112
115
|
"credentialDoor": {
|
|
116
|
+
"account": {
|
|
117
|
+
"field": "account"
|
|
118
|
+
},
|
|
113
119
|
"path": "/_twin/app-credentials",
|
|
114
120
|
"body": {},
|
|
115
121
|
"fill": {
|
|
@@ -174,6 +180,9 @@
|
|
|
174
180
|
"note": "The AWS SDKs read AWS_ENDPOINT_URL as every service's endpoint (https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html)."
|
|
175
181
|
},
|
|
176
182
|
"credentialDoor": {
|
|
183
|
+
"account": {
|
|
184
|
+
"field": "account"
|
|
185
|
+
},
|
|
177
186
|
"path": "/_twin/app-credentials",
|
|
178
187
|
"body": {},
|
|
179
188
|
"fill": {
|
|
@@ -360,6 +369,9 @@
|
|
|
360
369
|
"credentialDoor": {
|
|
361
370
|
"path": "/_twin/app-credentials",
|
|
362
371
|
"body": {},
|
|
372
|
+
"account": {
|
|
373
|
+
"field": "account"
|
|
374
|
+
},
|
|
363
375
|
"fill": {
|
|
364
376
|
"CLERK_SECRET_KEY": "secret_key",
|
|
365
377
|
"CLERK_API_KEY": "secret_key",
|
|
@@ -782,6 +794,9 @@
|
|
|
782
794
|
"note": "Python e2b 2.45.0 and the JS SDK read E2B_API_URL; the JS SDK reads E2B_SANDBOX_URL and sends sandbox id/port headers; vendor hosts route through the World proxy"
|
|
783
795
|
},
|
|
784
796
|
"credentialDoor": {
|
|
797
|
+
"account": {
|
|
798
|
+
"field": "account"
|
|
799
|
+
},
|
|
785
800
|
"path": "/_twin/teams",
|
|
786
801
|
"body": {
|
|
787
802
|
"name": "World team"
|
|
@@ -1003,6 +1018,9 @@
|
|
|
1003
1018
|
"note": "Google GenAI SDK reads this base URL; other callers retain the routed vendor host."
|
|
1004
1019
|
},
|
|
1005
1020
|
"credentialDoor": {
|
|
1021
|
+
"account": {
|
|
1022
|
+
"field": "account"
|
|
1023
|
+
},
|
|
1006
1024
|
"path": "/_twin/app-credentials",
|
|
1007
1025
|
"body": {},
|
|
1008
1026
|
"fill": {
|
|
@@ -1079,6 +1097,9 @@
|
|
|
1079
1097
|
"app"
|
|
1080
1098
|
],
|
|
1081
1099
|
"credentialDoor": {
|
|
1100
|
+
"account": {
|
|
1101
|
+
"field": "account"
|
|
1102
|
+
},
|
|
1082
1103
|
"path": "/_twin/app-credentials",
|
|
1083
1104
|
"body": {},
|
|
1084
1105
|
"fill": {
|
|
@@ -1213,6 +1234,9 @@
|
|
|
1213
1234
|
],
|
|
1214
1235
|
"endpointEnvNone": "Google's OAuth libraries read no base-URL variable: the endpoints are the discovery document's, claimed by the host rules.",
|
|
1215
1236
|
"credentialDoor": {
|
|
1237
|
+
"account": {
|
|
1238
|
+
"field": "world_account"
|
|
1239
|
+
},
|
|
1216
1240
|
"path": "/_twin/credentials",
|
|
1217
1241
|
"body": {
|
|
1218
1242
|
"client_email": "world@world-project.iam.gserviceaccount.com",
|
|
@@ -1657,11 +1681,20 @@
|
|
|
1657
1681
|
"endpointEnv": {
|
|
1658
1682
|
"name": "LIVEKIT_URL",
|
|
1659
1683
|
"templates": {
|
|
1660
|
-
"LIVEKIT_URL": "ws://${host}:${port}"
|
|
1661
|
-
"LIVEKIT_API_KEY": "twin-livekit-key",
|
|
1662
|
-
"LIVEKIT_API_SECRET": "twin-livekit-secret-for-the-worlds-own-server"
|
|
1684
|
+
"LIVEKIT_URL": "ws://${host}:${port}"
|
|
1663
1685
|
},
|
|
1664
|
-
"note": "
|
|
1686
|
+
"note": "The native server uses a private key; its twin front accepts only keys issued for retained World accounts."
|
|
1687
|
+
},
|
|
1688
|
+
"credentialDoor": {
|
|
1689
|
+
"path": "/_twin/app-credentials",
|
|
1690
|
+
"body": {},
|
|
1691
|
+
"account": {
|
|
1692
|
+
"field": "account"
|
|
1693
|
+
},
|
|
1694
|
+
"fill": {
|
|
1695
|
+
"LIVEKIT_API_KEY": "api_key",
|
|
1696
|
+
"LIVEKIT_API_SECRET": "api_secret"
|
|
1697
|
+
}
|
|
1665
1698
|
},
|
|
1666
1699
|
"sidePorts": [
|
|
1667
1700
|
{
|
|
@@ -1696,6 +1729,9 @@
|
|
|
1696
1729
|
"resources": [],
|
|
1697
1730
|
"endpointEnvNone": "Open Autonomy reads MODEL_GATEWAY_URL and defaults to api-gateway.merge.dev; the World claims the host",
|
|
1698
1731
|
"credentialDoor": {
|
|
1732
|
+
"account": {
|
|
1733
|
+
"field": "account"
|
|
1734
|
+
},
|
|
1699
1735
|
"path": "/_twin/organizations",
|
|
1700
1736
|
"body": {},
|
|
1701
1737
|
"fill": {
|
|
@@ -1734,6 +1770,9 @@
|
|
|
1734
1770
|
"resources": [],
|
|
1735
1771
|
"endpointEnvNone": "the SDKs call https://api.mistral.ai/v1 unless given a base URL in code or config; the World claims the host",
|
|
1736
1772
|
"credentialDoor": {
|
|
1773
|
+
"account": {
|
|
1774
|
+
"field": "account"
|
|
1775
|
+
},
|
|
1737
1776
|
"path": "/_twin/app-credentials",
|
|
1738
1777
|
"body": {},
|
|
1739
1778
|
"fill": {
|
|
@@ -1808,6 +1847,9 @@
|
|
|
1808
1847
|
"note": "npm and bun read the registry from npm_config_registry (and .npmrc's `registry`)."
|
|
1809
1848
|
},
|
|
1810
1849
|
"credentialDoor": {
|
|
1850
|
+
"account": {
|
|
1851
|
+
"field": "account"
|
|
1852
|
+
},
|
|
1811
1853
|
"path": "/_twin/app-credentials",
|
|
1812
1854
|
"body": {},
|
|
1813
1855
|
"fill": {
|
|
@@ -1871,6 +1913,9 @@
|
|
|
1871
1913
|
"api_key"
|
|
1872
1914
|
],
|
|
1873
1915
|
"credentialDoor": {
|
|
1916
|
+
"account": {
|
|
1917
|
+
"field": "account"
|
|
1918
|
+
},
|
|
1874
1919
|
"path": "/_twin/app-credentials",
|
|
1875
1920
|
"body": {},
|
|
1876
1921
|
"fill": {
|
|
@@ -1982,6 +2027,9 @@
|
|
|
1982
2027
|
"note": "the twin's own URL; applications reach it at <region>.connect.psdb.cloud, which the injector redirects, with the password the credentialDoor issued."
|
|
1983
2028
|
},
|
|
1984
2029
|
"credentialDoor": {
|
|
2030
|
+
"account": {
|
|
2031
|
+
"field": "account"
|
|
2032
|
+
},
|
|
1985
2033
|
"path": "/_twin/app-credentials",
|
|
1986
2034
|
"body": {
|
|
1987
2035
|
"organization": "world",
|
|
@@ -2306,6 +2354,9 @@
|
|
|
2306
2354
|
"received"
|
|
2307
2355
|
],
|
|
2308
2356
|
"credentialDoor": {
|
|
2357
|
+
"account": {
|
|
2358
|
+
"field": "account"
|
|
2359
|
+
},
|
|
2309
2360
|
"path": "/_twin/app-credentials",
|
|
2310
2361
|
"body": {},
|
|
2311
2362
|
"fill": {
|
|
@@ -2377,6 +2428,9 @@
|
|
|
2377
2428
|
],
|
|
2378
2429
|
"endpointEnvNone": "an SDK sends to its DSN's host and sentry-cli to SENTRY_URL (sentry.io by default); the DSN the World issues names the World's ingest host, claimed by the host rules",
|
|
2379
2430
|
"credentialDoor": {
|
|
2431
|
+
"account": {
|
|
2432
|
+
"field": "account"
|
|
2433
|
+
},
|
|
2380
2434
|
"path": "/_twin/app-credentials",
|
|
2381
2435
|
"body": {},
|
|
2382
2436
|
"fill": {
|
|
@@ -2485,6 +2539,9 @@
|
|
|
2485
2539
|
"app"
|
|
2486
2540
|
],
|
|
2487
2541
|
"credentialDoor": {
|
|
2542
|
+
"account": {
|
|
2543
|
+
"field": "account"
|
|
2544
|
+
},
|
|
2488
2545
|
"path": "/_twin/app-credentials",
|
|
2489
2546
|
"body": {},
|
|
2490
2547
|
"fill": {
|
|
@@ -2602,6 +2659,9 @@
|
|
|
2602
2659
|
"credentialDoor": {
|
|
2603
2660
|
"path": "/_twin/app-credentials",
|
|
2604
2661
|
"body": {},
|
|
2662
|
+
"account": {
|
|
2663
|
+
"field": "account"
|
|
2664
|
+
},
|
|
2605
2665
|
"fill": {
|
|
2606
2666
|
"STRIPE_SECRET_KEY": "secret_key",
|
|
2607
2667
|
"STRIPE_API_KEY": "secret_key",
|
|
@@ -2675,7 +2735,11 @@
|
|
|
2675
2735
|
"managedDatabase": {
|
|
2676
2736
|
"kind": "postgres",
|
|
2677
2737
|
"arg": "--database",
|
|
2678
|
-
"
|
|
2738
|
+
"user": "world",
|
|
2739
|
+
"database": "world",
|
|
2740
|
+
"clock": "wall",
|
|
2741
|
+
"credentialField": "database_url",
|
|
2742
|
+
"note": "the selected Supabase twin owns its private PostgreSQL data plane; the credential door answers its URL, application migrations own application tables, and SQL uses wall time"
|
|
2679
2743
|
},
|
|
2680
2744
|
"serveExport": "createSupabaseTwinServer"
|
|
2681
2745
|
},
|
|
@@ -2886,6 +2950,9 @@
|
|
|
2886
2950
|
],
|
|
2887
2951
|
"endpointEnvNone": "Tinybird's clients take the API host as configuration (@chronark/zod-bird's baseUrl, tinybird-cli's --host), defaulting to https://api.tinybird.co, which the World routes by host; no SDK reads a base-URL variable of its own",
|
|
2888
2952
|
"credentialDoor": {
|
|
2953
|
+
"account": {
|
|
2954
|
+
"field": "account"
|
|
2955
|
+
},
|
|
2889
2956
|
"path": "/_twin/app-credentials",
|
|
2890
2957
|
"body": {},
|
|
2891
2958
|
"fill": {
|
|
@@ -3205,6 +3272,9 @@
|
|
|
3205
3272
|
"note": "Redis reads its REST URL; QStash and Workflow read QSTASH_URL. Direct SDK transports use the twin endpoint and issued token; other clients also use host routing."
|
|
3206
3273
|
},
|
|
3207
3274
|
"credentialDoor": {
|
|
3275
|
+
"account": {
|
|
3276
|
+
"field": "account"
|
|
3277
|
+
},
|
|
3208
3278
|
"path": "/_twin/app-credentials",
|
|
3209
3279
|
"body": {
|
|
3210
3280
|
"owner": "owner@world.test"
|
|
@@ -3270,6 +3340,9 @@
|
|
|
3270
3340
|
],
|
|
3271
3341
|
"endpointEnvNone": "the applications reach api.vercel.com and the Edge Config connection string's host, which the World routes to the twin",
|
|
3272
3342
|
"credentialDoor": {
|
|
3343
|
+
"account": {
|
|
3344
|
+
"field": "account"
|
|
3345
|
+
},
|
|
3273
3346
|
"path": "/_twin/app-credentials",
|
|
3274
3347
|
"body": {
|
|
3275
3348
|
"team": "world",
|
|
@@ -3508,6 +3581,9 @@
|
|
|
3508
3581
|
"upload"
|
|
3509
3582
|
],
|
|
3510
3583
|
"credentialDoor": {
|
|
3584
|
+
"account": {
|
|
3585
|
+
"field": "account"
|
|
3586
|
+
},
|
|
3511
3587
|
"path": "/_twin/app-credentials",
|
|
3512
3588
|
"body": {},
|
|
3513
3589
|
"fill": {
|
|
@@ -3546,6 +3622,9 @@
|
|
|
3546
3622
|
"resources": [],
|
|
3547
3623
|
"endpointEnvNone": "the SDK calls https://api.x.ai/v1 unless given a base URL in code; the World claims the host",
|
|
3548
3624
|
"credentialDoor": {
|
|
3625
|
+
"account": {
|
|
3626
|
+
"field": "account"
|
|
3627
|
+
},
|
|
3549
3628
|
"path": "/_twin/app-credentials",
|
|
3550
3629
|
"body": {},
|
|
3551
3630
|
"fill": {
|
package/inject.cjs
CHANGED
|
@@ -358,8 +358,8 @@ function strictEgressEnabled() {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
// THE WORLD'S DECISION (docs/contributing/architecture.md, "Capability decisions"): every seam below asks
|
|
361
|
-
// capability-decision.cjs and enforces its answer. This process is a host process, whose declaration is the open one;
|
|
362
|
-
//
|
|
361
|
+
// capability-decision.cjs and enforces its answer. This process is a host process, whose declaration is the open one; or
|
|
362
|
+
// a process of an image run, which carries its
|
|
363
363
|
// image's declaration (VOLTER_WORLD_DECLARATION) and is confined from the host's network. What the World grants is its
|
|
364
364
|
// published policy. The seams supply what they observe: the twin route, the vendors sharing a host, the World's doors.
|
|
365
365
|
function worldGrant() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/world-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.162",
|
|
4
4
|
"description": "The kernel of Volter World: one log per twin, branches as pointers, checkpoints, the fold that keeps a twin current, the head that performs a write against the vendor, references, and the git plane. A twin package builds on it; the runtime serves it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"twin",
|