@frondruntime/devtools 0.3.0 → 0.4.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/CHANGELOG.md +21 -1
- package/README.md +30 -0
- package/dist/{chunk-8xwbnbvs.js → chunk-71tmgh2e.js} +5 -2
- package/dist/chunk-71tmgh2e.js.map +10 -0
- package/dist/index.d.ts +74 -5
- package/dist/index.js +12 -4
- package/dist/index.js.map +5 -5
- package/dist/node.js +1 -1
- package/package.json +4 -4
- package/src/attach.ts +26 -1
- package/src/attachDevtools.ts +10 -2
- package/src/encode.ts +38 -1
- package/src/protocol.ts +36 -1
- package/dist/chunk-8xwbnbvs.js.map +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.0](https://github.com/frondruntime/frond/compare/devtools-v0.3.0...devtools-v0.4.0) (2026-08-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* apps on this release require @frondruntime/hub at the matching version. A 0.3.x hub refuses the attachment with a message naming both versions, rather than accepting it and silently dropping the stream.
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* typed signal lane, hub protocol 2, and the lint gate ([#18](https://github.com/frondruntime/frond/issues/18)) ([7363e4e](https://github.com/frondruntime/frond/commit/7363e4e2c1ecc81ac140fff563289d97891cd34b))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Dependencies
|
|
16
|
+
|
|
17
|
+
* The following workspace dependencies were updated
|
|
18
|
+
* devDependencies
|
|
19
|
+
* @frondruntime/core bumped to 0.4.0
|
|
20
|
+
* peerDependencies
|
|
21
|
+
* @frondruntime/core bumped from 0.3.0 to 0.4.0
|
|
22
|
+
|
|
3
23
|
## [0.3.0](https://github.com/frondruntime/frond/compare/devtools-v0.2.0...devtools-v0.3.0) (2026-07-28)
|
|
4
24
|
|
|
5
25
|
|
|
6
26
|
### ⚠ BREAKING CHANGES
|
|
7
27
|
|
|
8
|
-
* **devtools:** `EncodedNodeSnapshot` drops `label` and `key
|
|
28
|
+
* **devtools:** `EncodedNodeSnapshot` drops `label` and `key`. `label` was a presentation formatting of `tag` and `key` is already embedded in `nodeId`; both were duplicated on every row of a graph read. `kind` stays — "node" versus "resource" is not recoverable from either and decides whether release semantics apply. **`HUB_PROTOCOL_VERSION` ships at 1**, not 3: the development history moved it to 2 and then 3 before this package existed on npm, and it was reset before release so the number counts published generations. Nothing outside this repo ever spoke 2 or 3.
|
|
9
29
|
|
|
10
30
|
### Features
|
|
11
31
|
|
package/README.md
CHANGED
|
@@ -48,6 +48,8 @@ Opt into `"full"` per app, deliberately. The runtimes worth debugging are the on
|
|
|
48
48
|
|
|
49
49
|
`"none"` is its own encoder rather than a stricter `"shape"`, because a key list is itself a description of app data — an app that said it would send none should not be sending the key names of every node in a graph snapshot.
|
|
50
50
|
|
|
51
|
+
What every policy still sends is how a record is addressed: its tag, its `nodeIds`, and — on a signal — its channel and event name. Those are the filters `frond_read_events` takes, so withholding them would leave a feed that cannot be narrowed to the thing you are looking for, and they are authored as constants beside the publishing code rather than derived from data. The payload is the value, and at `"none"` the payload is what goes.
|
|
52
|
+
|
|
51
53
|
At `"shape"` the descriptors are strings rather than JSON objects, because this feed is read by an agent through MCP and a node result rendered as forty lines of pretty-printed JSON that contain no data is worse than one rendered as `{id,name}`. Numbers, booleans, and strings up to 256 characters still cross verbatim: in a runtime event those are ids, tags, timestamps, and flags, which is the entire signal. Anything structured is a descriptor, because a node result or an action input is always an object or an array. A class instance gives up only its type — `AccountModel{?}` — and `_tag` is the one nested field that survives, since a failure feed that says `{_tag,nodeId}` instead of `GraphNodeAcquireFailed` is not worth reading.
|
|
52
54
|
|
|
53
55
|
Every bound at `"full"` announces itself in the output: `{"_": "elided", "by": "depth"}` — or `"budget"`, or `"entries"` — where the walk stopped, and a `{"_": "string"}` descriptor carrying `length` and `head` where a string was cut. A cap a reader cannot see is worse than a low one, because it turns "there was more" into "that was all". Markers stay objects under a `_` key at this policy, where the values around them are real data and a marker has to remain distinguishable from one.
|
|
@@ -96,6 +98,34 @@ The attach socket is unauthenticated by design — it only carries data *into* t
|
|
|
96
98
|
|
|
97
99
|
The main entry imports nothing from `node:`. The transport is a global `WebSocket` carrying ndjson, so the same build attaches from a browser, from Bun, from Node, and from React Native.
|
|
98
100
|
|
|
101
|
+
### React Native
|
|
102
|
+
|
|
103
|
+
Nothing to install: this package uses no global beyond `WebSocket`, so there is no `crypto` polyfill to add and no Node shim to configure.
|
|
104
|
+
|
|
105
|
+
What does differ is the address. **The default is loopback, and loopback means something different on each target.**
|
|
106
|
+
|
|
107
|
+
| Target | What to do |
|
|
108
|
+
| -------------------------- | ------------------------------------------------------------------------------------------ |
|
|
109
|
+
| iOS Simulator | Nothing. It shares the host's network stack, so `ws://127.0.0.1:17391/attach` is the hub. |
|
|
110
|
+
| Android emulator | `adb reverse tcp:17391 tcp:17391` on the host, then the default URL works unchanged. |
|
|
111
|
+
| Android emulator, no `adb` | Start the hub with `--host 0.0.0.0` and pass `url: "ws://10.0.2.2:17391/attach"`. |
|
|
112
|
+
| Physical device | Start the hub with `--host 0.0.0.0` and pass `url: "ws://<host-lan-ip>:17391/attach"`. |
|
|
113
|
+
|
|
114
|
+
`adb reverse` is the better of the two Android options: it tunnels the port to the emulator over the existing debug bridge, so the hub stays on loopback and the app keeps the default URL. `10.0.2.2` is the emulator's alias for the host, and reaching it means the hub has to be listening on every interface.
|
|
115
|
+
|
|
116
|
+
**`--host 0.0.0.0` puts an unauthenticated socket on your local network.** The hub has no notion of who is on the other end, in either direction: anything that can reach the port can push records into the dashboard an agent then reads, and can ask attached apps for graph snapshots up to whatever ceiling they declared. On a trusted network, for a development build, that is the trade; do not leave it bound that way, and do not do it at all with an app whose ceiling is `"full"`.
|
|
117
|
+
|
|
118
|
+
### Testing
|
|
119
|
+
|
|
120
|
+
Attaching from a Jest suite reaches Effect's RPC layer, which pulls in `msgpackr` — an ESM-only package that Jest's default CJS transform cannot load, and one this package does not choose: it is a dependency of `effect` itself, so no serialization setting here avoids it. Either run the suite as ESM, or let Jest transform it:
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
// jest.config.js
|
|
124
|
+
transformIgnorePatterns: ["node_modules/(?!(msgpackr|msgpackr-extract)/)"];
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The narrower fix is not to attach in tests at all. `attachDevtools` exists to watch a process you are working on by hand; a test run has no hub to dial and nothing to watch.
|
|
128
|
+
|
|
99
129
|
Filesystem discovery lives behind its own export, so a browser bundler never has to resolve it:
|
|
100
130
|
|
|
101
131
|
```ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/protocol.ts
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
import { Rpc, RpcGroup } from "effect/unstable/rpc";
|
|
4
|
-
var HUB_PROTOCOL_VERSION =
|
|
4
|
+
var HUB_PROTOCOL_VERSION = 2;
|
|
5
5
|
var HUB_DEFAULT_PORT = 17391;
|
|
6
6
|
var HUB_DEFAULT_HOST = "127.0.0.1";
|
|
7
7
|
var HUB_ATTACH_PATH = "/attach";
|
|
@@ -13,6 +13,7 @@ var RuntimeEventCategory = Schema.Literals([
|
|
|
13
13
|
"input",
|
|
14
14
|
"lifecycle",
|
|
15
15
|
"operation",
|
|
16
|
+
"signal",
|
|
16
17
|
"state"
|
|
17
18
|
]);
|
|
18
19
|
var RuntimeEventSeverity = Schema.Literals(["debug", "error", "info", "warning"]);
|
|
@@ -68,6 +69,8 @@ var EncodedEventRecord = Schema.Struct({
|
|
|
68
69
|
reason: RuntimeWorkReason,
|
|
69
70
|
priority: RuntimeWorkPriority,
|
|
70
71
|
nodeIds: Schema.Array(Schema.String),
|
|
72
|
+
channel: Schema.optionalKey(Schema.String),
|
|
73
|
+
name: Schema.optionalKey(Schema.String),
|
|
71
74
|
fields: Schema.Record(Schema.String, Schema.Unknown),
|
|
72
75
|
failures: Schema.Array(Schema.Unknown)
|
|
73
76
|
});
|
|
@@ -161,4 +164,4 @@ var FrondHubRpcs = RpcGroup.make(Attach, Ingest, Reply);
|
|
|
161
164
|
|
|
162
165
|
export { HUB_PROTOCOL_VERSION, HUB_DEFAULT_PORT, HUB_DEFAULT_HOST, HUB_ATTACH_PATH, HUB_DEFAULT_ATTACH_URL, ValuePolicy, RuntimeEventCategory, RuntimeEventSeverity, RuntimeEventTimeline, RuntimeWorkSource, RuntimeWorkReason, RuntimeWorkPriority, AttachmentInfo, EncodedEventRecord, EncodedNodeSnapshot, EncodedGraphEdge, GraphSnapshot, GraphQuery, NodeQuery, StateQuery, QueryOutcome, HubAttached, HubPing, HubQuery, HubCommand, HubRejection, Attach, Ingest, Reply, FrondHubRpcs };
|
|
163
166
|
|
|
164
|
-
//# debugId=
|
|
167
|
+
//# debugId=720F6D78A34FBE6564756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/protocol.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { Schema } from \"effect\";\nimport { Rpc, RpcGroup } from \"effect/unstable/rpc\";\n\n/**\n * Wire contract between an attached Frond runtime and the hub.\n *\n * Direction of the RPC roles is deliberate and inverted from who dials: the\n * hub listens and is the RPC *server*, the app dials out and is the RPC\n * *client*. That keeps the app free of any listening socket, and it is the only\n * arrangement both `RpcServer.layerHttp` and `RpcClient.layerProtocolSocket`\n * support without a hand-written socket adapter on either side.\n *\n * Hub-to-app work (state reads, and later refresh and action invocation)\n * therefore does not travel as a plain RPC call. It rides the `Attach` response\n * stream as a `Query` command, and the app answers with a separate unary\n * `Reply` correlated by `requestId`. `Attach` is the only long-lived call.\n *\n * Version equality is exact, on both sides, and there is no capability\n * negotiation. That is a deliberate choice rather than an omission: `HubCommand`\n * is a schema union, so an app one version behind would fail to decode a command\n * it has never heard of and drop its socket — presenting as \"the runtime stopped\n * emitting\", which is the most expensive way this can fail. Refusing the\n * attachment outright says the same thing immediately and in words.\n *\n * The number counts published generations of *this contract*, and moves on its\n * own schedule — it is not derived from, and does not track, the npm version of\n * any package. Tying the two was the earlier arrangement and it was wrong in\n * both directions: a release that touched nothing on the wire still moved the\n * number and refused every app that had not upgraded, while a genuine schema\n * change inside one release moved nothing and let two builds that disagreed\n * attach to each other. Starting at 1 with the first published hub, so what the\n * number counts is generations anyone could have installed.\n *\n * Moved to 2 because {@link RuntimeEventCategory} gained `\"signal\"`. A literal\n * union is not an excess property: a 0.3.x hub decoding `category: \"signal\"`\n * fails with `SchemaError(Expected \"command\" | ... | \"state\", got \"signal\")`,\n * and that failure takes the whole `Frond.Ingest` batch, non-signal records\n * included. Both builds announce 1, so the attachment would succeed and the app\n * would simply stop streaming — the exact failure the paragraph above refuses to\n * ship. The optional `channel`/`name` fields really are two-way safe and would\n * not have needed this; the category is what forced it.\n */\nexport const HUB_PROTOCOL_VERSION = 2;\n\n/**\n * Unregistered, and chosen for the band rather than the number.\n *\n * Above 9999 to clear the entire dev-server zone — Vite, Metro, Expo, CRA,\n * Django, Storybook, the node inspector — and below 32768 so it can never\n * collide with an ephemeral source port on Linux, whose range starts there.\n *\n * Stable on purpose. Apps hardcode it, so a hub that drifted to the next free\n * port on a collision would leave them dialing nothing, which presents as \"the\n * runtime is not emitting\" — the most expensive way to fail.\n */\nexport const HUB_DEFAULT_PORT = 17391;\n\nexport const HUB_DEFAULT_HOST = \"127.0.0.1\";\n\nexport const HUB_ATTACH_PATH = \"/attach\";\n\n/** Where an app dials when it was given no explicit URL. */\nexport const HUB_DEFAULT_ATTACH_URL = `ws://${HUB_DEFAULT_HOST}:${HUB_DEFAULT_PORT}${HUB_ATTACH_PATH}`;\n\n/**\n * How much of a value crosses the wire.\n *\n * Negotiated in one direction only: the hub asks, and the app answers with the\n * lesser of the request and its own ceiling. The ceiling defaults to `\"shape\"`,\n * so an app sends structure until someone deliberately decides otherwise — the\n * decision to put real values on a socket should be one somebody made, not one\n * that came with the default.\n */\nexport const ValuePolicy = Schema.Literals([\"none\", \"shape\", \"full\"]);\nexport type ValuePolicy = typeof ValuePolicy.Type;\n\nexport const RuntimeEventCategory = Schema.Literals([\n \"command\",\n \"diagnostic\",\n \"input\",\n \"lifecycle\",\n \"operation\",\n \"signal\",\n \"state\",\n]);\n\nexport const RuntimeEventSeverity = Schema.Literals([\"debug\", \"error\", \"info\", \"warning\"]);\n\nexport const RuntimeEventTimeline = Schema.Literals([\"live\", \"state\", \"system\", \"work\"]);\n\nexport const RuntimeWorkSource = Schema.Literals([\n \"react\",\n \"mobx\",\n \"node\",\n \"manual\",\n \"devtools\",\n \"runtime\",\n \"signal\",\n \"test\",\n]);\n\nexport const RuntimeWorkReason = Schema.Literals([\n \"start\",\n \"stop\",\n \"readiness\",\n \"retry\",\n \"preload\",\n \"refresh\",\n \"action\",\n \"args-update\",\n \"live\",\n \"release\",\n \"eviction\",\n \"unsafe-update\",\n \"input\",\n \"signal\",\n]);\n\nexport const RuntimeWorkPriority = Schema.Literals([\"blocking\", \"visible\", \"background\", \"idle\"]);\n\n/**\n * Who is attaching.\n *\n * `runtimeId` is the runtime's own `runtime-N` counter and collides freely\n * across tabs, reloads, and processes; `instanceId` is minted once per\n * `attachDevtools` call and is the only field safe to use as an identity key.\n */\nexport const AttachmentInfo = Schema.Struct({\n protocolVersion: Schema.Number,\n /** Stable for the life of the attaching runtime, including across reconnects. */\n instanceId: Schema.String,\n runtimeId: Schema.String,\n /**\n * How many times this runtime had already attached before this connection.\n *\n * Zero on a first attach; anything higher means the socket dropped and came\n * back, which is the same thing as saying the events in between are gone.\n * Devtools are not durable by design — nothing bridges that gap — so this\n * field exists to make the gap visible rather than to let anyone close it.\n */\n generation: Schema.Number,\n /** Human label for the CLI list, e.g. the host app's package name. */\n name: Schema.String,\n /** Free-form origin hint: \"bun\", \"browser\", \"expo-ios\", … */\n platform: Schema.String,\n startedAt: Schema.Number,\n /** The strongest value policy this app is willing to honor. */\n values: ValuePolicy,\n});\nexport type AttachmentInfo = typeof AttachmentInfo.Type;\n\n/**\n * A runtime event, flattened and already redacted by the sender.\n *\n * `fields` holds JSON-safe shape descriptors, not live values — encoding\n * happens at observe time, because a `RuntimeEventRecord` carries live\n * references that keep mutating after the record is handed out. The descriptor\n * vocabulary is written down once, in `descriptors.ts`, and what each policy\n * produces lives with the walk that produces it — `describeShape` in `shape.ts`,\n * `describeFull` in `full.ts`, `describeError` in `cause.ts`. Nothing on this\n * side should restate any of it and drift.\n */\nexport const EncodedEventRecord = Schema.Struct({\n sequence: Schema.Number,\n recordedAt: Schema.Number,\n /** The `RuntimeEvent` `_tag`, e.g. \"GraphNodeLiveDemandChanged\". */\n tag: Schema.String,\n category: RuntimeEventCategory,\n severity: RuntimeEventSeverity,\n timeline: RuntimeEventTimeline,\n reportable: Schema.Boolean,\n workId: Schema.Number,\n parentWorkId: Schema.optional(Schema.Number),\n source: RuntimeWorkSource,\n reason: RuntimeWorkReason,\n priority: RuntimeWorkPriority,\n nodeIds: Schema.Array(Schema.String),\n /**\n * Which signal this is, on the two events that carry one.\n *\n * Lifted out of `fields` because that is where they used to die: the field\n * walk treats every event body the same way, so a publication whose one field\n * is a signal record arrived at the default `\"shape\"` policy as a key list of\n * that record — a reader could tell that *a* signal fired and nothing about\n * which one. A channel and an event name are routing structure rather than app\n * data, which is the same argument `describeShape` makes for letting `_tag`\n * cross verbatim, so these two cross at every policy. The `payload` stays in\n * `fields` and stays clamped, because it is the half that really is data.\n *\n * Optional rather than required, which keeps these two fields compatible in\n * both directions on their own: an old hub ignores the extra properties a new\n * app sends, because effect Schema drops excess properties on decode and\n * nothing here overrides `onExcessProperty`, and a new hub reads an old app's\n * records as what they are — signals whose channel it was never told.\n *\n * That is a property of these fields and not of the release. The same release\n * added `\"signal\"` to {@link RuntimeEventCategory}, which an old hub does\n * reject, so {@link HUB_PROTOCOL_VERSION} moved to 2 regardless. Keeping these\n * optional is still what makes a new hub able to read an old app at all.\n */\n channel: Schema.optionalKey(Schema.String),\n name: Schema.optionalKey(Schema.String),\n /**\n * Keyed by the event's own field names, minus `_tag`.\n *\n * A record rather than `Unknown`: every consumer — the UI, and shortly the\n * MCP reader — looks fields up by name, and typing the container as unknown\n * only moves that cast to each of them. The *values* stay unknown, which is\n * the honest part: what a field holds depends on the negotiated policy.\n */\n fields: Schema.Record(Schema.String, Schema.Unknown),\n /**\n * What went wrong, as chains of causes rather than as single errors.\n *\n * Each entry is `{_: \"error\", message, causes}`, outermost cause first. The\n * runtime lifts these off the event's own fields, so the same failure also\n * appears in `fields` — encoded identically, so one failure never reads as\n * two. Present at every policy: `\"none\"` is a statement about values, and a\n * feed that cannot say what is failing is not worth reading.\n */\n failures: Schema.Array(Schema.Unknown),\n});\nexport type EncodedEventRecord = typeof EncodedEventRecord.Type;\n\n/**\n * One node, as it is right now.\n *\n * Split the same way `EncodedEventRecord` is: the fields a reader filters and\n * branches on are typed, and anything that came out of the app's own data is\n * `Unknown`, because what it holds depends on the negotiated policy. Giving\n * `NodeStatus`, `NodeOperation` and the rest real schemas here would copy core's\n * type surface into the wire contract and guarantee the two drift apart.\n *\n * Every field here has to earn its place in *every row* of a graph read, which\n * is why core's `label` and `key` are not among them: `label` is a formatting of\n * `tag` and `key` is already inside `nodeId`, so both are the same fact charged\n * twice, a few hundred times per snapshot.\n */\nexport const EncodedNodeSnapshot = Schema.Struct({\n nodeId: Schema.String,\n /** The spec's tag, e.g. `\"orders\"`. Shared by every key; `nodeId` is the identity. */\n tag: Schema.String,\n /**\n * `\"node\"`, `\"service\"`, `\"resource\"` or `\"facade\"` — the one identity field\n * nothing else here implies.\n *\n * It says whether this row owns a release: a resource holds something the app\n * has to give back, and a reader deciding what a leak looks like cannot get\n * that from `tag` or `nodeId`.\n *\n * Carried as a string rather than a literal union so a hub can read an app\n * built against a core that has since grown a kind. Version equality already\n * gates the wire; making this field the second thing that can reject a\n * snapshot would buy nothing.\n */\n kind: Schema.String,\n /**\n * Which arm of core's `NodeSnapshot` this is: `Unwired`, `Idle`, `Pending`,\n * `Ready`, `ReadinessError`, `Releasing`, `Invalid`.\n *\n * Typed and hoisted because it is the one field every reader branches on.\n * Left inside the encoded `status` it would oblige an agent to understand this\n * encoder's descriptors before it could ask which nodes are broken.\n */\n state: Schema.String,\n /**\n * Core's per-node write counter, carried verbatim.\n *\n * The cheap way to tell \"still the value I saw last time\" from \"recomputed,\n * and happens to look the same\" — which no amount of comparing encoded\n * results can answer once a policy has redacted them.\n */\n revision: Schema.Number,\n status: Schema.Unknown,\n liveDemand: Schema.Unknown,\n operation: Schema.Unknown,\n resultValidity: Schema.optional(Schema.Unknown),\n /**\n * Why this node is not usable, as a chain of causes.\n *\n * Same encoding as `EncodedEventRecord.failures`, deliberately: a node failed\n * in the snapshot and the event that failed it should read identically.\n */\n failure: Schema.optional(Schema.Unknown),\n /**\n * The last operation that failed, as `{operationId, kind, at, error}`.\n *\n * Distinct from `failure`, and the difference is the whole point of keeping\n * it: a node can be `Ready` on a stale-but-valid result while its most recent\n * refresh failed. `failure` would be absent and everything would look fine.\n */\n operationFailure: Schema.optional(Schema.Unknown),\n /** Why live demand could not be served, as `{at, failures}`. */\n liveFailure: Schema.optional(Schema.Unknown),\n /**\n * The node's current value.\n *\n * Only ever present on a single-node query. A graph read of a few hundred\n * nodes is a topology question, and answering it with every result attached\n * would put the whole application state on the wire to draw a diagram.\n */\n result: Schema.optional(Schema.Unknown),\n});\nexport type EncodedNodeSnapshot = typeof EncodedNodeSnapshot.Type;\n\nexport const EncodedGraphEdge = Schema.Struct({\n from: Schema.String,\n to: Schema.String,\n /** The dependency name the dependent declared, not the target's tag. */\n dependency: Schema.String,\n});\nexport type EncodedGraphEdge = typeof EncodedGraphEdge.Type;\n\n/**\n * The graph at one instant.\n *\n * The counterpart to the event stream rather than a replacement for it: events\n * say what happened, this says what is true. `capturedAt` and `sequence` are\n * what let a reader hold both at once — a snapshot taken \"as of sequence 4412\"\n * can be lined up against the log the reader already has, instead of being a\n * second account of the same system with no way to relate them.\n */\nexport const GraphSnapshot = Schema.Struct({\n capturedAt: Schema.Number,\n /**\n * The last event sequence the runtime had recorded when this was taken.\n *\n * Absent on a runtime that has not emitted yet, which is the only honest\n * answer — zero would claim a position in a log that has none.\n */\n sequence: Schema.optional(Schema.Number),\n runtimeId: Schema.String,\n runtimeStatus: Schema.String,\n graphStatus: Schema.String,\n observedInputs: Schema.Number,\n /**\n * The policy the app actually applied, which may be less than was asked for.\n *\n * Stated per snapshot rather than inferred from the attachment: a reader that\n * finds no `result` on a node needs to tell \"redacted\" from \"not ready\", and\n * those are the same absence.\n */\n values: ValuePolicy,\n nodes: Schema.Array(EncodedNodeSnapshot),\n edges: Schema.Array(EncodedGraphEdge),\n});\nexport type GraphSnapshot = typeof GraphSnapshot.Type;\n\n/** Every node and edge, with statuses but without results. */\nexport const GraphQuery = Schema.Struct({ _tag: Schema.tag(\"Graph\") });\n\n/** One node, with its result and the edges incident on it. */\nexport const NodeQuery = Schema.Struct({\n _tag: Schema.tag(\"Node\"),\n nodeId: Schema.String,\n});\n\nexport const StateQuery = Schema.Union([GraphQuery, NodeQuery]);\nexport type StateQuery = typeof StateQuery.Type;\n\n/**\n * The app's answer to one query.\n *\n * `Failed` rather than an RPC error because the reply is a separate call from\n * the request: an error on this channel would fail the *reply*, which is not\n * the thing that went wrong, and would leave the hub waiting out its timeout\n * for an answer that already came back.\n */\nexport const QueryOutcome = Schema.Union([\n Schema.Struct({ _tag: Schema.tag(\"Snapshot\"), snapshot: GraphSnapshot }),\n Schema.Struct({ _tag: Schema.tag(\"Failed\"), reason: Schema.String }),\n]);\nexport type QueryOutcome = typeof QueryOutcome.Type;\n\n/** Hub accepted the attachment and assigned it an id. */\nexport const HubAttached = Schema.Struct({\n _tag: Schema.tag(\"Attached\"),\n attachmentId: Schema.String,\n /** What the hub is asking for. The app may downgrade, never upgrade. */\n values: ValuePolicy,\n});\n\n/** Liveness probe; the app answers by continuing to hold the stream open. */\nexport const HubPing = Schema.Struct({\n _tag: Schema.tag(\"Ping\"),\n at: Schema.Number,\n});\n\n/**\n * Asks the app what is true right now.\n *\n * Rides this stream because the hub has no way to call the app — it listens and\n * the app dials, so the only open channel in this direction is the `Attach`\n * response. The answer comes back as a separate `Reply` call rather than in\n * band, which is why `requestId` exists.\n *\n * `values` is requested per query, not per attachment. A stream of events and a\n * deliberate read of one node are different acts: the first is a firehose worth\n * keeping cheap, the second is someone asking a specific question. Both are\n * still clamped by the app's own ceiling, so this widens nothing the app has not\n * already agreed to.\n */\nexport const HubQuery = Schema.Struct({\n _tag: Schema.tag(\"Query\"),\n requestId: Schema.String,\n query: StateQuery,\n values: ValuePolicy,\n});\n\n/** Server-to-client commands. */\nexport const HubCommand = Schema.Union([HubAttached, HubPing, HubQuery]);\nexport type HubCommand = typeof HubCommand.Type;\n\n/**\n * The hub refused the attachment.\n *\n * `reason` is prose for a terminal, not a code to branch on. It is the last\n * thing said on a connection that is about to close, and the symptom on the\n * other end — devtools that quietly never appear — carries no information at\n * all, so the string has to carry the diagnosis and the next step instead. The\n * hub's version mismatch names both versions and which side to upgrade.\n *\n * Specific on purpose, where a rejection elsewhere would be deliberately vague:\n * there is no authentication on this call (see `Attach`), so an uninvited\n * caller learns nothing here it could not learn by dialing and observing, and\n * vagueness would cost only the developer who is actually trying to attach.\n */\nexport class HubRejection extends Schema.TaggedErrorClass<HubRejection>(\"HubRejection\")(\n \"HubRejection\",\n { reason: Schema.String }\n) {}\n\n/**\n * Opens the attachment and holds it open.\n *\n * The stream's lifetime *is* the attachment's lifetime: when the socket drops,\n * the handler is interrupted, which is how the hub learns about detachment.\n * There is no explicit detach call and there should not be one — a crashed app\n * cannot send it.\n *\n * Unauthenticated on purpose. Browsers do not apply CORS to WebSockets, so any\n * page a developer visits can dial a loopback port — but this direction only\n * carries data *into* the hub, so the worst an uninvited caller achieves is\n * putting junk in a dashboard. The direction where app data leaves is the MCP\n * endpoint, and a secret on this half while that one is open would buy nothing\n * and cost every host app a value to configure.\n *\n * The consequence, stated plainly because something downstream has to honour\n * it: records arriving here are not proof of their own origin, and a consumer\n * that feeds them to an agent is feeding it untrusted text.\n */\nexport class Attach extends Rpc.make(\"Frond.Attach\", {\n payload: { info: AttachmentInfo },\n success: HubCommand,\n error: HubRejection,\n stream: true,\n}) {}\n\n/**\n * Pushes a batch of events.\n *\n * `droppedSince` is the sender's count of records it could not buffer since the\n * previous batch. It is not optional and not a nicety: a devtools feed that\n * silently loses events is worse than one that admits to a gap, because an\n * agent reasoning over the stream cannot tell \"did not happen\" from \"was\n * dropped\".\n */\nexport class Ingest extends Rpc.make(\"Frond.Ingest\", {\n payload: {\n attachmentId: Schema.String,\n records: Schema.Array(EncodedEventRecord),\n droppedSince: Schema.Number,\n },\n}) {}\n\n/**\n * Answers one `Query`.\n *\n * A unary call in the app-to-hub direction, correlated by `requestId`, because\n * the RPC roles only run that way — see the note at the top of this file. The\n * consequence worth naming: a reply is not causally tied to the stream that\n * asked for it, so the hub has to time its requests out. An app that dies\n * mid-query simply never calls this.\n */\nexport class Reply extends Rpc.make(\"Frond.Reply\", {\n payload: {\n attachmentId: Schema.String,\n requestId: Schema.String,\n outcome: QueryOutcome,\n },\n}) {}\n\nexport const FrondHubRpcs = RpcGroup.make(Attach, Ingest, Reply);\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAAA;AACA;AAyCO,IAAM,uBAAuB;AAa7B,IAAM,mBAAmB;AAEzB,IAAM,mBAAmB;AAEzB,IAAM,kBAAkB;AAGxB,IAAM,yBAAyB,QAAQ,oBAAoB,mBAAmB;AAW9E,IAAM,cAAc,OAAO,SAAS,CAAC,QAAQ,SAAS,MAAM,CAAC;AAG7D,IAAM,uBAAuB,OAAO,SAAS;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,uBAAuB,OAAO,SAAS,CAAC,SAAS,SAAS,QAAQ,SAAS,C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164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -227,6 +227,14 @@ export declare type DevtoolsOptions = {
|
|
|
227
227
|
readonly platform?: string | undefined;
|
|
228
228
|
/** See {@link import("./attach.ts").AttachOptions.values}. Defaults to `"shape"`. */
|
|
229
229
|
readonly values?: ValuePolicy | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* Stable identity for this app across reconnects. Generated when omitted.
|
|
232
|
+
*
|
|
233
|
+
* Worth setting to something recognisable when several apps attach at once,
|
|
234
|
+
* since this is what tells one from another after a hub restart. Any string
|
|
235
|
+
* does, so long as it is stable for the life of the process and distinct per
|
|
236
|
+
* running app.
|
|
237
|
+
*/
|
|
230
238
|
readonly instanceId?: string | undefined;
|
|
231
239
|
/** Return false to leave a record out of the stream entirely. */
|
|
232
240
|
readonly include?: ((record: Runtime.RuntimeEventRecord) => boolean) | undefined;
|
|
@@ -261,7 +269,7 @@ export declare const EncodedEventRecord: Schema.Struct<{
|
|
|
261
269
|
readonly recordedAt: Schema.Number;
|
|
262
270
|
/** The `RuntimeEvent` `_tag`, e.g. "GraphNodeLiveDemandChanged". */
|
|
263
271
|
readonly tag: Schema.String;
|
|
264
|
-
readonly category: Schema.Literals<readonly ["command", "diagnostic", "input", "lifecycle", "operation", "state"]>;
|
|
272
|
+
readonly category: Schema.Literals<readonly ["command", "diagnostic", "input", "lifecycle", "operation", "signal", "state"]>;
|
|
265
273
|
readonly severity: Schema.Literals<readonly ["debug", "error", "info", "warning"]>;
|
|
266
274
|
readonly timeline: Schema.Literals<readonly ["live", "state", "system", "work"]>;
|
|
267
275
|
readonly reportable: Schema.Boolean;
|
|
@@ -271,6 +279,31 @@ export declare const EncodedEventRecord: Schema.Struct<{
|
|
|
271
279
|
readonly reason: Schema.Literals<readonly ["start", "stop", "readiness", "retry", "preload", "refresh", "action", "args-update", "live", "release", "eviction", "unsafe-update", "input", "signal"]>;
|
|
272
280
|
readonly priority: Schema.Literals<readonly ["blocking", "visible", "background", "idle"]>;
|
|
273
281
|
readonly nodeIds: Schema.$Array<Schema.String>;
|
|
282
|
+
/**
|
|
283
|
+
* Which signal this is, on the two events that carry one.
|
|
284
|
+
*
|
|
285
|
+
* Lifted out of `fields` because that is where they used to die: the field
|
|
286
|
+
* walk treats every event body the same way, so a publication whose one field
|
|
287
|
+
* is a signal record arrived at the default `"shape"` policy as a key list of
|
|
288
|
+
* that record — a reader could tell that *a* signal fired and nothing about
|
|
289
|
+
* which one. A channel and an event name are routing structure rather than app
|
|
290
|
+
* data, which is the same argument `describeShape` makes for letting `_tag`
|
|
291
|
+
* cross verbatim, so these two cross at every policy. The `payload` stays in
|
|
292
|
+
* `fields` and stays clamped, because it is the half that really is data.
|
|
293
|
+
*
|
|
294
|
+
* Optional rather than required, which keeps these two fields compatible in
|
|
295
|
+
* both directions on their own: an old hub ignores the extra properties a new
|
|
296
|
+
* app sends, because effect Schema drops excess properties on decode and
|
|
297
|
+
* nothing here overrides `onExcessProperty`, and a new hub reads an old app's
|
|
298
|
+
* records as what they are — signals whose channel it was never told.
|
|
299
|
+
*
|
|
300
|
+
* That is a property of these fields and not of the release. The same release
|
|
301
|
+
* added `"signal"` to {@link RuntimeEventCategory}, which an old hub does
|
|
302
|
+
* reject, so {@link HUB_PROTOCOL_VERSION} moved to 2 regardless. Keeping these
|
|
303
|
+
* optional is still what makes a new hub able to read an old app at all.
|
|
304
|
+
*/
|
|
305
|
+
readonly channel: Schema.optionalKey<Schema.String>;
|
|
306
|
+
readonly name: Schema.optionalKey<Schema.String>;
|
|
274
307
|
/**
|
|
275
308
|
* Keyed by the event's own field names, minus `_tag`.
|
|
276
309
|
*
|
|
@@ -428,7 +461,9 @@ export declare type EncodePolicy = ValuePolicy;
|
|
|
428
461
|
*
|
|
429
462
|
* Classification, work context, and node ids are metadata the runtime already
|
|
430
463
|
* owns and are copied verbatim — they are ids and enum members, never user
|
|
431
|
-
* data.
|
|
464
|
+
* data. A signal's channel and name join them, on the reasoning
|
|
465
|
+
* `EncodedEventRecord` gives for the two fields. Only the event body goes
|
|
466
|
+
* through the value encoder.
|
|
432
467
|
*/
|
|
433
468
|
export declare function encodeRecord(record: Runtime.RuntimeEventRecord, policy: EncodePolicy): EncodedEventRecord;
|
|
434
469
|
|
|
@@ -593,8 +628,17 @@ export declare const HUB_DEFAULT_PORT = 17391;
|
|
|
593
628
|
* change inside one release moved nothing and let two builds that disagreed
|
|
594
629
|
* attach to each other. Starting at 1 with the first published hub, so what the
|
|
595
630
|
* number counts is generations anyone could have installed.
|
|
631
|
+
*
|
|
632
|
+
* Moved to 2 because {@link RuntimeEventCategory} gained `"signal"`. A literal
|
|
633
|
+
* union is not an excess property: a 0.3.x hub decoding `category: "signal"`
|
|
634
|
+
* fails with `SchemaError(Expected "command" | ... | "state", got "signal")`,
|
|
635
|
+
* and that failure takes the whole `Frond.Ingest` batch, non-signal records
|
|
636
|
+
* included. Both builds announce 1, so the attachment would succeed and the app
|
|
637
|
+
* would simply stop streaming — the exact failure the paragraph above refuses to
|
|
638
|
+
* ship. The optional `channel`/`name` fields really are two-way safe and would
|
|
639
|
+
* not have needed this; the category is what forced it.
|
|
596
640
|
*/
|
|
597
|
-
export declare const HUB_PROTOCOL_VERSION =
|
|
641
|
+
export declare const HUB_PROTOCOL_VERSION = 2;
|
|
598
642
|
|
|
599
643
|
/** Hub accepted the attachment and assigned it an id. */
|
|
600
644
|
export declare const HubAttached: Schema.Struct<{
|
|
@@ -699,7 +743,7 @@ declare const Ingest_base: Rpc.Rpc<"Frond.Ingest", Schema.Struct<{
|
|
|
699
743
|
readonly recordedAt: Schema.Number;
|
|
700
744
|
/** The `RuntimeEvent` `_tag`, e.g. "GraphNodeLiveDemandChanged". */
|
|
701
745
|
readonly tag: Schema.String;
|
|
702
|
-
readonly category: Schema.Literals<readonly ["command", "diagnostic", "input", "lifecycle", "operation", "state"]>;
|
|
746
|
+
readonly category: Schema.Literals<readonly ["command", "diagnostic", "input", "lifecycle", "operation", "signal", "state"]>;
|
|
703
747
|
readonly severity: Schema.Literals<readonly ["debug", "error", "info", "warning"]>;
|
|
704
748
|
readonly timeline: Schema.Literals<readonly ["live", "state", "system", "work"]>;
|
|
705
749
|
readonly reportable: Schema.Boolean;
|
|
@@ -709,6 +753,31 @@ declare const Ingest_base: Rpc.Rpc<"Frond.Ingest", Schema.Struct<{
|
|
|
709
753
|
readonly reason: Schema.Literals<readonly ["start", "stop", "readiness", "retry", "preload", "refresh", "action", "args-update", "live", "release", "eviction", "unsafe-update", "input", "signal"]>;
|
|
710
754
|
readonly priority: Schema.Literals<readonly ["blocking", "visible", "background", "idle"]>;
|
|
711
755
|
readonly nodeIds: Schema.$Array<Schema.String>;
|
|
756
|
+
/**
|
|
757
|
+
* Which signal this is, on the two events that carry one.
|
|
758
|
+
*
|
|
759
|
+
* Lifted out of `fields` because that is where they used to die: the field
|
|
760
|
+
* walk treats every event body the same way, so a publication whose one field
|
|
761
|
+
* is a signal record arrived at the default `"shape"` policy as a key list of
|
|
762
|
+
* that record — a reader could tell that *a* signal fired and nothing about
|
|
763
|
+
* which one. A channel and an event name are routing structure rather than app
|
|
764
|
+
* data, which is the same argument `describeShape` makes for letting `_tag`
|
|
765
|
+
* cross verbatim, so these two cross at every policy. The `payload` stays in
|
|
766
|
+
* `fields` and stays clamped, because it is the half that really is data.
|
|
767
|
+
*
|
|
768
|
+
* Optional rather than required, which keeps these two fields compatible in
|
|
769
|
+
* both directions on their own: an old hub ignores the extra properties a new
|
|
770
|
+
* app sends, because effect Schema drops excess properties on decode and
|
|
771
|
+
* nothing here overrides `onExcessProperty`, and a new hub reads an old app's
|
|
772
|
+
* records as what they are — signals whose channel it was never told.
|
|
773
|
+
*
|
|
774
|
+
* That is a property of these fields and not of the release. The same release
|
|
775
|
+
* added `"signal"` to {@link RuntimeEventCategory}, which an old hub does
|
|
776
|
+
* reject, so {@link HUB_PROTOCOL_VERSION} moved to 2 regardless. Keeping these
|
|
777
|
+
* optional is still what makes a new hub able to read an old app at all.
|
|
778
|
+
*/
|
|
779
|
+
readonly channel: Schema.optionalKey<Schema.String>;
|
|
780
|
+
readonly name: Schema.optionalKey<Schema.String>;
|
|
712
781
|
/**
|
|
713
782
|
* Keyed by the event's own field names, minus `_tag`.
|
|
714
783
|
*
|
|
@@ -979,7 +1048,7 @@ declare const Reply_base: Rpc.Rpc<"Frond.Reply", Schema.Struct<{
|
|
|
979
1048
|
*/
|
|
980
1049
|
export declare function resolvePolicy(requested: ValuePolicy, ceiling: ValuePolicy): EncodePolicy;
|
|
981
1050
|
|
|
982
|
-
export declare const RuntimeEventCategory: Schema.Literals<readonly ["command", "diagnostic", "input", "lifecycle", "operation", "state"]>;
|
|
1051
|
+
export declare const RuntimeEventCategory: Schema.Literals<readonly ["command", "diagnostic", "input", "lifecycle", "operation", "signal", "state"]>;
|
|
983
1052
|
|
|
984
1053
|
export declare const RuntimeEventSeverity: Schema.Literals<readonly ["debug", "error", "info", "warning"]>;
|
|
985
1054
|
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
RuntimeWorkSource,
|
|
30
30
|
StateQuery,
|
|
31
31
|
ValuePolicy
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-71tmgh2e.js";
|
|
33
33
|
|
|
34
34
|
// src/attach.ts
|
|
35
35
|
import { Clock, Effect, Layer, Stream } from "effect";
|
|
@@ -425,10 +425,15 @@ function encodeRecord(record, policy) {
|
|
|
425
425
|
reason: record.work.reason,
|
|
426
426
|
priority: record.work.priority,
|
|
427
427
|
nodeIds: record.nodeIds,
|
|
428
|
+
...signalIdentity(record.event),
|
|
428
429
|
fields: policy === "none" ? {} : describeFields(record.event, encodeField),
|
|
429
430
|
failures: record.failures.map(encoder.failure)
|
|
430
431
|
};
|
|
431
432
|
}
|
|
433
|
+
function signalIdentity(event) {
|
|
434
|
+
const signal = event._tag === "RuntimeSignalPublished" ? event.record.signal : event._tag === "RuntimeSignalSubscriberFailureObserved" ? event.signal.signal : undefined;
|
|
435
|
+
return signal === undefined ? {} : { channel: signal.channel, name: signal.name };
|
|
436
|
+
}
|
|
432
437
|
function describeFields(event, encodeValue) {
|
|
433
438
|
const fields = {};
|
|
434
439
|
for (const [key, value] of Object.entries(event)) {
|
|
@@ -525,6 +530,9 @@ function encodeLiveFailure(failure, encoder) {
|
|
|
525
530
|
// src/attach.ts
|
|
526
531
|
var MAX_BUFFERED_RECORDS = 4096;
|
|
527
532
|
var FLUSH_INTERVAL = "250 millis";
|
|
533
|
+
function newInstanceId() {
|
|
534
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
535
|
+
}
|
|
528
536
|
function attachLayer(attachUrl) {
|
|
529
537
|
return RpcClient.layerProtocolSocket().pipe(Layer.provide(Socket.layerWebSocket(attachUrl)), Layer.provide(Socket.layerWebSocketConstructorGlobal), Layer.provide(RpcSerialization.layerNdjson));
|
|
530
538
|
}
|
|
@@ -548,7 +556,7 @@ var attachRuntime = Effect.fnUntraced(function* (options) {
|
|
|
548
556
|
yield* Effect.addFinalizer(() => Effect.sync(() => subscription.unsubscribe()));
|
|
549
557
|
const info = {
|
|
550
558
|
protocolVersion: HUB_PROTOCOL_VERSION,
|
|
551
|
-
instanceId: options.instanceId ??
|
|
559
|
+
instanceId: options.instanceId ?? newInstanceId(),
|
|
552
560
|
runtimeId: options.runtime.getSnapshotSync().runtimeId,
|
|
553
561
|
generation: options.generation ?? 0,
|
|
554
562
|
name: options.name,
|
|
@@ -621,7 +629,7 @@ function refusal(cause) {
|
|
|
621
629
|
}
|
|
622
630
|
function attachDevtools(options) {
|
|
623
631
|
const url = options.url ?? HUB_DEFAULT_ATTACH_URL;
|
|
624
|
-
const instanceId = options.instanceId ??
|
|
632
|
+
const instanceId = options.instanceId ?? newInstanceId();
|
|
625
633
|
let generation = 0;
|
|
626
634
|
const session = Effect2.suspend(() => attachRuntime({
|
|
627
635
|
runtime: options.runtime,
|
|
@@ -702,4 +710,4 @@ export {
|
|
|
702
710
|
Attach
|
|
703
711
|
};
|
|
704
712
|
|
|
705
|
-
//# debugId=
|
|
713
|
+
//# debugId=2D4EEFF071D4325764756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/attach.ts", "../src/cause.ts", "../src/descriptors.ts", "../src/full.ts", "../src/shape.ts", "../src/encode.ts", "../src/policy.ts", "../src/snapshot.ts", "../src/attachDevtools.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { Runtime } from \"@frondruntime/core\";\nimport { Clock, Effect, Layer, Stream } from \"effect\";\nimport { RpcClient, RpcSerialization } from \"effect/unstable/rpc\";\nimport { Socket } from \"effect/unstable/socket\";\nimport { encodeRecord } from \"./encode.ts\";\nimport { type EncodePolicy, resolvePolicy } from \"./policy.ts\";\nimport {\n type AttachmentInfo,\n type EncodedEventRecord,\n FrondHubRpcs,\n HUB_PROTOCOL_VERSION,\n type HubCommand,\n type QueryOutcome,\n type ValuePolicy,\n} from \"./protocol.ts\";\nimport { encodeGraphSnapshot } from \"./snapshot.ts\";\n\n/**\n * How many encoded records are held between flushes.\n *\n * When this fills, further records are counted and discarded rather than\n * buffered without bound: an attached app must never be slowed down, let alone\n * grow unboundedly, because a devtools consumer stopped reading. The count\n * travels as `droppedSince`, so the hub always knows a gap happened.\n */\nconst MAX_BUFFERED_RECORDS = 4096;\n\nconst FLUSH_INTERVAL = \"250 millis\";\n\nexport type AttachOptions = {\n readonly runtime: Runtime.Runtime;\n readonly attachUrl: string;\n /** Human label for the hub's list, e.g. the host app's package name. */\n readonly name: string;\n readonly platform: string;\n /**\n * The most this app will ever disclose, whatever the hub asks for.\n *\n * `\"shape\"` by default: structure, key names, lengths and types, but no\n * values. Sending real values is a decision worth making per app rather than\n * inheriting — the runtimes worth debugging are the ones holding tokens and\n * account state, and a default that ships them is a default that ships them\n * the first time someone forgets.\n */\n readonly values?: ValuePolicy | undefined;\n /**\n * Stable identity for this attachment, unique across processes.\n *\n * Defaults to a fresh UUID, which is right for an ordinary app. The hub sets\n * it explicitly so it can recognise its own self-attachment in the list it\n * serves — `runtimeId` cannot do that job, because it comes from a\n * per-process counter and every runtime's first one is `runtime-1`.\n *\n * Minted per *call*, not per attempt: `attachDevtools` reuses one across\n * reconnects, so an app that outlives a hub restart comes back as itself.\n */\n readonly instanceId?: string;\n /** How many times this runtime has already attached. See `AttachmentInfo`. */\n readonly generation?: number;\n /**\n * Called once the hub has accepted this attempt.\n *\n * Exists so the caller can count reconnections without having to guess from\n * the outside which attempts got as far as being accepted.\n */\n readonly onAttached?: (() => void) | undefined;\n /**\n * Return false to leave a record out of the stream entirely.\n *\n * Distinct from the drop counter below, and the difference matters: a drop is\n * a gap the hub must be told about, because an agent reading the feed has to\n * be able to tell \"did not happen\" from \"was lost\". A record excluded here\n * was never in scope, so it is not a gap and is not counted as one.\n *\n * Exists for one caller — the hub, which observes the runtime it is also\n * writing into and would otherwise feed itself forever. An ordinary app has\n * no reason to pass this.\n */\n readonly include?: (record: Runtime.RuntimeEventRecord) => boolean;\n};\n\n/**\n * Transport for one attachment.\n *\n * Exported because the hub dials itself over exactly this layer — same\n * protocol, same serialization, same socket code path as a real app. If\n * self-attach works, the transport works.\n */\nexport function attachLayer(attachUrl: string): Layer.Layer<RpcClient.Protocol> {\n return RpcClient.layerProtocolSocket().pipe(\n Layer.provide(Socket.layerWebSocket(attachUrl)),\n Layer.provide(Socket.layerWebSocketConstructorGlobal),\n Layer.provide(RpcSerialization.layerNdjson)\n );\n}\n\n/**\n * Streams a runtime's events to a hub for as long as the connection lives.\n *\n * The returned Effect does not settle while attached — it *is* the attachment.\n * Fork it into a scope and close the scope to detach; the hub learns about the\n * detachment from the socket dying, which is the only mechanism that also works\n * when the app crashes.\n */\nexport const attachRuntime = Effect.fnUntraced(function* (options: AttachOptions) {\n const client = yield* RpcClient.make(FrondHubRpcs);\n\n const ceiling: ValuePolicy = options.values ?? \"shape\";\n\n let buffer: Array<EncodedEventRecord> = [];\n let dropped = 0;\n // Events fire between the socket opening and the `Attached` command arriving,\n // and the conservative reading of an unanswered negotiation is the narrow\n // one. Still clamped, so a ceiling of `\"none\"` holds from the first record.\n let policy: EncodePolicy = resolvePolicy(\"shape\", ceiling);\n let attachmentId: string | undefined;\n\n // Encoding happens here, at observe time, not at flush time: a\n // `RuntimeEventRecord` carries live references that keep mutating after the\n // record is handed out, so a record buffered raw would describe the graph as\n // it is when flushed, not as it was when the event fired.\n const subscription = options.runtime.observe((record) => {\n // Before the buffer check, so an excluded record cannot be counted as a\n // drop, and before encoding, so it costs nothing to exclude one.\n if (options.include !== undefined && !options.include(record)) {\n return;\n }\n\n if (buffer.length >= MAX_BUFFERED_RECORDS) {\n dropped += 1;\n return;\n }\n\n buffer.push(encodeRecord(record, policy));\n });\n\n yield* Effect.addFinalizer(() => Effect.sync(() => subscription.unsubscribe()));\n\n const info: AttachmentInfo = {\n protocolVersion: HUB_PROTOCOL_VERSION,\n instanceId: options.instanceId ?? crypto.randomUUID(),\n runtimeId: options.runtime.getSnapshotSync().runtimeId,\n generation: options.generation ?? 0,\n name: options.name,\n platform: options.platform,\n startedAt: yield* Clock.currentTimeMillis,\n // Advertised so the hub can show what it is going to get. Advisory only:\n // `resolvePolicy` below is what actually enforces it, because a ceiling a\n // sender merely announces is one the sender can forget to apply.\n values: ceiling,\n };\n\n const flushOnce = Effect.gen(function* () {\n yield* Effect.sleep(FLUSH_INTERVAL);\n\n const id = attachmentId;\n\n if (id === undefined || (buffer.length === 0 && dropped === 0)) {\n return;\n }\n\n // Swapped, not drained: `observe` runs on whatever fiber produced the\n // event, so anything appended during the send lands in the next batch\n // instead of being lost to a splice race.\n const records = buffer;\n const droppedSince = dropped;\n buffer = [];\n dropped = 0;\n\n yield* client[\"Frond.Ingest\"]({ attachmentId: id, records, droppedSince });\n });\n\n yield* Effect.forkScoped(Effect.forever(flushOnce));\n\n /**\n * Answers one query, on its own fiber.\n *\n * Forked rather than awaited inline because this runs on the command stream:\n * a snapshot of a large graph is the most expensive thing this client does,\n * and blocking here would stall the heartbeat and every query behind it\n * behind one slow answer.\n *\n * Nothing in here is allowed to fail outward. A query that throws comes back\n * as `Failed`, because the alternative is an error escaping into the stream\n * handler and taking down an attachment over a question that was only ever\n * advisory.\n */\n const answer = (command: Extract<HubCommand, { readonly _tag: \"Query\" }>) =>\n Effect.gen(function* () {\n const id = attachmentId;\n\n if (id === undefined) {\n return;\n }\n\n const capturedAt = yield* Clock.currentTimeMillis;\n\n const outcome = yield* Effect.map(\n Effect.exit(\n Effect.sync(() => {\n // Clamped against the ceiling, not against the stream's policy. A\n // deliberate read may ask for more than the firehose gets, and may\n // never ask for more than the app agreed to disclose.\n const requested = resolvePolicy(command.values, ceiling);\n\n return encodeGraphSnapshot(options.runtime.getSnapshotSync(), {\n policy: requested,\n capturedAt,\n nodeId: command.query._tag === \"Node\" ? command.query.nodeId : undefined,\n });\n })\n ),\n (exit): QueryOutcome =>\n exit._tag === \"Success\"\n ? { _tag: \"Snapshot\", snapshot: exit.value }\n : { _tag: \"Failed\", reason: failureReason(exit.cause) }\n );\n\n yield* Effect.ignore(\n client[\"Frond.Reply\"]({ attachmentId: id, requestId: command.requestId, outcome })\n );\n });\n\n yield* Stream.runForEach(client[\"Frond.Attach\"]({ info }), (command) => {\n if (command._tag === \"Attached\") {\n return Effect.sync(() => {\n attachmentId = command.attachmentId;\n policy = resolvePolicy(command.values, ceiling);\n options.onAttached?.();\n });\n }\n\n if (command._tag === \"Query\") {\n return Effect.forkScoped(answer(command));\n }\n\n return Effect.void;\n });\n});\n\n/**\n * A reason string for a query that could not be answered.\n *\n * Deliberately thin. This travels to a hub that will show it to whoever asked,\n * and the useful cases — an unstarted runtime, a node id that does not resolve —\n * already say so in their message. Serializing a cause chain here would mean a\n * second, competing account of failures next to the one the event stream\n * already carries.\n */\nfunction failureReason(cause: unknown): string {\n if (cause instanceof Error) {\n return cause.message === \"\" ? cause.name : cause.message;\n }\n\n return String(cause);\n}\n",
|
|
5
|
+
"import type { Runtime } from \"@frondruntime/core\";\nimport { Clock, Effect, Layer, Stream } from \"effect\";\nimport { RpcClient, RpcSerialization } from \"effect/unstable/rpc\";\nimport { Socket } from \"effect/unstable/socket\";\nimport { encodeRecord } from \"./encode.ts\";\nimport { type EncodePolicy, resolvePolicy } from \"./policy.ts\";\nimport {\n type AttachmentInfo,\n type EncodedEventRecord,\n FrondHubRpcs,\n HUB_PROTOCOL_VERSION,\n type HubCommand,\n type QueryOutcome,\n type ValuePolicy,\n} from \"./protocol.ts\";\nimport { encodeGraphSnapshot } from \"./snapshot.ts\";\n\n/**\n * How many encoded records are held between flushes.\n *\n * When this fills, further records are counted and discarded rather than\n * buffered without bound: an attached app must never be slowed down, let alone\n * grow unboundedly, because a devtools consumer stopped reading. The count\n * travels as `droppedSince`, so the hub always knows a gap happened.\n */\nconst MAX_BUFFERED_RECORDS = 4096;\n\nconst FLUSH_INTERVAL = \"250 millis\";\n\nexport type AttachOptions = {\n readonly runtime: Runtime.Runtime;\n readonly attachUrl: string;\n /** Human label for the hub's list, e.g. the host app's package name. */\n readonly name: string;\n readonly platform: string;\n /**\n * The most this app will ever disclose, whatever the hub asks for.\n *\n * `\"shape\"` by default: structure, key names, lengths and types, but no\n * values. Sending real values is a decision worth making per app rather than\n * inheriting — the runtimes worth debugging are the ones holding tokens and\n * account state, and a default that ships them is a default that ships them\n * the first time someone forgets.\n */\n readonly values?: ValuePolicy | undefined;\n /**\n * Stable identity for this attachment, unique across processes.\n *\n * Defaults to a fresh UUID, which is right for an ordinary app. The hub sets\n * it explicitly so it can recognise its own self-attachment in the list it\n * serves — `runtimeId` cannot do that job, because it comes from a\n * per-process counter and every runtime's first one is `runtime-1`.\n *\n * Minted per *call*, not per attempt: `attachDevtools` reuses one across\n * reconnects, so an app that outlives a hub restart comes back as itself.\n */\n readonly instanceId?: string;\n /** How many times this runtime has already attached. See `AttachmentInfo`. */\n readonly generation?: number;\n /**\n * Called once the hub has accepted this attempt.\n *\n * Exists so the caller can count reconnections without having to guess from\n * the outside which attempts got as far as being accepted.\n */\n readonly onAttached?: (() => void) | undefined;\n /**\n * Return false to leave a record out of the stream entirely.\n *\n * Distinct from the drop counter below, and the difference matters: a drop is\n * a gap the hub must be told about, because an agent reading the feed has to\n * be able to tell \"did not happen\" from \"was lost\". A record excluded here\n * was never in scope, so it is not a gap and is not counted as one.\n *\n * Exists for one caller — the hub, which observes the runtime it is also\n * writing into and would otherwise feed itself forever. An ordinary app has\n * no reason to pass this.\n */\n readonly include?: (record: Runtime.RuntimeEventRecord) => boolean;\n};\n\n/**\n * Mints the id that identifies this runtime for the life of the process.\n *\n * Deliberately not `crypto.randomUUID`, which this used to be. That call is not\n * available everywhere a Frond app runs — React Native has no global `crypto`\n * until a polyfill installs one — and reaching for it meant either a startup\n * crash on the runtime least able to explain it, or a guard, and a guard is a\n * branch whose two halves nobody exercises together.\n *\n * The entropy was never the requirement. This id has to be unique among the\n * handful of apps attached to one local hub at one time, and stable across that\n * process's own reconnects. Nothing authenticates with it, nothing persists it,\n * and it dies with the hub. A timestamp for cross-process separation and a short\n * random suffix for anything started inside the same millisecond covers that\n * with room to spare; the timestamp is the half that matters, because\n * `Math.random` is seeded per process and two processes launched together is\n * exactly where bare randomness is weakest.\n *\n * If this ever fronts something that is not a local devtools socket, it needs a\n * real generator — but then it also needs a real identity, not this.\n */\nexport function newInstanceId(): string {\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\n/**\n * Transport for one attachment.\n *\n * Exported because the hub dials itself over exactly this layer — same\n * protocol, same serialization, same socket code path as a real app. If\n * self-attach works, the transport works.\n */\nexport function attachLayer(attachUrl: string): Layer.Layer<RpcClient.Protocol> {\n return RpcClient.layerProtocolSocket().pipe(\n Layer.provide(Socket.layerWebSocket(attachUrl)),\n Layer.provide(Socket.layerWebSocketConstructorGlobal),\n Layer.provide(RpcSerialization.layerNdjson)\n );\n}\n\n/**\n * Streams a runtime's events to a hub for as long as the connection lives.\n *\n * The returned Effect does not settle while attached — it *is* the attachment.\n * Fork it into a scope and close the scope to detach; the hub learns about the\n * detachment from the socket dying, which is the only mechanism that also works\n * when the app crashes.\n */\nexport const attachRuntime = Effect.fnUntraced(function* (options: AttachOptions) {\n const client = yield* RpcClient.make(FrondHubRpcs);\n\n const ceiling: ValuePolicy = options.values ?? \"shape\";\n\n let buffer: Array<EncodedEventRecord> = [];\n let dropped = 0;\n // Events fire between the socket opening and the `Attached` command arriving,\n // and the conservative reading of an unanswered negotiation is the narrow\n // one. Still clamped, so a ceiling of `\"none\"` holds from the first record.\n let policy: EncodePolicy = resolvePolicy(\"shape\", ceiling);\n let attachmentId: string | undefined;\n\n // Encoding happens here, at observe time, not at flush time: a\n // `RuntimeEventRecord` carries live references that keep mutating after the\n // record is handed out, so a record buffered raw would describe the graph as\n // it is when flushed, not as it was when the event fired.\n const subscription = options.runtime.observe((record) => {\n // Before the buffer check, so an excluded record cannot be counted as a\n // drop, and before encoding, so it costs nothing to exclude one.\n if (options.include !== undefined && !options.include(record)) {\n return;\n }\n\n if (buffer.length >= MAX_BUFFERED_RECORDS) {\n dropped += 1;\n return;\n }\n\n buffer.push(encodeRecord(record, policy));\n });\n\n yield* Effect.addFinalizer(() => Effect.sync(() => subscription.unsubscribe()));\n\n const info: AttachmentInfo = {\n protocolVersion: HUB_PROTOCOL_VERSION,\n instanceId: options.instanceId ?? newInstanceId(),\n runtimeId: options.runtime.getSnapshotSync().runtimeId,\n generation: options.generation ?? 0,\n name: options.name,\n platform: options.platform,\n startedAt: yield* Clock.currentTimeMillis,\n // Advertised so the hub can show what it is going to get. Advisory only:\n // `resolvePolicy` below is what actually enforces it, because a ceiling a\n // sender merely announces is one the sender can forget to apply.\n values: ceiling,\n };\n\n const flushOnce = Effect.gen(function* () {\n yield* Effect.sleep(FLUSH_INTERVAL);\n\n const id = attachmentId;\n\n if (id === undefined || (buffer.length === 0 && dropped === 0)) {\n return;\n }\n\n // Swapped, not drained: `observe` runs on whatever fiber produced the\n // event, so anything appended during the send lands in the next batch\n // instead of being lost to a splice race.\n const records = buffer;\n const droppedSince = dropped;\n buffer = [];\n dropped = 0;\n\n yield* client[\"Frond.Ingest\"]({ attachmentId: id, records, droppedSince });\n });\n\n yield* Effect.forkScoped(Effect.forever(flushOnce));\n\n /**\n * Answers one query, on its own fiber.\n *\n * Forked rather than awaited inline because this runs on the command stream:\n * a snapshot of a large graph is the most expensive thing this client does,\n * and blocking here would stall the heartbeat and every query behind it\n * behind one slow answer.\n *\n * Nothing in here is allowed to fail outward. A query that throws comes back\n * as `Failed`, because the alternative is an error escaping into the stream\n * handler and taking down an attachment over a question that was only ever\n * advisory.\n */\n const answer = (command: Extract<HubCommand, { readonly _tag: \"Query\" }>) =>\n Effect.gen(function* () {\n const id = attachmentId;\n\n if (id === undefined) {\n return;\n }\n\n const capturedAt = yield* Clock.currentTimeMillis;\n\n const outcome = yield* Effect.map(\n Effect.exit(\n Effect.sync(() => {\n // Clamped against the ceiling, not against the stream's policy. A\n // deliberate read may ask for more than the firehose gets, and may\n // never ask for more than the app agreed to disclose.\n const requested = resolvePolicy(command.values, ceiling);\n\n return encodeGraphSnapshot(options.runtime.getSnapshotSync(), {\n policy: requested,\n capturedAt,\n nodeId: command.query._tag === \"Node\" ? command.query.nodeId : undefined,\n });\n })\n ),\n (exit): QueryOutcome =>\n exit._tag === \"Success\"\n ? { _tag: \"Snapshot\", snapshot: exit.value }\n : { _tag: \"Failed\", reason: failureReason(exit.cause) }\n );\n\n yield* Effect.ignore(\n client[\"Frond.Reply\"]({ attachmentId: id, requestId: command.requestId, outcome })\n );\n });\n\n yield* Stream.runForEach(client[\"Frond.Attach\"]({ info }), (command) => {\n if (command._tag === \"Attached\") {\n return Effect.sync(() => {\n attachmentId = command.attachmentId;\n policy = resolvePolicy(command.values, ceiling);\n options.onAttached?.();\n });\n }\n\n if (command._tag === \"Query\") {\n return Effect.forkScoped(answer(command));\n }\n\n return Effect.void;\n });\n});\n\n/**\n * A reason string for a query that could not be answered.\n *\n * Deliberately thin. This travels to a hub that will show it to whoever asked,\n * and the useful cases — an unstarted runtime, a node id that does not resolve —\n * already say so in their message. Serializing a cause chain here would mean a\n * second, competing account of failures next to the one the event stream\n * already carries.\n */\nfunction failureReason(cause: unknown): string {\n if (cause instanceof Error) {\n return cause.message === \"\" ? cause.name : cause.message;\n }\n\n return String(cause);\n}\n",
|
|
6
6
|
"import { Diagnostics } from \"@frondruntime/core\";\nimport type { ErrorDescriptor } from \"./descriptors.ts\";\nimport type { EncodePolicy } from \"./policy.ts\";\n\n/**\n * Failures, as chains of causes.\n *\n * Kept apart from the two value encoders because it is not one: a failure is\n * described the same way at every policy, and what varies is only how much of\n * each frame crosses. The value encoders call in here; nothing here calls back\n * out to them except through {@link FullContext}, which is what keeps this\n * module a leaf.\n */\n\n/**\n * How far up a `cause` chain to walk. Matches the core default.\n *\n * Chains this long are rare and the frames are small; the expensive parts of a\n * frame — its stack and its payload — are bounded separately below.\n */\nconst CAUSE_MAX_DEPTH = 8;\nconst SHAPE_CAUSE_STRING_LENGTH = 256;\nconst FULL_CAUSE_STRING_LENGTH = 1024;\n/**\n * How much stack to take from core before selecting frames out of it.\n *\n * Deliberately far above anything a real stack reaches: cutting here cuts by\n * character, which is the thing {@link abridgeStack} exists to stop doing. This\n * is a guard against a fabricated `stack` string, not a budget.\n */\nconst CAUSE_STACK_SOURCE_LENGTH = 32768;\n/**\n * How many frames survive selection.\n *\n * The frame that names app code is almost always within the first few once the\n * library frames are gone; fifteen is room for a couple of layers of wrapping on\n * top of that without the trace becoming the record.\n */\nconst KEPT_STACK_FRAMES = 15;\n/** Kept from a trace that is library frames all the way down. See {@link abridgeStack}. */\nconst LIBRARY_ONLY_STACK_FRAMES = 2;\n/** The fallback bound, for a `stack` this cannot read as frames at all. */\nconst FULL_CAUSE_STACK_LENGTH = 2048;\n\n/**\n * Frames, in the two formats a JS runtime produces.\n *\n * V8 (Node, Bun, Chromium) indents every frame with `at `; JSC and SpiderMonkey\n * write `name@url:line:column`. Matched rather than assumed because the header\n * of a stack is the error's own message, which is app text and must not be\n * mistaken for a frame and dropped.\n */\nconst V8_STACK_FRAME = /^\\s*at\\s\\S/;\n// Anchored and whitespace-free on both sides of the `@`, because a JSC stack has\n// no header line to protect it: a message like `Cannot find module\n// /app/node_modules/x/index.js:1:1` ends the way a frame ends, and an unanchored\n// pattern would call line 0 a frame, leaving `header` empty and feeding the\n// message itself to the library filter.\nconst AT_STACK_FRAME = /^\\S*@\\S*:\\d+:\\d+\\s*$/;\n\n/**\n * Frames that belong to someone else's code.\n *\n * `node_modules` is the whole point; the rest are the same idea for code that\n * has no file in the tree at all — Node's builtins, Bun's, and native frames.\n * Bun writes its own native frames as `at moduleEvaluation (native:1:11)` rather\n * than in either of the parenthesized spellings, hence the bare `native:`.\n */\nconst LIBRARY_STACK_FRAME = /node_modules|node:|bun:|native:|\\(native\\)|\\[native code]/;\n\n/**\n * What the `\"full\"` policy needs in order to encode an error's own payload.\n *\n * `encodeValue` is injected rather than imported. The full encoder descends into\n * errors and errors descend into their payloads, so calling that encoder by name\n * from here would make the two modules mutually recursive at module scope for no\n * gain — the caller already holds the depth, the `seen` set and the budget that\n * such a call would need, and closing over them is both shorter and the only\n * arrangement in which this file has no dependency on either value encoder.\n *\n * `seen` is still passed through, because this function adds to it: every link\n * of the chain joins the ancestor path for the duration of the walk below it.\n */\nexport type FullContext = {\n readonly seen: Set<object>;\n readonly encodeValue: (value: unknown) => unknown;\n};\n\n/**\n * Serializes a failure and everything that caused it.\n *\n * Thin over `Diagnostics.serializeCauseChain`, which is already the runtime's\n * own answer to \"what went wrong\" and is already defensive about it — getters\n * that throw, cycles, absent fields. Reusing it means the devtools feed and a\n * runtime sink describe the same failure the same way; hand-rolling a second\n * walk here would eventually mean two accounts of one error that disagree.\n *\n * `preview` is dropped from every frame. Core builds it for a human reading a\n * report, and for an `Error` it is name, message, stack and cause — all of\n * which the frame already carries, one of them recursively, so keeping it would\n * send the chain once per link and add nothing.\n *\n * Two things are `\"full\"`-only, for the same reason the rest of this encoder\n * withholds things. A `stack` is bulk at `\"shape\"`: a wall of Effect internals\n * around the two frames that name app code. And `fields` is the error's own\n * payload — `status`, `endpoint`, whatever the app put on it — which is app\n * data by any other name. What survives at `\"shape\"` is what the chain names\n * explicitly: `tag`, `nodeId`, `operation`, `dependency`, `path`.\n */\nexport function describeError(\n value: unknown,\n policy: EncodePolicy,\n full?: FullContext\n): ErrorDescriptor {\n const disclose = policy === \"full\";\n\n const frames = Diagnostics.serializeCauseChain(value, {\n maxDepth: CAUSE_MAX_DEPTH,\n maxStringLength: disclose ? FULL_CAUSE_STRING_LENGTH : SHAPE_CAUSE_STRING_LENGTH,\n // Asked for whole, then abridged by frame below. Core can only cut by\n // character, which is exactly the cut that loses the frame worth keeping.\n maxStackLength: CAUSE_STACK_SOURCE_LENGTH,\n maxObjectKeys: disclose ? 20 : 8,\n });\n\n if (full === undefined) {\n // `path` and `valueKind` are the two frame fields that describe the app's\n // data rather than the runtime's: a path is a list of the app's own key\n // names, and a value kind says whether what failed was an array or an\n // object. Both are shape by any definition, so `\"none\"` — whose whole\n // contract is that no shape crosses — drops them. The message still\n // crosses at every policy; that is deliberate, and it is the one thing a\n // reader cannot diagnose without.\n const shed = policy === \"none\" ? { path: undefined, valueKind: undefined } : {};\n\n return {\n _: \"error\",\n message: rootMessage(frames),\n causes: frames.map((frame) =>\n compact({ ...frame, ...shed, stack: undefined, preview: undefined })\n ),\n };\n }\n\n // Every link joins the ancestor path for the duration, so a payload field\n // pointing back at an error already on the chain is a cycle rather than a\n // second trip through this function.\n //\n // Only what this call actually inserted comes back out. A link an enclosing\n // frame is still standing on has to stay marked: an error reached through an\n // app object whose payload points back at that object is the ordinary shape of\n // a wrapped failure, and un-marking it there would let the walk descend into\n // the ancestor instead of naming the cycle.\n const links = causeValues(value, frames.length);\n const marked = links.filter(\n (link): link is object => typeof link === \"object\" && link !== null && !full.seen.has(link)\n );\n\n for (const link of marked) {\n full.seen.add(link);\n }\n\n try {\n return {\n _: \"error\",\n message: rootMessage(frames),\n causes: frames.map((frame, index) =>\n compact({\n ...frame,\n preview: undefined,\n stack: frame.stack === undefined ? undefined : abridgeStack(frame.stack),\n fields: errorFields(links[index], full.encodeValue),\n })\n ),\n };\n } finally {\n for (const link of marked) {\n full.seen.delete(link);\n }\n }\n}\n\n/**\n * A stack, selected by frame instead of cut by character.\n *\n * A raw stack is mostly other people's code — Effect's fiber runtime, the test\n * runner, the module loader — and the frames that name the app are scattered\n * through it rather than at the top. Truncating at a character count therefore\n * spends the budget on internals and can cut the one frame a reader needed, so\n * this drops library frames outright and keeps the first {@link\n * KEPT_STACK_FRAMES} of what is left.\n *\n * The dropped count is not decoration. An abridged trace that does not say it is\n * abridged reads as \"this is where it came from\", and a reader who then cannot\n * find the caller concludes the wrong thing about the code rather than about the\n * trace.\n *\n * Two cases deliberately do not select. A trace that is library frames all the\n * way down — a failure raised entirely inside a dependency — still says where in\n * that dependency, and an empty stack would throw that away for nothing. And a\n * `stack` with no recognizable frames is not a stack this can reason about, so\n * it falls back to the character bound rather than guessing.\n */\nfunction abridgeStack(stack: string): string {\n const lines = stack.split(\"\\n\");\n const first = lines.findIndex(isStackFrame);\n\n if (first === -1) {\n return stack.length <= FULL_CAUSE_STACK_LENGTH\n ? stack\n : `${stack.slice(0, FULL_CAUSE_STACK_LENGTH)}…`;\n }\n\n // Everything above the first frame is the error's own header, kept whole: it\n // is the name and message, which is the part a reader reads first.\n const header = lines.slice(0, first);\n // Counted against everything below the header, not just the lines the two\n // patterns recognize. JSC writes frames this cannot parse — `promiseReactionJob@[native code]`\n // has no `:line:col` — and dropping those out of the denominator would let the\n // trace claim it accounted for what it removed while quietly removing more.\n const body = lines.slice(first).filter((line) => line.trim() !== \"\");\n const frames = body.filter(isStackFrame);\n const own = frames.filter((line) => !LIBRARY_STACK_FRAME.test(line));\n const kept = (own.length === 0 ? frames.slice(0, LIBRARY_ONLY_STACK_FRAMES) : own).slice(\n 0,\n KEPT_STACK_FRAMES\n );\n const dropped = body.length - kept.length;\n\n if (dropped === 0) {\n return [...header, ...kept].join(\"\\n\");\n }\n\n return [\n ...header,\n ...kept,\n ` … ${dropped} frame${dropped === 1 ? \"\" : \"s\"} dropped: library internals, unrecognized lines, and any past the first ${KEPT_STACK_FRAMES}`,\n ].join(\"\\n\");\n}\n\nfunction isStackFrame(line: string): boolean {\n return V8_STACK_FRAME.test(line) || AT_STACK_FRAME.test(line);\n}\n\n/**\n * Re-walks the chain for the values behind the frames.\n *\n * Bounded by `count`, which is the frame count rather than a limit of its own:\n * two walks of the same chain that could stop in different places would\n * eventually pair a frame with the wrong value.\n */\nfunction causeValues(root: unknown, count: number): ReadonlyArray<unknown> {\n const values: Array<unknown> = [];\n let current: unknown = root;\n\n for (let index = 0; index < count; index += 1) {\n values.push(current);\n\n if (typeof current !== \"object\" || current === null) {\n break;\n }\n\n try {\n current = (current as Record<string, unknown>)[\"cause\"];\n } catch {\n break;\n }\n }\n\n return values;\n}\n\n/**\n * Keys a frame already accounts for, by name, and should not repeat.\n *\n * `cause` is the next frame. The rest are what `serializeCauseChain` lifts out\n * of a failure into named fields — sometimes renamed, as `tag` is to `nodeTag`,\n * which is why this list is written against the *source* keys and has to stay\n * in step with that function rather than with the frame type.\n */\nconst NAMED_ERROR_KEYS = new Set([\n \"boundary\",\n \"cancellation\",\n \"cause\",\n \"dependency\",\n \"invariant\",\n \"kind\",\n \"message\",\n \"name\",\n \"nodeId\",\n \"operation\",\n \"path\",\n \"stack\",\n \"tag\",\n \"timeout\",\n \"_tag\",\n]);\n\n/**\n * What a failure carries beyond being a failure.\n *\n * The half of an error a cause chain cannot name in advance: an HTTP status, a\n * request id, the arguments the call was made with. `undefined` when there is\n * none, which is the common case — a wrapper carries nothing but the fields\n * above — and {@link compact} drops the key on the way out.\n */\nfunction errorFields(value: unknown, encodeValue: (value: unknown) => unknown): unknown {\n if (typeof value !== \"object\" || value === null) {\n // A thrown string or number is its own payload, and the frame's `message`\n // only got a rendering of it.\n return encodeValue(value);\n }\n\n const own: Record<string, unknown> = {};\n\n try {\n for (const key of Object.keys(value)) {\n if (!NAMED_ERROR_KEYS.has(key)) {\n own[key] = (value as Record<string, unknown>)[key];\n }\n }\n } catch {\n return undefined;\n }\n\n return Object.keys(own).length === 0 ? undefined : encodeValue(own);\n}\n\n/**\n * The innermost thing that had something to say.\n *\n * Two kinds of frame have nothing: a `Data.TaggedError` wrapper, whose message\n * is empty, and a failure that is not an error at all — a node status, say —\n * for which core falls back to the value's kind. Both are skipped, the second\n * because `\"object\"` in a field called `message` reads as a message and is not\n * one. When the whole chain is like that, the outermost frame's own name is the\n * most this can honestly say, and the frames below it carry the rest.\n */\nfunction rootMessage(frames: ReadonlyArray<Diagnostics.SerializedCauseFrame>): string {\n for (let index = frames.length - 1; index >= 0; index -= 1) {\n const frame = frames[index];\n const message = frame?.message;\n\n if (message !== undefined && message !== \"\" && message !== frame?.valueKind) {\n return message;\n }\n }\n\n return frames[0]?.tag ?? frames[0]?.name ?? \"\";\n}\n\n/**\n * Drops absent keys.\n *\n * A cause frame declares every field any failure might carry, so most of them\n * are `undefined` on any given one. JSON would drop those anyway; doing it here\n * means the in-memory record the hub retains and renders matches the wire.\n */\nfunction compact(frame: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(frame)) {\n if (value !== undefined) {\n out[key] = value;\n }\n }\n\n return out;\n}\n",
|
|
7
7
|
"/**\n * The vocabulary both encoders emit where a value did not survive whole.\n *\n * Shared rather than duplicated because the two encoders disagree about almost\n * everything else — `\"shape\"` says as little as it can and `\"full\"` says as much\n * as it can — and the one thing they must agree on is how a reader tells a\n * marker from data.\n */\n\n/**\n * A failure, as its chain of causes rather than as its outermost link.\n *\n * The outermost link is almost never the interesting one. Frond wraps failures\n * as it unwinds — `RefreshFailed` around `ActionFailed` around whatever the app\n * actually threw — and those wrappers are `Data.TaggedError`s, whose `message`\n * is the empty string. Encoding one as `{name, message}` therefore yields\n * `{\"RefreshFailed\", \"\"}`: the shape of an answer with none of the content.\n *\n * Deliberately not a *projection*. Core can also produce one of those, with a\n * headline, a severity guess and a retryability guess, and it is the right thing\n * to put in front of a human or into an error reporter. This feed is read by an\n * agent, which is better served by the frames themselves — every wrapper, in\n * order, with the fields each one carries — than by someone else's summary of\n * them.\n */\nexport type ErrorDescriptor = {\n readonly _: \"error\";\n /**\n * The deepest non-empty message in the chain: what actually went wrong.\n *\n * A selection, not a synthesis — it is one of the messages in `causes`,\n * hoisted because it is the field worth reading first and it is otherwise\n * buried under however many wrappers the unwinding added.\n */\n readonly message: string;\n /** Outermost first. Frame `n + 1` is frame `n`'s `cause`. */\n readonly causes: ReadonlyArray<Record<string, unknown>>;\n};\n\n/**\n * A marker that survived where a value did not.\n *\n * Only ever emitted alongside real data — at `\"full\"`, and at `\"shape\"` for a\n * string long enough to be cut — which is why these stay objects while the\n * `\"shape\"` vocabulary is strings. A reader looking at real values has to be\n * able to tell a marker from one of them, and `{_: …}` is that tell.\n *\n * `_` rather than `_tag` so a descriptor is never mistaken for a domain tagged\n * union by anything reading the feed.\n *\n * Two markers are *keys* rather than arms of this union, because they annotate\n * an encoded object from the inside and have nowhere else to go: `\"full\"` adds\n * `_type` — a string — to a class instance, and `_elided` (whose value is the\n * `\"elided\"` arm below) to an object whose key list was cut. Both are listed\n * here so this type stays the one place the vocabulary is written down.\n */\nexport type ShapeDescriptor =\n | { readonly _: \"opaque\"; readonly type: string }\n | { readonly _: \"string\"; readonly length: number; readonly head: string }\n | ErrorDescriptor\n /** A value already on the path above this one. Emitted instead of recursing. */\n | { readonly _: \"cycle\" }\n /** A bound stopped the walk here. `by` names which one. */\n | { readonly _: \"elided\"; readonly by: \"depth\" | \"budget\" | \"entries\"; readonly length?: number }\n /**\n * Collections, at `\"full\"` only — `\"shape\"` names them `Map(3)` and `Set(3)`.\n * `size` is the collection's real size; `entries` and `values` are what\n * survived the entry bound, so the two disagree when one was hit.\n */\n | {\n readonly _: \"map\";\n readonly entries: ReadonlyArray<readonly [unknown, unknown]>;\n readonly size: number;\n }\n | { readonly _: \"set\"; readonly values: ReadonlyArray<unknown>; readonly size: number };\n\n/**\n * What `\"none\"` puts where a value was.\n *\n * A word, not a descriptor: `\"none\"` is the policy that has decided the reader\n * learns nothing about this value, and a key list or a type name is something.\n * The same marker for every value, so it cannot be read as a shape either.\n */\nexport const WITHHELD = \"withheld\";\n\n/**\n * Reading a value can run the app's code, so reading it can throw.\n *\n * A getter that throws, a revoked `Proxy` — a finalized immer draft, a torn-down\n * reactive scope — a prototype whose `constructor` is a throwing getter: every\n * one of those turns `Object.keys` or an `instanceof` into an exception, and\n * none of them is exotic in a frontend app.\n *\n * The consequence is what makes this worth guarding rather than letting throw.\n * On the event path the encoder runs inside the app's own observer, and core\n * routes an observer failure to sinks only — so the record would vanish without\n * incrementing `dropped`, which is exactly the \"did not happen\" versus \"was\n * lost\" distinction the protocol exists to preserve. On the snapshot path one\n * unreadable node would fail the whole graph read and leave a reader with\n * nothing instead of with 299 good rows and one marked hole.\n *\n * `{_: \"opaque\"}` is the honest answer: there is something here, and this\n * encoder could not look at it. The thrown error's own message is not carried —\n * it comes from app code, and a `\"shape\"` read that let one through would be a\n * hole in the policy rather than a diagnostic.\n */\nexport const UNREADABLE = { _: \"opaque\", type: \"unreadable\" } satisfies ShapeDescriptor;\n",
|
|
8
8
|
"import { describeError } from \"./cause.ts\";\nimport { type ShapeDescriptor, UNREADABLE } from \"./descriptors.ts\";\n\n/**\n * Bounds for `\"full\"`. Termination guards, not a byte budget.\n *\n * This encoder runs against a loopback socket, so bytes are close to free; what\n * these stop is a cycle the `seen` set cannot catch, a proxy that manufactures\n * keys on demand, or a linked list a few hundred thousand long — cases where the\n * walk would hang the observed app inside its own devtools. Set them where a\n * pathological structure trips them and a large-but-real one does not, and every\n * one of them announces itself in the output. A cap an agent cannot see is worse\n * than a low cap: it turns \"there was more\" into \"that was all\", which is the\n * one thing this feed must never say.\n */\nconst FULL_MAX_DEPTH = 24;\nconst FULL_MAX_STRING_LENGTH = 65536;\nconst FULL_MAX_ENTRIES = 4096;\n/**\n * Total encoded values per record, across the whole tree.\n *\n * Counts values, not characters: one 64k string spends the same allowance as\n * `true`. So this bounds how long the walk runs, and only loosely bounds what it\n * produces — which is the right trade here, where the walk is the expensive half\n * and the wire is a socket to the same machine.\n */\nexport const FULL_MAX_NODES = 50000;\n\nexport type Budget = { remaining: number };\n\n/**\n * Reduces a value to JSON-safe form while keeping its contents.\n *\n * The counterpart to `describeShape`, and the opposite default: where the shape\n * encoder asks \"what can I say without revealing this\", this one asks \"what is\n * the least I can leave out\".\n *\n * Which is also why it does not share that encoder's string vocabulary. Here the\n * values around a marker are real data, so a marker has to stay\n * distinguishable from one — hence `{_: \"elided\"}` rather than a word. There,\n * nothing structured is real, so there is nothing for a word to collide with.\n *\n * `seen` is the ancestor path, not every value visited. A value that appears\n * twice in a result — a shared config object, the same node referenced by two\n * dependents — is legitimately encoded twice; only a value containing *itself*\n * is a cycle. Tracking all visited values instead would silently blank out\n * shared structure and read as data loss.\n */\nexport function describeFull(\n value: unknown,\n depth: number,\n seen: Set<object>,\n budget: Budget\n): unknown {\n if (budget.remaining <= 0) {\n return { _: \"elided\", by: \"budget\" } satisfies ShapeDescriptor;\n }\n\n budget.remaining -= 1;\n\n if (value === null || value === undefined) {\n return value ?? null;\n }\n\n switch (typeof value) {\n case \"boolean\":\n case \"number\": {\n return value;\n }\n // Not JSON-safe, and no rendering of them is more useful than saying what\n // they were.\n case \"bigint\": {\n return { _: \"opaque\", type: `bigint:${value.toString()}` } satisfies ShapeDescriptor;\n }\n case \"function\": {\n return {\n _: \"opaque\",\n type: `function:${(value as { readonly name?: string }).name || \"anonymous\"}`,\n } satisfies ShapeDescriptor;\n }\n case \"symbol\": {\n return { _: \"opaque\", type: value.toString() } satisfies ShapeDescriptor;\n }\n case \"string\": {\n return value.length <= FULL_MAX_STRING_LENGTH\n ? value\n : ({\n _: \"string\",\n length: value.length,\n head: value.slice(0, FULL_MAX_STRING_LENGTH),\n } satisfies ShapeDescriptor);\n }\n default: {\n return describeFullStructure(value as object, depth, seen, budget);\n }\n }\n}\n\nfunction describeFullStructure(\n value: object,\n depth: number,\n seen: Set<object>,\n budget: Budget\n): unknown {\n try {\n return describeFullStructureUnguarded(value, depth, seen, budget);\n } catch {\n // See {@link UNREADABLE}. The `seen` set is left as this call found it: the\n // one place that adds to it deletes in a `finally`.\n return UNREADABLE;\n }\n}\n\nfunction describeFullStructureUnguarded(\n value: object,\n depth: number,\n seen: Set<object>,\n budget: Budget\n): unknown {\n if (seen.has(value)) {\n return { _: \"cycle\" } satisfies ShapeDescriptor;\n }\n\n if (value instanceof Error) {\n const described = describeError(value, \"full\", {\n seen,\n encodeValue: (own) => describeFull(own, depth + 1, seen, budget),\n });\n\n // Charged against the record's allowance like any other subtree, so one\n // deeply-wrapped failure cannot spend the whole budget on itself.\n budget.remaining -= described.causes.length;\n\n return described;\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n if (depth >= FULL_MAX_DEPTH) {\n return { _: \"elided\", by: \"depth\" } satisfies ShapeDescriptor;\n }\n\n seen.add(value);\n\n try {\n if (Array.isArray(value)) {\n const kept = value.slice(0, FULL_MAX_ENTRIES);\n const encoded: Array<unknown> = kept.map((entry) =>\n describeFull(entry, depth + 1, seen, budget)\n );\n\n if (value.length > FULL_MAX_ENTRIES) {\n encoded.push({\n _: \"elided\",\n by: \"entries\",\n length: value.length,\n } satisfies ShapeDescriptor);\n }\n\n return encoded;\n }\n\n if (value instanceof Map) {\n return {\n _: \"map\",\n entries: [...value.entries()]\n .slice(0, FULL_MAX_ENTRIES)\n .map(\n ([key, entry]) =>\n [\n describeFull(key, depth + 1, seen, budget),\n describeFull(entry, depth + 1, seen, budget),\n ] as const\n ),\n size: value.size,\n } satisfies ShapeDescriptor;\n }\n\n if (value instanceof Set) {\n return {\n _: \"set\",\n values: [...value.values()]\n .slice(0, FULL_MAX_ENTRIES)\n .map((entry) => describeFull(entry, depth + 1, seen, budget)),\n size: value.size,\n } satisfies ShapeDescriptor;\n }\n\n const out: Record<string, unknown> = {};\n\n // Own enumerable keys only. Walking the prototype chain would drag in\n // methods and framework internals, which is noise rather than visibility.\n const allKeys = Object.keys(value);\n const keys = allKeys.slice(0, FULL_MAX_ENTRIES);\n\n for (const key of keys) {\n out[key] = describeFull((value as Record<string, unknown>)[key], depth + 1, seen, budget);\n }\n\n // An array that gets truncated pushes a marker; an object has to carry one\n // as a key, and a silently short key list is the failure this whole encoder\n // is written against — it reads as \"the object had 256 keys\", which is a lie\n // the consumer has no way to detect.\n //\n // A real key named `_elided` loses to the marker. Preferred over a mangled\n // name: the collision is vanishingly rare, and a marker under a name nobody\n // reads is the same as no marker.\n if (allKeys.length > keys.length) {\n out[\"_elided\"] = {\n _: \"elided\",\n by: \"entries\",\n length: allKeys.length,\n } satisfies ShapeDescriptor;\n }\n\n const prototype = Object.getPrototypeOf(value) as unknown;\n\n // Class instances keep their type name alongside their fields: knowing a\n // value is a `HubServerResult` and not a bag of keys is most of what makes\n // a graph result readable.\n if (prototype !== null && prototype !== Object.prototype) {\n out[\"_type\"] =\n (value.constructor as { readonly name?: string } | undefined)?.name ?? \"object\";\n }\n\n return out;\n } finally {\n seen.delete(value);\n }\n}\n",
|
|
9
9
|
"import { describeError } from \"./cause.ts\";\nimport { type ShapeDescriptor, UNREADABLE } from \"./descriptors.ts\";\n\nconst MAX_STRING_LENGTH = 256;\nconst MAX_KEYS = 32;\nconst MAX_DEPTH = 3;\n\n/**\n * Reduces a value to something JSON-safe that cannot carry user data.\n *\n * Small primitives pass through, because in a runtime event they are ids, tags,\n * timestamps, and flags — the entire signal. Anything structured becomes a\n * descriptor: a node result or an action input is exactly the kind of value\n * that must not leave the process, and it is always an object or an array.\n *\n * ## The shape vocabulary\n *\n * One line per value, in a syntax that says what it is without a legend:\n *\n * ```text\n * {} a plain object, no own keys\n * {id,name,total} a plain object with those keys, in order\n * {id,name,…} …and more keys than {@link MAX_KEYS}\n * Wired{_tag,run} the same object, discriminated: its `_tag` is \"Wired\"\n * AccountModel{?} a class instance — the type, and no claim about fields\n * string[42] an array of 42, named by its first element\n * {id,name}[3] the same, where that element is an object\n * unknown[0] an empty array: nothing to name it by\n * Map(3) / Set(3) collections, by size\n * function / symbol / bigint values with no JSON form\n * {…} / […] the depth bound stopped the walk here\n * ```\n *\n * Strings rather than the `{_: \"object\", keys, truncated}` objects this used to\n * emit, and the reason is the reader rather than the wire: this feed is read by\n * an agent through MCP, where each descriptor arrived as several lines of\n * pretty-printed JSON to say one thing about one field. A node result rendered\n * as forty lines that contain no data is worse than one rendered as `{id,name}`.\n *\n * Lossless, which is the part that makes it safe: a shape descriptor is only\n * ever produced once the policy has decided the value itself is not crossing, so\n * there is nothing behind it that a richer encoding could have expanded to.\n *\n * The residual ambiguity is named rather than defended: a short app string that\n * happens to read `\"function\"` crosses verbatim at this policy and is\n * indistinguishable from the descriptor. Structured values are not ambiguous —\n * none of them cross — and paying an object per field to fix a collision with a\n * literal `\"function\"` is the wrong trade.\n */\nexport function describeShape(value: unknown, depth: number): unknown {\n if (value === null || value === undefined) {\n return value ?? null;\n }\n\n switch (typeof value) {\n case \"boolean\":\n case \"number\": {\n return value;\n }\n case \"bigint\":\n case \"function\":\n case \"symbol\": {\n return typeof value;\n }\n case \"string\": {\n // The one descriptor that stays an object at this policy, because it is\n // the one carrying content: `head` is app data, and a reader has to be\n // able to tell it from a string that crossed whole.\n return value.length <= MAX_STRING_LENGTH\n ? value\n : ({\n _: \"string\",\n length: value.length,\n head: value.slice(0, MAX_STRING_LENGTH),\n } satisfies ShapeDescriptor);\n }\n default: {\n return describeStructure(value, depth);\n }\n }\n}\n\n/** See {@link UNREADABLE} for why this cannot be allowed to throw. */\nfunction describeStructure(value: object, depth: number): unknown {\n try {\n return describeStructureUnguarded(value, depth);\n } catch {\n return UNREADABLE;\n }\n}\n\nfunction describeStructureUnguarded(value: object, depth: number): unknown {\n // Before the depth check: a failure nested past the limit is still the reason\n // the event exists, and \"an object, elided\" is not worth the bytes it saves.\n if (value instanceof Error) {\n return describeError(value, \"shape\");\n }\n\n if (depth >= MAX_DEPTH) {\n return Array.isArray(value) ? \"[…]\" : \"{…}\";\n }\n\n if (Array.isArray(value)) {\n const first = value[0];\n\n // Named by its first element rather than by every one of them: a\n // homogeneous array is the common case and the first entry settles it, and\n // a heterogeneous one is not summarizable at any length worth spending.\n return `${first === undefined ? \"unknown\" : shapeName(first, depth + 1)}[${value.length}]`;\n }\n\n if (value instanceof Map) {\n return `Map(${value.size})`;\n }\n\n if (value instanceof Set) {\n return `Set(${value.size})`;\n }\n\n const prototype = Object.getPrototypeOf(value) as unknown;\n\n // Class instances are app domain objects by construction; the type name is as\n // far as this encoder is willing to go, and `{?}` says the fields exist rather\n // than letting a bare type name read as \"it has none\".\n if (prototype !== null && prototype !== Object.prototype) {\n return `${(value.constructor as { readonly name?: string } | undefined)?.name ?? \"object\"}{?}`;\n }\n\n const keys = Object.keys(value);\n const shown = keys.length > MAX_KEYS ? [...keys.slice(0, MAX_KEYS), \"…\"] : keys;\n // `_tag` is the one nested field that survives verbatim. A discriminant is\n // structure, not data — and a failure feed that says \"an object with these\n // keys\" instead of \"GraphNodeAcquireFailed\" is not worth reading.\n const tag = (value as { readonly _tag?: unknown })._tag;\n\n return `${typeof tag === \"string\" ? tag : \"\"}{${shown.join(\",\")}}`;\n}\n\n/**\n * What an array is an array of.\n *\n * Distinct from {@link describeShape} because that answers with the value where\n * it can — a number stays a number — and a position naming a type needs the\n * type. `typeof` supplies every primitive name; structured entries recurse, so\n * an array of objects reads `{id,name}[3]` and inherits the depth bound with it.\n */\nfunction shapeName(value: unknown, depth: number): string {\n if (value === null) {\n return \"null\";\n }\n\n if (typeof value !== \"object\") {\n return typeof value;\n }\n\n const described = describeStructure(value, depth);\n\n // An `Error` element describes as a cause chain, which is an object. Its\n // descriptor names it `error`, so the array says the same.\n return typeof described === \"string\" ? described : \"error\";\n}\n",
|
|
10
|
-
"import type { Runtime } from \"@frondruntime/core\";\nimport { describeError } from \"./cause.ts\";\nimport { WITHHELD } from \"./descriptors.ts\";\nimport { type Budget, describeFull, FULL_MAX_NODES } from \"./full.ts\";\nimport type { EncodePolicy } from \"./policy.ts\";\nimport type { EncodedEventRecord } from \"./protocol.ts\";\nimport { describeShape } from \"./shape.ts\";\n\n/**\n * Applies a policy to a value.\n *\n * The three encoders this composes are deliberately separate modules: the clamp\n * that decides disclosure (`policy.ts`), the walk that says as little as it can\n * (`shape.ts`), the walk that says as much as it can (`full.ts`), and the one\n * that describes failures the same way at every policy (`cause.ts`). What is\n * left here is the wiring — which walk a policy gets, and how one runtime event\n * is laid out on the wire.\n */\n\n/**\n * A policy, applied to one answer.\n *\n * One of these per record and per snapshot, because the budget it closes over\n * is the thing worth bounding: what a single answer costs the wire. A record\n * with one enormous field should spend its own allowance rather than be judged\n * field by field, and two records should never be able to spend each other's.\n */\nexport type ValueEncoder = {\n /** Ordinary app data, redacted according to the policy. */\n readonly value: (value: unknown) => unknown;\n /**\n * A failure, as a chain of causes.\n *\n * Separate from {@link value} because the runtime already knows which is\n * which, and sniffing would get it wrong: a failure that is not an `Error`\n * instance — an Effect `Cause`, a node status — reaches the value encoder as\n * an anonymous bag of keys.\n */\n readonly failure: (value: unknown) => unknown;\n};\n\nexport function createValueEncoder(policy: EncodePolicy): ValueEncoder {\n // Spelled out rather than folded into the `\"shape\"` branch. Falling through\n // was the bug: `\"none\"` reached the shape encoder and emitted key lists for\n // every node in a graph snapshot, which is a description of app data by an\n // app that had said it would send none.\n if (policy === \"none\") {\n return {\n value: () => WITHHELD,\n // Still a chain, because \"there is an error here\" is not the value's\n // data. What crosses is what the failure names about itself — its tags,\n // its node, the innermost message — and never its payload or its stack,\n // which `describeError` withholds at anything below `\"full\"`.\n failure: (value) => describeError(value, policy),\n };\n }\n\n if (policy === \"shape\") {\n return {\n value: (value) => describeShape(value, 0),\n failure: (value) => describeError(value, policy),\n };\n }\n\n const budget: Budget = { remaining: FULL_MAX_NODES };\n\n return {\n value: (value) => describeFull(value, 0, new Set<object>(), budget),\n // The `seen` set is per call and shared between the two halves of that call:\n // `describeError` marks each link of the chain as an ancestor, and the\n // payload walk it hands off to has to see those marks or it will descend\n // back into an error it is already standing on.\n failure: (value) => {\n const seen = new Set<object>();\n\n return describeError(value, policy, {\n seen,\n encodeValue: (own) => describeFull(own, 1, seen, budget),\n });\n },\n };\n}\n\n/**\n * Encodes one runtime event for the wire.\n *\n * Classification, work context, and node ids are metadata the runtime already\n * owns and are copied verbatim — they are ids and enum members, never user\n * data. Only the event body goes through the value encoder.\n */\nexport function encodeRecord(\n record: Runtime.RuntimeEventRecord,\n policy: EncodePolicy\n): EncodedEventRecord {\n const encoder = createValueEncoder(policy);\n\n // The runtime pulls `failures` straight off the event's own fields, so the\n // same object arrives twice — once as `fields.error`, once as `failures[0]`.\n // Matched by identity so both come out as the same thing; a record that\n // described one failure two different ways would read as two.\n const known = new Set(\n record.failures.filter(\n (failure): failure is object => typeof failure === \"object\" && failure !== null\n )\n );\n\n const encodeField = (value: unknown): unknown =>\n typeof value === \"object\" && value !== null && known.has(value)\n ? encoder.failure(value)\n : encoder.value(value);\n\n return {\n sequence: record.sequence,\n recordedAt: record.recordedAt,\n tag: record.event._tag,\n category: record.classification.category,\n severity: record.classification.severity,\n timeline: record.classification.timeline,\n reportable: record.classification.reportable,\n workId: record.work.workId,\n parentWorkId: record.work.parentWorkId,\n source: record.work.source,\n reason: record.work.reason,\n priority: record.work.priority,\n nodeIds: record.nodeIds,\n fields: policy === \"none\" ? {} : describeFields(record.event, encodeField),\n // Failures are causes, not results: their messages are what makes a\n // devtools feed worth reading, so they are described rather than dropped —\n // including under `\"none\"`, whose subject is values, not what broke.\n //\n // Encoded as failures rather than as values, because that is what the\n // runtime says they are — no sniffing required. Which matters for the ones\n // that are not `Error` instances: an Effect `Cause` reaching the value\n // encoder comes out as a bag of key names.\n failures: record.failures.map(encoder.failure),\n };\n}\n\nfunction describeFields(\n event: Runtime.RuntimeEvent,\n encodeValue: (value: unknown) => unknown\n): Record<string, unknown> {\n const fields: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(event)) {\n if (key === \"_tag\") {\n continue;\n }\n\n fields[key] = encodeValue(value);\n }\n\n return fields;\n}\n",
|
|
10
|
+
"import type { Runtime } from \"@frondruntime/core\";\nimport { describeError } from \"./cause.ts\";\nimport { WITHHELD } from \"./descriptors.ts\";\nimport { type Budget, describeFull, FULL_MAX_NODES } from \"./full.ts\";\nimport type { EncodePolicy } from \"./policy.ts\";\nimport type { EncodedEventRecord } from \"./protocol.ts\";\nimport { describeShape } from \"./shape.ts\";\n\n/**\n * Applies a policy to a value.\n *\n * The three encoders this composes are deliberately separate modules: the clamp\n * that decides disclosure (`policy.ts`), the walk that says as little as it can\n * (`shape.ts`), the walk that says as much as it can (`full.ts`), and the one\n * that describes failures the same way at every policy (`cause.ts`). What is\n * left here is the wiring — which walk a policy gets, and how one runtime event\n * is laid out on the wire.\n */\n\n/**\n * A policy, applied to one answer.\n *\n * One of these per record and per snapshot, because the budget it closes over\n * is the thing worth bounding: what a single answer costs the wire. A record\n * with one enormous field should spend its own allowance rather than be judged\n * field by field, and two records should never be able to spend each other's.\n */\nexport type ValueEncoder = {\n /** Ordinary app data, redacted according to the policy. */\n readonly value: (value: unknown) => unknown;\n /**\n * A failure, as a chain of causes.\n *\n * Separate from {@link value} because the runtime already knows which is\n * which, and sniffing would get it wrong: a failure that is not an `Error`\n * instance — an Effect `Cause`, a node status — reaches the value encoder as\n * an anonymous bag of keys.\n */\n readonly failure: (value: unknown) => unknown;\n};\n\nexport function createValueEncoder(policy: EncodePolicy): ValueEncoder {\n // Spelled out rather than folded into the `\"shape\"` branch. Falling through\n // was the bug: `\"none\"` reached the shape encoder and emitted key lists for\n // every node in a graph snapshot, which is a description of app data by an\n // app that had said it would send none.\n if (policy === \"none\") {\n return {\n value: () => WITHHELD,\n // Still a chain, because \"there is an error here\" is not the value's\n // data. What crosses is what the failure names about itself — its tags,\n // its node, the innermost message — and never its payload or its stack,\n // which `describeError` withholds at anything below `\"full\"`.\n failure: (value) => describeError(value, policy),\n };\n }\n\n if (policy === \"shape\") {\n return {\n value: (value) => describeShape(value, 0),\n failure: (value) => describeError(value, policy),\n };\n }\n\n const budget: Budget = { remaining: FULL_MAX_NODES };\n\n return {\n value: (value) => describeFull(value, 0, new Set<object>(), budget),\n // The `seen` set is per call and shared between the two halves of that call:\n // `describeError` marks each link of the chain as an ancestor, and the\n // payload walk it hands off to has to see those marks or it will descend\n // back into an error it is already standing on.\n failure: (value) => {\n const seen = new Set<object>();\n\n return describeError(value, policy, {\n seen,\n encodeValue: (own) => describeFull(own, 1, seen, budget),\n });\n },\n };\n}\n\n/**\n * Encodes one runtime event for the wire.\n *\n * Classification, work context, and node ids are metadata the runtime already\n * owns and are copied verbatim — they are ids and enum members, never user\n * data. A signal's channel and name join them, on the reasoning\n * `EncodedEventRecord` gives for the two fields. Only the event body goes\n * through the value encoder.\n */\nexport function encodeRecord(\n record: Runtime.RuntimeEventRecord,\n policy: EncodePolicy\n): EncodedEventRecord {\n const encoder = createValueEncoder(policy);\n\n // The runtime pulls `failures` straight off the event's own fields, so the\n // same object arrives twice — once as `fields.error`, once as `failures[0]`.\n // Matched by identity so both come out as the same thing; a record that\n // described one failure two different ways would read as two.\n const known = new Set(\n record.failures.filter(\n (failure): failure is object => typeof failure === \"object\" && failure !== null\n )\n );\n\n const encodeField = (value: unknown): unknown =>\n typeof value === \"object\" && value !== null && known.has(value)\n ? encoder.failure(value)\n : encoder.value(value);\n\n return {\n sequence: record.sequence,\n recordedAt: record.recordedAt,\n tag: record.event._tag,\n category: record.classification.category,\n severity: record.classification.severity,\n timeline: record.classification.timeline,\n reportable: record.classification.reportable,\n workId: record.work.workId,\n parentWorkId: record.work.parentWorkId,\n source: record.work.source,\n reason: record.work.reason,\n priority: record.work.priority,\n nodeIds: record.nodeIds,\n // Unclamped, like every routing field above it. A signal's channel and name\n // are how a reader addresses one — the filters `frond_read_events` exposes —\n // and they are authored as constants next to the code that publishes, the\n // same standing as `tag` and `nodeIds`. What the payload holds is the value,\n // and that is what `fields` withholds a line below.\n ...signalIdentity(record.event),\n fields: policy === \"none\" ? {} : describeFields(record.event, encodeField),\n // Failures are causes, not results: their messages are what makes a\n // devtools feed worth reading, so they are described rather than dropped —\n // including under `\"none\"`, whose subject is values, not what broke.\n //\n // Encoded as failures rather than as values, because that is what the\n // runtime says they are — no sniffing required. Which matters for the ones\n // that are not `Error` instances: an Effect `Cause` reaching the value\n // encoder comes out as a bag of key names.\n failures: record.failures.map(encoder.failure),\n };\n}\n\n/**\n * Names the signal an event is about, where it is about one.\n *\n * Two tags, written out, rather than a rule the field walk could apply to any\n * event: a general \"promote a field called `channel`\" would promote whatever an\n * app happened to name that way, which is app data crossing the policy that was\n * meant to clamp it. Only these two events have a channel the runtime itself put\n * there, and `RuntimeSignalSubscriberFailureObserved` is here for the same\n * reason as the publication — a subscriber failure that cannot say which signal\n * it was handling is a failure with no subject.\n *\n * Absent rather than empty on everything else. `channel: \"\"` is a record\n * claiming a channel it does not have, and a reader filtering on the field would\n * have to know to treat one string as meaning \"no\".\n */\nfunction signalIdentity(event: Runtime.RuntimeEvent): {\n readonly channel?: string;\n readonly name?: string;\n} {\n const signal =\n event._tag === \"RuntimeSignalPublished\"\n ? event.record.signal\n : event._tag === \"RuntimeSignalSubscriberFailureObserved\"\n ? event.signal.signal\n : undefined;\n\n return signal === undefined ? {} : { channel: signal.channel, name: signal.name };\n}\n\nfunction describeFields(\n event: Runtime.RuntimeEvent,\n encodeValue: (value: unknown) => unknown\n): Record<string, unknown> {\n const fields: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(event)) {\n if (key === \"_tag\") {\n continue;\n }\n\n fields[key] = encodeValue(value);\n }\n\n return fields;\n}\n",
|
|
11
11
|
"import type { ValuePolicy } from \"./protocol.ts\";\n\n/**\n * What this encoder can produce. All three policies are implemented.\n *\n * `\"full\"` is a stub in the sense that it has no per-field allowlist and no\n * redaction — it sends what it finds. It is not a stub in its bounds: cycles,\n * depth, and breadth are enforced, because those three are not polish. A cyclic\n * or unboundedly deep graph result would hang the observed app inside its own\n * devtools, on its own event loop.\n *\n * What those bounds are not is a size budget. This socket is loopback and the\n * eventual reader is an agent's context window, so the scarce resource is the\n * reader's attention rather than the wire — which is why `\"shape\"` spends real\n * effort being terse and `\"full\"` spends none.\n */\nexport type EncodePolicy = ValuePolicy;\n\n/** Increasing disclosure. The only ordering the clamp below depends on. */\nconst POLICY_RANK: Record<ValuePolicy, number> = { none: 0, shape: 1, full: 2 };\n\n/**\n * Clamps what the hub asked for to what this app is willing to send.\n *\n * The whole negotiation lives here, in one expression, rather than as a policy\n * check threaded through the encoder: a sender may always answer with less than\n * it was asked for and may never answer with more, and that rule is only\n * trustworthy if there is exactly one place it can be got wrong.\n *\n * Its own module for the same reason. This is the one function in the package\n * whose failure mode is disclosure rather than a bad rendering, and it should be\n * readable — and testable — without the several hundred lines of walking that\n * depend on it.\n */\nexport function resolvePolicy(requested: ValuePolicy, ceiling: ValuePolicy): EncodePolicy {\n return POLICY_RANK[requested] <= POLICY_RANK[ceiling] ? requested : ceiling;\n}\n",
|
|
12
12
|
"import type { Graph, Runtime } from \"@frondruntime/core\";\nimport { createValueEncoder, type ValueEncoder } from \"./encode.ts\";\nimport type { EncodePolicy } from \"./policy.ts\";\nimport type { EncodedGraphEdge, EncodedNodeSnapshot, GraphSnapshot } from \"./protocol.ts\";\n\n/**\n * Derived from the snapshot rather than imported by name.\n *\n * `NodeOperationFailure` is exported from core and `NodeLiveFailure` is not,\n * even though both appear on the public `NodeSnapshot`. Reading them off the\n * field keeps this file working either way, and means neither can drift from\n * the shape actually being encoded.\n */\ntype OperationFailure = NonNullable<Graph.NodeSnapshot[\"operationFailure\"]>;\ntype LiveFailure = NonNullable<Graph.NodeSnapshot[\"liveFailure\"]>;\n\nexport type SnapshotRequest = {\n readonly policy: EncodePolicy;\n readonly capturedAt: number;\n /**\n * Narrow to one node and include its result.\n *\n * The whole difference between the two queries. A graph read answers a\n * topology question and a few hundred results would drown it; a node read is\n * someone asking what one value currently is, which is the only question a\n * result answers.\n */\n readonly nodeId?: string | undefined;\n};\n\n/**\n * The graph as the app sees it right now, reduced to something sendable.\n *\n * The counterpart to {@link encodeRecord}, and deliberately built from the same\n * {@link ValueEncoder}: a node that is failing in a snapshot and the event that\n * failed it should read identically, and the way to guarantee that is for one\n * piece of code to describe both.\n *\n * Two things in a `NodeSnapshot` cannot cross and are dropped rather than\n * approximated. `Pending.attempt` is a `Promise<NodeRead>` — nothing about it\n * survives serialization, and `state: \"Pending\"` already says the only thing it\n * would have told a reader. And `Ready.node` is the node facade object, which is\n * mostly methods; `result` is the value someone actually meant to ask about.\n *\n * Two more are dropped for costing a line each in every row of a graph read\n * while saying something the row already said: `label` is core's presentation\n * formatting of `tag`, and `key` is the second half of `nodeId`. `kind` stays —\n * `\"node\"` against `\"resource\"` is nowhere in the other fields, and it is what\n * tells a reader whether release semantics apply to this row.\n */\nexport function encodeGraphSnapshot(\n snapshot: Runtime.RuntimeSnapshot,\n request: SnapshotRequest\n): GraphSnapshot {\n const encoder = createValueEncoder(request.policy);\n\n const nodes =\n request.nodeId === undefined\n ? snapshot.graph.nodes\n : snapshot.graph.nodes.filter((node) => node.nodeId === request.nodeId);\n\n // Every edge touching the node, in either direction: \"what does this depend\n // on\" and \"what breaks if this does\" are the same question asked twice, and a\n // single-node read that answered only the first would be half a diagnosis.\n const edges =\n request.nodeId === undefined\n ? snapshot.graph.edges\n : snapshot.graph.edges.filter(\n (edge) => edge.from === request.nodeId || edge.to === request.nodeId\n );\n\n return {\n capturedAt: request.capturedAt,\n // Absent rather than zero on a runtime that has not emitted: zero is a real\n // position in a log, and claiming one this snapshot does not have would let\n // a reader line it up against events that had not happened yet. Through\n // `absent` for the same reason everything else optional here is — see below.\n ...absent(\"sequence\", snapshot.events.at(-1)?.sequence, identity),\n runtimeId: snapshot.runtimeId,\n runtimeStatus: snapshot.status,\n graphStatus: snapshot.graph.status,\n observedInputs: snapshot.graph.observedInputs,\n values: request.policy,\n nodes: nodes.map((node) => encodeNode(node, encoder, request.nodeId !== undefined)),\n edges: edges.map(encodeEdge),\n };\n}\n\nfunction encodeEdge(edge: Graph.EdgeSnapshot): EncodedGraphEdge {\n return { from: edge.from, to: edge.to, dependency: edge.dependency };\n}\n\n/**\n * One node's worth of failure stays one node's worth.\n *\n * The value encoder guards its own walks, so reaching here should take something\n * it does not model at all. But a graph read is the answer to \"what is the app\n * doing\", and answering it with a single `Failed` because one row of three\n * hundred could not be encoded trades a complete diagnosis for none. The\n * identity fields are the runtime's own struct rather than app data, so a row\n * that keeps them and drops everything else is still a row a reader can act on —\n * and `status` naming the hole is what stops it reading as a healthy node.\n */\nfunction encodeNode(\n node: Graph.NodeSnapshot,\n encoder: ValueEncoder,\n includeResult: boolean\n): EncodedNodeSnapshot {\n try {\n return encodeNodeUnguarded(node, encoder, includeResult);\n } catch {\n return {\n nodeId: node.nodeId,\n tag: node.tag,\n kind: node.kind,\n state: node._tag,\n revision: node.revision,\n status: { _: \"opaque\", type: \"unreadable\" },\n liveDemand: { _: \"opaque\", type: \"unreadable\" },\n operation: { _: \"opaque\", type: \"unreadable\" },\n };\n }\n}\n\nfunction encodeNodeUnguarded(\n node: Graph.NodeSnapshot,\n encoder: ValueEncoder,\n includeResult: boolean\n): EncodedNodeSnapshot {\n const failure = nodeFailure(node);\n\n return {\n nodeId: node.nodeId,\n tag: node.tag,\n kind: node.kind,\n state: node._tag,\n revision: node.revision,\n // `status` can carry an error of its own — `Invalid.error`, or a `Wired` run\n // state that is `Error`. Those reach the value encoder, which routes an\n // `Error` to the same cause-chain description at either policy, so they are\n // not lost the way a hand-rolled struct walk would lose them.\n status: encoder.value(node.status),\n liveDemand: encoder.value(node.liveDemand),\n operation: encoder.value(node.operation),\n ...absent(\"resultValidity\", node.resultValidity, encoder.value),\n ...absent(\"failure\", failure, encoder.failure),\n ...absent(\"operationFailure\", encodeOperationFailure(node.operationFailure, encoder), identity),\n ...absent(\"liveFailure\", encodeLiveFailure(node.liveFailure, encoder), identity),\n // Read off the `Ready` arm rather than from a general field walk, because\n // that is the only arm that has one — an unresolved node has no result, and\n // an absent field here means exactly that.\n ...absent(\n \"result\",\n includeResult && node._tag === \"Ready\" ? { value: node.result } : undefined,\n (held) => encoder.value(held.value)\n ),\n };\n}\n\nconst identity = <A>(value: A): A => value;\n\n/**\n * Omits the key rather than setting it to `undefined`.\n *\n * Load-bearing, not tidiness. These fields cross as `Schema.optional`, and an\n * explicit `undefined` in that position does not survive the trip — it arrives\n * as `null`, so a healthy node would report `failure: null` and a topology read\n * would report a `result` on every node it deliberately withheld one from. An\n * absent key is the only encoding that still reads as \"there is nothing here\".\n *\n * The `result` case goes through a wrapper because `undefined` is a legitimate\n * value for a `Ready` node to hold, and unwrapping it here would make \"the node\n * resolved to undefined\" indistinguishable from \"no result was asked for\".\n */\nfunction absent<K extends string, A, B>(\n key: K,\n value: A | undefined,\n encode: (value: A) => B\n): { [P in K]?: B } {\n return value === undefined ? {} : ({ [key]: encode(value) } as { [P in K]?: B });\n}\n\n/**\n * The failure that explains this node's state, if it has one.\n *\n * The arm-specific error wins over the general `failure` field: on a node that\n * is `ReadinessError` or `Invalid`, that error *is* why the node is in that arm,\n * whereas `failure` is whatever was last recorded and can be older.\n */\nfunction nodeFailure(node: Graph.NodeSnapshot): unknown {\n if (node._tag === \"ReadinessError\" || node._tag === \"Invalid\") {\n return node.error;\n }\n\n return node.failure;\n}\n\n/**\n * Unwrapped rather than handed to the value encoder whole.\n *\n * `NodeOperationFailure` is a struct with an error inside it, and passing the\n * struct as a value would reduce the whole thing to `{operationId,kind,at,error}`\n * at `\"shape\"` — a key list, with the error behind the last key never described\n * at all. That is the exact loss the failure path exists to prevent. Naming the\n * field explicitly is what keeps the chain crossing at every policy.\n */\nfunction encodeOperationFailure(\n failure: OperationFailure | undefined,\n encoder: ValueEncoder\n): unknown | undefined {\n return failure === undefined\n ? undefined\n : {\n operationId: failure.operationId,\n kind: failure.kind,\n at: failure.at,\n error: encoder.failure(failure.error),\n };\n}\n\n/** Same reasoning as {@link encodeOperationFailure}, over a list. */\nfunction encodeLiveFailure(\n failure: LiveFailure | undefined,\n encoder: ValueEncoder\n): unknown | undefined {\n return failure === undefined\n ? undefined\n : { at: failure.at, failures: failure.failures.map(encoder.failure) };\n}\n",
|
|
13
|
-
"import type { Runtime } from \"@frondruntime/core\";\nimport { Cause, Data, Effect, Fiber } from \"effect\";\nimport { attachLayer, attachRuntime } from \"./attach.ts\";\nimport { HUB_DEFAULT_ATTACH_URL, HubRejection, type ValuePolicy } from \"./protocol.ts\";\n\n/**\n * How long to wait before dialing again.\n *\n * Fixed rather than backing off: the hub is a process on the same machine that\n * a developer starts and stops by hand, and an app that had backed off to\n * thirty seconds would spend most of a debugging session not yet reconnected.\n * Two seconds of an idle loopback socket costs nothing worth measuring.\n */\nconst RETRY_DELAY = \"2 seconds\";\n\n/**\n * Ends the retry loop.\n *\n * A second error rather than reusing `HubRejection`, because the two travel in\n * opposite directions through the same code: `HubRejection` arrives from the\n * hub into an attempt that swallows everything, and this one has to get back\n * *out* of that swallowing. Keeping them distinct is what lets the loop stop for\n * exactly one thing.\n */\nclass AttachRefused extends Data.TaggedError(\"AttachRefused\")<{\n readonly reason: string;\n}> {}\n\n/**\n * The hub's refusal, picked out of whatever else an attempt failed with.\n *\n * Matched on the error value's own identity, not on message text: a refusal is\n * the one outcome that stops the loop forever, and \"the message looked like a\n * rejection\" is not a property worth betting that on.\n *\n * The refusal is a typed failure here rather than a defect or a closed stream\n * because the RPC roles are inverted from who dials — the app is the *client*,\n * so the hub's `Attach` error channel is this side's error channel, and the\n * decoded `HubRejection` lands as an ordinary `Fail` on the cause.\n */\nfunction refusal(cause: Cause.Cause<unknown>): HubRejection | undefined {\n for (const reason of cause.reasons) {\n if (Cause.isFailReason(reason) && reason.error instanceof HubRejection) {\n return reason.error;\n }\n }\n\n return undefined;\n}\n\nexport type DevtoolsOptions = {\n readonly runtime: Runtime.Runtime;\n /** Human label for the hub's list, e.g. the host app's package name. */\n readonly name: string;\n /**\n * Where to dial. Defaults to the hub's own default port on loopback.\n *\n * Worth setting for a non-default port, and required for anything that is not\n * on the same host as the hub — a real iOS device or an Android emulator\n * cannot reach `127.0.0.1`, and needs the developer machine's LAN address.\n */\n readonly url?: string | undefined;\n /** Free-form origin hint. Guessed from the environment when omitted. */\n readonly platform?: string | undefined;\n /** See {@link import(\"./attach.ts\").AttachOptions.values}. Defaults to `\"shape\"`. */\n readonly values?: ValuePolicy | undefined;\n readonly instanceId?: string | undefined;\n /** Return false to leave a record out of the stream entirely. */\n readonly include?: ((record: Runtime.RuntimeEventRecord) => boolean) | undefined;\n /**\n * Called instead of failing, on every attempt that ends badly.\n *\n * Silent by default, and that is the right default: not being able to reach\n * the hub is the *normal* state of an app whose developer has not started one\n * yet, and a devtools client that logged about it once every two seconds\n * would be a worse citizen of the console than one that says nothing.\n *\n * The one exception is a hub that *refuses* the attachment, which is terminal\n * rather than normal. Supplying this takes ownership of reporting it: the\n * console fallback below fires only when this is absent.\n */\n readonly onError?: ((cause: unknown) => void) | undefined;\n};\n\n/**\n * Streams a runtime's events to a local hub for as long as the app lives.\n *\n * The plain-function front door, as opposed to {@link attachRuntime}: a host\n * app's entry file is not an Effect program, and making one the price of\n * admission would put this behind a rewrite nobody is going to do.\n *\n * Three properties make it safe to leave in an entry file behind nothing but a\n * dev check. It never throws and never rejects, so a devtools client cannot\n * take down the app it is observing. It retries forever, so the hub can be\n * started, stopped and restarted underneath a running app. And it returns\n * before it connects, so it costs the startup path nothing.\n *\n * \"Forever\" has one deliberate exception. A hub that *refuses* the attachment —\n * today, only a protocol version mismatch — is answering a question about this\n * build, and every retry would ask it again and get the same answer. So a\n * refusal stops the loop and says so out loud, because the alternative is what\n * this used to do: reconnect every two seconds, silently, for the whole life of\n * a process that was never going to attach.\n *\n * @example\n * ```ts\n * if (import.meta.env.DEV) {\n * attachDevtools({ runtime, name: \"checkout-web\" });\n * }\n * ```\n *\n * @returns A function that detaches. Idempotent, and safe to ignore.\n */\nexport function attachDevtools(options: DevtoolsOptions): () => void {\n const url = options.url ?? HUB_DEFAULT_ATTACH_URL;\n\n // Minted here rather than per attempt, so a hub restart underneath a running\n // app brings back the same runtime instead of an apparent stranger. Paired\n // with `generation` below, which is what says how many times that happened.\n const instanceId = options.instanceId ??
|
|
13
|
+
"import type { Runtime } from \"@frondruntime/core\";\nimport { Cause, Data, Effect, Fiber } from \"effect\";\nimport { attachLayer, attachRuntime, newInstanceId } from \"./attach.ts\";\nimport { HUB_DEFAULT_ATTACH_URL, HubRejection, type ValuePolicy } from \"./protocol.ts\";\n\n/**\n * How long to wait before dialing again.\n *\n * Fixed rather than backing off: the hub is a process on the same machine that\n * a developer starts and stops by hand, and an app that had backed off to\n * thirty seconds would spend most of a debugging session not yet reconnected.\n * Two seconds of an idle loopback socket costs nothing worth measuring.\n */\nconst RETRY_DELAY = \"2 seconds\";\n\n/**\n * Ends the retry loop.\n *\n * A second error rather than reusing `HubRejection`, because the two travel in\n * opposite directions through the same code: `HubRejection` arrives from the\n * hub into an attempt that swallows everything, and this one has to get back\n * *out* of that swallowing. Keeping them distinct is what lets the loop stop for\n * exactly one thing.\n */\nclass AttachRefused extends Data.TaggedError(\"AttachRefused\")<{\n readonly reason: string;\n}> {}\n\n/**\n * The hub's refusal, picked out of whatever else an attempt failed with.\n *\n * Matched on the error value's own identity, not on message text: a refusal is\n * the one outcome that stops the loop forever, and \"the message looked like a\n * rejection\" is not a property worth betting that on.\n *\n * The refusal is a typed failure here rather than a defect or a closed stream\n * because the RPC roles are inverted from who dials — the app is the *client*,\n * so the hub's `Attach` error channel is this side's error channel, and the\n * decoded `HubRejection` lands as an ordinary `Fail` on the cause.\n */\nfunction refusal(cause: Cause.Cause<unknown>): HubRejection | undefined {\n for (const reason of cause.reasons) {\n if (Cause.isFailReason(reason) && reason.error instanceof HubRejection) {\n return reason.error;\n }\n }\n\n return undefined;\n}\n\nexport type DevtoolsOptions = {\n readonly runtime: Runtime.Runtime;\n /** Human label for the hub's list, e.g. the host app's package name. */\n readonly name: string;\n /**\n * Where to dial. Defaults to the hub's own default port on loopback.\n *\n * Worth setting for a non-default port, and required for anything that is not\n * on the same host as the hub — a real iOS device or an Android emulator\n * cannot reach `127.0.0.1`, and needs the developer machine's LAN address.\n */\n readonly url?: string | undefined;\n /** Free-form origin hint. Guessed from the environment when omitted. */\n readonly platform?: string | undefined;\n /** See {@link import(\"./attach.ts\").AttachOptions.values}. Defaults to `\"shape\"`. */\n readonly values?: ValuePolicy | undefined;\n /**\n * Stable identity for this app across reconnects. Generated when omitted.\n *\n * Worth setting to something recognisable when several apps attach at once,\n * since this is what tells one from another after a hub restart. Any string\n * does, so long as it is stable for the life of the process and distinct per\n * running app.\n */\n readonly instanceId?: string | undefined;\n /** Return false to leave a record out of the stream entirely. */\n readonly include?: ((record: Runtime.RuntimeEventRecord) => boolean) | undefined;\n /**\n * Called instead of failing, on every attempt that ends badly.\n *\n * Silent by default, and that is the right default: not being able to reach\n * the hub is the *normal* state of an app whose developer has not started one\n * yet, and a devtools client that logged about it once every two seconds\n * would be a worse citizen of the console than one that says nothing.\n *\n * The one exception is a hub that *refuses* the attachment, which is terminal\n * rather than normal. Supplying this takes ownership of reporting it: the\n * console fallback below fires only when this is absent.\n */\n readonly onError?: ((cause: unknown) => void) | undefined;\n};\n\n/**\n * Streams a runtime's events to a local hub for as long as the app lives.\n *\n * The plain-function front door, as opposed to {@link attachRuntime}: a host\n * app's entry file is not an Effect program, and making one the price of\n * admission would put this behind a rewrite nobody is going to do.\n *\n * Three properties make it safe to leave in an entry file behind nothing but a\n * dev check. It never throws and never rejects, so a devtools client cannot\n * take down the app it is observing. It retries forever, so the hub can be\n * started, stopped and restarted underneath a running app. And it returns\n * before it connects, so it costs the startup path nothing.\n *\n * \"Forever\" has one deliberate exception. A hub that *refuses* the attachment —\n * today, only a protocol version mismatch — is answering a question about this\n * build, and every retry would ask it again and get the same answer. So a\n * refusal stops the loop and says so out loud, because the alternative is what\n * this used to do: reconnect every two seconds, silently, for the whole life of\n * a process that was never going to attach.\n *\n * @example\n * ```ts\n * if (import.meta.env.DEV) {\n * attachDevtools({ runtime, name: \"checkout-web\" });\n * }\n * ```\n *\n * @returns A function that detaches. Idempotent, and safe to ignore.\n */\nexport function attachDevtools(options: DevtoolsOptions): () => void {\n const url = options.url ?? HUB_DEFAULT_ATTACH_URL;\n\n // Minted here rather than per attempt, so a hub restart underneath a running\n // app brings back the same runtime instead of an apparent stranger. Paired\n // with `generation` below, which is what says how many times that happened.\n const instanceId = options.instanceId ?? newInstanceId();\n\n let generation = 0;\n\n // Deferred so each attempt reads the counter as it stands, and bumped only\n // when the hub accepted — a hub that is simply not running yet must not\n // inflate this every two seconds.\n const session = Effect.suspend(() =>\n attachRuntime({\n runtime: options.runtime,\n attachUrl: url,\n name: options.name,\n platform: options.platform ?? detectPlatform(),\n instanceId,\n generation,\n onAttached: () => {\n generation += 1;\n },\n ...(options.values === undefined ? {} : { values: options.values }),\n ...(options.include === undefined ? {} : { include: options.include }),\n })\n ).pipe(\n Effect.scoped,\n Effect.provide(attachLayer(url)),\n // `catchCause`, not `catch`: a defect in the transport is exactly as much\n // the host app's problem as a failure is, which is to say none.\n Effect.catchCause((cause) => {\n options.onError?.(cause);\n\n const refused = refusal(cause);\n\n // Every other ending is worth another attempt — a hub not started yet, a\n // socket dropped, a port moved — and retrying them is the behavior this\n // whole loop exists for. A refusal is not one of those: the next attempt\n // sends the same version and earns the same answer, so it leaves as a\n // failure, which is the one thing `forever` below does not swallow.\n return refused === undefined ? Effect.void : new AttachRefused({ reason: refused.reason });\n })\n );\n\n // `forever` over a *caught* attempt rather than `retry` over a failing one,\n // so the loop is reached by both outcomes. A hub that closes the stream\n // cleanly on shutdown is a success, and a success that stopped reconnecting\n // would leave the app permanently detached from the next hub.\n const fiber = Effect.runFork(\n Effect.forever(Effect.andThen(session, Effect.sleep(RETRY_DELAY))).pipe(\n Effect.catchTag(\"AttachRefused\", (refused) =>\n Effect.sync(() => {\n // Reached at most once per call, and that is structural rather than\n // guarded by a flag: getting here at all means the loop has stopped.\n //\n // Written to the console only when nobody asked for the causes. An\n // app that passed `onError` has already been told, in the handler it\n // supplied, and owns what it does with it; an app that did not would\n // otherwise be left with devtools that will never connect and nothing\n // anywhere saying so — which is the exact failure this whole change\n // is about, and a silent default would only move it one layer down.\n if (options.onError === undefined) {\n console.error(`[frond] devtools attach refused: ${refused.reason}`);\n }\n })\n )\n )\n );\n\n return () => {\n Effect.runFork(Fiber.interrupt(fiber));\n };\n}\n\n/** What `detectPlatform` reads. Everything on it is assumed absent. */\ntype PlatformGlobals = {\n readonly document?: unknown;\n readonly navigator?: { readonly product?: string };\n readonly process?: { readonly versions?: { readonly bun?: string } };\n};\n\n/**\n * A best-effort origin hint for the hub's list.\n *\n * Read off `globalThis` rather than referenced directly, for two reasons: a\n * bare `process` in a browser is a ReferenceError rather than `undefined`, and\n * naming it directly would drag `@types/node` into an entry point whose whole\n * claim is that it does not depend on Node.\n */\nfunction detectPlatform(): string {\n const globals = globalThis as PlatformGlobals;\n\n if (globals.document !== undefined) {\n return \"web\";\n }\n\n if (globals.navigator?.product === \"ReactNative\") {\n return \"react-native\";\n }\n\n if (globals.process !== undefined) {\n return globals.process.versions?.bun === undefined ? \"node\" : \"bun\";\n }\n\n return \"unknown\";\n}\n"
|
|
14
14
|
],
|
|
15
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AACA;AACA;;;ACHA;AAoBA,IAAM,kBAAkB;AACxB,IAAM,4BAA4B;AAClC,IAAM,2BAA2B;AAQjC,IAAM,4BAA4B;AAQlC,IAAM,oBAAoB;AAE1B,IAAM,4BAA4B;AAElC,IAAM,0BAA0B;AAUhC,IAAM,iBAAiB;AAMvB,IAAM,iBAAiB;AAUvB,IAAM,sBAAs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AAAA,IACpE;AAAA,GACD,CACH,CACF,CACF;AAAA,EAEA,OAAO,MAAM;AAAA,IACX,QAAO,QAAQ,MAAM,UAAU,KAAK,CAAC;AAAA;AAAA;AAmBzC,SAAS,cAAc,GAAW;AAAA,EAChC,MAAM,UAAU;AAAA,EAEhB,IAAI,QAAQ,aAAa,WAAW;AAAA,IAClC,OAAO;AAAA,EACT;AAAA,EAEA,IAAI,QAAQ,WAAW,YAAY,eAAe;AAAA,IAChD,OAAO;AAAA,EACT;AAAA,EAEA,IAAI,QAAQ,YAAY,WAAW;AAAA,IACjC,OAAO,QAAQ,QAAQ,UAAU,QAAQ,YAAY,SAAS;AAAA,EAChE;AAAA,EAEA,OAAO;AAAA;",
|
|
16
|
+
"debugId": "2D4EEFF071D4325764756E2164756E21",
|
|
17
17
|
"names": []
|
|
18
18
|
}
|
package/dist/node.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frondruntime/devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Attach a Frond runtime to the local devtools hub.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
"test": "bun --conditions=source test"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@frondruntime/core": "0.
|
|
61
|
-
"effect": "
|
|
60
|
+
"@frondruntime/core": "0.4.0",
|
|
61
|
+
"effect": ">=4.0.0-beta.100 <5.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@frondruntime/core": "workspace:*",
|
|
65
65
|
"@types/bun": "1.3.14",
|
|
66
66
|
"@types/node": "26.1.1",
|
|
67
|
-
"effect": "4.0.0-beta.
|
|
67
|
+
"effect": "4.0.0-beta.102"
|
|
68
68
|
},
|
|
69
69
|
"author": {
|
|
70
70
|
"name": "Roman Dubinin",
|
package/src/attach.ts
CHANGED
|
@@ -79,6 +79,31 @@ export type AttachOptions = {
|
|
|
79
79
|
readonly include?: (record: Runtime.RuntimeEventRecord) => boolean;
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Mints the id that identifies this runtime for the life of the process.
|
|
84
|
+
*
|
|
85
|
+
* Deliberately not `crypto.randomUUID`, which this used to be. That call is not
|
|
86
|
+
* available everywhere a Frond app runs — React Native has no global `crypto`
|
|
87
|
+
* until a polyfill installs one — and reaching for it meant either a startup
|
|
88
|
+
* crash on the runtime least able to explain it, or a guard, and a guard is a
|
|
89
|
+
* branch whose two halves nobody exercises together.
|
|
90
|
+
*
|
|
91
|
+
* The entropy was never the requirement. This id has to be unique among the
|
|
92
|
+
* handful of apps attached to one local hub at one time, and stable across that
|
|
93
|
+
* process's own reconnects. Nothing authenticates with it, nothing persists it,
|
|
94
|
+
* and it dies with the hub. A timestamp for cross-process separation and a short
|
|
95
|
+
* random suffix for anything started inside the same millisecond covers that
|
|
96
|
+
* with room to spare; the timestamp is the half that matters, because
|
|
97
|
+
* `Math.random` is seeded per process and two processes launched together is
|
|
98
|
+
* exactly where bare randomness is weakest.
|
|
99
|
+
*
|
|
100
|
+
* If this ever fronts something that is not a local devtools socket, it needs a
|
|
101
|
+
* real generator — but then it also needs a real identity, not this.
|
|
102
|
+
*/
|
|
103
|
+
export function newInstanceId(): string {
|
|
104
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
82
107
|
/**
|
|
83
108
|
* Transport for one attachment.
|
|
84
109
|
*
|
|
@@ -138,7 +163,7 @@ export const attachRuntime = Effect.fnUntraced(function* (options: AttachOptions
|
|
|
138
163
|
|
|
139
164
|
const info: AttachmentInfo = {
|
|
140
165
|
protocolVersion: HUB_PROTOCOL_VERSION,
|
|
141
|
-
instanceId: options.instanceId ??
|
|
166
|
+
instanceId: options.instanceId ?? newInstanceId(),
|
|
142
167
|
runtimeId: options.runtime.getSnapshotSync().runtimeId,
|
|
143
168
|
generation: options.generation ?? 0,
|
|
144
169
|
name: options.name,
|
package/src/attachDevtools.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Runtime } from "@frondruntime/core";
|
|
2
2
|
import { Cause, Data, Effect, Fiber } from "effect";
|
|
3
|
-
import { attachLayer, attachRuntime } from "./attach.ts";
|
|
3
|
+
import { attachLayer, attachRuntime, newInstanceId } from "./attach.ts";
|
|
4
4
|
import { HUB_DEFAULT_ATTACH_URL, HubRejection, type ValuePolicy } from "./protocol.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -64,6 +64,14 @@ export type DevtoolsOptions = {
|
|
|
64
64
|
readonly platform?: string | undefined;
|
|
65
65
|
/** See {@link import("./attach.ts").AttachOptions.values}. Defaults to `"shape"`. */
|
|
66
66
|
readonly values?: ValuePolicy | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Stable identity for this app across reconnects. Generated when omitted.
|
|
69
|
+
*
|
|
70
|
+
* Worth setting to something recognisable when several apps attach at once,
|
|
71
|
+
* since this is what tells one from another after a hub restart. Any string
|
|
72
|
+
* does, so long as it is stable for the life of the process and distinct per
|
|
73
|
+
* running app.
|
|
74
|
+
*/
|
|
67
75
|
readonly instanceId?: string | undefined;
|
|
68
76
|
/** Return false to leave a record out of the stream entirely. */
|
|
69
77
|
readonly include?: ((record: Runtime.RuntimeEventRecord) => boolean) | undefined;
|
|
@@ -117,7 +125,7 @@ export function attachDevtools(options: DevtoolsOptions): () => void {
|
|
|
117
125
|
// Minted here rather than per attempt, so a hub restart underneath a running
|
|
118
126
|
// app brings back the same runtime instead of an apparent stranger. Paired
|
|
119
127
|
// with `generation` below, which is what says how many times that happened.
|
|
120
|
-
const instanceId = options.instanceId ??
|
|
128
|
+
const instanceId = options.instanceId ?? newInstanceId();
|
|
121
129
|
|
|
122
130
|
let generation = 0;
|
|
123
131
|
|
package/src/encode.ts
CHANGED
|
@@ -86,7 +86,9 @@ export function createValueEncoder(policy: EncodePolicy): ValueEncoder {
|
|
|
86
86
|
*
|
|
87
87
|
* Classification, work context, and node ids are metadata the runtime already
|
|
88
88
|
* owns and are copied verbatim — they are ids and enum members, never user
|
|
89
|
-
* data.
|
|
89
|
+
* data. A signal's channel and name join them, on the reasoning
|
|
90
|
+
* `EncodedEventRecord` gives for the two fields. Only the event body goes
|
|
91
|
+
* through the value encoder.
|
|
90
92
|
*/
|
|
91
93
|
export function encodeRecord(
|
|
92
94
|
record: Runtime.RuntimeEventRecord,
|
|
@@ -123,6 +125,12 @@ export function encodeRecord(
|
|
|
123
125
|
reason: record.work.reason,
|
|
124
126
|
priority: record.work.priority,
|
|
125
127
|
nodeIds: record.nodeIds,
|
|
128
|
+
// Unclamped, like every routing field above it. A signal's channel and name
|
|
129
|
+
// are how a reader addresses one — the filters `frond_read_events` exposes —
|
|
130
|
+
// and they are authored as constants next to the code that publishes, the
|
|
131
|
+
// same standing as `tag` and `nodeIds`. What the payload holds is the value,
|
|
132
|
+
// and that is what `fields` withholds a line below.
|
|
133
|
+
...signalIdentity(record.event),
|
|
126
134
|
fields: policy === "none" ? {} : describeFields(record.event, encodeField),
|
|
127
135
|
// Failures are causes, not results: their messages are what makes a
|
|
128
136
|
// devtools feed worth reading, so they are described rather than dropped —
|
|
@@ -136,6 +144,35 @@ export function encodeRecord(
|
|
|
136
144
|
};
|
|
137
145
|
}
|
|
138
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Names the signal an event is about, where it is about one.
|
|
149
|
+
*
|
|
150
|
+
* Two tags, written out, rather than a rule the field walk could apply to any
|
|
151
|
+
* event: a general "promote a field called `channel`" would promote whatever an
|
|
152
|
+
* app happened to name that way, which is app data crossing the policy that was
|
|
153
|
+
* meant to clamp it. Only these two events have a channel the runtime itself put
|
|
154
|
+
* there, and `RuntimeSignalSubscriberFailureObserved` is here for the same
|
|
155
|
+
* reason as the publication — a subscriber failure that cannot say which signal
|
|
156
|
+
* it was handling is a failure with no subject.
|
|
157
|
+
*
|
|
158
|
+
* Absent rather than empty on everything else. `channel: ""` is a record
|
|
159
|
+
* claiming a channel it does not have, and a reader filtering on the field would
|
|
160
|
+
* have to know to treat one string as meaning "no".
|
|
161
|
+
*/
|
|
162
|
+
function signalIdentity(event: Runtime.RuntimeEvent): {
|
|
163
|
+
readonly channel?: string;
|
|
164
|
+
readonly name?: string;
|
|
165
|
+
} {
|
|
166
|
+
const signal =
|
|
167
|
+
event._tag === "RuntimeSignalPublished"
|
|
168
|
+
? event.record.signal
|
|
169
|
+
: event._tag === "RuntimeSignalSubscriberFailureObserved"
|
|
170
|
+
? event.signal.signal
|
|
171
|
+
: undefined;
|
|
172
|
+
|
|
173
|
+
return signal === undefined ? {} : { channel: signal.channel, name: signal.name };
|
|
174
|
+
}
|
|
175
|
+
|
|
139
176
|
function describeFields(
|
|
140
177
|
event: Runtime.RuntimeEvent,
|
|
141
178
|
encodeValue: (value: unknown) => unknown
|
package/src/protocol.ts
CHANGED
|
@@ -30,8 +30,17 @@ import { Rpc, RpcGroup } from "effect/unstable/rpc";
|
|
|
30
30
|
* change inside one release moved nothing and let two builds that disagreed
|
|
31
31
|
* attach to each other. Starting at 1 with the first published hub, so what the
|
|
32
32
|
* number counts is generations anyone could have installed.
|
|
33
|
+
*
|
|
34
|
+
* Moved to 2 because {@link RuntimeEventCategory} gained `"signal"`. A literal
|
|
35
|
+
* union is not an excess property: a 0.3.x hub decoding `category: "signal"`
|
|
36
|
+
* fails with `SchemaError(Expected "command" | ... | "state", got "signal")`,
|
|
37
|
+
* and that failure takes the whole `Frond.Ingest` batch, non-signal records
|
|
38
|
+
* included. Both builds announce 1, so the attachment would succeed and the app
|
|
39
|
+
* would simply stop streaming — the exact failure the paragraph above refuses to
|
|
40
|
+
* ship. The optional `channel`/`name` fields really are two-way safe and would
|
|
41
|
+
* not have needed this; the category is what forced it.
|
|
33
42
|
*/
|
|
34
|
-
export const HUB_PROTOCOL_VERSION =
|
|
43
|
+
export const HUB_PROTOCOL_VERSION = 2;
|
|
35
44
|
|
|
36
45
|
/**
|
|
37
46
|
* Unregistered, and chosen for the band rather than the number.
|
|
@@ -71,6 +80,7 @@ export const RuntimeEventCategory = Schema.Literals([
|
|
|
71
80
|
"input",
|
|
72
81
|
"lifecycle",
|
|
73
82
|
"operation",
|
|
83
|
+
"signal",
|
|
74
84
|
"state",
|
|
75
85
|
]);
|
|
76
86
|
|
|
@@ -165,6 +175,31 @@ export const EncodedEventRecord = Schema.Struct({
|
|
|
165
175
|
reason: RuntimeWorkReason,
|
|
166
176
|
priority: RuntimeWorkPriority,
|
|
167
177
|
nodeIds: Schema.Array(Schema.String),
|
|
178
|
+
/**
|
|
179
|
+
* Which signal this is, on the two events that carry one.
|
|
180
|
+
*
|
|
181
|
+
* Lifted out of `fields` because that is where they used to die: the field
|
|
182
|
+
* walk treats every event body the same way, so a publication whose one field
|
|
183
|
+
* is a signal record arrived at the default `"shape"` policy as a key list of
|
|
184
|
+
* that record — a reader could tell that *a* signal fired and nothing about
|
|
185
|
+
* which one. A channel and an event name are routing structure rather than app
|
|
186
|
+
* data, which is the same argument `describeShape` makes for letting `_tag`
|
|
187
|
+
* cross verbatim, so these two cross at every policy. The `payload` stays in
|
|
188
|
+
* `fields` and stays clamped, because it is the half that really is data.
|
|
189
|
+
*
|
|
190
|
+
* Optional rather than required, which keeps these two fields compatible in
|
|
191
|
+
* both directions on their own: an old hub ignores the extra properties a new
|
|
192
|
+
* app sends, because effect Schema drops excess properties on decode and
|
|
193
|
+
* nothing here overrides `onExcessProperty`, and a new hub reads an old app's
|
|
194
|
+
* records as what they are — signals whose channel it was never told.
|
|
195
|
+
*
|
|
196
|
+
* That is a property of these fields and not of the release. The same release
|
|
197
|
+
* added `"signal"` to {@link RuntimeEventCategory}, which an old hub does
|
|
198
|
+
* reject, so {@link HUB_PROTOCOL_VERSION} moved to 2 regardless. Keeping these
|
|
199
|
+
* optional is still what makes a new hub able to read an old app at all.
|
|
200
|
+
*/
|
|
201
|
+
channel: Schema.optionalKey(Schema.String),
|
|
202
|
+
name: Schema.optionalKey(Schema.String),
|
|
168
203
|
/**
|
|
169
204
|
* Keyed by the event's own field names, minus `_tag`.
|
|
170
205
|
*
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/protocol.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { Schema } from \"effect\";\nimport { Rpc, RpcGroup } from \"effect/unstable/rpc\";\n\n/**\n * Wire contract between an attached Frond runtime and the hub.\n *\n * Direction of the RPC roles is deliberate and inverted from who dials: the\n * hub listens and is the RPC *server*, the app dials out and is the RPC\n * *client*. That keeps the app free of any listening socket, and it is the only\n * arrangement both `RpcServer.layerHttp` and `RpcClient.layerProtocolSocket`\n * support without a hand-written socket adapter on either side.\n *\n * Hub-to-app work (state reads, and later refresh and action invocation)\n * therefore does not travel as a plain RPC call. It rides the `Attach` response\n * stream as a `Query` command, and the app answers with a separate unary\n * `Reply` correlated by `requestId`. `Attach` is the only long-lived call.\n *\n * Version equality is exact, on both sides, and there is no capability\n * negotiation. That is a deliberate choice rather than an omission: `HubCommand`\n * is a schema union, so an app one version behind would fail to decode a command\n * it has never heard of and drop its socket — presenting as \"the runtime stopped\n * emitting\", which is the most expensive way this can fail. Refusing the\n * attachment outright says the same thing immediately and in words.\n *\n * The number counts published generations of *this contract*, and moves on its\n * own schedule — it is not derived from, and does not track, the npm version of\n * any package. Tying the two was the earlier arrangement and it was wrong in\n * both directions: a release that touched nothing on the wire still moved the\n * number and refused every app that had not upgraded, while a genuine schema\n * change inside one release moved nothing and let two builds that disagreed\n * attach to each other. Starting at 1 with the first published hub, so what the\n * number counts is generations anyone could have installed.\n */\nexport const HUB_PROTOCOL_VERSION = 1;\n\n/**\n * Unregistered, and chosen for the band rather than the number.\n *\n * Above 9999 to clear the entire dev-server zone — Vite, Metro, Expo, CRA,\n * Django, Storybook, the node inspector — and below 32768 so it can never\n * collide with an ephemeral source port on Linux, whose range starts there.\n *\n * Stable on purpose. Apps hardcode it, so a hub that drifted to the next free\n * port on a collision would leave them dialing nothing, which presents as \"the\n * runtime is not emitting\" — the most expensive way to fail.\n */\nexport const HUB_DEFAULT_PORT = 17391;\n\nexport const HUB_DEFAULT_HOST = \"127.0.0.1\";\n\nexport const HUB_ATTACH_PATH = \"/attach\";\n\n/** Where an app dials when it was given no explicit URL. */\nexport const HUB_DEFAULT_ATTACH_URL = `ws://${HUB_DEFAULT_HOST}:${HUB_DEFAULT_PORT}${HUB_ATTACH_PATH}`;\n\n/**\n * How much of a value crosses the wire.\n *\n * Negotiated in one direction only: the hub asks, and the app answers with the\n * lesser of the request and its own ceiling. The ceiling defaults to `\"shape\"`,\n * so an app sends structure until someone deliberately decides otherwise — the\n * decision to put real values on a socket should be one somebody made, not one\n * that came with the default.\n */\nexport const ValuePolicy = Schema.Literals([\"none\", \"shape\", \"full\"]);\nexport type ValuePolicy = typeof ValuePolicy.Type;\n\nexport const RuntimeEventCategory = Schema.Literals([\n \"command\",\n \"diagnostic\",\n \"input\",\n \"lifecycle\",\n \"operation\",\n \"state\",\n]);\n\nexport const RuntimeEventSeverity = Schema.Literals([\"debug\", \"error\", \"info\", \"warning\"]);\n\nexport const RuntimeEventTimeline = Schema.Literals([\"live\", \"state\", \"system\", \"work\"]);\n\nexport const RuntimeWorkSource = Schema.Literals([\n \"react\",\n \"mobx\",\n \"node\",\n \"manual\",\n \"devtools\",\n \"runtime\",\n \"signal\",\n \"test\",\n]);\n\nexport const RuntimeWorkReason = Schema.Literals([\n \"start\",\n \"stop\",\n \"readiness\",\n \"retry\",\n \"preload\",\n \"refresh\",\n \"action\",\n \"args-update\",\n \"live\",\n \"release\",\n \"eviction\",\n \"unsafe-update\",\n \"input\",\n \"signal\",\n]);\n\nexport const RuntimeWorkPriority = Schema.Literals([\"blocking\", \"visible\", \"background\", \"idle\"]);\n\n/**\n * Who is attaching.\n *\n * `runtimeId` is the runtime's own `runtime-N` counter and collides freely\n * across tabs, reloads, and processes; `instanceId` is minted once per\n * `attachDevtools` call and is the only field safe to use as an identity key.\n */\nexport const AttachmentInfo = Schema.Struct({\n protocolVersion: Schema.Number,\n /** Stable for the life of the attaching runtime, including across reconnects. */\n instanceId: Schema.String,\n runtimeId: Schema.String,\n /**\n * How many times this runtime had already attached before this connection.\n *\n * Zero on a first attach; anything higher means the socket dropped and came\n * back, which is the same thing as saying the events in between are gone.\n * Devtools are not durable by design — nothing bridges that gap — so this\n * field exists to make the gap visible rather than to let anyone close it.\n */\n generation: Schema.Number,\n /** Human label for the CLI list, e.g. the host app's package name. */\n name: Schema.String,\n /** Free-form origin hint: \"bun\", \"browser\", \"expo-ios\", … */\n platform: Schema.String,\n startedAt: Schema.Number,\n /** The strongest value policy this app is willing to honor. */\n values: ValuePolicy,\n});\nexport type AttachmentInfo = typeof AttachmentInfo.Type;\n\n/**\n * A runtime event, flattened and already redacted by the sender.\n *\n * `fields` holds JSON-safe shape descriptors, not live values — encoding\n * happens at observe time, because a `RuntimeEventRecord` carries live\n * references that keep mutating after the record is handed out. The descriptor\n * vocabulary is written down once, in `descriptors.ts`, and what each policy\n * produces lives with the walk that produces it — `describeShape` in `shape.ts`,\n * `describeFull` in `full.ts`, `describeError` in `cause.ts`. Nothing on this\n * side should restate any of it and drift.\n */\nexport const EncodedEventRecord = Schema.Struct({\n sequence: Schema.Number,\n recordedAt: Schema.Number,\n /** The `RuntimeEvent` `_tag`, e.g. \"GraphNodeLiveDemandChanged\". */\n tag: Schema.String,\n category: RuntimeEventCategory,\n severity: RuntimeEventSeverity,\n timeline: RuntimeEventTimeline,\n reportable: Schema.Boolean,\n workId: Schema.Number,\n parentWorkId: Schema.optional(Schema.Number),\n source: RuntimeWorkSource,\n reason: RuntimeWorkReason,\n priority: RuntimeWorkPriority,\n nodeIds: Schema.Array(Schema.String),\n /**\n * Keyed by the event's own field names, minus `_tag`.\n *\n * A record rather than `Unknown`: every consumer — the UI, and shortly the\n * MCP reader — looks fields up by name, and typing the container as unknown\n * only moves that cast to each of them. The *values* stay unknown, which is\n * the honest part: what a field holds depends on the negotiated policy.\n */\n fields: Schema.Record(Schema.String, Schema.Unknown),\n /**\n * What went wrong, as chains of causes rather than as single errors.\n *\n * Each entry is `{_: \"error\", message, causes}`, outermost cause first. The\n * runtime lifts these off the event's own fields, so the same failure also\n * appears in `fields` — encoded identically, so one failure never reads as\n * two. Present at every policy: `\"none\"` is a statement about values, and a\n * feed that cannot say what is failing is not worth reading.\n */\n failures: Schema.Array(Schema.Unknown),\n});\nexport type EncodedEventRecord = typeof EncodedEventRecord.Type;\n\n/**\n * One node, as it is right now.\n *\n * Split the same way `EncodedEventRecord` is: the fields a reader filters and\n * branches on are typed, and anything that came out of the app's own data is\n * `Unknown`, because what it holds depends on the negotiated policy. Giving\n * `NodeStatus`, `NodeOperation` and the rest real schemas here would copy core's\n * type surface into the wire contract and guarantee the two drift apart.\n *\n * Every field here has to earn its place in *every row* of a graph read, which\n * is why core's `label` and `key` are not among them: `label` is a formatting of\n * `tag` and `key` is already inside `nodeId`, so both are the same fact charged\n * twice, a few hundred times per snapshot.\n */\nexport const EncodedNodeSnapshot = Schema.Struct({\n nodeId: Schema.String,\n /** The spec's tag, e.g. `\"orders\"`. Shared by every key; `nodeId` is the identity. */\n tag: Schema.String,\n /**\n * `\"node\"`, `\"service\"`, `\"resource\"` or `\"facade\"` — the one identity field\n * nothing else here implies.\n *\n * It says whether this row owns a release: a resource holds something the app\n * has to give back, and a reader deciding what a leak looks like cannot get\n * that from `tag` or `nodeId`.\n *\n * Carried as a string rather than a literal union so a hub can read an app\n * built against a core that has since grown a kind. Version equality already\n * gates the wire; making this field the second thing that can reject a\n * snapshot would buy nothing.\n */\n kind: Schema.String,\n /**\n * Which arm of core's `NodeSnapshot` this is: `Unwired`, `Idle`, `Pending`,\n * `Ready`, `ReadinessError`, `Releasing`, `Invalid`.\n *\n * Typed and hoisted because it is the one field every reader branches on.\n * Left inside the encoded `status` it would oblige an agent to understand this\n * encoder's descriptors before it could ask which nodes are broken.\n */\n state: Schema.String,\n /**\n * Core's per-node write counter, carried verbatim.\n *\n * The cheap way to tell \"still the value I saw last time\" from \"recomputed,\n * and happens to look the same\" — which no amount of comparing encoded\n * results can answer once a policy has redacted them.\n */\n revision: Schema.Number,\n status: Schema.Unknown,\n liveDemand: Schema.Unknown,\n operation: Schema.Unknown,\n resultValidity: Schema.optional(Schema.Unknown),\n /**\n * Why this node is not usable, as a chain of causes.\n *\n * Same encoding as `EncodedEventRecord.failures`, deliberately: a node failed\n * in the snapshot and the event that failed it should read identically.\n */\n failure: Schema.optional(Schema.Unknown),\n /**\n * The last operation that failed, as `{operationId, kind, at, error}`.\n *\n * Distinct from `failure`, and the difference is the whole point of keeping\n * it: a node can be `Ready` on a stale-but-valid result while its most recent\n * refresh failed. `failure` would be absent and everything would look fine.\n */\n operationFailure: Schema.optional(Schema.Unknown),\n /** Why live demand could not be served, as `{at, failures}`. */\n liveFailure: Schema.optional(Schema.Unknown),\n /**\n * The node's current value.\n *\n * Only ever present on a single-node query. A graph read of a few hundred\n * nodes is a topology question, and answering it with every result attached\n * would put the whole application state on the wire to draw a diagram.\n */\n result: Schema.optional(Schema.Unknown),\n});\nexport type EncodedNodeSnapshot = typeof EncodedNodeSnapshot.Type;\n\nexport const EncodedGraphEdge = Schema.Struct({\n from: Schema.String,\n to: Schema.String,\n /** The dependency name the dependent declared, not the target's tag. */\n dependency: Schema.String,\n});\nexport type EncodedGraphEdge = typeof EncodedGraphEdge.Type;\n\n/**\n * The graph at one instant.\n *\n * The counterpart to the event stream rather than a replacement for it: events\n * say what happened, this says what is true. `capturedAt` and `sequence` are\n * what let a reader hold both at once — a snapshot taken \"as of sequence 4412\"\n * can be lined up against the log the reader already has, instead of being a\n * second account of the same system with no way to relate them.\n */\nexport const GraphSnapshot = Schema.Struct({\n capturedAt: Schema.Number,\n /**\n * The last event sequence the runtime had recorded when this was taken.\n *\n * Absent on a runtime that has not emitted yet, which is the only honest\n * answer — zero would claim a position in a log that has none.\n */\n sequence: Schema.optional(Schema.Number),\n runtimeId: Schema.String,\n runtimeStatus: Schema.String,\n graphStatus: Schema.String,\n observedInputs: Schema.Number,\n /**\n * The policy the app actually applied, which may be less than was asked for.\n *\n * Stated per snapshot rather than inferred from the attachment: a reader that\n * finds no `result` on a node needs to tell \"redacted\" from \"not ready\", and\n * those are the same absence.\n */\n values: ValuePolicy,\n nodes: Schema.Array(EncodedNodeSnapshot),\n edges: Schema.Array(EncodedGraphEdge),\n});\nexport type GraphSnapshot = typeof GraphSnapshot.Type;\n\n/** Every node and edge, with statuses but without results. */\nexport const GraphQuery = Schema.Struct({ _tag: Schema.tag(\"Graph\") });\n\n/** One node, with its result and the edges incident on it. */\nexport const NodeQuery = Schema.Struct({\n _tag: Schema.tag(\"Node\"),\n nodeId: Schema.String,\n});\n\nexport const StateQuery = Schema.Union([GraphQuery, NodeQuery]);\nexport type StateQuery = typeof StateQuery.Type;\n\n/**\n * The app's answer to one query.\n *\n * `Failed` rather than an RPC error because the reply is a separate call from\n * the request: an error on this channel would fail the *reply*, which is not\n * the thing that went wrong, and would leave the hub waiting out its timeout\n * for an answer that already came back.\n */\nexport const QueryOutcome = Schema.Union([\n Schema.Struct({ _tag: Schema.tag(\"Snapshot\"), snapshot: GraphSnapshot }),\n Schema.Struct({ _tag: Schema.tag(\"Failed\"), reason: Schema.String }),\n]);\nexport type QueryOutcome = typeof QueryOutcome.Type;\n\n/** Hub accepted the attachment and assigned it an id. */\nexport const HubAttached = Schema.Struct({\n _tag: Schema.tag(\"Attached\"),\n attachmentId: Schema.String,\n /** What the hub is asking for. The app may downgrade, never upgrade. */\n values: ValuePolicy,\n});\n\n/** Liveness probe; the app answers by continuing to hold the stream open. */\nexport const HubPing = Schema.Struct({\n _tag: Schema.tag(\"Ping\"),\n at: Schema.Number,\n});\n\n/**\n * Asks the app what is true right now.\n *\n * Rides this stream because the hub has no way to call the app — it listens and\n * the app dials, so the only open channel in this direction is the `Attach`\n * response. The answer comes back as a separate `Reply` call rather than in\n * band, which is why `requestId` exists.\n *\n * `values` is requested per query, not per attachment. A stream of events and a\n * deliberate read of one node are different acts: the first is a firehose worth\n * keeping cheap, the second is someone asking a specific question. Both are\n * still clamped by the app's own ceiling, so this widens nothing the app has not\n * already agreed to.\n */\nexport const HubQuery = Schema.Struct({\n _tag: Schema.tag(\"Query\"),\n requestId: Schema.String,\n query: StateQuery,\n values: ValuePolicy,\n});\n\n/** Server-to-client commands. */\nexport const HubCommand = Schema.Union([HubAttached, HubPing, HubQuery]);\nexport type HubCommand = typeof HubCommand.Type;\n\n/**\n * The hub refused the attachment.\n *\n * `reason` is prose for a terminal, not a code to branch on. It is the last\n * thing said on a connection that is about to close, and the symptom on the\n * other end — devtools that quietly never appear — carries no information at\n * all, so the string has to carry the diagnosis and the next step instead. The\n * hub's version mismatch names both versions and which side to upgrade.\n *\n * Specific on purpose, where a rejection elsewhere would be deliberately vague:\n * there is no authentication on this call (see `Attach`), so an uninvited\n * caller learns nothing here it could not learn by dialing and observing, and\n * vagueness would cost only the developer who is actually trying to attach.\n */\nexport class HubRejection extends Schema.TaggedErrorClass<HubRejection>(\"HubRejection\")(\n \"HubRejection\",\n { reason: Schema.String }\n) {}\n\n/**\n * Opens the attachment and holds it open.\n *\n * The stream's lifetime *is* the attachment's lifetime: when the socket drops,\n * the handler is interrupted, which is how the hub learns about detachment.\n * There is no explicit detach call and there should not be one — a crashed app\n * cannot send it.\n *\n * Unauthenticated on purpose. Browsers do not apply CORS to WebSockets, so any\n * page a developer visits can dial a loopback port — but this direction only\n * carries data *into* the hub, so the worst an uninvited caller achieves is\n * putting junk in a dashboard. The direction where app data leaves is the MCP\n * endpoint, and a secret on this half while that one is open would buy nothing\n * and cost every host app a value to configure.\n *\n * The consequence, stated plainly because something downstream has to honour\n * it: records arriving here are not proof of their own origin, and a consumer\n * that feeds them to an agent is feeding it untrusted text.\n */\nexport class Attach extends Rpc.make(\"Frond.Attach\", {\n payload: { info: AttachmentInfo },\n success: HubCommand,\n error: HubRejection,\n stream: true,\n}) {}\n\n/**\n * Pushes a batch of events.\n *\n * `droppedSince` is the sender's count of records it could not buffer since the\n * previous batch. It is not optional and not a nicety: a devtools feed that\n * silently loses events is worse than one that admits to a gap, because an\n * agent reasoning over the stream cannot tell \"did not happen\" from \"was\n * dropped\".\n */\nexport class Ingest extends Rpc.make(\"Frond.Ingest\", {\n payload: {\n attachmentId: Schema.String,\n records: Schema.Array(EncodedEventRecord),\n droppedSince: Schema.Number,\n },\n}) {}\n\n/**\n * Answers one `Query`.\n *\n * A unary call in the app-to-hub direction, correlated by `requestId`, because\n * the RPC roles only run that way — see the note at the top of this file. The\n * consequence worth naming: a reply is not causally tied to the stream that\n * asked for it, so the hub has to time its requests out. An app that dies\n * mid-query simply never calls this.\n */\nexport class Reply extends Rpc.make(\"Frond.Reply\", {\n payload: {\n attachmentId: Schema.String,\n requestId: Schema.String,\n outcome: QueryOutcome,\n },\n}) {}\n\nexport const FrondHubRpcs = RpcGroup.make(Attach, Ingest, Reply);\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";AAAA;AACA;AAgCO,IAAM,uBAAuB;AAa7B,IAAM,mBAAmB;AAEzB,IAAM,mBAAmB;AAEzB,IAAM,kBAAkB;AAGxB,IAAM,yBAAyB,QAAQ,oBAAoB,mBAAmB;AAW9E,IAAM,cAAc,OAAO,SAAS,CAAC,QAAQ,SAAS,MAAM,CAAC;AAG7D,IAAM,uBAAuB,OAAO,SAAS;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,uBAAuB,OAAO,SAAS,CAAC,SAAS,SAAS,QAAQ,SAAS,CAAC;AAElF,IAAM,uBAAuB,OAAO,SAAS,CAAC,QAAQ,SAAS,UAAU,MAAM,CAAC;AAEhF,IAAM,oBAAoB,OAAO,SAAS;AAAA,EAC/C;AAAA,EACA;AAAA,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