@frondruntime/devtools 0.4.0 → 0.5.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 +20 -0
- package/dist/chunk-tky04mfa.js +169 -0
- package/dist/chunk-tky04mfa.js.map +10 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +74 -74
- package/dist/index.js.map +3 -3
- package/dist/node.js +4 -4
- package/dist/node.js.map +1 -1
- package/package.json +4 -4
- package/src/attach.ts +2 -2
- package/src/protocol.ts +4 -5
- package/dist/chunk-71tmgh2e.js +0 -167
- package/dist/chunk-71tmgh2e.js.map +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.0](https://github.com/frondruntime/frond/compare/devtools-v0.4.0...devtools-v0.5.0) (2026-10-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* report message, name, fingerprint, tags, and contexts change shape; createRuntimeEventReports returns [] for non-reportable records; dependency-caused failures no longer produce their own reports.
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* report errors by failing node, once at the source ([#24](https://github.com/frondruntime/frond/issues/24)) ([b98e22e](https://github.com/frondruntime/frond/commit/b98e22eec5717dff958920935bf741f02cf5416c))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Dependencies
|
|
16
|
+
|
|
17
|
+
* The following workspace dependencies were updated
|
|
18
|
+
* devDependencies
|
|
19
|
+
* @frondruntime/core bumped to 0.5.0
|
|
20
|
+
* peerDependencies
|
|
21
|
+
* @frondruntime/core bumped from 0.4.0 to 0.5.0
|
|
22
|
+
|
|
3
23
|
## [0.4.0](https://github.com/frondruntime/frond/compare/devtools-v0.3.0...devtools-v0.4.0) (2026-08-02)
|
|
4
24
|
|
|
5
25
|
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// src/protocol.ts
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { Rpc, RpcGroup } from "effect/rpc";
|
|
4
|
+
var HUB_PROTOCOL_VERSION2 = 2;
|
|
5
|
+
var HUB_DEFAULT_PORT2 = 17391;
|
|
6
|
+
var HUB_DEFAULT_HOST2 = "127.0.0.1";
|
|
7
|
+
var HUB_ATTACH_PATH2 = "/attach";
|
|
8
|
+
var HUB_DEFAULT_ATTACH_URL2 = `ws://${HUB_DEFAULT_HOST2}:${HUB_DEFAULT_PORT2}${HUB_ATTACH_PATH2}`;
|
|
9
|
+
var ValuePolicy2 = Schema.Literals(["none", "shape", "full"]);
|
|
10
|
+
var RuntimeEventCategory2 = Schema.Literals([
|
|
11
|
+
"command",
|
|
12
|
+
"diagnostic",
|
|
13
|
+
"input",
|
|
14
|
+
"lifecycle",
|
|
15
|
+
"operation",
|
|
16
|
+
"signal",
|
|
17
|
+
"state"
|
|
18
|
+
]);
|
|
19
|
+
var RuntimeEventSeverity2 = Schema.Literals(["debug", "error", "info", "warning"]);
|
|
20
|
+
var RuntimeEventTimeline2 = Schema.Literals(["live", "state", "system", "work"]);
|
|
21
|
+
var RuntimeWorkSource2 = Schema.Literals([
|
|
22
|
+
"react",
|
|
23
|
+
"mobx",
|
|
24
|
+
"node",
|
|
25
|
+
"manual",
|
|
26
|
+
"devtools",
|
|
27
|
+
"runtime",
|
|
28
|
+
"signal",
|
|
29
|
+
"test"
|
|
30
|
+
]);
|
|
31
|
+
var RuntimeWorkReason2 = Schema.Literals([
|
|
32
|
+
"start",
|
|
33
|
+
"stop",
|
|
34
|
+
"readiness",
|
|
35
|
+
"retry",
|
|
36
|
+
"preload",
|
|
37
|
+
"refresh",
|
|
38
|
+
"action",
|
|
39
|
+
"args-update",
|
|
40
|
+
"live",
|
|
41
|
+
"release",
|
|
42
|
+
"eviction",
|
|
43
|
+
"unsafe-update",
|
|
44
|
+
"input",
|
|
45
|
+
"signal"
|
|
46
|
+
]);
|
|
47
|
+
var RuntimeWorkPriority2 = Schema.Literals(["blocking", "visible", "background", "idle"]);
|
|
48
|
+
var AttachmentInfo2 = Schema.Struct({
|
|
49
|
+
protocolVersion: Schema.Number,
|
|
50
|
+
instanceId: Schema.String,
|
|
51
|
+
runtimeId: Schema.String,
|
|
52
|
+
generation: Schema.Number,
|
|
53
|
+
name: Schema.String,
|
|
54
|
+
platform: Schema.String,
|
|
55
|
+
startedAt: Schema.Number,
|
|
56
|
+
values: ValuePolicy2
|
|
57
|
+
});
|
|
58
|
+
var EncodedEventRecord2 = Schema.Struct({
|
|
59
|
+
sequence: Schema.Number,
|
|
60
|
+
recordedAt: Schema.Number,
|
|
61
|
+
tag: Schema.String,
|
|
62
|
+
category: RuntimeEventCategory2,
|
|
63
|
+
severity: RuntimeEventSeverity2,
|
|
64
|
+
timeline: RuntimeEventTimeline2,
|
|
65
|
+
reportable: Schema.Boolean,
|
|
66
|
+
workId: Schema.Number,
|
|
67
|
+
parentWorkId: Schema.optional(Schema.Number),
|
|
68
|
+
source: RuntimeWorkSource2,
|
|
69
|
+
reason: RuntimeWorkReason2,
|
|
70
|
+
priority: RuntimeWorkPriority2,
|
|
71
|
+
nodeIds: Schema.Array(Schema.String),
|
|
72
|
+
channel: Schema.optionalKey(Schema.String),
|
|
73
|
+
name: Schema.optionalKey(Schema.String),
|
|
74
|
+
fields: Schema.Record(Schema.String, Schema.Unknown),
|
|
75
|
+
failures: Schema.Array(Schema.Unknown)
|
|
76
|
+
});
|
|
77
|
+
var EncodedNodeSnapshot2 = Schema.Struct({
|
|
78
|
+
nodeId: Schema.String,
|
|
79
|
+
tag: Schema.String,
|
|
80
|
+
kind: Schema.String,
|
|
81
|
+
state: Schema.String,
|
|
82
|
+
revision: Schema.Number,
|
|
83
|
+
status: Schema.Unknown,
|
|
84
|
+
liveDemand: Schema.Unknown,
|
|
85
|
+
operation: Schema.Unknown,
|
|
86
|
+
resultValidity: Schema.optional(Schema.Unknown),
|
|
87
|
+
failure: Schema.optional(Schema.Unknown),
|
|
88
|
+
operationFailure: Schema.optional(Schema.Unknown),
|
|
89
|
+
liveFailure: Schema.optional(Schema.Unknown),
|
|
90
|
+
result: Schema.optional(Schema.Unknown)
|
|
91
|
+
});
|
|
92
|
+
var EncodedGraphEdge2 = Schema.Struct({
|
|
93
|
+
from: Schema.String,
|
|
94
|
+
to: Schema.String,
|
|
95
|
+
dependency: Schema.String
|
|
96
|
+
});
|
|
97
|
+
var GraphSnapshot2 = Schema.Struct({
|
|
98
|
+
capturedAt: Schema.Number,
|
|
99
|
+
sequence: Schema.optional(Schema.Number),
|
|
100
|
+
runtimeId: Schema.String,
|
|
101
|
+
runtimeStatus: Schema.String,
|
|
102
|
+
graphStatus: Schema.String,
|
|
103
|
+
observedInputs: Schema.Number,
|
|
104
|
+
values: ValuePolicy2,
|
|
105
|
+
nodes: Schema.Array(EncodedNodeSnapshot2),
|
|
106
|
+
edges: Schema.Array(EncodedGraphEdge2)
|
|
107
|
+
});
|
|
108
|
+
var GraphQuery2 = Schema.Struct({ _tag: Schema.tag("Graph") });
|
|
109
|
+
var NodeQuery2 = Schema.Struct({
|
|
110
|
+
_tag: Schema.tag("Node"),
|
|
111
|
+
nodeId: Schema.String
|
|
112
|
+
});
|
|
113
|
+
var StateQuery2 = Schema.Union([GraphQuery2, NodeQuery2]);
|
|
114
|
+
var QueryOutcome2 = Schema.Union([
|
|
115
|
+
Schema.Struct({ _tag: Schema.tag("Snapshot"), snapshot: GraphSnapshot2 }),
|
|
116
|
+
Schema.Struct({ _tag: Schema.tag("Failed"), reason: Schema.String })
|
|
117
|
+
]);
|
|
118
|
+
var HubAttached2 = Schema.Struct({
|
|
119
|
+
_tag: Schema.tag("Attached"),
|
|
120
|
+
attachmentId: Schema.String,
|
|
121
|
+
values: ValuePolicy2
|
|
122
|
+
});
|
|
123
|
+
var HubPing2 = Schema.Struct({
|
|
124
|
+
_tag: Schema.tag("Ping"),
|
|
125
|
+
at: Schema.Number
|
|
126
|
+
});
|
|
127
|
+
var HubQuery2 = Schema.Struct({
|
|
128
|
+
_tag: Schema.tag("Query"),
|
|
129
|
+
requestId: Schema.String,
|
|
130
|
+
query: StateQuery2,
|
|
131
|
+
values: ValuePolicy2
|
|
132
|
+
});
|
|
133
|
+
var HubCommand2 = Schema.Union([HubAttached2, HubPing2, HubQuery2]);
|
|
134
|
+
|
|
135
|
+
class HubRejection2 extends Schema.TaggedError()("HubRejection", {
|
|
136
|
+
reason: Schema.String
|
|
137
|
+
}) {
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
class Attach2 extends Rpc.make("Frond.Attach", {
|
|
141
|
+
payload: { info: AttachmentInfo2 },
|
|
142
|
+
success: HubCommand2,
|
|
143
|
+
error: HubRejection2,
|
|
144
|
+
stream: true
|
|
145
|
+
}) {
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
class Ingest2 extends Rpc.make("Frond.Ingest", {
|
|
149
|
+
payload: {
|
|
150
|
+
attachmentId: Schema.String,
|
|
151
|
+
records: Schema.Array(EncodedEventRecord2),
|
|
152
|
+
droppedSince: Schema.Number
|
|
153
|
+
}
|
|
154
|
+
}) {
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
class Reply2 extends Rpc.make("Frond.Reply", {
|
|
158
|
+
payload: {
|
|
159
|
+
attachmentId: Schema.String,
|
|
160
|
+
requestId: Schema.String,
|
|
161
|
+
outcome: QueryOutcome2
|
|
162
|
+
}
|
|
163
|
+
}) {
|
|
164
|
+
}
|
|
165
|
+
var FrondHubRpcs2 = RpcGroup.make(Attach2, Ingest2, Reply2);
|
|
166
|
+
|
|
167
|
+
export { HUB_PROTOCOL_VERSION2, HUB_DEFAULT_PORT2, HUB_DEFAULT_HOST2, HUB_ATTACH_PATH2, HUB_DEFAULT_ATTACH_URL2, ValuePolicy2, RuntimeEventCategory2, RuntimeEventSeverity2, RuntimeEventTimeline2, RuntimeWorkSource2, RuntimeWorkReason2, RuntimeWorkPriority2, AttachmentInfo2, EncodedEventRecord2, EncodedNodeSnapshot2, EncodedGraphEdge2, GraphSnapshot2, GraphQuery2, NodeQuery2, StateQuery2, QueryOutcome2, HubAttached2, HubPing2, HubQuery2, HubCommand2, HubRejection2, Attach2, Ingest2, Reply2, FrondHubRpcs2 };
|
|
168
|
+
|
|
169
|
+
//# debugId=D15BC16ECFF7952164756E2164756E21
|
|
@@ -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/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.TaggedError<HubRejection>()(\"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,wBAAuB;AAa7B,IAAM,oBAAmB;AAEzB,IAAM,oBAAmB;AAEzB,IAAM,mBAAkB;AAGxB,IAAM,0BAAyB,QAAQ,qBAAoB,oBAAmB;AAW9E,IAAM,eAAc,OAAO,SAAS,CAAC,QAAQ,SAAS,MAAM,CAAC;AAG7D,IAAM,wBAAuB,OAAO,SAAS;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,wBAAuB,OAAO,SAAS,CAAC,SAAS,SAAS,QAAQ,SAAS,CAAC;AAElF,IAAM,wBAAuB,OAAO,SAAS,CAAC,QAAQ,SAAS,UAAU,MAAM,CAAC;AAEhF,IAAM,qBAAoB,OAAO,SAAS;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,qBAAoB,OAAO,SAAS;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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AAM,OAAO,IAAI,OAAO;AAAA,EACxB,WAAW,OAAO;AAAA,EAClB,OAAO;AAAA,EACP,QAAQ;AACV,CAAC;AAGM,IAAM,cAAa,OAAO,MAAM,CAAC,cAAa,UAAS,SAAQ,CAAC;AAAA;AAiBhE,MAAM,sBAAqB,OAAO,YAA0B,EAAE,gBAAgB;AAAA,EACnF,QAAQ,OAAO;AACjB,CAAC,EAAE;AAAC;AAAA;AAqBG,MAAM,gBAAe,IAAI,KAAK,gBAAgB;AAAA,EACnD,SAAS,EAAE,MAAM,gBAAe;AAAA,EAChC,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AACV,CAAC,EAAE;AAAC;AAAA;AAWG,MAAM,gBAAe,IAAI,KAAK,gBAAgB;AAAA,EACnD,SAAS;AAAA,IACP,cAAc,OAAO;AAAA,IACrB,SAAS,OAAO,MAAM,mBAAkB;AAAA,IACxC,cAAc,OAAO;AAAA,EACvB;AACF,CAAC,EAAE;AAAC;AAAA;AAWG,MAAM,eAAc,IAAI,KAAK,eAAe;AAAA,EACjD,SAAS;AAAA,IACP,cAAc,OAAO;AAAA,IACrB,WAAW,OAAO;AAAA,IAClB,SAAS;AAAA,EACX;AACF,CAAC,EAAE;AAAC;AAEG,IAAM,gBAAe,SAAS,KAAK,SAAQ,SAAQ,MAAK;",
|
|
8
|
+
"debugId": "D15BC16ECFF7952164756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { Layer } from 'effect';
|
|
3
|
-
import { Rpc } from 'effect/
|
|
4
|
-
import { RpcClient } from 'effect/
|
|
5
|
-
import { RpcClientError } from 'effect/
|
|
6
|
-
import { RpcGroup } from 'effect/
|
|
3
|
+
import { Rpc } from 'effect/rpc';
|
|
4
|
+
import { RpcClient } from 'effect/rpc';
|
|
5
|
+
import { RpcClientError } from 'effect/rpc/RpcClientError';
|
|
6
|
+
import { RpcGroup } from 'effect/rpc';
|
|
7
7
|
import type { Runtime } from '@frondruntime/core';
|
|
8
8
|
import { Schema } from 'effect';
|
|
9
9
|
import { Scope } from 'effect/Scope';
|
|
10
|
-
import { Stream } from 'effect/
|
|
10
|
+
import { Stream } from 'effect/rpc/RpcSchema';
|
|
11
11
|
import { YieldableError } from 'effect/Cause';
|
|
12
12
|
|
|
13
13
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} from "./chunk-
|
|
2
|
+
HUB_PROTOCOL_VERSION2,
|
|
3
|
+
HUB_DEFAULT_PORT2,
|
|
4
|
+
HUB_DEFAULT_HOST2,
|
|
5
|
+
HUB_ATTACH_PATH2,
|
|
6
|
+
HUB_DEFAULT_ATTACH_URL2,
|
|
7
|
+
ValuePolicy2,
|
|
8
|
+
RuntimeEventCategory2,
|
|
9
|
+
RuntimeEventSeverity2,
|
|
10
|
+
RuntimeEventTimeline2,
|
|
11
|
+
RuntimeWorkSource2,
|
|
12
|
+
RuntimeWorkReason2,
|
|
13
|
+
RuntimeWorkPriority2,
|
|
14
|
+
AttachmentInfo2,
|
|
15
|
+
EncodedEventRecord2,
|
|
16
|
+
EncodedNodeSnapshot2,
|
|
17
|
+
EncodedGraphEdge2,
|
|
18
|
+
GraphSnapshot2,
|
|
19
|
+
GraphQuery2,
|
|
20
|
+
NodeQuery2,
|
|
21
|
+
StateQuery2,
|
|
22
|
+
QueryOutcome2,
|
|
23
|
+
HubAttached2,
|
|
24
|
+
HubPing2,
|
|
25
|
+
HubQuery2,
|
|
26
|
+
HubCommand2,
|
|
27
|
+
HubRejection2,
|
|
28
|
+
Attach2,
|
|
29
|
+
Ingest2,
|
|
30
|
+
Reply2,
|
|
31
|
+
FrondHubRpcs2
|
|
32
|
+
} from "./chunk-tky04mfa.js";
|
|
33
33
|
|
|
34
34
|
// src/attach.ts
|
|
35
35
|
import { Clock, Effect, Layer, Stream } from "effect";
|
|
36
|
-
import { RpcClient, RpcSerialization } from "effect/
|
|
37
|
-
import { Socket } from "effect/
|
|
36
|
+
import { RpcClient, RpcSerialization } from "effect/rpc";
|
|
37
|
+
import { Socket } from "effect/socket";
|
|
38
38
|
|
|
39
39
|
// src/cause.ts
|
|
40
40
|
import { Diagnostics } from "@frondruntime/core";
|
|
@@ -537,7 +537,7 @@ function attachLayer(attachUrl) {
|
|
|
537
537
|
return RpcClient.layerProtocolSocket().pipe(Layer.provide(Socket.layerWebSocket(attachUrl)), Layer.provide(Socket.layerWebSocketConstructorGlobal), Layer.provide(RpcSerialization.layerNdjson));
|
|
538
538
|
}
|
|
539
539
|
var attachRuntime = Effect.fnUntraced(function* (options) {
|
|
540
|
-
const client = yield* RpcClient.make(
|
|
540
|
+
const client = yield* RpcClient.make(FrondHubRpcs2);
|
|
541
541
|
const ceiling = options.values ?? "shape";
|
|
542
542
|
let buffer = [];
|
|
543
543
|
let dropped = 0;
|
|
@@ -555,7 +555,7 @@ var attachRuntime = Effect.fnUntraced(function* (options) {
|
|
|
555
555
|
});
|
|
556
556
|
yield* Effect.addFinalizer(() => Effect.sync(() => subscription.unsubscribe()));
|
|
557
557
|
const info = {
|
|
558
|
-
protocolVersion:
|
|
558
|
+
protocolVersion: HUB_PROTOCOL_VERSION2,
|
|
559
559
|
instanceId: options.instanceId ?? newInstanceId(),
|
|
560
560
|
runtimeId: options.runtime.getSnapshotSync().runtimeId,
|
|
561
561
|
generation: options.generation ?? 0,
|
|
@@ -621,14 +621,14 @@ class AttachRefused extends Data.TaggedError("AttachRefused") {
|
|
|
621
621
|
}
|
|
622
622
|
function refusal(cause) {
|
|
623
623
|
for (const reason of cause.reasons) {
|
|
624
|
-
if (Cause.isFailReason(reason) && reason.error instanceof
|
|
624
|
+
if (Cause.isFailReason(reason) && reason.error instanceof HubRejection2) {
|
|
625
625
|
return reason.error;
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
628
|
return;
|
|
629
629
|
}
|
|
630
630
|
function attachDevtools(options) {
|
|
631
|
-
const url = options.url ??
|
|
631
|
+
const url = options.url ?? HUB_DEFAULT_ATTACH_URL2;
|
|
632
632
|
const instanceId = options.instanceId ?? newInstanceId();
|
|
633
633
|
let generation = 0;
|
|
634
634
|
const session = Effect2.suspend(() => attachRuntime({
|
|
@@ -671,43 +671,43 @@ function detectPlatform() {
|
|
|
671
671
|
return "unknown";
|
|
672
672
|
}
|
|
673
673
|
export {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
674
|
+
Attach2 as Attach,
|
|
675
|
+
AttachmentInfo2 as AttachmentInfo,
|
|
676
|
+
EncodedEventRecord2 as EncodedEventRecord,
|
|
677
|
+
EncodedGraphEdge2 as EncodedGraphEdge,
|
|
678
|
+
EncodedNodeSnapshot2 as EncodedNodeSnapshot,
|
|
679
|
+
FrondHubRpcs2 as FrondHubRpcs,
|
|
680
|
+
GraphQuery2 as GraphQuery,
|
|
681
|
+
GraphSnapshot2 as GraphSnapshot,
|
|
682
|
+
HUB_ATTACH_PATH2 as HUB_ATTACH_PATH,
|
|
683
|
+
HUB_DEFAULT_ATTACH_URL2 as HUB_DEFAULT_ATTACH_URL,
|
|
684
|
+
HUB_DEFAULT_HOST2 as HUB_DEFAULT_HOST,
|
|
685
|
+
HUB_DEFAULT_PORT2 as HUB_DEFAULT_PORT,
|
|
686
|
+
HUB_PROTOCOL_VERSION2 as HUB_PROTOCOL_VERSION,
|
|
687
|
+
HubAttached2 as HubAttached,
|
|
688
|
+
HubCommand2 as HubCommand,
|
|
689
|
+
HubPing2 as HubPing,
|
|
690
|
+
HubQuery2 as HubQuery,
|
|
691
|
+
HubRejection2 as HubRejection,
|
|
692
|
+
Ingest2 as Ingest,
|
|
693
|
+
NodeQuery2 as NodeQuery,
|
|
694
|
+
QueryOutcome2 as QueryOutcome,
|
|
695
|
+
Reply2 as Reply,
|
|
696
|
+
RuntimeEventCategory2 as RuntimeEventCategory,
|
|
697
|
+
RuntimeEventSeverity2 as RuntimeEventSeverity,
|
|
698
|
+
RuntimeEventTimeline2 as RuntimeEventTimeline,
|
|
699
|
+
RuntimeWorkPriority2 as RuntimeWorkPriority,
|
|
700
|
+
RuntimeWorkReason2 as RuntimeWorkReason,
|
|
701
|
+
RuntimeWorkSource2 as RuntimeWorkSource,
|
|
702
|
+
StateQuery2 as StateQuery,
|
|
703
|
+
ValuePolicy2 as ValuePolicy,
|
|
680
704
|
attachDevtools,
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
RuntimeEventSeverity,
|
|
688
|
-
RuntimeEventCategory,
|
|
689
|
-
Reply,
|
|
690
|
-
QueryOutcome,
|
|
691
|
-
NodeQuery,
|
|
692
|
-
Ingest,
|
|
693
|
-
HubRejection,
|
|
694
|
-
HubQuery,
|
|
695
|
-
HubPing,
|
|
696
|
-
HubCommand,
|
|
697
|
-
HubAttached,
|
|
698
|
-
HUB_PROTOCOL_VERSION,
|
|
699
|
-
HUB_DEFAULT_PORT,
|
|
700
|
-
HUB_DEFAULT_HOST,
|
|
701
|
-
HUB_DEFAULT_ATTACH_URL,
|
|
702
|
-
HUB_ATTACH_PATH,
|
|
703
|
-
GraphSnapshot,
|
|
704
|
-
GraphQuery,
|
|
705
|
-
FrondHubRpcs,
|
|
706
|
-
EncodedNodeSnapshot,
|
|
707
|
-
EncodedGraphEdge,
|
|
708
|
-
EncodedEventRecord,
|
|
709
|
-
AttachmentInfo,
|
|
710
|
-
Attach
|
|
705
|
+
attachLayer,
|
|
706
|
+
attachRuntime,
|
|
707
|
+
createValueEncoder,
|
|
708
|
+
encodeGraphSnapshot,
|
|
709
|
+
encodeRecord,
|
|
710
|
+
resolvePolicy
|
|
711
711
|
};
|
|
712
712
|
|
|
713
|
-
//# debugId=
|
|
713
|
+
//# debugId=774FA5A5A200C1E464756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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 * 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",
|
|
5
|
+
"import type { Runtime } from \"@frondruntime/core\";\nimport { Clock, Effect, Layer, Stream } from \"effect\";\nimport { RpcClient, RpcSerialization } from \"effect/rpc\";\nimport { Socket } from \"effect/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",
|
|
@@ -12,7 +12,7 @@
|
|
|
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
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,sBAAsB;AAyCrB,SAAS,aAAa,CAC3B,OACA,QACA,MACiB;AAAA,EACjB,MAAM,WAAW,WAAW;AAAA,EAE5B,MAAM,SAAS,YAAY,oBAAoB,OAAO;AAAA,IACpD,UAAU;AAAA,IACV,iBAAiB,WAAW,2BAA2B;AAAA,IAGvD,gBAAgB;AAAA,IAChB,eAAe,WAAW,KAAK;AAAA,EACjC,CAAC;AAAA,EAED,IAAI,SAAS,WAAW;AAAA,IAQtB,MAAM,OAAO,WAAW,SAAS,EAAE,MAAM,WAAW,WAAW,UAAU,IAAI,CAAC;AAAA,IAE9E,OAAO;AAAA,MACL,GAAG;AAAA,MACH,SAAS,Y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,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": "774FA5A5A200C1E464756E2164756E21",
|
|
17
17
|
"names": []
|
|
18
18
|
}
|
package/dist/node.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
HUB_DEFAULT_PORT2
|
|
3
|
+
} from "./chunk-tky04mfa.js";
|
|
4
4
|
|
|
5
5
|
// src/node.ts
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
import { dirname, join, parse } from "node:path";
|
|
8
8
|
function readHubLock(options = {}) {
|
|
9
|
-
const port = options.port ??
|
|
9
|
+
const port = options.port ?? HUB_DEFAULT_PORT2;
|
|
10
10
|
const relative = join(".frond", `hub-${port}.json`);
|
|
11
11
|
let directory = options.cwd ?? process.cwd();
|
|
12
12
|
const root = parse(directory).root;
|
|
@@ -42,4 +42,4 @@ export {
|
|
|
42
42
|
readHubLock
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
//# debugId=
|
|
45
|
+
//# debugId=769503E17CF0445264756E2164756E21
|
package/dist/node.js.map
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"import { readFileSync } from \"node:fs\";\nimport { dirname, join, parse } from \"node:path\";\nimport { HUB_DEFAULT_PORT } from \"./protocol.ts\";\n\n/**\n * Filesystem discovery for hosts that have a filesystem.\n *\n * Deliberately a separate export from the package root. A browser bundle must\n * never have to resolve `node:fs`, and the reliable way to guarantee that is\n * for the module graph a browser reaches to not contain it — not a runtime\n * guard, which bundlers still follow.\n */\n\n/** What a running hub writes to `.frond/hub-<port>.json`. */\nexport type HubLock = {\n readonly protocolVersion: number;\n readonly attachUrl: string;\n readonly host: string;\n readonly port: number;\n readonly pid: number;\n};\n\nexport type ReadHubLockOptions = {\n /** Which hub to look for. Defaults to the default port. */\n readonly port?: number | undefined;\n /** Where to start searching. Defaults to the process's working directory. */\n readonly cwd?: string | undefined;\n};\n\n/**\n * Finds the lockfile of a hub running for this project.\n *\n * Walks up from `cwd` rather than looking only in it, because the hub is\n * started from the repository root and the app that wants to attach usually is\n * not — a monorepo package running its own dev server is the normal case, not\n * the exception.\n *\n * Returns `undefined` rather than throwing for every way the file can fail to\n * be a lock: absent, unreadable, or malformed. Not finding a hub is the\n * ordinary state of a machine where nobody started one, and the caller's\n * response to all three is identical anyway.\n *\n * What it does *not* do is decide whether the hub named by a well-formed lock\n * is still there. A hub that died without running its finalizer leaves a file\n * that parses, and this returns it. Liveness is the caller's call and the\n * fields to make it are on the result: `pid` for a signal probe, `port` for a\n * dial, and `protocolVersion` to compare against the one this build speaks. A\n * reader that guessed on the caller's behalf would be guessing wrong for the\n * scripts that only want the address.\n */\nexport function readHubLock(options: ReadHubLockOptions = {}): HubLock | undefined {\n const port = options.port ?? HUB_DEFAULT_PORT;\n const relative = join(\".frond\", `hub-${port}.json`);\n\n let directory = options.cwd ?? process.cwd();\n const root = parse(directory).root;\n\n for (;;) {\n const found = readLock(join(directory, relative));\n\n if (found !== undefined) {\n return found;\n }\n\n if (directory === root) {\n return undefined;\n }\n\n const parent = dirname(directory);\n\n // `dirname` is a fixed point at the root on every platform, and on some\n // inputs it reaches one that is not `parse().root`. Without this the loop\n // above would spin forever on exactly the paths nobody tests with.\n if (parent === directory) {\n return undefined;\n }\n\n directory = parent;\n }\n}\n\nfunction readLock(path: string): HubLock | undefined {\n let parsed: unknown;\n\n try {\n parsed = JSON.parse(readFileSync(path, \"utf8\"));\n } catch {\n return undefined;\n }\n\n if (typeof parsed !== \"object\" || parsed === null) {\n return undefined;\n }\n\n const lock = parsed as Partial<HubLock>;\n\n // Every field checked rather than cast, because this file outlives the process\n // that wrote it if that process died badly — so what is on disk may have been\n // written by a build that is no longer installed. A shape check is all this\n // does: it says the five fields are there and are the right types, not that\n // the hub behind them is alive or speaks the protocol this build speaks.\n // Those are the caller's to decide, from `pid` and `protocolVersion`.\n return typeof lock.attachUrl === \"string\" &&\n typeof lock.host === \"string\" &&\n typeof lock.port === \"number\" &&\n typeof lock.pid === \"number\" &&\n typeof lock.protocolVersion === \"number\"\n ? (lock as HubLock)\n : undefined;\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";;;;;AAAA;AACA;AAiDO,SAAS,WAAW,CAAC,UAA8B,CAAC,GAAwB;AAAA,EACjF,MAAM,OAAO,QAAQ,QAAQ;AAAA,EAC7B,MAAM,WAAW,KAAK,UAAU,OAAO,WAAW;AAAA,EAElD,IAAI,YAAY,QAAQ,OAAO,QAAQ,IAAI;AAAA,EAC3C,MAAM,OAAO,MAAM,SAAS,EAAE;AAAA,EAE9B,UAAS;AAAA,IACP,MAAM,QAAQ,SAAS,KAAK,WAAW,QAAQ,CAAC;AAAA,IAEhD,IAAI,UAAU,WAAW;AAAA,MACvB,OAAO;AAAA,IACT;AAAA,IAEA,IAAI,cAAc,MAAM;AAAA,MACtB;AAAA,IACF;AAAA,IAEA,MAAM,SAAS,QAAQ,SAAS;AAAA,IAKhC,IAAI,WAAW,WAAW;AAAA,MACxB;AAAA,IACF;AAAA,IAEA,YAAY;AAAA,EACd;AAAA;AAGF,SAAS,QAAQ,CAAC,MAAmC;AAAA,EACnD,IAAI;AAAA,EAEJ,IAAI;AAAA,IACF,SAAS,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;AAAA,IAC9C,MAAM;AAAA,IACN;AAAA;AAAA,EAGF,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,MAAM,OAAO;AAAA,EAQb,OAAO,OAAO,KAAK,cAAc,YAC/B,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,QAAQ,YACpB,OAAO,KAAK,oBAAoB,WAC7B,OACD;AAAA;",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "769503E17CF0445264756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frondruntime/devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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.5.0",
|
|
61
|
+
"effect": "^4.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.
|
|
67
|
+
"effect": "4.0.5"
|
|
68
68
|
},
|
|
69
69
|
"author": {
|
|
70
70
|
"name": "Roman Dubinin",
|
package/src/attach.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Runtime } from "@frondruntime/core";
|
|
2
2
|
import { Clock, Effect, Layer, Stream } from "effect";
|
|
3
|
-
import { RpcClient, RpcSerialization } from "effect/
|
|
4
|
-
import { Socket } from "effect/
|
|
3
|
+
import { RpcClient, RpcSerialization } from "effect/rpc";
|
|
4
|
+
import { Socket } from "effect/socket";
|
|
5
5
|
import { encodeRecord } from "./encode.ts";
|
|
6
6
|
import { type EncodePolicy, resolvePolicy } from "./policy.ts";
|
|
7
7
|
import {
|
package/src/protocol.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { Rpc, RpcGroup } from "effect/
|
|
2
|
+
import { Rpc, RpcGroup } from "effect/rpc";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Wire contract between an attached Frond runtime and the hub.
|
|
@@ -425,10 +425,9 @@ export type HubCommand = typeof HubCommand.Type;
|
|
|
425
425
|
* caller learns nothing here it could not learn by dialing and observing, and
|
|
426
426
|
* vagueness would cost only the developer who is actually trying to attach.
|
|
427
427
|
*/
|
|
428
|
-
export class HubRejection extends Schema.
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
) {}
|
|
428
|
+
export class HubRejection extends Schema.TaggedError<HubRejection>()("HubRejection", {
|
|
429
|
+
reason: Schema.String,
|
|
430
|
+
}) {}
|
|
432
431
|
|
|
433
432
|
/**
|
|
434
433
|
* Opens the attachment and holds it open.
|
package/dist/chunk-71tmgh2e.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
// src/protocol.ts
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { Rpc, RpcGroup } from "effect/unstable/rpc";
|
|
4
|
-
var HUB_PROTOCOL_VERSION = 2;
|
|
5
|
-
var HUB_DEFAULT_PORT = 17391;
|
|
6
|
-
var HUB_DEFAULT_HOST = "127.0.0.1";
|
|
7
|
-
var HUB_ATTACH_PATH = "/attach";
|
|
8
|
-
var HUB_DEFAULT_ATTACH_URL = `ws://${HUB_DEFAULT_HOST}:${HUB_DEFAULT_PORT}${HUB_ATTACH_PATH}`;
|
|
9
|
-
var ValuePolicy = Schema.Literals(["none", "shape", "full"]);
|
|
10
|
-
var RuntimeEventCategory = Schema.Literals([
|
|
11
|
-
"command",
|
|
12
|
-
"diagnostic",
|
|
13
|
-
"input",
|
|
14
|
-
"lifecycle",
|
|
15
|
-
"operation",
|
|
16
|
-
"signal",
|
|
17
|
-
"state"
|
|
18
|
-
]);
|
|
19
|
-
var RuntimeEventSeverity = Schema.Literals(["debug", "error", "info", "warning"]);
|
|
20
|
-
var RuntimeEventTimeline = Schema.Literals(["live", "state", "system", "work"]);
|
|
21
|
-
var RuntimeWorkSource = Schema.Literals([
|
|
22
|
-
"react",
|
|
23
|
-
"mobx",
|
|
24
|
-
"node",
|
|
25
|
-
"manual",
|
|
26
|
-
"devtools",
|
|
27
|
-
"runtime",
|
|
28
|
-
"signal",
|
|
29
|
-
"test"
|
|
30
|
-
]);
|
|
31
|
-
var RuntimeWorkReason = Schema.Literals([
|
|
32
|
-
"start",
|
|
33
|
-
"stop",
|
|
34
|
-
"readiness",
|
|
35
|
-
"retry",
|
|
36
|
-
"preload",
|
|
37
|
-
"refresh",
|
|
38
|
-
"action",
|
|
39
|
-
"args-update",
|
|
40
|
-
"live",
|
|
41
|
-
"release",
|
|
42
|
-
"eviction",
|
|
43
|
-
"unsafe-update",
|
|
44
|
-
"input",
|
|
45
|
-
"signal"
|
|
46
|
-
]);
|
|
47
|
-
var RuntimeWorkPriority = Schema.Literals(["blocking", "visible", "background", "idle"]);
|
|
48
|
-
var AttachmentInfo = Schema.Struct({
|
|
49
|
-
protocolVersion: Schema.Number,
|
|
50
|
-
instanceId: Schema.String,
|
|
51
|
-
runtimeId: Schema.String,
|
|
52
|
-
generation: Schema.Number,
|
|
53
|
-
name: Schema.String,
|
|
54
|
-
platform: Schema.String,
|
|
55
|
-
startedAt: Schema.Number,
|
|
56
|
-
values: ValuePolicy
|
|
57
|
-
});
|
|
58
|
-
var EncodedEventRecord = Schema.Struct({
|
|
59
|
-
sequence: Schema.Number,
|
|
60
|
-
recordedAt: Schema.Number,
|
|
61
|
-
tag: Schema.String,
|
|
62
|
-
category: RuntimeEventCategory,
|
|
63
|
-
severity: RuntimeEventSeverity,
|
|
64
|
-
timeline: RuntimeEventTimeline,
|
|
65
|
-
reportable: Schema.Boolean,
|
|
66
|
-
workId: Schema.Number,
|
|
67
|
-
parentWorkId: Schema.optional(Schema.Number),
|
|
68
|
-
source: RuntimeWorkSource,
|
|
69
|
-
reason: RuntimeWorkReason,
|
|
70
|
-
priority: RuntimeWorkPriority,
|
|
71
|
-
nodeIds: Schema.Array(Schema.String),
|
|
72
|
-
channel: Schema.optionalKey(Schema.String),
|
|
73
|
-
name: Schema.optionalKey(Schema.String),
|
|
74
|
-
fields: Schema.Record(Schema.String, Schema.Unknown),
|
|
75
|
-
failures: Schema.Array(Schema.Unknown)
|
|
76
|
-
});
|
|
77
|
-
var EncodedNodeSnapshot = Schema.Struct({
|
|
78
|
-
nodeId: Schema.String,
|
|
79
|
-
tag: Schema.String,
|
|
80
|
-
kind: Schema.String,
|
|
81
|
-
state: Schema.String,
|
|
82
|
-
revision: Schema.Number,
|
|
83
|
-
status: Schema.Unknown,
|
|
84
|
-
liveDemand: Schema.Unknown,
|
|
85
|
-
operation: Schema.Unknown,
|
|
86
|
-
resultValidity: Schema.optional(Schema.Unknown),
|
|
87
|
-
failure: Schema.optional(Schema.Unknown),
|
|
88
|
-
operationFailure: Schema.optional(Schema.Unknown),
|
|
89
|
-
liveFailure: Schema.optional(Schema.Unknown),
|
|
90
|
-
result: Schema.optional(Schema.Unknown)
|
|
91
|
-
});
|
|
92
|
-
var EncodedGraphEdge = Schema.Struct({
|
|
93
|
-
from: Schema.String,
|
|
94
|
-
to: Schema.String,
|
|
95
|
-
dependency: Schema.String
|
|
96
|
-
});
|
|
97
|
-
var GraphSnapshot = Schema.Struct({
|
|
98
|
-
capturedAt: Schema.Number,
|
|
99
|
-
sequence: Schema.optional(Schema.Number),
|
|
100
|
-
runtimeId: Schema.String,
|
|
101
|
-
runtimeStatus: Schema.String,
|
|
102
|
-
graphStatus: Schema.String,
|
|
103
|
-
observedInputs: Schema.Number,
|
|
104
|
-
values: ValuePolicy,
|
|
105
|
-
nodes: Schema.Array(EncodedNodeSnapshot),
|
|
106
|
-
edges: Schema.Array(EncodedGraphEdge)
|
|
107
|
-
});
|
|
108
|
-
var GraphQuery = Schema.Struct({ _tag: Schema.tag("Graph") });
|
|
109
|
-
var NodeQuery = Schema.Struct({
|
|
110
|
-
_tag: Schema.tag("Node"),
|
|
111
|
-
nodeId: Schema.String
|
|
112
|
-
});
|
|
113
|
-
var StateQuery = Schema.Union([GraphQuery, NodeQuery]);
|
|
114
|
-
var QueryOutcome = Schema.Union([
|
|
115
|
-
Schema.Struct({ _tag: Schema.tag("Snapshot"), snapshot: GraphSnapshot }),
|
|
116
|
-
Schema.Struct({ _tag: Schema.tag("Failed"), reason: Schema.String })
|
|
117
|
-
]);
|
|
118
|
-
var HubAttached = Schema.Struct({
|
|
119
|
-
_tag: Schema.tag("Attached"),
|
|
120
|
-
attachmentId: Schema.String,
|
|
121
|
-
values: ValuePolicy
|
|
122
|
-
});
|
|
123
|
-
var HubPing = Schema.Struct({
|
|
124
|
-
_tag: Schema.tag("Ping"),
|
|
125
|
-
at: Schema.Number
|
|
126
|
-
});
|
|
127
|
-
var HubQuery = Schema.Struct({
|
|
128
|
-
_tag: Schema.tag("Query"),
|
|
129
|
-
requestId: Schema.String,
|
|
130
|
-
query: StateQuery,
|
|
131
|
-
values: ValuePolicy
|
|
132
|
-
});
|
|
133
|
-
var HubCommand = Schema.Union([HubAttached, HubPing, HubQuery]);
|
|
134
|
-
|
|
135
|
-
class HubRejection extends Schema.TaggedErrorClass("HubRejection")("HubRejection", { reason: Schema.String }) {
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
class Attach extends Rpc.make("Frond.Attach", {
|
|
139
|
-
payload: { info: AttachmentInfo },
|
|
140
|
-
success: HubCommand,
|
|
141
|
-
error: HubRejection,
|
|
142
|
-
stream: true
|
|
143
|
-
}) {
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
class Ingest extends Rpc.make("Frond.Ingest", {
|
|
147
|
-
payload: {
|
|
148
|
-
attachmentId: Schema.String,
|
|
149
|
-
records: Schema.Array(EncodedEventRecord),
|
|
150
|
-
droppedSince: Schema.Number
|
|
151
|
-
}
|
|
152
|
-
}) {
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
class Reply extends Rpc.make("Frond.Reply", {
|
|
156
|
-
payload: {
|
|
157
|
-
attachmentId: Schema.String,
|
|
158
|
-
requestId: Schema.String,
|
|
159
|
-
outcome: QueryOutcome
|
|
160
|
-
}
|
|
161
|
-
}) {
|
|
162
|
-
}
|
|
163
|
-
var FrondHubRpcs = RpcGroup.make(Attach, Ingest, Reply);
|
|
164
|
-
|
|
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 };
|
|
166
|
-
|
|
167
|
-
//# debugId=720F6D78A34FBE6564756E2164756E21
|
|
@@ -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 *\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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