@mostra/protocol 0.10.0 → 0.12.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/dist/actions.d.ts +11 -3
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/browser.d.ts +43 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +29 -1
- package/dist/browser.js.map +1 -1
- package/dist/diagnostics/codes/action.d.ts +1 -1
- package/dist/diagnostics/codes/action.d.ts.map +1 -1
- package/dist/diagnostics/codes/action.js +12 -1
- package/dist/diagnostics/codes/action.js.map +1 -1
- package/dist/diagnostics/codes/index.d.ts +3 -2
- package/dist/diagnostics/codes/index.d.ts.map +1 -1
- package/dist/diagnostics/codes/index.js +3 -1
- package/dist/diagnostics/codes/index.js.map +1 -1
- package/dist/diagnostics/codes/remote.d.ts +1 -1
- package/dist/diagnostics/codes/remote.d.ts.map +1 -1
- package/dist/diagnostics/codes/remote.js +78 -1
- package/dist/diagnostics/codes/remote.js.map +1 -1
- package/dist/diagnostics/codes/submit.d.ts +1 -1
- package/dist/diagnostics/codes/submit.d.ts.map +1 -1
- package/dist/diagnostics/codes/submit.js +12 -1
- package/dist/diagnostics/codes/submit.js.map +1 -1
- package/dist/diagnostics/codes/team.d.ts +8 -0
- package/dist/diagnostics/codes/team.d.ts.map +1 -0
- package/dist/diagnostics/codes/team.js +44 -0
- package/dist/diagnostics/codes/team.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.d.ts.map +1 -1
- package/dist/diagnostics/diagnostic.js +2 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/index.d.ts +17 -7
- package/dist/index.js +14 -4
- package/dist/interaction.d.ts +17 -3
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +17 -13
- package/dist/interaction.js.map +1 -1
- package/dist/manifest.d.ts +3 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +5 -2
- package/dist/manifest.js.map +1 -1
- package/dist/methods/artifact/pause.d.ts +33 -0
- package/dist/methods/artifact/pause.d.ts.map +1 -0
- package/dist/methods/artifact/pause.js +33 -0
- package/dist/methods/artifact/pause.js.map +1 -0
- package/dist/methods/index.d.ts.map +1 -1
- package/dist/methods/index.js +16 -2
- package/dist/methods/index.js.map +1 -1
- package/dist/methods/port/relay-author.d.ts +28 -0
- package/dist/methods/port/relay-author.d.ts.map +1 -0
- package/dist/methods/port/relay-author.js +42 -0
- package/dist/methods/port/relay-author.js.map +1 -0
- package/dist/methods/port/trusted-controls-policy.d.ts +1 -1
- package/dist/methods/remote/link.d.ts +40 -0
- package/dist/methods/remote/link.d.ts.map +1 -0
- package/dist/methods/remote/link.js +40 -0
- package/dist/methods/remote/link.js.map +1 -0
- package/dist/methods/results/get.d.ts +3 -1
- package/dist/methods/results/get.d.ts.map +1 -1
- package/dist/methods/results/get.js +4 -3
- package/dist/methods/results/get.js.map +1 -1
- package/dist/methods/results/list.d.ts +33 -0
- package/dist/methods/results/list.d.ts.map +1 -0
- package/dist/methods/results/list.js +35 -0
- package/dist/methods/results/list.js.map +1 -0
- package/dist/methods/roster/add.d.ts +47 -0
- package/dist/methods/roster/add.d.ts.map +1 -0
- package/dist/methods/roster/add.js +46 -0
- package/dist/methods/roster/add.js.map +1 -0
- package/dist/methods/roster/get.d.ts +18 -0
- package/dist/methods/roster/get.d.ts.map +1 -0
- package/dist/methods/roster/get.js +22 -0
- package/dist/methods/roster/get.js.map +1 -0
- package/dist/methods/roster/remove.d.ts +28 -0
- package/dist/methods/roster/remove.d.ts.map +1 -0
- package/dist/methods/roster/remove.js +31 -0
- package/dist/methods/roster/remove.js.map +1 -0
- package/dist/methods/share/start.d.ts +15 -2
- package/dist/methods/share/start.d.ts.map +1 -1
- package/dist/methods/share/start.js +5 -1
- package/dist/methods/share/start.js.map +1 -1
- package/dist/methods/state/get.d.ts +1 -1
- package/dist/methods/state/patch.d.ts +1 -1
- package/dist/methods/view/url.d.ts +1 -1
- package/dist/methods/wait/wait.d.ts +1 -1
- package/dist/operator.d.ts +511 -0
- package/dist/operator.d.ts.map +1 -0
- package/dist/operator.js +134 -0
- package/dist/operator.js.map +1 -0
- package/dist/team-settings.d.ts +21 -0
- package/dist/team-settings.d.ts.map +1 -0
- package/dist/team-settings.js +27 -0
- package/dist/team-settings.js.map +1 -0
- package/dist/team.d.ts +221 -0
- package/dist/team.d.ts.map +1 -0
- package/dist/team.js +162 -0
- package/dist/team.js.map +1 -0
- package/dist/verify.d.ts +7 -0
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/package.json +11 -1
- package/schemas/protocol.draft-07.json +1027 -45
- package/schemas/protocol.schema.json +996 -46
- package/src/actions.ts +8 -4
- package/src/browser.ts +64 -0
- package/src/diagnostics/codes/action.ts +12 -0
- package/src/diagnostics/codes/index.ts +6 -2
- package/src/diagnostics/codes/remote.ts +84 -0
- package/src/diagnostics/codes/submit.ts +12 -0
- package/src/diagnostics/codes/team.ts +53 -0
- package/src/diagnostics/diagnostic.ts +3 -1
- package/src/index.ts +66 -2
- package/src/interaction.ts +30 -5
- package/src/manifest.ts +5 -0
- package/src/methods/artifact/pause.ts +59 -0
- package/src/methods/index.ts +14 -0
- package/src/methods/port/relay-author.ts +57 -0
- package/src/methods/remote/link.ts +65 -0
- package/src/methods/results/get.ts +3 -2
- package/src/methods/results/list.ts +61 -0
- package/src/methods/roster/add.ts +77 -0
- package/src/methods/roster/get.ts +30 -0
- package/src/methods/roster/remove.ts +49 -0
- package/src/methods/share/start.ts +23 -3
- package/src/operator.ts +660 -0
- package/src/team-settings.ts +38 -0
- package/src/team.ts +398 -0
- package/src/verify.ts +7 -0
package/dist/actions.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Frame, WireError } from "./serializer.js";
|
|
2
|
+
import { PresenceState, RosterForPage } from "./team.js";
|
|
2
3
|
import * as z from "zod";
|
|
3
4
|
//#region src/actions.d.ts
|
|
4
5
|
/** A value written by the serializer: its batches, in order (`serializeAll`). */
|
|
@@ -177,9 +178,10 @@ export interface LiveUpdate {
|
|
|
177
178
|
readonly awaiting?: boolean;
|
|
178
179
|
}
|
|
179
180
|
/**
|
|
180
|
-
* An ephemeral message on a page's event stream (SSE `event: run
|
|
181
|
-
* `id`, so a reconnect's cursor is untouched) or in a poll's `ephemeral`:
|
|
182
|
-
* never stored as an event.
|
|
181
|
+
* An ephemeral message on a page's event stream (SSE `event: run`, `live`, `respondents` or
|
|
182
|
+
* `presence`, without an `id`, so a reconnect's cursor is untouched) or in a poll's `ephemeral`:
|
|
183
|
+
* lossy, coalesced, and never stored as an event. `respondents` and `presence` (D168) reach only a
|
|
184
|
+
* page that asked for them, so a version built before them never receives one.
|
|
183
185
|
*/
|
|
184
186
|
export type EphemeralMessage = {
|
|
185
187
|
readonly kind: "run";
|
|
@@ -187,6 +189,12 @@ export type EphemeralMessage = {
|
|
|
187
189
|
} | {
|
|
188
190
|
readonly kind: "live";
|
|
189
191
|
readonly live: LiveUpdate;
|
|
192
|
+
} | {
|
|
193
|
+
readonly kind: "respondents";
|
|
194
|
+
readonly respondents: RosterForPage;
|
|
195
|
+
} | {
|
|
196
|
+
readonly kind: "presence";
|
|
197
|
+
readonly presence: PresenceState;
|
|
190
198
|
};
|
|
191
199
|
/** `POST …/call/{fnId}`: a plain server-function call, no durable record (D54). */
|
|
192
200
|
export interface CallRequest {
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","names":[],"sources":["../src/actions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.d.ts","names":[],"sources":["../src/actions.ts"],"mappings":";;;;;YAiBY,6BAA6B;;;;;qBAM5B,SAAS,EAAE,QAAQ;;iBASf,oBAAoB;;WAE1B;;;qBAIE,aAAa,EAAE,QAAQ;;qBAYvB;;qBAGA;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N;;;;;WAKA;aACE;aACA;aACA;;;;qBAKA,aAAa,EAAE,QAAQ;;qBAoBvB,qBAAqB;;qBAGrB"}
|
package/dist/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","names":[],"sources":["../src/actions.ts"],"sourcesContent":["/**\n * Actions, live data and secrets (INTERFACES §2.4, §4, §6; D24, D44, D54, D56): the shapes the\n * browser protocol, the host protocol and the worker channel share. Server-function arguments and\n * results travel as the serializer's batches (`Batches`).\n *\n * ```ts\n * const run: RunState = await post(\"runs\", { viewId, fnId: \"actions.ts#sendReply\", args, clientKey });\n * if (run.status === \"succeeded\") show(await deserializeAll(run.batches));\n * ```\n */\nimport * as z from \"zod\";\nimport { ViewId } from \"./ids.ts\";\nimport type { Frame, WireError } from \"./serializer.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** A value written by the serializer: its batches, in order (`serializeAll`). */\nexport type Batches = readonly (readonly Frame[])[];\n\n/**\n * The Zod schema of the `Batches` type: a list of batches, each a list of frames. The frames\n * themselves are checked by the reader (`ValueReader`), which refuses anything malformed.\n */\nexport const Batches: z.ZodType<Batches> = z\n .array(z.array(z.record(z.string(), z.unknown())).readonly())\n .readonly()\n .register(wireRegistry, {\n id: \"Batches\",\n description: \"A serialized server-function value: its batches of frames, in order.\",\n }) as unknown as z.ZodType<Batches>;\n\n/** An error as runs, calls and live sources report it. */\nexport interface ActionError extends WireError {\n /** The stack of the thrown error, kept in the run log and never sent to a page. */\n readonly stack?: string;\n}\n\n/** The Zod schema of the `ActionError` type. */\nexport const ActionError: z.ZodType<ActionError> = z\n .object({\n message: z.string(),\n code: z.string().exactOptional(),\n stack: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ActionError\",\n description: \"An error from server code: its message and diagnostic code.\",\n });\n\n/** The largest serialized arguments a call or run takes, in characters of JSON. */\nexport const ACTION_ARGS_MAX: number = 16 * 1024 * 1024;\n\n/** The largest serialized result a run keeps, in characters of JSON (larger fails the run). */\nexport const ACTION_RESULT_MAX: number = 16 * 1024 * 1024;\n\n/** The cap of a run's log, in UTF-16 code units of its lines (D47's 1 MB). */\nexport const RUN_LOG_MAX: number = 1024 * 1024;\n\n/** The line a capped log ends with. */\nexport const RUN_LOG_TRUNCATED = \"[log truncated at 1 MB]\";\n\n/** The longest run key, in characters. */\nexport const RUN_KEY_MAX = 256;\n\n/**\n * A run's state (D24, ARCHITECTURE §7). `queued`: recorded, not yet started in a worker.\n * `running`: started. `waiting`: a remote server's run that waits for its owner's instance (D165\n * item 4); a page that doesn't know it treats it like `queued`. `unknown`: a relayed run whose\n * owner never reported its end within the artifact's offline limit, which may have taken effect;\n * the owner's later report replaces it once. The others are final.\n */\nexport type RunStatus =\n | \"queued\"\n | \"running\"\n | \"waiting\"\n | \"succeeded\"\n | \"failed\"\n | \"cancelled\"\n | \"unknown\";\n\n/** Every run status. */\nexport const RUN_STATUSES: readonly RunStatus[] = [\n \"queued\",\n \"running\",\n \"waiting\",\n \"succeeded\",\n \"failed\",\n \"cancelled\",\n \"unknown\",\n];\n\n/** Whether a run in `status` has ended. */\nexport function isFinalRunStatus(status: RunStatus): boolean {\n return status === \"succeeded\" || status === \"failed\" || status === \"cancelled\";\n}\n\n/**\n * Why a run ended the way it did, beside its status: `interrupted` (its worker or the instance\n * stopped while it ran, D24), `threw` (the action threw), `unserializable` (its result is outside\n * the type set), `too-large`, `parked` (its artifact's worker keeps crashing), `cancelled` (by a\n * viewer), `unknown-function`. Later releases add reasons.\n */\nexport type RunReason = string;\n\n/** A run's progress, as the action last reported it. */\nexport interface RunProgress {\n /** From 0 to 1. */\n readonly fraction?: number;\n /** One short line for people. */\n readonly message?: string;\n}\n\n/** The Zod schema of the `RunProgress` type. */\nexport const RunProgress: z.ZodType<RunProgress> = z\n .object({\n fraction: z.number().min(0).max(1).exactOptional(),\n message: z.string().max(1000).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunProgress\",\n description: \"A run's progress: fraction and message.\",\n });\n\n/**\n * One action run as a page reads it (D54): its state, progress, log and the result written so far.\n * A result that is an async iterable grows item by item while the run is `running`.\n */\nexport interface RunState {\n /** The run's `run_` ID. */\n readonly runId: string;\n /** The server function it runs: `<module path>#<export>`. */\n readonly fnId: string;\n /** The idempotency key it was started with, if any. */\n readonly key?: string;\n /** The run's state. */\n readonly status: RunStatus;\n /** Why it ended, for `failed` and `cancelled`. */\n readonly reason?: RunReason;\n /** Its latest progress. */\n readonly progress?: RunProgress;\n /** The log lines, capped at 1 MB with a marker line. */\n readonly log: readonly string[];\n /** The result's batches so far. */\n readonly batches: Batches;\n /** For `failed`: what went wrong, without the stack. */\n readonly error?: WireError;\n /** When it was recorded. */\n readonly startedAt: string;\n /** When it ended. */\n readonly finishedAt?: string;\n /** Whether this request joined a run that already existed (a key or a retried `clientKey`). */\n readonly joined?: boolean;\n /**\n * The index of the first line in `log`, when the request said which lines the page holds\n * (`RunAttachRequest.held`); absent: 0, the whole log.\n */\n readonly logFrom?: number;\n /** The index of the first batch in `batches`, as `logFrom`; absent: 0. */\n readonly batchFrom?: number;\n /**\n * On a remote server: the run is `running` on its owner's instance, which can't be reached now\n * (D165 item 4); it ends when the owner reports, or becomes `unknown` past the offline limit.\n */\n readonly ownerUnreachable?: boolean;\n}\n\n/** The Zod schema of the `RunState` type. */\nexport const RunState: z.ZodType<RunState> = z\n .object({\n runId: z.string(),\n fnId: z.string(),\n key: z.string().exactOptional(),\n status: z.enum(RUN_STATUSES as [RunStatus, ...RunStatus[]]),\n reason: z.string().exactOptional(),\n progress: RunProgress.exactOptional(),\n log: z.array(z.string()).readonly(),\n batches: Batches,\n error: z.object({ message: z.string(), code: z.string().exactOptional() }).exactOptional(),\n startedAt: z.string(),\n finishedAt: z.string().exactOptional(),\n joined: z.boolean().exactOptional(),\n logFrom: z.number().int().nonnegative().exactOptional(),\n batchFrom: z.number().int().nonnegative().exactOptional(),\n ownerUnreachable: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunState\",\n description: \"An action run: status, progress, log and the result written so far.\",\n });\n\n/**\n * What changed in a run since a page last heard: a lossy notification on the event stream. Lines\n * start at `logFrom` and batches at `batchFrom`; a page that holds fewer reads the run again\n * (`runs/attach`).\n */\nexport interface RunDelta {\n /** The run's `run_` ID. */\n readonly runId: string;\n /** The run's state. */\n readonly status: RunStatus;\n /** Why it ended so, for `failed` and `cancelled`. */\n readonly reason?: RunReason;\n /** Its latest progress. */\n readonly progress?: RunProgress;\n /** The index of the first line in `log`. */\n readonly logFrom: number;\n /** Log lines, starting at `logFrom`. */\n readonly log: readonly string[];\n /** The index of the first batch in `batches`. */\n readonly batchFrom: number;\n /** Result batches, starting at `batchFrom`. */\n readonly batches: Batches;\n /** What went wrong. */\n readonly error?: WireError;\n /** When it ended. */\n readonly finishedAt?: string;\n}\n\n/** A live source's value as a page reads it (D56). */\nexport interface LiveState {\n /** The idempotency key it was started with, if any. */\n readonly key: string;\n /** The value's revision, a decimal string that only grows; absent before any value. */\n readonly revision?: string;\n /** When the value was produced. */\n readonly at?: string;\n /** The latest value, serialized. */\n readonly value?: Batches;\n /**\n * Append mode (`useLive(key, { mode: \"append\" })`): the values kept in the source's ring, oldest\n * first, at most the window the page asked for.\n */\n readonly ring?: readonly {\n readonly revision: string;\n readonly at: string;\n readonly value: Batches;\n }[];\n /** The producer's last failure, while the last good value stays (FAILURE_MODEL §6). */\n readonly error?: WireError;\n /**\n * `true` while the source has no value and no failure and the artifact's latest version has a\n * producer whose first `load` is on its way: the page shows it loading, and verify waits for it.\n * Absent for a key nothing produces (one only `mostra push` writes) and for a source that only\n * streams, whose first value may never come (WP-14's Opus review).\n */\n readonly awaiting?: boolean;\n /**\n * `true` on a hosted page while the artifact's owner instance is offline, so its producers\n * can't refresh the value: the last value stays, with its `at` (D165 item 4).\n */\n readonly ownerOffline?: boolean;\n}\n\n/** One live update on the event stream: never stored as an event (D63, LL-04). */\nexport interface LiveUpdate {\n /** The live source's key. */\n readonly key: string;\n /** The value's revision. */\n readonly revision?: string;\n /** When the value was produced. */\n readonly at?: string;\n /** The value, serialized. */\n readonly value?: Batches;\n /** What went wrong. */\n readonly error?: WireError;\n /**\n * `false` when a source read as {@link LiveState.awaiting} turned out to have no first `load`\n * (its producer only streams): the page stops waiting for a first value.\n */\n readonly awaiting?: boolean;\n}\n\n/**\n * An ephemeral message on a page's event stream (SSE `event: run` or `event: live`, without an\n * `id`, so a reconnect's cursor is untouched) or in a poll's `ephemeral`: lossy, coalesced, and\n * never stored as an event.\n */\nexport type EphemeralMessage =\n | { readonly kind: \"run\"; readonly run: RunDelta }\n | { readonly kind: \"live\"; readonly live: LiveUpdate };\n\n/** `POST …/call/{fnId}`: a plain server-function call, no durable record (D54). */\nexport interface CallRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The arguments, serialized as one array value. */\n readonly args: Batches;\n}\n\n/** The Zod schema of the `CallRequest` type. */\nexport const CallRequest: z.ZodType<CallRequest> = z\n .object({ viewId: ViewId.schema, args: Batches })\n .register(wireRegistry, {\n id: \"CallRequest\",\n description: \"A plain server-function call: the view and the serialized arguments.\",\n });\n\n/**\n * One line of a plain call's answer (`application/x-ndjson`): a batch of the result, then the end.\n */\nexport type CallLine =\n | { readonly batch: readonly Frame[] }\n | { readonly end: { readonly status: \"succeeded\" } }\n | { readonly end: { readonly status: \"failed\"; readonly error: WireError } };\n\n/** `POST …/runs`: start a durable action run, or join one (D54, AC-02, AC-03). */\nexport interface RunRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** `<module path>#<export>`. */\n readonly fnId: string;\n /** The arguments, serialized as one array value. */\n readonly args: Batches;\n /** The author's idempotency key: one run per artifact, function and key, ever. */\n readonly key?: string;\n /** A fresh ID per invocation, so a retried request joins the run it already started. */\n readonly clientKey: string;\n}\n\n/** The Zod schema of the `RunRequest` type. */\nexport const RunRequest: z.ZodType<RunRequest> = z\n .object({\n viewId: ViewId.schema,\n fnId: z.string().min(3).max(1024),\n args: Batches,\n key: z.string().min(1).max(RUN_KEY_MAX).exactOptional(),\n clientKey: z.string().min(8).max(64),\n })\n .register(wireRegistry, {\n id: \"RunRequest\",\n description: \"Start or join an action run: the function, its arguments and keys.\",\n });\n\n/**\n * `POST …/runs/attach`: read runs and hear their changes on the event stream for the next minute\n * (re-attach after a reload, AC-02). By ID, or by function and key.\n */\nexport interface RunAttachRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** Runs by ID. */\n readonly runIds?: readonly string[];\n /** Runs by function and key. */\n readonly keyed?: readonly { readonly fnId: string; readonly key: string }[];\n /**\n * What the page already holds of runs it names by ID: so many log lines and batches. Each such\n * run's answer starts there (`RunState.logFrom`, `batchFrom`), so a page renewing its interest\n * doesn't read the whole run again (Opus review 14).\n */\n readonly held?: readonly {\n readonly runId: string;\n readonly log: number;\n readonly batches: number;\n }[];\n}\n\n/** The Zod schema of the `RunAttachRequest` type. */\nexport const RunAttachRequest: z.ZodType<RunAttachRequest> = z\n .object({\n viewId: ViewId.schema,\n runIds: z.array(z.string().max(64)).max(100).readonly().exactOptional(),\n keyed: z\n .array(\n z.object({ fnId: z.string().min(3).max(1024), key: z.string().min(1).max(RUN_KEY_MAX) }),\n )\n .max(100)\n .readonly()\n .exactOptional(),\n held: z\n .array(\n z.object({\n runId: z.string().max(64),\n log: z.number().int().nonnegative(),\n batches: z.number().int().nonnegative(),\n }),\n )\n .max(100)\n .readonly()\n .exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunAttachRequest\",\n description: \"Runs a page reads and follows: by ID, or by function and key.\",\n });\n\n/** `POST …/runs/{id}/cancel`. */\nexport interface RunCancelRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n}\n\n/** The Zod schema of the `RunCancelRequest` type. */\nexport const RunCancelRequest: z.ZodType<RunCancelRequest> = z\n .object({ viewId: ViewId.schema })\n .register(wireRegistry, { id: \"RunCancelRequest\", description: \"Cancel a run, from a view.\" });\n\n/** The keys of live sources: like JavaScript export names, which is what `live.ts` declares. */\nexport const LIVE_KEY_PATTERN: RegExp = /^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/;\n\n/**\n * The reserved live keys of tallies (D165 item 12, INTERFACES §18.4): `$tally/<field>` reads the\n * count by choice of a manifest `tally` entry. No producer or push writes one (their keys follow\n * {@link LIVE_KEY_PATTERN}); only a page reads them.\n */\nexport const TALLY_LIVE_PREFIX = \"$tally/\";\n\n/** The value of a tally's live key: the counts by choice, or only the total below `minTotal`. */\nexport interface TallyValue {\n /** Each listed choice's count, absent while fewer than `minTotal` answers were counted. */\n readonly counts?: Readonly<Record<string, number>>;\n /** How many answers were counted: answers, never people. */\n readonly total: number;\n}\n\n/** The keys a page may read: a source's ({@link LIVE_KEY_PATTERN}) or a tally's (`$tally/<field>`). */\nexport const READABLE_LIVE_KEY_PATTERN: RegExp =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what it refuses.\n /^(?:[A-Za-z_$][A-Za-z0-9_$]{0,127}$|\\$tally\\/[^\\u0000-\\u001f\\u007f]{1,256}$)/;\n\n/** The largest live value, in characters of serialized JSON (DATA_MODEL §5's 4 MiB). */\nexport const LIVE_VALUE_MAX: number = 4 * 1024 * 1024;\n\n/** The ring size of a pushed source in append mode that no `defineLive` sized. */\nexport const LIVE_RING_DEFAULT = 1024;\n\n/** The largest ring a source may keep. */\nexport const LIVE_RING_MAX = 100_000;\n\n/**\n * `POST …/live`: read live sources and keep their producers running for this view for the next\n * minute (D56, LL-04); a page asks again while it shows them.\n */\nexport interface LiveRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /**\n * The sources, each with its append window; `refresh` asks the source's producer to load again\n * now (`useLive`'s `refresh()`).\n */\n readonly keys: readonly {\n readonly key: string;\n readonly window?: number;\n readonly refresh?: boolean;\n }[];\n}\n\n/** The Zod schema of the `LiveRequest` type. */\nexport const LiveRequest: z.ZodType<LiveRequest> = z\n .object({\n viewId: ViewId.schema,\n keys: z\n .array(\n z.object({\n key: z.string().regex(READABLE_LIVE_KEY_PATTERN),\n window: z.int().min(1).max(LIVE_RING_MAX).exactOptional(),\n refresh: z.boolean().exactOptional(),\n }),\n )\n .max(256)\n .readonly(),\n })\n .register(wireRegistry, {\n id: \"LiveRequest\",\n description: \"Live sources a page reads and keeps running: keys and append windows.\",\n });\n\n/** Secret names: letters, digits, `_`, `.` and `-`, starting with a letter or `_` (D44). */\nexport const SECRET_NAME_PATTERN: RegExp = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;\n\n/** The largest secret value, in UTF-8 bytes. */\nexport const SECRET_VALUE_MAX: number = 64 * 1024;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,MAAa,UAA8B,EACxC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5D,SAAS,CAAC,CACV,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AASH,MAAa,cAAsC,EAChD,OAAO;CACN,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,OAAO,EAAE,OAAO,CAAC,CAAC,cAAc;AAClC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,kBAA0B;;AAGvC,MAAa,oBAA4B;;AAGzC,MAAa,cAAsB;;AAGnC,MAAa,oBAAoB;;AAGjC,MAAa,cAAc;;AAmB3B,MAAa,eAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,iBAAiB,QAA4B;CAC3D,OAAO,WAAW,eAAe,WAAW,YAAY,WAAW;AACrE;;AAmBA,MAAa,cAAsC,EAChD,OAAO;CACN,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;CACjD,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,GAA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,EAChD,OAAO;CACN,QAAQ,OAAO;CACf,MAAM,EACH,MACC,EAAE,OAAO;EACP,KAAK,EAAE,OAAO,CAAC,CAAC,MAAM,yBAAyB;EAC/C,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,cAAc;EACxD,SAAS,EAAE,QAAQ,CAAC,CAAC,cAAc;CACrC,CAAC,CACH,CAAC,CACA,IAAI,GAAG,CAAC,CACR,SAAS;AACd,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,sBAA8B;;AAG3C,MAAa,mBAA2B"}
|
|
1
|
+
{"version":3,"file":"actions.js","names":[],"sources":["../src/actions.ts"],"sourcesContent":["/**\n * Actions, live data and secrets (INTERFACES §2.4, §4, §6; D24, D44, D54, D56): the shapes the\n * browser protocol, the host protocol and the worker channel share. Server-function arguments and\n * results travel as the serializer's batches (`Batches`).\n *\n * ```ts\n * const run: RunState = await post(\"runs\", { viewId, fnId: \"actions.ts#sendReply\", args, clientKey });\n * if (run.status === \"succeeded\") show(await deserializeAll(run.batches));\n * ```\n */\nimport * as z from \"zod\";\nimport { ViewId } from \"./ids.ts\";\nimport type { Frame, WireError } from \"./serializer.ts\";\nimport type { PresenceState, RosterForPage } from \"./team.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** A value written by the serializer: its batches, in order (`serializeAll`). */\nexport type Batches = readonly (readonly Frame[])[];\n\n/**\n * The Zod schema of the `Batches` type: a list of batches, each a list of frames. The frames\n * themselves are checked by the reader (`ValueReader`), which refuses anything malformed.\n */\nexport const Batches: z.ZodType<Batches> = z\n .array(z.array(z.record(z.string(), z.unknown())).readonly())\n .readonly()\n .register(wireRegistry, {\n id: \"Batches\",\n description: \"A serialized server-function value: its batches of frames, in order.\",\n }) as unknown as z.ZodType<Batches>;\n\n/** An error as runs, calls and live sources report it. */\nexport interface ActionError extends WireError {\n /** The stack of the thrown error, kept in the run log and never sent to a page. */\n readonly stack?: string;\n}\n\n/** The Zod schema of the `ActionError` type. */\nexport const ActionError: z.ZodType<ActionError> = z\n .object({\n message: z.string(),\n code: z.string().exactOptional(),\n stack: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ActionError\",\n description: \"An error from server code: its message and diagnostic code.\",\n });\n\n/** The largest serialized arguments a call or run takes, in characters of JSON. */\nexport const ACTION_ARGS_MAX: number = 16 * 1024 * 1024;\n\n/** The largest serialized result a run keeps, in characters of JSON (larger fails the run). */\nexport const ACTION_RESULT_MAX: number = 16 * 1024 * 1024;\n\n/** The cap of a run's log, in UTF-16 code units of its lines (D47's 1 MB). */\nexport const RUN_LOG_MAX: number = 1024 * 1024;\n\n/** The line a capped log ends with. */\nexport const RUN_LOG_TRUNCATED = \"[log truncated at 1 MB]\";\n\n/** The longest run key, in characters. */\nexport const RUN_KEY_MAX = 256;\n\n/**\n * A run's state (D24, ARCHITECTURE §7). `queued`: recorded, not yet started in a worker.\n * `running`: started. `waiting`: a remote server's run that waits for its owner's instance (D165\n * item 4); a page that doesn't know it treats it like `queued`. `unknown`: a relayed run whose\n * owner never reported its end within the artifact's offline limit, which may have taken effect;\n * the owner's later report replaces it once. The others are final.\n */\nexport type RunStatus =\n | \"queued\"\n | \"running\"\n | \"waiting\"\n | \"succeeded\"\n | \"failed\"\n | \"cancelled\"\n | \"unknown\";\n\n/** Every run status. */\nexport const RUN_STATUSES: readonly RunStatus[] = [\n \"queued\",\n \"running\",\n \"waiting\",\n \"succeeded\",\n \"failed\",\n \"cancelled\",\n \"unknown\",\n];\n\n/** Whether a run in `status` has ended. */\nexport function isFinalRunStatus(status: RunStatus): boolean {\n return status === \"succeeded\" || status === \"failed\" || status === \"cancelled\";\n}\n\n/**\n * Why a run ended the way it did, beside its status: `interrupted` (its worker or the instance\n * stopped while it ran, D24), `threw` (the action threw), `unserializable` (its result is outside\n * the type set), `too-large`, `parked` (its artifact's worker keeps crashing), `cancelled` (by a\n * viewer), `unknown-function`. Later releases add reasons.\n */\nexport type RunReason = string;\n\n/** A run's progress, as the action last reported it. */\nexport interface RunProgress {\n /** From 0 to 1. */\n readonly fraction?: number;\n /** One short line for people. */\n readonly message?: string;\n}\n\n/** The Zod schema of the `RunProgress` type. */\nexport const RunProgress: z.ZodType<RunProgress> = z\n .object({\n fraction: z.number().min(0).max(1).exactOptional(),\n message: z.string().max(1000).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunProgress\",\n description: \"A run's progress: fraction and message.\",\n });\n\n/**\n * One action run as a page reads it (D54): its state, progress, log and the result written so far.\n * A result that is an async iterable grows item by item while the run is `running`.\n */\nexport interface RunState {\n /** The run's `run_` ID. */\n readonly runId: string;\n /** The server function it runs: `<module path>#<export>`. */\n readonly fnId: string;\n /** The idempotency key it was started with, if any. */\n readonly key?: string;\n /** The run's state. */\n readonly status: RunStatus;\n /** Why it ended, for `failed` and `cancelled`. */\n readonly reason?: RunReason;\n /** Its latest progress. */\n readonly progress?: RunProgress;\n /** The log lines, capped at 1 MB with a marker line. */\n readonly log: readonly string[];\n /** The result's batches so far. */\n readonly batches: Batches;\n /** For `failed`: what went wrong, without the stack. */\n readonly error?: WireError;\n /** When it was recorded. */\n readonly startedAt: string;\n /** When it ended. */\n readonly finishedAt?: string;\n /** Whether this request joined a run that already existed (a key or a retried `clientKey`). */\n readonly joined?: boolean;\n /**\n * The index of the first line in `log`, when the request said which lines the page holds\n * (`RunAttachRequest.held`); absent: 0, the whole log.\n */\n readonly logFrom?: number;\n /** The index of the first batch in `batches`, as `logFrom`; absent: 0. */\n readonly batchFrom?: number;\n /**\n * On a remote server: the run is `running` on its owner's instance, which can't be reached now\n * (D165 item 4); it ends when the owner reports, or becomes `unknown` past the offline limit.\n */\n readonly ownerUnreachable?: boolean;\n}\n\n/** The Zod schema of the `RunState` type. */\nexport const RunState: z.ZodType<RunState> = z\n .object({\n runId: z.string(),\n fnId: z.string(),\n key: z.string().exactOptional(),\n status: z.enum(RUN_STATUSES as [RunStatus, ...RunStatus[]]),\n reason: z.string().exactOptional(),\n progress: RunProgress.exactOptional(),\n log: z.array(z.string()).readonly(),\n batches: Batches,\n error: z.object({ message: z.string(), code: z.string().exactOptional() }).exactOptional(),\n startedAt: z.string(),\n finishedAt: z.string().exactOptional(),\n joined: z.boolean().exactOptional(),\n logFrom: z.number().int().nonnegative().exactOptional(),\n batchFrom: z.number().int().nonnegative().exactOptional(),\n ownerUnreachable: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunState\",\n description: \"An action run: status, progress, log and the result written so far.\",\n });\n\n/**\n * What changed in a run since a page last heard: a lossy notification on the event stream. Lines\n * start at `logFrom` and batches at `batchFrom`; a page that holds fewer reads the run again\n * (`runs/attach`).\n */\nexport interface RunDelta {\n /** The run's `run_` ID. */\n readonly runId: string;\n /** The run's state. */\n readonly status: RunStatus;\n /** Why it ended so, for `failed` and `cancelled`. */\n readonly reason?: RunReason;\n /** Its latest progress. */\n readonly progress?: RunProgress;\n /** The index of the first line in `log`. */\n readonly logFrom: number;\n /** Log lines, starting at `logFrom`. */\n readonly log: readonly string[];\n /** The index of the first batch in `batches`. */\n readonly batchFrom: number;\n /** Result batches, starting at `batchFrom`. */\n readonly batches: Batches;\n /** What went wrong. */\n readonly error?: WireError;\n /** When it ended. */\n readonly finishedAt?: string;\n}\n\n/** A live source's value as a page reads it (D56). */\nexport interface LiveState {\n /** The idempotency key it was started with, if any. */\n readonly key: string;\n /** The value's revision, a decimal string that only grows; absent before any value. */\n readonly revision?: string;\n /** When the value was produced. */\n readonly at?: string;\n /** The latest value, serialized. */\n readonly value?: Batches;\n /**\n * Append mode (`useLive(key, { mode: \"append\" })`): the values kept in the source's ring, oldest\n * first, at most the window the page asked for.\n */\n readonly ring?: readonly {\n readonly revision: string;\n readonly at: string;\n readonly value: Batches;\n }[];\n /** The producer's last failure, while the last good value stays (FAILURE_MODEL §6). */\n readonly error?: WireError;\n /**\n * `true` while the source has no value and no failure and the artifact's latest version has a\n * producer whose first `load` is on its way: the page shows it loading, and verify waits for it.\n * Absent for a key nothing produces (one only `mostra push` writes) and for a source that only\n * streams, whose first value may never come (WP-14's Opus review).\n */\n readonly awaiting?: boolean;\n /**\n * `true` on a hosted page while the artifact's owner instance is offline, so its producers\n * can't refresh the value: the last value stays, with its `at` (D165 item 4).\n */\n readonly ownerOffline?: boolean;\n}\n\n/** One live update on the event stream: never stored as an event (D63, LL-04). */\nexport interface LiveUpdate {\n /** The live source's key. */\n readonly key: string;\n /** The value's revision. */\n readonly revision?: string;\n /** When the value was produced. */\n readonly at?: string;\n /** The value, serialized. */\n readonly value?: Batches;\n /** What went wrong. */\n readonly error?: WireError;\n /**\n * `false` when a source read as {@link LiveState.awaiting} turned out to have no first `load`\n * (its producer only streams): the page stops waiting for a first value.\n */\n readonly awaiting?: boolean;\n}\n\n/**\n * An ephemeral message on a page's event stream (SSE `event: run`, `live`, `respondents` or\n * `presence`, without an `id`, so a reconnect's cursor is untouched) or in a poll's `ephemeral`:\n * lossy, coalesced, and never stored as an event. `respondents` and `presence` (D168) reach only a\n * page that asked for them, so a version built before them never receives one.\n */\nexport type EphemeralMessage =\n | { readonly kind: \"run\"; readonly run: RunDelta }\n | { readonly kind: \"live\"; readonly live: LiveUpdate }\n | { readonly kind: \"respondents\"; readonly respondents: RosterForPage }\n | { readonly kind: \"presence\"; readonly presence: PresenceState };\n\n/** `POST …/call/{fnId}`: a plain server-function call, no durable record (D54). */\nexport interface CallRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The arguments, serialized as one array value. */\n readonly args: Batches;\n}\n\n/** The Zod schema of the `CallRequest` type. */\nexport const CallRequest: z.ZodType<CallRequest> = z\n .object({ viewId: ViewId.schema, args: Batches })\n .register(wireRegistry, {\n id: \"CallRequest\",\n description: \"A plain server-function call: the view and the serialized arguments.\",\n });\n\n/**\n * One line of a plain call's answer (`application/x-ndjson`): a batch of the result, then the end.\n */\nexport type CallLine =\n | { readonly batch: readonly Frame[] }\n | { readonly end: { readonly status: \"succeeded\" } }\n | { readonly end: { readonly status: \"failed\"; readonly error: WireError } };\n\n/** `POST …/runs`: start a durable action run, or join one (D54, AC-02, AC-03). */\nexport interface RunRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** `<module path>#<export>`. */\n readonly fnId: string;\n /** The arguments, serialized as one array value. */\n readonly args: Batches;\n /** The author's idempotency key: one run per artifact, function and key, ever. */\n readonly key?: string;\n /** A fresh ID per invocation, so a retried request joins the run it already started. */\n readonly clientKey: string;\n}\n\n/** The Zod schema of the `RunRequest` type. */\nexport const RunRequest: z.ZodType<RunRequest> = z\n .object({\n viewId: ViewId.schema,\n fnId: z.string().min(3).max(1024),\n args: Batches,\n key: z.string().min(1).max(RUN_KEY_MAX).exactOptional(),\n clientKey: z.string().min(8).max(64),\n })\n .register(wireRegistry, {\n id: \"RunRequest\",\n description: \"Start or join an action run: the function, its arguments and keys.\",\n });\n\n/**\n * `POST …/runs/attach`: read runs and hear their changes on the event stream for the next minute\n * (re-attach after a reload, AC-02). By ID, or by function and key.\n */\nexport interface RunAttachRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** Runs by ID. */\n readonly runIds?: readonly string[];\n /** Runs by function and key. */\n readonly keyed?: readonly { readonly fnId: string; readonly key: string }[];\n /**\n * What the page already holds of runs it names by ID: so many log lines and batches. Each such\n * run's answer starts there (`RunState.logFrom`, `batchFrom`), so a page renewing its interest\n * doesn't read the whole run again (Opus review 14).\n */\n readonly held?: readonly {\n readonly runId: string;\n readonly log: number;\n readonly batches: number;\n }[];\n}\n\n/** The Zod schema of the `RunAttachRequest` type. */\nexport const RunAttachRequest: z.ZodType<RunAttachRequest> = z\n .object({\n viewId: ViewId.schema,\n runIds: z.array(z.string().max(64)).max(100).readonly().exactOptional(),\n keyed: z\n .array(\n z.object({ fnId: z.string().min(3).max(1024), key: z.string().min(1).max(RUN_KEY_MAX) }),\n )\n .max(100)\n .readonly()\n .exactOptional(),\n held: z\n .array(\n z.object({\n runId: z.string().max(64),\n log: z.number().int().nonnegative(),\n batches: z.number().int().nonnegative(),\n }),\n )\n .max(100)\n .readonly()\n .exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunAttachRequest\",\n description: \"Runs a page reads and follows: by ID, or by function and key.\",\n });\n\n/** `POST …/runs/{id}/cancel`. */\nexport interface RunCancelRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n}\n\n/** The Zod schema of the `RunCancelRequest` type. */\nexport const RunCancelRequest: z.ZodType<RunCancelRequest> = z\n .object({ viewId: ViewId.schema })\n .register(wireRegistry, { id: \"RunCancelRequest\", description: \"Cancel a run, from a view.\" });\n\n/** The keys of live sources: like JavaScript export names, which is what `live.ts` declares. */\nexport const LIVE_KEY_PATTERN: RegExp = /^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/;\n\n/**\n * The reserved live keys of tallies (D165 item 12, INTERFACES §18.4): `$tally/<field>` reads the\n * count by choice of a manifest `tally` entry. No producer or push writes one (their keys follow\n * {@link LIVE_KEY_PATTERN}); only a page reads them.\n */\nexport const TALLY_LIVE_PREFIX = \"$tally/\";\n\n/** The value of a tally's live key: the counts by choice, or only the total below `minTotal`. */\nexport interface TallyValue {\n /** Each listed choice's count, absent while fewer than `minTotal` answers were counted. */\n readonly counts?: Readonly<Record<string, number>>;\n /** How many answers were counted: answers, never people. */\n readonly total: number;\n}\n\n/** The keys a page may read: a source's ({@link LIVE_KEY_PATTERN}) or a tally's (`$tally/<field>`). */\nexport const READABLE_LIVE_KEY_PATTERN: RegExp =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what it refuses.\n /^(?:[A-Za-z_$][A-Za-z0-9_$]{0,127}$|\\$tally\\/[^\\u0000-\\u001f\\u007f]{1,256}$)/;\n\n/** The largest live value, in characters of serialized JSON (DATA_MODEL §5's 4 MiB). */\nexport const LIVE_VALUE_MAX: number = 4 * 1024 * 1024;\n\n/** The ring size of a pushed source in append mode that no `defineLive` sized. */\nexport const LIVE_RING_DEFAULT = 1024;\n\n/** The largest ring a source may keep. */\nexport const LIVE_RING_MAX = 100_000;\n\n/**\n * `POST …/live`: read live sources and keep their producers running for this view for the next\n * minute (D56, LL-04); a page asks again while it shows them.\n */\nexport interface LiveRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /**\n * The sources, each with its append window; `refresh` asks the source's producer to load again\n * now (`useLive`'s `refresh()`).\n */\n readonly keys: readonly {\n readonly key: string;\n readonly window?: number;\n readonly refresh?: boolean;\n }[];\n}\n\n/** The Zod schema of the `LiveRequest` type. */\nexport const LiveRequest: z.ZodType<LiveRequest> = z\n .object({\n viewId: ViewId.schema,\n keys: z\n .array(\n z.object({\n key: z.string().regex(READABLE_LIVE_KEY_PATTERN),\n window: z.int().min(1).max(LIVE_RING_MAX).exactOptional(),\n refresh: z.boolean().exactOptional(),\n }),\n )\n .max(256)\n .readonly(),\n })\n .register(wireRegistry, {\n id: \"LiveRequest\",\n description: \"Live sources a page reads and keeps running: keys and append windows.\",\n });\n\n/** Secret names: letters, digits, `_`, `.` and `-`, starting with a letter or `_` (D44). */\nexport const SECRET_NAME_PATTERN: RegExp = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;\n\n/** The largest secret value, in UTF-8 bytes. */\nexport const SECRET_VALUE_MAX: number = 64 * 1024;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,MAAa,UAA8B,EACxC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5D,SAAS,CAAC,CACV,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AASH,MAAa,cAAsC,EAChD,OAAO;CACN,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,OAAO,EAAE,OAAO,CAAC,CAAC,cAAc;AAClC,CAAC,CAAC,CACD,SAAS,cAAc;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AAI,CAAC,CAAC,YAAY;CACxC,CAAC,CACH,CAAC,CACA,IAAI,GAAG,CAAC,CACR,SAAS,CAAC,CACV,cAAc;AACnB,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AASH,MAAa,mBAAgD,EAC1D,OAAO,EAAE,QAAQ,OAAO,OAAO,CAAC,CAAC,CACjC,SAAS,cAAc;CAAE,IAAI;CAAoB,aAAa;AAA6B,CAAC;;AAG/F,MAAa,mBAA2B;;;;;;AAOxC,MAAa,oBAAoB;;AAWjC,MAAa,4BAEX;;AAGF,MAAa,iBAAyB;;AAGtC,MAAa,oBAAoB;;AAGjC,MAAa,gBAAgB;;AAqB7B,MAAa,cAAsC,EAChD,OAAO;CACN,QAAQ,OAAO;CACf,MAAM,EACH,MACC,EAAE,OAAO;EACP,KAAK,EAAE,OAAO,CAAC,CAAC,MAAM,yBAAyB;EAC/C,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,cAAc;EACxD,SAAS,EAAE,QAAQ,CAAC,CAAC,cAAc;CACrC,CAAC,CACH,CAAC,CACA,IAAI,GAAG,CAAC,CACR,SAAS;AACd,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,sBAA8B;;AAG3C,MAAa,mBAA2B"}
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EphemeralMessage } from "./actions.js";
|
|
2
1
|
import { DeliveryTarget, REVIEW_SET_ID_PATTERN, VersionRef, ViewContext, ViewContextWire, readViewContext } from "./view.js";
|
|
3
2
|
import { DocumentRevision, EventRecord, FieldOp, FieldState, SubmissionSummary, Viewer } from "./interaction.js";
|
|
3
|
+
import { EphemeralMessage } from "./actions.js";
|
|
4
4
|
import * as z from "zod";
|
|
5
5
|
//#region src/browser.d.ts
|
|
6
6
|
/** Every browser-protocol revision this release serves, oldest first. */
|
|
@@ -126,6 +126,48 @@ export interface FrameTicket extends ViewContext {
|
|
|
126
126
|
* (D70, D158 item 5). Absent: cookie mode.
|
|
127
127
|
*/
|
|
128
128
|
readonly mode?: "worker";
|
|
129
|
+
/**
|
|
130
|
+
* The artifact is paused (D165 item 14): the shell says so, by whom and why (the reason as text);
|
|
131
|
+
* it takes no submissions and runs no actions until it is resumed (WP-30).
|
|
132
|
+
*/
|
|
133
|
+
readonly paused?: {
|
|
134
|
+
readonly by: "owner" | "operator";
|
|
135
|
+
readonly reason?: string;
|
|
136
|
+
};
|
|
137
|
+
/** On a remote server: what the hosted shell's trusted chrome shows around the page (D161). */
|
|
138
|
+
readonly hosted?: HostedChrome;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The hosted shell's trusted chrome for one view (D161, ARCHITECTURE §15.8; WP-30). Every string an
|
|
142
|
+
* owner or operator supplies is rendered as text, never as markup.
|
|
143
|
+
*/
|
|
144
|
+
export interface HostedChrome {
|
|
145
|
+
/** Who sent the page: the owner's display name, and the provider that verified it, if any. */
|
|
146
|
+
readonly sender?: {
|
|
147
|
+
readonly name: string;
|
|
148
|
+
readonly verifiedBy?: string;
|
|
149
|
+
};
|
|
150
|
+
/** Who this browser is to the page: signed in as an account, or anonymous (with a chosen name). */
|
|
151
|
+
readonly viewer: {
|
|
152
|
+
readonly kind: "account" | "anonymous" | "named";
|
|
153
|
+
readonly name?: string;
|
|
154
|
+
readonly verified: boolean;
|
|
155
|
+
};
|
|
156
|
+
/** Whether "Sign in" is offered (the viewer isn't signed in, and the server has a provider). */
|
|
157
|
+
readonly signIn: boolean;
|
|
158
|
+
/** The operator's footer wording in place of the shell's own; never hidden on a public link. */
|
|
159
|
+
readonly footer?: string;
|
|
160
|
+
/** The operator's line after "Your answer was sent.". */
|
|
161
|
+
readonly afterSubmit?: string;
|
|
162
|
+
/** The made-with mark, where the operator shows one. */
|
|
163
|
+
readonly madeWith?: {
|
|
164
|
+
readonly href?: string;
|
|
165
|
+
};
|
|
166
|
+
/** A page shown before the artifact, once per browser and link. */
|
|
167
|
+
readonly interstitial?: {
|
|
168
|
+
readonly kind: string;
|
|
169
|
+
readonly message?: string;
|
|
170
|
+
};
|
|
129
171
|
}
|
|
130
172
|
/** The Zod schema of the `FrameTicket` type. */
|
|
131
173
|
export declare const FrameTicket: z.ZodType<FrameTicket>;
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","names":[],"sources":["../src/browser.ts"],"mappings":";;;;;;qBA0Ca;;qBAGA;;qBAGA;;iBAGI;;WAEN;;WAEA;;WAEA,cAAc;;WAEd;;WAEA,cAAc;;;qBAIZ,eAAe,EAAE,QAAQ;;iBAcrB;;WAEN;;WAEA,kBAAkB;;WAElB;;;qBAIE,eAAe,EAAE,QAAQ;;iBAYrB;;WAEN;;WAEA;;WAEA;;;qBAIE,eAAe,EAAE,QAAQ;;iBAYrB;;WAEN,UAAU;;WAEV;;WAEA,QAAQ,SAAS,eAAe;;;qBAI9B,kBAAkB,EAAE,QAAQ;;;;;iBAexB;;WAEN;;WAEA,QAAQ;;WAER,OAAO;;WAEP,OAAO;;WAEP,aAAa;;;;;;WAMb,SAAS;;;qBAIP,gBAAgB,EAAE,QAAQ;;iBAetB;;WAEN;;WAEA,iBAAiB;;WAEjB,WAAW;;;;;WAKX,qBAAqB;;;qBAInB,YAAY,EAAE,QAAQ;;;;;iBAgBlB,oBAAoB;;WAE1B;;WAEA;;WAEA;;WAEA;;;;;WAKA;;;;;WAKA;;;;;;WAMA;;;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","names":[],"sources":["../src/browser.ts"],"mappings":";;;;;;qBA0Ca;;qBAGA;;qBAGA;;iBAGI;;WAEN;;WAEA;;WAEA,cAAc;;WAEd;;WAEA,cAAc;;;qBAIZ,eAAe,EAAE,QAAQ;;iBAcrB;;WAEN;;WAEA,kBAAkB;;WAElB;;;qBAIE,e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;WAEN;;WAEA;;WAEA;;WAEA;;;qBAIE,eAAe,EAAE,QAAQ;;;;;;iBAiBrB;;WAEN,SAAS;;WAET,kBAAkB;;;qBAIhB,WAAW,EAAE,QAAQ"}
|
package/dist/browser.js
CHANGED
|
@@ -82,6 +82,29 @@ const PollResult = z.object({
|
|
|
82
82
|
id: "PollResult",
|
|
83
83
|
description: "A long-poll answer: the cursor, the events after the asked one, and a snapshot."
|
|
84
84
|
});
|
|
85
|
+
const HostedChrome = z.object({
|
|
86
|
+
sender: z.object({
|
|
87
|
+
name: z.string().max(256),
|
|
88
|
+
verifiedBy: z.string().max(64).exactOptional()
|
|
89
|
+
}).exactOptional(),
|
|
90
|
+
viewer: z.object({
|
|
91
|
+
kind: z.enum([
|
|
92
|
+
"account",
|
|
93
|
+
"anonymous",
|
|
94
|
+
"named"
|
|
95
|
+
]),
|
|
96
|
+
name: z.string().max(256).exactOptional(),
|
|
97
|
+
verified: z.boolean()
|
|
98
|
+
}),
|
|
99
|
+
signIn: z.boolean(),
|
|
100
|
+
footer: z.string().max(500).exactOptional(),
|
|
101
|
+
afterSubmit: z.string().max(500).exactOptional(),
|
|
102
|
+
madeWith: z.object({ href: z.url({ protocol: /^https$/ }).max(2048).exactOptional() }).exactOptional(),
|
|
103
|
+
interstitial: z.object({
|
|
104
|
+
kind: z.string().max(64),
|
|
105
|
+
message: z.string().max(2e3).exactOptional()
|
|
106
|
+
}).exactOptional()
|
|
107
|
+
});
|
|
85
108
|
/** The Zod schema of the `FrameTicket` type. */
|
|
86
109
|
const FrameTicket = z.object({
|
|
87
110
|
artifactId: ArtifactId.schema,
|
|
@@ -103,7 +126,12 @@ const FrameTicket = z.object({
|
|
|
103
126
|
pinned: z.boolean(),
|
|
104
127
|
serverParked: z.literal(true).exactOptional(),
|
|
105
128
|
devPreview: z.literal(true).exactOptional(),
|
|
106
|
-
mode: z.literal("worker").exactOptional()
|
|
129
|
+
mode: z.literal("worker").exactOptional(),
|
|
130
|
+
paused: z.object({
|
|
131
|
+
by: z.enum(["owner", "operator"]),
|
|
132
|
+
reason: z.string().max(500).exactOptional()
|
|
133
|
+
}).exactOptional(),
|
|
134
|
+
hosted: HostedChrome.exactOptional()
|
|
107
135
|
}).register(wireRegistry, {
|
|
108
136
|
id: "FrameTicket",
|
|
109
137
|
description: "A frame ticket: the view it opens, where to load it, and the view's controls."
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * The browser protocol (INTERFACES §4, D106): what the client runtime in an artifact's frame sends\n * to the gateway and receives from it. Published versions embed the client runtime, so a gateway\n * serves every revision it ever shipped (FAILURE_MODEL §7); within a revision payloads only grow.\n * Paths are `/_mostra/v/{revision}/…` on the artifact's origin.\n *\n * ```ts\n * const body: FieldsRequest = { mutationId, scope: \"viewer\", baseRevision: \"3\", viewId, ops };\n * await fetch(`/_mostra/v/${BROWSER_PROTOCOL_REVISION}/fields`, { method: \"POST\", body: … });\n * ```\n */\nimport * as z from \"zod\";\nimport type { EphemeralMessage } from \"./actions.ts\";\nimport { ArtifactId, Cursor, MutationId, ViewId } from \"./ids.ts\";\nimport {\n DocumentRevision,\n EventRecord,\n FieldOp,\n FieldState,\n SubmissionSummary,\n Viewer,\n} from \"./interaction.ts\";\nimport { SubmissionPolicy } from \"./manifest.ts\";\nimport {\n REVIEW_SET_ID_PATTERN,\n SubmitChannel,\n TrustedControl,\n VersionRef,\n type ViewContext,\n} from \"./view.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\nexport {\n type DeliveryTarget,\n REVIEW_SET_ID_PATTERN,\n readViewContext,\n VersionRef,\n ViewContext,\n ViewContextWire,\n} from \"./view.ts\";\n\n/** Every browser-protocol revision this release serves, oldest first. */\nexport const BROWSER_PROTOCOL_REVISIONS: readonly [\"2026-10-15\"] = [\"2026-10-15\"];\n\n/** The newest browser-protocol revision: what a client runtime built now speaks. */\nexport const BROWSER_PROTOCOL_REVISION = \"2026-10-15\";\n\n/** The longest JSON a signal's payload may be, in UTF-8 bytes (D106). */\nexport const SIGNAL_PAYLOAD_MAX_BYTES: number = 64 * 1024;\n\n/** `POST …/fields`: one mutation of the viewer's draft or the artifact's state. */\nexport interface FieldsRequest {\n /** A fresh `mut_` ID per change; a retry repeats it and gets the recorded result. */\n readonly mutationId: string;\n /** Which document: the viewer's draft or the artifact's shared state. */\n readonly scope: \"viewer\" | \"artifact\";\n /** The document revision the page last saw; fields changed after it come back as conflicts. */\n readonly baseRevision: DocumentRevision;\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The field changes, applied together under one revision. */\n readonly ops: readonly FieldOp[];\n}\n\n/** The Zod schema of the `FieldsRequest` type. */\nexport const FieldsRequest: z.ZodType<FieldsRequest> = z\n .object({\n mutationId: MutationId.schema,\n scope: z.enum([\"viewer\", \"artifact\"]),\n baseRevision: DocumentRevision,\n viewId: ViewId.schema,\n ops: z.array(FieldOp).min(1).max(1000).readonly(),\n })\n .register(wireRegistry, {\n id: \"FieldsRequest\",\n description: \"A browser mutation: its ID, scope, base revision, view and field ops.\",\n });\n\n/** `POST …/submit`: submit the viewer's draft from the artifact's own code (D40). */\nexport interface SubmitRequest {\n /** The view the page was opened as (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw; another one is `MOSTRA_SUBMIT_REVISION_MOVED`. */\n readonly expectedRevision: DocumentRevision;\n /** Always `artifact` on this route; the shell's trusted Submit is the `shell` channel (D40). */\n readonly channel: \"artifact\";\n}\n\n/** The Zod schema of the `SubmitRequest` type. */\nexport const SubmitRequest: z.ZodType<SubmitRequest> = z\n .object({\n viewId: ViewId.schema,\n expectedRevision: DocumentRevision,\n channel: z.literal(\"artifact\"),\n })\n .register(wireRegistry, {\n id: \"SubmitRequest\",\n description: \"A browser submit: the view and the draft revision the viewer saw.\",\n });\n\n/** `POST …/signal`: raise a named signal for the host's attention (IN-09). */\nexport interface SignalRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** Letters, digits, `.`, `_` and `-`; `submit` is reserved. */\n readonly name: string;\n /** Any JSON, at most 64 KiB. */\n readonly payload?: unknown;\n}\n\n/** The Zod schema of the `SignalRequest` type. */\nexport const SignalRequest: z.ZodType<SignalRequest> = z\n .object({\n viewId: ViewId.schema,\n name: z.string().min(1).max(64),\n payload: z.unknown().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"SignalRequest\",\n description: \"A browser signal: the view, the signal's name and an optional JSON payload.\",\n }) as z.ZodType<SignalRequest>;\n\n/** A document as the page loads it: its revision and fields. */\nexport interface DocumentSnapshot {\n /** The document's revision. */\n readonly revision: DocumentRevision;\n /** The draft's epoch (D103); 1 for artifact state. */\n readonly epoch: number;\n /** Every field by ID. */\n readonly fields: Readonly<Record<string, FieldState>>;\n}\n\n/** The Zod schema of the `DocumentSnapshot` type. */\nexport const DocumentSnapshot: z.ZodType<DocumentSnapshot> = z\n .object({\n revision: DocumentRevision,\n epoch: z.int().min(1),\n fields: z.record(z.string(), FieldState),\n })\n .register(wireRegistry, {\n id: \"DocumentSnapshot\",\n description: \"A document's revision, epoch and fields, as a page loads it.\",\n });\n\n/**\n * The first message of a browser event stream, and a poll's `snapshot`: where the page stands,\n * so it renders the canonical draft and state before applying events after `cursor`.\n */\nexport interface StreamSnapshot {\n /** Events after this cursor follow. */\n readonly cursor: string;\n /** Who the page acts as. */\n readonly viewer: Viewer;\n /** The viewer's draft. */\n readonly draft: DocumentSnapshot;\n /** The artifact's shared state. */\n readonly state: DocumentSnapshot;\n /** The submission that closed this draft, or this viewer's latest under `epochs`. */\n readonly submission?: SubmissionSummary;\n /**\n * The artifact's latest version when the snapshot was read (WP-07): a reader that missed its\n * `version.published` event (published between a frame ticket and the stream, or compacted)\n * still learns of it.\n */\n readonly latest?: VersionRef;\n}\n\n/** The Zod schema of the `StreamSnapshot` type. */\nexport const StreamSnapshot: z.ZodType<StreamSnapshot> = z\n .object({\n cursor: Cursor.schema,\n viewer: Viewer,\n draft: DocumentSnapshot,\n state: DocumentSnapshot,\n submission: SubmissionSummary.exactOptional(),\n latest: VersionRef.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"StreamSnapshot\",\n description: \"Where a page stands: cursor, viewer, draft, artifact state and its submission.\",\n });\n\n/** `GET …/events/poll`: the long-poll answer on the same cursor as the stream (D47). */\nexport interface PollResult {\n /** Where the next poll continues. */\n readonly cursor: string;\n /** The events for this page after the cursor asked for, in order. */\n readonly events: readonly EventRecord[];\n /** Present when the poll asked for none or its cursor was compacted away. */\n readonly snapshot?: StreamSnapshot;\n /**\n * Run and live updates for this view since its last poll (WP-08): lossy and never stored as\n * events, the long-poll's counterpart of the stream's `run` and `live` messages.\n */\n readonly ephemeral?: readonly EphemeralMessage[];\n}\n\n/** The Zod schema of the `PollResult` type. */\nexport const PollResult: z.ZodType<PollResult> = z\n .object({\n cursor: Cursor.schema,\n events: z.array(EventRecord).readonly(),\n snapshot: StreamSnapshot.exactOptional(),\n ephemeral: z.array(z.record(z.string(), z.unknown())).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PollResult\",\n description: \"A long-poll answer: the cursor, the events after the asked one, and a snapshot.\",\n }) as unknown as z.ZodType<PollResult>;\n\n/**\n * `POST /a/{artifactId}/_mostra/ticket`'s answer on the shell origin: a single-use frame ticket,\n * the view it opens and what the shell needs to render the view's trusted controls (D104, D108).\n */\nexport interface FrameTicket extends ViewContext {\n /** The frame's entry URL, carrying the single-use ticket. */\n readonly src: string;\n /** The artifact's origin: the only origin the bridge accepts messages from. */\n readonly artifactOrigin: string;\n /** Whether this viewer follows the artifact's new versions (D63). */\n readonly follow: boolean;\n /** Whether the link opens this version only (D97 item 9): then the shell offers no newer one. */\n readonly pinned: boolean;\n /**\n * The version's server code keeps crashing and is parked (WP-08, FAILURE_MODEL §2): the shell\n * says so, since the page's actions and live data won't work until a new publish.\n */\n readonly serverParked?: true;\n /**\n * The frame shows `mostra dev`'s development preview of unpublished source (D140 item 12): the\n * shell says so, and it is never a published version.\n */\n readonly devPreview?: true;\n /**\n * `worker` when the shell and the artifact are two sites (a Cloudflare quick tunnel, a host's\n * addresses on two hosts): the frame enters through the bootstrap page and a service worker\n * (D70, D158 item 5). Absent: cookie mode.\n */\n readonly mode?: \"worker\";\n}\n\n/** The Zod schema of the `FrameTicket` type. */\nexport const FrameTicket: z.ZodType<FrameTicket> = z\n .object({\n artifactId: ArtifactId.schema,\n viewId: ViewId.schema,\n version: VersionRef,\n latest: VersionRef,\n policy: SubmissionPolicy,\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),\n controls: z.array(TrustedControl).max(32).readonly(),\n target: z.enum([\"live\", \"static\", \"mcp-app\", \"verify\"]),\n src: z.string().min(1),\n artifactOrigin: z.string().min(1),\n follow: z.boolean(),\n pinned: z.boolean(),\n serverParked: z.literal(true).exactOptional(),\n devPreview: z.literal(true).exactOptional(),\n mode: z.literal(\"worker\").exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FrameTicket\",\n description: \"A frame ticket: the view it opens, where to load it, and the view's controls.\",\n });\n\n// ── Frame sessions in worker mode (WP-13, D70, D158 item 5) ───────────────────────────────\n\n/**\n * The header Mostra's service worker adds to every same-origin request of a worker-mode frame:\n * its frame session's secret, which no cookie can carry across sites.\n */\nexport const FRAME_SESSION_HEADER = \"x-mostra-frame\";\n\n/**\n * The header a hosted shell sends its session's secret in (INTERFACES §18.4, D165 item 8): no\n * cookie is ever set or read on a hosted host, so no tenant page can toss, shadow or crowd one out.\n */\nexport const SHELL_SESSION_HEADER = \"x-mostra-shell\";\n\n/**\n * `POST /_mostra/enter` on the artifact's origin: the bootstrap page exchanges the shell's\n * single-use frame ticket, from `/_mostra/enter#t=…`, for a worker-mode frame session.\n */\nexport interface EnterRequest {\n /** The frame ticket. */\n readonly ticket: string;\n}\n\n/** The Zod schema of the `EnterRequest` type. */\nexport const EnterRequest: z.ZodType<EnterRequest> = z\n .object({ ticket: z.string().min(1).max(64) })\n .register(wireRegistry, { id: \"EnterRequest\", description: \"A frame ticket to exchange.\" });\n\n/** The answer to `EnterRequest`. */\nexport interface EnterResult {\n /** The frame session's secret, which the service worker sends as `X-Mostra-Frame`. */\n readonly session: string;\n /** The shell's origin: the only page the bootstrap reports to. */\n readonly shellOrigin: string;\n}\n\n/** The Zod schema of the `EnterResult` type. */\nexport const EnterResult: z.ZodType<EnterResult> = z\n .object({ session: z.string().min(1), shellOrigin: z.string().min(1) })\n .register(wireRegistry, {\n id: \"EnterResult\",\n description: \"A worker-mode frame session's secret and the shell's origin.\",\n });\n\n/**\n * `POST /_mostra/v/{rev}/ticket`: a single-use ticket that opens one event stream, long poll or\n * WebSocket of this session without it (`?ticket=`), so the request can bypass the service\n * worker (VERIFIED_FACTS: Firefox stalls on endless responses a worker passes on).\n */\nexport interface StreamTicketRequest {\n /** What it opens: `stream` (events and polls, the default) or `socket` (a WebSocket). */\n readonly purpose?: \"stream\" | \"socket\";\n}\n\n/** The Zod schema of the `StreamTicketRequest` type. */\nexport const StreamTicketRequest: z.ZodType<StreamTicketRequest> = z\n .object({ purpose: z.enum([\"stream\", \"socket\"]).exactOptional() })\n .register(wireRegistry, { id: \"StreamTicketRequest\" });\n\n/** The answer to a `StreamTicketRequest`. */\nexport interface StreamTicket {\n /** The ticket: 130 bits, single-use. */\n readonly ticket: string;\n /** When it stops working, 60 s after it was minted. */\n readonly expiresAt: string;\n}\n\n/** The Zod schema of the `StreamTicket` type. */\nexport const StreamTicket: z.ZodType<StreamTicket> = z\n .object({ ticket: z.string().min(1), expiresAt: z.iso.datetime() })\n .register(wireRegistry, {\n id: \"StreamTicket\",\n description: \"A single-use ticket for one stream, poll or WebSocket.\",\n });\n\n/**\n * `GET /_mostra/session` on the artifact's origin: the frame session's facts for same-origin code.\n */\nexport interface FrameSessionFacts {\n /** The CSRF token every mutation sends as `X-Mostra-CSRF`. */\n readonly csrf: string;\n /** The artifact the frame shows. */\n readonly artifactId: string;\n /** The shell's exact origin: the bridge's only peer. */\n readonly shellOrigin: string;\n /** The link's scopes. */\n readonly scopes: readonly string[];\n /** The viewer the page acts as (WP-07). */\n readonly viewer?: Viewer;\n /** The version the frame session entered. */\n readonly version?: VersionRef;\n /** How the frame authenticates (D70): absent means `cookie`. */\n readonly mode?: \"cookie\" | \"worker\";\n /**\n * `false` where event streams don't pass (a Cloudflare quick tunnel holds responses back until\n * they end): the page long-polls from the start (D47). Absent means streams pass.\n */\n readonly streams?: boolean;\n}\n\n/** The Zod schema of the `FrameSessionFacts` type. */\nexport const FrameSessionFacts: z.ZodType<FrameSessionFacts> = z\n .object({\n csrf: z.string().min(1),\n artifactId: ArtifactId.schema,\n shellOrigin: z.string().min(1),\n scopes: z.array(z.string()).readonly(),\n viewer: Viewer.exactOptional(),\n version: VersionRef.exactOptional(),\n mode: z.enum([\"cookie\", \"worker\"]).exactOptional(),\n streams: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FrameSessionFacts\",\n description: \"A frame session's CSRF token, shell origin, scopes, viewer, version and mode.\",\n });\n\n// ── The shell's own routes (WP-07, on the shell origin) ──────────────────────────────────\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/submit`: the shell's trusted Submit (the `shell` channel,\n * D40). Only the shell's page can send it: the route takes the shell's session, its exact origin\n * and its CSRF token, none of which an artifact's page has.\n */\nexport interface ShellSubmitRequest {\n /** The view the shell's frame shows (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw, after the frame flushed its saves. */\n readonly expectedRevision: DocumentRevision;\n}\n\n/** The Zod schema of the `ShellSubmitRequest` type. */\nexport const ShellSubmitRequest: z.ZodType<ShellSubmitRequest> = z\n .object({ viewId: ViewId.schema, expectedRevision: DocumentRevision })\n .register(wireRegistry, {\n id: \"ShellSubmitRequest\",\n description: \"The shell's trusted Submit: the view and the draft revision the viewer saw.\",\n });\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/review/choose`: the shell's trusted Choose (D65, D113).\n * It writes the viewer's draft field `review.<reviewSetId>.choice` like any mutation, so a stale\n * base revision comes back as a conflict.\n */\nexport interface ChooseRequest {\n /** The view the shell's frame shows. */\n readonly viewId: string;\n /** A fresh `mut_` ID; a retry repeats it. */\n readonly mutationId: string;\n /** The draft revision the shell last saw. */\n readonly baseRevision: DocumentRevision;\n /** The review set. */\n readonly reviewSetId: string;\n /** The chosen candidate's ID. */\n readonly candidateId: string;\n /** The candidate's label, kept with the choice for results. */\n readonly label?: string;\n}\n\n/** The Zod schema of the `ChooseRequest` type. */\nexport const ChooseRequest: z.ZodType<ChooseRequest> = z\n .object({\n viewId: ViewId.schema,\n mutationId: MutationId.schema,\n baseRevision: DocumentRevision,\n reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN),\n candidateId: z.string().min(1).max(256),\n label: z.string().max(256).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ChooseRequest\",\n description:\n \"The shell's trusted Choose: the view, mutation, base revision, set and candidate.\",\n });\n\n/** `POST /a/{artifactId}/_mostra/v/{rev}/follow`: the viewer's \"Always follow this artifact\" (D63). */\nexport interface FollowRequest {\n /** `true` to load new versions automatically, `false` to stop. */\n readonly follow: boolean;\n}\n\n/** The Zod schema of the `FollowRequest` type. */\nexport const FollowRequest: z.ZodType<FollowRequest> = z\n .object({ follow: z.boolean() })\n .register(wireRegistry, {\n id: \"FollowRequest\",\n description: \"Whether the viewer follows the artifact's new versions.\",\n });\n\n/** A draft field a version doesn't cover (D42, D109): kept, shown read-only and delivered. */\nexport interface OrphanedField {\n /** The field's ID. */\n readonly id: string;\n /** Its label, when it has one. */\n readonly label?: string;\n /** Its value. */\n readonly value: unknown;\n /** The version whose view last wrote it. */\n readonly fromVersion: number;\n}\n\n/** The Zod schema of the `OrphanedField` type. */\nexport const OrphanedField: z.ZodType<OrphanedField> = z\n .object({\n id: z.string(),\n label: z.string().exactOptional(),\n value: z.unknown(),\n fromVersion: z.int().min(1),\n })\n .register(wireRegistry, {\n id: \"OrphanedField\",\n description: \"A draft field a version doesn't cover: its ID, label, value and source version.\",\n }) as z.ZodType<OrphanedField>;\n\n/**\n * `GET /a/{artifactId}/_mostra/v/{rev}/carry?version=<number>`: which of the viewer's answers a\n * version doesn't carry over (D42, D109). The banner counts them before a switch; the \"Not\n * carried over\" panel lists them for the version shown.\n */\nexport interface CarryOver {\n /** The version asked about. */\n readonly version: VersionRef;\n /** The viewer's draft fields the version doesn't cover. */\n readonly orphans: readonly OrphanedField[];\n}\n\n/** The Zod schema of the `CarryOver` type. */\nexport const CarryOver: z.ZodType<CarryOver> = z\n .object({ version: VersionRef, orphans: z.array(OrphanedField).readonly() })\n .register(wireRegistry, {\n id: \"CarryOver\",\n description: \"The viewer's answers a version doesn't carry over.\",\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0CA,MAAa,6BAAsD,CAAC,YAAY;;AAGhF,MAAa,4BAA4B;;AAGzC,MAAa,2BAAmC;;AAiBhD,MAAa,gBAA0C,EACpD,OAAO;CACN,YAAY,WAAW;CACvB,OAAO,EAAE,KAAK,CAAC,UAAU,UAAU,CAAC;CACpC,cAAc;CACd,QAAQ,OAAO;CACf,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAI,CAAC,CAAC,SAAS;AAClD,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,gBAA0C,EACpD,OAAO;CACN,QAAQ,OAAO;CACf,kBAAkB;CAClB,SAAS,EAAE,QAAQ,UAAU;AAC/B,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,gBAA0C,EACpD,OAAO;CACN,QAAQ,OAAO;CACf,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;CAC9B,SAAS,EAAE,QAAQ,CAAC,CAAC,cAAc;AACrC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,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I;CACJ,aAAa;AACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * The browser protocol (INTERFACES §4, D106): what the client runtime in an artifact's frame sends\n * to the gateway and receives from it. Published versions embed the client runtime, so a gateway\n * serves every revision it ever shipped (FAILURE_MODEL §7); within a revision payloads only grow.\n * Paths are `/_mostra/v/{revision}/…` on the artifact's origin.\n *\n * ```ts\n * const body: FieldsRequest = { mutationId, scope: \"viewer\", baseRevision: \"3\", viewId, ops };\n * await fetch(`/_mostra/v/${BROWSER_PROTOCOL_REVISION}/fields`, { method: \"POST\", body: … });\n * ```\n */\nimport * as z from \"zod\";\nimport type { EphemeralMessage } from \"./actions.ts\";\nimport { ArtifactId, Cursor, MutationId, ViewId } from \"./ids.ts\";\nimport {\n DocumentRevision,\n EventRecord,\n FieldOp,\n FieldState,\n SubmissionSummary,\n Viewer,\n} from \"./interaction.ts\";\nimport { SubmissionPolicy } from \"./manifest.ts\";\nimport {\n REVIEW_SET_ID_PATTERN,\n SubmitChannel,\n TrustedControl,\n VersionRef,\n type ViewContext,\n} from \"./view.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\nexport {\n type DeliveryTarget,\n REVIEW_SET_ID_PATTERN,\n readViewContext,\n VersionRef,\n ViewContext,\n ViewContextWire,\n} from \"./view.ts\";\n\n/** Every browser-protocol revision this release serves, oldest first. */\nexport const BROWSER_PROTOCOL_REVISIONS: readonly [\"2026-10-15\"] = [\"2026-10-15\"];\n\n/** The newest browser-protocol revision: what a client runtime built now speaks. */\nexport const BROWSER_PROTOCOL_REVISION = \"2026-10-15\";\n\n/** The longest JSON a signal's payload may be, in UTF-8 bytes (D106). */\nexport const SIGNAL_PAYLOAD_MAX_BYTES: number = 64 * 1024;\n\n/** `POST …/fields`: one mutation of the viewer's draft or the artifact's state. */\nexport interface FieldsRequest {\n /** A fresh `mut_` ID per change; a retry repeats it and gets the recorded result. */\n readonly mutationId: string;\n /** Which document: the viewer's draft or the artifact's shared state. */\n readonly scope: \"viewer\" | \"artifact\";\n /** The document revision the page last saw; fields changed after it come back as conflicts. */\n readonly baseRevision: DocumentRevision;\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The field changes, applied together under one revision. */\n readonly ops: readonly FieldOp[];\n}\n\n/** The Zod schema of the `FieldsRequest` type. */\nexport const FieldsRequest: z.ZodType<FieldsRequest> = z\n .object({\n mutationId: MutationId.schema,\n scope: z.enum([\"viewer\", \"artifact\"]),\n baseRevision: DocumentRevision,\n viewId: ViewId.schema,\n ops: z.array(FieldOp).min(1).max(1000).readonly(),\n })\n .register(wireRegistry, {\n id: \"FieldsRequest\",\n description: \"A browser mutation: its ID, scope, base revision, view and field ops.\",\n });\n\n/** `POST …/submit`: submit the viewer's draft from the artifact's own code (D40). */\nexport interface SubmitRequest {\n /** The view the page was opened as (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw; another one is `MOSTRA_SUBMIT_REVISION_MOVED`. */\n readonly expectedRevision: DocumentRevision;\n /** Always `artifact` on this route; the shell's trusted Submit is the `shell` channel (D40). */\n readonly channel: \"artifact\";\n}\n\n/** The Zod schema of the `SubmitRequest` type. */\nexport const SubmitRequest: z.ZodType<SubmitRequest> = z\n .object({\n viewId: ViewId.schema,\n expectedRevision: DocumentRevision,\n channel: z.literal(\"artifact\"),\n })\n .register(wireRegistry, {\n id: \"SubmitRequest\",\n description: \"A browser submit: the view and the draft revision the viewer saw.\",\n });\n\n/** `POST …/signal`: raise a named signal for the host's attention (IN-09). */\nexport interface SignalRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** Letters, digits, `.`, `_` and `-`; `submit` is reserved. */\n readonly name: string;\n /** Any JSON, at most 64 KiB. */\n readonly payload?: unknown;\n}\n\n/** The Zod schema of the `SignalRequest` type. */\nexport const SignalRequest: z.ZodType<SignalRequest> = z\n .object({\n viewId: ViewId.schema,\n name: z.string().min(1).max(64),\n payload: z.unknown().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"SignalRequest\",\n description: \"A browser signal: the view, the signal's name and an optional JSON payload.\",\n }) as z.ZodType<SignalRequest>;\n\n/** A document as the page loads it: its revision and fields. */\nexport interface DocumentSnapshot {\n /** The document's revision. */\n readonly revision: DocumentRevision;\n /** The draft's epoch (D103); 1 for artifact state. */\n readonly epoch: number;\n /** Every field by ID. */\n readonly fields: Readonly<Record<string, FieldState>>;\n}\n\n/** The Zod schema of the `DocumentSnapshot` type. */\nexport const DocumentSnapshot: z.ZodType<DocumentSnapshot> = z\n .object({\n revision: DocumentRevision,\n epoch: z.int().min(1),\n fields: z.record(z.string(), FieldState),\n })\n .register(wireRegistry, {\n id: \"DocumentSnapshot\",\n description: \"A document's revision, epoch and fields, as a page loads it.\",\n });\n\n/**\n * The first message of a browser event stream, and a poll's `snapshot`: where the page stands,\n * so it renders the canonical draft and state before applying events after `cursor`.\n */\nexport interface StreamSnapshot {\n /** Events after this cursor follow. */\n readonly cursor: string;\n /** Who the page acts as. */\n readonly viewer: Viewer;\n /** The viewer's draft. */\n readonly draft: DocumentSnapshot;\n /** The artifact's shared state. */\n readonly state: DocumentSnapshot;\n /** The submission that closed this draft, or this viewer's latest under `epochs`. */\n readonly submission?: SubmissionSummary;\n /**\n * The artifact's latest version when the snapshot was read (WP-07): a reader that missed its\n * `version.published` event (published between a frame ticket and the stream, or compacted)\n * still learns of it.\n */\n readonly latest?: VersionRef;\n}\n\n/** The Zod schema of the `StreamSnapshot` type. */\nexport const StreamSnapshot: z.ZodType<StreamSnapshot> = z\n .object({\n cursor: Cursor.schema,\n viewer: Viewer,\n draft: DocumentSnapshot,\n state: DocumentSnapshot,\n submission: SubmissionSummary.exactOptional(),\n latest: VersionRef.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"StreamSnapshot\",\n description: \"Where a page stands: cursor, viewer, draft, artifact state and its submission.\",\n });\n\n/** `GET …/events/poll`: the long-poll answer on the same cursor as the stream (D47). */\nexport interface PollResult {\n /** Where the next poll continues. */\n readonly cursor: string;\n /** The events for this page after the cursor asked for, in order. */\n readonly events: readonly EventRecord[];\n /** Present when the poll asked for none or its cursor was compacted away. */\n readonly snapshot?: StreamSnapshot;\n /**\n * Run and live updates for this view since its last poll (WP-08): lossy and never stored as\n * events, the long-poll's counterpart of the stream's `run` and `live` messages.\n */\n readonly ephemeral?: readonly EphemeralMessage[];\n}\n\n/** The Zod schema of the `PollResult` type. */\nexport const PollResult: z.ZodType<PollResult> = z\n .object({\n cursor: Cursor.schema,\n events: z.array(EventRecord).readonly(),\n snapshot: StreamSnapshot.exactOptional(),\n ephemeral: z.array(z.record(z.string(), z.unknown())).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PollResult\",\n description: \"A long-poll answer: the cursor, the events after the asked one, and a snapshot.\",\n }) as unknown as z.ZodType<PollResult>;\n\n/**\n * `POST /a/{artifactId}/_mostra/ticket`'s answer on the shell origin: a single-use frame ticket,\n * the view it opens and what the shell needs to render the view's trusted controls (D104, D108).\n */\nexport interface FrameTicket extends ViewContext {\n /** The frame's entry URL, carrying the single-use ticket. */\n readonly src: string;\n /** The artifact's origin: the only origin the bridge accepts messages from. */\n readonly artifactOrigin: string;\n /** Whether this viewer follows the artifact's new versions (D63). */\n readonly follow: boolean;\n /** Whether the link opens this version only (D97 item 9): then the shell offers no newer one. */\n readonly pinned: boolean;\n /**\n * The version's server code keeps crashing and is parked (WP-08, FAILURE_MODEL §2): the shell\n * says so, since the page's actions and live data won't work until a new publish.\n */\n readonly serverParked?: true;\n /**\n * The frame shows `mostra dev`'s development preview of unpublished source (D140 item 12): the\n * shell says so, and it is never a published version.\n */\n readonly devPreview?: true;\n /**\n * `worker` when the shell and the artifact are two sites (a Cloudflare quick tunnel, a host's\n * addresses on two hosts): the frame enters through the bootstrap page and a service worker\n * (D70, D158 item 5). Absent: cookie mode.\n */\n readonly mode?: \"worker\";\n /**\n * The artifact is paused (D165 item 14): the shell says so, by whom and why (the reason as text);\n * it takes no submissions and runs no actions until it is resumed (WP-30).\n */\n readonly paused?: { readonly by: \"owner\" | \"operator\"; readonly reason?: string };\n /** On a remote server: what the hosted shell's trusted chrome shows around the page (D161). */\n readonly hosted?: HostedChrome;\n}\n\n/**\n * The hosted shell's trusted chrome for one view (D161, ARCHITECTURE §15.8; WP-30). Every string an\n * owner or operator supplies is rendered as text, never as markup.\n */\nexport interface HostedChrome {\n /** Who sent the page: the owner's display name, and the provider that verified it, if any. */\n readonly sender?: { readonly name: string; readonly verifiedBy?: string };\n /** Who this browser is to the page: signed in as an account, or anonymous (with a chosen name). */\n readonly viewer: {\n readonly kind: \"account\" | \"anonymous\" | \"named\";\n readonly name?: string;\n readonly verified: boolean;\n };\n /** Whether \"Sign in\" is offered (the viewer isn't signed in, and the server has a provider). */\n readonly signIn: boolean;\n /** The operator's footer wording in place of the shell's own; never hidden on a public link. */\n readonly footer?: string;\n /** The operator's line after \"Your answer was sent.\". */\n readonly afterSubmit?: string;\n /** The made-with mark, where the operator shows one. */\n readonly madeWith?: { readonly href?: string };\n /** A page shown before the artifact, once per browser and link. */\n readonly interstitial?: { readonly kind: string; readonly message?: string };\n}\n\nconst HostedChrome: z.ZodType<HostedChrome> = z.object({\n sender: z\n .object({ name: z.string().max(256), verifiedBy: z.string().max(64).exactOptional() })\n .exactOptional(),\n viewer: z.object({\n kind: z.enum([\"account\", \"anonymous\", \"named\"]),\n name: z.string().max(256).exactOptional(),\n verified: z.boolean(),\n }),\n signIn: z.boolean(),\n footer: z.string().max(500).exactOptional(),\n afterSubmit: z.string().max(500).exactOptional(),\n madeWith: z\n .object({\n href: z\n .url({ protocol: /^https$/ })\n .max(2_048)\n .exactOptional(),\n })\n .exactOptional(),\n interstitial: z\n .object({ kind: z.string().max(64), message: z.string().max(2_000).exactOptional() })\n .exactOptional(),\n});\n\n/** The Zod schema of the `FrameTicket` type. */\nexport const FrameTicket: z.ZodType<FrameTicket> = z\n .object({\n artifactId: ArtifactId.schema,\n viewId: ViewId.schema,\n version: VersionRef,\n latest: VersionRef,\n policy: SubmissionPolicy,\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),\n controls: z.array(TrustedControl).max(32).readonly(),\n target: z.enum([\"live\", \"static\", \"mcp-app\", \"verify\"]),\n src: z.string().min(1),\n artifactOrigin: z.string().min(1),\n follow: z.boolean(),\n pinned: z.boolean(),\n serverParked: z.literal(true).exactOptional(),\n devPreview: z.literal(true).exactOptional(),\n mode: z.literal(\"worker\").exactOptional(),\n paused: z\n .object({\n by: z.enum([\"owner\", \"operator\"]),\n reason: z.string().max(500).exactOptional(),\n })\n .exactOptional(),\n hosted: HostedChrome.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FrameTicket\",\n description: \"A frame ticket: the view it opens, where to load it, and the view's controls.\",\n });\n\n// ── Frame sessions in worker mode (WP-13, D70, D158 item 5) ───────────────────────────────\n\n/**\n * The header Mostra's service worker adds to every same-origin request of a worker-mode frame:\n * its frame session's secret, which no cookie can carry across sites.\n */\nexport const FRAME_SESSION_HEADER = \"x-mostra-frame\";\n\n/**\n * The header a hosted shell sends its session's secret in (INTERFACES §18.4, D165 item 8): no\n * cookie is ever set or read on a hosted host, so no tenant page can toss, shadow or crowd one out.\n */\nexport const SHELL_SESSION_HEADER = \"x-mostra-shell\";\n\n/**\n * `POST /_mostra/enter` on the artifact's origin: the bootstrap page exchanges the shell's\n * single-use frame ticket, from `/_mostra/enter#t=…`, for a worker-mode frame session.\n */\nexport interface EnterRequest {\n /** The frame ticket. */\n readonly ticket: string;\n}\n\n/** The Zod schema of the `EnterRequest` type. */\nexport const EnterRequest: z.ZodType<EnterRequest> = z\n .object({ ticket: z.string().min(1).max(64) })\n .register(wireRegistry, { id: \"EnterRequest\", description: \"A frame ticket to exchange.\" });\n\n/** The answer to `EnterRequest`. */\nexport interface EnterResult {\n /** The frame session's secret, which the service worker sends as `X-Mostra-Frame`. */\n readonly session: string;\n /** The shell's origin: the only page the bootstrap reports to. */\n readonly shellOrigin: string;\n}\n\n/** The Zod schema of the `EnterResult` type. */\nexport const EnterResult: z.ZodType<EnterResult> = z\n .object({ session: z.string().min(1), shellOrigin: z.string().min(1) })\n .register(wireRegistry, {\n id: \"EnterResult\",\n description: \"A worker-mode frame session's secret and the shell's origin.\",\n });\n\n/**\n * `POST /_mostra/v/{rev}/ticket`: a single-use ticket that opens one event stream, long poll or\n * WebSocket of this session without it (`?ticket=`), so the request can bypass the service\n * worker (VERIFIED_FACTS: Firefox stalls on endless responses a worker passes on).\n */\nexport interface StreamTicketRequest {\n /** What it opens: `stream` (events and polls, the default) or `socket` (a WebSocket). */\n readonly purpose?: \"stream\" | \"socket\";\n}\n\n/** The Zod schema of the `StreamTicketRequest` type. */\nexport const StreamTicketRequest: z.ZodType<StreamTicketRequest> = z\n .object({ purpose: z.enum([\"stream\", \"socket\"]).exactOptional() })\n .register(wireRegistry, { id: \"StreamTicketRequest\" });\n\n/** The answer to a `StreamTicketRequest`. */\nexport interface StreamTicket {\n /** The ticket: 130 bits, single-use. */\n readonly ticket: string;\n /** When it stops working, 60 s after it was minted. */\n readonly expiresAt: string;\n}\n\n/** The Zod schema of the `StreamTicket` type. */\nexport const StreamTicket: z.ZodType<StreamTicket> = z\n .object({ ticket: z.string().min(1), expiresAt: z.iso.datetime() })\n .register(wireRegistry, {\n id: \"StreamTicket\",\n description: \"A single-use ticket for one stream, poll or WebSocket.\",\n });\n\n/**\n * `GET /_mostra/session` on the artifact's origin: the frame session's facts for same-origin code.\n */\nexport interface FrameSessionFacts {\n /** The CSRF token every mutation sends as `X-Mostra-CSRF`. */\n readonly csrf: string;\n /** The artifact the frame shows. */\n readonly artifactId: string;\n /** The shell's exact origin: the bridge's only peer. */\n readonly shellOrigin: string;\n /** The link's scopes. */\n readonly scopes: readonly string[];\n /** The viewer the page acts as (WP-07). */\n readonly viewer?: Viewer;\n /** The version the frame session entered. */\n readonly version?: VersionRef;\n /** How the frame authenticates (D70): absent means `cookie`. */\n readonly mode?: \"cookie\" | \"worker\";\n /**\n * `false` where event streams don't pass (a Cloudflare quick tunnel holds responses back until\n * they end): the page long-polls from the start (D47). Absent means streams pass.\n */\n readonly streams?: boolean;\n}\n\n/** The Zod schema of the `FrameSessionFacts` type. */\nexport const FrameSessionFacts: z.ZodType<FrameSessionFacts> = z\n .object({\n csrf: z.string().min(1),\n artifactId: ArtifactId.schema,\n shellOrigin: z.string().min(1),\n scopes: z.array(z.string()).readonly(),\n viewer: Viewer.exactOptional(),\n version: VersionRef.exactOptional(),\n mode: z.enum([\"cookie\", \"worker\"]).exactOptional(),\n streams: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FrameSessionFacts\",\n description: \"A frame session's CSRF token, shell origin, scopes, viewer, version and mode.\",\n });\n\n// ── The shell's own routes (WP-07, on the shell origin) ──────────────────────────────────\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/submit`: the shell's trusted Submit (the `shell` channel,\n * D40). Only the shell's page can send it: the route takes the shell's session, its exact origin\n * and its CSRF token, none of which an artifact's page has.\n */\nexport interface ShellSubmitRequest {\n /** The view the shell's frame shows (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw, after the frame flushed its saves. */\n readonly expectedRevision: DocumentRevision;\n}\n\n/** The Zod schema of the `ShellSubmitRequest` type. */\nexport const ShellSubmitRequest: z.ZodType<ShellSubmitRequest> = z\n .object({ viewId: ViewId.schema, expectedRevision: DocumentRevision })\n .register(wireRegistry, {\n id: \"ShellSubmitRequest\",\n description: \"The shell's trusted Submit: the view and the draft revision the viewer saw.\",\n });\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/review/choose`: the shell's trusted Choose (D65, D113).\n * It writes the viewer's draft field `review.<reviewSetId>.choice` like any mutation, so a stale\n * base revision comes back as a conflict.\n */\nexport interface ChooseRequest {\n /** The view the shell's frame shows. */\n readonly viewId: string;\n /** A fresh `mut_` ID; a retry repeats it. */\n readonly mutationId: string;\n /** The draft revision the shell last saw. */\n readonly baseRevision: DocumentRevision;\n /** The review set. */\n readonly reviewSetId: string;\n /** The chosen candidate's ID. */\n readonly candidateId: string;\n /** The candidate's label, kept with the choice for results. */\n readonly label?: string;\n}\n\n/** The Zod schema of the `ChooseRequest` type. */\nexport const ChooseRequest: z.ZodType<ChooseRequest> = z\n .object({\n viewId: ViewId.schema,\n mutationId: MutationId.schema,\n baseRevision: DocumentRevision,\n reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN),\n candidateId: z.string().min(1).max(256),\n label: z.string().max(256).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ChooseRequest\",\n description:\n \"The shell's trusted Choose: the view, mutation, base revision, set and candidate.\",\n });\n\n/** `POST /a/{artifactId}/_mostra/v/{rev}/follow`: the viewer's \"Always follow this artifact\" (D63). */\nexport interface FollowRequest {\n /** `true` to load new versions automatically, `false` to stop. */\n readonly follow: boolean;\n}\n\n/** The Zod schema of the `FollowRequest` type. */\nexport const FollowRequest: z.ZodType<FollowRequest> = z\n .object({ follow: z.boolean() })\n .register(wireRegistry, {\n id: \"FollowRequest\",\n description: \"Whether the viewer follows the artifact's new versions.\",\n });\n\n/** A draft field a version doesn't cover (D42, D109): kept, shown read-only and delivered. */\nexport interface OrphanedField {\n /** The field's ID. */\n readonly id: string;\n /** Its label, when it has one. */\n readonly label?: string;\n /** Its value. */\n readonly value: unknown;\n /** The version whose view last wrote it. */\n readonly fromVersion: number;\n}\n\n/** The Zod schema of the `OrphanedField` type. */\nexport const OrphanedField: z.ZodType<OrphanedField> = z\n .object({\n id: z.string(),\n label: z.string().exactOptional(),\n value: z.unknown(),\n fromVersion: z.int().min(1),\n })\n .register(wireRegistry, {\n id: \"OrphanedField\",\n description: \"A draft field a version doesn't cover: its ID, label, value and source version.\",\n }) as z.ZodType<OrphanedField>;\n\n/**\n * `GET /a/{artifactId}/_mostra/v/{rev}/carry?version=<number>`: which of the viewer's answers a\n * version doesn't carry over (D42, D109). The banner counts them before a switch; the \"Not\n * carried over\" panel lists them for the version shown.\n */\nexport interface CarryOver {\n /** The version asked about. */\n readonly version: VersionRef;\n /** The viewer's draft fields the version doesn't cover. */\n readonly orphans: readonly OrphanedField[];\n}\n\n/** The Zod schema of the `CarryOver` type. */\nexport const CarryOver: z.ZodType<CarryOver> = z\n .object({ version: VersionRef, orphans: z.array(OrphanedField).readonly() })\n .register(wireRegistry, {\n id: \"CarryOver\",\n description: \"The viewer's answers a version doesn't carry over.\",\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0CA,MAAa,6BAAsD,CAAC,YAAY;;AAGhF,MAAa,4BAA4B;;AAGzC,MAAa,2BAAmC;;AAiBhD,MAAa,gBAA0C,EACpD,OAAO;CACN,YAAY,WAAW;CACvB,OAAO,EAAE,KAAK,CAAC,UAAU,UAAU,CAAC;CACpC,cAAc;CACd,QAAQ,OAAO;CACf,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAI,CAAC,CAAC,SAAS;AAClD,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,gBAA0C,EACpD,OAAO;CACN,QAAQ,OAAO;CACf,kBAAkB;CAClB,SAAS,EAAE,QAAQ,UAAU;AAC/B,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,gBAA0C,EACpD,OAAO;CACN,QAAQ,OAAO;CACf,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;CAC9B,SAAS,EAAE,QAAQ,CAAC,CAAC,cAAc;AACrC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,mBAAgD,EAC1D,OAAO;CACN,UAAU;CACV,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACpB,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU;AACzC,CAAC,CAAC,CAC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ACf,CAAC;;AAuBH,MAAa,gBAA0C,EACpD,OAAO;CACN,QAAQ,OAAO;CACf,YAAY,WAAW;CACvB,cAAc;CACd,aAAa,EAAE,OAAO,CAAC,CAAC,MAAM,qBAAqB;CACnD,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CACtC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,cAAc;AAC3C,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AASH,MAAa,gBAA0C,EACpD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAC/B,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAeH,MAAa,gBAA0C,EACpD,OAAO;CACN,IAAI,EAAE,OAAO;CACb,OAAO,EAAE,OAAO,CAAC,CAAC,cAAc;CAChC,OAAO,EAAE,QAAQ;CACjB,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;AAC5B,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAeH,MAAa,YAAkC,EAC5C,OAAO;CAAE,SAAS;CAAY,SAAS,EAAE,MAAM,aAAa,CAAC,CAAC,SAAS;AAAE,CAAC,CAAC,CAC3E,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../spec.js";
|
|
2
2
|
//#region src/diagnostics/codes/action.d.ts
|
|
3
3
|
/** The codes of the ACTION area, in the order they were added. */
|
|
4
|
-
export declare const actionDiagnosticCodes: readonly ["MOSTRA_ACTION_EXPORT_INVALID", "MOSTRA_ACTION_UNSERIALIZABLE", "MOSTRA_ACTION_THREW", "MOSTRA_ACTION_UNKNOWN_FUNCTION", "MOSTRA_ACTION_INTERRUPTED", "MOSTRA_ACTION_CANCELLED", "MOSTRA_ACTION_TOO_LARGE", "MOSTRA_ACTION_RUN_NOT_FOUND", "MOSTRA_ACTION_EVENT_INVALID"];
|
|
4
|
+
export declare const actionDiagnosticCodes: readonly ["MOSTRA_ACTION_EXPORT_INVALID", "MOSTRA_ACTION_UNSERIALIZABLE", "MOSTRA_ACTION_THREW", "MOSTRA_ACTION_UNKNOWN_FUNCTION", "MOSTRA_ACTION_INTERRUPTED", "MOSTRA_ACTION_CANCELLED", "MOSTRA_ACTION_TOO_LARGE", "MOSTRA_ACTION_RUN_NOT_FOUND", "MOSTRA_ACTION_EVENT_INVALID", "MOSTRA_ACTION_PAUSED"];
|
|
5
5
|
/** The codes of the ACTION area. */
|
|
6
6
|
export type ActionDiagnosticCode = (typeof actionDiagnosticCodes)[number];
|
|
7
7
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","names":[],"sources":["../../../src/diagnostics/codes/action.ts"],"mappings":";;;qBAMa;;
|
|
1
|
+
{"version":3,"file":"action.d.ts","names":[],"sources":["../../../src/diagnostics/codes/action.ts"],"mappings":";;;qBAMa;;YAeD,+BAA+B"}
|
|
@@ -9,7 +9,8 @@ const actionDiagnosticCodes = [
|
|
|
9
9
|
"MOSTRA_ACTION_CANCELLED",
|
|
10
10
|
"MOSTRA_ACTION_TOO_LARGE",
|
|
11
11
|
"MOSTRA_ACTION_RUN_NOT_FOUND",
|
|
12
|
-
"MOSTRA_ACTION_EVENT_INVALID"
|
|
12
|
+
"MOSTRA_ACTION_EVENT_INVALID",
|
|
13
|
+
"MOSTRA_ACTION_PAUSED"
|
|
13
14
|
];
|
|
14
15
|
/** The ACTION area's catalog entries. */
|
|
15
16
|
const actionDiagnostics = {
|
|
@@ -102,6 +103,16 @@ const actionDiagnostics = {
|
|
|
102
103
|
explanation: "Server code called `emit(type, payload)` from `@mostra/server` with a type that isn't `host.` followed by a name, or a payload that isn't JSON or is larger than 64 KiB. The event is not appended; `emit` throws.",
|
|
103
104
|
fix: "Use a type such as `host.reply-sent` and a small JSON payload. Put larger data in artifact state or a live source and send its key in the event."
|
|
104
105
|
}
|
|
106
|
+
},
|
|
107
|
+
MOSTRA_ACTION_PAUSED: {
|
|
108
|
+
severity: "error",
|
|
109
|
+
phase: "host",
|
|
110
|
+
title: "Artifact paused, no actions run",
|
|
111
|
+
hint: "Wait until the page is resumed, then run the action again.",
|
|
112
|
+
docs: {
|
|
113
|
+
explanation: "The artifact is paused, so its actions don't run: the run or call was refused before anything was recorded or sent to the owner's machine.",
|
|
114
|
+
fix: "The owner resumes it with `mostra resume <artifact>`; a pause by the server's operator is resumed only by the operator."
|
|
115
|
+
}
|
|
105
116
|
}
|
|
106
117
|
};
|
|
107
118
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","names":[],"sources":["../../../src/diagnostics/codes/action.ts"],"sourcesContent":["/**\n * Diagnostic codes of the ACTION area.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the ACTION area, in the order they were added. */\nexport const actionDiagnosticCodes = [\n \"MOSTRA_ACTION_EXPORT_INVALID\",\n \"MOSTRA_ACTION_UNSERIALIZABLE\",\n \"MOSTRA_ACTION_THREW\",\n \"MOSTRA_ACTION_UNKNOWN_FUNCTION\",\n \"MOSTRA_ACTION_INTERRUPTED\",\n \"MOSTRA_ACTION_CANCELLED\",\n \"MOSTRA_ACTION_TOO_LARGE\",\n \"MOSTRA_ACTION_RUN_NOT_FOUND\",\n \"MOSTRA_ACTION_EVENT_INVALID\",\n // gen:codes\n] as const;\n\n/** The codes of the ACTION area. */\nexport type ActionDiagnosticCode = (typeof actionDiagnosticCodes)[number];\n\n/** The ACTION area's catalog entries. */\nexport const actionDiagnostics: AreaCatalog<ActionDiagnosticCode> = {\n MOSTRA_ACTION_EXPORT_INVALID: {\n severity: \"error\",\n phase: \"compile\",\n title: \"Server module exports something other than an async function\",\n hint: 'Export only async functions from a \"use server\" module; move other exports to an ordinary module.',\n docs: {\n explanation:\n 'A module that starts with `\"use server\"` makes every export a server function the page can call. React\\'s contract allows only async functions there. Mostra reports this code for any other export (a constant, a class, a non-async function, `export *`), naming the export.',\n fix: \"Make the function `async`, or move the value to a separate module without the directive and import it from both sides.\",\n },\n },\n MOSTRA_ACTION_UNSERIALIZABLE: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Server function argument or result outside React's serializable types\",\n hint: \"Pass and return only plain objects, arrays, primitives, Map, Set, Date, typed arrays, FormData and promises; convert class instances to plain objects first.\",\n docs: {\n explanation:\n \"Server function arguments and results cross a process boundary, so Mostra accepts exactly the types React documents for Server Functions (D54): strings, numbers, bigints, booleans, `undefined`, `null`, symbols registered with `Symbol.for`, arrays, `Map`, `Set`, typed arrays, `ArrayBuffer`, `Date`, `FormData`, plain objects, other server functions and promises. A result may also be an async iterable, whose items stream to the page. Mostra reports this code for anything else (a class instance, an `Error`, a `RegExp`, an object with a null prototype, a function that isn't a server function, an unregistered symbol, JSX) and names where in the value it is, such as `Argument 2 at .items[1]`. A promise in an argument that rejects fails the call the same way.\",\n fix: \"Convert the value to the supported types before the call or the return: `{ ...instance }` or a mapping for class instances, `error.message` for errors and `regexp.source` for regular expressions.\",\n },\n },\n MOSTRA_ACTION_THREW: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Server function threw\",\n hint: \"Read the run's log for the stack, then fix the server function or catch the error and return a result instead.\",\n docs: {\n explanation:\n \"A server function threw while it ran. The page gets `{ code: \\\"MOSTRA_ACTION_THREW\\\", message }` with the thrown error's message (`useAction`'s `error`, or the rejected promise of a plain call); the stack goes to the action run's log, never to the page. When the error carried a diagnostic code of its own (a `MOSTRA_SECRET_MISSING`, say), that code is reported instead.\",\n fix: \"Fix the cause in the function, or catch the error inside it and return a value the page can show. Mostra never retries a run by itself (D24); retry in your own code, or call the action again with a new key.\",\n },\n },\n MOSTRA_ACTION_UNKNOWN_FUNCTION: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"No such server function in this version\",\n hint: \"Publish the artifact again so the page and its server code come from the same version.\",\n docs: {\n explanation:\n \"The page called a server function ID (`<module path>#<export>`) that the version's server bundle doesn't export. Pages call only functions their own build references, so this means a page and a worker of different versions, or a request written by hand.\",\n fix: 'Republish the artifact and reload the page. Call server functions by importing them from their `\"use server\"` module, never by ID.',\n },\n },\n MOSTRA_ACTION_INTERRUPTED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Action run interrupted\",\n hint: \"Check the run's effects at their provider, then start it again with a new key if it should run again.\",\n docs: {\n explanation:\n \"The action run's worker crashed, ran out of memory, was stopped by the event-loop watchdog, or the instance stopped while the run was running. The run ends `failed` with the reason `interrupted`, and Mostra never retries it by itself (D24): an action that had already started a side effect, such as sending an email, may or may not have finished it.\",\n fix: \"Look at the effect where it happens (the mail provider's sent folder, say) before running the action again. Pass the provider's own idempotency key from the action (for example, the run's key) so a repeated request can't act twice.\",\n },\n },\n MOSTRA_ACTION_CANCELLED: {\n severity: \"warning\",\n phase: \"runtime\",\n title: \"Action run cancelled\",\n hint: \"Start the action again if it should still run.\",\n docs: {\n explanation:\n \"The action run was cancelled from a page, and its `abortSignal` fired. The run ends `cancelled` when the action stops; an action that ignores the signal ends with whatever it returns.\",\n fix: \"Nothing to fix. Pass `abortSignal` from `@mostra/server` to `fetch` and other cancellable calls so cancelling stops the work.\",\n },\n },\n MOSTRA_ACTION_TOO_LARGE: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Server function arguments or result too large\",\n hint: \"Return or pass less data: page through it, or write it to artifact state or a live source instead.\",\n docs: {\n explanation:\n \"A server function's serialized arguments, or an action run's serialized result, is over 16 MiB. A plain call or run with arguments that large is refused before it starts; a run whose result grows past the limit is stopped and ends `failed`.\",\n fix: \"Send identifiers rather than whole documents, return a page of results at a time, or publish large data through a live source or artifact state, which the page reads on its own.\",\n },\n },\n MOSTRA_ACTION_RUN_NOT_FOUND: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"No such action run\",\n hint: \"Start the action again; the run ID names no run of this artifact.\",\n docs: {\n explanation:\n \"A page asked for or cancelled an action run that this artifact doesn't have, or one started from another artifact.\",\n fix: \"Use the run IDs `useAction` reports. A page that keeps run IDs itself should drop IDs from other artifacts.\",\n },\n },\n MOSTRA_ACTION_EVENT_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Host event type or payload invalid\",\n hint: \"Name the event `host.<name>` with 1 to 64 letters, digits, `.`, `_` and `-`, and keep its payload JSON of at most 64 KiB.\",\n docs: {\n explanation:\n \"Server code called `emit(type, payload)` from `@mostra/server` with a type that isn't `host.` followed by a name, or a payload that isn't JSON or is larger than 64 KiB. The event is not appended; `emit` throws.\",\n fix: \"Use a type such as `host.reply-sent` and a small JSON payload. Put larger data in artifact state or a live source and send its key in the event.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAMA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,oBAAuD;CAClE,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,qBAAqB;EACnB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,gCAAgC;EAC9B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,yBAAyB;EACvB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,yBAAyB;EACvB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,6BAA6B;EAC3B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,6BAA6B;EAC3B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;AAEF"}
|
|
1
|
+
{"version":3,"file":"action.js","names":[],"sources":["../../../src/diagnostics/codes/action.ts"],"sourcesContent":["/**\n * Diagnostic codes of the ACTION area.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the ACTION area, in the order they were added. */\nexport const actionDiagnosticCodes = [\n \"MOSTRA_ACTION_EXPORT_INVALID\",\n \"MOSTRA_ACTION_UNSERIALIZABLE\",\n \"MOSTRA_ACTION_THREW\",\n \"MOSTRA_ACTION_UNKNOWN_FUNCTION\",\n \"MOSTRA_ACTION_INTERRUPTED\",\n \"MOSTRA_ACTION_CANCELLED\",\n \"MOSTRA_ACTION_TOO_LARGE\",\n \"MOSTRA_ACTION_RUN_NOT_FOUND\",\n \"MOSTRA_ACTION_EVENT_INVALID\",\n \"MOSTRA_ACTION_PAUSED\",\n // gen:codes\n] as const;\n\n/** The codes of the ACTION area. */\nexport type ActionDiagnosticCode = (typeof actionDiagnosticCodes)[number];\n\n/** The ACTION area's catalog entries. */\nexport const actionDiagnostics: AreaCatalog<ActionDiagnosticCode> = {\n MOSTRA_ACTION_EXPORT_INVALID: {\n severity: \"error\",\n phase: \"compile\",\n title: \"Server module exports something other than an async function\",\n hint: 'Export only async functions from a \"use server\" module; move other exports to an ordinary module.',\n docs: {\n explanation:\n 'A module that starts with `\"use server\"` makes every export a server function the page can call. React\\'s contract allows only async functions there. Mostra reports this code for any other export (a constant, a class, a non-async function, `export *`), naming the export.',\n fix: \"Make the function `async`, or move the value to a separate module without the directive and import it from both sides.\",\n },\n },\n MOSTRA_ACTION_UNSERIALIZABLE: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Server function argument or result outside React's serializable types\",\n hint: \"Pass and return only plain objects, arrays, primitives, Map, Set, Date, typed arrays, FormData and promises; convert class instances to plain objects first.\",\n docs: {\n explanation:\n \"Server function arguments and results cross a process boundary, so Mostra accepts exactly the types React documents for Server Functions (D54): strings, numbers, bigints, booleans, `undefined`, `null`, symbols registered with `Symbol.for`, arrays, `Map`, `Set`, typed arrays, `ArrayBuffer`, `Date`, `FormData`, plain objects, other server functions and promises. A result may also be an async iterable, whose items stream to the page. Mostra reports this code for anything else (a class instance, an `Error`, a `RegExp`, an object with a null prototype, a function that isn't a server function, an unregistered symbol, JSX) and names where in the value it is, such as `Argument 2 at .items[1]`. A promise in an argument that rejects fails the call the same way.\",\n fix: \"Convert the value to the supported types before the call or the return: `{ ...instance }` or a mapping for class instances, `error.message` for errors and `regexp.source` for regular expressions.\",\n },\n },\n MOSTRA_ACTION_THREW: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Server function threw\",\n hint: \"Read the run's log for the stack, then fix the server function or catch the error and return a result instead.\",\n docs: {\n explanation:\n \"A server function threw while it ran. The page gets `{ code: \\\"MOSTRA_ACTION_THREW\\\", message }` with the thrown error's message (`useAction`'s `error`, or the rejected promise of a plain call); the stack goes to the action run's log, never to the page. When the error carried a diagnostic code of its own (a `MOSTRA_SECRET_MISSING`, say), that code is reported instead.\",\n fix: \"Fix the cause in the function, or catch the error inside it and return a value the page can show. Mostra never retries a run by itself (D24); retry in your own code, or call the action again with a new key.\",\n },\n },\n MOSTRA_ACTION_UNKNOWN_FUNCTION: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"No such server function in this version\",\n hint: \"Publish the artifact again so the page and its server code come from the same version.\",\n docs: {\n explanation:\n \"The page called a server function ID (`<module path>#<export>`) that the version's server bundle doesn't export. Pages call only functions their own build references, so this means a page and a worker of different versions, or a request written by hand.\",\n fix: 'Republish the artifact and reload the page. Call server functions by importing them from their `\"use server\"` module, never by ID.',\n },\n },\n MOSTRA_ACTION_INTERRUPTED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Action run interrupted\",\n hint: \"Check the run's effects at their provider, then start it again with a new key if it should run again.\",\n docs: {\n explanation:\n \"The action run's worker crashed, ran out of memory, was stopped by the event-loop watchdog, or the instance stopped while the run was running. The run ends `failed` with the reason `interrupted`, and Mostra never retries it by itself (D24): an action that had already started a side effect, such as sending an email, may or may not have finished it.\",\n fix: \"Look at the effect where it happens (the mail provider's sent folder, say) before running the action again. Pass the provider's own idempotency key from the action (for example, the run's key) so a repeated request can't act twice.\",\n },\n },\n MOSTRA_ACTION_CANCELLED: {\n severity: \"warning\",\n phase: \"runtime\",\n title: \"Action run cancelled\",\n hint: \"Start the action again if it should still run.\",\n docs: {\n explanation:\n \"The action run was cancelled from a page, and its `abortSignal` fired. The run ends `cancelled` when the action stops; an action that ignores the signal ends with whatever it returns.\",\n fix: \"Nothing to fix. Pass `abortSignal` from `@mostra/server` to `fetch` and other cancellable calls so cancelling stops the work.\",\n },\n },\n MOSTRA_ACTION_TOO_LARGE: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Server function arguments or result too large\",\n hint: \"Return or pass less data: page through it, or write it to artifact state or a live source instead.\",\n docs: {\n explanation:\n \"A server function's serialized arguments, or an action run's serialized result, is over 16 MiB. A plain call or run with arguments that large is refused before it starts; a run whose result grows past the limit is stopped and ends `failed`.\",\n fix: \"Send identifiers rather than whole documents, return a page of results at a time, or publish large data through a live source or artifact state, which the page reads on its own.\",\n },\n },\n MOSTRA_ACTION_RUN_NOT_FOUND: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"No such action run\",\n hint: \"Start the action again; the run ID names no run of this artifact.\",\n docs: {\n explanation:\n \"A page asked for or cancelled an action run that this artifact doesn't have, or one started from another artifact.\",\n fix: \"Use the run IDs `useAction` reports. A page that keeps run IDs itself should drop IDs from other artifacts.\",\n },\n },\n MOSTRA_ACTION_EVENT_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Host event type or payload invalid\",\n hint: \"Name the event `host.<name>` with 1 to 64 letters, digits, `.`, `_` and `-`, and keep its payload JSON of at most 64 KiB.\",\n docs: {\n explanation:\n \"Server code called `emit(type, payload)` from `@mostra/server` with a type that isn't `host.` followed by a name, or a payload that isn't JSON or is larger than 64 KiB. The event is not appended; `emit` throws.\",\n fix: \"Use a type such as `host.reply-sent` and a small JSON payload. Put larger data in artifact state or a live source and send its key in the event.\",\n },\n },\n MOSTRA_ACTION_PAUSED: {\n severity: \"error\",\n phase: \"host\",\n title: \"Artifact paused, no actions run\",\n hint: \"Wait until the page is resumed, then run the action again.\",\n docs: {\n explanation:\n \"The artifact is paused, so its actions don't run: the run or call was refused before anything was recorded or sent to the owner's machine.\",\n fix: \"The owner resumes it with `mostra resume <artifact>`; a pause by the server's operator is resumed only by the operator.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAMA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,oBAAuD;CAClE,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,qBAAqB;EACnB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,gCAAgC;EAC9B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,yBAAyB;EACvB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,yBAAyB;EACvB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,6BAA6B;EAC3B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,6BAA6B;EAC3B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,sBAAsB;EACpB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;AAEF"}
|
|
@@ -25,11 +25,12 @@ import { ShareDiagnosticCode, shareDiagnosticCodes } from "./share.js";
|
|
|
25
25
|
import { SmokeDiagnosticCode, smokeDiagnosticCodes } from "./smoke.js";
|
|
26
26
|
import { SubmitDiagnosticCode, submitDiagnosticCodes } from "./submit.js";
|
|
27
27
|
import { TargetDiagnosticCode, targetDiagnosticCodes } from "./target.js";
|
|
28
|
+
import { TeamDiagnosticCode, teamDiagnosticCodes } from "./team.js";
|
|
28
29
|
import { TypeDiagnosticCode, typeDiagnosticCodes } from "./type.js";
|
|
29
30
|
import { VerifyDiagnosticCode, verifyDiagnosticCodes } from "./verify.js";
|
|
30
31
|
//#region src/diagnostics/codes/index.d.ts
|
|
31
32
|
/** Every code in the catalog. Codes are semver surface and are never removed (AX-03). */
|
|
32
|
-
export type KnownDiagnosticCode = RemoteDiagnosticCode | ShareDiagnosticCode | CliDiagnosticCode | RegressionDiagnosticCode | SmokeDiagnosticCode | A11yDiagnosticCode | NetworkDiagnosticCode | ConsoleDiagnosticCode | TypeDiagnosticCode | VerifyDiagnosticCode | LiveDiagnosticCode | SecretDiagnosticCode | RuntimeDiagnosticCode | FieldDiagnosticCode | SubmitDiagnosticCode | HygieneDiagnosticCode | DepDiagnosticCode | EnvDiagnosticCode | TargetDiagnosticCode | ArtifactDiagnosticCode | PublishDiagnosticCode | ActionDiagnosticCode | BuildDiagnosticCode | ManifestDiagnosticCode | HomeDiagnosticCode | PlatformDiagnosticCode | HostDiagnosticCode;
|
|
33
|
+
export type KnownDiagnosticCode = TeamDiagnosticCode | RemoteDiagnosticCode | ShareDiagnosticCode | CliDiagnosticCode | RegressionDiagnosticCode | SmokeDiagnosticCode | A11yDiagnosticCode | NetworkDiagnosticCode | ConsoleDiagnosticCode | TypeDiagnosticCode | VerifyDiagnosticCode | LiveDiagnosticCode | SecretDiagnosticCode | RuntimeDiagnosticCode | FieldDiagnosticCode | SubmitDiagnosticCode | HygieneDiagnosticCode | DepDiagnosticCode | EnvDiagnosticCode | TargetDiagnosticCode | ArtifactDiagnosticCode | PublishDiagnosticCode | ActionDiagnosticCode | BuildDiagnosticCode | ManifestDiagnosticCode | HomeDiagnosticCode | PlatformDiagnosticCode | HostDiagnosticCode;
|
|
33
34
|
/** Every cataloged code with its severity, phase, title, default hint and docs text. */
|
|
34
35
|
export declare const diagnosticCatalog: Readonly<Record<KnownDiagnosticCode, DiagnosticSpec>>;
|
|
35
36
|
/** Options for {@link createDiagnostic}. */
|
|
@@ -49,5 +50,5 @@ export interface CreateDiagnosticOptions {
|
|
|
49
50
|
*/
|
|
50
51
|
export declare function createDiagnostic(code: KnownDiagnosticCode, details: DiagnosticDetails, options?: CreateDiagnosticOptions): Diagnostic;
|
|
51
52
|
//#endregion
|
|
52
|
-
export { type A11yDiagnosticCode, type ActionDiagnosticCode, type ArtifactDiagnosticCode, type BuildDiagnosticCode, type CliDiagnosticCode, type ConsoleDiagnosticCode, type DepDiagnosticCode, type EnvDiagnosticCode, type FieldDiagnosticCode, type HomeDiagnosticCode, type HostDiagnosticCode, type HygieneDiagnosticCode, type LiveDiagnosticCode, type ManifestDiagnosticCode, type NetworkDiagnosticCode, type PlatformDiagnosticCode, type PublishDiagnosticCode, type RegressionDiagnosticCode, type RemoteDiagnosticCode, type RuntimeDiagnosticCode, type SecretDiagnosticCode, type ShareDiagnosticCode, type SmokeDiagnosticCode, type SubmitDiagnosticCode, type TargetDiagnosticCode, type TypeDiagnosticCode, type VerifyDiagnosticCode, a11yDiagnosticCodes, actionDiagnosticCodes, artifactDiagnosticCodes, buildDiagnosticCodes, cliDiagnosticCodes, consoleDiagnosticCodes, depDiagnosticCodes, envDiagnosticCodes, fieldDiagnosticCodes, homeDiagnosticCodes, hostDiagnosticCodes, hygieneDiagnosticCodes, liveDiagnosticCodes, manifestDiagnosticCodes, networkDiagnosticCodes, platformDiagnosticCodes, publishDiagnosticCodes, regressionDiagnosticCodes, remoteDiagnosticCodes, runtimeDiagnosticCodes, secretDiagnosticCodes, shareDiagnosticCodes, smokeDiagnosticCodes, submitDiagnosticCodes, targetDiagnosticCodes, typeDiagnosticCodes, verifyDiagnosticCodes };
|
|
53
|
+
export { type A11yDiagnosticCode, type ActionDiagnosticCode, type ArtifactDiagnosticCode, type BuildDiagnosticCode, type CliDiagnosticCode, type ConsoleDiagnosticCode, type DepDiagnosticCode, type EnvDiagnosticCode, type FieldDiagnosticCode, type HomeDiagnosticCode, type HostDiagnosticCode, type HygieneDiagnosticCode, type LiveDiagnosticCode, type ManifestDiagnosticCode, type NetworkDiagnosticCode, type PlatformDiagnosticCode, type PublishDiagnosticCode, type RegressionDiagnosticCode, type RemoteDiagnosticCode, type RuntimeDiagnosticCode, type SecretDiagnosticCode, type ShareDiagnosticCode, type SmokeDiagnosticCode, type SubmitDiagnosticCode, type TargetDiagnosticCode, type TeamDiagnosticCode, type TypeDiagnosticCode, type VerifyDiagnosticCode, a11yDiagnosticCodes, actionDiagnosticCodes, artifactDiagnosticCodes, buildDiagnosticCodes, cliDiagnosticCodes, consoleDiagnosticCodes, depDiagnosticCodes, envDiagnosticCodes, fieldDiagnosticCodes, homeDiagnosticCodes, hostDiagnosticCodes, hygieneDiagnosticCodes, liveDiagnosticCodes, manifestDiagnosticCodes, networkDiagnosticCodes, platformDiagnosticCodes, publishDiagnosticCodes, regressionDiagnosticCodes, remoteDiagnosticCodes, runtimeDiagnosticCodes, secretDiagnosticCodes, shareDiagnosticCodes, smokeDiagnosticCodes, submitDiagnosticCodes, targetDiagnosticCodes, teamDiagnosticCodes, typeDiagnosticCodes, verifyDiagnosticCodes };
|
|
53
54
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/diagnostics/codes/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/diagnostics/codes/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAmEY,sBAER,qBACA,uBACA,sBACA,oBACA,2BACA,sBACA,qBACA,wBACA,wBACA,qBACA,uBACA,qBACA,uBACA,wBACA,sBACA,uBACA,wBACA,oBACA,oBACA,uBACA,yBACA,wBACA,uBACA,sBACA,yBACA,qBACA,yBACA;;qBAGS,mBAAmB,SAAS,OAAO,qBAAqB;;iBAiCpD;;WAEN;;;;;;;;;;;;wBAaK,iBACd,MAAM,qBACN,SAAS,mBACT,UAAS,0BACR"}
|
|
@@ -24,11 +24,13 @@ import { shareDiagnosticCodes, shareDiagnostics } from "./share.js";
|
|
|
24
24
|
import { smokeDiagnosticCodes, smokeDiagnostics } from "./smoke.js";
|
|
25
25
|
import { submitDiagnosticCodes, submitDiagnostics } from "./submit.js";
|
|
26
26
|
import { targetDiagnosticCodes, targetDiagnostics } from "./target.js";
|
|
27
|
+
import { teamDiagnosticCodes, teamDiagnostics } from "./team.js";
|
|
27
28
|
import { typeDiagnosticCodes, typeDiagnostics } from "./type.js";
|
|
28
29
|
import { verifyDiagnosticCodes, verifyDiagnostics } from "./verify.js";
|
|
29
30
|
//#region src/diagnostics/codes/index.ts
|
|
30
31
|
/** Every cataloged code with its severity, phase, title, default hint and docs text. */
|
|
31
32
|
const diagnosticCatalog = {
|
|
33
|
+
...teamDiagnostics,
|
|
32
34
|
...remoteDiagnostics,
|
|
33
35
|
...shareDiagnostics,
|
|
34
36
|
...cliDiagnostics,
|
|
@@ -71,6 +73,6 @@ function createDiagnostic(code, details, options = {}) {
|
|
|
71
73
|
return buildDiagnostic(code, diagnosticCatalog[code], details, options.docsBase);
|
|
72
74
|
}
|
|
73
75
|
//#endregion
|
|
74
|
-
export { a11yDiagnosticCodes, actionDiagnosticCodes, artifactDiagnosticCodes, buildDiagnosticCodes, cliDiagnosticCodes, consoleDiagnosticCodes, createDiagnostic, depDiagnosticCodes, diagnosticCatalog, envDiagnosticCodes, fieldDiagnosticCodes, homeDiagnosticCodes, hostDiagnosticCodes, hygieneDiagnosticCodes, liveDiagnosticCodes, manifestDiagnosticCodes, networkDiagnosticCodes, platformDiagnosticCodes, publishDiagnosticCodes, regressionDiagnosticCodes, remoteDiagnosticCodes, runtimeDiagnosticCodes, secretDiagnosticCodes, shareDiagnosticCodes, smokeDiagnosticCodes, submitDiagnosticCodes, targetDiagnosticCodes, typeDiagnosticCodes, verifyDiagnosticCodes };
|
|
76
|
+
export { a11yDiagnosticCodes, actionDiagnosticCodes, artifactDiagnosticCodes, buildDiagnosticCodes, cliDiagnosticCodes, consoleDiagnosticCodes, createDiagnostic, depDiagnosticCodes, diagnosticCatalog, envDiagnosticCodes, fieldDiagnosticCodes, homeDiagnosticCodes, hostDiagnosticCodes, hygieneDiagnosticCodes, liveDiagnosticCodes, manifestDiagnosticCodes, networkDiagnosticCodes, platformDiagnosticCodes, publishDiagnosticCodes, regressionDiagnosticCodes, remoteDiagnosticCodes, runtimeDiagnosticCodes, secretDiagnosticCodes, shareDiagnosticCodes, smokeDiagnosticCodes, submitDiagnosticCodes, targetDiagnosticCodes, teamDiagnosticCodes, typeDiagnosticCodes, verifyDiagnosticCodes };
|
|
75
77
|
|
|
76
78
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/diagnostics/codes/index.ts"],"sourcesContent":["/**\n * The diagnostic catalog, assembled from one source file per area. `pnpm gen diagnostic` keeps\n * the lists below in step with the area files; edit the area files, not these lists.\n */\nimport type { Diagnostic } from \"../diagnostic.ts\";\nimport { buildDiagnostic, type DiagnosticDetails, type DiagnosticSpec } from \"../spec.ts\";\nimport { type A11yDiagnosticCode, a11yDiagnostics } from \"./a11y.ts\";\nimport { type ActionDiagnosticCode, actionDiagnostics } from \"./action.ts\";\nimport { type ArtifactDiagnosticCode, artifactDiagnostics } from \"./artifact.ts\";\nimport { type BuildDiagnosticCode, buildDiagnostics } from \"./build.ts\";\nimport { type CliDiagnosticCode, cliDiagnostics } from \"./cli.ts\";\nimport { type ConsoleDiagnosticCode, consoleDiagnostics } from \"./console.ts\";\nimport { type DepDiagnosticCode, depDiagnostics } from \"./dep.ts\";\nimport { type EnvDiagnosticCode, envDiagnostics } from \"./env.ts\";\nimport { type FieldDiagnosticCode, fieldDiagnostics } from \"./field.ts\";\nimport { type HomeDiagnosticCode, homeDiagnostics } from \"./home.ts\";\nimport { type HostDiagnosticCode, hostDiagnostics } from \"./host.ts\";\nimport { type HygieneDiagnosticCode, hygieneDiagnostics } from \"./hygiene.ts\";\nimport { type LiveDiagnosticCode, liveDiagnostics } from \"./live.ts\";\nimport { type ManifestDiagnosticCode, manifestDiagnostics } from \"./manifest.ts\";\nimport { type NetworkDiagnosticCode, networkDiagnostics } from \"./network.ts\";\nimport { type PlatformDiagnosticCode, platformDiagnostics } from \"./platform.ts\";\nimport { type PublishDiagnosticCode, publishDiagnostics } from \"./publish.ts\";\nimport { type RegressionDiagnosticCode, regressionDiagnostics } from \"./regression.ts\";\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/diagnostics/codes/index.ts"],"sourcesContent":["/**\n * The diagnostic catalog, assembled from one source file per area. `pnpm gen diagnostic` keeps\n * the lists below in step with the area files; edit the area files, not these lists.\n */\nimport type { Diagnostic } from \"../diagnostic.ts\";\nimport { buildDiagnostic, type DiagnosticDetails, type DiagnosticSpec } from \"../spec.ts\";\nimport { type A11yDiagnosticCode, a11yDiagnostics } from \"./a11y.ts\";\nimport { type ActionDiagnosticCode, actionDiagnostics } from \"./action.ts\";\nimport { type ArtifactDiagnosticCode, artifactDiagnostics } from \"./artifact.ts\";\nimport { type BuildDiagnosticCode, buildDiagnostics } from \"./build.ts\";\nimport { type CliDiagnosticCode, cliDiagnostics } from \"./cli.ts\";\nimport { type ConsoleDiagnosticCode, consoleDiagnostics } from \"./console.ts\";\nimport { type DepDiagnosticCode, depDiagnostics } from \"./dep.ts\";\nimport { type EnvDiagnosticCode, envDiagnostics } from \"./env.ts\";\nimport { type FieldDiagnosticCode, fieldDiagnostics } from \"./field.ts\";\nimport { type HomeDiagnosticCode, homeDiagnostics } from \"./home.ts\";\nimport { type HostDiagnosticCode, hostDiagnostics } from \"./host.ts\";\nimport { type HygieneDiagnosticCode, hygieneDiagnostics } from \"./hygiene.ts\";\nimport { type LiveDiagnosticCode, liveDiagnostics } from \"./live.ts\";\nimport { type ManifestDiagnosticCode, manifestDiagnostics } from \"./manifest.ts\";\nimport { type NetworkDiagnosticCode, networkDiagnostics } from \"./network.ts\";\nimport { type PlatformDiagnosticCode, platformDiagnostics } from \"./platform.ts\";\nimport { type PublishDiagnosticCode, publishDiagnostics } from \"./publish.ts\";\nimport { type RegressionDiagnosticCode, regressionDiagnostics } from \"./regression.ts\";\nimport { type RemoteDiagnosticCode, remoteDiagnostics } from \"./remote.ts\";\nimport { type RuntimeDiagnosticCode, runtimeDiagnostics } from \"./runtime.ts\";\nimport { type SecretDiagnosticCode, secretDiagnostics } from \"./secret.ts\";\nimport { type ShareDiagnosticCode, shareDiagnostics } from \"./share.ts\";\nimport { type SmokeDiagnosticCode, smokeDiagnostics } from \"./smoke.ts\";\nimport { type SubmitDiagnosticCode, submitDiagnostics } from \"./submit.ts\";\nimport { type TargetDiagnosticCode, targetDiagnostics } from \"./target.ts\";\n// gen:area-imports\nimport { type TeamDiagnosticCode, teamDiagnostics } from \"./team.ts\";\nimport { type TypeDiagnosticCode, typeDiagnostics } from \"./type.ts\";\nimport { type VerifyDiagnosticCode, verifyDiagnostics } from \"./verify.ts\";\n\nexport { type A11yDiagnosticCode, a11yDiagnosticCodes } from \"./a11y.ts\";\nexport { type ActionDiagnosticCode, actionDiagnosticCodes } from \"./action.ts\";\nexport { type ArtifactDiagnosticCode, artifactDiagnosticCodes } from \"./artifact.ts\";\nexport { type BuildDiagnosticCode, buildDiagnosticCodes } from \"./build.ts\";\nexport { type CliDiagnosticCode, cliDiagnosticCodes } from \"./cli.ts\";\nexport { type ConsoleDiagnosticCode, consoleDiagnosticCodes } from \"./console.ts\";\nexport { type DepDiagnosticCode, depDiagnosticCodes } from \"./dep.ts\";\nexport { type EnvDiagnosticCode, envDiagnosticCodes } from \"./env.ts\";\nexport { type FieldDiagnosticCode, fieldDiagnosticCodes } from \"./field.ts\";\nexport { type HomeDiagnosticCode, homeDiagnosticCodes } from \"./home.ts\";\nexport { type HostDiagnosticCode, hostDiagnosticCodes } from \"./host.ts\";\nexport { type HygieneDiagnosticCode, hygieneDiagnosticCodes } from \"./hygiene.ts\";\nexport { type LiveDiagnosticCode, liveDiagnosticCodes } from \"./live.ts\";\nexport { type ManifestDiagnosticCode, manifestDiagnosticCodes } from \"./manifest.ts\";\nexport { type NetworkDiagnosticCode, networkDiagnosticCodes } from \"./network.ts\";\nexport { type PlatformDiagnosticCode, platformDiagnosticCodes } from \"./platform.ts\";\nexport { type PublishDiagnosticCode, publishDiagnosticCodes } from \"./publish.ts\";\nexport { type RegressionDiagnosticCode, regressionDiagnosticCodes } from \"./regression.ts\";\nexport { type RemoteDiagnosticCode, remoteDiagnosticCodes } from \"./remote.ts\";\nexport { type RuntimeDiagnosticCode, runtimeDiagnosticCodes } from \"./runtime.ts\";\nexport { type SecretDiagnosticCode, secretDiagnosticCodes } from \"./secret.ts\";\nexport { type ShareDiagnosticCode, shareDiagnosticCodes } from \"./share.ts\";\nexport { type SmokeDiagnosticCode, smokeDiagnosticCodes } from \"./smoke.ts\";\nexport { type SubmitDiagnosticCode, submitDiagnosticCodes } from \"./submit.ts\";\nexport { type TargetDiagnosticCode, targetDiagnosticCodes } from \"./target.ts\";\n// gen:area-exports\nexport { type TeamDiagnosticCode, teamDiagnosticCodes } from \"./team.ts\";\nexport { type TypeDiagnosticCode, typeDiagnosticCodes } from \"./type.ts\";\nexport { type VerifyDiagnosticCode, verifyDiagnosticCodes } from \"./verify.ts\";\n\n/** Every code in the catalog. Codes are semver surface and are never removed (AX-03). */\nexport type KnownDiagnosticCode =\n // gen:area-codes\n | TeamDiagnosticCode\n | RemoteDiagnosticCode\n | ShareDiagnosticCode\n | CliDiagnosticCode\n | RegressionDiagnosticCode\n | SmokeDiagnosticCode\n | A11yDiagnosticCode\n | NetworkDiagnosticCode\n | ConsoleDiagnosticCode\n | TypeDiagnosticCode\n | VerifyDiagnosticCode\n | LiveDiagnosticCode\n | SecretDiagnosticCode\n | RuntimeDiagnosticCode\n | FieldDiagnosticCode\n | SubmitDiagnosticCode\n | HygieneDiagnosticCode\n | DepDiagnosticCode\n | EnvDiagnosticCode\n | TargetDiagnosticCode\n | ArtifactDiagnosticCode\n | PublishDiagnosticCode\n | ActionDiagnosticCode\n | BuildDiagnosticCode\n | ManifestDiagnosticCode\n | HomeDiagnosticCode\n | PlatformDiagnosticCode\n | HostDiagnosticCode;\n\n/** Every cataloged code with its severity, phase, title, default hint and docs text. */\nexport const diagnosticCatalog: Readonly<Record<KnownDiagnosticCode, DiagnosticSpec>> = {\n // gen:area-spreads\n ...teamDiagnostics,\n ...remoteDiagnostics,\n ...shareDiagnostics,\n ...cliDiagnostics,\n ...regressionDiagnostics,\n ...smokeDiagnostics,\n ...a11yDiagnostics,\n ...networkDiagnostics,\n ...consoleDiagnostics,\n ...typeDiagnostics,\n ...verifyDiagnostics,\n ...liveDiagnostics,\n ...secretDiagnostics,\n ...runtimeDiagnostics,\n ...fieldDiagnostics,\n ...submitDiagnostics,\n ...hygieneDiagnostics,\n ...depDiagnostics,\n ...envDiagnostics,\n ...targetDiagnostics,\n ...artifactDiagnostics,\n ...publishDiagnostics,\n ...actionDiagnostics,\n ...buildDiagnostics,\n ...manifestDiagnostics,\n ...homeDiagnostics,\n ...platformDiagnostics,\n ...hostDiagnostics,\n};\n\n/** Options for {@link createDiagnostic}. */\nexport interface CreateDiagnosticOptions {\n /** The docs site base URL. Defaults to `DEFAULT_DOCS_BASE`. */\n readonly docsBase?: string;\n}\n\n/**\n * Creates the diagnostic for one occurrence of a cataloged code. Severity, phase, the default hint\n * and the docs link come from the catalog.\n *\n * ```ts\n * createDiagnostic(\"MOSTRA_HOST_REVISION_UNSUPPORTED\", {\n * message: \"The client offered 2026-01-01; this instance supports 2026-10-10.\",\n * });\n * ```\n */\nexport function createDiagnostic(\n code: KnownDiagnosticCode,\n details: DiagnosticDetails,\n options: CreateDiagnosticOptions = {},\n): Diagnostic {\n return buildDiagnostic(code, diagnosticCatalog[code], details, options.docsBase);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGA,MAAa,oBAA2E;CAEtF,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL;;;;;;;;;;;AAkBA,SAAgB,iBACd,MACA,SACA,UAAmC,CAAC,GACxB;CACZ,OAAO,gBAAgB,MAAM,kBAAkB,OAAO,SAAS,QAAQ,QAAQ;AACjF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../spec.js";
|
|
2
2
|
//#region src/diagnostics/codes/remote.d.ts
|
|
3
3
|
/** The codes of the REMOTE area, in the order they were added. */
|
|
4
|
-
export declare const remoteDiagnosticCodes: readonly ["MOSTRA_REMOTE_CONFIG_INVALID", "MOSTRA_REMOTE_LOGIN_FAILED", "MOSTRA_REMOTE_UNREACHABLE", "MOSTRA_REMOTE_OWNER_OFFLINE", "MOSTRA_REMOTE_QUEUE_FULL", "MOSTRA_REMOTE_NOT_OWNER_INSTANCE", "MOSTRA_REMOTE_SIGN_IN_REQUIRED", "MOSTRA_REMOTE_RATE_LIMITED"];
|
|
4
|
+
export declare const remoteDiagnosticCodes: readonly ["MOSTRA_REMOTE_CONFIG_INVALID", "MOSTRA_REMOTE_LOGIN_FAILED", "MOSTRA_REMOTE_UNREACHABLE", "MOSTRA_REMOTE_OWNER_OFFLINE", "MOSTRA_REMOTE_QUEUE_FULL", "MOSTRA_REMOTE_NOT_OWNER_INSTANCE", "MOSTRA_REMOTE_SIGN_IN_REQUIRED", "MOSTRA_REMOTE_RATE_LIMITED", "MOSTRA_REMOTE_PAUSED_BY_OPERATOR", "MOSTRA_REMOTE_LIMIT_REACHED", "MOSTRA_REMOTE_OPERATOR_UNAVAILABLE", "MOSTRA_REMOTE_NO_INSTANCE", "MOSTRA_REMOTE_UNDER_REVIEW", "MOSTRA_REMOTE_HOME_SUSPENDED", "MOSTRA_REMOTE_HOME_MOVING"];
|
|
5
5
|
/** The codes of the REMOTE area. */
|
|
6
6
|
export type RemoteDiagnosticCode = (typeof remoteDiagnosticCodes)[number];
|
|
7
7
|
//#endregion
|