@mostra/protocol 0.6.2 → 0.8.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.
Files changed (73) hide show
  1. package/dist/actions.d.ts +12 -0
  2. package/dist/actions.d.ts.map +1 -1
  3. package/dist/actions.js.map +1 -1
  4. package/dist/bridge.d.ts +25 -0
  5. package/dist/bridge.d.ts.map +1 -1
  6. package/dist/bridge.js +32 -2
  7. package/dist/bridge.js.map +1 -1
  8. package/dist/browser.d.ts +76 -0
  9. package/dist/browser.d.ts.map +1 -1
  10. package/dist/browser.js +45 -2
  11. package/dist/browser.js.map +1 -1
  12. package/dist/diagnostics/codes/hygiene.d.ts +1 -1
  13. package/dist/diagnostics/codes/hygiene.d.ts.map +1 -1
  14. package/dist/diagnostics/codes/hygiene.js +12 -1
  15. package/dist/diagnostics/codes/hygiene.js.map +1 -1
  16. package/dist/diagnostics/codes/index.d.ts +3 -2
  17. package/dist/diagnostics/codes/index.d.ts.map +1 -1
  18. package/dist/diagnostics/codes/index.js +3 -1
  19. package/dist/diagnostics/codes/index.js.map +1 -1
  20. package/dist/diagnostics/codes/share.d.ts +8 -0
  21. package/dist/diagnostics/codes/share.d.ts.map +1 -0
  22. package/dist/diagnostics/codes/share.js +88 -0
  23. package/dist/diagnostics/codes/share.js.map +1 -0
  24. package/dist/hygiene.d.ts.map +1 -1
  25. package/dist/hygiene.js +2 -1
  26. package/dist/hygiene.js.map +1 -1
  27. package/dist/ids.d.ts +5 -1
  28. package/dist/ids.d.ts.map +1 -1
  29. package/dist/ids.js +3 -1
  30. package/dist/ids.js.map +1 -1
  31. package/dist/index.d.ts +10 -5
  32. package/dist/index.js +9 -4
  33. package/dist/methods/index.d.ts.map +1 -1
  34. package/dist/methods/index.js +9 -1
  35. package/dist/methods/index.js.map +1 -1
  36. package/dist/methods/instance/status.d.ts +24 -0
  37. package/dist/methods/instance/status.d.ts.map +1 -1
  38. package/dist/methods/instance/status.js +11 -2
  39. package/dist/methods/instance/status.js.map +1 -1
  40. package/dist/methods/port/addressing-external-base.d.ts +52 -0
  41. package/dist/methods/port/addressing-external-base.d.ts.map +1 -0
  42. package/dist/methods/port/addressing-external-base.js +61 -0
  43. package/dist/methods/port/addressing-external-base.js.map +1 -0
  44. package/dist/methods/share/list.d.ts +23 -0
  45. package/dist/methods/share/list.d.ts.map +1 -0
  46. package/dist/methods/share/list.js +29 -0
  47. package/dist/methods/share/list.js.map +1 -0
  48. package/dist/methods/share/start.d.ts +96 -0
  49. package/dist/methods/share/start.d.ts.map +1 -0
  50. package/dist/methods/share/start.js +73 -0
  51. package/dist/methods/share/start.js.map +1 -0
  52. package/dist/methods/share/stop.d.ts +29 -0
  53. package/dist/methods/share/stop.d.ts.map +1 -0
  54. package/dist/methods/share/stop.js +32 -0
  55. package/dist/methods/share/stop.js.map +1 -0
  56. package/package.json +2 -2
  57. package/schemas/protocol.draft-07.json +535 -0
  58. package/schemas/protocol.schema.json +507 -0
  59. package/src/actions.ts +12 -0
  60. package/src/bridge.ts +49 -0
  61. package/src/browser.ts +118 -0
  62. package/src/diagnostics/codes/hygiene.ts +12 -0
  63. package/src/diagnostics/codes/index.ts +6 -2
  64. package/src/diagnostics/codes/share.ts +100 -0
  65. package/src/hygiene.ts +1 -0
  66. package/src/ids.ts +9 -1
  67. package/src/index.ts +39 -0
  68. package/src/methods/index.ts +8 -0
  69. package/src/methods/instance/status.ts +38 -0
  70. package/src/methods/port/addressing-external-base.ts +113 -0
  71. package/src/methods/share/list.ts +42 -0
  72. package/src/methods/share/start.ts +150 -0
  73. package/src/methods/share/stop.ts +50 -0
@@ -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\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 })\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// ── 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,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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
+ {"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 * `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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AC;;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/hygiene.d.ts
3
3
  /** The codes of the HYGIENE area, in the order they were added. */
4
- export declare const hygieneDiagnosticCodes: readonly ["MOSTRA_HYGIENE_HOST_REFUSED", "MOSTRA_HYGIENE_ORIGIN_REFUSED", "MOSTRA_HYGIENE_CSRF_MISSING", "MOSTRA_HYGIENE_CONTENT_TYPE", "MOSTRA_HYGIENE_REQUEST_MALFORMED", "MOSTRA_HYGIENE_SESSION_MISSING", "MOSTRA_HYGIENE_TOKEN_INVALID", "MOSTRA_HYGIENE_TOKEN_REVOKED", "MOSTRA_HYGIENE_SCOPE_DENIED", "MOSTRA_HYGIENE_RATE_LIMITED", "MOSTRA_HYGIENE_NOT_SERVED", "MOSTRA_HYGIENE_SESSION_CONFLICT", "MOSTRA_HYGIENE_HEADERS_TOO_LARGE"];
4
+ export declare const hygieneDiagnosticCodes: readonly ["MOSTRA_HYGIENE_HOST_REFUSED", "MOSTRA_HYGIENE_ORIGIN_REFUSED", "MOSTRA_HYGIENE_CSRF_MISSING", "MOSTRA_HYGIENE_CONTENT_TYPE", "MOSTRA_HYGIENE_REQUEST_MALFORMED", "MOSTRA_HYGIENE_SESSION_MISSING", "MOSTRA_HYGIENE_TOKEN_INVALID", "MOSTRA_HYGIENE_TOKEN_REVOKED", "MOSTRA_HYGIENE_SCOPE_DENIED", "MOSTRA_HYGIENE_RATE_LIMITED", "MOSTRA_HYGIENE_NOT_SERVED", "MOSTRA_HYGIENE_SESSION_CONFLICT", "MOSTRA_HYGIENE_HEADERS_TOO_LARGE", "MOSTRA_HYGIENE_FRAME_SESSION"];
5
5
  /** The codes of the HYGIENE area. */
6
6
  export type HygieneDiagnosticCode = (typeof hygieneDiagnosticCodes)[number];
7
7
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"hygiene.d.ts","names":[],"sources":["../../../src/diagnostics/codes/hygiene.ts"],"mappings":";;;qBAQa;;YAkBD,gCAAgC"}
1
+ {"version":3,"file":"hygiene.d.ts","names":[],"sources":["../../../src/diagnostics/codes/hygiene.ts"],"mappings":";;;qBAQa;;YAmBD,gCAAgC"}
@@ -13,7 +13,8 @@ const hygieneDiagnosticCodes = [
13
13
  "MOSTRA_HYGIENE_RATE_LIMITED",
14
14
  "MOSTRA_HYGIENE_NOT_SERVED",
15
15
  "MOSTRA_HYGIENE_SESSION_CONFLICT",
16
- "MOSTRA_HYGIENE_HEADERS_TOO_LARGE"
16
+ "MOSTRA_HYGIENE_HEADERS_TOO_LARGE",
17
+ "MOSTRA_HYGIENE_FRAME_SESSION"
17
18
  ];
18
19
  /** The HYGIENE area's catalog entries. */
19
20
  const hygieneDiagnostics = {
@@ -146,6 +147,16 @@ const hygieneDiagnostics = {
146
147
  explanation: "The request's headers passed the gateway's limit of 1 MiB, more than any browser sends for one host's cookies. Every port of the loopback host shares one cookie jar, so a page on any of them can fill it. The gateway answers 431 with `Clear-Site-Data: \"cookies\"`, which empties the host's cookies, so the next request works. Mostra's sessions go with them and come back when a link is opened again.",
147
148
  fix: "Open the artifact's link again. If it keeps happening, find the page that sets the cookies: it runs on this host."
148
149
  }
150
+ },
151
+ MOSTRA_HYGIENE_FRAME_SESSION: {
152
+ severity: "error",
153
+ phase: "hygiene",
154
+ title: "Frame session couldn't start",
155
+ hint: "Open the artifact's tailnet or Funnel link, or this link in a normal window of another browser.",
156
+ docs: {
157
+ explanation: "Where the shell and the artifact are two sites (a Cloudflare quick tunnel, or a host's addresses on two hosts), the artifact's frame can't use a cookie: it enters through a bootstrap page that installs Mostra's service worker at `/`, which signs every request of the frame (worker mode, D70). Mostra reports this code when that can't happen: the browser offers the frame no service worker (a private window, a setting that blocks third-party storage), refuses to install it, or the gateway refused the frame's entry. The client runtime reports it too when the artifact's own code registers another service worker at `/`, which would replace Mostra's and end the frame's session.",
158
+ fix: "Open the artifact through a tailnet or Funnel share, where the frame uses a cookie, or in a browser window that allows service workers in frames. An artifact that needs its own service worker registers it at a narrower scope than `/`."
159
+ }
149
160
  }
150
161
  };
151
162
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"hygiene.js","names":[],"sources":["../../../src/diagnostics/codes/hygiene.ts"],"sourcesContent":["/**\n * Diagnostic codes of the HYGIENE area: requests the gateway refuses because they don't come from\n * the holder of an artifact's capability URL (D06, HY-01). None of them limits what an artifact\n * or an agent may do; each keeps strangers out.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the HYGIENE area, in the order they were added. */\nexport const hygieneDiagnosticCodes = [\n \"MOSTRA_HYGIENE_HOST_REFUSED\",\n \"MOSTRA_HYGIENE_ORIGIN_REFUSED\",\n \"MOSTRA_HYGIENE_CSRF_MISSING\",\n \"MOSTRA_HYGIENE_CONTENT_TYPE\",\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n \"MOSTRA_HYGIENE_SESSION_MISSING\",\n \"MOSTRA_HYGIENE_TOKEN_INVALID\",\n \"MOSTRA_HYGIENE_TOKEN_REVOKED\",\n \"MOSTRA_HYGIENE_SCOPE_DENIED\",\n \"MOSTRA_HYGIENE_RATE_LIMITED\",\n \"MOSTRA_HYGIENE_NOT_SERVED\",\n \"MOSTRA_HYGIENE_SESSION_CONFLICT\",\n \"MOSTRA_HYGIENE_HEADERS_TOO_LARGE\",\n // gen:codes\n] as const;\n\n/** The codes of the HYGIENE area. */\nexport type HygieneDiagnosticCode = (typeof hygieneDiagnosticCodes)[number];\n\n/** The HYGIENE area's catalog entries. */\nexport const hygieneDiagnostics: AreaCatalog<HygieneDiagnosticCode> = {\n MOSTRA_HYGIENE_HOST_REFUSED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Host not served\",\n hint: \"Open the artifact through the exact link Mostra gave you.\",\n docs: {\n explanation:\n \"The request's `Host` header named a host this gateway doesn't serve. Each gateway listener accepts exactly the host and port its capability URLs use, so a page that rebinds its own DNS name to the loopback address can't reach an artifact (DNS rebinding). The gateway answers 421.\",\n fix: \"Use the URL from `view/url` or the publish receipt as it is, without replacing `127.0.0.1` by `localhost` or another name. A gateway started with `--bind` and `--url-host` accepts the URL host it was given.\",\n },\n },\n MOSTRA_HYGIENE_ORIGIN_REFUSED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Origin refused\",\n hint: \"Send the request from the page's own origin.\",\n docs: {\n explanation:\n \"A request that changes state, opens a stream or upgrades to a WebSocket must carry an `Origin` header equal to the origin it is sent to. The gateway compares the strings exactly and answers 403 otherwise, so another website, or another artifact on a different port, can't drive this one.\",\n fix: \"Call the gateway from the page it serves: the shell from the shell, the artifact from its own frame. Tools outside a browser send the listener's own origin.\",\n },\n },\n MOSTRA_HYGIENE_CSRF_MISSING: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"CSRF token missing or wrong\",\n hint: \"Send the session's CSRF token from `GET /_mostra/session` in the `X-Mostra-CSRF` header.\",\n docs: {\n explanation:\n \"Every request that changes state through a session carries the session's CSRF token in the `X-Mostra-CSRF` header. The token comes only from the session endpoint of the same origin, which no other page can read. A missing or different token is answered with 403.\",\n fix: \"Read `csrf` from `GET /_mostra/session` (on the shell, `GET /a/<artifactId>/_mostra/session`) and send it with every POST. Mostra's client runtime and shell do this for you.\",\n },\n },\n MOSTRA_HYGIENE_CONTENT_TYPE: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"JSON content type required\",\n hint: \"Send the body as JSON with `Content-Type: application/json`.\",\n docs: {\n explanation:\n \"Requests that change state must have a JSON body. A form or plain-text body is something any website can send without asking the browser first, so the gateway refuses it with 415.\",\n fix: \"Send `Content-Type: application/json` and a JSON body.\",\n },\n },\n MOSTRA_HYGIENE_REQUEST_MALFORMED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Malformed request\",\n hint: \"Send one well-formed HTTP request with a path that starts with `/`.\",\n docs: {\n explanation:\n \"The gateway refused a request it can't interpret safely: a repeated `Host` or `Origin` header, a request target that isn't a path, an encoded `/` or `..` that would leave the served tree, a body that isn't valid JSON, or a header with control characters. It answers 400 rather than guess.\",\n fix: \"Send a single request with one `Host` header and a plain path. Browsers always do; this usually means a hand-written client or a probe.\",\n },\n },\n MOSTRA_HYGIENE_SESSION_MISSING: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"No session\",\n hint: \"Open the artifact's capability link again to start a session.\",\n docs: {\n explanation:\n \"The request carried no valid session for this origin. Sessions start when a capability link is opened: the shell exchanges the link's token for a session cookie, and gives the artifact frame a single-use ticket for its own. A session issued for another origin never counts, because every port of the host shares the browser's cookies. The gateway answers 401.\",\n fix: \"Open the full capability link, including the part after `#`. A bookmark of the page without it works while the browser keeps the session cookie (400 days).\",\n },\n },\n MOSTRA_HYGIENE_TOKEN_INVALID: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Unknown capability token\",\n hint: \"Use the complete capability link Mostra gave you, or mint a new one with `view/url`.\",\n docs: {\n explanation:\n \"The capability token or frame ticket matched nothing in this home: it was mistyped, cut short, belongs to another home or artifact, or the ticket was already used or expired (tickets last 60 seconds and work once). Over the host protocol, the token ID named in `view/revoke` or `view/rotate` doesn't exist. The gateway answers 401, and failed attempts count towards the rate limit.\",\n fix: \"Copy the whole link again. An agent or host mints a fresh one with `view/url`; the shell gets a new frame ticket by reloading.\",\n },\n },\n MOSTRA_HYGIENE_TOKEN_REVOKED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Link revoked or expired\",\n hint: \"Ask for a new link: `view/url` mints one, or `view/rotate` replaces this one.\",\n docs: {\n explanation:\n \"The capability link was revoked (`view/revoke`), replaced (`view/rotate`), or reached the end of its `ttl`. Every session started from it ends too. The gateway answers 410. Local links have no expiry unless one was asked for.\",\n fix: \"Get a new link from whoever shared this one. An agent mints it with `view/url`, or rotates the old one with `view/rotate`, and shares the new URL.\",\n },\n },\n MOSTRA_HYGIENE_SCOPE_DENIED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Not allowed by this link\",\n hint: \"Open a link minted with this scope (`view/url` with `scopes`).\",\n docs: {\n explanation:\n \"The session's link doesn't carry the scope this request needs: `draft` to save answers, `submit` to submit, `review` to comment, and `action:*`, `action:<export>` or `action:<module path>#<export>` to run a server function. A view-and-comment link, for example, can't submit or run an action. The gateway answers 403.\",\n fix: 'Mint a link with the scopes the viewer needs, such as `view/url` with `scopes: [\"view\", \"draft\", \"submit\"]`. Without `scopes`, a link carries every scope.',\n },\n },\n MOSTRA_HYGIENE_RATE_LIMITED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Too many failed attempts\",\n hint: \"Wait for the time in `Retry-After`, then open the link again.\",\n docs: {\n explanation:\n \"More than 30 capability tokens failed for this artifact within a minute, so the gateway refuses every token for it, valid ones included, until the minute has passed. A guess can't succeed while the limit holds, and only this artifact's links wait. The gateway answers 429 with `Retry-After`.\",\n fix: \"Wait, then open the link again. Repeated failures usually come from a mistyped link or a script retrying an old one.\",\n },\n },\n MOSTRA_HYGIENE_NOT_SERVED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Nothing served here\",\n hint: \"Request a published version's files or a documented `/_mostra/` path.\",\n docs: {\n explanation:\n \"The gateway serves only published versions' client files and the browser-protocol paths under `/_mostra/`. Everything else in the home, such as sources, server bundles, staging and unpublished builds, has no URL. A path or method nothing answers gets 404 or 405.\",\n fix: \"Check the path. Server code runs through the browser protocol, never as a file, and an artifact becomes viewable only once it is published.\",\n },\n },\n MOSTRA_HYGIENE_SESSION_CONFLICT: {\n severity: \"warning\",\n phase: \"hygiene\",\n title: \"Another link is already open for this artifact\",\n hint: \"Choose which link to keep; send `replace: true` to use the new one.\",\n docs: {\n explanation:\n \"This browser already has a live session for the artifact from a different link. Opening a link never silently replaces it, because a page elsewhere could send the viewer to its own, narrower link and take over their tabs (D98). The shell shows both links' access and lets the viewer choose; the answer is 409 with `current` and `offered`.\",\n fix: \"In the shell, choose the link to keep. A client exchanging tokens itself sends `replace: true` to replace the session.\",\n },\n },\n MOSTRA_HYGIENE_HEADERS_TOO_LARGE: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"The request's headers are too large\",\n hint: \"Open the link again: this page cleared the cookies that made the request too large.\",\n docs: {\n explanation:\n \"The request's headers passed the gateway's limit of 1 MiB, more than any browser sends for one host's cookies. Every port of the loopback host shares one cookie jar, so a page on any of them can fill it. The gateway answers 431 with `Clear-Site-Data: \\\"cookies\\\"`, which empties the host's cookies, so the next request works. Mostra's sessions go with them and come back when a link is opened again.\",\n fix: \"Open the artifact's link again. If it keeps happening, find the page that sets the cookies: it runs on this host.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAQA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,qBAAyD;CACpE,6BAA6B;EAC3B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,+BAA+B;EAC7B,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,kCAAkC;EAChC,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,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,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,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,iCAAiC;EAC/B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,kCAAkC;EAChC,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;AAEF"}
1
+ {"version":3,"file":"hygiene.js","names":[],"sources":["../../../src/diagnostics/codes/hygiene.ts"],"sourcesContent":["/**\n * Diagnostic codes of the HYGIENE area: requests the gateway refuses because they don't come from\n * the holder of an artifact's capability URL (D06, HY-01). None of them limits what an artifact\n * or an agent may do; each keeps strangers out.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the HYGIENE area, in the order they were added. */\nexport const hygieneDiagnosticCodes = [\n \"MOSTRA_HYGIENE_HOST_REFUSED\",\n \"MOSTRA_HYGIENE_ORIGIN_REFUSED\",\n \"MOSTRA_HYGIENE_CSRF_MISSING\",\n \"MOSTRA_HYGIENE_CONTENT_TYPE\",\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n \"MOSTRA_HYGIENE_SESSION_MISSING\",\n \"MOSTRA_HYGIENE_TOKEN_INVALID\",\n \"MOSTRA_HYGIENE_TOKEN_REVOKED\",\n \"MOSTRA_HYGIENE_SCOPE_DENIED\",\n \"MOSTRA_HYGIENE_RATE_LIMITED\",\n \"MOSTRA_HYGIENE_NOT_SERVED\",\n \"MOSTRA_HYGIENE_SESSION_CONFLICT\",\n \"MOSTRA_HYGIENE_HEADERS_TOO_LARGE\",\n \"MOSTRA_HYGIENE_FRAME_SESSION\",\n // gen:codes\n] as const;\n\n/** The codes of the HYGIENE area. */\nexport type HygieneDiagnosticCode = (typeof hygieneDiagnosticCodes)[number];\n\n/** The HYGIENE area's catalog entries. */\nexport const hygieneDiagnostics: AreaCatalog<HygieneDiagnosticCode> = {\n MOSTRA_HYGIENE_HOST_REFUSED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Host not served\",\n hint: \"Open the artifact through the exact link Mostra gave you.\",\n docs: {\n explanation:\n \"The request's `Host` header named a host this gateway doesn't serve. Each gateway listener accepts exactly the host and port its capability URLs use, so a page that rebinds its own DNS name to the loopback address can't reach an artifact (DNS rebinding). The gateway answers 421.\",\n fix: \"Use the URL from `view/url` or the publish receipt as it is, without replacing `127.0.0.1` by `localhost` or another name. A gateway started with `--bind` and `--url-host` accepts the URL host it was given.\",\n },\n },\n MOSTRA_HYGIENE_ORIGIN_REFUSED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Origin refused\",\n hint: \"Send the request from the page's own origin.\",\n docs: {\n explanation:\n \"A request that changes state, opens a stream or upgrades to a WebSocket must carry an `Origin` header equal to the origin it is sent to. The gateway compares the strings exactly and answers 403 otherwise, so another website, or another artifact on a different port, can't drive this one.\",\n fix: \"Call the gateway from the page it serves: the shell from the shell, the artifact from its own frame. Tools outside a browser send the listener's own origin.\",\n },\n },\n MOSTRA_HYGIENE_CSRF_MISSING: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"CSRF token missing or wrong\",\n hint: \"Send the session's CSRF token from `GET /_mostra/session` in the `X-Mostra-CSRF` header.\",\n docs: {\n explanation:\n \"Every request that changes state through a session carries the session's CSRF token in the `X-Mostra-CSRF` header. The token comes only from the session endpoint of the same origin, which no other page can read. A missing or different token is answered with 403.\",\n fix: \"Read `csrf` from `GET /_mostra/session` (on the shell, `GET /a/<artifactId>/_mostra/session`) and send it with every POST. Mostra's client runtime and shell do this for you.\",\n },\n },\n MOSTRA_HYGIENE_CONTENT_TYPE: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"JSON content type required\",\n hint: \"Send the body as JSON with `Content-Type: application/json`.\",\n docs: {\n explanation:\n \"Requests that change state must have a JSON body. A form or plain-text body is something any website can send without asking the browser first, so the gateway refuses it with 415.\",\n fix: \"Send `Content-Type: application/json` and a JSON body.\",\n },\n },\n MOSTRA_HYGIENE_REQUEST_MALFORMED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Malformed request\",\n hint: \"Send one well-formed HTTP request with a path that starts with `/`.\",\n docs: {\n explanation:\n \"The gateway refused a request it can't interpret safely: a repeated `Host` or `Origin` header, a request target that isn't a path, an encoded `/` or `..` that would leave the served tree, a body that isn't valid JSON, or a header with control characters. It answers 400 rather than guess.\",\n fix: \"Send a single request with one `Host` header and a plain path. Browsers always do; this usually means a hand-written client or a probe.\",\n },\n },\n MOSTRA_HYGIENE_SESSION_MISSING: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"No session\",\n hint: \"Open the artifact's capability link again to start a session.\",\n docs: {\n explanation:\n \"The request carried no valid session for this origin. Sessions start when a capability link is opened: the shell exchanges the link's token for a session cookie, and gives the artifact frame a single-use ticket for its own. A session issued for another origin never counts, because every port of the host shares the browser's cookies. The gateway answers 401.\",\n fix: \"Open the full capability link, including the part after `#`. A bookmark of the page without it works while the browser keeps the session cookie (400 days).\",\n },\n },\n MOSTRA_HYGIENE_TOKEN_INVALID: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Unknown capability token\",\n hint: \"Use the complete capability link Mostra gave you, or mint a new one with `view/url`.\",\n docs: {\n explanation:\n \"The capability token or frame ticket matched nothing in this home: it was mistyped, cut short, belongs to another home or artifact, or the ticket was already used or expired (tickets last 60 seconds and work once). Over the host protocol, the token ID named in `view/revoke` or `view/rotate` doesn't exist. The gateway answers 401, and failed attempts count towards the rate limit.\",\n fix: \"Copy the whole link again. An agent or host mints a fresh one with `view/url`; the shell gets a new frame ticket by reloading.\",\n },\n },\n MOSTRA_HYGIENE_TOKEN_REVOKED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Link revoked or expired\",\n hint: \"Ask for a new link: `view/url` mints one, or `view/rotate` replaces this one.\",\n docs: {\n explanation:\n \"The capability link was revoked (`view/revoke`), replaced (`view/rotate`), or reached the end of its `ttl`. Every session started from it ends too. The gateway answers 410. Local links have no expiry unless one was asked for.\",\n fix: \"Get a new link from whoever shared this one. An agent mints it with `view/url`, or rotates the old one with `view/rotate`, and shares the new URL.\",\n },\n },\n MOSTRA_HYGIENE_SCOPE_DENIED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Not allowed by this link\",\n hint: \"Open a link minted with this scope (`view/url` with `scopes`).\",\n docs: {\n explanation:\n \"The session's link doesn't carry the scope this request needs: `draft` to save answers, `submit` to submit, `review` to comment, and `action:*`, `action:<export>` or `action:<module path>#<export>` to run a server function. A view-and-comment link, for example, can't submit or run an action. The gateway answers 403.\",\n fix: 'Mint a link with the scopes the viewer needs, such as `view/url` with `scopes: [\"view\", \"draft\", \"submit\"]`. Without `scopes`, a link carries every scope.',\n },\n },\n MOSTRA_HYGIENE_RATE_LIMITED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Too many failed attempts\",\n hint: \"Wait for the time in `Retry-After`, then open the link again.\",\n docs: {\n explanation:\n \"More than 30 capability tokens failed for this artifact within a minute, so the gateway refuses every token for it, valid ones included, until the minute has passed. A guess can't succeed while the limit holds, and only this artifact's links wait. The gateway answers 429 with `Retry-After`.\",\n fix: \"Wait, then open the link again. Repeated failures usually come from a mistyped link or a script retrying an old one.\",\n },\n },\n MOSTRA_HYGIENE_NOT_SERVED: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Nothing served here\",\n hint: \"Request a published version's files or a documented `/_mostra/` path.\",\n docs: {\n explanation:\n \"The gateway serves only published versions' client files and the browser-protocol paths under `/_mostra/`. Everything else in the home, such as sources, server bundles, staging and unpublished builds, has no URL. A path or method nothing answers gets 404 or 405.\",\n fix: \"Check the path. Server code runs through the browser protocol, never as a file, and an artifact becomes viewable only once it is published.\",\n },\n },\n MOSTRA_HYGIENE_SESSION_CONFLICT: {\n severity: \"warning\",\n phase: \"hygiene\",\n title: \"Another link is already open for this artifact\",\n hint: \"Choose which link to keep; send `replace: true` to use the new one.\",\n docs: {\n explanation:\n \"This browser already has a live session for the artifact from a different link. Opening a link never silently replaces it, because a page elsewhere could send the viewer to its own, narrower link and take over their tabs (D98). The shell shows both links' access and lets the viewer choose; the answer is 409 with `current` and `offered`.\",\n fix: \"In the shell, choose the link to keep. A client exchanging tokens itself sends `replace: true` to replace the session.\",\n },\n },\n MOSTRA_HYGIENE_HEADERS_TOO_LARGE: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"The request's headers are too large\",\n hint: \"Open the link again: this page cleared the cookies that made the request too large.\",\n docs: {\n explanation:\n \"The request's headers passed the gateway's limit of 1 MiB, more than any browser sends for one host's cookies. Every port of the loopback host shares one cookie jar, so a page on any of them can fill it. The gateway answers 431 with `Clear-Site-Data: \\\"cookies\\\"`, which empties the host's cookies, so the next request works. Mostra's sessions go with them and come back when a link is opened again.\",\n fix: \"Open the artifact's link again. If it keeps happening, find the page that sets the cookies: it runs on this host.\",\n },\n },\n MOSTRA_HYGIENE_FRAME_SESSION: {\n severity: \"error\",\n phase: \"hygiene\",\n title: \"Frame session couldn't start\",\n hint: \"Open the artifact's tailnet or Funnel link, or this link in a normal window of another browser.\",\n docs: {\n explanation:\n \"Where the shell and the artifact are two sites (a Cloudflare quick tunnel, or a host's addresses on two hosts), the artifact's frame can't use a cookie: it enters through a bootstrap page that installs Mostra's service worker at `/`, which signs every request of the frame (worker mode, D70). Mostra reports this code when that can't happen: the browser offers the frame no service worker (a private window, a setting that blocks third-party storage), refuses to install it, or the gateway refused the frame's entry. The client runtime reports it too when the artifact's own code registers another service worker at `/`, which would replace Mostra's and end the frame's session.\",\n fix: \"Open the artifact through a tailnet or Funnel share, where the frame uses a cookie, or in a browser window that allows service workers in frames. An artifact that needs its own service worker registers it at a narrower scope than `/`.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAQA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,qBAAyD;CACpE,6BAA6B;EAC3B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,+BAA+B;EAC7B,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,kCAAkC;EAChC,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,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,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,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,iCAAiC;EAC/B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,kCAAkC;EAChC,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;AAEF"}
@@ -20,6 +20,7 @@ import { PublishDiagnosticCode, publishDiagnosticCodes } from "./publish.js";
20
20
  import { RegressionDiagnosticCode, regressionDiagnosticCodes } from "./regression.js";
21
21
  import { RuntimeDiagnosticCode, runtimeDiagnosticCodes } from "./runtime.js";
22
22
  import { SecretDiagnosticCode, secretDiagnosticCodes } from "./secret.js";
23
+ import { ShareDiagnosticCode, shareDiagnosticCodes } from "./share.js";
23
24
  import { SmokeDiagnosticCode, smokeDiagnosticCodes } from "./smoke.js";
24
25
  import { SubmitDiagnosticCode, submitDiagnosticCodes } from "./submit.js";
25
26
  import { TargetDiagnosticCode, targetDiagnosticCodes } from "./target.js";
@@ -27,7 +28,7 @@ import { TypeDiagnosticCode, typeDiagnosticCodes } from "./type.js";
27
28
  import { VerifyDiagnosticCode, verifyDiagnosticCodes } from "./verify.js";
28
29
  //#region src/diagnostics/codes/index.d.ts
29
30
  /** Every code in the catalog. Codes are semver surface and are never removed (AX-03). */
30
- export type KnownDiagnosticCode = 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;
31
+ export type KnownDiagnosticCode = 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;
31
32
  /** Every cataloged code with its severity, phase, title, default hint and docs text. */
32
33
  export declare const diagnosticCatalog: Readonly<Record<KnownDiagnosticCode, DiagnosticSpec>>;
33
34
  /** Options for {@link createDiagnostic}. */
@@ -47,5 +48,5 @@ export interface CreateDiagnosticOptions {
47
48
  */
48
49
  export declare function createDiagnostic(code: KnownDiagnosticCode, details: DiagnosticDetails, options?: CreateDiagnosticOptions): Diagnostic;
49
50
  //#endregion
50
- 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 RuntimeDiagnosticCode, type SecretDiagnosticCode, 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, runtimeDiagnosticCodes, secretDiagnosticCodes, smokeDiagnosticCodes, submitDiagnosticCodes, targetDiagnosticCodes, typeDiagnosticCodes, verifyDiagnosticCodes };
51
+ 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 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, runtimeDiagnosticCodes, secretDiagnosticCodes, shareDiagnosticCodes, smokeDiagnosticCodes, submitDiagnosticCodes, targetDiagnosticCodes, typeDiagnosticCodes, verifyDiagnosticCodes };
51
52
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/diagnostics/codes/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA6DY,sBAER,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;;iBA8BpD;;WAEN;;;;;;;;;;;;wBAaK,iBACd,MAAM,qBACN,SAAS,mBACT,UAAS,0BACR"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/diagnostics/codes/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA+DY,sBAER,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;;iBA+BpD;;WAEN;;;;;;;;;;;;wBAaK,iBACd,MAAM,qBACN,SAAS,mBACT,UAAS,0BACR"}
@@ -19,6 +19,7 @@ import { publishDiagnosticCodes, publishDiagnostics } from "./publish.js";
19
19
  import { regressionDiagnosticCodes, regressionDiagnostics } from "./regression.js";
20
20
  import { runtimeDiagnosticCodes, runtimeDiagnostics } from "./runtime.js";
21
21
  import { secretDiagnosticCodes, secretDiagnostics } from "./secret.js";
22
+ import { shareDiagnosticCodes, shareDiagnostics } from "./share.js";
22
23
  import { smokeDiagnosticCodes, smokeDiagnostics } from "./smoke.js";
23
24
  import { submitDiagnosticCodes, submitDiagnostics } from "./submit.js";
24
25
  import { targetDiagnosticCodes, targetDiagnostics } from "./target.js";
@@ -27,6 +28,7 @@ import { verifyDiagnosticCodes, verifyDiagnostics } from "./verify.js";
27
28
  //#region src/diagnostics/codes/index.ts
28
29
  /** Every cataloged code with its severity, phase, title, default hint and docs text. */
29
30
  const diagnosticCatalog = {
31
+ ...shareDiagnostics,
30
32
  ...cliDiagnostics,
31
33
  ...regressionDiagnostics,
32
34
  ...smokeDiagnostics,
@@ -67,6 +69,6 @@ function createDiagnostic(code, details, options = {}) {
67
69
  return buildDiagnostic(code, diagnosticCatalog[code], details, options.docsBase);
68
70
  }
69
71
  //#endregion
70
- export { a11yDiagnosticCodes, actionDiagnosticCodes, artifactDiagnosticCodes, buildDiagnosticCodes, cliDiagnosticCodes, consoleDiagnosticCodes, createDiagnostic, depDiagnosticCodes, diagnosticCatalog, envDiagnosticCodes, fieldDiagnosticCodes, homeDiagnosticCodes, hostDiagnosticCodes, hygieneDiagnosticCodes, liveDiagnosticCodes, manifestDiagnosticCodes, networkDiagnosticCodes, platformDiagnosticCodes, publishDiagnosticCodes, regressionDiagnosticCodes, runtimeDiagnosticCodes, secretDiagnosticCodes, smokeDiagnosticCodes, submitDiagnosticCodes, targetDiagnosticCodes, typeDiagnosticCodes, verifyDiagnosticCodes };
72
+ export { a11yDiagnosticCodes, actionDiagnosticCodes, artifactDiagnosticCodes, buildDiagnosticCodes, cliDiagnosticCodes, consoleDiagnosticCodes, createDiagnostic, depDiagnosticCodes, diagnosticCatalog, envDiagnosticCodes, fieldDiagnosticCodes, homeDiagnosticCodes, hostDiagnosticCodes, hygieneDiagnosticCodes, liveDiagnosticCodes, manifestDiagnosticCodes, networkDiagnosticCodes, platformDiagnosticCodes, publishDiagnosticCodes, regressionDiagnosticCodes, runtimeDiagnosticCodes, secretDiagnosticCodes, shareDiagnosticCodes, smokeDiagnosticCodes, submitDiagnosticCodes, targetDiagnosticCodes, typeDiagnosticCodes, verifyDiagnosticCodes };
71
73
 
72
74
  //# 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\";\n// gen:area-imports\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 RuntimeDiagnosticCode, runtimeDiagnostics } from \"./runtime.ts\";\nimport { type SecretDiagnosticCode, secretDiagnostics } from \"./secret.ts\";\nimport { type SmokeDiagnosticCode, smokeDiagnostics } from \"./smoke.ts\";\nimport { type SubmitDiagnosticCode, submitDiagnostics } from \"./submit.ts\";\nimport { type TargetDiagnosticCode, targetDiagnostics } from \"./target.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\";\n// gen:area-exports\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 RuntimeDiagnosticCode, runtimeDiagnosticCodes } from \"./runtime.ts\";\nexport { type SecretDiagnosticCode, secretDiagnosticCodes } from \"./secret.ts\";\nexport { type SmokeDiagnosticCode, smokeDiagnosticCodes } from \"./smoke.ts\";\nexport { type SubmitDiagnosticCode, submitDiagnosticCodes } from \"./submit.ts\";\nexport { type TargetDiagnosticCode, targetDiagnosticCodes } from \"./target.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 | 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 ...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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FA,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;AACL;;;;;;;;;;;AAkBA,SAAgB,iBACd,MACA,SACA,UAAmC,CAAC,GACxB;CACZ,OAAO,gBAAgB,MAAM,kBAAkB,OAAO,SAAS,QAAQ,QAAQ;AACjF"}
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 RuntimeDiagnosticCode, runtimeDiagnostics } from \"./runtime.ts\";\nimport { type SecretDiagnosticCode, secretDiagnostics } from \"./secret.ts\";\n// gen:area-imports\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\";\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 RuntimeDiagnosticCode, runtimeDiagnosticCodes } from \"./runtime.ts\";\nexport { type SecretDiagnosticCode, secretDiagnosticCodes } from \"./secret.ts\";\n// gen:area-exports\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\";\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 | 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 ...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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,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;AACL;;;;;;;;;;;AAkBA,SAAgB,iBACd,MACA,SACA,UAAmC,CAAC,GACxB;CACZ,OAAO,gBAAgB,MAAM,kBAAkB,OAAO,SAAS,QAAQ,QAAQ;AACjF"}
@@ -0,0 +1,8 @@
1
+ import "../spec.js";
2
+ //#region src/diagnostics/codes/share.d.ts
3
+ /** The codes of the SHARE area, in the order they were added. */
4
+ export declare const shareDiagnosticCodes: readonly ["MOSTRA_SHARE_TOOL_MISSING", "MOSTRA_SHARE_TOOL_NOT_READY", "MOSTRA_SHARE_NOT_ENABLED", "MOSTRA_SHARE_PORTS_EXHAUSTED", "MOSTRA_SHARE_TUNNEL_FAILED", "MOSTRA_SHARE_NOT_FOUND", "MOSTRA_SHARE_TTL_INVALID"];
5
+ /** The codes of the SHARE area. */
6
+ export type ShareDiagnosticCode = (typeof shareDiagnosticCodes)[number];
7
+ //#endregion
8
+ //# sourceMappingURL=share.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share.d.ts","names":[],"sources":["../../../src/diagnostics/codes/share.ts"],"mappings":";;;qBAMa;;YAYD,8BAA8B"}
@@ -0,0 +1,88 @@
1
+ //#region src/diagnostics/codes/share.ts
2
+ /** The codes of the SHARE area, in the order they were added. */
3
+ const shareDiagnosticCodes = [
4
+ "MOSTRA_SHARE_TOOL_MISSING",
5
+ "MOSTRA_SHARE_TOOL_NOT_READY",
6
+ "MOSTRA_SHARE_NOT_ENABLED",
7
+ "MOSTRA_SHARE_PORTS_EXHAUSTED",
8
+ "MOSTRA_SHARE_TUNNEL_FAILED",
9
+ "MOSTRA_SHARE_NOT_FOUND",
10
+ "MOSTRA_SHARE_TTL_INVALID"
11
+ ];
12
+ /** The SHARE area's catalog entries. */
13
+ const shareDiagnostics = {
14
+ MOSTRA_SHARE_TOOL_MISSING: {
15
+ severity: "error",
16
+ phase: "host",
17
+ title: "Sharing tool not installed",
18
+ hint: "Install the tool the message names, then run the share again.",
19
+ docs: {
20
+ explanation: "A share drives a tunnel tool installed on this machine: `tailscale` for tailnet and Funnel shares, `cloudflared` for Cloudflare quick tunnels. Mostra never bundles or downloads them; it found none where it looks (`PATH`, the tool's usual install locations, or `MOSTRA_TAILSCALE` and `MOSTRA_CLOUDFLARED`). The message says how to install it on this system.",
21
+ fix: "Install the tool (Tailscale from tailscale.com/download, `cloudflared` from Cloudflare's downloads or a package manager), or point `MOSTRA_TAILSCALE` or `MOSTRA_CLOUDFLARED` at it, then share again."
22
+ }
23
+ },
24
+ MOSTRA_SHARE_TOOL_NOT_READY: {
25
+ severity: "error",
26
+ phase: "host",
27
+ title: "Sharing tool not ready",
28
+ hint: "Do what the message says to the tool, then run the share again.",
29
+ docs: {
30
+ explanation: "The tunnel tool is installed but can't serve yet: Tailscale isn't running or isn't signed in to a tailnet, or `cloudflared` exited before it opened a tunnel. The message quotes what the tool reported.",
31
+ fix: "Start Tailscale and sign in (`tailscale up`), or check that `cloudflared` runs and this machine reaches Cloudflare, then share again."
32
+ }
33
+ },
34
+ MOSTRA_SHARE_NOT_ENABLED: {
35
+ severity: "error",
36
+ phase: "host",
37
+ title: "Sharing not enabled on the tailnet",
38
+ hint: "Open the address in the message as the tailnet's admin to turn the feature on, then run the share again.",
39
+ docs: {
40
+ explanation: "Tailscale Serve needs HTTPS certificates turned on for the tailnet, and Funnel needs the Funnel permission for this device. Tailscale refused the share and gave an address where an admin of the tailnet turns the feature on; the message carries it.",
41
+ fix: "Open the address as an admin of the tailnet and approve, then share again. Without admin rights, ask the tailnet's admin, or share publicly through a Cloudflare quick tunnel (`mostra share <artifact> --public`)."
42
+ }
43
+ },
44
+ MOSTRA_SHARE_PORTS_EXHAUSTED: {
45
+ severity: "error",
46
+ phase: "host",
47
+ title: "No tunnel port free",
48
+ hint: "Stop a share you no longer need (`mostra share list`, then `mostra share stop <share>`), or share through a Cloudflare quick tunnel.",
49
+ docs: {
50
+ explanation: "Tailscale Funnel listens only on ports 443, 8443 and 10000 of a device: Mostra gives 443 to the shell and the other two to one artifact each, so at most two artifacts are shared through Funnel at once. A port is also unavailable when this device's own Serve or Funnel configuration already uses it.",
51
+ fix: "Stop one of the Funnel shares, free the port in Tailscale's own configuration, or share this artifact through a Cloudflare quick tunnel."
52
+ }
53
+ },
54
+ MOSTRA_SHARE_TUNNEL_FAILED: {
55
+ severity: "error",
56
+ phase: "host",
57
+ title: "Tunnel failed",
58
+ hint: "Run the share again; if it fails the same way, check the tool's message and this machine's network.",
59
+ docs: {
60
+ explanation: "The tunnel tool started but didn't serve within its time, or stopped: the message quotes what it reported. A share whose tunnel ends and can't be set up again stops, and `mostra share list` shows why; a Cloudflare quick tunnel can't keep its address, so its share ends with it.",
61
+ fix: "Share again for a new link. A tailnet or Funnel share keeps its address across restarts of its tunnel; a Cloudflare quick tunnel gets a new one each time."
62
+ }
63
+ },
64
+ MOSTRA_SHARE_NOT_FOUND: {
65
+ severity: "error",
66
+ phase: "host",
67
+ title: "Unknown share",
68
+ hint: "List the home's shares with `mostra share list` and name one of them.",
69
+ docs: {
70
+ explanation: "No share of this home has the ID given, or the artifact has no share.",
71
+ fix: "Use a share ID from `mostra share list`."
72
+ }
73
+ },
74
+ MOSTRA_SHARE_TTL_INVALID: {
75
+ severity: "error",
76
+ phase: "host",
77
+ title: "Share lifetime refused",
78
+ hint: "Give a public share a lifetime of at most 7 days, such as `--ttl 24h`.",
79
+ docs: {
80
+ explanation: "A public share (Funnel or Cloudflare) admits anyone holding its link, so it lasts 1 hour unless `ttl` says otherwise, and at most 7 days. Tailnet shares have no limit.",
81
+ fix: "Use a `ttl` of 7 days or less, and share again when it ends, or share inside the tailnet."
82
+ }
83
+ }
84
+ };
85
+ //#endregion
86
+ export { shareDiagnosticCodes, shareDiagnostics };
87
+
88
+ //# sourceMappingURL=share.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share.js","names":[],"sources":["../../../src/diagnostics/codes/share.ts"],"sourcesContent":["/**\n * Diagnostic codes of the SHARE area.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the SHARE area, in the order they were added. */\nexport const shareDiagnosticCodes = [\n \"MOSTRA_SHARE_TOOL_MISSING\",\n \"MOSTRA_SHARE_TOOL_NOT_READY\",\n \"MOSTRA_SHARE_NOT_ENABLED\",\n \"MOSTRA_SHARE_PORTS_EXHAUSTED\",\n \"MOSTRA_SHARE_TUNNEL_FAILED\",\n \"MOSTRA_SHARE_NOT_FOUND\",\n \"MOSTRA_SHARE_TTL_INVALID\",\n // gen:codes\n] as const;\n\n/** The codes of the SHARE area. */\nexport type ShareDiagnosticCode = (typeof shareDiagnosticCodes)[number];\n\n/** The SHARE area's catalog entries. */\nexport const shareDiagnostics: AreaCatalog<ShareDiagnosticCode> = {\n MOSTRA_SHARE_TOOL_MISSING: {\n severity: \"error\",\n phase: \"host\",\n title: \"Sharing tool not installed\",\n hint: \"Install the tool the message names, then run the share again.\",\n docs: {\n explanation:\n \"A share drives a tunnel tool installed on this machine: `tailscale` for tailnet and Funnel shares, `cloudflared` for Cloudflare quick tunnels. Mostra never bundles or downloads them; it found none where it looks (`PATH`, the tool's usual install locations, or `MOSTRA_TAILSCALE` and `MOSTRA_CLOUDFLARED`). The message says how to install it on this system.\",\n fix: \"Install the tool (Tailscale from tailscale.com/download, `cloudflared` from Cloudflare's downloads or a package manager), or point `MOSTRA_TAILSCALE` or `MOSTRA_CLOUDFLARED` at it, then share again.\",\n },\n },\n MOSTRA_SHARE_TOOL_NOT_READY: {\n severity: \"error\",\n phase: \"host\",\n title: \"Sharing tool not ready\",\n hint: \"Do what the message says to the tool, then run the share again.\",\n docs: {\n explanation:\n \"The tunnel tool is installed but can't serve yet: Tailscale isn't running or isn't signed in to a tailnet, or `cloudflared` exited before it opened a tunnel. The message quotes what the tool reported.\",\n fix: \"Start Tailscale and sign in (`tailscale up`), or check that `cloudflared` runs and this machine reaches Cloudflare, then share again.\",\n },\n },\n MOSTRA_SHARE_NOT_ENABLED: {\n severity: \"error\",\n phase: \"host\",\n title: \"Sharing not enabled on the tailnet\",\n hint: \"Open the address in the message as the tailnet's admin to turn the feature on, then run the share again.\",\n docs: {\n explanation:\n \"Tailscale Serve needs HTTPS certificates turned on for the tailnet, and Funnel needs the Funnel permission for this device. Tailscale refused the share and gave an address where an admin of the tailnet turns the feature on; the message carries it.\",\n fix: \"Open the address as an admin of the tailnet and approve, then share again. Without admin rights, ask the tailnet's admin, or share publicly through a Cloudflare quick tunnel (`mostra share <artifact> --public`).\",\n },\n },\n MOSTRA_SHARE_PORTS_EXHAUSTED: {\n severity: \"error\",\n phase: \"host\",\n title: \"No tunnel port free\",\n hint: \"Stop a share you no longer need (`mostra share list`, then `mostra share stop <share>`), or share through a Cloudflare quick tunnel.\",\n docs: {\n explanation:\n \"Tailscale Funnel listens only on ports 443, 8443 and 10000 of a device: Mostra gives 443 to the shell and the other two to one artifact each, so at most two artifacts are shared through Funnel at once. A port is also unavailable when this device's own Serve or Funnel configuration already uses it.\",\n fix: \"Stop one of the Funnel shares, free the port in Tailscale's own configuration, or share this artifact through a Cloudflare quick tunnel.\",\n },\n },\n MOSTRA_SHARE_TUNNEL_FAILED: {\n severity: \"error\",\n phase: \"host\",\n title: \"Tunnel failed\",\n hint: \"Run the share again; if it fails the same way, check the tool's message and this machine's network.\",\n docs: {\n explanation:\n \"The tunnel tool started but didn't serve within its time, or stopped: the message quotes what it reported. A share whose tunnel ends and can't be set up again stops, and `mostra share list` shows why; a Cloudflare quick tunnel can't keep its address, so its share ends with it.\",\n fix: \"Share again for a new link. A tailnet or Funnel share keeps its address across restarts of its tunnel; a Cloudflare quick tunnel gets a new one each time.\",\n },\n },\n MOSTRA_SHARE_NOT_FOUND: {\n severity: \"error\",\n phase: \"host\",\n title: \"Unknown share\",\n hint: \"List the home's shares with `mostra share list` and name one of them.\",\n docs: {\n explanation: \"No share of this home has the ID given, or the artifact has no share.\",\n fix: \"Use a share ID from `mostra share list`.\",\n },\n },\n MOSTRA_SHARE_TTL_INVALID: {\n severity: \"error\",\n phase: \"host\",\n title: \"Share lifetime refused\",\n hint: \"Give a public share a lifetime of at most 7 days, such as `--ttl 24h`.\",\n docs: {\n explanation:\n \"A public share (Funnel or Cloudflare) admits anyone holding its link, so it lasts 1 hour unless `ttl` says otherwise, and at most 7 days. Tailnet shares have no limit.\",\n fix: \"Use a `ttl` of 7 days or less, and share again when it ends, or share inside the tailnet.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAMA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,mBAAqD;CAChE,2BAA2B;EACzB,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,0BAA0B;EACxB,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,4BAA4B;EAC1B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,wBAAwB;EACtB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aAAa;GACb,KAAK;EACP;CACF;CACA,0BAA0B;EACxB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;AAEF"}
@@ -1 +1 @@
1
- {"version":3,"file":"hygiene.d.ts","names":[],"sources":["../src/hygiene.ts"],"mappings":";;;;iBAoBiB;;WAEN;;WAEA;;;;;;;;;;;;YAaC;;iBAGK;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;WAET;;;iBAIM;;WAEN;;WAEA,YAAY;;;qBAIV;;wBAmBG,QAAQ,MAAM,uBAAuB,iBAAiB,kBAAkB;;wBAexE,UAAU,WAAW;;;;;;wBAcrB,SAAS;;wBAiBT,YACd,iDACA;;wBAOc,kBAAkB;;;;;;;wBAWlB,aAAa,QAAQ,eAAe,SAAS,eAAe"}
1
+ {"version":3,"file":"hygiene.d.ts","names":[],"sources":["../src/hygiene.ts"],"mappings":";;;;iBAoBiB;;WAEN;;WAEA;;;;;;;;;;;;YAaC;;iBAGK;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;WAET;;;iBAIM;;WAEN;;WAEA,YAAY;;;qBAIV;;wBAoBG,QAAQ,MAAM,uBAAuB,iBAAiB,kBAAkB;;wBAexE,UAAU,WAAW;;;;;;wBAcrB,SAAS;;wBAiBT,YACd,iDACA;;wBAOc,kBAAkB;;;;;;;wBAWlB,aAAa,QAAQ,eAAe,SAAS,eAAe"}
package/dist/hygiene.js CHANGED
@@ -31,7 +31,8 @@ const STATUS = {
31
31
  MOSTRA_HYGIENE_RATE_LIMITED: 429,
32
32
  MOSTRA_HYGIENE_NOT_SERVED: 404,
33
33
  MOSTRA_HYGIENE_SESSION_CONFLICT: 409,
34
- MOSTRA_HYGIENE_HEADERS_TOO_LARGE: 431
34
+ MOSTRA_HYGIENE_HEADERS_TOO_LARGE: 431,
35
+ MOSTRA_HYGIENE_FRAME_SESSION: 403
35
36
  };
36
37
  /** Builds a refusal with the status the code's HTTP mapping gives (FAILURE_MODEL §8). */
37
38
  function refusal(code, message, status) {
@@ -1 +1 @@
1
- {"version":3,"file":"hygiene.js","names":[],"sources":["../src/hygiene.ts"],"sourcesContent":["/**\n * Request hygiene (D06, ARCHITECTURE §10, HY-01): the checks every Mostra HTTP endpoint applies\n * before it acts on a request, as pure functions with no I/O. The gateway runs them on every\n * request, and `mostra mcp --http` (WP-15) runs the same code (D96), so a request a stranger's\n * page could send is refused the same way everywhere. None of them limits what an artifact, an\n * agent or a viewer may do; they only make sure a request comes from the page it claims to.\n *\n * ```ts\n * const refusal = checkRequest(\n * { origin: \"http://127.0.0.1:23456\", hosts: [\"127.0.0.1:23456\"] },\n * { method: \"POST\", target: \"/a/art_…/_mostra/ticket\", headers, intent: \"mutation\", csrf },\n * );\n * if (refusal) return respond(refusal.status, refusal.diagnostic);\n * ```\n */\nimport { type HygieneDiagnosticCode, hygieneDiagnostics } from \"./diagnostics/codes/hygiene.ts\";\nimport type { Diagnostic } from \"./diagnostics/diagnostic.ts\";\nimport { buildDiagnostic } from \"./diagnostics/spec.ts\";\n\n/** What one listener serves: its own origin and the exact `Host` values it accepts. */\nexport interface RequestPolicy {\n /** The listener's origin, such as `http://127.0.0.1:23456`; `Origin` headers must equal it. */\n readonly origin: string;\n /** Every `host:port` this listener answers to (lowercase): its URL host, plus registered tunnels. */\n readonly hosts: readonly string[];\n}\n\n/**\n * What a request is for, which decides the checks beyond the envelope:\n * - `read`: a GET or HEAD of a page or file; a foreign `Origin` is refused, none is fine.\n * - `stream`: an event stream (GET); same-origin only, by `Origin` or `Sec-Fetch-Site`.\n * - `upgrade`: a WebSocket upgrade; `Origin` must be present and equal.\n * - `exchange`: a mutation that starts a session (a capability token or ticket in the body):\n * `Origin` and a JSON content type, but no CSRF token yet.\n * - `mutation`: any other state change: `Origin`, a JSON content type and the session's CSRF\n * token in `X-Mostra-CSRF`.\n */\nexport type RequestIntent = \"read\" | \"stream\" | \"upgrade\" | \"exchange\" | \"mutation\";\n\n/** One request as the transport received it. */\nexport interface RequestFacts {\n /** The method, as sent. */\n readonly method: string;\n /** The request target exactly as sent: an origin-form path with its query. */\n readonly target: string;\n /** Every header as `[name, value]` in arrival order, so repeated headers are visible. */\n readonly headers: readonly (readonly [string, string])[];\n /** The intent the matched route declared; omit to check only the envelope. */\n readonly intent?: RequestIntent;\n /** The session's CSRF token, for `mutation` requests. */\n readonly csrf?: string;\n}\n\n/** A refused request: the HTTP status to answer with and the diagnostic for its body. */\nexport interface Refusal {\n /** The HTTP status: 400, 401, 403, 404, 410, 415, 421 or 429. */\n readonly status: number;\n /** What was refused and why, for the response body and the log. */\n readonly diagnostic: Diagnostic;\n}\n\n/** The header that carries a session's CSRF token on every mutation (D98). */\nexport const CSRF_HEADER = \"x-mostra-csrf\";\n\nconst STATUS: Readonly<Record<HygieneDiagnosticCode, number>> = {\n MOSTRA_HYGIENE_HOST_REFUSED: 421,\n MOSTRA_HYGIENE_ORIGIN_REFUSED: 403,\n MOSTRA_HYGIENE_CSRF_MISSING: 403,\n MOSTRA_HYGIENE_CONTENT_TYPE: 415,\n MOSTRA_HYGIENE_REQUEST_MALFORMED: 400,\n MOSTRA_HYGIENE_SESSION_MISSING: 401,\n MOSTRA_HYGIENE_TOKEN_INVALID: 401,\n MOSTRA_HYGIENE_TOKEN_REVOKED: 410,\n MOSTRA_HYGIENE_SCOPE_DENIED: 403,\n MOSTRA_HYGIENE_RATE_LIMITED: 429,\n MOSTRA_HYGIENE_NOT_SERVED: 404,\n MOSTRA_HYGIENE_SESSION_CONFLICT: 409,\n MOSTRA_HYGIENE_HEADERS_TOO_LARGE: 431,\n};\n\n/** Builds a refusal with the status the code's HTTP mapping gives (FAILURE_MODEL §8). */\nexport function refusal(code: HygieneDiagnosticCode, message: string, status?: number): Refusal {\n return {\n status: status ?? STATUS[code],\n diagnostic: buildDiagnostic(code, hygieneDiagnostics[code], { message }),\n };\n}\n\n/** Headers that must appear at most once: a second copy could mean two different things. */\nconst SINGLE = new Set([\"host\", \"origin\", \"content-type\", \"content-length\", CSRF_HEADER, \"cookie\"]);\n\n/** Characters no header value or path may carry: controls other than tab, and DEL. */\n// biome-ignore lint/suspicious/noControlCharactersInRegex: matching control characters is the point.\nconst CONTROL = /[\\u0000-\\u0008\\u000a-\\u001f\\u007f]/;\n\n/** Constant-time comparison of two strings, so timing reveals nothing about a secret. */\nexport function safeEqual(a: string, b: string): boolean {\n let difference = a.length ^ b.length;\n const length = Math.max(a.length, b.length);\n for (let index = 0; index < length; index++) {\n difference |= (a.charCodeAt(index) | 0) ^ (b.charCodeAt(index) | 0);\n }\n return difference === 0;\n}\n\n/**\n * The path a request target names, decoded, or `undefined` when it isn't a safe origin-form path:\n * absolute and authority forms, `*`, encoded `/` or `\\`, `.` or `..` segments (encoded or not),\n * NUL and other controls, and invalid percent-encoding are all refused.\n */\nexport function safePath(target: string): string | undefined {\n if (!target.startsWith(\"/\") || target.startsWith(\"//\")) return undefined;\n const end = target.search(/[?#]/);\n const raw = end < 0 ? target : target.slice(0, end);\n if (/%(2f|5c)/i.test(raw) || raw.includes(\"\\\\\")) return undefined;\n let path: string;\n try {\n path = decodeURIComponent(raw);\n } catch {\n return undefined;\n }\n if (CONTROL.test(path) || path.includes(\"\\u0000\")) return undefined;\n if (path.split(\"/\").some((segment) => segment === \".\" || segment === \"..\")) return undefined;\n return path;\n}\n\n/** The value of a header (case-insensitive name), or `undefined`. */\nexport function headerValue(\n headers: readonly (readonly [string, string])[],\n name: string,\n): string | undefined {\n const lower = name.toLowerCase();\n return headers.find(([key]) => key.toLowerCase() === lower)?.[1];\n}\n\n/** Whether a `Content-Type` value is JSON (`application/json`, any parameters). */\nexport function isJsonContentType(value: string | undefined): boolean {\n if (value === undefined) return false;\n return value.split(\";\")[0]?.trim().toLowerCase() === \"application/json\";\n}\n\n/**\n * Checks a request's envelope (the `Host` allowlist, the request target, repeated and malformed\n * headers) and, when `intent` is given, what that intent needs: `Origin`, the JSON content type\n * and the CSRF token. Returns the first refusal, or `undefined` when the request may proceed.\n * Session, token and scope checks follow in the endpoint, which knows its session.\n */\nexport function checkRequest(policy: RequestPolicy, request: RequestFacts): Refusal | undefined {\n const counts = new Map<string, number>();\n for (const [name, value] of request.headers) {\n const lower = name.toLowerCase();\n counts.set(lower, (counts.get(lower) ?? 0) + 1);\n if (CONTROL.test(value)) {\n return refusal(\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n `The ${lower} header has control characters.`,\n );\n }\n }\n for (const name of SINGLE) {\n if ((counts.get(name) ?? 0) > 1) {\n return refusal(\"MOSTRA_HYGIENE_REQUEST_MALFORMED\", `The request repeats the ${name} header.`);\n }\n }\n const host = headerValue(request.headers, \"host\")?.toLowerCase();\n if (host === undefined || !policy.hosts.includes(host)) {\n return refusal(\n \"MOSTRA_HYGIENE_HOST_REFUSED\",\n host === undefined\n ? \"The request has no Host header.\"\n : \"The request's Host isn't one this listener serves.\",\n );\n }\n if (safePath(request.target) === undefined) {\n return refusal(\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n \"The request target isn't a plain path inside the served tree.\",\n );\n }\n if (request.intent === undefined) return undefined;\n\n const origin = headerValue(request.headers, \"origin\");\n switch (request.intent) {\n case \"read\":\n if (origin !== undefined && origin !== policy.origin) {\n return refusal(\"MOSTRA_HYGIENE_ORIGIN_REFUSED\", \"The request came from another origin.\");\n }\n return undefined;\n case \"stream\": {\n const site = headerValue(request.headers, \"sec-fetch-site\");\n const sameOrigin = origin === undefined ? site === \"same-origin\" : origin === policy.origin;\n return sameOrigin\n ? undefined\n : refusal(\"MOSTRA_HYGIENE_ORIGIN_REFUSED\", \"A stream must be opened by its own origin.\");\n }\n case \"upgrade\":\n case \"exchange\":\n case \"mutation\": {\n if (origin !== policy.origin) {\n return refusal(\n \"MOSTRA_HYGIENE_ORIGIN_REFUSED\",\n origin === undefined\n ? \"The request has no Origin header.\"\n : \"The request came from another origin.\",\n );\n }\n if (request.intent === \"upgrade\") return undefined;\n if (!isJsonContentType(headerValue(request.headers, \"content-type\"))) {\n return refusal(\"MOSTRA_HYGIENE_CONTENT_TYPE\", \"The request's body isn't declared as JSON.\");\n }\n if (request.intent === \"exchange\") return undefined;\n const sent = headerValue(request.headers, CSRF_HEADER);\n if (request.csrf === undefined || sent === undefined || !safeEqual(sent, request.csrf)) {\n return refusal(\n \"MOSTRA_HYGIENE_CSRF_MISSING\",\n sent === undefined\n ? `The request has no ${CSRF_HEADER} header.`\n : `The request's ${CSRF_HEADER} header doesn't match its session.`,\n );\n }\n return undefined;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8DA,MAAa,cAAc;AAE3B,MAAM,SAA0D;CAC9D,6BAA6B;CAC7B,+BAA+B;CAC/B,6BAA6B;CAC7B,6BAA6B;CAC7B,kCAAkC;CAClC,gCAAgC;CAChC,8BAA8B;CAC9B,8BAA8B;CAC9B,6BAA6B;CAC7B,6BAA6B;CAC7B,2BAA2B;CAC3B,iCAAiC;CACjC,kCAAkC;AACpC;;AAGA,SAAgB,QAAQ,MAA6B,SAAiB,QAA0B;CAC9F,OAAO;EACL,QAAQ,UAAU,OAAO;EACzB,YAAY,gBAAgB,MAAM,mBAAmB,OAAO,EAAE,QAAQ,CAAC;CACzE;AACF;;AAGA,MAAM,yBAAS,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAgB;CAAkB;CAAa;AAAQ,CAAC;;AAIlG,MAA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C1C,MAAM,OAAO,YAAY,QAAQ,SAAS,WAAW;GACrD,IAAI,QAAQ,SAAS,KAAA,KAAa,SAAS,KAAA,KAAa,CAAC,UAAU,MAAM,QAAQ,IAAI,GACnF,OAAO,QACL,+BACA,SAAS,KAAA,IACL,sBAAsB,YAAY,YAClC,iBAAiB,YAAY,mCACnC;GAEF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"hygiene.js","names":[],"sources":["../src/hygiene.ts"],"sourcesContent":["/**\n * Request hygiene (D06, ARCHITECTURE §10, HY-01): the checks every Mostra HTTP endpoint applies\n * before it acts on a request, as pure functions with no I/O. The gateway runs them on every\n * request, and `mostra mcp --http` (WP-15) runs the same code (D96), so a request a stranger's\n * page could send is refused the same way everywhere. None of them limits what an artifact, an\n * agent or a viewer may do; they only make sure a request comes from the page it claims to.\n *\n * ```ts\n * const refusal = checkRequest(\n * { origin: \"http://127.0.0.1:23456\", hosts: [\"127.0.0.1:23456\"] },\n * { method: \"POST\", target: \"/a/art_…/_mostra/ticket\", headers, intent: \"mutation\", csrf },\n * );\n * if (refusal) return respond(refusal.status, refusal.diagnostic);\n * ```\n */\nimport { type HygieneDiagnosticCode, hygieneDiagnostics } from \"./diagnostics/codes/hygiene.ts\";\nimport type { Diagnostic } from \"./diagnostics/diagnostic.ts\";\nimport { buildDiagnostic } from \"./diagnostics/spec.ts\";\n\n/** What one listener serves: its own origin and the exact `Host` values it accepts. */\nexport interface RequestPolicy {\n /** The listener's origin, such as `http://127.0.0.1:23456`; `Origin` headers must equal it. */\n readonly origin: string;\n /** Every `host:port` this listener answers to (lowercase): its URL host, plus registered tunnels. */\n readonly hosts: readonly string[];\n}\n\n/**\n * What a request is for, which decides the checks beyond the envelope:\n * - `read`: a GET or HEAD of a page or file; a foreign `Origin` is refused, none is fine.\n * - `stream`: an event stream (GET); same-origin only, by `Origin` or `Sec-Fetch-Site`.\n * - `upgrade`: a WebSocket upgrade; `Origin` must be present and equal.\n * - `exchange`: a mutation that starts a session (a capability token or ticket in the body):\n * `Origin` and a JSON content type, but no CSRF token yet.\n * - `mutation`: any other state change: `Origin`, a JSON content type and the session's CSRF\n * token in `X-Mostra-CSRF`.\n */\nexport type RequestIntent = \"read\" | \"stream\" | \"upgrade\" | \"exchange\" | \"mutation\";\n\n/** One request as the transport received it. */\nexport interface RequestFacts {\n /** The method, as sent. */\n readonly method: string;\n /** The request target exactly as sent: an origin-form path with its query. */\n readonly target: string;\n /** Every header as `[name, value]` in arrival order, so repeated headers are visible. */\n readonly headers: readonly (readonly [string, string])[];\n /** The intent the matched route declared; omit to check only the envelope. */\n readonly intent?: RequestIntent;\n /** The session's CSRF token, for `mutation` requests. */\n readonly csrf?: string;\n}\n\n/** A refused request: the HTTP status to answer with and the diagnostic for its body. */\nexport interface Refusal {\n /** The HTTP status: 400, 401, 403, 404, 410, 415, 421 or 429. */\n readonly status: number;\n /** What was refused and why, for the response body and the log. */\n readonly diagnostic: Diagnostic;\n}\n\n/** The header that carries a session's CSRF token on every mutation (D98). */\nexport const CSRF_HEADER = \"x-mostra-csrf\";\n\nconst STATUS: Readonly<Record<HygieneDiagnosticCode, number>> = {\n MOSTRA_HYGIENE_HOST_REFUSED: 421,\n MOSTRA_HYGIENE_ORIGIN_REFUSED: 403,\n MOSTRA_HYGIENE_CSRF_MISSING: 403,\n MOSTRA_HYGIENE_CONTENT_TYPE: 415,\n MOSTRA_HYGIENE_REQUEST_MALFORMED: 400,\n MOSTRA_HYGIENE_SESSION_MISSING: 401,\n MOSTRA_HYGIENE_TOKEN_INVALID: 401,\n MOSTRA_HYGIENE_TOKEN_REVOKED: 410,\n MOSTRA_HYGIENE_SCOPE_DENIED: 403,\n MOSTRA_HYGIENE_RATE_LIMITED: 429,\n MOSTRA_HYGIENE_NOT_SERVED: 404,\n MOSTRA_HYGIENE_SESSION_CONFLICT: 409,\n MOSTRA_HYGIENE_HEADERS_TOO_LARGE: 431,\n MOSTRA_HYGIENE_FRAME_SESSION: 403,\n};\n\n/** Builds a refusal with the status the code's HTTP mapping gives (FAILURE_MODEL §8). */\nexport function refusal(code: HygieneDiagnosticCode, message: string, status?: number): Refusal {\n return {\n status: status ?? STATUS[code],\n diagnostic: buildDiagnostic(code, hygieneDiagnostics[code], { message }),\n };\n}\n\n/** Headers that must appear at most once: a second copy could mean two different things. */\nconst SINGLE = new Set([\"host\", \"origin\", \"content-type\", \"content-length\", CSRF_HEADER, \"cookie\"]);\n\n/** Characters no header value or path may carry: controls other than tab, and DEL. */\n// biome-ignore lint/suspicious/noControlCharactersInRegex: matching control characters is the point.\nconst CONTROL = /[\\u0000-\\u0008\\u000a-\\u001f\\u007f]/;\n\n/** Constant-time comparison of two strings, so timing reveals nothing about a secret. */\nexport function safeEqual(a: string, b: string): boolean {\n let difference = a.length ^ b.length;\n const length = Math.max(a.length, b.length);\n for (let index = 0; index < length; index++) {\n difference |= (a.charCodeAt(index) | 0) ^ (b.charCodeAt(index) | 0);\n }\n return difference === 0;\n}\n\n/**\n * The path a request target names, decoded, or `undefined` when it isn't a safe origin-form path:\n * absolute and authority forms, `*`, encoded `/` or `\\`, `.` or `..` segments (encoded or not),\n * NUL and other controls, and invalid percent-encoding are all refused.\n */\nexport function safePath(target: string): string | undefined {\n if (!target.startsWith(\"/\") || target.startsWith(\"//\")) return undefined;\n const end = target.search(/[?#]/);\n const raw = end < 0 ? target : target.slice(0, end);\n if (/%(2f|5c)/i.test(raw) || raw.includes(\"\\\\\")) return undefined;\n let path: string;\n try {\n path = decodeURIComponent(raw);\n } catch {\n return undefined;\n }\n if (CONTROL.test(path) || path.includes(\"\\u0000\")) return undefined;\n if (path.split(\"/\").some((segment) => segment === \".\" || segment === \"..\")) return undefined;\n return path;\n}\n\n/** The value of a header (case-insensitive name), or `undefined`. */\nexport function headerValue(\n headers: readonly (readonly [string, string])[],\n name: string,\n): string | undefined {\n const lower = name.toLowerCase();\n return headers.find(([key]) => key.toLowerCase() === lower)?.[1];\n}\n\n/** Whether a `Content-Type` value is JSON (`application/json`, any parameters). */\nexport function isJsonContentType(value: string | undefined): boolean {\n if (value === undefined) return false;\n return value.split(\";\")[0]?.trim().toLowerCase() === \"application/json\";\n}\n\n/**\n * Checks a request's envelope (the `Host` allowlist, the request target, repeated and malformed\n * headers) and, when `intent` is given, what that intent needs: `Origin`, the JSON content type\n * and the CSRF token. Returns the first refusal, or `undefined` when the request may proceed.\n * Session, token and scope checks follow in the endpoint, which knows its session.\n */\nexport function checkRequest(policy: RequestPolicy, request: RequestFacts): Refusal | undefined {\n const counts = new Map<string, number>();\n for (const [name, value] of request.headers) {\n const lower = name.toLowerCase();\n counts.set(lower, (counts.get(lower) ?? 0) + 1);\n if (CONTROL.test(value)) {\n return refusal(\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n `The ${lower} header has control characters.`,\n );\n }\n }\n for (const name of SINGLE) {\n if ((counts.get(name) ?? 0) > 1) {\n return refusal(\"MOSTRA_HYGIENE_REQUEST_MALFORMED\", `The request repeats the ${name} header.`);\n }\n }\n const host = headerValue(request.headers, \"host\")?.toLowerCase();\n if (host === undefined || !policy.hosts.includes(host)) {\n return refusal(\n \"MOSTRA_HYGIENE_HOST_REFUSED\",\n host === undefined\n ? \"The request has no Host header.\"\n : \"The request's Host isn't one this listener serves.\",\n );\n }\n if (safePath(request.target) === undefined) {\n return refusal(\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n \"The request target isn't a plain path inside the served tree.\",\n );\n }\n if (request.intent === undefined) return undefined;\n\n const origin = headerValue(request.headers, \"origin\");\n switch (request.intent) {\n case \"read\":\n if (origin !== undefined && origin !== policy.origin) {\n return refusal(\"MOSTRA_HYGIENE_ORIGIN_REFUSED\", \"The request came from another origin.\");\n }\n return undefined;\n case \"stream\": {\n const site = headerValue(request.headers, \"sec-fetch-site\");\n const sameOrigin = origin === undefined ? site === \"same-origin\" : origin === policy.origin;\n return sameOrigin\n ? undefined\n : refusal(\"MOSTRA_HYGIENE_ORIGIN_REFUSED\", \"A stream must be opened by its own origin.\");\n }\n case \"upgrade\":\n case \"exchange\":\n case \"mutation\": {\n if (origin !== policy.origin) {\n return refusal(\n \"MOSTRA_HYGIENE_ORIGIN_REFUSED\",\n origin === undefined\n ? \"The request has no Origin header.\"\n : \"The request came from another origin.\",\n );\n }\n if (request.intent === \"upgrade\") return undefined;\n if (!isJsonContentType(headerValue(request.headers, \"content-type\"))) {\n return refusal(\"MOSTRA_HYGIENE_CONTENT_TYPE\", \"The request's body isn't declared as JSON.\");\n }\n if (request.intent === \"exchange\") return undefined;\n const sent = headerValue(request.headers, CSRF_HEADER);\n if (request.csrf === undefined || sent === undefined || !safeEqual(sent, request.csrf)) {\n return refusal(\n \"MOSTRA_HYGIENE_CSRF_MISSING\",\n sent === undefined\n ? `The request has no ${CSRF_HEADER} header.`\n : `The request's ${CSRF_HEADER} header doesn't match its session.`,\n );\n }\n return undefined;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8DA,MAAa,cAAc;AAE3B,MAAM,SAA0D;CAC9D,6BAA6B;CAC7B,+BAA+B;CAC/B,6BAA6B;CAC7B,6BAA6B;CAC7B,kCAAkC;CAClC,gCAAgC;CAChC,8BAA8B;CAC9B,8BAA8B;CAC9B,6BAA6B;CAC7B,6BAA6B;CAC7B,2BAA2B;CAC3B,iCAAiC;CACjC,kCAAkC;CAClC,8BAA8B;AAChC;;AAGA,SAAgB,QAAQ,MAA6B,SAAiB,QAA0B;CAC9F,OAAO;EACL,QAAQ,UAAU,OAAO;EACzB,YAAY,gBAAgB,MAAM,mBAAmB,OAAO,EAAE,QAAQ,CAAC;CACzE;AACF;;AAGA,MAAM,yBAAS,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAgB;CAAkB;CAAa;AAAQ,CAAC;;AAIlG,MAAM,UAAU;;AAGhB,SAAgB,UAAU,GAAW,GAAoB;CACvD,IAAI,aAAa,EAAE,SAAS,EAAE;CAC9B,MAAM,SAAS,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM;CAC1C,KAAK,IAA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AAS,KAAA,IACL,sBAAsB,YAAY,YAClC,iBAAiB,YAAY,mCACnC;GAEF;EACF;CACF;AACF"}
package/dist/ids.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as z from "zod";
2
2
  //#region src/ids.d.ts
3
3
  /** The prefixes INTERFACES §1 assigns, one per entity. */
4
- export type IdPrefix = "art" | "ver" | "vw" | "vwr" | "sub" | "dlv" | "run" | "thr" | "cmt" | "tok" | "mut";
4
+ export type IdPrefix = "art" | "ver" | "vw" | "vwr" | "sub" | "dlv" | "run" | "thr" | "cmt" | "tok" | "mut" | "shr";
5
5
  /**
6
6
  * A branded ID string. The brand exists only at the type level, so an `Id<"art">` is a plain
7
7
  * string at run time and on the wire.
@@ -97,6 +97,10 @@ export declare const TokenId: GeneratedIdKind<"tok">;
97
97
  export type MutationId = Id<"mut">;
98
98
  /** Mutation IDs. */
99
99
  export declare const MutationId: GeneratedIdKind<"mut">;
100
+ /** A share ID (`shr_` + ULID): one share of an artifact through a tunnel (D158). */
101
+ export type ShareId = Id<"shr">;
102
+ /** Share IDs. */
103
+ export declare const ShareId: GeneratedIdKind<"shr">;
100
104
  /**
101
105
  * An event cursor: the decimal string of a home-wide event position (INTERFACES §1). Decimal
102
106
  * strings keep 64-bit positions exact in JavaScript.
package/dist/ids.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ids.d.ts","names":[],"sources":["../src/ids.ts"],"mappings":";;;YAmBY;;;;;YAiBA,GAAG,UAAU,eAAe;WAA2B,kBAAkB;;;YAGzE;;iBAGK,OAAO,UAAU;;WAEvB,QAAQ;;WAER;;WAEA,MAAM;;WAEN,SAAS;;WAET,QAAQ,EAAE,QAAQ,GAAG;;EAE9B,GAAG,iBAAiB,SAAS,GAAG;;;;;;;EAOhC,MAAM,gBAAgB,GAAG;;;iBAIV,gBAAgB,UAAU,kBAAkB,OAAO;;EAElE,UAAU,GAAG;;;YAkFH,aAAa;;qBAEZ,YAAY;;YAKb,YAAY;;iBAEP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WAA6B;;;qBAG5B;;WAEF,SAAS;WACT,QAAQ,EAAE,QAAQ;EAC3B,GAAG,iBAAiB,SAAS;;EAE7B,MAAM,gBAAgB;;EAEtB,QAAQ,GAAG,QAAQ,GAAG"}
package/dist/ids.js CHANGED
@@ -109,6 +109,8 @@ const CommentId = generated(defineKind("cmt", "comment", "ulid", "CommentId"));
109
109
  const TokenId = generated(defineKind("tok", "capability token", "ulid", "TokenId"));
110
110
  /** Mutation IDs. */
111
111
  const MutationId = generated(defineKind("mut", "mutation", "ulid", "MutationId"));
112
+ /** Share IDs. */
113
+ const ShareId = generated(defineKind("shr", "share", "ulid", "ShareId"));
112
114
  /** Event cursors. */
113
115
  const Cursor = (() => {
114
116
  const pattern = /^(0|[1-9][0-9]{0,18})$/;
@@ -130,6 +132,6 @@ const Cursor = (() => {
130
132
  };
131
133
  })();
132
134
  //#endregion
133
- export { ArtifactId, CommentId, Cursor, DeliveryId, MutationId, RunId, SubmissionId, ThreadId, TokenId, VersionId, ViewId, ViewerId };
135
+ export { ArtifactId, CommentId, Cursor, DeliveryId, MutationId, RunId, ShareId, SubmissionId, ThreadId, TokenId, VersionId, ViewId, ViewerId };
134
136
 
135
137
  //# sourceMappingURL=ids.js.map