@volter/world-core 2.0.37 → 3.0.1
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/README.md +4 -5
- package/app-route.cjs +12 -6
- package/app-route.d.cts +1 -1
- package/dist/app-route.cjs +12 -6
- package/dist/app-route.d.cts +1 -1
- package/dist/generated/pack-facts.json +1410 -3069
- package/dist/inject.cjs +64 -9
- package/dist/pack-facts.cjs +44 -0
- package/dist/src/actions.d.ts +3 -3
- package/dist/src/actions.js +22 -16
- package/dist/src/ancestry.d.ts +14 -2
- package/dist/src/ancestry.js +92 -2
- package/dist/src/anthropic-wire.d.ts +39 -0
- package/dist/src/anthropic-wire.js +136 -0
- package/dist/src/bytes.d.ts +7 -0
- package/dist/src/bytes.js +35 -0
- package/dist/src/changeset.d.ts +1 -1
- package/dist/src/changeset.js +0 -0
- package/dist/src/clickhouse/index.d.ts +3 -0
- package/dist/src/clickhouse/index.js +6 -0
- package/dist/src/clickhouse/sql.d.ts +233 -0
- package/dist/src/clickhouse/sql.js +4329 -0
- package/dist/src/clickhouse/types.d.ts +18 -0
- package/dist/src/clickhouse/types.js +47 -0
- package/dist/src/clickhouse/values.d.ts +146 -0
- package/dist/src/clickhouse/values.js +858 -0
- package/dist/src/client-bundle.js +2 -3
- package/dist/src/cors.d.ts +15 -0
- package/dist/src/cors.js +31 -0
- package/dist/src/derived-core.d.ts +487 -24
- package/dist/src/derived-core.js +788 -144
- package/dist/src/derived-real.d.ts +13 -0
- package/dist/src/derived-real.js +518 -0
- package/dist/src/derived.d.ts +35 -1
- package/dist/src/derived.js +61 -9
- package/dist/src/emit.js +1 -2
- package/dist/src/events.d.ts +206 -0
- package/dist/src/events.js +341 -0
- package/dist/src/executor.d.ts +3 -0
- package/dist/src/executor.js +19 -2
- package/dist/src/file-response.d.ts +6 -0
- package/dist/src/file-response.js +30 -0
- package/dist/src/fork.js +3 -2
- package/dist/src/git/history.d.ts +7 -0
- package/dist/src/git/history.js +24 -0
- package/dist/src/git/index.d.ts +1 -0
- package/dist/src/git/index.js +1 -0
- package/dist/src/git/lfs.d.ts +28 -0
- package/dist/src/git/lfs.js +66 -0
- package/dist/src/git/objects.js +3 -8
- package/dist/src/git/smart-http.d.ts +3 -1
- package/dist/src/git/smart-http.js +67 -6
- package/dist/src/graphql-wire.d.ts +29 -0
- package/dist/src/graphql-wire.js +101 -0
- package/dist/src/grpc-wire.d.ts +67 -0
- package/dist/src/grpc-wire.js +170 -0
- package/dist/src/h2.d.ts +40 -0
- package/dist/src/h2.js +656 -0
- package/dist/src/head.d.ts +32 -3
- package/dist/src/head.js +161 -40
- package/dist/src/history.d.ts +1 -1
- package/dist/src/history.js +6 -6
- package/dist/src/hpack.json +1 -0
- package/dist/src/index.d.ts +64 -75
- package/dist/src/index.js +58 -101
- package/dist/src/log.js +28 -19
- package/dist/src/machines.d.ts +50 -0
- package/dist/src/machines.js +151 -0
- package/dist/src/managed-database.d.ts +86 -0
- package/dist/src/managed-database.js +283 -0
- package/dist/src/multipart.d.ts +11 -0
- package/dist/src/multipart.js +51 -0
- package/dist/src/observe.d.ts +15 -5
- package/dist/src/observe.js +23 -9
- package/dist/src/openai-wire.d.ts +108 -0
- package/dist/src/openai-wire.js +337 -0
- package/dist/src/pack-assets.d.ts +3 -4
- package/dist/src/pack-assets.js +15 -10
- package/dist/src/pack-fetch.d.ts +77 -0
- package/dist/src/pack-fetch.js +449 -0
- package/dist/src/pack-paths.d.ts +12 -0
- package/dist/src/pack-paths.js +86 -0
- package/dist/src/packRegistry.d.ts +69 -162
- package/dist/src/packRegistry.js +55 -20
- package/dist/src/people.d.ts +13 -0
- package/dist/src/people.js +18 -0
- package/dist/src/placeholder-image.d.ts +5 -0
- package/dist/src/placeholder-image.js +114 -0
- package/dist/src/protobuf.d.ts +28 -0
- package/dist/src/protobuf.js +332 -0
- package/dist/src/redis/engine.js +1 -1
- package/dist/src/request-scope.d.ts +1 -1
- package/dist/src/request-scope.js +6 -4
- package/dist/src/resource-blob.d.ts +5 -0
- package/dist/src/resource-blob.js +11 -0
- package/dist/src/runtime.d.ts +85 -0
- package/dist/src/runtime.js +104 -0
- package/dist/src/s3/wire.d.ts +60 -0
- package/dist/src/s3/wire.js +157 -0
- package/dist/src/scenario.d.ts +3 -0
- package/dist/src/scenario.js +2 -0
- package/dist/src/schema-sample.d.ts +1 -0
- package/dist/src/schema-sample.js +21 -0
- package/dist/src/sealed-box.d.ts +14 -0
- package/dist/src/sealed-box.js +225 -0
- package/dist/src/serve-http.d.ts +14 -0
- package/dist/src/serve-http.js +27 -3
- package/dist/src/serve.d.ts +6 -0
- package/dist/src/serve.js +69 -14
- package/dist/src/signing.d.ts +135 -0
- package/dist/src/signing.js +222 -0
- package/dist/src/sigv4.d.ts +48 -0
- package/dist/src/sigv4.js +167 -0
- package/dist/src/smtp.d.ts +16 -0
- package/dist/src/smtp.js +72 -0
- package/dist/src/sockets.d.ts +51 -0
- package/dist/src/sockets.js +90 -0
- package/dist/src/state-system.d.ts +1 -0
- package/dist/src/state-system.js +1 -1
- package/dist/src/storage.d.ts +1 -1
- package/dist/src/storage.js +3 -3
- package/dist/src/trace-context.js +1 -1
- package/dist/src/twin-fetch.d.ts +0 -7
- package/dist/src/twin-fetch.js +0 -14
- package/dist/src/vendor-call.d.ts +6 -0
- package/dist/src/vendor-call.js +41 -0
- package/dist/src/world-store.js +1 -1
- package/dist/vendor-hosts.cjs +36 -125
- package/dist/vendor-hosts.d.cts +8 -0
- package/generated/pack-facts.json +1410 -3069
- package/inject.cjs +64 -9
- package/pack-facts.cjs +44 -0
- package/package.json +17 -3
- package/src/actions.ts +23 -16
- package/src/ancestry.ts +74 -2
- package/src/anthropic-wire.ts +137 -0
- package/src/bytes.ts +42 -0
- package/src/changeset.ts +5 -5
- package/src/clickhouse/index.ts +6 -0
- package/src/clickhouse/sql.ts +3059 -0
- package/src/clickhouse/types.ts +44 -0
- package/src/clickhouse/values.ts +697 -0
- package/src/client-bundle.ts +2 -3
- package/src/cors.ts +34 -0
- package/src/derived-core.ts +1013 -146
- package/src/derived-real.ts +434 -0
- package/src/derived.ts +73 -3
- package/src/emit.ts +1 -2
- package/src/events.ts +449 -0
- package/src/executor.ts +24 -2
- package/src/file-response.ts +27 -0
- package/src/fork.ts +3 -2
- package/src/git/history.ts +19 -0
- package/src/git/index.ts +1 -0
- package/src/git/lfs.ts +67 -0
- package/src/git/objects.ts +3 -5
- package/src/git/smart-http.ts +56 -6
- package/src/graphql-wire.ts +106 -0
- package/src/grpc-wire.ts +159 -0
- package/src/h2.ts +627 -0
- package/src/head.ts +132 -41
- package/src/history.ts +6 -6
- package/src/hpack.json +1 -0
- package/src/index.ts +82 -329
- package/src/log.ts +27 -18
- package/src/machines.ts +151 -0
- package/src/managed-database.ts +299 -0
- package/src/multipart.ts +51 -0
- package/src/observe.ts +31 -15
- package/src/openai-wire.ts +371 -0
- package/src/pack-assets.ts +15 -11
- package/src/pack-fetch.ts +458 -0
- package/src/pack-paths.ts +72 -0
- package/src/packRegistry.ts +79 -167
- package/src/people.ts +31 -0
- package/src/placeholder-image.ts +88 -0
- package/src/protobuf.ts +251 -0
- package/src/redis/engine.ts +1 -1
- package/src/request-scope.ts +8 -4
- package/src/resource-blob.ts +13 -0
- package/src/runtime.ts +344 -0
- package/src/s3/wire.ts +172 -0
- package/src/scenario.ts +4 -0
- package/src/schema-sample.ts +24 -0
- package/src/sealed-box.ts +182 -0
- package/src/serve-http.ts +31 -3
- package/src/serve.ts +58 -14
- package/src/signing.ts +231 -0
- package/src/sigv4.ts +158 -0
- package/src/smtp.ts +76 -0
- package/src/sockets.ts +140 -0
- package/src/state-system.ts +2 -2
- package/src/storage.ts +3 -3
- package/src/trace-context.ts +1 -1
- package/src/twin-fetch.ts +0 -20
- package/src/vendor-call.ts +41 -0
- package/src/world-store.ts +1 -1
- package/vendor-hosts.cjs +36 -125
- package/vendor-hosts.d.cts +8 -0
- package/dist/src/mirror-shell.d.ts +0 -2
- package/dist/src/mirror-shell.js +0 -13
- package/dist/src/v1-removed.d.ts +0 -159
- package/dist/src/v1-removed.js +0 -124
- package/src/mirror-shell.ts +0 -15
- package/src/v1-removed.ts +0 -172
package/src/protobuf.ts
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// PROTOCOL BUFFERS (architecture, "Other wires": the gRPC wire): a message's proto3 JSON form
|
|
2
|
+
// (https://protobuf.dev/programming-guides/json/) to its binary encoding (https://protobuf.dev/programming-guides/encoding/)
|
|
3
|
+
// and back, over the schema the derive writes for a proto unit (`src/generated/proto.gen.json`, twin-standard's
|
|
4
|
+
// `protoSchema`). A handler reads and answers the JSON form; the wire carries the bytes. The JSON form names a field by
|
|
5
|
+
// its JSON name, writes 64-bit integers as decimal strings, bytes as base64, enums by their value names, a map as an
|
|
6
|
+
// object, and leaves out a field holding its default; `google.protobuf.Timestamp`, `Duration`, the wrappers and `Empty`
|
|
7
|
+
// take their own JSON forms. Importing it does nothing.
|
|
8
|
+
|
|
9
|
+
type Row = Record<string, unknown>;
|
|
10
|
+
export type ProtoField = { name: string; json: string; number: number; type: string; kind: 'scalar' | 'message' | 'enum'; repeated?: true; map?: { key: string; value: string; valueKind: 'scalar' | 'message' | 'enum' } };
|
|
11
|
+
export type ProtoSchema = {
|
|
12
|
+
messages: Record<string, ProtoField[]>;
|
|
13
|
+
enums: Record<string, Record<string, number>>;
|
|
14
|
+
rpcs: Record<string, { operation: string; request: string; response: string; serverStreams?: true; clientStreams?: true }>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const VARINT = new Set(['int32', 'int64', 'uint32', 'uint64', 'sint32', 'sint64', 'bool']);
|
|
18
|
+
const FIXED64 = new Set(['fixed64', 'sfixed64', 'double']);
|
|
19
|
+
const FIXED32 = new Set(['fixed32', 'sfixed32', 'float']);
|
|
20
|
+
const LONG = new Set(['int64', 'uint64', 'sint64', 'fixed64', 'sfixed64']);
|
|
21
|
+
const WRAPPERS: Record<string, string> = {
|
|
22
|
+
'google.protobuf.DoubleValue': 'double', 'google.protobuf.FloatValue': 'float', 'google.protobuf.Int64Value': 'int64',
|
|
23
|
+
'google.protobuf.UInt64Value': 'uint64', 'google.protobuf.Int32Value': 'int32', 'google.protobuf.UInt32Value': 'uint32',
|
|
24
|
+
'google.protobuf.BoolValue': 'bool', 'google.protobuf.StringValue': 'string', 'google.protobuf.BytesValue': 'bytes',
|
|
25
|
+
};
|
|
26
|
+
const ENC = new TextEncoder();
|
|
27
|
+
const DEC = new TextDecoder();
|
|
28
|
+
|
|
29
|
+
const wireOf = (f: { type: string; kind: string }): number =>
|
|
30
|
+
f.kind === 'enum' || VARINT.has(f.type) ? 0 : FIXED64.has(f.type) ? 1 : FIXED32.has(f.type) ? 5 : 2;
|
|
31
|
+
|
|
32
|
+
// ── writing ────────────────────────────────────────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
class Writer {
|
|
35
|
+
private parts: number[] = [];
|
|
36
|
+
varint(v: bigint): void {
|
|
37
|
+
let x = BigInt.asUintN(64, v);
|
|
38
|
+
while (x >= 0x80n) { this.parts.push(Number((x & 0x7fn) | 0x80n)); x >>= 7n; }
|
|
39
|
+
this.parts.push(Number(x));
|
|
40
|
+
}
|
|
41
|
+
tag(number: number, wire: number): void { this.varint((BigInt(number) << 3n) | BigInt(wire)); }
|
|
42
|
+
bytes(b: Uint8Array): void { this.varint(BigInt(b.length)); for (const x of b) this.parts.push(x); }
|
|
43
|
+
raw(b: Uint8Array): void { for (const x of b) this.parts.push(x); }
|
|
44
|
+
fixed(v: bigint | number, size: 4 | 8, float = false): void {
|
|
45
|
+
const buf = new DataView(new ArrayBuffer(size));
|
|
46
|
+
if (float) { if (size === 8) buf.setFloat64(0, Number(v), true); else buf.setFloat32(0, Number(v), true); }
|
|
47
|
+
else if (size === 8) buf.setBigUint64(0, BigInt.asUintN(64, BigInt(v)), true); else buf.setUint32(0, Number(BigInt.asUintN(32, BigInt(v))), true);
|
|
48
|
+
for (const x of new Uint8Array(buf.buffer)) this.parts.push(x);
|
|
49
|
+
}
|
|
50
|
+
done(): Uint8Array { return Uint8Array.from(this.parts); }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const zigzag = (v: bigint, bits: 32 | 64): bigint => (v << 1n) ^ (v >> BigInt(bits - 1));
|
|
54
|
+
const b64decode = (s: string): Uint8Array => Uint8Array.from(atob(s.replace(/-/g, '+').replace(/_/g, '/')), (c) => c.charCodeAt(0));
|
|
55
|
+
const b64encode = (b: Uint8Array): string => btoa(Array.from(b, (x) => String.fromCharCode(x)).join(''));
|
|
56
|
+
|
|
57
|
+
function enumNumber(schema: ProtoSchema, type: string, v: unknown): number {
|
|
58
|
+
if (typeof v === 'number') return v;
|
|
59
|
+
const n = schema.enums[type]?.[String(v)];
|
|
60
|
+
if (n === undefined) throw new Error(`protobuf: ${String(v)} is not a value of ${type}`);
|
|
61
|
+
return n;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function writeScalar(w: Writer, type: string, v: unknown): void {
|
|
65
|
+
switch (type) {
|
|
66
|
+
case 'int32': case 'int64': case 'uint32': case 'uint64': w.varint(BigInt(v as string | number)); break;
|
|
67
|
+
case 'sint32': w.varint(zigzag(BigInt(v as number), 32)); break;
|
|
68
|
+
case 'sint64': w.varint(zigzag(BigInt(v as string), 64)); break;
|
|
69
|
+
case 'bool': w.varint(v ? 1n : 0n); break;
|
|
70
|
+
case 'fixed64': case 'sfixed64': w.fixed(BigInt(v as string), 8); break;
|
|
71
|
+
case 'double': w.fixed(Number(v), 8, true); break;
|
|
72
|
+
case 'fixed32': case 'sfixed32': w.fixed(Number(v), 4); break;
|
|
73
|
+
case 'float': w.fixed(Number(v), 4, true); break;
|
|
74
|
+
default: throw new Error(`protobuf: ${type} is not a packable scalar`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A well-known type's JSON form as the message it stands for, or undefined for any other type. */
|
|
79
|
+
function wellKnownIn(type: string, v: unknown): Row | undefined {
|
|
80
|
+
if (type === 'google.protobuf.Timestamp' && typeof v === 'string') {
|
|
81
|
+
const ms = Date.parse(v);
|
|
82
|
+
const frac = /\.(\d+)/.exec(v)?.[1] ?? '';
|
|
83
|
+
return { seconds: String(Math.floor(ms / 1000)), nanos: Number(frac.padEnd(9, '0').slice(0, 9)) };
|
|
84
|
+
}
|
|
85
|
+
if (type === 'google.protobuf.Duration' && typeof v === 'string') {
|
|
86
|
+
const [s, f = ''] = v.replace(/s$/, '').split('.');
|
|
87
|
+
return { seconds: s, nanos: (s!.startsWith('-') ? -1 : 1) * Number(f.padEnd(9, '0').slice(0, 9)) };
|
|
88
|
+
}
|
|
89
|
+
if (WRAPPERS[type] !== undefined) return { value: v };
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function writeValue(schema: ProtoSchema, w: Writer, f: { number: number; type: string; kind: string }, v: unknown): void {
|
|
94
|
+
if (f.kind === 'message') { w.tag(f.number, 2); w.bytes(encodeMessage(schema, f.type, v)); return; }
|
|
95
|
+
if (f.kind === 'enum') { w.tag(f.number, 0); w.varint(BigInt(enumNumber(schema, f.type, v))); return; }
|
|
96
|
+
if (f.type === 'string') { w.tag(f.number, 2); w.bytes(ENC.encode(String(v))); return; }
|
|
97
|
+
if (f.type === 'bytes') { w.tag(f.number, 2); w.bytes(typeof v === 'string' ? b64decode(v) : (v as Uint8Array)); return; }
|
|
98
|
+
w.tag(f.number, wireOf(f)); writeScalar(w, f.type, v);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A message's JSON form (proto3 JSON) as its binary encoding. */
|
|
102
|
+
export function encodeMessage(schema: ProtoSchema, type: string, value: unknown): Uint8Array {
|
|
103
|
+
const known = wellKnownIn(type, value);
|
|
104
|
+
const v = (known ?? (value && typeof value === 'object' ? value : {})) as Row;
|
|
105
|
+
const fields = schema.messages[type];
|
|
106
|
+
if (!fields) throw new Error(`protobuf: ${type} is not a message of the schema`);
|
|
107
|
+
const w = new Writer();
|
|
108
|
+
for (const f of fields) {
|
|
109
|
+
const x = v[f.json] ?? v[f.name];
|
|
110
|
+
if (x === undefined || x === null) continue;
|
|
111
|
+
if (f.map) {
|
|
112
|
+
for (const [k, mv] of Object.entries(x as Row)) {
|
|
113
|
+
const entry = new Writer();
|
|
114
|
+
const keyType = f.map.key;
|
|
115
|
+
writeValue(schema, entry, { number: 1, type: keyType, kind: 'scalar' }, keyType === 'bool' ? k === 'true' : k);
|
|
116
|
+
writeValue(schema, entry, { number: 2, type: f.map.value, kind: f.map.valueKind }, mv);
|
|
117
|
+
w.tag(f.number, 2); w.bytes(entry.done());
|
|
118
|
+
}
|
|
119
|
+
} else if (f.repeated) {
|
|
120
|
+
const list = x as unknown[];
|
|
121
|
+
if (f.kind === 'enum' || (f.kind === 'scalar' && f.type !== 'string' && f.type !== 'bytes')) {
|
|
122
|
+
// proto3 packs repeated scalars and enums
|
|
123
|
+
const packed = new Writer();
|
|
124
|
+
for (const item of list) { if (f.kind === 'enum') packed.varint(BigInt(enumNumber(schema, f.type, item))); else writeScalar(packed, f.type, item); }
|
|
125
|
+
w.tag(f.number, 2); w.bytes(packed.done());
|
|
126
|
+
} else for (const item of list) writeValue(schema, w, f, item);
|
|
127
|
+
} else writeValue(schema, w, f, x);
|
|
128
|
+
}
|
|
129
|
+
return w.done();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ── reading ────────────────────────────────────────────────────────────────────────────────────
|
|
133
|
+
|
|
134
|
+
class Reader {
|
|
135
|
+
at = 0;
|
|
136
|
+
constructor(readonly b: Uint8Array) {}
|
|
137
|
+
get done(): boolean { return this.at >= this.b.length; }
|
|
138
|
+
varint(): bigint {
|
|
139
|
+
let out = 0n; let shift = 0n;
|
|
140
|
+
for (;;) {
|
|
141
|
+
if (this.at >= this.b.length) throw new Error('protobuf: a varint runs past the end');
|
|
142
|
+
const x = this.b[this.at++]!;
|
|
143
|
+
out |= BigInt(x & 0x7f) << shift;
|
|
144
|
+
if (!(x & 0x80)) return out;
|
|
145
|
+
shift += 7n;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
take(n: number): Uint8Array {
|
|
149
|
+
if (n < 0 || this.at + n > this.b.length) throw new Error(`protobuf: a field runs past the message's end (${n} bytes at ${this.at} of ${this.b.length})`);
|
|
150
|
+
const out = this.b.subarray(this.at, this.at + n); this.at += n; return out;
|
|
151
|
+
}
|
|
152
|
+
bytes(): Uint8Array { return this.take(Number(this.varint())); }
|
|
153
|
+
skip(wire: number): void {
|
|
154
|
+
if (wire === 0) this.varint(); else if (wire === 1) this.take(8); else if (wire === 5) this.take(4); else if (wire === 2) this.bytes();
|
|
155
|
+
else throw new Error(`protobuf: wire type ${wire} is not supported`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const unzigzag = (v: bigint): bigint => (v >> 1n) ^ -(v & 1n);
|
|
160
|
+
|
|
161
|
+
function readScalar(r: Reader, type: string): unknown {
|
|
162
|
+
switch (type) {
|
|
163
|
+
case 'int32': return Number(BigInt.asIntN(32, r.varint()));
|
|
164
|
+
case 'uint32': return Number(BigInt.asUintN(32, r.varint()));
|
|
165
|
+
case 'int64': return String(BigInt.asIntN(64, r.varint()));
|
|
166
|
+
case 'uint64': return String(BigInt.asUintN(64, r.varint()));
|
|
167
|
+
case 'sint32': return Number(unzigzag(r.varint()));
|
|
168
|
+
case 'sint64': return String(unzigzag(r.varint()));
|
|
169
|
+
case 'bool': return r.varint() !== 0n;
|
|
170
|
+
case 'fixed64': return String(new DataView(r.take(8).slice().buffer).getBigUint64(0, true));
|
|
171
|
+
case 'sfixed64': return String(new DataView(r.take(8).slice().buffer).getBigInt64(0, true));
|
|
172
|
+
case 'double': return new DataView(r.take(8).slice().buffer).getFloat64(0, true);
|
|
173
|
+
case 'fixed32': return new DataView(r.take(4).slice().buffer).getUint32(0, true);
|
|
174
|
+
case 'sfixed32': return new DataView(r.take(4).slice().buffer).getInt32(0, true);
|
|
175
|
+
case 'float': return new DataView(r.take(4).slice().buffer).getFloat32(0, true);
|
|
176
|
+
default: throw new Error(`protobuf: ${type} is not a scalar`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function enumName(schema: ProtoSchema, type: string, n: number): string | number {
|
|
181
|
+
for (const [name, v] of Object.entries(schema.enums[type] ?? {})) if (v === n) return name;
|
|
182
|
+
return n;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function readValue(schema: ProtoSchema, r: Reader, f: { type: string; kind: string }, wire: number): unknown {
|
|
186
|
+
if (f.kind === 'message') return decodeMessage(schema, f.type, r.bytes());
|
|
187
|
+
if (f.kind === 'enum') return enumName(schema, f.type, Number(BigInt.asIntN(32, r.varint())));
|
|
188
|
+
if (f.type === 'string') return DEC.decode(r.bytes());
|
|
189
|
+
if (f.type === 'bytes') return b64encode(r.bytes());
|
|
190
|
+
void wire;
|
|
191
|
+
return readScalar(r, f.type);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** A well-known message's JSON form from its decoded fields, or the fields as they are for any other type. */
|
|
195
|
+
function wellKnownOut(type: string, m: Row): unknown {
|
|
196
|
+
if (type === 'google.protobuf.Timestamp') {
|
|
197
|
+
const whole = new Date(Number(m.seconds ?? 0) * 1000).toISOString().replace(/\.000Z$/, '');
|
|
198
|
+
const nanos = Number(m.nanos ?? 0);
|
|
199
|
+
return `${whole}${protoFraction(nanos)}Z`;
|
|
200
|
+
}
|
|
201
|
+
if (type === 'google.protobuf.Duration') {
|
|
202
|
+
const seconds = BigInt(String(m.seconds ?? '0'));
|
|
203
|
+
const nanos = Number(m.nanos ?? 0);
|
|
204
|
+
const negative = seconds < 0n || nanos < 0;
|
|
205
|
+
return `${negative ? '-' : ''}${seconds < 0n ? -seconds : seconds}${protoFraction(Math.abs(nanos))}s`;
|
|
206
|
+
}
|
|
207
|
+
if (WRAPPERS[type] !== undefined) return m.value ?? (WRAPPERS[type] === 'bool' ? false : WRAPPERS[type] === 'string' || WRAPPERS[type] === 'bytes' ? '' : 0);
|
|
208
|
+
return m;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** ProtoJSON emits 0, 3, 6 or 9 fractional digits, retaining the full nanosecond value. */
|
|
212
|
+
function protoFraction(nanos: number): string {
|
|
213
|
+
if (!nanos) return '';
|
|
214
|
+
const digits = String(nanos).padStart(9, '0');
|
|
215
|
+
return `.${digits.slice(0, nanos % 1e6 === 0 ? 3 : nanos % 1000 === 0 ? 6 : 9)}`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** A message's binary encoding as its JSON form (proto3 JSON; a field at its default is left out). */
|
|
219
|
+
export function decodeMessage(schema: ProtoSchema, type: string, bytes: Uint8Array): unknown {
|
|
220
|
+
const fields = schema.messages[type];
|
|
221
|
+
if (!fields) throw new Error(`protobuf: ${type} is not a message of the schema`);
|
|
222
|
+
const byNumber = new Map(fields.map((f) => [f.number, f] as const));
|
|
223
|
+
const out: Row = {};
|
|
224
|
+
const r = new Reader(bytes);
|
|
225
|
+
while (!r.done) {
|
|
226
|
+
const key = Number(r.varint());
|
|
227
|
+
const number = key >>> 3;
|
|
228
|
+
const wire = key & 7;
|
|
229
|
+
const f = byNumber.get(number);
|
|
230
|
+
if (!f) { r.skip(wire); continue; }
|
|
231
|
+
if (f.map) {
|
|
232
|
+
const entry = new Reader(r.bytes());
|
|
233
|
+
let k: unknown; let v: unknown;
|
|
234
|
+
while (!entry.done) {
|
|
235
|
+
const ek = Number(entry.varint());
|
|
236
|
+
if ((ek >>> 3) === 1) k = readValue(schema, entry, { type: f.map.key, kind: 'scalar' }, ek & 7);
|
|
237
|
+
else if ((ek >>> 3) === 2) v = readValue(schema, entry, { type: f.map.value, kind: f.map.valueKind }, ek & 7);
|
|
238
|
+
else entry.skip(ek & 7);
|
|
239
|
+
}
|
|
240
|
+
((out[f.json] ??= {}) as Row)[String(k ?? '')] = v;
|
|
241
|
+
} else if (f.repeated) {
|
|
242
|
+
const list = (out[f.json] ??= []) as unknown[];
|
|
243
|
+
// a packed run of scalars or enums, or one element
|
|
244
|
+
if (wire === 2 && (f.kind === 'enum' || (f.kind === 'scalar' && f.type !== 'string' && f.type !== 'bytes'))) {
|
|
245
|
+
const packed = new Reader(r.bytes());
|
|
246
|
+
while (!packed.done) list.push(f.kind === 'enum' ? enumName(schema, f.type, Number(BigInt.asIntN(32, packed.varint()))) : readScalar(packed, f.type));
|
|
247
|
+
} else list.push(readValue(schema, r, f, wire));
|
|
248
|
+
} else out[f.json] = readValue(schema, r, f, wire);
|
|
249
|
+
}
|
|
250
|
+
return wellKnownOut(type, out);
|
|
251
|
+
}
|
package/src/redis/engine.ts
CHANGED
|
@@ -84,7 +84,7 @@ export class ReadOnlyError extends Error {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
/** Redis's type name for a stream, as TYPE answers it (a Redis type, not
|
|
87
|
+
/** Redis's type name for a stream, as TYPE answers it (a Redis type, not a pack name: scripts/architecture-auto.ts A2). */
|
|
88
88
|
const STREAM = 'stream' as const;
|
|
89
89
|
export const KEY_TYPES = ['string', 'list', 'set', 'hash', 'zset', STREAM] as const;
|
|
90
90
|
export type KeyType = typeof KEY_TYPES[number];
|
package/src/request-scope.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// runs under `runAsVendorMove` and still lands under a read-only request, as a real vendor renews a
|
|
12
12
|
// subscription whoever is looking.
|
|
13
13
|
//
|
|
14
|
-
// Created on first use, never at import: a browser bundle
|
|
14
|
+
// Created on first use, never at import: a browser bundle carries the kernel and
|
|
15
15
|
// has no AsyncLocalStorage (see serve.ts identitySlot).
|
|
16
16
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
17
17
|
import { runWithTraceparent, traceparentForDelivery } from './trace-context.ts';
|
|
@@ -26,9 +26,13 @@ export function isReadOnlyRequest(request: Request | { headers: Headers }): bool
|
|
|
26
26
|
|
|
27
27
|
/** A write a read-only request attempted: refused before anything was written (rule D3's 405). */
|
|
28
28
|
export class ReadOnlyRequestError extends Error {
|
|
29
|
-
|
|
29
|
+
// a field, not a parameter property: Node runs this module with its types stripped (an application importing the
|
|
30
|
+
// World clock), and stripping takes no parameter property
|
|
31
|
+
readonly service: string;
|
|
32
|
+
constructor(service: string) {
|
|
30
33
|
super(`${service}: this request is read-only (${READ_ONLY_REQUEST_HEADER}: 1); it cannot write`);
|
|
31
34
|
this.name = 'ReadOnlyRequestError';
|
|
35
|
+
this.service = service;
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -53,14 +57,14 @@ export async function runAsReadOnlyRequest<T>(fn: () => T | Promise<T>): Promise
|
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
/** Run `fn` as the VENDOR's own move (a pack's catch-up): its writes land even under a read-only
|
|
56
|
-
* request
|
|
60
|
+
* request, and are recorded as the World's own moves, never as the caller's API call (inVendorMove). */
|
|
57
61
|
export function runAsVendorMove<T>(fn: () => T): T {
|
|
58
62
|
const current = writeScope().getStore();
|
|
59
63
|
// the vendor's move is its own span of the request's trace (a delivery's shape): what it writes is joined to the
|
|
60
64
|
// trace, never to the request's caller, who did not make it
|
|
61
65
|
const own = traceparentForDelivery();
|
|
62
66
|
const run = own ? () => runWithTraceparent(own, fn) : fn;
|
|
63
|
-
return
|
|
67
|
+
return writeScope().run(current ? { ...current, vendorMove: true } : { readOnly: false, vendorMove: true, refusals: [] }, run);
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
/** Whether this runs as the vendor's own move (runAsVendorMove). */
|
package/src/resource-blob.ts
CHANGED
|
@@ -13,6 +13,19 @@ export async function readResourceBlob(service: string, key: string, root?: stri
|
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/** Write a resource payload on this branch (a stored object's bytes), where a read finds it first. */
|
|
17
|
+
export async function writeResourceBlob(service: string, key: string, bytes: Uint8Array, root?: string): Promise<void> {
|
|
18
|
+
assertResourceKey(key);
|
|
19
|
+
await getActiveBlobStore().put(join(worldPaths(service, root).resources, key), bytes);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Remove this branch's copy of a resource payload; an ancestor's stays its own (the row that named it is what a
|
|
23
|
+
* deletion ends). */
|
|
24
|
+
export async function removeResourceBlob(service: string, key: string, root?: string): Promise<void> {
|
|
25
|
+
assertResourceKey(key);
|
|
26
|
+
await getActiveBlobStore().remove(join(worldPaths(service, root).resources, key));
|
|
27
|
+
}
|
|
28
|
+
|
|
16
29
|
/** A service's resources dir at this branch, then at each retained ancestor's: where a read resolves a payload, and
|
|
17
30
|
* what a listing that mints ids covers, so a branch serves bytes its parent received and never re-mints a parent's id. */
|
|
18
31
|
export function resourceChain(service: string, root?: string): string[] {
|
package/src/runtime.ts
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
// @volter/world-core/runtime — the kernel itself and the vendor-independent runtime libraries: the log and the tree
|
|
2
|
+
// read and written directly, checkpoints, branches, landing and receipts, the head, the stores, the runtime's scopes and
|
|
3
|
+
// clocks, and the plugin contract's surfaces. It is the runtime's, the CLI's, the host's and the tooling's. A Protocol 3
|
|
4
|
+
// pack never imports it: its contract is the root, `@volter/world-core` (docs/contributing/architecture.md, "The pack
|
|
5
|
+
// contract: the kernel's root"). Removed v1 entry points fail explicitly. Conformance and validation tooling lives in
|
|
6
|
+
// @volter/world-tooling, a dev dependency.
|
|
7
|
+
// Pack registry — vendor twins self-describe (TwinPack) so tooling discovers them.
|
|
8
|
+
export { clearRegistry, getPack, hasPack, listPacks, packOf, registerPack, pullPosture, assertContinuousPullAllowed, pullOnSchedule, resolvePullVendor, DEFAULT_PULL_POSTURE, DEFAULT_PULL_TRIGGER, PROTOCOL_VERSION, PROTOCOL_MAJOR, protocolStanding } from './packRegistry.ts';
|
|
9
|
+
export type { PackTransport, PullPosture, PullTrigger, PullVendor, RoundTripWrite, TwinPack } from './packRegistry.ts';
|
|
10
|
+
// The DELIVER verb (`emit`) — vendor-agnostic engine + CLI glue; packs declare a TwinEmitter
|
|
11
|
+
// (their event catalog, endpoints-from-state, and signed synthesis) on `TwinPack.emitter`.
|
|
12
|
+
export { parseScenarioDocument, scenarioFaultResult, ScenarioEngine, ScenarioError, statefulTwinManifest, twinManifest } from './scenario.ts';
|
|
13
|
+
export { WORLD_CLOCK_ENV, worldNow } from './world-clock.ts';
|
|
14
|
+
export { WORLD_ENV_NAMES_ENV, worldEnvValue } from './world-env.ts';
|
|
15
|
+
export { createTwinFetchFromHandler, TWIN_PREFIX_HEADER, TWIN_REQUEST_SCOPES, twinPublicBase, withRequestScopes } from './twin-fetch.ts';
|
|
16
|
+
export { isReadOnlyRequest, READ_ONLY_REQUEST_HEADER, ReadOnlyRequestError, runAsReadOnlyRequest, runAsVendorMove, writesRefused } from './request-scope.ts';
|
|
17
|
+
export { compileSurface, createDerivedFetch, matchOperation } from './derived.ts';
|
|
18
|
+
export { currentTraceparent, deliveryTraceHeaders, newTraceparent, parseTraceparent, runWithRequestTrace, runWithTraceparent, TRACEPARENT_HEADER, traceparentForDelivery, validTraceparent } from './trace-context.ts';
|
|
19
|
+
export type { Traceparent } from './trace-context.ts';
|
|
20
|
+
export type { DerivedCall, DerivedCoreOutcome, DerivedFetch, DerivedFetchOptions, DerivedHandler, DerivedOperation, DerivedOwner, DerivedSurface } from './derived.ts';
|
|
21
|
+
export { authRefusal, bindSemantics, coreFor, crossCutting, flagOf, derivedRequestScopes, observeTransitions, resourcesOfType as twinResourcesOfType, semanticsContext, stateOf, transitionFor, parseBracketForm, readParams, render as renderDerived, serveCore, sse, vendorError } from './derived-core.ts';
|
|
22
|
+
export { deliverEvents, fillEnvelope, signEvent, signEventAll, verifyEvent } from './events.ts';
|
|
23
|
+
export { equalSecrets, hmac, jwks, jwtDecode, jwtSign, jwtVerify, keyId, lettersFrom, md5, sha256, SIGNING_ALGORITHMS, uuidFrom } from './signing.ts';
|
|
24
|
+
export type { HandlerCrypto, Jwk, Jwks, JwtVerdict, SigningKey } from './signing.ts';
|
|
25
|
+
export type { EventDelivery, EventRender, EventScheme, EventsDecl, EventTransport, EventWrite } from './events.ts';
|
|
26
|
+
export type { Actor, CoreScope, DerivedManifest, ErrorSpec, FieldRule, Handler, HandlerContext, ResourceDecl, WriteHookContext, ScreenDecl, Semantics, SemanticsContext, StateField, Transition, TransitionObserver, SeedCall } from './derived-core.ts';
|
|
27
|
+
export type { RemoteExecute, RemoteExecuteRequest, RemoteExecuteResponse } from './remote-execute.ts';
|
|
28
|
+
export type { TwinFetchAdapterConfig, TwinFetchHandlerRequest, TwinFetchHandlerResult, TwinStream, TwinStreamConnection, TwinStreamSink } from './twin-fetch.ts';
|
|
29
|
+
export type { PackScenarioAdapter, ScenarioDecision, ScenarioDocument, ScenarioExtractorSpec, ScenarioFault, ScenarioFaultResult, ScenarioFeatures, ScenarioHandler, ScenarioMatcher, ScenarioMissRecord, ScenarioStatus } from './scenario.ts';
|
|
30
|
+
export { emitTwinEvent, eventSubscriptionMatches, listEmittable, runEmitCli } from './emit.ts';
|
|
31
|
+
export type { EmitDeliveryResult, EmitEndpoint, EmitReport, EmittableEvent, SynthesizedDelivery, TwinEmitter } from './emit.ts';
|
|
32
|
+
// The vendor-agnostic CLIENT-SIDE RATE BUDGET — the fail-closed backstop a pack's guarded client
|
|
33
|
+
// routes every live vendor call through. The MECHANISM is here; the per-vendor ceiling/window/
|
|
34
|
+
// weights are DATA the pack declares (`TwinPack.rateBudget` / `declareRateBudget`). Exported so an
|
|
35
|
+
// operator can inspect spend (`snapshot`) and a caller can catch `RateBudgetError` by type; there
|
|
36
|
+
// is deliberately no export that disables the guard, and a vendor with no declaration falls back
|
|
37
|
+
// to `DEFAULT_RATE_BUDGET` rather than to no limit at all.
|
|
38
|
+
export {
|
|
39
|
+
DEFAULT_RATE_BUDGET,
|
|
40
|
+
MAX_RATE_BUDGET_CEILING,
|
|
41
|
+
MAX_RATE_BUDGET_WINDOW_MS,
|
|
42
|
+
MIN_RATE_BUDGET_WEIGHT,
|
|
43
|
+
MIN_RATE_BUDGET_WINDOW_MS,
|
|
44
|
+
RateBudget,
|
|
45
|
+
RateBudgetError,
|
|
46
|
+
declareRateBudget,
|
|
47
|
+
hasRateBudgetDeclaration,
|
|
48
|
+
listRateBudgets,
|
|
49
|
+
priceCall,
|
|
50
|
+
rateBudgetPath,
|
|
51
|
+
rateBudgetPolicy,
|
|
52
|
+
rateBudgetWeight,
|
|
53
|
+
resetToSeconds,
|
|
54
|
+
assertBudgetGuardIntact,
|
|
55
|
+
} from './rateBudget.ts';
|
|
56
|
+
export type {
|
|
57
|
+
RateBudgetDeclaration,
|
|
58
|
+
RateBudgetErrorKind,
|
|
59
|
+
RateBudgetOptions,
|
|
60
|
+
RateBudgetPolicy,
|
|
61
|
+
RateBudgetReservation,
|
|
62
|
+
RateBudgetSnapshot,
|
|
63
|
+
RateBudgetWeightRule,
|
|
64
|
+
} from './rateBudget.ts';
|
|
65
|
+
export {
|
|
66
|
+
GenericWorldStateSchema,
|
|
67
|
+
WorldActorSchema,
|
|
68
|
+
WorldExternalRefSchema,
|
|
69
|
+
WorldServiceEventSchema,
|
|
70
|
+
WorldSubjectSchema,
|
|
71
|
+
} from './schemas.ts';
|
|
72
|
+
// NOTE: source books (event→tracker-source mapping) moved OUT of the world — it was
|
|
73
|
+
// the last tracker coupling. It now lives at `@volter/tracker/world-source-books`,
|
|
74
|
+
// so `@volter/world-core` is a pure twin runtime.
|
|
75
|
+
export {
|
|
76
|
+
loadWorldConfig,
|
|
77
|
+
} from './worldConfig.ts';
|
|
78
|
+
export type {
|
|
79
|
+
WorldConfig,
|
|
80
|
+
WorldServiceConfig,
|
|
81
|
+
} from './worldConfig.ts';
|
|
82
|
+
export {
|
|
83
|
+
DELTA_TYPE_SUFFIX,
|
|
84
|
+
diffSubjectFields,
|
|
85
|
+
hashFieldValue,
|
|
86
|
+
subjectKey, deltaAfterFields } from './hash.ts';
|
|
87
|
+
export type {
|
|
88
|
+
FieldChange,
|
|
89
|
+
SubjectFields,
|
|
90
|
+
} from './hash.ts';
|
|
91
|
+
export {
|
|
92
|
+
appendDurable,
|
|
93
|
+
appendEvent,
|
|
94
|
+
createEvent,
|
|
95
|
+
emptyGenericState,
|
|
96
|
+
genericWorldReducer,
|
|
97
|
+
listEvents,
|
|
98
|
+
loadState,
|
|
99
|
+
projectionLockPath,
|
|
100
|
+
readJsonFile,
|
|
101
|
+
rebuildGenericState,
|
|
102
|
+
rebuildState,
|
|
103
|
+
// Scrub: delete pulled data at rest (TWIN-45) — the honest, plain-`rm` counterpart to
|
|
104
|
+
// sync pull's fold-into-the-log. See docs/concepts/data-and-keys.md for the full data-at-rest story.
|
|
105
|
+
scrubService,
|
|
106
|
+
scrubWorld,
|
|
107
|
+
stateDirName,
|
|
108
|
+
// Opt-in structured stderr logging (VOLTER_TWIN_LOG=1) for the audit trail. Public so a
|
|
109
|
+
// CONNECTOR can say on the same stream when the vendor handed it a truncated page — a
|
|
110
|
+
// silent shortfall is the one thing a pull must never pass off as the whole resource.
|
|
111
|
+
twinLog,
|
|
112
|
+
// The kernel's cross-process mutual-exclusion primitive (exclusive-create lockfile with
|
|
113
|
+
// stale-holder reclaim). Public so world-runtime can guard concurrent `upWorld` claims of
|
|
114
|
+
// one instance dir with the SAME lock semantics the event log uses (TWIN-36).
|
|
115
|
+
withFileLock,
|
|
116
|
+
worldPaths,
|
|
117
|
+
worldStateRoot,
|
|
118
|
+
// Where another pack's store is in a World (architecture A3), and the variable the runtime names its data directory in.
|
|
119
|
+
ownerStoreRoots,
|
|
120
|
+
WORLD_DATA_ENV,
|
|
121
|
+
} from './storage.ts';
|
|
122
|
+
export type {
|
|
123
|
+
AppendEventResult,
|
|
124
|
+
CommitQueuedEventsResult,
|
|
125
|
+
GenericWorldState,
|
|
126
|
+
EnqueueEventResult,
|
|
127
|
+
QueuedWorldServiceEvent,
|
|
128
|
+
WorldPaths,
|
|
129
|
+
WorldReducer,
|
|
130
|
+
WorldServiceEvent,
|
|
131
|
+
} from './types.ts';
|
|
132
|
+
export type { ScrubResult } from './storage.ts';
|
|
133
|
+
// The pluggable persistence seam: the sync WorldStore interface, its fs (default) and
|
|
134
|
+
// in-memory implementations, the active-store injection point, and the async
|
|
135
|
+
// hydrate/flush boundary a serverless (Durable Object / KV / redis) entry uses.
|
|
136
|
+
export {
|
|
137
|
+
FsWorldStore,
|
|
138
|
+
MemoryWorldStore,
|
|
139
|
+
getActiveWorldStore,
|
|
140
|
+
setActiveWorldStore,
|
|
141
|
+
withWorldStore,
|
|
142
|
+
hydrateInto,
|
|
143
|
+
flushFrom,
|
|
144
|
+
} from './world-store.ts';
|
|
145
|
+
export type { WorldStore, WorldStat, HydrationSource, HydrationSink } from './world-store.ts';
|
|
146
|
+
export type { CheckLoader } from './head.ts';
|
|
147
|
+
export { SqlWorldStore } from './world-store-sql.ts';
|
|
148
|
+
export type { SqlExec } from './world-store-sql.ts';
|
|
149
|
+
// The blob seam (runtime contract R11): byte storage behind byte-carrying handlers, so a
|
|
150
|
+
// serverless namespace puts bytes in object storage while local worlds keep today's layout.
|
|
151
|
+
export {
|
|
152
|
+
FsBlobStore,
|
|
153
|
+
MemoryBlobStore,
|
|
154
|
+
blobDigest,
|
|
155
|
+
getActiveBlobStore,
|
|
156
|
+
setActiveBlobStore,
|
|
157
|
+
withBlobStore,
|
|
158
|
+
readBlobRange,
|
|
159
|
+
} from './blob-store.ts';
|
|
160
|
+
export type { BlobStore } from './blob-store.ts';
|
|
161
|
+
export {
|
|
162
|
+
applyTwinWrite,
|
|
163
|
+
applyTwinWriteAtomic,
|
|
164
|
+
createTwinServer,
|
|
165
|
+
CALLER_HEADER,
|
|
166
|
+
callerForHeader,
|
|
167
|
+
callerFromHeader,
|
|
168
|
+
journalTwinRequest,
|
|
169
|
+
readTwinRequestJournalFrom,
|
|
170
|
+
type TwinRequestJournalCursor,
|
|
171
|
+
twinRequestJournalFailures,
|
|
172
|
+
twinRequestCredentials,
|
|
173
|
+
readTwinRequestJournal,
|
|
174
|
+
recordedInput,
|
|
175
|
+
resolveTwinRead,
|
|
176
|
+
twinRequestJournalEnabled,
|
|
177
|
+
twinRequestJournalPath,
|
|
178
|
+
twinResources,
|
|
179
|
+
} from './serve.ts';
|
|
180
|
+
export type {
|
|
181
|
+
AtomicTwinWriteDecision,
|
|
182
|
+
TwinRequestJournalEntry,
|
|
183
|
+
TwinResource,
|
|
184
|
+
TwinWriteInput,
|
|
185
|
+
TwinWriteResult,
|
|
186
|
+
} from './serve.ts';
|
|
187
|
+
export { createTwinProxy } from './proxy.ts';
|
|
188
|
+
export type { TwinProxy, TwinProxyOptions, VendorRoute } from './proxy.ts';
|
|
189
|
+
export {
|
|
190
|
+
forkTwin,
|
|
191
|
+
isFork,
|
|
192
|
+
readForkMeta,
|
|
193
|
+
} from './fork.ts';
|
|
194
|
+
export type { ForkMeta } from './fork.ts';
|
|
195
|
+
export {
|
|
196
|
+
appendAction,
|
|
197
|
+
appendTransactionCommit,
|
|
198
|
+
checkPrecondition,
|
|
199
|
+
confirmAction,
|
|
200
|
+
listActions,
|
|
201
|
+
listTransactionCommits,
|
|
202
|
+
pendingActions,
|
|
203
|
+
pushablePendingActions,
|
|
204
|
+
isTwinBookkeeping,
|
|
205
|
+
pendingTransactionCommits,
|
|
206
|
+
projectResources,
|
|
207
|
+
projectOwnerResources,
|
|
208
|
+
OwnerStoreAmbiguousError,
|
|
209
|
+
revertAction,
|
|
210
|
+
TwinActionPreconditionError, subjectAliases, resolveSubjectId, runWithCorrelationId, currentCorrelationId } from './actions.ts';
|
|
211
|
+
export type {
|
|
212
|
+
ActionProjection,
|
|
213
|
+
ProjectedDelivery,
|
|
214
|
+
ProjectedResource,
|
|
215
|
+
ProjectedResourcePatch,
|
|
216
|
+
ProjectedResourceRef,
|
|
217
|
+
TwinAction,
|
|
218
|
+
TwinActionOp,
|
|
219
|
+
TwinActionPrecondition,
|
|
220
|
+
TwinActionPreconditionOp,
|
|
221
|
+
TwinActionRevertSpec,
|
|
222
|
+
TwinTransactionCommit,
|
|
223
|
+
TwinTransactionCommitOp,
|
|
224
|
+
TwinTransactionPrecondition,
|
|
225
|
+
TwinTransactionRevertSpec,
|
|
226
|
+
} from './actions.ts';
|
|
227
|
+
// ── Operator control plane (R19/R20): remote refs, queue lifecycle, push ledger,
|
|
228
|
+
// apply leases, plan, status. (the twins architecture notes)
|
|
229
|
+
// The CHANGESET primitive + the ledger DIFF (docs/concepts/the-model.md v0) — "commit" and
|
|
230
|
+
// "diff" for operational reality: a cross-service base marker, the ledger delta since it, and
|
|
231
|
+
// the content-addressed, replayable changeset over that delta. State-level by construction
|
|
232
|
+
// (it reads the same per-service action ledgers `actions.ts` writes); `volter-world` supplies
|
|
233
|
+
// world discovery and thin verbs on top.
|
|
234
|
+
export {
|
|
235
|
+
approveChangeset,
|
|
236
|
+
assertMarkerBelongsTo,
|
|
237
|
+
assertSafeChangesetName,
|
|
238
|
+
assertValidVerifiers,
|
|
239
|
+
buildChangeset,
|
|
240
|
+
captureMarker,
|
|
241
|
+
changesetContentHash,
|
|
242
|
+
changesetHashMatches,
|
|
243
|
+
changesetReadiness,
|
|
244
|
+
approverOf,
|
|
245
|
+
CHANGESET_KIND,
|
|
246
|
+
diffLedgers,
|
|
247
|
+
formatApplication,
|
|
248
|
+
formatChangeset,
|
|
249
|
+
formatRebaseReport,
|
|
250
|
+
narrateActions,
|
|
251
|
+
narrationDrift,
|
|
252
|
+
rebaseChangeset,
|
|
253
|
+
formatChangesetStatus,
|
|
254
|
+
formatLedgerDelta,
|
|
255
|
+
formatReplayReport,
|
|
256
|
+
formatVerification,
|
|
257
|
+
MARKER_KIND,
|
|
258
|
+
normalizeChangeset,
|
|
259
|
+
parseVerifierExpression,
|
|
260
|
+
replayChangeset,
|
|
261
|
+
runChangesetVerifiers,
|
|
262
|
+
summarizeByVendor,
|
|
263
|
+
twinWriteShape,
|
|
264
|
+
withApplication,
|
|
265
|
+
withVerification,
|
|
266
|
+
worldBootMarker,
|
|
267
|
+
WORLD_BOOT_MARKER_ID,
|
|
268
|
+
} from './changeset.ts';
|
|
269
|
+
export type {
|
|
270
|
+
ApplyReceipt,
|
|
271
|
+
RebaseActionResult,
|
|
272
|
+
RebaseReport,
|
|
273
|
+
RebaseTarget,
|
|
274
|
+
Changeset,
|
|
275
|
+
ChangesetAction,
|
|
276
|
+
ChangesetApplication,
|
|
277
|
+
CompensationEntry,
|
|
278
|
+
ChangesetApproval,
|
|
279
|
+
ChangesetReadiness,
|
|
280
|
+
ChangesetVerification,
|
|
281
|
+
ChangesetVerifier,
|
|
282
|
+
ChangesetVerifierResult,
|
|
283
|
+
LedgerDelta,
|
|
284
|
+
LedgerPosition,
|
|
285
|
+
LedgerRef,
|
|
286
|
+
ReplayActionResult,
|
|
287
|
+
ReplayReport,
|
|
288
|
+
ReplayTarget,
|
|
289
|
+
VendorSummary,
|
|
290
|
+
WorldMarker,
|
|
291
|
+
} from './changeset.ts';
|
|
292
|
+
export { getActivePackAssets, setActivePackAssets, packAsset, assetContentType, confinedAssetPath, LocalPackAssets, BindingPackAssets, type PackAssetStore } from './pack-assets.ts';
|
|
293
|
+
export { installedPackageDir, packRepository, isDerivedPack, vendorPackageDir, vendorOfPackModule } from './pack-paths.ts';
|
|
294
|
+
|
|
295
|
+
// The git plane (contract "The git plane is a kernel library"): objects, packs, refs, smart HTTP.
|
|
296
|
+
export * as git from './git/index.ts';
|
|
297
|
+
// S3's wire (contract "S3's wire is a kernel library too"): its XML, CORS, lifecycle, delete batches, ETags, body bytes.
|
|
298
|
+
export * as s3 from './s3/wire.ts';
|
|
299
|
+
|
|
300
|
+
// The push arm: the kernel's transaction over a pack's one `perform<Name>Action` (contract section of that name).
|
|
301
|
+
|
|
302
|
+
// The placeholder remote (contract section of that name): the seed is a pull, never a pending write.
|
|
303
|
+
export { PLACEHOLDER_REMOTE, beginPlaceholderPull, endPlaceholderPull, placeholderPullActive, placeholderPullMarkerPath, withPlaceholderPull, placeholderEventsFor } from './placeholder-remote.ts';
|
|
304
|
+
|
|
305
|
+
export { aliasesFrom, ownFields, subjectHistory, rebaseBranch, cutCheckpoint, appendParentEntry, wholeLog, branchEntries, branchLogPath, branchMetaPath, CHECKPOINT_EVERY, dropCheckpoint, foldEntries, landedCopy, landedIds, parentEntries, parentLogPath, position, readBranchMeta, readTree, toEntry, toEvent, unpushedEntries, writeBranchMeta } from './log.ts';
|
|
306
|
+
export type { BranchMeta, Entry, EntryOp, Receipt } from './log.ts';
|
|
307
|
+
export { sealCredential, openSealedCredential, MemoryCredentialStorage, keySealer, transitSealer, type Rewrapped, type Sealer, type TransitSealerOptions, type SealedByVault, type SealedUnderKey } from './credential.ts';
|
|
308
|
+
export type { CredentialPayload, CredentialStorage, SealedCredential } from './credential.ts';
|
|
309
|
+
export { validateRemoteOrigin, buildRemoteExecute, type CredentialCustody } from './executor.ts';
|
|
310
|
+
export type { TwinAuthStrategy } from './executor.ts';
|
|
311
|
+
export { clearRoot, authStrategyFor, clearStateSystems, NO_SECRETS_CHECK, readRoot, registerAuthStrategy, registerStateSystem, rootPath, runChecks, stateSystemFor, writeRoot } from './state-system.ts';
|
|
312
|
+
export type { Check, CheckVerdict, DeployPolicy, RootConfig, StateSystemAdapters } from './state-system.ts';
|
|
313
|
+
export { observeAppends } from './actions.ts';
|
|
314
|
+
export { appendActionIfAbsent, appendActionOccurrence } from './actions.ts';
|
|
315
|
+
|
|
316
|
+
// the head and the fold (company contract "The head", "Refresh is the kernel's fold")
|
|
317
|
+
export { answerVendorErrors, performEntries, performAtHead, deployableEntries, headOf, boundRoot, loadChecks, loadCheck, openRootCredential, resealRootCredential, destinationOf, openSealedRecord, sealsThroughVault, rootCustody, sealingKey, setCheckLoader, setSealingKeySource, setSealer, currentSealer, openSealedAt, userKek, userKekPath, vendorOf, worldRootOf, RefusedWriteError, VendorWriteError, HeadError } from './head.ts';
|
|
318
|
+
export type { BoundRoot, DeployReport, Head, PerformAction, PerformContext, PushOutcome } from './head.ts';
|
|
319
|
+
export { observeResource, observeResources, collectObservations, foldObservations } from './observe.ts';
|
|
320
|
+
export type { ObservedResource, ObserveReport, Observation } from './observe.ts';
|
|
321
|
+
export { readTreeMap, readParentTreeMap, treeStamp, treeChangesSince, originEntries, appendOriginEntry, originLogPath, isUrlParent, parentPosition, positionAt, splitsBatch, assertBatchBoundary } from './log.ts';
|
|
322
|
+
|
|
323
|
+
export { referenceField, registerReferences, packReferences, resolveReferences, type ReferenceDeclaration } from './references.ts';
|
|
324
|
+
// the HTTP server seam: the one place the serve path meets the runtime (Bun or Node)
|
|
325
|
+
export { serveHttp, serveStream, nodeBuiltin, WORLD_BOOT_PATH, type HttpServer, type ServeHttpOptions, type HttpHandler } from './serve-http.ts';
|
|
326
|
+
// two runtime-neutral helpers for a serve path: a file as a Response, a page's client bundle
|
|
327
|
+
export { fileResponse, contentTypeOf } from './file-response.ts';
|
|
328
|
+
export { bundleClient, filePathOf } from './client-bundle.ts';
|
|
329
|
+
// the brand's tokens and faces for a Volter page (the console, the site, the UI kit), fetched at build
|
|
330
|
+
export { brandTokensResponse } from './brand-tokens.ts';
|
|
331
|
+
|
|
332
|
+
export { multipartBoundary, multipartParts, type MultipartPart } from './multipart.ts';
|
|
333
|
+
export { corsHeaders, withCors, type CorsDecl } from './cors.ts';
|
|
334
|
+
export { vendorFetch, VendorUnreachableError } from './vendor-call.ts';
|
|
335
|
+
export { closeManagedDatabases, EngineDatabaseError, EngineUnavailableError, managedDatabase, quoteIdent, useDatabaseDriver, WORLD_CLOCK_SETTING, worldClockSql, type DatabaseDriver } from './managed-database.ts';
|
|
336
|
+
export type { Batch as EngineBatch, ManagedDatabase, Statement as EngineStatement, StatementResult as EngineStatementResult } from './managed-database.ts';
|
|
337
|
+
export { readResourceBlob, readResourceBlobRange, removeResourceBlob, resourceBlobSize, resourceChain, writeResourceBlob } from './resource-blob.ts';
|
|
338
|
+
|
|
339
|
+
export { assertStateRemovable, checkParent, stateGeneration, withAncestryLock, withHistoryLock, withHistoryLocks, withStateLock, withStateRemoval } from './ancestry.ts';
|
|
340
|
+
|
|
341
|
+
export { captureHistory, captureParentHistory, historyChanges, historyAtInstant, historyDigest, historyEntries, historyLength, historyPrefix, inheritedHistory, originHead, publishOriginHistory, readHistoryView } from './history.ts';
|
|
342
|
+
export type { HistoryView, HistoryLayout, HistoryReference, HistoryOrigin } from './history.ts';
|
|
343
|
+
export { foldHistory } from './log.ts';
|
|
344
|
+
export { volterHome } from './volter-home.ts';
|