typebulb 0.57.2 → 0.58.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 +18 -1
- package/SKILL.md +20 -3
- package/dist/agents/claude/client.js +274 -175
- package/dist/agents/codex/client.js +257 -158
- package/dist/agents/pi/client.js +275 -176
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/inference.d.ts +19 -9
- package/dist/ai/inference.d.ts.map +1 -1
- package/dist/ai/inference.js +40 -23
- package/dist/ai/inference.js.map +1 -1
- package/dist/dts/tbTypings.d.ts.map +1 -1
- package/dist/dts/tbTypings.js +285 -258
- package/dist/dts/tbTypings.js.map +1 -1
- package/dist/format/index.d.ts +1 -0
- package/dist/format/index.d.ts.map +1 -1
- package/dist/format/index.js +1 -0
- package/dist/format/index.js.map +1 -1
- package/dist/format/runtimeState.d.ts +34 -0
- package/dist/format/runtimeState.d.ts.map +1 -0
- package/dist/format/runtimeState.js +88 -0
- package/dist/format/runtimeState.js.map +1 -0
- package/dist/index.js +433 -298
- package/dist/render.js +196 -97
- package/dist/servers.js +97 -53
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runtime-state writers a rendered bulb document ships (runtime-specs/TB-State.md).
|
|
3
|
+
* ONE copy, beside scrollRestore.ts and for the same reason: `tb.setData` / `tb.setInsight` are a
|
|
4
|
+
* contract both hosts owe a bulb, so a second implementation is a second set of semantics waiting
|
|
5
|
+
* to drift. What differs between hosts is only where the page globals live and how the pair
|
|
6
|
+
* reaches an address bar, and both arrive through `init`.
|
|
7
|
+
*
|
|
8
|
+
* init({ applyData, applyInsight, send })
|
|
9
|
+
* applyData(chunks) -> put the chunks in this host's data global
|
|
10
|
+
* applyInsight(json) -> put the serialized insight in this host's insight global
|
|
11
|
+
* send(pair) -> hand { data?, insight? } to this host's transport; resolve once the
|
|
12
|
+
* write has landed. Must never reject: a transport failure costs the
|
|
13
|
+
* fragment, never the swap.
|
|
14
|
+
*
|
|
15
|
+
* setData(chunks) / setInsight(value) -> the two tb.* writers, resolving once the address bar
|
|
16
|
+
* reflects the write. Neither hands back a link: the fragment is
|
|
17
|
+
* already in the URL, which a bulb reads with tb.url() like any other.
|
|
18
|
+
* seed(pair) -> apply and record what a decoded `#tb=` fragment carried, without sending it back
|
|
19
|
+
* pair() -> the wire pair, for a host that files it (the CLI modal's Save). Empty when
|
|
20
|
+
* nothing has been set, which is also how a host asks whether anything has.
|
|
21
|
+
*
|
|
22
|
+
* The recorded pair is deliberately NOT the page globals, which boot holding the file's own
|
|
23
|
+
* blocks: only a slot someone set travels, so an untouched one falls through to source (Invariant
|
|
24
|
+
* 3) instead of spending the URL ceiling on a copy of the file. It is built key by key, so an
|
|
25
|
+
* unset slot is ABSENT rather than present-and-undefined: both receivers test `'insight' in pair`,
|
|
26
|
+
* which stays exact for a null insight and needs no companion flag.
|
|
27
|
+
*
|
|
28
|
+
* Coalescing keys on whether the in-flight write has read the pair yet, not on whether one is
|
|
29
|
+
* outstanding. Writes landing before that ride it, one round trip for the pair; a write landing
|
|
30
|
+
* after it queues one re-send, because the write on the wire carries a state the page has moved
|
|
31
|
+
* past, and skipping the re-send would leave the address bar addressing it (Invariant 6).
|
|
32
|
+
*/
|
|
33
|
+
export declare const runtimeStateEngine = "(function () {\n var W = window;\n var rtData, rtInsight, rtHasInsight = false;\n var applyData, applyInsight, send;\n var pending = null, sent = false, queued = null;\n\n var pair = function () {\n var p = {};\n if (rtData !== undefined) p.data = rtData;\n if (rtHasInsight) p.insight = rtInsight;\n return p;\n };\n\n var start = function () {\n sent = false;\n return Promise.resolve()\n .then(function () { sent = true; return send(pair()); })\n .catch(function () { return undefined; })\n .finally(function () { pending = null; });\n };\n var publish = function () {\n if (!pending) { pending = start(); return pending; }\n if (!sent) return pending;\n if (!queued) queued = pending.then(function () { queued = null; return publish(); });\n return queued;\n };\n\n W.__tbState = {\n init: function (o) { applyData = o.applyData; applyInsight = o.applyInsight; send = o.send; },\n pair: pair,\n // Applied but not sent: the fragment already holds this, so sending it back would re-encode\n // the state the page just booted from.\n seed: function (p) {\n if (p.data !== undefined) { rtData = p.data; applyData(p.data); }\n if ('insight' in p) { rtInsight = p.insight; rtHasInsight = true; applyInsight(JSON.stringify(p.insight, null, 2)); }\n },\n // The globals move before the round trip, so a synchronous tb.data() right after the await is\n // never stale.\n setData: function (chunks) {\n var arr = Array.isArray(chunks) ? chunks : [chunks];\n rtData = arr;\n applyData(arr);\n return publish();\n },\n setInsight: function (value) {\n // Serialize before recording: a value JSON.stringify rejects (a cycle, a BigInt) must leave\n // the slot untouched, or every later setter carries a pair that can never be encoded or sent.\n var json = JSON.stringify(value, null, 2);\n rtInsight = value;\n rtHasInsight = true;\n applyInsight(json);\n return publish();\n }\n };\n})();";
|
|
34
|
+
//# sourceMappingURL=runtimeState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeState.d.ts","sourceRoot":"","sources":["../../format/src/runtimeState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,kBAAkB,4/DAsDzB,CAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runtime-state writers a rendered bulb document ships (runtime-specs/TB-State.md).
|
|
3
|
+
* ONE copy, beside scrollRestore.ts and for the same reason: `tb.setData` / `tb.setInsight` are a
|
|
4
|
+
* contract both hosts owe a bulb, so a second implementation is a second set of semantics waiting
|
|
5
|
+
* to drift. What differs between hosts is only where the page globals live and how the pair
|
|
6
|
+
* reaches an address bar, and both arrive through `init`.
|
|
7
|
+
*
|
|
8
|
+
* init({ applyData, applyInsight, send })
|
|
9
|
+
* applyData(chunks) -> put the chunks in this host's data global
|
|
10
|
+
* applyInsight(json) -> put the serialized insight in this host's insight global
|
|
11
|
+
* send(pair) -> hand { data?, insight? } to this host's transport; resolve once the
|
|
12
|
+
* write has landed. Must never reject: a transport failure costs the
|
|
13
|
+
* fragment, never the swap.
|
|
14
|
+
*
|
|
15
|
+
* setData(chunks) / setInsight(value) -> the two tb.* writers, resolving once the address bar
|
|
16
|
+
* reflects the write. Neither hands back a link: the fragment is
|
|
17
|
+
* already in the URL, which a bulb reads with tb.url() like any other.
|
|
18
|
+
* seed(pair) -> apply and record what a decoded `#tb=` fragment carried, without sending it back
|
|
19
|
+
* pair() -> the wire pair, for a host that files it (the CLI modal's Save). Empty when
|
|
20
|
+
* nothing has been set, which is also how a host asks whether anything has.
|
|
21
|
+
*
|
|
22
|
+
* The recorded pair is deliberately NOT the page globals, which boot holding the file's own
|
|
23
|
+
* blocks: only a slot someone set travels, so an untouched one falls through to source (Invariant
|
|
24
|
+
* 3) instead of spending the URL ceiling on a copy of the file. It is built key by key, so an
|
|
25
|
+
* unset slot is ABSENT rather than present-and-undefined: both receivers test `'insight' in pair`,
|
|
26
|
+
* which stays exact for a null insight and needs no companion flag.
|
|
27
|
+
*
|
|
28
|
+
* Coalescing keys on whether the in-flight write has read the pair yet, not on whether one is
|
|
29
|
+
* outstanding. Writes landing before that ride it, one round trip for the pair; a write landing
|
|
30
|
+
* after it queues one re-send, because the write on the wire carries a state the page has moved
|
|
31
|
+
* past, and skipping the re-send would leave the address bar addressing it (Invariant 6).
|
|
32
|
+
*/
|
|
33
|
+
export const runtimeStateEngine = `(function () {
|
|
34
|
+
var W = window;
|
|
35
|
+
var rtData, rtInsight, rtHasInsight = false;
|
|
36
|
+
var applyData, applyInsight, send;
|
|
37
|
+
var pending = null, sent = false, queued = null;
|
|
38
|
+
|
|
39
|
+
var pair = function () {
|
|
40
|
+
var p = {};
|
|
41
|
+
if (rtData !== undefined) p.data = rtData;
|
|
42
|
+
if (rtHasInsight) p.insight = rtInsight;
|
|
43
|
+
return p;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var start = function () {
|
|
47
|
+
sent = false;
|
|
48
|
+
return Promise.resolve()
|
|
49
|
+
.then(function () { sent = true; return send(pair()); })
|
|
50
|
+
.catch(function () { return undefined; })
|
|
51
|
+
.finally(function () { pending = null; });
|
|
52
|
+
};
|
|
53
|
+
var publish = function () {
|
|
54
|
+
if (!pending) { pending = start(); return pending; }
|
|
55
|
+
if (!sent) return pending;
|
|
56
|
+
if (!queued) queued = pending.then(function () { queued = null; return publish(); });
|
|
57
|
+
return queued;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
W.__tbState = {
|
|
61
|
+
init: function (o) { applyData = o.applyData; applyInsight = o.applyInsight; send = o.send; },
|
|
62
|
+
pair: pair,
|
|
63
|
+
// Applied but not sent: the fragment already holds this, so sending it back would re-encode
|
|
64
|
+
// the state the page just booted from.
|
|
65
|
+
seed: function (p) {
|
|
66
|
+
if (p.data !== undefined) { rtData = p.data; applyData(p.data); }
|
|
67
|
+
if ('insight' in p) { rtInsight = p.insight; rtHasInsight = true; applyInsight(JSON.stringify(p.insight, null, 2)); }
|
|
68
|
+
},
|
|
69
|
+
// The globals move before the round trip, so a synchronous tb.data() right after the await is
|
|
70
|
+
// never stale.
|
|
71
|
+
setData: function (chunks) {
|
|
72
|
+
var arr = Array.isArray(chunks) ? chunks : [chunks];
|
|
73
|
+
rtData = arr;
|
|
74
|
+
applyData(arr);
|
|
75
|
+
return publish();
|
|
76
|
+
},
|
|
77
|
+
setInsight: function (value) {
|
|
78
|
+
// Serialize before recording: a value JSON.stringify rejects (a cycle, a BigInt) must leave
|
|
79
|
+
// the slot untouched, or every later setter carries a pair that can never be encoded or sent.
|
|
80
|
+
var json = JSON.stringify(value, null, 2);
|
|
81
|
+
rtInsight = value;
|
|
82
|
+
rtHasInsight = true;
|
|
83
|
+
applyInsight(json);
|
|
84
|
+
return publish();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
})();`;
|
|
88
|
+
//# sourceMappingURL=runtimeState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeState.js","sourceRoot":"","sources":["../../format/src/runtimeState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAsD5B,CAAA"}
|