@mostra/protocol 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +30 -4
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +14 -4
- package/dist/actions.js.map +1 -1
- package/dist/artifact.d.ts +2 -1
- package/dist/artifact.d.ts.map +1 -1
- package/dist/artifact.js +2 -1
- package/dist/artifact.js.map +1 -1
- package/dist/browser.d.ts +5 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +7 -2
- package/dist/browser.js.map +1 -1
- package/dist/capability.d.ts +0 -9
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +1 -17
- package/dist/capability.js.map +1 -1
- package/dist/diagnostics/codes/artifact.d.ts +1 -1
- package/dist/diagnostics/codes/artifact.d.ts.map +1 -1
- package/dist/diagnostics/codes/artifact.js +12 -1
- package/dist/diagnostics/codes/artifact.js.map +1 -1
- package/dist/diagnostics/codes/home.d.ts +1 -1
- package/dist/diagnostics/codes/home.d.ts.map +1 -1
- package/dist/diagnostics/codes/home.js +12 -1
- package/dist/diagnostics/codes/home.js.map +1 -1
- package/dist/diagnostics/codes/index.d.ts +3 -2
- package/dist/diagnostics/codes/index.d.ts.map +1 -1
- package/dist/diagnostics/codes/index.js +3 -1
- package/dist/diagnostics/codes/index.js.map +1 -1
- package/dist/diagnostics/codes/remote.d.ts +8 -0
- package/dist/diagnostics/codes/remote.d.ts.map +1 -0
- package/dist/diagnostics/codes/remote.js +99 -0
- package/dist/diagnostics/codes/remote.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.d.ts.map +1 -1
- package/dist/diagnostics/diagnostic.js +2 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/duration.d.ts +13 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/duration.js +27 -0
- package/dist/duration.js.map +1 -0
- package/dist/ids.d.ts +17 -1
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +9 -1
- package/dist/ids.js.map +1 -1
- package/dist/index.d.ts +30 -8
- package/dist/index.js +30 -8
- package/dist/interaction.d.ts +28 -2
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +20 -5
- package/dist/interaction.js.map +1 -1
- package/dist/manifest.d.ts +59 -14
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +63 -15
- package/dist/manifest.js.map +1 -1
- package/dist/methods/artifact/export.d.ts +40 -0
- package/dist/methods/artifact/export.d.ts.map +1 -0
- package/dist/methods/artifact/export.js +36 -0
- package/dist/methods/artifact/export.js.map +1 -0
- package/dist/methods/artifact/import.d.ts +23 -0
- package/dist/methods/artifact/import.d.ts.map +1 -0
- package/dist/methods/artifact/import.js +25 -0
- package/dist/methods/artifact/import.js.map +1 -0
- package/dist/methods/artifact/publish.d.ts +2 -1
- package/dist/methods/artifact/publish.d.ts.map +1 -1
- package/dist/methods/artifact/publish.js +1 -1
- package/dist/methods/hosted/push.d.ts +76 -0
- package/dist/methods/hosted/push.d.ts.map +1 -0
- package/dist/methods/hosted/push.js +71 -0
- package/dist/methods/hosted/push.js.map +1 -0
- package/dist/methods/hosted/submission.d.ts +18 -0
- package/dist/methods/hosted/submission.d.ts.map +1 -0
- package/dist/methods/hosted/submission.js +23 -0
- package/dist/methods/hosted/submission.js.map +1 -0
- package/dist/methods/index.d.ts.map +1 -1
- package/dist/methods/index.js +38 -2
- package/dist/methods/index.js.map +1 -1
- package/dist/methods/instance/status.d.ts +3 -0
- package/dist/methods/instance/status.d.ts.map +1 -1
- package/dist/methods/instance/status.js +3 -1
- package/dist/methods/instance/status.js.map +1 -1
- package/dist/methods/mostra/initialize.d.ts +17 -3
- package/dist/methods/mostra/initialize.d.ts.map +1 -1
- package/dist/methods/mostra/initialize.js +11 -3
- package/dist/methods/mostra/initialize.js.map +1 -1
- package/dist/methods/port/relay-call.d.ts +33 -0
- package/dist/methods/port/relay-call.d.ts.map +1 -0
- package/dist/methods/port/relay-call.js +31 -0
- package/dist/methods/port/relay-call.js.map +1 -0
- package/dist/methods/port/relay-cancel.d.ts +16 -0
- package/dist/methods/port/relay-cancel.d.ts.map +1 -0
- package/dist/methods/port/relay-cancel.js +21 -0
- package/dist/methods/port/relay-cancel.js.map +1 -0
- package/dist/methods/port/relay-live.d.ts +25 -0
- package/dist/methods/port/relay-live.d.ts.map +1 -0
- package/dist/methods/port/relay-live.js +32 -0
- package/dist/methods/port/relay-live.js.map +1 -0
- package/dist/methods/port/relay-reconcile.d.ts +39 -0
- package/dist/methods/port/relay-reconcile.d.ts.map +1 -0
- package/dist/methods/port/relay-reconcile.js +35 -0
- package/dist/methods/port/relay-reconcile.js.map +1 -0
- package/dist/methods/port/relay-run.d.ts +47 -0
- package/dist/methods/port/relay-run.d.ts.map +1 -0
- package/dist/methods/port/relay-run.js +41 -0
- package/dist/methods/port/relay-run.js.map +1 -0
- package/dist/methods/port/submissions-deliver.d.ts +8 -0
- package/dist/methods/port/submissions-deliver.d.ts.map +1 -1
- package/dist/methods/port/submissions-deliver.js +4 -2
- package/dist/methods/port/submissions-deliver.js.map +1 -1
- package/dist/methods/relay/call-batch.d.ts +26 -0
- package/dist/methods/relay/call-batch.d.ts.map +1 -0
- package/dist/methods/relay/call-batch.js +30 -0
- package/dist/methods/relay/call-batch.js.map +1 -0
- package/dist/methods/relay/effect.d.ts +31 -0
- package/dist/methods/relay/effect.d.ts.map +1 -0
- package/dist/methods/relay/effect.js +30 -0
- package/dist/methods/relay/effect.js.map +1 -0
- package/dist/methods/relay/live-value.d.ts +33 -0
- package/dist/methods/relay/live-value.d.ts.map +1 -0
- package/dist/methods/relay/live-value.js +32 -0
- package/dist/methods/relay/live-value.js.map +1 -0
- package/dist/methods/relay/run-update.d.ts +46 -0
- package/dist/methods/relay/run-update.d.ts.map +1 -0
- package/dist/methods/relay/run-update.js +45 -0
- package/dist/methods/relay/run-update.js.map +1 -0
- package/dist/methods/remote/login-wait.d.ts +30 -0
- package/dist/methods/remote/login-wait.d.ts.map +1 -0
- package/dist/methods/remote/login-wait.js +36 -0
- package/dist/methods/remote/login-wait.js.map +1 -0
- package/dist/methods/remote/login.d.ts +41 -0
- package/dist/methods/remote/login.d.ts.map +1 -0
- package/dist/methods/remote/login.js +37 -0
- package/dist/methods/remote/login.js.map +1 -0
- package/dist/methods/remote/logout.d.ts +25 -0
- package/dist/methods/remote/logout.d.ts.map +1 -0
- package/dist/methods/remote/logout.js +28 -0
- package/dist/methods/remote/logout.js.map +1 -0
- package/dist/methods/remote/status.d.ts +14 -0
- package/dist/methods/remote/status.d.ts.map +1 -0
- package/dist/methods/remote/status.js +22 -0
- package/dist/methods/remote/status.js.map +1 -0
- package/dist/methods/remote/token.d.ts +19 -0
- package/dist/methods/remote/token.d.ts.map +1 -0
- package/dist/methods/remote/token.js +24 -0
- package/dist/methods/remote/token.js.map +1 -0
- package/dist/methods/share/start.d.ts +5 -2
- package/dist/methods/share/start.d.ts.map +1 -1
- package/dist/methods/share/start.js +6 -3
- package/dist/methods/share/start.js.map +1 -1
- package/dist/methods/state/patch.d.ts +7 -0
- package/dist/methods/state/patch.d.ts.map +1 -1
- package/dist/methods/state/patch.js +2 -1
- package/dist/methods/state/patch.js.map +1 -1
- package/dist/methods/view/url.d.ts +2 -1
- package/dist/methods/view/url.d.ts.map +1 -1
- package/dist/methods/view/url.js +2 -1
- package/dist/methods/view/url.js.map +1 -1
- package/dist/policy.d.ts +18 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +23 -0
- package/dist/policy.js.map +1 -0
- package/dist/remote.d.ts +55 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +52 -0
- package/dist/remote.js.map +1 -0
- package/dist/view.d.ts +1 -1
- package/dist/view.js +1 -1
- package/dist/view.js.map +1 -1
- package/package.json +2 -2
- package/schemas/protocol.draft-07.json +1607 -126
- package/schemas/protocol.schema.json +1543 -126
- package/src/actions.ts +45 -5
- package/src/browser.ts +6 -0
- package/src/capability.ts +0 -23
- package/src/diagnostics/codes/artifact.ts +12 -0
- package/src/diagnostics/codes/home.ts +12 -0
- package/src/diagnostics/codes/index.ts +6 -2
- package/src/diagnostics/codes/remote.ts +113 -0
- package/src/diagnostics/diagnostic.ts +3 -1
- package/src/duration.ts +29 -0
- package/src/ids.ts +33 -1
- package/src/index.ts +124 -8
- package/src/interaction.ts +42 -2
- package/src/manifest.ts +115 -24
- package/src/methods/artifact/export.ts +68 -0
- package/src/methods/artifact/import.ts +39 -0
- package/src/methods/hosted/push.ts +146 -0
- package/src/methods/hosted/submission.ts +34 -0
- package/src/methods/index.ts +36 -0
- package/src/methods/instance/status.ts +4 -0
- package/src/methods/mostra/initialize.ts +19 -3
- package/src/methods/port/relay-call.ts +58 -0
- package/src/methods/port/relay-cancel.ts +33 -0
- package/src/methods/port/relay-live.ts +48 -0
- package/src/methods/port/relay-reconcile.ts +71 -0
- package/src/methods/port/relay-run.ts +80 -0
- package/src/methods/port/submissions-deliver.ts +13 -1
- package/src/methods/relay/call-batch.ts +52 -0
- package/src/methods/relay/effect.ts +55 -0
- package/src/methods/relay/live-value.ts +54 -0
- package/src/methods/relay/run-update.ts +81 -0
- package/src/methods/remote/login-wait.ts +55 -0
- package/src/methods/remote/login.ts +72 -0
- package/src/methods/remote/logout.ts +42 -0
- package/src/methods/remote/status.ts +34 -0
- package/src/methods/remote/token.ts +39 -0
- package/src/methods/share/start.ts +12 -4
- package/src/methods/state/patch.ts +6 -0
- package/src/methods/view/url.ts +2 -1
- package/src/policy.ts +30 -0
- package/src/remote.ts +89 -0
- package/src/view.ts +1 -1
package/dist/interaction.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction.js","names":[],"sources":["../src/interaction.ts"],"sourcesContent":["/**\n * The interaction ledger's wire types (INTERFACES §4, §6, §7, §8; DATA_MODEL §3, §4): viewers,\n * fields and their mutations, events and their filters, `wait` conditions, submissions, deliveries\n * and results. The host protocol methods (`state/*`, `results/get`, `wait`, `events/*`), the\n * submissions and drafts ports, and the browser protocol all speak these shapes.\n */\nimport * as z from \"zod\";\nimport {\n ArtifactId,\n Cursor,\n DeliveryId,\n SubmissionId,\n VersionId,\n ViewerId,\n ViewId,\n} from \"./ids.ts\";\nimport { ArtifactLink, SubmissionPolicy } from \"./manifest.ts\";\nimport type { SubmitChannel } from \"./view.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\nexport { ControlsPolicy, SubmitChannel, TrustedControl } from \"./view.ts\";\n\n// ── Viewers and actors ────────────────────────────────────────────────────────────────────\n\n/** How Mostra knows a viewer (DATA_MODEL §3 `viewer.kind`). */\nexport type ViewerKind = \"local\" | \"tailnet\" | \"token\" | \"host\";\n\n/**\n * A person who views an artifact (PRODUCT vocabulary). The home's local user is one viewer of kind\n * `local`; a link minted with `viewer` acts as a viewer of kind `token` (D104).\n */\nexport interface Viewer {\n /** The viewer's ID. */\n readonly id: string;\n /** How Mostra knows the viewer. */\n readonly kind: ViewerKind;\n /** The display name, when one is known. */\n readonly name?: string;\n /** The host's own key for this person, as given to `view/url` (D104). */\n readonly ref?: string;\n}\n\n/** The Zod schema of the `Viewer` type. */\nexport const Viewer: z.ZodType<Viewer> = z\n .object({\n id: ViewerId.schema,\n kind: z.enum([\"local\", \"tailnet\", \"token\", \"host\"]),\n name: z.string().exactOptional(),\n ref: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Viewer\",\n description: \"A person who views an artifact: ID, kind, display name and the host's own key.\",\n });\n\n/**\n * The person a capability link acts for (`view/url`'s `viewer`, D104): the host's stable key for\n * them, such as an email or an account ID, and a display name.\n */\nexport interface ViewerSpec {\n /** The host's stable key for this person: the same `ref` always names the same viewer. */\n readonly ref: string;\n /** The name people see; updated when given again. */\n readonly name?: string;\n}\n\n/** The Zod schema of the `ViewerSpec` type. */\nexport const ViewerSpec: z.ZodType<ViewerSpec> = z\n .object({\n ref: z.string().min(1).max(256),\n name: z.string().min(1).max(256).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ViewerSpec\",\n description: \"The person a capability link acts for: the host's stable key and a display name.\",\n });\n\n/** Who caused an event or wrote a field (DATA_MODEL §4). */\nexport interface Actor {\n /** Who: a viewer, an agent (a protocol client), a host, or Mostra itself. */\n readonly kind: \"viewer\" | \"agent\" | \"host\" | \"mostra\";\n /** A viewer's ID, or the protocol client's name for agents and hosts. */\n readonly id?: string;\n /** A display name, when one is known. */\n readonly name?: string;\n}\n\n/** The Zod schema of the `Actor` type. */\nexport const Actor: z.ZodType<Actor> = z\n .object({\n kind: z.enum([\"viewer\", \"agent\", \"host\", \"mostra\"]),\n id: z.string().exactOptional(),\n name: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Actor\",\n description: \"Who caused an event or wrote a field: a viewer, an agent, a host or Mostra.\",\n });\n\n// ── Fields and mutations ──────────────────────────────────────────────────────────────────\n\n/** The longest field ID, in UTF-16 code units. */\nexport const FIELD_ID_MAX_LENGTH = 256;\n\n/**\n * Whether `id` is a field ID (D52): 1 to 256 characters without control characters; dots separate\n * the parts that nest in results, so none is empty.\n */\nexport function isFieldId(id: unknown): id is string {\n return (\n typeof id === \"string\" &&\n id.length >= 1 &&\n id.length <= FIELD_ID_MAX_LENGTH &&\n // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what it refuses.\n !/[\\u0000-\\u001f\\u007f]/.test(id) &&\n !id.split(\".\").includes(\"\")\n );\n}\n\n/** Which document a field belongs to: the viewer's draft, or the artifact's shared state (D63). */\nexport type FieldScope = \"viewer\" | \"artifact\";\n\n/**\n * A document revision: the decimal string of a document's monotonic counter (DATA_MODEL §3).\n * `\"0\"` is a document nothing has written yet.\n */\nexport type DocumentRevision = string;\n\n/** The Zod schema of the `DocumentRevision` type. */\nexport const DocumentRevision: z.ZodType<DocumentRevision> = z\n .string()\n .regex(/^(0|[1-9][0-9]{0,15})$/)\n .register(wireRegistry, {\n id: \"DocumentRevision\",\n description: \"A draft's or artifact state's revision: a non-negative decimal integer string.\",\n });\n\n/**\n * One change to one field. Exactly one of `value` and `delete` is given. The optional metadata\n * travels with the field into results and decides what events redact (D52, D106).\n */\nexport interface FieldOp {\n /** The field ID (D52). */\n readonly id: string;\n /** The new value: any JSON value, `null` included. */\n readonly value?: unknown;\n /** Removes the field. */\n readonly delete?: true;\n /** The label people see in results and the shell's blocker list. */\n readonly label?: string;\n /** Whether the shell asks for it before submit. */\n readonly required?: boolean;\n /** Kept in submissions and results, redacted from events and logs (D52). */\n readonly sensitive?: boolean;\n}\n\n/** The Zod schema of the `FieldOp` type. */\nexport const FieldOp: z.ZodType<FieldOp> = z\n .object({\n id: z.string().min(1).max(FIELD_ID_MAX_LENGTH),\n value: z.unknown().exactOptional(),\n delete: z.literal(true).exactOptional(),\n label: z.string().max(1024).exactOptional(),\n required: z.boolean().exactOptional(),\n sensitive: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FieldOp\",\n description:\n \"One change to one field: a value or a delete, with optional label, required and sensitive.\",\n }) as z.ZodType<FieldOp>;\n\n/** A field's current state. */\nexport interface FieldState {\n /** The field's value: any JSON value. */\n readonly value: unknown;\n /** The document revision that last wrote it. */\n readonly revision: DocumentRevision;\n /** Who wrote it last. */\n readonly updatedBy?: Actor;\n /** When it was written last. */\n readonly updatedAt: string;\n /** The label people see. */\n readonly label?: string;\n /** Whether the shell asks for it before submit. */\n readonly required?: boolean;\n /** Whether events and logs redact its value (D52). */\n readonly sensitive?: boolean;\n}\n\n/** The Zod schema of the `FieldState` type. */\nexport const FieldState: z.ZodType<FieldState> = z\n .object({\n value: z.unknown(),\n revision: DocumentRevision,\n updatedBy: Actor.exactOptional(),\n updatedAt: z.iso.datetime(),\n label: z.string().exactOptional(),\n required: z.boolean().exactOptional(),\n sensitive: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FieldState\",\n description: \"A field's current value, the revision that wrote it, who wrote it and when.\",\n }) as z.ZodType<FieldState>;\n\n/**\n * A field op that wasn't applied because the field changed after the mutation's base revision\n * (D22, FAILURE_MODEL §5): what the field holds now, so the writer can keep theirs or take it.\n */\nexport interface FieldConflict {\n /** The field's ID. */\n readonly id: string;\n /** The revision that last changed the field. */\n readonly revision: DocumentRevision;\n /** Its current value; absent when it was deleted. */\n readonly value?: unknown;\n /** `true` when the field was deleted. */\n readonly deleted?: true;\n /** Who changed it. */\n readonly updatedBy?: Actor;\n /** When it changed. */\n readonly updatedAt?: string;\n}\n\n/** The Zod schema of the `FieldConflict` type. */\nexport const FieldConflict: z.ZodType<FieldConflict> = z\n .object({\n id: z.string(),\n revision: DocumentRevision,\n value: z.unknown().exactOptional(),\n deleted: z.literal(true).exactOptional(),\n updatedBy: Actor.exactOptional(),\n updatedAt: z.iso.datetime().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FieldConflict\",\n description: \"A field op not applied because the field changed after the base revision.\",\n }) as z.ZodType<FieldConflict>;\n\n/** What a mutation did: the document's revision after it, the ops applied, and the conflicts. */\nexport interface MutationResult {\n /** The document's revision after the mutation; unchanged when nothing applied. */\n readonly revision: DocumentRevision;\n /** The field IDs whose ops were applied. */\n readonly applied: readonly string[];\n /** The ops not applied, with what each field holds now. */\n readonly conflicts: readonly FieldConflict[];\n}\n\n/** The Zod schema of the `MutationResult` type. */\nexport const MutationResult: z.ZodType<MutationResult> = z\n .object({\n revision: DocumentRevision,\n applied: z.array(z.string()).readonly(),\n conflicts: z.array(FieldConflict).readonly(),\n })\n .register(wireRegistry, {\n id: \"MutationResult\",\n description:\n \"A mutation's outcome: the revision after it, the applied field IDs, the conflicts.\",\n });\n\n// ── Events ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * One durable event (DATA_MODEL §4). Its cursor is its stable ID and its place in the home-wide\n * order; `seq` orders an artifact's own events without gaps.\n */\nexport interface EventRecord {\n /** The event's stable ID and home-wide position. */\n readonly cursor: Cursor;\n /** The artifact, or `null` for a home-wide event. */\n readonly artifactId: string | null;\n /** The artifact's sequence number, or `null` for a home-wide event. */\n readonly seq: number | null;\n /** The type from DATA_MODEL §4's catalog. */\n readonly type: string;\n /** When it was appended. */\n readonly at: string;\n /** Who caused it. */\n readonly actor: Actor;\n /** What caused it: a run, a mutation, a submission. */\n readonly causation?: Readonly<Record<string, string>>;\n /** The event's data; sensitive field values are redacted (D52). */\n readonly payload: Readonly<Record<string, unknown>>;\n}\n\n/** The Zod schema of the `EventRecord` type. */\nexport const EventRecord: z.ZodType<EventRecord> = z\n .object({\n cursor: Cursor.schema,\n artifactId: ArtifactId.schema.nullable(),\n seq: z.int().min(1).nullable(),\n type: z.string(),\n at: z.iso.datetime(),\n actor: Actor,\n causation: z.record(z.string(), z.string()).exactOptional(),\n payload: z.record(z.string(), z.unknown()),\n })\n .register(wireRegistry, {\n id: \"EventRecord\",\n description:\n \"One durable event: cursor, artifact, per-artifact sequence, type, time, actor, payload.\",\n }) as z.ZodType<EventRecord>;\n\n/**\n * An event type, or a family of them: `submission.created`, or `submission.*` for every type that\n * starts with `submission.`.\n */\nexport type EventTypePattern = string;\n\n/** The Zod schema of the `EventTypePattern` type. */\nexport const EventTypePattern: z.ZodType<EventTypePattern> = z\n .string()\n .regex(/^[a-z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*(\\.\\*)?$/)\n .register(wireRegistry, {\n id: \"EventTypePattern\",\n description: \"An event type (submission.created) or a family of them (submission.*).\",\n });\n\n/**\n * Which events a reader wants (IN-08, H-09). Both parts are optional, and an event must pass both.\n * `artifact.compacted` always passes for a matching artifact, so a filtered reader still learns of\n * a compaction (DATA_MODEL §4).\n */\nexport interface EventFilter {\n /** Only these artifacts' events; absent: every artifact's, and home-wide ones. */\n readonly artifacts?: readonly string[];\n /** Only these types; absent: every type. */\n readonly types?: readonly EventTypePattern[];\n}\n\n/** The Zod schema of the `EventFilter` type. */\nexport const EventFilter: z.ZodType<EventFilter> = z\n .object({\n artifacts: z.array(ArtifactId.schema).max(1000).readonly().exactOptional(),\n types: z.array(EventTypePattern).max(100).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"EventFilter\",\n description:\n \"Which events a reader wants: these artifacts' and these types (patterns allowed).\",\n });\n\n/**\n * What `wait` waits for (ARCHITECTURE §6, D103): `submitted`, `signal:<name>`, `state:<fieldId>`\n * or `event:<type pattern>`.\n */\nexport type WaitCondition = string;\n\n/** A signal's name: letters, digits, `.`, `_` and `-`, starting with a letter or digit (D106). */\nexport const SIGNAL_NAME_PATTERN: RegExp = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;\n\n/** The Zod schema of the `WaitCondition` type. */\nexport const WaitCondition: z.ZodType<WaitCondition> = z\n .string()\n .regex(\n // biome-ignore lint/suspicious/noControlCharactersInRegex: field IDs exclude control characters.\n /^(submitted|signal:[A-Za-z0-9][A-Za-z0-9._-]{0,63}|state:[^\\u0000-\\u001f\\u007f]{1,256}|event:[a-z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*(\\.\\*)?)$/,\n )\n .register(wireRegistry, {\n id: \"WaitCondition\",\n description: \"What wait waits for: submitted, signal:<name>, state:<fieldId> or event:<type>.\",\n });\n\n// ── Submissions, deliveries and results ──────────────────────────────────────────────────\n\n/** A delivery's state (FAILURE_MODEL §4). */\nexport type DeliveryState = \"pending\" | \"delivered\" | \"rejected\" | \"undeliverable\";\n\n/** One submission's delivery to one host (D105). */\nexport interface DeliveryStatus {\n /** The delivery's stable ID (`dlv_`), repeated by every redelivery. */\n readonly deliveryId: string;\n /**\n * The host: its client name. Empty for Mostra's built-in adapter, which takes submissions when no\n * host does; client names are never empty, so no host can be mistaken for it (D105).\n */\n readonly owner: string;\n /** Where the delivery stands. */\n readonly state: DeliveryState;\n /** How many times Mostra called the host for it. */\n readonly attempts: number;\n /** The host's reason, for a rejection. */\n readonly reason?: string;\n /**\n * `true` while a pending delivery waits: its host isn't connected, or an attempt failed and it\n * will be retried (D47's \"Pending delivery\"). Absent while the first attempt is under way.\n */\n readonly waiting?: true;\n /** When its state last changed. */\n readonly updatedAt: string;\n}\n\n/** The Zod schema of the `DeliveryStatus` type. */\nexport const DeliveryStatus: z.ZodType<DeliveryStatus> = z\n .object({\n deliveryId: DeliveryId.schema,\n owner: z.string(),\n state: z.enum([\"pending\", \"delivered\", \"rejected\", \"undeliverable\"]),\n attempts: z.int().min(0),\n reason: z.string().exactOptional(),\n waiting: z.literal(true).exactOptional(),\n updatedAt: z.iso.datetime(),\n })\n .register(wireRegistry, {\n id: \"DeliveryStatus\",\n description: \"One submission's delivery to one host: owner, state, attempts and reason.\",\n });\n\n/** A submission as a submit answers it (INTERFACES §4). */\nexport interface SubmissionSummary {\n /** The submission's ID. */\n readonly id: string;\n /** When it was made. */\n readonly at: string;\n /** The draft epoch it closed (D103); 1 outside `epochs`. */\n readonly epoch: number;\n /** Where the submit came from (D40). */\n readonly channel: SubmitChannel;\n /** The version the view showed. */\n readonly versionId: string;\n /** That version's number. */\n readonly version: number;\n /** The view it was made from. */\n readonly viewId: string;\n /** Whether a newer version existed when the viewer submitted (H-10). */\n readonly staleView: boolean;\n /** The draft revision it was made from. */\n readonly draftRevision: DocumentRevision;\n /** SHA-256 of the snapshot's canonical JSON (RFC 8785), lowercase hex. */\n readonly digest: string;\n /** Every delivery's state, summed up: the worst of them. */\n readonly delivery: DeliveryState;\n /** Each host's delivery, so a viewer sees which host has it (IN-13). */\n readonly deliveries?: readonly DeliveryStatus[];\n /** `true` when this submit repeated an earlier one and got it back (D22). */\n readonly duplicate?: true;\n}\n\n/** The Zod schema of the `SubmissionSummary` type. */\nexport const SubmissionSummary: z.ZodType<SubmissionSummary> = z\n .object({\n id: SubmissionId.schema,\n at: z.iso.datetime(),\n epoch: z.int().min(1),\n channel: z.enum([\"shell\", \"artifact\"]),\n versionId: VersionId.schema,\n version: z.int().min(1),\n viewId: ViewId.schema,\n staleView: z.boolean(),\n draftRevision: DocumentRevision,\n digest: z.string().regex(/^[0-9a-f]{64}$/),\n delivery: z.enum([\"pending\", \"delivered\", \"rejected\", \"undeliverable\"]),\n deliveries: z.array(DeliveryStatus).readonly().exactOptional(),\n duplicate: z.literal(true).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"SubmissionSummary\",\n description:\n \"A submission as a submit answers it: ID, time, epoch, version, view, digest, delivery.\",\n });\n\n/** A rectangle in CSS pixels, relative to its frame. */\nexport interface Rect {\n /** Distance from the frame's left edge. */\n readonly x: number;\n /** Distance from the frame's top edge. */\n readonly y: number;\n /** Width. */\n readonly width: number;\n /** Height. */\n readonly height: number;\n}\n\n/** A viewport: its size in CSS pixels and its device pixel ratio. */\nexport interface Viewport {\n /** Width in CSS pixels. */\n readonly width: number;\n /** Height in CSS pixels. */\n readonly height: number;\n /** Device pixel ratio. */\n readonly dpr: number;\n}\n\n/** One comment thread in results (INTERFACES §8; built by the review layer, WP-20). */\nexport interface ResultComment {\n /** The thread's ID. */\n readonly threadId: string;\n /** Whether the thread is open or resolved. */\n readonly status: \"open\" | \"resolved\";\n /** The thread's messages, oldest first, each with its author. */\n readonly messages: readonly {\n readonly author: Viewer;\n readonly at: string;\n readonly text: string;\n }[];\n /** Every layer of the anchor that applies (D23). */\n readonly anchor: {\n readonly reviewId?: string;\n /** W3C Web Annotation selectors. */\n readonly selectors?: readonly unknown[];\n readonly rect?: Rect;\n readonly viewport?: Viewport;\n readonly page?: string;\n readonly candidateId?: string;\n readonly terminal?: {\n readonly rows: readonly [number, number];\n readonly cols: readonly [number, number];\n readonly t?: number;\n };\n readonly time?: number;\n readonly slide?: { readonly index: number; readonly step: number };\n };\n /** The screenshot crop, always stored (D23). */\n readonly crop: { readonly path: string; readonly width: number; readonly height: number };\n}\n\n/**\n * The complete submission (INTERFACES §8): what `results/get`, `mostra results` and the\n * submissions port carry. Everything in it comes from the immutable submission and the version it\n * names, never from the live draft (IN-06).\n */\nexport interface Results {\n /** The artifact, with the metadata of the version the viewer saw. */\n readonly artifact: {\n readonly id: string;\n readonly title: string;\n readonly description?: string;\n readonly family?: string;\n readonly links: readonly ArtifactLink[];\n };\n /** The submission's facts: when, how, by whom, from which version and view, and its delivery. */\n readonly submission: {\n readonly id: string;\n readonly at: string;\n readonly epoch: number;\n /** The same viewer's previous submission, under `epochs` (D103). */\n readonly previous?: string;\n readonly policy: SubmissionPolicy;\n readonly channel: SubmitChannel;\n readonly viewer: Viewer;\n readonly versionId: string;\n readonly version: number;\n readonly viewId: string;\n /** Whether a newer version existed when the viewer submitted (H-10). */\n readonly staleView: boolean;\n /** The newest version's number at the time, when the view was stale. */\n readonly latestVersion?: number;\n readonly draftRevision: DocumentRevision;\n readonly stateRevision?: DocumentRevision;\n readonly digest: string;\n readonly delivery: DeliveryState;\n readonly deliveries: readonly DeliveryStatus[];\n };\n /** The draft's fields by ID, dotted IDs nested (D52). */\n readonly answers: Readonly<Record<string, unknown>>;\n /** Every field in `answers` and `state`, with its label and scope. */\n readonly fields: readonly {\n readonly id: string;\n readonly label?: string;\n readonly required?: boolean;\n readonly sensitive?: boolean;\n readonly scope: FieldScope;\n }[];\n /** Artifact state at `stateRevision`, dotted IDs nested (D63). */\n readonly state?: Readonly<Record<string, unknown>>;\n /** The review sets' choices: the fields `review.<set>.choice` (D65). */\n readonly choices: readonly {\n readonly reviewSetId: string;\n readonly candidateId: string;\n readonly label?: string;\n }[];\n /** Comment threads with their anchors and crops (WP-20). */\n readonly comments: readonly ResultComment[];\n /** Answers a newer version couldn't map (D42). */\n readonly orphaned: readonly {\n readonly id: string;\n readonly label?: string;\n readonly value: unknown;\n readonly fromVersion: number;\n }[];\n /** Action runs started in this view (WP-08). */\n readonly actions: readonly {\n readonly runId: string;\n readonly action: string;\n readonly status: string;\n readonly at: string;\n }[];\n /** Signals raised in this view before the submission: the newest 100, within 1 MiB of payloads. */\n readonly signals: readonly {\n readonly name: string;\n readonly at: string;\n readonly payload?: unknown;\n }[];\n /** How many older signals of the view the limit left out; absent when none. */\n readonly signalsOmitted?: number;\n /** Set when compaction removed events of this view before it submitted, so signals may be missing. */\n readonly signalsCompacted?: true;\n}\n\nconst RectSchema = z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n});\n\n/** The Zod schema of the `ResultComment` type. */\nexport const ResultComment: z.ZodType<ResultComment> = z\n .object({\n threadId: z.string(),\n status: z.enum([\"open\", \"resolved\"]),\n messages: z\n .array(z.object({ author: Viewer, at: z.iso.datetime(), text: z.string() }))\n .readonly(),\n anchor: z.object({\n reviewId: z.string().exactOptional(),\n selectors: z.array(z.unknown()).readonly().exactOptional(),\n rect: RectSchema.exactOptional(),\n viewport: z\n .object({ width: z.number(), height: z.number(), dpr: z.number() })\n .exactOptional(),\n page: z.string().exactOptional(),\n candidateId: z.string().exactOptional(),\n terminal: z\n .object({\n rows: z.tuple([z.int(), z.int()]).readonly(),\n cols: z.tuple([z.int(), z.int()]).readonly(),\n t: z.number().exactOptional(),\n })\n .exactOptional(),\n time: z.number().exactOptional(),\n slide: z.object({ index: z.int(), step: z.int() }).exactOptional(),\n }),\n crop: z.object({ path: z.string(), width: z.int(), height: z.int() }),\n })\n .register(wireRegistry, {\n id: \"ResultComment\",\n description: \"One comment thread in results: messages, anchor layers and the screenshot crop.\",\n }) as z.ZodType<ResultComment>;\n\n/** The Zod schema of the `Results` type. */\nexport const Results: z.ZodType<Results> = z\n .object({\n artifact: z.object({\n id: ArtifactId.schema,\n title: z.string(),\n description: z.string().exactOptional(),\n family: z.string().exactOptional(),\n links: z.array(ArtifactLink).readonly(),\n }),\n submission: z.object({\n id: SubmissionId.schema,\n at: z.iso.datetime(),\n epoch: z.int().min(1),\n previous: SubmissionId.schema.exactOptional(),\n policy: SubmissionPolicy,\n channel: z.enum([\"shell\", \"artifact\"]),\n viewer: Viewer,\n versionId: VersionId.schema,\n version: z.int().min(1),\n viewId: ViewId.schema,\n staleView: z.boolean(),\n latestVersion: z.int().min(1).exactOptional(),\n draftRevision: DocumentRevision,\n stateRevision: DocumentRevision.exactOptional(),\n digest: z.string().regex(/^[0-9a-f]{64}$/),\n delivery: z.enum([\"pending\", \"delivered\", \"rejected\", \"undeliverable\"]),\n deliveries: z.array(DeliveryStatus).readonly(),\n }),\n answers: z.record(z.string(), z.unknown()),\n fields: z\n .array(\n z.object({\n id: z.string(),\n label: z.string().exactOptional(),\n required: z.boolean().exactOptional(),\n sensitive: z.boolean().exactOptional(),\n scope: z.enum([\"viewer\", \"artifact\"]),\n }),\n )\n .readonly(),\n state: z.record(z.string(), z.unknown()).exactOptional(),\n choices: z\n .array(\n z.object({\n reviewSetId: z.string(),\n candidateId: z.string(),\n label: z.string().exactOptional(),\n }),\n )\n .readonly(),\n comments: z.array(ResultComment).readonly(),\n orphaned: z\n .array(\n z.object({\n id: z.string(),\n label: z.string().exactOptional(),\n value: z.unknown(),\n fromVersion: z.int().min(1),\n }),\n )\n .readonly(),\n actions: z\n .array(\n z.object({\n runId: z.string(),\n action: z.string(),\n status: z.string(),\n at: z.iso.datetime(),\n }),\n )\n .readonly(),\n signals: z\n .array(\n z.object({ name: z.string(), at: z.iso.datetime(), payload: z.unknown().exactOptional() }),\n )\n .readonly(),\n signalsOmitted: z.int().min(1).exactOptional(),\n signalsCompacted: z.literal(true).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Results\",\n description:\n \"The complete submission: artifact, submission facts, answers, fields, state, choices, comments, orphans, actions, signals.\",\n }) as z.ZodType<Results>;\n"],"mappings":";;;;;;;;;;;;;AA2CA,MAAa,SAA4B,EACtC,OAAO;CACN,IAAI,SAAS;CACb,MAAM,EAAE,KAAK;EAAC;EAAS;EAAW;EAAS;CAAM,CAAC;CAClD,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,KAAK,EAAE,OAAO,CAAC,CAAC,cAAc;AAChC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAcH,MAAa,aAAoC,EAC9C,OAAO;CACN,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAC9B,MAAM,EAAE,OAAO,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;CAC7C,kBAAkB,EAAE,QAAQ,IAAI,CAAC,CAAC,cAAc;AAClD,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"interaction.js","names":[],"sources":["../src/interaction.ts"],"sourcesContent":["/**\n * The interaction ledger's wire types (INTERFACES §4, §6, §7, §8; DATA_MODEL §3, §4): viewers,\n * fields and their mutations, events and their filters, `wait` conditions, submissions, deliveries\n * and results. The host protocol methods (`state/*`, `results/get`, `wait`, `events/*`), the\n * submissions and drafts ports, and the browser protocol all speak these shapes.\n */\nimport * as z from \"zod\";\nimport {\n ArtifactId,\n Cursor,\n DeliveryId,\n SubmissionId,\n VersionId,\n ViewerId,\n ViewId,\n} from \"./ids.ts\";\nimport { ArtifactLink, SubmissionPolicy } from \"./manifest.ts\";\nimport type { SubmitChannel } from \"./view.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\nexport { ControlsPolicy, SubmitChannel, TrustedControl } from \"./view.ts\";\n\n// ── Viewers and actors ────────────────────────────────────────────────────────────────────\n\n/** How Mostra knows a viewer (DATA_MODEL §3 `viewer.kind`). */\n/**\n * How Mostra knows a viewer: `account` and `anonymous` are hosted links' (a signed-in person, and\n * one per browser who isn't signed in, D165 item 8).\n */\nexport type ViewerKind = \"local\" | \"tailnet\" | \"token\" | \"host\" | \"account\" | \"anonymous\";\n\n/**\n * A person who views an artifact (PRODUCT vocabulary). The home's local user is one viewer of kind\n * `local`; a link minted with `viewer` acts as a viewer of kind `token` (D104).\n */\nexport interface Viewer {\n /** The viewer's ID. */\n readonly id: string;\n /** How Mostra knows the viewer. */\n readonly kind: ViewerKind;\n /** The display name, when one is known. */\n readonly name?: string;\n /** The host's own key for this person, as given to `view/url` (D104). */\n readonly ref?: string;\n}\n\n/** The Zod schema of the `Viewer` type. */\nexport const Viewer: z.ZodType<Viewer> = z\n .object({\n id: ViewerId.schema,\n kind: z.enum([\"local\", \"tailnet\", \"token\", \"host\", \"account\", \"anonymous\"]),\n name: z.string().exactOptional(),\n ref: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Viewer\",\n description: \"A person who views an artifact: ID, kind, display name and the host's own key.\",\n });\n\n/**\n * The person a capability link acts for (`view/url`'s `viewer`, D104): the host's stable key for\n * them, such as an email or an account ID, and a display name.\n */\nexport interface ViewerSpec {\n /** The host's stable key for this person: the same `ref` always names the same viewer. */\n readonly ref: string;\n /** The name people see; updated when given again. */\n readonly name?: string;\n}\n\n/** The Zod schema of the `ViewerSpec` type. */\nexport const ViewerSpec: z.ZodType<ViewerSpec> = z\n .object({\n ref: z.string().min(1).max(256),\n name: z.string().min(1).max(256).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ViewerSpec\",\n description: \"The person a capability link acts for: the host's stable key and a display name.\",\n });\n\n/** Who caused an event or wrote a field (DATA_MODEL §4). */\nexport interface Actor {\n /** Who: a viewer, an agent (a protocol client), a host, or Mostra itself. */\n readonly kind: \"viewer\" | \"agent\" | \"host\" | \"mostra\";\n /** A viewer's ID, or the protocol client's name for agents and hosts. */\n readonly id?: string;\n /** A display name, when one is known. */\n readonly name?: string;\n}\n\n/** The Zod schema of the `Actor` type. */\nexport const Actor: z.ZodType<Actor> = z\n .object({\n kind: z.enum([\"viewer\", \"agent\", \"host\", \"mostra\"]),\n id: z.string().exactOptional(),\n name: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Actor\",\n description: \"Who caused an event or wrote a field: a viewer, an agent, a host or Mostra.\",\n });\n\n// ── Fields and mutations ──────────────────────────────────────────────────────────────────\n\n/** The longest field ID, in UTF-16 code units. */\nexport const FIELD_ID_MAX_LENGTH = 256;\n\n/**\n * Whether `id` is a field ID (D52): 1 to 256 characters without control characters; dots separate\n * the parts that nest in results, so none is empty.\n */\nexport function isFieldId(id: unknown): id is string {\n return (\n typeof id === \"string\" &&\n id.length >= 1 &&\n id.length <= FIELD_ID_MAX_LENGTH &&\n // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what it refuses.\n !/[\\u0000-\\u001f\\u007f]/.test(id) &&\n !id.split(\".\").includes(\"\")\n );\n}\n\n/** Which document a field belongs to: the viewer's draft, or the artifact's shared state (D63). */\nexport type FieldScope = \"viewer\" | \"artifact\";\n\n/**\n * A document revision: the decimal string of a document's monotonic counter (DATA_MODEL §3).\n * `\"0\"` is a document nothing has written yet.\n */\nexport type DocumentRevision = string;\n\n/** The Zod schema of the `DocumentRevision` type. */\nexport const DocumentRevision: z.ZodType<DocumentRevision> = z\n .string()\n .regex(/^(0|[1-9][0-9]{0,15})$/)\n .register(wireRegistry, {\n id: \"DocumentRevision\",\n description: \"A draft's or artifact state's revision: a non-negative decimal integer string.\",\n });\n\n/**\n * One change to one field. Exactly one of `value` and `delete` is given. The optional metadata\n * travels with the field into results and decides what events redact (D52, D106).\n */\nexport interface FieldOp {\n /** The field ID (D52). */\n readonly id: string;\n /** The new value: any JSON value, `null` included. */\n readonly value?: unknown;\n /** Removes the field. */\n readonly delete?: true;\n /** The label people see in results and the shell's blocker list. */\n readonly label?: string;\n /** Whether the shell asks for it before submit. */\n readonly required?: boolean;\n /** Kept in submissions and results, redacted from events and logs (D52). */\n readonly sensitive?: boolean;\n}\n\n/** The Zod schema of the `FieldOp` type. */\nexport const FieldOp: z.ZodType<FieldOp> = z\n .object({\n id: z.string().min(1).max(FIELD_ID_MAX_LENGTH),\n value: z.unknown().exactOptional(),\n delete: z.literal(true).exactOptional(),\n label: z.string().max(1024).exactOptional(),\n required: z.boolean().exactOptional(),\n sensitive: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FieldOp\",\n description:\n \"One change to one field: a value or a delete, with optional label, required and sensitive.\",\n }) as z.ZodType<FieldOp>;\n\n/** A field's current state. */\nexport interface FieldState {\n /** The field's value: any JSON value. */\n readonly value: unknown;\n /** The document revision that last wrote it. */\n readonly revision: DocumentRevision;\n /** Who wrote it last. */\n readonly updatedBy?: Actor;\n /** When it was written last. */\n readonly updatedAt: string;\n /** The label people see. */\n readonly label?: string;\n /** Whether the shell asks for it before submit. */\n readonly required?: boolean;\n /** Whether events and logs redact its value (D52). */\n readonly sensitive?: boolean;\n}\n\n/** The Zod schema of the `FieldState` type. */\nexport const FieldState: z.ZodType<FieldState> = z\n .object({\n value: z.unknown(),\n revision: DocumentRevision,\n updatedBy: Actor.exactOptional(),\n updatedAt: z.iso.datetime(),\n label: z.string().exactOptional(),\n required: z.boolean().exactOptional(),\n sensitive: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FieldState\",\n description: \"A field's current value, the revision that wrote it, who wrote it and when.\",\n }) as z.ZodType<FieldState>;\n\n/**\n * A field op that wasn't applied because the field changed after the mutation's base revision\n * (D22, FAILURE_MODEL §5): what the field holds now, so the writer can keep theirs or take it.\n */\nexport interface FieldConflict {\n /** The field's ID. */\n readonly id: string;\n /** The revision that last changed the field. */\n readonly revision: DocumentRevision;\n /** Its current value; absent when it was deleted. */\n readonly value?: unknown;\n /** `true` when the field was deleted. */\n readonly deleted?: true;\n /** Who changed it. */\n readonly updatedBy?: Actor;\n /** When it changed. */\n readonly updatedAt?: string;\n}\n\n/** The Zod schema of the `FieldConflict` type. */\nexport const FieldConflict: z.ZodType<FieldConflict> = z\n .object({\n id: z.string(),\n revision: DocumentRevision,\n value: z.unknown().exactOptional(),\n deleted: z.literal(true).exactOptional(),\n updatedBy: Actor.exactOptional(),\n updatedAt: z.iso.datetime().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FieldConflict\",\n description: \"A field op not applied because the field changed after the base revision.\",\n }) as z.ZodType<FieldConflict>;\n\n/** What a mutation did: the document's revision after it, the ops applied, and the conflicts. */\nexport interface MutationResult {\n /** The document's revision after the mutation; unchanged when nothing applied. */\n readonly revision: DocumentRevision;\n /** The field IDs whose ops were applied. */\n readonly applied: readonly string[];\n /** The ops not applied, with what each field holds now. */\n readonly conflicts: readonly FieldConflict[];\n}\n\n/** The Zod schema of the `MutationResult` type. */\nexport const MutationResult: z.ZodType<MutationResult> = z\n .object({\n revision: DocumentRevision,\n applied: z.array(z.string()).readonly(),\n conflicts: z.array(FieldConflict).readonly(),\n })\n .register(wireRegistry, {\n id: \"MutationResult\",\n description:\n \"A mutation's outcome: the revision after it, the applied field IDs, the conflicts.\",\n });\n\n// ── Events ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Where an owner instance's copy of a hosted record came from (INTERFACES §18.2, D165 item 1): the\n * server, the hosted home, its incarnation and the record's cursor there (a submission's is the\n * cursor of its `submission.created`).\n */\nexport interface EventOrigin {\n /** The server's API origin. */\n readonly server: string;\n /** The hosted home's `hom_` ID. */\n readonly home: string;\n /** The hosted home's incarnation when the record was copied. */\n readonly incarnation: string;\n /** The record's cursor in the hosted home. */\n readonly cursor: Cursor;\n}\n\n/** The Zod schema of the `EventOrigin` type. */\nexport const EventOrigin: z.ZodType<EventOrigin> = z\n .object({\n server: z.string().min(1),\n home: z.string().min(1),\n incarnation: z.string().min(1),\n cursor: Cursor.schema,\n })\n .register(wireRegistry, {\n id: \"EventOrigin\",\n description:\n \"Where an owner's copy of a hosted record came from: server, home, incarnation, cursor.\",\n }) as z.ZodType<EventOrigin>;\n\n/**\n * One durable event (DATA_MODEL §4). Its cursor is its stable ID and its place in the home-wide\n * order; `seq` orders an artifact's own events without gaps.\n */\nexport interface EventRecord {\n /** The event's stable ID and home-wide position. */\n readonly cursor: Cursor;\n /** The artifact, or `null` for a home-wide event. */\n readonly artifactId: string | null;\n /** The artifact's sequence number, or `null` for a home-wide event. */\n readonly seq: number | null;\n /** The type from DATA_MODEL §4's catalog. */\n readonly type: string;\n /** When it was appended. */\n readonly at: string;\n /** Who caused it. */\n readonly actor: Actor;\n /** What caused it: a run, a mutation, a submission. */\n readonly causation?: Readonly<Record<string, string>>;\n /** The event's data; sensitive field values are redacted (D52). */\n readonly payload: Readonly<Record<string, unknown>>;\n /** For an event an owner instance copied from its hosted home: where it came from. */\n readonly origin?: EventOrigin;\n}\n\n/** The Zod schema of the `EventRecord` type. */\nexport const EventRecord: z.ZodType<EventRecord> = z\n .object({\n cursor: Cursor.schema,\n artifactId: ArtifactId.schema.nullable(),\n seq: z.int().min(1).nullable(),\n type: z.string(),\n at: z.iso.datetime(),\n actor: Actor,\n causation: z.record(z.string(), z.string()).exactOptional(),\n payload: z.record(z.string(), z.unknown()),\n origin: EventOrigin.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"EventRecord\",\n description:\n \"One durable event: cursor, artifact, per-artifact sequence, type, time, actor, payload.\",\n }) as z.ZodType<EventRecord>;\n\n/**\n * An event type, or a family of them: `submission.created`, or `submission.*` for every type that\n * starts with `submission.`.\n */\nexport type EventTypePattern = string;\n\n/** The Zod schema of the `EventTypePattern` type. */\nexport const EventTypePattern: z.ZodType<EventTypePattern> = z\n .string()\n .regex(/^[a-z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*(\\.\\*)?$/)\n .register(wireRegistry, {\n id: \"EventTypePattern\",\n description: \"An event type (submission.created) or a family of them (submission.*).\",\n });\n\n/**\n * Which events a reader wants (IN-08, H-09). Both parts are optional, and an event must pass both.\n * `artifact.compacted` always passes for a matching artifact, so a filtered reader still learns of\n * a compaction (DATA_MODEL §4).\n */\nexport interface EventFilter {\n /** Only these artifacts' events; absent: every artifact's, and home-wide ones. */\n readonly artifacts?: readonly string[];\n /** Only these types; absent: every type. */\n readonly types?: readonly EventTypePattern[];\n}\n\n/** The Zod schema of the `EventFilter` type. */\nexport const EventFilter: z.ZodType<EventFilter> = z\n .object({\n artifacts: z.array(ArtifactId.schema).max(1000).readonly().exactOptional(),\n types: z.array(EventTypePattern).max(100).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"EventFilter\",\n description:\n \"Which events a reader wants: these artifacts' and these types (patterns allowed).\",\n });\n\n/**\n * What `wait` waits for (ARCHITECTURE §6, D103): `submitted`, `signal:<name>`, `state:<fieldId>`\n * or `event:<type pattern>`.\n */\nexport type WaitCondition = string;\n\n/** A signal's name: letters, digits, `.`, `_` and `-`, starting with a letter or digit (D106). */\nexport const SIGNAL_NAME_PATTERN: RegExp = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;\n\n/** The Zod schema of the `WaitCondition` type. */\nexport const WaitCondition: z.ZodType<WaitCondition> = z\n .string()\n .regex(\n // biome-ignore lint/suspicious/noControlCharactersInRegex: field IDs exclude control characters.\n /^(submitted|signal:[A-Za-z0-9][A-Za-z0-9._-]{0,63}|state:[^\\u0000-\\u001f\\u007f]{1,256}|event:[a-z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*(\\.\\*)?)$/,\n )\n .register(wireRegistry, {\n id: \"WaitCondition\",\n description: \"What wait waits for: submitted, signal:<name>, state:<fieldId> or event:<type>.\",\n });\n\n// ── Submissions, deliveries and results ──────────────────────────────────────────────────\n\n/** A delivery's state (FAILURE_MODEL §4). */\nexport type DeliveryState = \"pending\" | \"delivered\" | \"rejected\" | \"undeliverable\";\n\n/** One submission's delivery to one host (D105). */\nexport interface DeliveryStatus {\n /** The delivery's stable ID (`dlv_`), repeated by every redelivery. */\n readonly deliveryId: string;\n /**\n * The host: its client name. Empty for Mostra's built-in adapter, which takes submissions when no\n * host does; client names are never empty, so no host can be mistaken for it (D105).\n */\n readonly owner: string;\n /** Where the delivery stands. */\n readonly state: DeliveryState;\n /** How many times Mostra called the host for it. */\n readonly attempts: number;\n /** The host's reason, for a rejection. */\n readonly reason?: string;\n /**\n * `true` while a pending delivery waits: its host isn't connected, or an attempt failed and it\n * will be retried (D47's \"Pending delivery\"). Absent while the first attempt is under way.\n */\n readonly waiting?: true;\n /** When its state last changed. */\n readonly updatedAt: string;\n}\n\n/** The Zod schema of the `DeliveryStatus` type. */\nexport const DeliveryStatus: z.ZodType<DeliveryStatus> = z\n .object({\n deliveryId: DeliveryId.schema,\n owner: z.string(),\n state: z.enum([\"pending\", \"delivered\", \"rejected\", \"undeliverable\"]),\n attempts: z.int().min(0),\n reason: z.string().exactOptional(),\n waiting: z.literal(true).exactOptional(),\n updatedAt: z.iso.datetime(),\n })\n .register(wireRegistry, {\n id: \"DeliveryStatus\",\n description: \"One submission's delivery to one host: owner, state, attempts and reason.\",\n });\n\n/** A submission as a submit answers it (INTERFACES §4). */\nexport interface SubmissionSummary {\n /** The submission's ID. */\n readonly id: string;\n /** When it was made. */\n readonly at: string;\n /** The draft epoch it closed (D103); 1 outside `epochs`. */\n readonly epoch: number;\n /** Where the submit came from (D40). */\n readonly channel: SubmitChannel;\n /** The version the view showed. */\n readonly versionId: string;\n /** That version's number. */\n readonly version: number;\n /** The view it was made from. */\n readonly viewId: string;\n /** Whether a newer version existed when the viewer submitted (H-10). */\n readonly staleView: boolean;\n /** The draft revision it was made from. */\n readonly draftRevision: DocumentRevision;\n /** SHA-256 of the snapshot's canonical JSON (RFC 8785), lowercase hex. */\n readonly digest: string;\n /** Every delivery's state, summed up: the worst of them. */\n readonly delivery: DeliveryState;\n /** Each host's delivery, so a viewer sees which host has it (IN-13). */\n readonly deliveries?: readonly DeliveryStatus[];\n /** `true` when this submit repeated an earlier one and got it back (D22). */\n readonly duplicate?: true;\n}\n\n/** The Zod schema of the `SubmissionSummary` type. */\nexport const SubmissionSummary: z.ZodType<SubmissionSummary> = z\n .object({\n id: SubmissionId.schema,\n at: z.iso.datetime(),\n epoch: z.int().min(1),\n channel: z.enum([\"shell\", \"artifact\"]),\n versionId: VersionId.schema,\n version: z.int().min(1),\n viewId: ViewId.schema,\n staleView: z.boolean(),\n draftRevision: DocumentRevision,\n digest: z.string().regex(/^[0-9a-f]{64}$/),\n delivery: z.enum([\"pending\", \"delivered\", \"rejected\", \"undeliverable\"]),\n deliveries: z.array(DeliveryStatus).readonly().exactOptional(),\n duplicate: z.literal(true).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"SubmissionSummary\",\n description:\n \"A submission as a submit answers it: ID, time, epoch, version, view, digest, delivery.\",\n });\n\n/** A rectangle in CSS pixels, relative to its frame. */\nexport interface Rect {\n /** Distance from the frame's left edge. */\n readonly x: number;\n /** Distance from the frame's top edge. */\n readonly y: number;\n /** Width. */\n readonly width: number;\n /** Height. */\n readonly height: number;\n}\n\n/** A viewport: its size in CSS pixels and its device pixel ratio. */\nexport interface Viewport {\n /** Width in CSS pixels. */\n readonly width: number;\n /** Height in CSS pixels. */\n readonly height: number;\n /** Device pixel ratio. */\n readonly dpr: number;\n}\n\n/** One comment thread in results (INTERFACES §8; built by the review layer, WP-20). */\nexport interface ResultComment {\n /** The thread's ID. */\n readonly threadId: string;\n /** Whether the thread is open or resolved. */\n readonly status: \"open\" | \"resolved\";\n /** The thread's messages, oldest first, each with its author. */\n readonly messages: readonly {\n readonly author: Viewer;\n readonly at: string;\n readonly text: string;\n }[];\n /** Every layer of the anchor that applies (D23). */\n readonly anchor: {\n readonly reviewId?: string;\n /** W3C Web Annotation selectors. */\n readonly selectors?: readonly unknown[];\n readonly rect?: Rect;\n readonly viewport?: Viewport;\n readonly page?: string;\n readonly candidateId?: string;\n readonly terminal?: {\n readonly rows: readonly [number, number];\n readonly cols: readonly [number, number];\n readonly t?: number;\n };\n readonly time?: number;\n readonly slide?: { readonly index: number; readonly step: number };\n };\n /** The screenshot crop, always stored (D23). */\n readonly crop: { readonly path: string; readonly width: number; readonly height: number };\n}\n\n/**\n * The complete submission (INTERFACES §8): what `results/get`, `mostra results` and the\n * submissions port carry. Everything in it comes from the immutable submission and the version it\n * names, never from the live draft (IN-06).\n */\nexport interface Results {\n /** The artifact, with the metadata of the version the viewer saw. */\n readonly artifact: {\n readonly id: string;\n readonly title: string;\n readonly description?: string;\n readonly family?: string;\n readonly links: readonly ArtifactLink[];\n };\n /** The submission's facts: when, how, by whom, from which version and view, and its delivery. */\n readonly submission: {\n readonly id: string;\n readonly at: string;\n readonly epoch: number;\n /** The same viewer's previous submission, under `epochs` (D103). */\n readonly previous?: string;\n readonly policy: SubmissionPolicy;\n readonly channel: SubmitChannel;\n readonly viewer: Viewer;\n readonly versionId: string;\n readonly version: number;\n readonly viewId: string;\n /** Whether a newer version existed when the viewer submitted (H-10). */\n readonly staleView: boolean;\n /** The newest version's number at the time, when the view was stale. */\n readonly latestVersion?: number;\n readonly draftRevision: DocumentRevision;\n readonly stateRevision?: DocumentRevision;\n readonly digest: string;\n readonly delivery: DeliveryState;\n readonly deliveries: readonly DeliveryStatus[];\n /** For a submission imported from a hosted home: where it came from (D165 item 1). */\n readonly origin?: EventOrigin;\n };\n /** The draft's fields by ID, dotted IDs nested (D52). */\n readonly answers: Readonly<Record<string, unknown>>;\n /** Every field in `answers` and `state`, with its label and scope. */\n readonly fields: readonly {\n readonly id: string;\n readonly label?: string;\n readonly required?: boolean;\n readonly sensitive?: boolean;\n readonly scope: FieldScope;\n }[];\n /** Artifact state at `stateRevision`, dotted IDs nested (D63). */\n readonly state?: Readonly<Record<string, unknown>>;\n /** The review sets' choices: the fields `review.<set>.choice` (D65). */\n readonly choices: readonly {\n readonly reviewSetId: string;\n readonly candidateId: string;\n readonly label?: string;\n }[];\n /** Comment threads with their anchors and crops (WP-20). */\n readonly comments: readonly ResultComment[];\n /** Answers a newer version couldn't map (D42). */\n readonly orphaned: readonly {\n readonly id: string;\n readonly label?: string;\n readonly value: unknown;\n readonly fromVersion: number;\n }[];\n /** Action runs started in this view (WP-08). */\n readonly actions: readonly {\n readonly runId: string;\n readonly action: string;\n readonly status: string;\n readonly at: string;\n }[];\n /** Signals raised in this view before the submission: the newest 100, within 1 MiB of payloads. */\n readonly signals: readonly {\n readonly name: string;\n readonly at: string;\n readonly payload?: unknown;\n }[];\n /** How many older signals of the view the limit left out; absent when none. */\n readonly signalsOmitted?: number;\n /** Set when compaction removed events of this view before it submitted, so signals may be missing. */\n readonly signalsCompacted?: true;\n}\n\nconst RectSchema = z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n});\n\n/** The Zod schema of the `ResultComment` type. */\nexport const ResultComment: z.ZodType<ResultComment> = z\n .object({\n threadId: z.string(),\n status: z.enum([\"open\", \"resolved\"]),\n messages: z\n .array(z.object({ author: Viewer, at: z.iso.datetime(), text: z.string() }))\n .readonly(),\n anchor: z.object({\n reviewId: z.string().exactOptional(),\n selectors: z.array(z.unknown()).readonly().exactOptional(),\n rect: RectSchema.exactOptional(),\n viewport: z\n .object({ width: z.number(), height: z.number(), dpr: z.number() })\n .exactOptional(),\n page: z.string().exactOptional(),\n candidateId: z.string().exactOptional(),\n terminal: z\n .object({\n rows: z.tuple([z.int(), z.int()]).readonly(),\n cols: z.tuple([z.int(), z.int()]).readonly(),\n t: z.number().exactOptional(),\n })\n .exactOptional(),\n time: z.number().exactOptional(),\n slide: z.object({ index: z.int(), step: z.int() }).exactOptional(),\n }),\n crop: z.object({ path: z.string(), width: z.int(), height: z.int() }),\n })\n .register(wireRegistry, {\n id: \"ResultComment\",\n description: \"One comment thread in results: messages, anchor layers and the screenshot crop.\",\n }) as z.ZodType<ResultComment>;\n\n/** The Zod schema of the `Results` type. */\nexport const Results: z.ZodType<Results> = z\n .object({\n artifact: z.object({\n id: ArtifactId.schema,\n title: z.string(),\n description: z.string().exactOptional(),\n family: z.string().exactOptional(),\n links: z.array(ArtifactLink).readonly(),\n }),\n submission: z.object({\n id: SubmissionId.schema,\n at: z.iso.datetime(),\n epoch: z.int().min(1),\n previous: SubmissionId.schema.exactOptional(),\n policy: SubmissionPolicy,\n channel: z.enum([\"shell\", \"artifact\"]),\n viewer: Viewer,\n versionId: VersionId.schema,\n version: z.int().min(1),\n viewId: ViewId.schema,\n staleView: z.boolean(),\n latestVersion: z.int().min(1).exactOptional(),\n draftRevision: DocumentRevision,\n stateRevision: DocumentRevision.exactOptional(),\n digest: z.string().regex(/^[0-9a-f]{64}$/),\n delivery: z.enum([\"pending\", \"delivered\", \"rejected\", \"undeliverable\"]),\n deliveries: z.array(DeliveryStatus).readonly(),\n origin: EventOrigin.exactOptional(),\n }),\n answers: z.record(z.string(), z.unknown()),\n fields: z\n .array(\n z.object({\n id: z.string(),\n label: z.string().exactOptional(),\n required: z.boolean().exactOptional(),\n sensitive: z.boolean().exactOptional(),\n scope: z.enum([\"viewer\", \"artifact\"]),\n }),\n )\n .readonly(),\n state: z.record(z.string(), z.unknown()).exactOptional(),\n choices: z\n .array(\n z.object({\n reviewSetId: z.string(),\n candidateId: z.string(),\n label: z.string().exactOptional(),\n }),\n )\n .readonly(),\n comments: z.array(ResultComment).readonly(),\n orphaned: z\n .array(\n z.object({\n id: z.string(),\n label: z.string().exactOptional(),\n value: z.unknown(),\n fromVersion: z.int().min(1),\n }),\n )\n .readonly(),\n actions: z\n .array(\n z.object({\n runId: z.string(),\n action: z.string(),\n status: z.string(),\n at: z.iso.datetime(),\n }),\n )\n .readonly(),\n signals: z\n .array(\n z.object({ name: z.string(), at: z.iso.datetime(), payload: z.unknown().exactOptional() }),\n )\n .readonly(),\n signalsOmitted: z.int().min(1).exactOptional(),\n signalsCompacted: z.literal(true).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Results\",\n description:\n \"The complete submission: artifact, submission facts, answers, fields, state, choices, comments, orphans, actions, signals.\",\n }) as z.ZodType<Results>;\n"],"mappings":";;;;;;;;;;;;;;AA+CA,MAAa,SAA4B,EACtC,OAAO;CACN,IAAI,SAAS;CACb,MAAM,EAAE,KAAK;EAAC;EAAS;EAAW;EAAS;EAAQ;EAAW;CAAW,CAAC;CAC1E,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,KAAK,EAAE,OAAO,CAAC,CAAC,cAAc;AAChC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAcH,MAAa,aAAoC,EAC9C,OAAO;CACN,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAC9B,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,cAAc;AACjD,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AAC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,EAAE,OAAO;EAAG,IAAI,EAAE,IAAI,SAAS;EAAG,SAAS,EAAE,QAAQ,CAAC,CAAC,cAAc;CAAE,CAAC,CAC3F,CAAC,CACA,SAAS;CACZ,gBAAgB,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;CAC7C,kBAAkB,EAAE,QAAQ,IAAI,CAAC,CAAC,cAAc;AAClD,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC"}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Duration } from "./duration.js";
|
|
2
|
+
import { SubmissionPolicy } from "./policy.js";
|
|
1
3
|
import * as z from "zod";
|
|
2
4
|
//#region src/manifest.d.ts
|
|
3
5
|
/** The families Mostra's templates and gallery know; any other string is allowed too. */
|
|
@@ -9,18 +11,6 @@ export interface ArtifactLink {
|
|
|
9
11
|
/** The other artifact's ID. */
|
|
10
12
|
readonly artifact: string;
|
|
11
13
|
}
|
|
12
|
-
/**
|
|
13
|
-
* The submission policy an artifact requests (D10, D39, D63). The host decides the policy in force;
|
|
14
|
-
* the manifest only asks for one.
|
|
15
|
-
*/
|
|
16
|
-
export type SubmissionPolicy = {
|
|
17
|
-
readonly policy: "once";
|
|
18
|
-
readonly scope?: "per-artifact" | "per-viewer";
|
|
19
|
-
} | {
|
|
20
|
-
readonly policy: "epochs";
|
|
21
|
-
} | {
|
|
22
|
-
readonly policy: "none";
|
|
23
|
-
};
|
|
24
14
|
/** A live terminal session the artifact declares (ROUND-3 §5.1, D65). */
|
|
25
15
|
export interface TerminalSpec {
|
|
26
16
|
/** The program and its arguments. */
|
|
@@ -46,6 +36,45 @@ export type DemoSpec = {
|
|
|
46
36
|
readonly attach: number;
|
|
47
37
|
readonly bridge?: boolean;
|
|
48
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* A count by choice the artifact opts into (D165 item 12, RM-07): every accepted submission adds
|
|
41
|
+
* one to the choice its viewer-scoped `field` holds, counted in the submit transaction, and viewers
|
|
42
|
+
* read the counts with `useLive("$tally/<field>")`. A value outside `choices`, or none, counts
|
|
43
|
+
* nothing, so free text is never shown.
|
|
44
|
+
*/
|
|
45
|
+
export interface TallySpec {
|
|
46
|
+
/** The viewer-scoped field whose value is counted. */
|
|
47
|
+
readonly field: string;
|
|
48
|
+
/** The values counted: 2 to 50 distinct strings. */
|
|
49
|
+
readonly choices: readonly string[];
|
|
50
|
+
/** Below this many answers (default 0), viewers see only the total, never the counts. */
|
|
51
|
+
readonly minTotal?: number;
|
|
52
|
+
}
|
|
53
|
+
/** How the artifact behaves on a remote server (D165, INTERFACES §18). */
|
|
54
|
+
export interface HostedSettings {
|
|
55
|
+
/**
|
|
56
|
+
* Relayed action runs while the owner instance is away (D165 item 4): `queue` (the default)
|
|
57
|
+
* waits up to `limit` (default `24h`, at most `7d`), `fail` ends a run at once.
|
|
58
|
+
*/
|
|
59
|
+
readonly offline?: {
|
|
60
|
+
readonly actions?: "queue" | "fail";
|
|
61
|
+
readonly limit?: Duration;
|
|
62
|
+
};
|
|
63
|
+
/** Who may trigger relayed actions (D159): `signed-in` (the default) or anyone with the `link`. */
|
|
64
|
+
readonly actions?: "signed-in" | "link";
|
|
65
|
+
/** Who may submit (D165 item 13): anyone with the `link` (the default), or `signed-in` viewers. */
|
|
66
|
+
readonly submissions?: "link" | "signed-in";
|
|
67
|
+
/** Link previews (D161): `generic` (the default) or the artifact's `title`. */
|
|
68
|
+
readonly preview?: "generic" | "title";
|
|
69
|
+
}
|
|
70
|
+
/** The longest offline limit a hosted artifact may set: 7 days (D165 item 4). */
|
|
71
|
+
export declare const HOSTED_OFFLINE_LIMIT_MAX_MS: number;
|
|
72
|
+
/** The offline limit of a hosted artifact that sets none: 24 hours (D165 item 4). */
|
|
73
|
+
export declare const HOSTED_OFFLINE_LIMIT_DEFAULT: Duration;
|
|
74
|
+
/** The fewest and most choices a tally counts (INTERFACES §18.4). */
|
|
75
|
+
export declare const TALLY_CHOICES_MIN = 2;
|
|
76
|
+
/** The most choices a tally counts. */
|
|
77
|
+
export declare const TALLY_CHOICES_MAX = 50;
|
|
49
78
|
/** The artifact manifest (INTERFACES §2.2). Every field except `title` is optional. */
|
|
50
79
|
export interface ArtifactManifest {
|
|
51
80
|
/** The artifact's ID. Written by `mostra new`; without one, the artifact is bound to its source path at first publish (D51). */
|
|
@@ -84,14 +113,30 @@ export interface ArtifactManifest {
|
|
|
84
113
|
readonly extraChecks?: readonly string[];
|
|
85
114
|
readonly smoke?: boolean;
|
|
86
115
|
};
|
|
116
|
+
/** Counts by choice of fixed-choice fields (D165 item 12). */
|
|
117
|
+
readonly tally?: readonly TallySpec[];
|
|
118
|
+
/** How the artifact behaves on a remote server (D165). */
|
|
119
|
+
readonly hosted?: HostedSettings;
|
|
87
120
|
}
|
|
88
121
|
/** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */
|
|
89
122
|
export declare const ARTIFACT_MANIFEST_KEYS: readonly (keyof ArtifactManifest)[];
|
|
90
123
|
/** The Zod schema of the `ArtifactLink` type. */
|
|
91
124
|
export declare const ArtifactLink: z.ZodType<ArtifactLink>;
|
|
92
|
-
/** The Zod schema of the `
|
|
93
|
-
export declare const
|
|
125
|
+
/** The Zod schema of the `TallySpec` type. */
|
|
126
|
+
export declare const TallySpec: z.ZodType<TallySpec>;
|
|
127
|
+
/** The Zod schema of the `HostedSettings` type. */
|
|
128
|
+
export declare const HostedSettings: z.ZodType<HostedSettings>;
|
|
94
129
|
/** The Zod schema of the `ArtifactManifest` type. Objects stay open, so newer keys pass through. */
|
|
95
130
|
export declare const ArtifactManifest: z.ZodType<ArtifactManifest>;
|
|
131
|
+
/**
|
|
132
|
+
* The rules of a manifest that JSON Schema can't state, checked after its schema by everything
|
|
133
|
+
* that reads a manifest (D165 items 4, 12): a tally's choices are distinct, each field is tallied
|
|
134
|
+
* once, and an offline limit is at most 7 days. Answers the first problem, with its field's path.
|
|
135
|
+
*/
|
|
136
|
+
export declare function manifestProblem(manifest: ArtifactManifest): {
|
|
137
|
+
readonly path: string;
|
|
138
|
+
readonly message: string;
|
|
139
|
+
} | undefined;
|
|
96
140
|
//#endregion
|
|
141
|
+
export { SubmissionPolicy };
|
|
97
142
|
//# sourceMappingURL=manifest.d.ts.map
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","names":[],"sources":["../src/manifest.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","names":[],"sources":["../src/manifest.ts"],"mappings":";;;;;YAoBY;;iBAaK;;WAEN;;WAEA;;;iBAIM;;WAEN;;WAEA;;WAEA,MAAM,SAAS;;WAEf;;WAEA;;WAEA;;;YAIC;WAEG;WACA;WACA;WACA;;WAEA;WAAyB;;;;;;;;iBAQvB;;WAEN;;WAEA;;WAEA;;;iBAIM;;;;;WAKN;aAAqB;aAAqC,QAAQ;;;WAElE;;WAEA;;WAEA;;;qBAIE;;qBAGA,8BAA8B;;qBAG9B;;qBAEA;;iBAGI;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;WAET,iBAAiB;;WAEjB;;WAEA,aAAa;;WAEb;aAAiB;aAAkC;;;WAEnD,YAAY,SAAS,eAAe;;WAEpC,QAAQ,SAAS,eAAe;;WAEhC;aACE;aACA;aACA;;;WAGF;aACE;aACA;aACA;aACA;;;WAGF,iBAAiB;;WAEjB,SAAS;;;qBAIP,wCAAwC;;qBAoBxC,cAAc,EAAE,QAAQ;;qBA2BxB,WAAW,EAAE,QAAQ;;qBAiBrB,gBAAgB,EAAE,QAAQ;;qBAmB1B,kBAAkB,EAAE,QAAQ;;;;;;wBA8CzB,gBACd,UAAU;WACE;WAAuB"}
|
package/dist/manifest.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { wireRegistry } from "./wire-registry.js";
|
|
2
2
|
import { ArtifactId } from "./ids.js";
|
|
3
|
+
import { Duration, durationMs } from "./duration.js";
|
|
4
|
+
import { SubmissionPolicy } from "./policy.js";
|
|
3
5
|
import * as z from "zod";
|
|
4
6
|
//#region src/manifest.ts
|
|
5
7
|
/**
|
|
@@ -12,6 +14,14 @@ import * as z from "zod";
|
|
|
12
14
|
* const checked = ArtifactManifest.safeParse(extracted);
|
|
13
15
|
* ```
|
|
14
16
|
*/
|
|
17
|
+
/** The longest offline limit a hosted artifact may set: 7 days (D165 item 4). */
|
|
18
|
+
const HOSTED_OFFLINE_LIMIT_MAX_MS = 6048e5;
|
|
19
|
+
/** The offline limit of a hosted artifact that sets none: 24 hours (D165 item 4). */
|
|
20
|
+
const HOSTED_OFFLINE_LIMIT_DEFAULT = "24h";
|
|
21
|
+
/** The fewest and most choices a tally counts (INTERFACES §18.4). */
|
|
22
|
+
const TALLY_CHOICES_MIN = 2;
|
|
23
|
+
/** The most choices a tally counts. */
|
|
24
|
+
const TALLY_CHOICES_MAX = 50;
|
|
15
25
|
/** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */
|
|
16
26
|
const ARTIFACT_MANIFEST_KEYS = [
|
|
17
27
|
"id",
|
|
@@ -25,7 +35,9 @@ const ARTIFACT_MANIFEST_KEYS = [
|
|
|
25
35
|
"terminals",
|
|
26
36
|
"demos",
|
|
27
37
|
"limits",
|
|
28
|
-
"verify"
|
|
38
|
+
"verify",
|
|
39
|
+
"tally",
|
|
40
|
+
"hosted"
|
|
29
41
|
];
|
|
30
42
|
const strings = z.array(z.string()).readonly();
|
|
31
43
|
/** The Zod schema of the `ArtifactLink` type. */
|
|
@@ -36,18 +48,6 @@ const ArtifactLink = z.object({
|
|
|
36
48
|
id: "ArtifactLink",
|
|
37
49
|
description: "A related artifact: how this one relates (rel) and the other artifact's ID."
|
|
38
50
|
});
|
|
39
|
-
/** The Zod schema of the `SubmissionPolicy` type. */
|
|
40
|
-
const SubmissionPolicy = z.discriminatedUnion("policy", [
|
|
41
|
-
z.object({
|
|
42
|
-
policy: z.literal("once"),
|
|
43
|
-
scope: z.enum(["per-artifact", "per-viewer"]).exactOptional()
|
|
44
|
-
}),
|
|
45
|
-
z.object({ policy: z.literal("epochs") }),
|
|
46
|
-
z.object({ policy: z.literal("none") })
|
|
47
|
-
]).register(wireRegistry, {
|
|
48
|
-
id: "SubmissionPolicy",
|
|
49
|
-
description: "A submission policy: once (per-artifact or per-viewer), epochs, or none."
|
|
50
|
-
});
|
|
51
51
|
const TerminalSpec = z.object({
|
|
52
52
|
command: z.array(z.string()).min(1).readonly(),
|
|
53
53
|
cwd: z.string().exactOptional(),
|
|
@@ -65,6 +65,28 @@ const DemoSpec = z.union([z.object({
|
|
|
65
65
|
attach: z.int().min(1).max(65535),
|
|
66
66
|
bridge: z.boolean().exactOptional()
|
|
67
67
|
})]);
|
|
68
|
+
/** The Zod schema of the `TallySpec` type. */
|
|
69
|
+
const TallySpec = z.object({
|
|
70
|
+
field: z.string().min(1).max(256),
|
|
71
|
+
choices: z.array(z.string().min(1).max(256)).min(2).max(50).readonly(),
|
|
72
|
+
minTotal: z.int().min(0).exactOptional()
|
|
73
|
+
}).register(wireRegistry, {
|
|
74
|
+
id: "TallySpec",
|
|
75
|
+
description: "A count by choice of a viewer-scoped field: its field, 2 to 50 distinct choices and minTotal."
|
|
76
|
+
});
|
|
77
|
+
/** The Zod schema of the `HostedSettings` type. */
|
|
78
|
+
const HostedSettings = z.object({
|
|
79
|
+
offline: z.object({
|
|
80
|
+
actions: z.enum(["queue", "fail"]).exactOptional(),
|
|
81
|
+
limit: Duration.exactOptional()
|
|
82
|
+
}).exactOptional(),
|
|
83
|
+
actions: z.enum(["signed-in", "link"]).exactOptional(),
|
|
84
|
+
submissions: z.enum(["link", "signed-in"]).exactOptional(),
|
|
85
|
+
preview: z.enum(["generic", "title"]).exactOptional()
|
|
86
|
+
}).register(wireRegistry, {
|
|
87
|
+
id: "HostedSettings",
|
|
88
|
+
description: "How an artifact behaves on a remote server: offline actions, who may act and submit, previews."
|
|
89
|
+
});
|
|
68
90
|
/** The Zod schema of the `ArtifactManifest` type. Objects stay open, so newer keys pass through. */
|
|
69
91
|
const ArtifactManifest = z.object({
|
|
70
92
|
id: ArtifactId.schema.exactOptional(),
|
|
@@ -90,12 +112,38 @@ const ArtifactManifest = z.object({
|
|
|
90
112
|
frames: strings.exactOptional(),
|
|
91
113
|
extraChecks: strings.exactOptional(),
|
|
92
114
|
smoke: z.boolean().exactOptional()
|
|
93
|
-
}).exactOptional()
|
|
115
|
+
}).exactOptional(),
|
|
116
|
+
tally: z.array(TallySpec).readonly().exactOptional(),
|
|
117
|
+
hosted: HostedSettings.exactOptional()
|
|
94
118
|
}).register(wireRegistry, {
|
|
95
119
|
id: "ArtifactManifest",
|
|
96
120
|
description: "The artifact manifest (INTERFACES §2.2): literal metadata from the entry's defineArtifact call or MDX frontmatter."
|
|
97
121
|
});
|
|
122
|
+
/**
|
|
123
|
+
* The rules of a manifest that JSON Schema can't state, checked after its schema by everything
|
|
124
|
+
* that reads a manifest (D165 items 4, 12): a tally's choices are distinct, each field is tallied
|
|
125
|
+
* once, and an offline limit is at most 7 days. Answers the first problem, with its field's path.
|
|
126
|
+
*/
|
|
127
|
+
function manifestProblem(manifest) {
|
|
128
|
+
const fields = /* @__PURE__ */ new Set();
|
|
129
|
+
for (const [index, tally] of (manifest.tally ?? []).entries()) {
|
|
130
|
+
if (new Set(tally.choices).size !== tally.choices.length) return {
|
|
131
|
+
path: `tally.${index}.choices`,
|
|
132
|
+
message: "a tally's choices must be distinct"
|
|
133
|
+
};
|
|
134
|
+
if (fields.has(tally.field)) return {
|
|
135
|
+
path: `tally.${index}.field`,
|
|
136
|
+
message: `\`${tally.field}\` is tallied twice`
|
|
137
|
+
};
|
|
138
|
+
fields.add(tally.field);
|
|
139
|
+
}
|
|
140
|
+
const limit = manifest.hosted?.offline?.limit;
|
|
141
|
+
if (limit !== void 0 && durationMs(limit) > 6048e5) return {
|
|
142
|
+
path: "hosted.offline.limit",
|
|
143
|
+
message: "an offline limit is at most 7d"
|
|
144
|
+
};
|
|
145
|
+
}
|
|
98
146
|
//#endregion
|
|
99
|
-
export { ARTIFACT_MANIFEST_KEYS, ArtifactLink, ArtifactManifest, SubmissionPolicy };
|
|
147
|
+
export { ARTIFACT_MANIFEST_KEYS, ArtifactLink, ArtifactManifest, HOSTED_OFFLINE_LIMIT_DEFAULT, HOSTED_OFFLINE_LIMIT_MAX_MS, HostedSettings, SubmissionPolicy, TALLY_CHOICES_MAX, TALLY_CHOICES_MIN, TallySpec, manifestProblem };
|
|
100
148
|
|
|
101
149
|
//# sourceMappingURL=manifest.js.map
|
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.ts"],"sourcesContent":["/**\n * The artifact manifest (INTERFACES §2.2, D51): the metadata an artifact declares in its entry, as\n * `export const artifact = defineArtifact({...})` in TSX or as YAML frontmatter in MDX. Mostra reads\n * it statically, so every value is a literal. The same type checks `defineArtifact` for authors,\n * validates the extracted literal in the supervisor and travels on the wire in `artifact/get`.\n *\n * ```ts\n * const checked = ArtifactManifest.safeParse(extracted);\n * ```\n */\nimport * as z from \"zod\";\nimport { ArtifactId } from \"./ids.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** The families Mostra's templates and gallery know; any other string is allowed too. */\nexport type ArtifactFamily =\n | \"questionnaire\"\n | \"proposal\"\n | \"prototype\"\n | \"review\"\n | \"dashboard\"\n | \"deck\"\n | \"demo\"\n | \"inbox\"\n | \"tasks\"\n | (string & {});\n\n/** A related artifact (PRODUCT J6): a later round, a follow-up, a replacement. */\nexport interface ArtifactLink {\n /** How this artifact relates to the other one. */\n readonly rel: \"round-of\" | \"follows\" | \"replaces\" | (string & {});\n /** The other artifact's ID. */\n readonly artifact: string;\n}\n\n/**\n * The submission policy an artifact requests (D10, D39, D63). The host decides the policy in force;\n * the manifest only asks for one.\n */\nexport type SubmissionPolicy =\n | { readonly policy: \"once\"; readonly scope?: \"per-artifact\" | \"per-viewer\" }\n | { readonly policy: \"epochs\" }\n | { readonly policy: \"none\" };\n\n/** A live terminal session the artifact declares (ROUND-3 §5.1, D65). */\nexport interface TerminalSpec {\n /** The program and its arguments. */\n readonly command: readonly string[];\n /** Its working directory, relative to the artifact's source. */\n readonly cwd?: string;\n /** Extra environment variables. */\n readonly env?: Readonly<Record<string, string>>;\n /** The terminal's width in cells. */\n readonly cols?: number;\n /** The terminal's height in cells. */\n readonly rows?: number;\n /** Whether viewers may type into it. Sessions are read-only by default. */\n readonly input?: boolean;\n}\n\n/** A web demo the artifact declares (ROUND-3 §5.4, TM-08): a command to run, or a port to attach to. */\nexport type DemoSpec =\n | {\n readonly command: readonly string[];\n readonly cwd?: string;\n readonly ready?: string;\n readonly bridge?: boolean;\n }\n | { readonly attach: number; readonly bridge?: boolean };\n\n/** The artifact manifest (INTERFACES §2.2). Every field except `title` is optional. */\nexport interface ArtifactManifest {\n /** The artifact's ID. Written by `mostra new`; without one, the artifact is bound to its source path at first publish (D51). */\n readonly id?: string;\n /** The title people see. */\n readonly title: string;\n /** One or two sentences on what the artifact is for. */\n readonly description?: string;\n /** What kind of artifact it is; templates and the gallery group by it. */\n readonly family?: ArtifactFamily;\n /** Related artifacts. */\n readonly links?: readonly ArtifactLink[];\n /** How the artifact is built and served: `spa`, the default and the only mode in v1 (D19). */\n readonly mode?: \"spa\";\n /** The submission policy the artifact requests; the host decides (D39, D63). */\n readonly submission?: SubmissionPolicy;\n /** The kit's shadcn base (default `base`, D72) and theme. */\n readonly kit?: { readonly base?: \"base\" | \"radix\"; readonly theme?: string };\n /** Live terminal sessions by name (D65). */\n readonly terminals?: Readonly<Record<string, TerminalSpec>>;\n /** Web demos by name (D65). */\n readonly demos?: Readonly<Record<string, DemoSpec>>;\n /** Stability limits for the artifact's worker (D62). */\n readonly limits?: {\n readonly heapMb?: number;\n readonly watchdogMs?: number;\n readonly idleMinutes?: number;\n };\n /** `verify` settings (D65). */\n readonly verify?: {\n readonly viewports?: readonly string[];\n readonly frames?: readonly string[];\n readonly extraChecks?: readonly string[];\n readonly smoke?: boolean;\n };\n}\n\n/** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */\nexport const ARTIFACT_MANIFEST_KEYS: readonly (keyof ArtifactManifest)[] = [\n \"id\",\n \"title\",\n \"description\",\n \"family\",\n \"links\",\n \"mode\",\n \"submission\",\n \"kit\",\n \"terminals\",\n \"demos\",\n \"limits\",\n \"verify\",\n];\n\nconst strings = z.array(z.string()).readonly();\n\n/** The Zod schema of the `ArtifactLink` type. */\nexport const ArtifactLink: z.ZodType<ArtifactLink> = z\n .object({ rel: z.string().min(1), artifact: z.string().min(1) })\n .register(wireRegistry, {\n id: \"ArtifactLink\",\n description: \"A related artifact: how this one relates (rel) and the other artifact's ID.\",\n });\n\n/** The Zod schema of the `SubmissionPolicy` type. */\nexport const SubmissionPolicy: z.ZodType<SubmissionPolicy> = z\n .discriminatedUnion(\"policy\", [\n z.object({\n policy: z.literal(\"once\"),\n scope: z.enum([\"per-artifact\", \"per-viewer\"]).exactOptional(),\n }),\n z.object({ policy: z.literal(\"epochs\") }),\n z.object({ policy: z.literal(\"none\") }),\n ])\n .register(wireRegistry, {\n id: \"SubmissionPolicy\",\n description: \"A submission policy: once (per-artifact or per-viewer), epochs, or none.\",\n });\n\nconst TerminalSpec: z.ZodType<TerminalSpec> = z.object({\n command: z.array(z.string()).min(1).readonly(),\n cwd: z.string().exactOptional(),\n env: z.record(z.string(), z.string()).readonly().exactOptional(),\n cols: z.int().min(1).exactOptional(),\n rows: z.int().min(1).exactOptional(),\n input: z.boolean().exactOptional(),\n});\n\nconst DemoSpec: z.ZodType<DemoSpec> = z.union([\n z.object({\n command: z.array(z.string()).min(1).readonly(),\n cwd: z.string().exactOptional(),\n ready: z.string().exactOptional(),\n bridge: z.boolean().exactOptional(),\n }),\n z.object({ attach: z.int().min(1).max(65535), bridge: z.boolean().exactOptional() }),\n]);\n\n/** The Zod schema of the `ArtifactManifest` type. Objects stay open, so newer keys pass through. */\nexport const ArtifactManifest: z.ZodType<ArtifactManifest> = z\n .object({\n id: ArtifactId.schema.exactOptional(),\n title: z.string().min(1),\n description: z.string().exactOptional(),\n family: z.string().min(1).exactOptional(),\n links: z.array(ArtifactLink).readonly().exactOptional(),\n mode: z.literal(\"spa\").exactOptional(),\n submission: SubmissionPolicy.exactOptional(),\n kit: z\n .object({\n base: z.enum([\"base\", \"radix\"]).exactOptional(),\n theme: z.string().exactOptional(),\n })\n .exactOptional(),\n terminals: z.record(z.string(), TerminalSpec).readonly().exactOptional(),\n demos: z.record(z.string(), DemoSpec).readonly().exactOptional(),\n limits: z\n .object({\n heapMb: z.int().min(1).exactOptional(),\n watchdogMs: z.int().min(1).exactOptional(),\n idleMinutes: z.number().min(0).exactOptional(),\n })\n .exactOptional(),\n verify: z\n .object({\n viewports: strings.exactOptional(),\n frames: strings.exactOptional(),\n extraChecks: strings.exactOptional(),\n smoke: z.boolean().exactOptional(),\n })\n .exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ArtifactManifest\",\n description:\n \"The artifact manifest (INTERFACES §2.2): literal metadata from the entry's defineArtifact call or MDX frontmatter.\",\n });\n"],"mappings":";;;;;;;;;;;;;;;AA4GA,MAAa,yBAA8D;CACzE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;;AAG7C,MAAa,eAAwC,EAClD,OAAO;CAAE,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAAG,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAAE,CAAC,CAAC,CAC/D,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,mBAAgD,EAC1D,mBAAmB,UAAU;CAC5B,EAAE,OAAO;EACP,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ACES §2.2, D51): the metadata an artifact declares in its entry, as\n * `export const artifact = defineArtifact({...})` in TSX or as YAML frontmatter in MDX. Mostra reads\n * it statically, so every value is a literal. The same type checks `defineArtifact` for authors,\n * validates the extracted literal in the supervisor and travels on the wire in `artifact/get`.\n *\n * ```ts\n * const checked = ArtifactManifest.safeParse(extracted);\n * ```\n */\nimport * as z from \"zod\";\nimport { Duration, durationMs } from \"./duration.ts\";\nimport { SubmissionPolicy } from \"./policy.ts\";\n\nexport { SubmissionPolicy };\n\nimport { ArtifactId } from \"./ids.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** The families Mostra's templates and gallery know; any other string is allowed too. */\nexport type ArtifactFamily =\n | \"questionnaire\"\n | \"proposal\"\n | \"prototype\"\n | \"review\"\n | \"dashboard\"\n | \"deck\"\n | \"demo\"\n | \"inbox\"\n | \"tasks\"\n | (string & {});\n\n/** A related artifact (PRODUCT J6): a later round, a follow-up, a replacement. */\nexport interface ArtifactLink {\n /** How this artifact relates to the other one. */\n readonly rel: \"round-of\" | \"follows\" | \"replaces\" | (string & {});\n /** The other artifact's ID. */\n readonly artifact: string;\n}\n\n/** A live terminal session the artifact declares (ROUND-3 §5.1, D65). */\nexport interface TerminalSpec {\n /** The program and its arguments. */\n readonly command: readonly string[];\n /** Its working directory, relative to the artifact's source. */\n readonly cwd?: string;\n /** Extra environment variables. */\n readonly env?: Readonly<Record<string, string>>;\n /** The terminal's width in cells. */\n readonly cols?: number;\n /** The terminal's height in cells. */\n readonly rows?: number;\n /** Whether viewers may type into it. Sessions are read-only by default. */\n readonly input?: boolean;\n}\n\n/** A web demo the artifact declares (ROUND-3 §5.4, TM-08): a command to run, or a port to attach to. */\nexport type DemoSpec =\n | {\n readonly command: readonly string[];\n readonly cwd?: string;\n readonly ready?: string;\n readonly bridge?: boolean;\n }\n | { readonly attach: number; readonly bridge?: boolean };\n\n/**\n * A count by choice the artifact opts into (D165 item 12, RM-07): every accepted submission adds\n * one to the choice its viewer-scoped `field` holds, counted in the submit transaction, and viewers\n * read the counts with `useLive(\"$tally/<field>\")`. A value outside `choices`, or none, counts\n * nothing, so free text is never shown.\n */\nexport interface TallySpec {\n /** The viewer-scoped field whose value is counted. */\n readonly field: string;\n /** The values counted: 2 to 50 distinct strings. */\n readonly choices: readonly string[];\n /** Below this many answers (default 0), viewers see only the total, never the counts. */\n readonly minTotal?: number;\n}\n\n/** How the artifact behaves on a remote server (D165, INTERFACES §18). */\nexport interface HostedSettings {\n /**\n * Relayed action runs while the owner instance is away (D165 item 4): `queue` (the default)\n * waits up to `limit` (default `24h`, at most `7d`), `fail` ends a run at once.\n */\n readonly offline?: { readonly actions?: \"queue\" | \"fail\"; readonly limit?: Duration };\n /** Who may trigger relayed actions (D159): `signed-in` (the default) or anyone with the `link`. */\n readonly actions?: \"signed-in\" | \"link\";\n /** Who may submit (D165 item 13): anyone with the `link` (the default), or `signed-in` viewers. */\n readonly submissions?: \"link\" | \"signed-in\";\n /** Link previews (D161): `generic` (the default) or the artifact's `title`. */\n readonly preview?: \"generic\" | \"title\";\n}\n\n/** The longest offline limit a hosted artifact may set: 7 days (D165 item 4). */\nexport const HOSTED_OFFLINE_LIMIT_MAX_MS: number = 7 * 24 * 60 * 60 * 1000;\n\n/** The offline limit of a hosted artifact that sets none: 24 hours (D165 item 4). */\nexport const HOSTED_OFFLINE_LIMIT_DEFAULT: Duration = \"24h\";\n\n/** The fewest and most choices a tally counts (INTERFACES §18.4). */\nexport const TALLY_CHOICES_MIN = 2;\n/** The most choices a tally counts. */\nexport const TALLY_CHOICES_MAX = 50;\n\n/** The artifact manifest (INTERFACES §2.2). Every field except `title` is optional. */\nexport interface ArtifactManifest {\n /** The artifact's ID. Written by `mostra new`; without one, the artifact is bound to its source path at first publish (D51). */\n readonly id?: string;\n /** The title people see. */\n readonly title: string;\n /** One or two sentences on what the artifact is for. */\n readonly description?: string;\n /** What kind of artifact it is; templates and the gallery group by it. */\n readonly family?: ArtifactFamily;\n /** Related artifacts. */\n readonly links?: readonly ArtifactLink[];\n /** How the artifact is built and served: `spa`, the default and the only mode in v1 (D19). */\n readonly mode?: \"spa\";\n /** The submission policy the artifact requests; the host decides (D39, D63). */\n readonly submission?: SubmissionPolicy;\n /** The kit's shadcn base (default `base`, D72) and theme. */\n readonly kit?: { readonly base?: \"base\" | \"radix\"; readonly theme?: string };\n /** Live terminal sessions by name (D65). */\n readonly terminals?: Readonly<Record<string, TerminalSpec>>;\n /** Web demos by name (D65). */\n readonly demos?: Readonly<Record<string, DemoSpec>>;\n /** Stability limits for the artifact's worker (D62). */\n readonly limits?: {\n readonly heapMb?: number;\n readonly watchdogMs?: number;\n readonly idleMinutes?: number;\n };\n /** `verify` settings (D65). */\n readonly verify?: {\n readonly viewports?: readonly string[];\n readonly frames?: readonly string[];\n readonly extraChecks?: readonly string[];\n readonly smoke?: boolean;\n };\n /** Counts by choice of fixed-choice fields (D165 item 12). */\n readonly tally?: readonly TallySpec[];\n /** How the artifact behaves on a remote server (D165). */\n readonly hosted?: HostedSettings;\n}\n\n/** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */\nexport const ARTIFACT_MANIFEST_KEYS: readonly (keyof ArtifactManifest)[] = [\n \"id\",\n \"title\",\n \"description\",\n \"family\",\n \"links\",\n \"mode\",\n \"submission\",\n \"kit\",\n \"terminals\",\n \"demos\",\n \"limits\",\n \"verify\",\n \"tally\",\n \"hosted\",\n];\n\nconst strings = z.array(z.string()).readonly();\n\n/** The Zod schema of the `ArtifactLink` type. */\nexport const ArtifactLink: z.ZodType<ArtifactLink> = z\n .object({ rel: z.string().min(1), artifact: z.string().min(1) })\n .register(wireRegistry, {\n id: \"ArtifactLink\",\n description: \"A related artifact: how this one relates (rel) and the other artifact's ID.\",\n });\n\nconst TerminalSpec: z.ZodType<TerminalSpec> = z.object({\n command: z.array(z.string()).min(1).readonly(),\n cwd: z.string().exactOptional(),\n env: z.record(z.string(), z.string()).readonly().exactOptional(),\n cols: z.int().min(1).exactOptional(),\n rows: z.int().min(1).exactOptional(),\n input: z.boolean().exactOptional(),\n});\n\nconst DemoSpec: z.ZodType<DemoSpec> = z.union([\n z.object({\n command: z.array(z.string()).min(1).readonly(),\n cwd: z.string().exactOptional(),\n ready: z.string().exactOptional(),\n bridge: z.boolean().exactOptional(),\n }),\n z.object({ attach: z.int().min(1).max(65535), bridge: z.boolean().exactOptional() }),\n]);\n\n/** The Zod schema of the `TallySpec` type. */\nexport const TallySpec: z.ZodType<TallySpec> = z\n .object({\n field: z.string().min(1).max(256),\n choices: z\n .array(z.string().min(1).max(256))\n .min(TALLY_CHOICES_MIN)\n .max(TALLY_CHOICES_MAX)\n .readonly(),\n minTotal: z.int().min(0).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"TallySpec\",\n description:\n \"A count by choice of a viewer-scoped field: its field, 2 to 50 distinct choices and minTotal.\",\n });\n\n/** The Zod schema of the `HostedSettings` type. */\nexport const HostedSettings: z.ZodType<HostedSettings> = z\n .object({\n offline: z\n .object({\n actions: z.enum([\"queue\", \"fail\"]).exactOptional(),\n limit: Duration.exactOptional(),\n })\n .exactOptional(),\n actions: z.enum([\"signed-in\", \"link\"]).exactOptional(),\n submissions: z.enum([\"link\", \"signed-in\"]).exactOptional(),\n preview: z.enum([\"generic\", \"title\"]).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"HostedSettings\",\n description:\n \"How an artifact behaves on a remote server: offline actions, who may act and submit, previews.\",\n });\n\n/** The Zod schema of the `ArtifactManifest` type. Objects stay open, so newer keys pass through. */\nexport const ArtifactManifest: z.ZodType<ArtifactManifest> = z\n .object({\n id: ArtifactId.schema.exactOptional(),\n title: z.string().min(1),\n description: z.string().exactOptional(),\n family: z.string().min(1).exactOptional(),\n links: z.array(ArtifactLink).readonly().exactOptional(),\n mode: z.literal(\"spa\").exactOptional(),\n submission: SubmissionPolicy.exactOptional(),\n kit: z\n .object({\n base: z.enum([\"base\", \"radix\"]).exactOptional(),\n theme: z.string().exactOptional(),\n })\n .exactOptional(),\n terminals: z.record(z.string(), TerminalSpec).readonly().exactOptional(),\n demos: z.record(z.string(), DemoSpec).readonly().exactOptional(),\n limits: z\n .object({\n heapMb: z.int().min(1).exactOptional(),\n watchdogMs: z.int().min(1).exactOptional(),\n idleMinutes: z.number().min(0).exactOptional(),\n })\n .exactOptional(),\n verify: z\n .object({\n viewports: strings.exactOptional(),\n frames: strings.exactOptional(),\n extraChecks: strings.exactOptional(),\n smoke: z.boolean().exactOptional(),\n })\n .exactOptional(),\n tally: z.array(TallySpec).readonly().exactOptional(),\n hosted: HostedSettings.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ArtifactManifest\",\n description:\n \"The artifact manifest (INTERFACES §2.2): literal metadata from the entry's defineArtifact call or MDX frontmatter.\",\n });\n\n/**\n * The rules of a manifest that JSON Schema can't state, checked after its schema by everything\n * that reads a manifest (D165 items 4, 12): a tally's choices are distinct, each field is tallied\n * once, and an offline limit is at most 7 days. Answers the first problem, with its field's path.\n */\nexport function manifestProblem(\n manifest: ArtifactManifest,\n): { readonly path: string; readonly message: string } | undefined {\n const fields = new Set<string>();\n for (const [index, tally] of (manifest.tally ?? []).entries()) {\n if (new Set(tally.choices).size !== tally.choices.length) {\n return { path: `tally.${index}.choices`, message: \"a tally's choices must be distinct\" };\n }\n if (fields.has(tally.field)) {\n return { path: `tally.${index}.field`, message: `\\`${tally.field}\\` is tallied twice` };\n }\n fields.add(tally.field);\n }\n const limit = manifest.hosted?.offline?.limit;\n if (limit !== undefined && durationMs(limit) > HOSTED_OFFLINE_LIMIT_MAX_MS) {\n return { path: \"hosted.offline.limit\", message: \"an offline limit is at most 7d\" };\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiGA,MAAa,8BAAsC;;AAGnD,MAAa,+BAAyC;;AAGtD,MAAa,oBAAoB;;AAEjC,MAAa,oBAAoB;;AA4CjC,MAAa,yBAA8D;CACzE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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MAAM,KAAK;CACxB;CACA,MAAM,QAAQ,SAAS,QAAQ,SAAS;CACxC,IAAI,UAAU,KAAA,KAAa,WAAW,KAAK,IAAA,QACzC,OAAO;EAAE,MAAM;EAAwB,SAAS;CAAiC;AAGrF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ArtifactRef } from "../../artifact.js";
|
|
2
|
+
import { MethodDefinition } from "../../method.js";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
//#region src/methods/artifact/export.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* An export class (ARCHITECTURE §3, VR-07). `bundle` is the portable artifact package (RM-01,
|
|
7
|
+
* WP-29); WP-24 adds `static`, `html` and `snapshot`, and WP-17 `mcp-app`, additively.
|
|
8
|
+
*/
|
|
9
|
+
export type ExportClass = "bundle";
|
|
10
|
+
/** The Zod schema of the `ExportClass` type. */
|
|
11
|
+
export declare const ExportClass: z.ZodType<ExportClass>;
|
|
12
|
+
/** The params of `artifact/export` (INTERFACES §6, §15). */
|
|
13
|
+
export interface ArtifactExportParams {
|
|
14
|
+
/** The artifact: its ID, or a source path it was published from. */
|
|
15
|
+
readonly artifact: ArtifactRef;
|
|
16
|
+
/** The version: a number or a version ID; the latest when absent. */
|
|
17
|
+
readonly version?: number | string;
|
|
18
|
+
/** What to write. */
|
|
19
|
+
readonly as: ExportClass;
|
|
20
|
+
/**
|
|
21
|
+
* Where: an absolute path. A bundle is a directory there, or one archive when the path ends in
|
|
22
|
+
* `.tar.zst`. It must not exist yet, or be an empty directory.
|
|
23
|
+
*/
|
|
24
|
+
readonly out: string;
|
|
25
|
+
}
|
|
26
|
+
/** The result of `artifact/export`. */
|
|
27
|
+
export interface ArtifactExportResult {
|
|
28
|
+
/** What it wrote, as absolute paths: the bundle's directory or archive. */
|
|
29
|
+
readonly files: readonly string[];
|
|
30
|
+
/** The version exported. */
|
|
31
|
+
readonly versionId: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `artifact/export`: writes a published version out of the home. A `bundle` carries the version's
|
|
35
|
+
* builds, manifest, lockfile and source snapshot, so `artifact/import` (`mostra run <bundle>`) in
|
|
36
|
+
* another home makes it the same version, with the same artifact and version IDs (RM-01).
|
|
37
|
+
*/
|
|
38
|
+
export declare const artifactExportMethod: MethodDefinition<ArtifactExportParams, ArtifactExportResult>;
|
|
39
|
+
//#endregion
|
|
40
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","names":[],"sources":["../../../src/methods/artifact/export.ts"],"mappings":";;;;;;;;YASY;;qBAGC,aAAa,EAAE,QAAQ;;iBAKnB;;WAEN,UAAU;;WAEV;;WAEA,IAAI;;;;;WAKJ;;;iBAIM;;WAEN;;WAEA;;;;;;;qBAwBE,sBAAsB,iBAAiB,sBAAsB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { wireRegistry } from "../../wire-registry.js";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.js";
|
|
3
|
+
import { defineMethod } from "../../method.js";
|
|
4
|
+
import * as z from "zod";
|
|
5
|
+
//#region src/methods/artifact/export.ts
|
|
6
|
+
/** The Zod schema of the `ExportClass` type. */
|
|
7
|
+
const ExportClass = z.enum(["bundle"]).register(wireRegistry, {
|
|
8
|
+
id: "ExportClass",
|
|
9
|
+
description: "An export class (VR-07)."
|
|
10
|
+
});
|
|
11
|
+
const params = z.object({
|
|
12
|
+
artifact: ArtifactRef,
|
|
13
|
+
version: z.union([z.int().min(1), z.string().min(1)]).exactOptional(),
|
|
14
|
+
as: ExportClass,
|
|
15
|
+
out: z.string().min(1)
|
|
16
|
+
}).register(wireRegistry, { id: "ArtifactExportParams" });
|
|
17
|
+
const result = z.object({
|
|
18
|
+
files: z.array(z.string()).readonly(),
|
|
19
|
+
versionId: z.string()
|
|
20
|
+
}).register(wireRegistry, { id: "ArtifactExportResult" });
|
|
21
|
+
/**
|
|
22
|
+
* `artifact/export`: writes a published version out of the home. A `bundle` carries the version's
|
|
23
|
+
* builds, manifest, lockfile and source snapshot, so `artifact/import` (`mostra run <bundle>`) in
|
|
24
|
+
* another home makes it the same version, with the same artifact and version IDs (RM-01).
|
|
25
|
+
*/
|
|
26
|
+
const artifactExportMethod = defineMethod({
|
|
27
|
+
method: "artifact/export",
|
|
28
|
+
direction: "client-to-instance",
|
|
29
|
+
mutating: false,
|
|
30
|
+
params,
|
|
31
|
+
result
|
|
32
|
+
});
|
|
33
|
+
//#endregion
|
|
34
|
+
export { ExportClass, artifactExportMethod };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","names":[],"sources":["../../../src/methods/artifact/export.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/**\n * An export class (ARCHITECTURE §3, VR-07). `bundle` is the portable artifact package (RM-01,\n * WP-29); WP-24 adds `static`, `html` and `snapshot`, and WP-17 `mcp-app`, additively.\n */\nexport type ExportClass = \"bundle\";\n\n/** The Zod schema of the `ExportClass` type. */\nexport const ExportClass: z.ZodType<ExportClass> = z\n .enum([\"bundle\"])\n .register(wireRegistry, { id: \"ExportClass\", description: \"An export class (VR-07).\" });\n\n/** The params of `artifact/export` (INTERFACES §6, §15). */\nexport interface ArtifactExportParams {\n /** The artifact: its ID, or a source path it was published from. */\n readonly artifact: ArtifactRef;\n /** The version: a number or a version ID; the latest when absent. */\n readonly version?: number | string;\n /** What to write. */\n readonly as: ExportClass;\n /**\n * Where: an absolute path. A bundle is a directory there, or one archive when the path ends in\n * `.tar.zst`. It must not exist yet, or be an empty directory.\n */\n readonly out: string;\n}\n\n/** The result of `artifact/export`. */\nexport interface ArtifactExportResult {\n /** What it wrote, as absolute paths: the bundle's directory or archive. */\n readonly files: readonly string[];\n /** The version exported. */\n readonly versionId: string;\n}\n\nconst params: z.ZodType<ArtifactExportParams> = z\n .object({\n artifact: ArtifactRef,\n version: z.union([z.int().min(1), z.string().min(1)]).exactOptional(),\n as: ExportClass,\n out: z.string().min(1),\n })\n .register(wireRegistry, { id: \"ArtifactExportParams\" });\n\nconst result: z.ZodType<ArtifactExportResult> = z\n .object({\n files: z.array(z.string()).readonly(),\n versionId: z.string(),\n })\n .register(wireRegistry, { id: \"ArtifactExportResult\" });\n\n/**\n * `artifact/export`: writes a published version out of the home. A `bundle` carries the version's\n * builds, manifest, lockfile and source snapshot, so `artifact/import` (`mostra run <bundle>`) in\n * another home makes it the same version, with the same artifact and version IDs (RM-01).\n */\nexport const artifactExportMethod: MethodDefinition<ArtifactExportParams, ArtifactExportResult> =\n defineMethod({\n method: \"artifact/export\",\n direction: \"client-to-instance\",\n mutating: false,\n params,\n result,\n });\n"],"mappings":";;;;;;AAYA,MAAa,cAAsC,EAChD,KAAK,CAAC,QAAQ,CAAC,CAAC,CAChB,SAAS,cAAc;CAAE,IAAI;CAAe,aAAa;AAA2B,CAAC;AAyBxF,MAAM,SAA0C,EAC7C,OAAO;CACN,UAAU;CACV,SAAS,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc;CACpE,IAAI;CACJ,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AACvB,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,uBAAuB,CAAC;AAExD,MAAM,SAA0C,EAC7C,OAAO;CACN,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACpC,WAAW,EAAE,OAAO;AACtB,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,uBAAuB,CAAC;;;;;;AAOxD,MAAa,uBACX,aAAa;CACX,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PublishReceipt } from "../../artifact.js";
|
|
2
|
+
import { MethodDefinition } from "../../method.js";
|
|
3
|
+
//#region src/methods/artifact/import.d.ts
|
|
4
|
+
/** The params of `artifact/import` (INTERFACES §15). */
|
|
5
|
+
export interface ArtifactImportParams {
|
|
6
|
+
/** A bundle `artifact/export` wrote: its directory or its `.tar.zst` archive, as an absolute path. */
|
|
7
|
+
readonly bundle: string;
|
|
8
|
+
/** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */
|
|
9
|
+
readonly requestId?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The result of `artifact/import`: the receipt of the version it made, or found (`reused`), with
|
|
13
|
+
* the bundle's artifact and version IDs.
|
|
14
|
+
*/
|
|
15
|
+
export type ArtifactImportResult = PublishReceipt;
|
|
16
|
+
/**
|
|
17
|
+
* `artifact/import`: makes a portable bundle a published version of this home (RM-01; the CLI's
|
|
18
|
+
* `mostra run <bundle>`): the same artifact ID, version ID and digests, checked against the
|
|
19
|
+
* bundle's files before anything is kept. Its server code runs here, against the bundle's lockfile.
|
|
20
|
+
*/
|
|
21
|
+
export declare const artifactImportMethod: MethodDefinition<ArtifactImportParams, ArtifactImportResult>;
|
|
22
|
+
//#endregion
|
|
23
|
+
//# sourceMappingURL=import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.d.ts","names":[],"sources":["../../../src/methods/artifact/import.ts"],"mappings":";;;;iBAMiB;;WAEN;;WAEA;;;;;;YAOC,uBAAuB;;;;;;qBActB,sBAAsB,iBAAiB,sBAAsB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { wireRegistry } from "../../wire-registry.js";
|
|
2
|
+
import { PublishReceipt } from "../../artifact.js";
|
|
3
|
+
import { defineMethod } from "../../method.js";
|
|
4
|
+
import * as z from "zod";
|
|
5
|
+
//#region src/methods/artifact/import.ts
|
|
6
|
+
const params = z.object({
|
|
7
|
+
bundle: z.string().min(1),
|
|
8
|
+
requestId: z.string().min(1).exactOptional()
|
|
9
|
+
}).register(wireRegistry, { id: "ArtifactImportParams" });
|
|
10
|
+
/**
|
|
11
|
+
* `artifact/import`: makes a portable bundle a published version of this home (RM-01; the CLI's
|
|
12
|
+
* `mostra run <bundle>`): the same artifact ID, version ID and digests, checked against the
|
|
13
|
+
* bundle's files before anything is kept. Its server code runs here, against the bundle's lockfile.
|
|
14
|
+
*/
|
|
15
|
+
const artifactImportMethod = defineMethod({
|
|
16
|
+
method: "artifact/import",
|
|
17
|
+
direction: "client-to-instance",
|
|
18
|
+
mutating: true,
|
|
19
|
+
params,
|
|
20
|
+
result: PublishReceipt
|
|
21
|
+
});
|
|
22
|
+
//#endregion
|
|
23
|
+
export { artifactImportMethod };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.js","names":[],"sources":["../../../src/methods/artifact/import.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { PublishReceipt } from \"../../artifact.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/** The params of `artifact/import` (INTERFACES §15). */\nexport interface ArtifactImportParams {\n /** A bundle `artifact/export` wrote: its directory or its `.tar.zst` archive, as an absolute path. */\n readonly bundle: string;\n /** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */\n readonly requestId?: string;\n}\n\n/**\n * The result of `artifact/import`: the receipt of the version it made, or found (`reused`), with\n * the bundle's artifact and version IDs.\n */\nexport type ArtifactImportResult = PublishReceipt;\n\nconst params: z.ZodType<ArtifactImportParams> = z\n .object({\n bundle: z.string().min(1),\n requestId: z.string().min(1).exactOptional(),\n })\n .register(wireRegistry, { id: \"ArtifactImportParams\" });\n\n/**\n * `artifact/import`: makes a portable bundle a published version of this home (RM-01; the CLI's\n * `mostra run <bundle>`): the same artifact ID, version ID and digests, checked against the\n * bundle's files before anything is kept. Its server code runs here, against the bundle's lockfile.\n */\nexport const artifactImportMethod: MethodDefinition<ArtifactImportParams, ArtifactImportResult> =\n defineMethod({\n method: \"artifact/import\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result: PublishReceipt,\n });\n"],"mappings":";;;;;AAmBA,MAAM,SAA0C,EAC7C,OAAO;CACN,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACxB,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;AAC7C,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,uBAAuB,CAAC;;;;;;AAOxD,MAAa,uBACX,aAAa;CACX,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA,QAAQ;AACV,CAAC"}
|