@mostra/protocol 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +11 -3
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/browser.d.ts +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.js +2 -2
- package/dist/diagnostics/codes/remote.js.map +1 -1
- package/dist/diagnostics/codes/team.d.ts +8 -0
- package/dist/diagnostics/codes/team.d.ts.map +1 -0
- package/dist/diagnostics/codes/team.js +44 -0
- package/dist/diagnostics/codes/team.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.d.ts.map +1 -1
- package/dist/diagnostics/diagnostic.js +2 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/index.d.ts +13 -6
- package/dist/index.js +11 -4
- package/dist/interaction.d.ts +12 -3
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +15 -12
- package/dist/interaction.js.map +1 -1
- package/dist/manifest.d.ts +3 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +5 -2
- package/dist/manifest.js.map +1 -1
- package/dist/methods/index.d.ts.map +1 -1
- package/dist/methods/index.js +10 -2
- package/dist/methods/index.js.map +1 -1
- package/dist/methods/port/trusted-controls-policy.d.ts +1 -1
- package/dist/methods/results/get.d.ts +3 -1
- package/dist/methods/results/get.d.ts.map +1 -1
- package/dist/methods/results/get.js +4 -3
- package/dist/methods/results/get.js.map +1 -1
- package/dist/methods/results/list.d.ts +33 -0
- package/dist/methods/results/list.d.ts.map +1 -0
- package/dist/methods/results/list.js +35 -0
- package/dist/methods/results/list.js.map +1 -0
- package/dist/methods/roster/add.d.ts +47 -0
- package/dist/methods/roster/add.d.ts.map +1 -0
- package/dist/methods/roster/add.js +46 -0
- package/dist/methods/roster/add.js.map +1 -0
- package/dist/methods/roster/get.d.ts +18 -0
- package/dist/methods/roster/get.d.ts.map +1 -0
- package/dist/methods/roster/get.js +22 -0
- package/dist/methods/roster/get.js.map +1 -0
- package/dist/methods/roster/remove.d.ts +28 -0
- package/dist/methods/roster/remove.d.ts.map +1 -0
- package/dist/methods/roster/remove.js +31 -0
- package/dist/methods/roster/remove.js.map +1 -0
- package/dist/methods/share/start.d.ts +15 -2
- package/dist/methods/share/start.d.ts.map +1 -1
- package/dist/methods/share/start.js +5 -1
- package/dist/methods/share/start.js.map +1 -1
- package/dist/methods/state/get.d.ts +1 -1
- package/dist/methods/state/patch.d.ts +1 -1
- package/dist/methods/view/url.d.ts +1 -1
- package/dist/methods/wait/wait.d.ts +1 -1
- package/dist/operator.d.ts +93 -11
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js.map +1 -1
- package/dist/team-settings.d.ts +21 -0
- package/dist/team-settings.d.ts.map +1 -0
- package/dist/team-settings.js +27 -0
- package/dist/team-settings.js.map +1 -0
- package/dist/team.d.ts +221 -0
- package/dist/team.d.ts.map +1 -0
- package/dist/team.js +162 -0
- package/dist/team.js.map +1 -0
- package/dist/verify.d.ts +7 -0
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/package.json +1 -1
- package/schemas/protocol.draft-07.json +802 -79
- package/schemas/protocol.schema.json +782 -91
- package/src/actions.ts +8 -4
- package/src/diagnostics/codes/index.ts +6 -2
- package/src/diagnostics/codes/remote.ts +2 -2
- package/src/diagnostics/codes/team.ts +53 -0
- package/src/diagnostics/diagnostic.ts +3 -1
- package/src/index.ts +47 -2
- package/src/interaction.ts +24 -5
- package/src/manifest.ts +5 -0
- package/src/methods/index.ts +8 -0
- package/src/methods/results/get.ts +3 -2
- package/src/methods/results/list.ts +61 -0
- package/src/methods/roster/add.ts +77 -0
- package/src/methods/roster/get.ts +30 -0
- package/src/methods/roster/remove.ts +49 -0
- package/src/methods/share/start.ts +23 -3
- package/src/operator.ts +83 -10
- package/src/team-settings.ts +38 -0
- package/src/team.ts +398 -0
- package/src/verify.ts +7 -0
|
@@ -5,6 +5,8 @@ import { ArtifactRef } from "../../artifact.js";
|
|
|
5
5
|
import { ViewerSpec } from "../../interaction.js";
|
|
6
6
|
import { CapabilityScope } from "../../capability.js";
|
|
7
7
|
import { defineMethod } from "../../method.js";
|
|
8
|
+
import { ROSTER_MAX, RespondentSpec } from "../../team.js";
|
|
9
|
+
import { RespondentLink } from "../roster/add.js";
|
|
8
10
|
import * as z from "zod";
|
|
9
11
|
//#region src/methods/share/start.ts
|
|
10
12
|
/** The Zod schema of the `ShareVia` type. */
|
|
@@ -48,11 +50,13 @@ const params = z.object({
|
|
|
48
50
|
ttl: Duration.exactOptional(),
|
|
49
51
|
scopes: z.array(CapabilityScope).min(1).readonly().exactOptional(),
|
|
50
52
|
viewer: ViewerSpec.exactOptional(),
|
|
53
|
+
respondents: z.array(RespondentSpec).min(1).max(ROSTER_MAX).readonly().exactOptional(),
|
|
51
54
|
requestId: z.string().min(1).exactOptional()
|
|
52
55
|
}).register(wireRegistry, { id: "ShareStartParams" });
|
|
53
56
|
const result = z.object({
|
|
54
57
|
...shareShape,
|
|
55
|
-
url: z.string().min(1)
|
|
58
|
+
url: z.string().min(1),
|
|
59
|
+
respondents: z.array(RespondentLink).readonly().exactOptional()
|
|
56
60
|
}).register(wireRegistry, {
|
|
57
61
|
id: "ShareStartResult",
|
|
58
62
|
description: "The share that started, with its capability URL."
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","names":[],"sources":["../../../src/methods/share/start.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { CapabilityScope } from \"../../capability.ts\";\nimport { Duration } from \"../../duration.ts\";\nimport { ArtifactId, ShareId, TokenId } from \"../../ids.ts\";\nimport { ViewerSpec } from \"../../interaction.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/**\n * How a share reaches its viewers (D158): `tailnet` through Tailscale Serve, to the people of the\n * user's tailnet, who are known by name; `funnel` through Tailscale Funnel and `cloudflare`\n * through a Cloudflare quick tunnel, both public, where the link is all that admits a viewer.\n */\nexport type ShareVia = \"tailnet\" | \"funnel\" | \"cloudflare\" | \"remote\";\n\n/** The Zod schema of the `ShareVia` type. */\nexport const ShareVia: z.ZodType<ShareVia> = z\n .enum([\"tailnet\", \"funnel\", \"cloudflare\", \"remote\"])\n .register(wireRegistry, {\n id: \"ShareVia\",\n description:\n \"How a share reaches its viewers: tailnet, funnel or cloudflare, or remote: hosted on a remote server (D165).\",\n });\n\n/** The longest a public share (Funnel or Cloudflare) may last: 7 days (D158). */\nexport const PUBLIC_SHARE_MAX_TTL_MS: number = 7 * 24 * 60 * 60 * 1000;\n\n/** How long a public share lasts when its `ttl` isn't given: 1 hour (D63 item 5, D158). */\nexport const PUBLIC_SHARE_DEFAULT_TTL: Duration = \"1h\";\n\n/** The params of `share/start` (INTERFACES §6, D158). */\nexport interface ShareStartParams {\n /** The artifact to share; the link opens its latest version. */\n readonly artifact: ArtifactRef;\n /** The tunnel. A public one (`funnel`, `cloudflare`) is explicit: never a fallback. */\n readonly via: ShareVia;\n /** For `remote`: the server's API origin. Default: the home's default server (D165 item 15). */\n readonly server?: string;\n /**\n * How long the share and its link last, such as `30m` or `24h`. Public shares: 1 hour by\n * default, at most 7 days. Tailnet shares: until stopped, unless given.\n */\n readonly ttl?: Duration;\n /** What the share's link allows (D97). Default: every scope. */\n readonly scopes?: readonly CapabilityScope[];\n /**\n * The person the share's link acts for (D104). Absent: whoever the tailnet or a host's identity\n * port names, else the link's own viewer, never the home's local user (D158).\n */\n readonly viewer?: ViewerSpec;\n /** Makes retries idempotent: a repeated `requestId` returns the same share (H-03). */\n readonly requestId?: string;\n}\n\n/** A share, as `share/start` and `share/list` report it. */\nexport interface Share {\n /** The share's ID, for `share/stop`. */\n readonly shareId: string;\n /** The artifact shared. */\n readonly artifactId: string;\n /** The tunnel. */\n readonly via: ShareVia;\n /**\n * The share's capability URL, at the tunnel's address. Holding it is the authorization (D06);\n * absent once the share ended, and in `share/list` when the home's key can no longer show it.\n */\n readonly url?: string;\n /** The tunnel's host name: the tailnet device's, or the quick tunnel's random one. */\n readonly hostname: string;\n /**\n * The address the artifact's frame is served at over the tunnel, while the share is active:\n * on a tailnet, the second port of this device that viewers must be allowed to reach.\n */\n readonly artifactOrigin?: string;\n /**\n * How the artifact's frame authenticates over this tunnel (D70): `cookie` where the shell and\n * the artifact are one site (Tailscale), `worker` where they are two (Cloudflare).\n */\n readonly mode: \"cookie\" | \"worker\";\n /** The share's link, for `view/rotate` and `view/revoke`. */\n readonly tokenId: string;\n /** When the share started (RFC 3339, UTC). */\n readonly startedAt: string;\n /** When the share and its link end, if they do. */\n readonly expiresAt?: string;\n /** `active` while it serves; `stopped` once it ended. */\n readonly state: \"active\" | \"stopped\";\n /** When it ended. */\n readonly stoppedAt?: string;\n /**\n * Why it ended: `stopped` (`share/stop`), `expired` (its TTL), `tunnel` (its tunnel ended and\n * couldn't be set up again), `restart` (a quick tunnel can't outlive its instance), or\n * `revoked` (its link was revoked).\n */\n readonly stopReason?: \"stopped\" | \"expired\" | \"tunnel\" | \"restart\" | \"revoked\" | (string & {});\n}\n\nconst shareShape = {\n shareId: ShareId.schema,\n artifactId: ArtifactId.schema,\n via: ShareVia,\n url: z.string().min(1).exactOptional(),\n hostname: z.string().min(1),\n artifactOrigin: z.string().min(1).exactOptional(),\n mode: z.enum([\"cookie\", \"worker\"]),\n tokenId: TokenId.schema,\n startedAt: z.iso.datetime(),\n expiresAt: z.iso.datetime().exactOptional(),\n state: z.enum([\"active\", \"stopped\"]),\n stoppedAt: z.iso.datetime().exactOptional(),\n stopReason: z.string().min(1).exactOptional(),\n};\n\n/** The Zod schema of the `Share` type. */\nexport const Share: z.ZodType<Share> = z.object(shareShape).register(wireRegistry, {\n id: \"Share\",\n description: \"A share: its tunnel, link, address, frame mode and lifetime.\",\n});\n\n
|
|
1
|
+
{"version":3,"file":"start.js","names":[],"sources":["../../../src/methods/share/start.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { CapabilityScope } from \"../../capability.ts\";\nimport { Duration } from \"../../duration.ts\";\nimport { ArtifactId, ShareId, TokenId } from \"../../ids.ts\";\nimport { ViewerSpec } from \"../../interaction.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { RespondentSpec, ROSTER_MAX } from \"../../team.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\nimport { RespondentLink } from \"../roster/add.ts\";\n\n/**\n * How a share reaches its viewers (D158): `tailnet` through Tailscale Serve, to the people of the\n * user's tailnet, who are known by name; `funnel` through Tailscale Funnel and `cloudflare`\n * through a Cloudflare quick tunnel, both public, where the link is all that admits a viewer.\n */\nexport type ShareVia = \"tailnet\" | \"funnel\" | \"cloudflare\" | \"remote\";\n\n/** The Zod schema of the `ShareVia` type. */\nexport const ShareVia: z.ZodType<ShareVia> = z\n .enum([\"tailnet\", \"funnel\", \"cloudflare\", \"remote\"])\n .register(wireRegistry, {\n id: \"ShareVia\",\n description:\n \"How a share reaches its viewers: tailnet, funnel or cloudflare, or remote: hosted on a remote server (D165).\",\n });\n\n/** The longest a public share (Funnel or Cloudflare) may last: 7 days (D158). */\nexport const PUBLIC_SHARE_MAX_TTL_MS: number = 7 * 24 * 60 * 60 * 1000;\n\n/** How long a public share lasts when its `ttl` isn't given: 1 hour (D63 item 5, D158). */\nexport const PUBLIC_SHARE_DEFAULT_TTL: Duration = \"1h\";\n\n/** The params of `share/start` (INTERFACES §6, D158). */\nexport interface ShareStartParams {\n /** The artifact to share; the link opens its latest version. */\n readonly artifact: ArtifactRef;\n /** The tunnel. A public one (`funnel`, `cloudflare`) is explicit: never a fallback. */\n readonly via: ShareVia;\n /** For `remote`: the server's API origin. Default: the home's default server (D165 item 15). */\n readonly server?: string;\n /**\n * How long the share and its link last, such as `30m` or `24h`. Public shares: 1 hour by\n * default, at most 7 days. Tailnet shares: until stopped, unless given.\n */\n readonly ttl?: Duration;\n /** What the share's link allows (D97). Default: every scope. */\n readonly scopes?: readonly CapabilityScope[];\n /**\n * The person the share's link acts for (D104). Absent: whoever the tailnet or a host's identity\n * port names, else the link's own viewer, never the home's local user (D158).\n */\n readonly viewer?: ViewerSpec;\n /**\n * People the artifact expects answers from through this share (D121, D168): they join the\n * roster of the home that holds the artifact's viewers (a remote share's hosted home), and each\n * gets a personal link at the share's address. On a remote server, `email` reaches the operator's\n * `invitations` port. Not with `viewer`.\n */\n readonly respondents?: readonly RespondentSpec[];\n /** Makes retries idempotent: a repeated `requestId` returns the same share (H-03). */\n readonly requestId?: string;\n}\n\n/** A share, as `share/start` and `share/list` report it. */\nexport interface Share {\n /** The share's ID, for `share/stop`. */\n readonly shareId: string;\n /** The artifact shared. */\n readonly artifactId: string;\n /** The tunnel. */\n readonly via: ShareVia;\n /**\n * The share's capability URL, at the tunnel's address. Holding it is the authorization (D06);\n * absent once the share ended, and in `share/list` when the home's key can no longer show it.\n */\n readonly url?: string;\n /** The tunnel's host name: the tailnet device's, or the quick tunnel's random one. */\n readonly hostname: string;\n /**\n * The address the artifact's frame is served at over the tunnel, while the share is active:\n * on a tailnet, the second port of this device that viewers must be allowed to reach.\n */\n readonly artifactOrigin?: string;\n /**\n * How the artifact's frame authenticates over this tunnel (D70): `cookie` where the shell and\n * the artifact are one site (Tailscale), `worker` where they are two (Cloudflare).\n */\n readonly mode: \"cookie\" | \"worker\";\n /** The share's link, for `view/rotate` and `view/revoke`. */\n readonly tokenId: string;\n /** When the share started (RFC 3339, UTC). */\n readonly startedAt: string;\n /** When the share and its link end, if they do. */\n readonly expiresAt?: string;\n /** `active` while it serves; `stopped` once it ended. */\n readonly state: \"active\" | \"stopped\";\n /** When it ended. */\n readonly stoppedAt?: string;\n /**\n * Why it ended: `stopped` (`share/stop`), `expired` (its TTL), `tunnel` (its tunnel ended and\n * couldn't be set up again), `restart` (a quick tunnel can't outlive its instance), or\n * `revoked` (its link was revoked).\n */\n readonly stopReason?: \"stopped\" | \"expired\" | \"tunnel\" | \"restart\" | \"revoked\" | (string & {});\n}\n\nconst shareShape = {\n shareId: ShareId.schema,\n artifactId: ArtifactId.schema,\n via: ShareVia,\n url: z.string().min(1).exactOptional(),\n hostname: z.string().min(1),\n artifactOrigin: z.string().min(1).exactOptional(),\n mode: z.enum([\"cookie\", \"worker\"]),\n tokenId: TokenId.schema,\n startedAt: z.iso.datetime(),\n expiresAt: z.iso.datetime().exactOptional(),\n state: z.enum([\"active\", \"stopped\"]),\n stoppedAt: z.iso.datetime().exactOptional(),\n stopReason: z.string().min(1).exactOptional(),\n};\n\n/** The Zod schema of the `Share` type. */\nexport const Share: z.ZodType<Share> = z.object(shareShape).register(wireRegistry, {\n id: \"Share\",\n description: \"A share: its tunnel, link, address, frame mode and lifetime.\",\n});\n\n/**\n * The result of `share/start`: the share, with its link, and the personal link of every respondent\n * it named (D168).\n */\nexport type ShareStartResult = Share & {\n readonly url: string;\n readonly respondents?: readonly RespondentLink[];\n};\n\nconst params: z.ZodType<ShareStartParams> = z\n .object({\n artifact: ArtifactRef,\n via: ShareVia,\n server: z\n .string()\n .regex(/^https?:\\/\\/[^/?#\\s]+$/)\n .exactOptional(),\n ttl: Duration.exactOptional(),\n scopes: z.array(CapabilityScope).min(1).readonly().exactOptional(),\n viewer: ViewerSpec.exactOptional(),\n respondents: z.array(RespondentSpec).min(1).max(ROSTER_MAX).readonly().exactOptional(),\n requestId: z.string().min(1).exactOptional(),\n })\n .register(wireRegistry, { id: \"ShareStartParams\" });\n\nconst result: z.ZodType<ShareStartResult> = z\n .object({\n ...shareShape,\n url: z.string().min(1),\n respondents: z.array(RespondentLink).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ShareStartResult\",\n description: \"The share that started, with its capability URL.\",\n });\n\n/**\n * `share/start`: shares an artifact through a tunnel the instance drives (D158): Tailscale Serve\n * for the tailnet, or Tailscale Funnel or a Cloudflare quick tunnel for anyone with the link. It\n * answers once the tunnel serves, with a new link at the tunnel's address that works there only.\n * A missing or unready tool is a `MOSTRA_SHARE_*` diagnostic saying what to do.\n */\nexport const shareStartMethod: MethodDefinition<ShareStartParams, ShareStartResult> = defineMethod({\n method: \"share/start\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result,\n});\n"],"mappings":";;;;;;;;;;;;AAmBA,MAAa,WAAgC,EAC1C,KAAK;CAAC;CAAW;CAAU;CAAc;AAAQ,CAAC,CAAC,CACnD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AAGH,MAAa,0BAAkC;;AAG/C,MAAa,2BAAqC;AA4ElD,MAAM,aAAa;CACjB,SAAS,QAAQ;CACjB,YAAY,WAAW;CACvB,KAAK;CACL,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;CACrC,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC1B,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;CAChD,MAAM,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC;CACjC,SAAS,QAAQ;CACjB,WAAW,EAAE,IAAI,SAAS;CAC1B,WAAW,EAAE,IAAI,SAAS,CAAC,CAAC,cAAc;CAC1C,OAAO,EAAE,KAAK,CAAC,UAAU,SAAS,CAAC;CACnC,WAAW,EAAE,IAAI,SAAS,CAAC,CAAC,cAAc;CAC1C,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;AAC9C;;AAGA,MAAa,QAA0B,EAAE,OAAO,UAAU,CAAC,CAAC,SAAS,cAAc;CACjF,IAAI;CACJ,aAAa;AACf,CAAC;AAWD,MAAM,SAAsC,EACzC,OAAO;CACN,UAAU;CACV,KAAK;CACL,QAAQ,EACL,OAAO,CAAC,CACR,MAAM,wBAAwB,CAAC,CAC/B,cAAc;CACjB,KAAK,SAAS,cAAc;CAC5B,QAAQ,EAAE,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CACjE,QAAQ,WAAW,cAAc;CACjC,aAAa,EAAE,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CACrF,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;AAC7C,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,mBAAmB,CAAC;AAEpD,MAAM,SAAsC,EACzC,OAAO;CACN,GAAG;CACH,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACrB,aAAa,EAAE,MAAM,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;AAChE,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;;;;;;AAQH,MAAa,mBAAyE,aAAa;CACjG,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArtifactRef } from "../../artifact.js";
|
|
2
1
|
import { DocumentRevision, FieldState } from "../../interaction.js";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.js";
|
|
3
3
|
import { MethodDefinition } from "../../method.js";
|
|
4
4
|
//#region src/methods/state/get.d.ts
|
|
5
5
|
/** The params of `state/get` (INTERFACES §6, D63). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArtifactRef } from "../../artifact.js";
|
|
2
1
|
import { DocumentRevision, FieldOp, MutationResult } from "../../interaction.js";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.js";
|
|
3
3
|
import { MethodDefinition } from "../../method.js";
|
|
4
4
|
//#region src/methods/state/patch.d.ts
|
|
5
5
|
/** The params of `state/patch` (INTERFACES §6, D63, D106). */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Duration } from "../../duration.js";
|
|
2
|
-
import { ArtifactRef } from "../../artifact.js";
|
|
3
2
|
import { Viewer, ViewerSpec } from "../../interaction.js";
|
|
3
|
+
import { ArtifactRef } from "../../artifact.js";
|
|
4
4
|
import { CapabilityScope } from "../../capability.js";
|
|
5
5
|
import { MethodDefinition } from "../../method.js";
|
|
6
6
|
import * as z from "zod";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArtifactRef } from "../../artifact.js";
|
|
2
1
|
import { EventRecord, WaitCondition } from "../../interaction.js";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.js";
|
|
3
3
|
import { MethodDefinition } from "../../method.js";
|
|
4
4
|
//#region src/methods/wait/wait.d.ts
|
|
5
5
|
/** The longest `wait`, in milliseconds: the longest timer JavaScript keeps (about 24.8 days). */
|
package/dist/operator.d.ts
CHANGED
|
@@ -15,8 +15,14 @@ export declare const OPERATOR_TIME_LIMITS: {
|
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* An operation `limits.check` judges. When the operator doesn't answer in time, `share`,
|
|
18
|
-
* `version.push`, `link` and authoring fail closed, and `view`, `submit
|
|
19
|
-
* so nothing a person typed is lost (D165
|
|
18
|
+
* `version.push`, `link` and authoring fail closed, and `view`, `submit`, draft writes and relayed
|
|
19
|
+
* actions (`run`, `run.wait`, `call`) proceed, so nothing a person typed or pressed is lost (D165
|
|
20
|
+
* item 9).
|
|
21
|
+
*
|
|
22
|
+
* - `run`: a relayed action run is about to be recorded (quantity 1). A request that joins a run
|
|
23
|
+
* already recorded (its key or client key) is never asked.
|
|
24
|
+
* - `run.wait`: that run would wait for its owner, who is away (quantity 1), asked after `run`.
|
|
25
|
+
* - `call`: a plain call is about to be relayed to the owner (quantity 1).
|
|
20
26
|
*/
|
|
21
27
|
export type LimitOperation = "share" | "version.push" | "link" | "view" | "submit" | "run" | "run.wait" | "call" | "mcp.call" | "storage";
|
|
22
28
|
/** What `limits.check` is asked. */
|
|
@@ -29,9 +35,15 @@ export interface LimitQuery {
|
|
|
29
35
|
readonly artifact?: string;
|
|
30
36
|
/** The artifact's hosted route, for operations on one (WP-30). */
|
|
31
37
|
readonly routeId?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The version being pushed, on `version.push` and `storage` (MT-03): a push that takes several
|
|
40
|
+
* rounds (the owner uploads the files it was told are missing, then pushes again) asks about the
|
|
41
|
+
* same version each round, so an operator counting versions counts this ID once.
|
|
42
|
+
*/
|
|
43
|
+
readonly versionId?: string;
|
|
32
44
|
/** What is asked for. */
|
|
33
45
|
readonly operation: LimitOperation;
|
|
34
|
-
/** How much: bytes for `storage
|
|
46
|
+
/** How much: bytes for `storage`, else 1. */
|
|
35
47
|
readonly quantity?: number;
|
|
36
48
|
}
|
|
37
49
|
/** How long the server may keep an answer instead of asking again, in milliseconds (WP-30). */
|
|
@@ -52,8 +64,14 @@ export type LimitAnswer = ({
|
|
|
52
64
|
} & Cacheable);
|
|
53
65
|
/** The schema the server checks `limits.check`'s answer against. */
|
|
54
66
|
export declare const LimitAnswer: z.ZodType<LimitAnswer>;
|
|
55
|
-
/**
|
|
56
|
-
|
|
67
|
+
/**
|
|
68
|
+
* A counter's name (INTERFACES §18.6). `bytes.stored` sums the client bytes a home uploads in a
|
|
69
|
+
* window; `bytes.held` is a level, not a sum: the client bytes a home holds, each file once however
|
|
70
|
+
* many of its versions name it, sent in the window after it changes (so it falls to what is left,
|
|
71
|
+
* and to 0 once, when content is removed), and for every home holding anything at the first window
|
|
72
|
+
* after a server starts and once a day (MT-03). Keep the latest value per home.
|
|
73
|
+
*/
|
|
74
|
+
export type MeterName = "views" | "submissions" | "requests" | "bytes.stored" | "bytes.held" | "bytes.egress" | "relay.messages" | "mcp.calls" | "home.activeSeconds" | (string & {});
|
|
57
75
|
/**
|
|
58
76
|
* One counter of a batch. `views` carry `viewerKey`, a monthly pseudonymous key (an HMAC under a
|
|
59
77
|
* key the server rotates each month), never an identity: per account for a signed-in viewer, per
|
|
@@ -90,7 +108,10 @@ export interface MeterBatch {
|
|
|
90
108
|
}
|
|
91
109
|
/**
|
|
92
110
|
* Who an identity provider says signed in (INTERFACES §18.5). `facts` carries what a provider
|
|
93
|
-
* tells beyond that
|
|
111
|
+
* tells beyond that, for an operator's policy: the built-in GitHub adapter gives `login`, the
|
|
112
|
+
* account's age (`createdAt`) and its public counts (`publicRepos`, `publicGists`, `followers`, from
|
|
113
|
+
* the same lookup, MT-03); the OpenID Connect adapter gives the ID token's claims its configuration
|
|
114
|
+
* names (`claims`, such as a Google Workspace account's domain `hd`), each under its own name.
|
|
94
115
|
*/
|
|
95
116
|
export interface SignInIdentity {
|
|
96
117
|
/** The provider's ID (`IdentityProvider.id`). */
|
|
@@ -103,7 +124,7 @@ export interface SignInIdentity {
|
|
|
103
124
|
readonly emailVerified?: boolean;
|
|
104
125
|
/** The display name the provider gives. */
|
|
105
126
|
readonly name?: string;
|
|
106
|
-
/** What else the provider tells (an account's age as `createdAt
|
|
127
|
+
/** What else the provider tells (an account's age as `createdAt`, chosen claims). */
|
|
107
128
|
readonly facts?: Readonly<Record<string, unknown>>;
|
|
108
129
|
}
|
|
109
130
|
/** The schema the server checks a provider's `SignInIdentity` against. */
|
|
@@ -133,6 +154,17 @@ export interface IdentityProvider {
|
|
|
133
154
|
readonly id: string;
|
|
134
155
|
/** What the sign-in page calls it ("GitHub"). */
|
|
135
156
|
readonly label: string;
|
|
157
|
+
/**
|
|
158
|
+
* Whether the provider verifies the names it gives, and the label a hosted page's sender line
|
|
159
|
+
* shows for it ("verified with Acme"; 1 to 64 characters, shown as text). Absent: a person who
|
|
160
|
+
* signs in through it is shown "name not verified". The server records the label on the sign-in
|
|
161
|
+
* identity when the provider links or signs in that person, so renaming or retiring the provider
|
|
162
|
+
* later changes no name already verified (MT-03). The built-in providers verify, but for the
|
|
163
|
+
* development one.
|
|
164
|
+
*/
|
|
165
|
+
readonly verifies?: {
|
|
166
|
+
readonly label: string;
|
|
167
|
+
};
|
|
136
168
|
/** Where to send the person: the provider's authorization URL with `state` and PKCE. */
|
|
137
169
|
authorize(state: string, pkce: SignInPkce, context: SignInContext): string | Promise<string>;
|
|
138
170
|
/**
|
|
@@ -261,7 +293,10 @@ export interface LinkPolicy extends Cacheable {
|
|
|
261
293
|
};
|
|
262
294
|
/** The longest a link may live from when it was minted. */
|
|
263
295
|
readonly maxTtl?: string;
|
|
264
|
-
/**
|
|
296
|
+
/**
|
|
297
|
+
* A link without a view for this long expires: judged from its last view before the one being
|
|
298
|
+
* opened (or from its minting), so a fresh visit to an idle link is refused as well (MT-03).
|
|
299
|
+
*/
|
|
265
300
|
readonly idleExpiry?: string;
|
|
266
301
|
/** The line after "Your answer was sent.", as text. */
|
|
267
302
|
readonly afterSubmit?: string;
|
|
@@ -324,7 +359,9 @@ export type OperatorEventKind = "submission.accepted" | "version.pushed" | "run.
|
|
|
324
359
|
/**
|
|
325
360
|
* One outbound event, delivered at least once with a stable `eventId`. `payload`:
|
|
326
361
|
* `submission.accepted` carries the submission's `Results` (INTERFACES §8, the `Results` type of `@mostra/protocol`); `version.pushed`
|
|
327
|
-
* `{ versionId, number }`; `run.ended` `{ runId, action, status }`; `roster.completed`
|
|
362
|
+
* `{ versionId, number }`; `run.ended` `{ runId, action, status }`; `roster.completed`
|
|
363
|
+
* `{ round, respondents, submissions: { ref, submissionId }[] }`, when every expected respondent
|
|
364
|
+
* answered (D168).
|
|
328
365
|
* `label` is the route's label, so an operator running several servers behind one front learns
|
|
329
366
|
* which serves which label (WP-30).
|
|
330
367
|
*/
|
|
@@ -412,8 +449,53 @@ export interface OperatorPorts {
|
|
|
412
449
|
readonly events?: {
|
|
413
450
|
deliver(e: OperatorEvent): Promise<void>;
|
|
414
451
|
};
|
|
415
|
-
/**
|
|
416
|
-
|
|
452
|
+
/**
|
|
453
|
+
* Invitations to expected respondents (D121, D168): for each respondent a hosted roster names
|
|
454
|
+
* with an `email`, when they are added or their personal link is replaced, so the operator can
|
|
455
|
+
* mail them their link. At least once, ordered per home, with a stable `invitationId`. No mailer
|
|
456
|
+
* ships: the open server only hands them over. Default: none sent.
|
|
457
|
+
*/
|
|
458
|
+
readonly invitations?: {
|
|
459
|
+
send(invitation: Invitation): Promise<void>;
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* One invitation (D168). `url` is the respondent's personal link, a capability URL whose secret is
|
|
464
|
+
* in its fragment: the server never stores or logs it (it builds it from the link's token when it
|
|
465
|
+
* hands the invitation over), so the operator mails it and keeps it no longer than that.
|
|
466
|
+
*/
|
|
467
|
+
export interface Invitation {
|
|
468
|
+
/** Stable across retries: `<home>:<tokenId>`, one per personal link. */
|
|
469
|
+
readonly invitationId: string;
|
|
470
|
+
/** The account that owns the route. */
|
|
471
|
+
readonly account: string;
|
|
472
|
+
/** Its hosted home. */
|
|
473
|
+
readonly home: string;
|
|
474
|
+
/** The route. */
|
|
475
|
+
readonly routeId: string;
|
|
476
|
+
/** The route's label. */
|
|
477
|
+
readonly label: string;
|
|
478
|
+
/** The artifact's ID. */
|
|
479
|
+
readonly artifactId: string;
|
|
480
|
+
/** The artifact's title, as its latest version names it. */
|
|
481
|
+
readonly title: string;
|
|
482
|
+
/** Who is invited: the owner's key for them, their name and the address to write to. */
|
|
483
|
+
readonly respondent: {
|
|
484
|
+
readonly ref: string;
|
|
485
|
+
readonly name?: string;
|
|
486
|
+
readonly email: string;
|
|
487
|
+
};
|
|
488
|
+
/** Who invites: the owner's display name and the provider that verified it, when one did. */
|
|
489
|
+
readonly sender: {
|
|
490
|
+
readonly name?: string;
|
|
491
|
+
readonly verifiedBy?: string;
|
|
492
|
+
};
|
|
493
|
+
/** The personal link. */
|
|
494
|
+
readonly url: string;
|
|
495
|
+
/** When the link stops working, when it has a lifetime. */
|
|
496
|
+
readonly expiresAt?: string;
|
|
497
|
+
/** When the respondent was added, or their link replaced. */
|
|
498
|
+
readonly at: string;
|
|
417
499
|
}
|
|
418
500
|
/** A hosted route, or one version of it: what the handle's quarantine and release act on. */
|
|
419
501
|
export type RouteTarget = {
|
package/dist/operator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","names":[],"sources":["../src/operator.ts"],"mappings":";;;qBA4Ba;;qBAGA;WACF;WACA;WACA;WACA;WACA;WACA;WACA;WACA
|
|
1
|
+
{"version":3,"file":"operator.d.ts","names":[],"sources":["../src/operator.ts"],"mappings":";;;qBA4Ba;;qBAGA;WACF;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;;;;;;;YAyBC;;iBAaK;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;WAMA;;WAEA,WAAW;;WAEX;;;iBAIM;;WAEN;;;YAIC;WACI;IAAkB;WAEnB;;WAEA;;WAEA;WACA;IACP;;qBAKK,aAAa,EAAE,QAAQ;;;;;;;;YAoBxB;;;;;;;;iBAmBK;;WAEN,MAAM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA,aAAa,SAAS;;;iBAIhB;;WAEN;;WAEA;;WAEA;;WAEA,mBAAmB;;;;;;;;;iBAYb;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA,QAAQ,SAAS;;;qBAIf,gBAAgB,EAAE,QAAQ;;iBAUtB;;WAEN;;WAEA;;WAEA;;;iBAIM;;WAEN;;WAEA;;;;;;iBAOM;;WAEN;;WAEA;;;;;;;;;WASA;aAAsB;;;EAE/B,UAAU,eAAe,MAAM,YAAY,SAAS,yBAAyB;;;;;;;EAO7E,SACE,QAAQ,SAAS,yBACjB,SAAS;aAA2B;aAAwB,MAAM;MACjE,QAAQ;;;;;;;;;;;;;YAcD;WAEG;WACA;WACA;;WAEA;aAAiB;;;WACjB;aAAoB;;;;qBAGtB,mBAAmB,EAAE,QAA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AAQ,GAAG,gBAAgB;;;;;;;;WAOtC;IAAgB,KAAK,YAAY,aAAa;;;;;;;;iBAQxC;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;aAAuB;aAAsB;aAAwB;;;WAErE;aAAmB;aAAwB;;;WAE3C;;WAEA;;WAEA;;;YAIC;WACG;;WACA;WAA0B;;;;;;iBAMxB;;WAEN;;WAEA;;EAET,WAAW,QAAQ,aAAa,iBAAiB;;EAEjD,QAAQ,QAAQ,cAAc;;EAE9B,MAAM,iBAAiB,iBAAiB;;EAExC,OAAO,kBAAkB;;EAEzB,YAAY,cAAc,iBAAiB;;EAE3C,WAAW,eAAe;;EAE1B,YAAY,kBAAkB;;EAE9B,WAAW,kBAAkB;;EAE7B,UAAU,eAAe;;EAEzB,YAAY,eAAe;;EAE3B,SAAS,eAAe;;EAExB,OAAO,kBAAkB;;;YAIf,kBAAkB,QAAQ,iBAAiB,gBAAgB,QAAQ;;wBAG/D,eAAe,QAAQ,iBAAiB"}
|
package/dist/operator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.js","names":[],"sources":["../src/operator.ts"],"sourcesContent":["/**\n * The operator boundary of a remote server (ARCHITECTURE §15.10, INTERFACES §18.6, D165 items 9\n * and 11): the ports an operating layer implements in an ES module the server loads in process,\n * and the handle the server gives it. Each port is optional and has a no-op default, so a\n * self-hoster needs none of it; each call is async and time-limited, and the server checks every\n * answer against the schemas below before it acts on one (an answer they refuse counts as no\n * answer).\n *\n * An operating layer imports nothing of Mostra but this module (`@mostra/protocol/operator`), so\n * the surface it builds on is this file's, versioned with `@mostra/protocol` and changed only\n * additively (D32).\n *\n * ```ts\n * import { defineOperator } from \"@mostra/protocol/operator\";\n *\n * export default defineOperator((server) => ({\n * limits: { check: async (q) => (q.operation === \"share\" ? { allowed: true } : { allowed: true }) },\n * abuse: { report: async (r) => { await server.quarantine({ routeId: r.routeId }, r.reason); } },\n * }));\n * ```\n *\n * Every port call and every handle target names a hosted route (`rte_…`): an artifact ID, and a\n * version ID derived from it (D89), repeat across homes when a project is copied, so a bare ID\n * would reach every tenant hosting it.\n */\nimport * as z from \"zod\";\n\n/** The operator boundary's own revision, which a module may check (additive within it). */\nexport const OPERATOR_REVISION = \"2026-11-08\";\n\n/** How long the server waits for each port, in milliseconds, before it acts as if none answered. */\nexport const OPERATOR_TIME_LIMITS: {\n readonly limits: number;\n readonly policy: number;\n readonly routing: number;\n readonly identity: number;\n readonly accounts: number;\n readonly authenticate: number;\n readonly pushed: number;\n readonly outbound: number;\n} = {\n limits: 2_000,\n policy: 2_000,\n routing: 2_000,\n identity: 2_000,\n accounts: 5_000,\n authenticate: 5_000,\n pushed: 30_000,\n outbound: 30_000,\n};\n\n// ── limits ──────────────────────────────────────────────────────────────────────────────\n\n/**\n * An operation `limits.check` judges. When the operator doesn't answer in time, `share`,\n * `version.push`, `link` and authoring fail closed, and `view`, `submit` and draft writes proceed,\n * so nothing a person typed is lost (D165 item 9).\n */\nexport type LimitOperation =\n | \"share\"\n | \"version.push\"\n | \"link\"\n | \"view\"\n | \"submit\"\n | \"run\"\n | \"run.wait\"\n | \"call\"\n | \"mcp.call\"\n | \"storage\";\n\n/** What `limits.check` is asked. */\nexport interface LimitQuery {\n /** The account the operation counts against. */\n readonly account: string;\n /** The account's hosted home. */\n readonly home: string;\n /** The artifact, for operations on one. */\n readonly artifact?: string;\n /** The artifact's hosted route, for operations on one (WP-30). */\n readonly routeId?: string;\n /** What is asked for. */\n readonly operation: LimitOperation;\n /** How much: bytes for `storage` and `version.push`, else 1. */\n readonly quantity?: number;\n}\n\n/** How long the server may keep an answer instead of asking again, in milliseconds (WP-30). */\nexport interface Cacheable {\n /** Absent or 0: ask again next time. */\n readonly cacheForMs?: number;\n}\n\n/** `limits.check`'s answer. */\nexport type LimitAnswer =\n | ({ readonly allowed: true } & Cacheable)\n | ({\n readonly allowed: false;\n /** A diagnostic code of the operator's (the server answers `MOSTRA_REMOTE_LIMIT_REACHED`). */\n readonly code: string;\n /** Shown as text to whoever was refused. */\n readonly message: string;\n readonly retryAfterMs?: number;\n } & Cacheable);\n\nconst cacheFor = z.int().min(0).max(86_400_000).exactOptional();\n\n/** The schema the server checks `limits.check`'s answer against. */\nexport const LimitAnswer: z.ZodType<LimitAnswer> = z.union([\n z.object({ allowed: z.literal(true), cacheForMs: cacheFor }),\n z.object({\n allowed: z.literal(false),\n code: z.string().min(1).max(128),\n message: z.string().max(1_000),\n retryAfterMs: z.int().min(0).max(86_400_000).exactOptional(),\n cacheForMs: cacheFor,\n }),\n]);\n\n// ── metering ────────────────────────────────────────────────────────────────────────────\n\n/** A counter's name (INTERFACES §18.6). */\nexport type MeterName =\n | \"views\"\n | \"submissions\"\n | \"requests\"\n | \"bytes.stored\"\n | \"bytes.egress\"\n | \"relay.messages\"\n | \"mcp.calls\"\n | \"home.activeSeconds\"\n | (string & {});\n\n/**\n * One counter of a batch. `views` carry `viewerKey`, a monthly pseudonymous key (an HMAC under a\n * key the server rotates each month), never an identity: per account for a signed-in viewer, per\n * viewer for a link minted with one, and per route for an anonymous viewer, since the shell gives\n * each route a different key and none spans routes (HY-08). `mcp.calls` carry `client`, the MCP\n * client's `clientInfo` name (D148).\n */\nexport interface MeterCounter {\n /** What is counted. */\n readonly name: MeterName;\n /** The account it counts against. */\n readonly account: string;\n /** The account's hosted home. */\n readonly home?: string;\n /** The artifact, for counters of one. */\n readonly artifactId?: string;\n /** The artifact's hosted route, for counters of one. */\n readonly routeId?: string;\n /** How much in the batch's window: a count, bytes or seconds. */\n readonly value: number;\n /** What tells counters of one name apart (`viewerKey`, `client`). */\n readonly dimensions?: Readonly<Record<string, string>>;\n}\n\n/** What `metering.record` receives, at least once, idempotent by `batchId`. */\nexport interface MeterBatch {\n /** Stable across retries: a batch delivered twice is the same batch. */\n readonly batchId: string;\n /** Where the window the counters cover starts. */\n readonly from: string;\n /** Where it ends. */\n readonly to: string;\n /** The counters, one per name, account, route and dimensions. */\n readonly counters: readonly MeterCounter[];\n}\n\n// ── sign-in: identity providers and accounts ────────────────────────────────────────────\n\n/**\n * Who an identity provider says signed in (INTERFACES §18.5). `facts` carries what a provider\n * tells beyond that (GitHub's account age, `createdAt`), for an operator's policy.\n */\nexport interface SignInIdentity {\n /** The provider's ID (`IdentityProvider.id`). */\n readonly provider: string;\n /** The provider's own stable ID for the person. */\n readonly subject: string;\n /** The person's email address, when the provider gives one. */\n readonly email?: string;\n /** Whether the provider verified `email`. */\n readonly emailVerified?: boolean;\n /** The display name the provider gives. */\n readonly name?: string;\n /** What else the provider tells (an account's age as `createdAt`). */\n readonly facts?: Readonly<Record<string, unknown>>;\n}\n\n/** The schema the server checks a provider's `SignInIdentity` against. */\nexport const SignInIdentity: z.ZodType<SignInIdentity> = z.object({\n provider: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/),\n subject: z.string().min(1).max(256),\n email: z.string().max(320).exactOptional(),\n emailVerified: z.boolean().exactOptional(),\n name: z.string().max(256).exactOptional(),\n facts: z.record(z.string(), z.unknown()).exactOptional(),\n});\n\n/** PKCE for one sign-in at a provider: the server makes it; the provider sends `challenge`. */\nexport interface SignInPkce {\n /** The S256 challenge the provider's authorization request carries. */\n readonly challenge: string;\n /** Always S256. */\n readonly method: \"S256\";\n /** The verifier the provider's code exchange sends. */\n readonly verifier: string;\n}\n\n/** What a provider's `authorize` and `callback` are told about the sign-in in progress. */\nexport interface SignInContext {\n /** The provider's return address on the API origin: `<apiOrigin>/signin/<id>/callback`. */\n readonly redirectUri: string;\n /** A fresh value an OpenID Connect provider binds its ID token to. */\n readonly nonce: string;\n}\n\n/**\n * An identity provider behind the sign-in port (D165 item 8): the built-in OpenID Connect and\n * GitHub adapters, a development one for tests, or one an operator module supplies.\n */\nexport interface IdentityProvider {\n /** Lower-case letters, digits and hyphens, at most 32: part of its callback's path. */\n readonly id: string;\n /** What the sign-in page calls it (\"GitHub\"). */\n readonly label: string;\n /** Where to send the person: the provider's authorization URL with `state` and PKCE. */\n authorize(state: string, pkce: SignInPkce, context: SignInContext): string | Promise<string>;\n /**\n * The person the provider names on return, from its callback's query (each parameter once; a\n * repeated one is refused before this is called). The server has already\n * checked `state`; the provider exchanges the code (with `pkce.verifier`) and checks what it\n * gets. Throws when sign-in failed.\n */\n callback(\n params: Readonly<Record<string, string>>,\n context: SignInContext & { readonly state: string; readonly pkce: SignInPkce },\n ): Promise<SignInIdentity>;\n}\n\n/**\n * `accounts.resolve`'s answer: the account (`status` `suspended` refuses sign-in), a **first\n * sign-in step** on the operator's origin, or a refusal shown as text.\n *\n * A step: the server sends the person to `step.url` with `mostra_return` added, an address on the\n * API origin (`/signin/return?step=<handle>`). The handle is single-use, lasts 15 minutes and is\n * bound to the browser that started the sign-in (a `__Host-` cookie on the API origin, never on a\n * user-content domain), so it can't be replayed or swapped. When the person comes back the server\n * calls `resolve` again with the same identity and `context.steps` one higher; at most three steps\n * per sign-in (WP-30, D167).\n */\nexport type AccountResolution =\n | {\n readonly account: string;\n readonly name?: string;\n readonly status: \"active\" | \"suspended\";\n }\n | { readonly step: { readonly url: string } }\n | { readonly refused: { readonly message: string } };\n\n/** The schema the server checks `accounts.resolve`'s answer against. */\nexport const AccountResolution: z.ZodType<AccountResolution> = z.union([\n z.object({\n account: z.string().min(1).max(128),\n name: z.string().max(256).exactOptional(),\n status: z.enum([\"active\", \"suspended\"]),\n }),\n z.object({ step: z.object({ url: z.url({ protocol: /^https$/ }).max(2_048) }) }),\n z.object({ refused: z.object({ message: z.string().max(1_000) }) }),\n]);\n\n/** Where an operator-issued credential was presented (D165 item 9, Opus review of WP-28). */\nexport type CredentialResource = \"host\" | \"mcp\" | \"files\";\n\n/**\n * `accounts.authenticate`'s answer for a credential the operator issued, or `null`. `subject`\n * names the credential stably (a service key's ID): a binding with it is one owner instance link\n * of the account, kept per subject, so a program can run an always-on owner instance.\n */\nexport interface AuthenticatedCredential {\n /** The account the credential acts for. */\n readonly account: string;\n /** What it may do: `mostra` for everything a sign-in may. */\n readonly scope: readonly string[];\n /** The credential's own stable name, which keys its instance link. */\n readonly subject?: string;\n}\n\n/** The schema the server checks `accounts.authenticate`'s answer against. */\nexport const AuthenticatedCredential: z.ZodType<AuthenticatedCredential | null> = z\n .object({\n account: z.string().min(1).max(128),\n scope: z.array(z.string().max(64)).max(32),\n subject: z\n .string()\n .regex(/^[A-Za-z0-9._:-]{1,128}$/)\n .exactOptional(),\n })\n .nullable();\n\n// ── abuse ───────────────────────────────────────────────────────────────────────────────\n\n/** A report from the shell's report control (`POST /a/{routeId}/_mostra/report`). */\nexport interface AbuseReport {\n /** The reported route. */\n readonly routeId: string;\n /** The route's label. */\n readonly label: string;\n /** The artifact's own ID (as its manifest names it). */\n readonly artifactId: string;\n /** The hosted home. */\n readonly home: string;\n /** The version the reporter saw, when the shell knew it. */\n readonly versionId?: string;\n /** The reason the reporter chose. */\n readonly reason: string;\n /** What the reporter wrote, as text. */\n readonly detail?: string;\n /** When the report was made. */\n readonly at: string;\n}\n\n/** What `abuse.pushed` receives after each version push, with read access to its client files. */\nexport interface PushedVersion {\n /** The route the version was pushed to. */\n readonly routeId: string;\n /** The route's label. */\n readonly label: string;\n /** The artifact's own ID (as its manifest names it). */\n readonly artifactId: string;\n /** The hosted home. */\n readonly home: string;\n /** The pushed version. */\n readonly versionId: string;\n /** The version's `manifest.json`, parsed. */\n readonly manifest: unknown;\n /** Every client file's path (`client/…`). */\n readonly files: readonly string[];\n /** A client file's bytes, by its path in the listing. */\n read(path: string): Promise<Uint8Array>;\n}\n\n/** `abuse.pushed`'s answer: quarantine the version, or nothing. */\nexport type PushedAnswer = { readonly quarantine?: { readonly reason: string } } | undefined;\n\n/** The schema the server checks `abuse.pushed`'s answer against. */\nexport const PushedAnswer: z.ZodType<PushedAnswer> = z\n .object({ quarantine: z.object({ reason: z.string().max(1_000) }).exactOptional() })\n .optional();\n\n// ── policy ──────────────────────────────────────────────────────────────────────────────\n\n/** What `policy.link` is asked about one link of one route. */\nexport interface LinkQuery {\n /** The account that owns the route. */\n readonly account: string;\n /** Its hosted home. */\n readonly home: string;\n /** The route. */\n readonly routeId: string;\n /** The artifact's own ID (as its manifest names it). */\n readonly artifactId: string;\n /** The link, once it exists. */\n readonly tokenId?: string;\n}\n\n/**\n * Per link and artifact (D161): an interstitial before the page, the longest link lifetime and an\n * idle expiry (durations such as `7d`), the after-submit line, the footer's wording (it can't be\n * hidden on a public link), and the made-with mark.\n */\nexport interface LinkPolicy extends Cacheable {\n /** A page the shell shows before the artifact, once per browser and link; its message as text. */\n readonly interstitial?: { readonly kind: string; readonly message?: string };\n /** The longest a link may live from when it was minted. */\n readonly maxTtl?: string;\n /** A link unused for this long expires. */\n readonly idleExpiry?: string;\n /** The line after \"Your answer was sent.\", as text. */\n readonly afterSubmit?: string;\n /** The footer's wording in place of \"Never enter passwords\", as text. */\n readonly footer?: string;\n /** Whether the made-with mark shows, and where it links. */\n readonly madeWith?: { readonly show: boolean; readonly href?: string };\n}\n\nconst duration = z.string().regex(/^[1-9][0-9]{0,8}[smhd]$/);\n\n/** The schema the server checks `policy.link`'s answer against. */\nexport const LinkPolicy: z.ZodType<LinkPolicy> = z.object({\n interstitial: z\n .object({ kind: z.string().min(1).max(64), message: z.string().max(2_000).exactOptional() })\n .exactOptional(),\n maxTtl: duration.exactOptional(),\n idleExpiry: duration.exactOptional(),\n afterSubmit: z.string().max(500).exactOptional(),\n footer: z.string().min(1).max(500).exactOptional(),\n madeWith: z\n .object({ show: z.boolean(), href: z.url({ protocol: /^https$/ }).exactOptional() })\n .exactOptional(),\n cacheForMs: cacheFor,\n});\n\n/**\n * How Mostra behaves in one chat host (D160): how a page renders there (an MCP App resource, or\n * the hosted link), and what a reached limit may say (`limit-reached` only, or the operator's\n * message).\n */\nexport interface ChatHostPolicy {\n /** `app`: through the MCP Apps resource; `link`: the hosted link only. */\n readonly render?: \"app\" | \"link\";\n /** What a reached limit may say there. */\n readonly quota?: \"limit-reached\" | \"message\";\n}\n\n/** The schema of the `ChatHostPolicy` type, for configuration and `policy.chatHost`. */\nexport const ChatHostPolicy: z.ZodType<ChatHostPolicy> = z.object({\n render: z.enum([\"app\", \"link\"]).exactOptional(),\n quota: z.enum([\"limit-reached\", \"message\"]).exactOptional(),\n});\n\n// ── routing ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * `routing.resolve`'s answer for an exact `Host` the server doesn't serve by itself (any host but\n * a configured user-content domain's apex and its routes' labels):\n *\n * - `shell`: the host shows the hosted shell (`/a/<routeId>`) for one home's routes, whose frames\n * are served on `<route label>.<domain>`. `domain` is a configured user-content domain, or one\n * the operator supplies (an organization's own, whose TLS the operator's edge terminates for the\n * host and every label under `domain`); the server serves those labels once the host is\n * recorded, without asking again.\n * - `route`: the host shows the shell of one route only (`/a/<routeId>`), with its frames on its\n * label under the active domain: a chosen, readable name.\n * - `null`: nothing is served (421).\n *\n * A host the operator supplies is recorded like the server's own labels, bound to its home\n * forever: never issued to another home, so no origin's storage passes between tenants (D165).\n */\nexport type RoutingAnswer =\n | ({ readonly shell: { readonly domain: string; readonly home: string } } & Cacheable)\n | ({ readonly route: { readonly home: string; readonly routeId: string } } & Cacheable)\n | null;\n\n/**\n * A host name of at least two labels, lower case; a port only as a local test server's hosts carry\n * one (the server's own configuration allows the same).\n */\nconst hostName = z\n .string()\n .regex(\n /^(?=.{1,253}(:|$))[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+(:\\d{1,5})?$/,\n );\n\n/** The schema the server checks `routing.resolve`'s answer against. */\nexport const RoutingAnswer: z.ZodType<RoutingAnswer> = z.union([\n z.object({\n shell: z.object({ domain: hostName, home: z.string().min(1) }),\n cacheForMs: cacheFor,\n }),\n z.object({\n route: z.object({ home: z.string().min(1), routeId: z.string().min(1) }),\n cacheForMs: cacheFor,\n }),\n z.null(),\n]);\n\n/** The schema of `routing.linkHost`'s answer: a shell host, or `null` for the active domain. */\nexport const LinkHost: z.ZodType<string | null> = hostName.nullable();\n\n// ── events ──────────────────────────────────────────────────────────────────────────────\n\n/** The kind of an outbound event. */\nexport type OperatorEventKind =\n | \"submission.accepted\"\n | \"version.pushed\"\n | \"run.ended\"\n | \"roster.completed\"\n | (string & {});\n\n/**\n * One outbound event, delivered at least once with a stable `eventId`. `payload`:\n * `submission.accepted` carries the submission's `Results` (INTERFACES §8, the `Results` type of `@mostra/protocol`); `version.pushed`\n * `{ versionId, number }`; `run.ended` `{ runId, action, status }`; `roster.completed` is WP-31's.\n * `label` is the route's label, so an operator running several servers behind one front learns\n * which serves which label (WP-30).\n */\nexport interface OperatorEvent {\n /** Stable across retries. */\n readonly eventId: string;\n /** What happened. */\n readonly kind: OperatorEventKind;\n /** The account that owns the route. */\n readonly account: string;\n /** Its hosted home. */\n readonly home: string;\n /** The route. */\n readonly routeId: string;\n /** The route's label. */\n readonly label: string;\n /** The artifact's own ID (as its manifest names it). */\n readonly artifactId: string;\n /** When it happened. */\n readonly at: string;\n /** What the kind carries. */\n readonly payload: unknown;\n}\n\n// ── the module ──────────────────────────────────────────────────────────────────────────\n\n/** The ports an operator module implements; each is optional, with the default named. */\nexport interface OperatorPorts {\n /** Allows or refuses an operation for an account. Default: allow. */\n readonly limits?: { check(q: LimitQuery): Promise<LimitAnswer> };\n /** Counters in batches, at least once. Default: discard. */\n readonly metering?: { record(batch: MeterBatch): Promise<void> };\n /**\n * Identity providers beside the configured ones, asked at each sign-in so the set can change\n * while the server runs (WP-30). Default: none.\n */\n readonly identity?: {\n providers(): Promise<readonly IdentityProvider[]> | readonly IdentityProvider[];\n };\n /**\n * Sign-in identities to accounts, a first sign-in step, and credentials the operator issued.\n * Default: the server's own accounts, no step, no outside credential.\n */\n readonly accounts?: {\n resolve(\n identity: SignInIdentity,\n context: { readonly steps: number },\n ): Promise<AccountResolution>;\n authenticate?(\n bearer: string,\n context: { readonly resource: CredentialResource },\n ): Promise<AuthenticatedCredential | null>;\n status?(account: string): Promise<\"active\" | \"suspended\">;\n };\n /** Reports and the after-push hook. Default: nothing. */\n readonly abuse?: {\n report(r: AbuseReport): Promise<void>;\n pushed?(v: PushedVersion): Promise<PushedAnswer>;\n };\n /** Per link and per chat host. Default: nothing beyond configuration. */\n readonly policy?: {\n link(q: LinkQuery): Promise<LinkPolicy>;\n chatHost?(client: {\n readonly name: string;\n readonly redirectHost?: string;\n }): Promise<ChatHostPolicy | null>;\n };\n /**\n * Hosts the operator supplies, and the host a new link is minted on. Default: the server's own\n * labels, and links on the active domain.\n */\n readonly routing?: {\n resolve(host: string): Promise<RoutingAnswer>;\n /**\n * The shell host a new link of this route is minted on (one `resolve` answers `shell` or\n * `route` for), or `null` for the active domain (WP-30). A link keeps the host it was minted\n * on (D137).\n */\n linkHost?(q: {\n readonly account: string;\n readonly home: string;\n readonly routeId: string;\n }): Promise<string | null>;\n };\n /** Outbound events, at least once with stable IDs. Default: discard. */\n readonly events?: { deliver(e: OperatorEvent): Promise<void> };\n /** Reserved for WP-31 (D121, D165 item 16); no mailer ships. */\n readonly invitations?: unknown;\n}\n\n/** A hosted route, or one version of it: what the handle's quarantine and release act on. */\nexport type RouteTarget =\n | { readonly routeId: string }\n | { readonly routeId: string; readonly versionId: string };\n\n/**\n * What the server gives its operator module (INTERFACES §18.6). Every target names a hosted route.\n * Each call is durable when it resolves.\n */\nexport interface ServerHandle {\n /** The operator boundary's revision this server speaks. */\n readonly revision: string;\n /** The server's API origin. */\n readonly apiOrigin: string;\n /** A neutral \"under review\" page from the shell; data kept; `release` restores it. */\n quarantine(target: RouteTarget, reason: string): Promise<void>;\n /** Ends a quarantine. */\n release(target: RouteTarget): Promise<void>;\n /** Views keep working; submissions and relayed actions are refused; only the operator resumes. */\n pause(routeId: string, reason: string): Promise<void>;\n /** Ends an operator's pause (and an owner's, too). */\n resume(routeId: string): Promise<void>;\n /** Refuses the home's bindings, pushes, links and pages until `resumeHome`. */\n suspendHome(home: string, reason: string): Promise<void>;\n /** Ends a suspension. */\n resumeHome(home: string): Promise<void>;\n /** Revokes every link of a route; answers how many were live. */\n revokeLinks(routeId: string): Promise<number>;\n /** Revokes one link (410 from then on). */\n revokeLink(tokenId: string): Promise<void>;\n /** Closes the home and refuses to reopen it, to move it between data directories. */\n drainHome(home: string): Promise<void>;\n /** Serves a drained home again. */\n releaseHome(home: string): Promise<void>;\n /** A restore from a backup: rotates the home's incarnation before it serves anything. */\n restored(home: string): Promise<void>;\n /** Deletion: explicit, never part of another action. The route's label is never issued again. */\n remove(routeId: string): Promise<void>;\n}\n\n/** An operator module's default export. */\nexport type OperatorModule = (server: ServerHandle) => OperatorPorts | Promise<OperatorPorts>;\n\n/** Types an operator module's default export; returns it unchanged. */\nexport function defineOperator(module: OperatorModule): OperatorModule {\n return module;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,oBAAoB;;AAGjC,MAAa,uBAST;CACF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;CACV,UAAU;CACV,cAAc;CACd,QAAQ;CACR,UAAU;AACZ;AAuDA,MAAM,WAAW,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAU,CAAC,CAAC,cAAc;;AAG9D,MAAa,cAAsC,EAAE,MAAM,CACzD,EAAE,OAAO;CAAE,SAAS,EAAE,QAAQ,IAAI;CAAG,YAAY;AAAS,CAAC,GAC3D,EAAE,OAAO;CACP,SAAS,EAAE,QAAQ,KAAK;CACxB,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAC/B,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,GAAK;CAC7B,cAAc,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAU,CAAC,CAAC,cAAc;CAC3D,YAAY;AACd,CAAC,CACH,CAAC;;AA0ED,MAAa,iBAA4C,EAAE,OAAO;CAChE,UAAU,EAAE,OAAO,CAAC,CAAC,MAAM,wBAAwB;CACnD,SAAS,E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;GAAG,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EAAE,CAAC;EACvE,YAAY;CACd,CAAC;CACD,EAAE,KAAK;AACT,CAAC;;AAGD,MAAa,WAAqC,SAAS,SAAS;;AAsJpE,SAAgB,eAAe,QAAwC;CACrE,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"operator.js","names":[],"sources":["../src/operator.ts"],"sourcesContent":["/**\n * The operator boundary of a remote server (ARCHITECTURE §15.10, INTERFACES §18.6, D165 items 9\n * and 11): the ports an operating layer implements in an ES module the server loads in process,\n * and the handle the server gives it. Each port is optional and has a no-op default, so a\n * self-hoster needs none of it; each call is async and time-limited, and the server checks every\n * answer against the schemas below before it acts on one (an answer they refuse counts as no\n * answer).\n *\n * An operating layer imports nothing of Mostra but this module (`@mostra/protocol/operator`), so\n * the surface it builds on is this file's, versioned with `@mostra/protocol` and changed only\n * additively (D32).\n *\n * ```ts\n * import { defineOperator } from \"@mostra/protocol/operator\";\n *\n * export default defineOperator((server) => ({\n * limits: { check: async (q) => (q.operation === \"share\" ? { allowed: true } : { allowed: true }) },\n * abuse: { report: async (r) => { await server.quarantine({ routeId: r.routeId }, r.reason); } },\n * }));\n * ```\n *\n * Every port call and every handle target names a hosted route (`rte_…`): an artifact ID, and a\n * version ID derived from it (D89), repeat across homes when a project is copied, so a bare ID\n * would reach every tenant hosting it.\n */\nimport * as z from \"zod\";\n\n/** The operator boundary's own revision, which a module may check (additive within it). */\nexport const OPERATOR_REVISION = \"2026-11-08\";\n\n/** How long the server waits for each port, in milliseconds, before it acts as if none answered. */\nexport const OPERATOR_TIME_LIMITS: {\n readonly limits: number;\n readonly policy: number;\n readonly routing: number;\n readonly identity: number;\n readonly accounts: number;\n readonly authenticate: number;\n readonly pushed: number;\n readonly outbound: number;\n} = {\n limits: 2_000,\n policy: 2_000,\n routing: 2_000,\n identity: 2_000,\n accounts: 5_000,\n authenticate: 5_000,\n pushed: 30_000,\n outbound: 30_000,\n};\n\n// ── limits ──────────────────────────────────────────────────────────────────────────────\n\n/**\n * An operation `limits.check` judges. When the operator doesn't answer in time, `share`,\n * `version.push`, `link` and authoring fail closed, and `view`, `submit`, draft writes and relayed\n * actions (`run`, `run.wait`, `call`) proceed, so nothing a person typed or pressed is lost (D165\n * item 9).\n *\n * - `run`: a relayed action run is about to be recorded (quantity 1). A request that joins a run\n * already recorded (its key or client key) is never asked.\n * - `run.wait`: that run would wait for its owner, who is away (quantity 1), asked after `run`.\n * - `call`: a plain call is about to be relayed to the owner (quantity 1).\n */\nexport type LimitOperation =\n | \"share\"\n | \"version.push\"\n | \"link\"\n | \"view\"\n | \"submit\"\n | \"run\"\n | \"run.wait\"\n | \"call\"\n | \"mcp.call\"\n | \"storage\";\n\n/** What `limits.check` is asked. */\nexport interface LimitQuery {\n /** The account the operation counts against. */\n readonly account: string;\n /** The account's hosted home. */\n readonly home: string;\n /** The artifact, for operations on one. */\n readonly artifact?: string;\n /** The artifact's hosted route, for operations on one (WP-30). */\n readonly routeId?: string;\n /**\n * The version being pushed, on `version.push` and `storage` (MT-03): a push that takes several\n * rounds (the owner uploads the files it was told are missing, then pushes again) asks about the\n * same version each round, so an operator counting versions counts this ID once.\n */\n readonly versionId?: string;\n /** What is asked for. */\n readonly operation: LimitOperation;\n /** How much: bytes for `storage`, else 1. */\n readonly quantity?: number;\n}\n\n/** How long the server may keep an answer instead of asking again, in milliseconds (WP-30). */\nexport interface Cacheable {\n /** Absent or 0: ask again next time. */\n readonly cacheForMs?: number;\n}\n\n/** `limits.check`'s answer. */\nexport type LimitAnswer =\n | ({ readonly allowed: true } & Cacheable)\n | ({\n readonly allowed: false;\n /** A diagnostic code of the operator's (the server answers `MOSTRA_REMOTE_LIMIT_REACHED`). */\n readonly code: string;\n /** Shown as text to whoever was refused. */\n readonly message: string;\n readonly retryAfterMs?: number;\n } & Cacheable);\n\nconst cacheFor = z.int().min(0).max(86_400_000).exactOptional();\n\n/** The schema the server checks `limits.check`'s answer against. */\nexport const LimitAnswer: z.ZodType<LimitAnswer> = z.union([\n z.object({ allowed: z.literal(true), cacheForMs: cacheFor }),\n z.object({\n allowed: z.literal(false),\n code: z.string().min(1).max(128),\n message: z.string().max(1_000),\n retryAfterMs: z.int().min(0).max(86_400_000).exactOptional(),\n cacheForMs: cacheFor,\n }),\n]);\n\n// ── metering ────────────────────────────────────────────────────────────────────────────\n\n/**\n * A counter's name (INTERFACES §18.6). `bytes.stored` sums the client bytes a home uploads in a\n * window; `bytes.held` is a level, not a sum: the client bytes a home holds, each file once however\n * many of its versions name it, sent in the window after it changes (so it falls to what is left,\n * and to 0 once, when content is removed), and for every home holding anything at the first window\n * after a server starts and once a day (MT-03). Keep the latest value per home.\n */\nexport type MeterName =\n | \"views\"\n | \"submissions\"\n | \"requests\"\n | \"bytes.stored\"\n | \"bytes.held\"\n | \"bytes.egress\"\n | \"relay.messages\"\n | \"mcp.calls\"\n | \"home.activeSeconds\"\n | (string & {});\n\n/**\n * One counter of a batch. `views` carry `viewerKey`, a monthly pseudonymous key (an HMAC under a\n * key the server rotates each month), never an identity: per account for a signed-in viewer, per\n * viewer for a link minted with one, and per route for an anonymous viewer, since the shell gives\n * each route a different key and none spans routes (HY-08). `mcp.calls` carry `client`, the MCP\n * client's `clientInfo` name (D148).\n */\nexport interface MeterCounter {\n /** What is counted. */\n readonly name: MeterName;\n /** The account it counts against. */\n readonly account: string;\n /** The account's hosted home. */\n readonly home?: string;\n /** The artifact, for counters of one. */\n readonly artifactId?: string;\n /** The artifact's hosted route, for counters of one. */\n readonly routeId?: string;\n /** How much in the batch's window: a count, bytes or seconds. */\n readonly value: number;\n /** What tells counters of one name apart (`viewerKey`, `client`). */\n readonly dimensions?: Readonly<Record<string, string>>;\n}\n\n/** What `metering.record` receives, at least once, idempotent by `batchId`. */\nexport interface MeterBatch {\n /** Stable across retries: a batch delivered twice is the same batch. */\n readonly batchId: string;\n /** Where the window the counters cover starts. */\n readonly from: string;\n /** Where it ends. */\n readonly to: string;\n /** The counters, one per name, account, route and dimensions. */\n readonly counters: readonly MeterCounter[];\n}\n\n// ── sign-in: identity providers and accounts ────────────────────────────────────────────\n\n/**\n * Who an identity provider says signed in (INTERFACES §18.5). `facts` carries what a provider\n * tells beyond that, for an operator's policy: the built-in GitHub adapter gives `login`, the\n * account's age (`createdAt`) and its public counts (`publicRepos`, `publicGists`, `followers`, from\n * the same lookup, MT-03); the OpenID Connect adapter gives the ID token's claims its configuration\n * names (`claims`, such as a Google Workspace account's domain `hd`), each under its own name.\n */\nexport interface SignInIdentity {\n /** The provider's ID (`IdentityProvider.id`). */\n readonly provider: string;\n /** The provider's own stable ID for the person. */\n readonly subject: string;\n /** The person's email address, when the provider gives one. */\n readonly email?: string;\n /** Whether the provider verified `email`. */\n readonly emailVerified?: boolean;\n /** The display name the provider gives. */\n readonly name?: string;\n /** What else the provider tells (an account's age as `createdAt`, chosen claims). */\n readonly facts?: Readonly<Record<string, unknown>>;\n}\n\n/** The schema the server checks a provider's `SignInIdentity` against. */\nexport const SignInIdentity: z.ZodType<SignInIdentity> = z.object({\n provider: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/),\n subject: z.string().min(1).max(256),\n email: z.string().max(320).exactOptional(),\n emailVerified: z.boolean().exactOptional(),\n name: z.string().max(256).exactOptional(),\n facts: z.record(z.string(), z.unknown()).exactOptional(),\n});\n\n/** PKCE for one sign-in at a provider: the server makes it; the provider sends `challenge`. */\nexport interface SignInPkce {\n /** The S256 challenge the provider's authorization request carries. */\n readonly challenge: string;\n /** Always S256. */\n readonly method: \"S256\";\n /** The verifier the provider's code exchange sends. */\n readonly verifier: string;\n}\n\n/** What a provider's `authorize` and `callback` are told about the sign-in in progress. */\nexport interface SignInContext {\n /** The provider's return address on the API origin: `<apiOrigin>/signin/<id>/callback`. */\n readonly redirectUri: string;\n /** A fresh value an OpenID Connect provider binds its ID token to. */\n readonly nonce: string;\n}\n\n/**\n * An identity provider behind the sign-in port (D165 item 8): the built-in OpenID Connect and\n * GitHub adapters, a development one for tests, or one an operator module supplies.\n */\nexport interface IdentityProvider {\n /** Lower-case letters, digits and hyphens, at most 32: part of its callback's path. */\n readonly id: string;\n /** What the sign-in page calls it (\"GitHub\"). */\n readonly label: string;\n /**\n * Whether the provider verifies the names it gives, and the label a hosted page's sender line\n * shows for it (\"verified with Acme\"; 1 to 64 characters, shown as text). Absent: a person who\n * signs in through it is shown \"name not verified\". The server records the label on the sign-in\n * identity when the provider links or signs in that person, so renaming or retiring the provider\n * later changes no name already verified (MT-03). The built-in providers verify, but for the\n * development one.\n */\n readonly verifies?: { readonly label: string };\n /** Where to send the person: the provider's authorization URL with `state` and PKCE. */\n authorize(state: string, pkce: SignInPkce, context: SignInContext): string | Promise<string>;\n /**\n * The person the provider names on return, from its callback's query (each parameter once; a\n * repeated one is refused before this is called). The server has already\n * checked `state`; the provider exchanges the code (with `pkce.verifier`) and checks what it\n * gets. Throws when sign-in failed.\n */\n callback(\n params: Readonly<Record<string, string>>,\n context: SignInContext & { readonly state: string; readonly pkce: SignInPkce },\n ): Promise<SignInIdentity>;\n}\n\n/**\n * `accounts.resolve`'s answer: the account (`status` `suspended` refuses sign-in), a **first\n * sign-in step** on the operator's origin, or a refusal shown as text.\n *\n * A step: the server sends the person to `step.url` with `mostra_return` added, an address on the\n * API origin (`/signin/return?step=<handle>`). The handle is single-use, lasts 15 minutes and is\n * bound to the browser that started the sign-in (a `__Host-` cookie on the API origin, never on a\n * user-content domain), so it can't be replayed or swapped. When the person comes back the server\n * calls `resolve` again with the same identity and `context.steps` one higher; at most three steps\n * per sign-in (WP-30, D167).\n */\nexport type AccountResolution =\n | {\n readonly account: string;\n readonly name?: string;\n readonly status: \"active\" | \"suspended\";\n }\n | { readonly step: { readonly url: string } }\n | { readonly refused: { readonly message: string } };\n\n/** The schema the server checks `accounts.resolve`'s answer against. */\nexport const AccountResolution: z.ZodType<AccountResolution> = z.union([\n z.object({\n account: z.string().min(1).max(128),\n name: z.string().max(256).exactOptional(),\n status: z.enum([\"active\", \"suspended\"]),\n }),\n z.object({ step: z.object({ url: z.url({ protocol: /^https$/ }).max(2_048) }) }),\n z.object({ refused: z.object({ message: z.string().max(1_000) }) }),\n]);\n\n/** Where an operator-issued credential was presented (D165 item 9, Opus review of WP-28). */\nexport type CredentialResource = \"host\" | \"mcp\" | \"files\";\n\n/**\n * `accounts.authenticate`'s answer for a credential the operator issued, or `null`. `subject`\n * names the credential stably (a service key's ID): a binding with it is one owner instance link\n * of the account, kept per subject, so a program can run an always-on owner instance.\n */\nexport interface AuthenticatedCredential {\n /** The account the credential acts for. */\n readonly account: string;\n /** What it may do: `mostra` for everything a sign-in may. */\n readonly scope: readonly string[];\n /** The credential's own stable name, which keys its instance link. */\n readonly subject?: string;\n}\n\n/** The schema the server checks `accounts.authenticate`'s answer against. */\nexport const AuthenticatedCredential: z.ZodType<AuthenticatedCredential | null> = z\n .object({\n account: z.string().min(1).max(128),\n scope: z.array(z.string().max(64)).max(32),\n subject: z\n .string()\n .regex(/^[A-Za-z0-9._:-]{1,128}$/)\n .exactOptional(),\n })\n .nullable();\n\n// ── abuse ───────────────────────────────────────────────────────────────────────────────\n\n/** A report from the shell's report control (`POST /a/{routeId}/_mostra/report`). */\nexport interface AbuseReport {\n /** The reported route. */\n readonly routeId: string;\n /** The route's label. */\n readonly label: string;\n /** The artifact's own ID (as its manifest names it). */\n readonly artifactId: string;\n /** The hosted home. */\n readonly home: string;\n /** The version the reporter saw, when the shell knew it. */\n readonly versionId?: string;\n /** The reason the reporter chose. */\n readonly reason: string;\n /** What the reporter wrote, as text. */\n readonly detail?: string;\n /** When the report was made. */\n readonly at: string;\n}\n\n/** What `abuse.pushed` receives after each version push, with read access to its client files. */\nexport interface PushedVersion {\n /** The route the version was pushed to. */\n readonly routeId: string;\n /** The route's label. */\n readonly label: string;\n /** The artifact's own ID (as its manifest names it). */\n readonly artifactId: string;\n /** The hosted home. */\n readonly home: string;\n /** The pushed version. */\n readonly versionId: string;\n /** The version's `manifest.json`, parsed. */\n readonly manifest: unknown;\n /** Every client file's path (`client/…`). */\n readonly files: readonly string[];\n /** A client file's bytes, by its path in the listing. */\n read(path: string): Promise<Uint8Array>;\n}\n\n/** `abuse.pushed`'s answer: quarantine the version, or nothing. */\nexport type PushedAnswer = { readonly quarantine?: { readonly reason: string } } | undefined;\n\n/** The schema the server checks `abuse.pushed`'s answer against. */\nexport const PushedAnswer: z.ZodType<PushedAnswer> = z\n .object({ quarantine: z.object({ reason: z.string().max(1_000) }).exactOptional() })\n .optional();\n\n// ── policy ──────────────────────────────────────────────────────────────────────────────\n\n/** What `policy.link` is asked about one link of one route. */\nexport interface LinkQuery {\n /** The account that owns the route. */\n readonly account: string;\n /** Its hosted home. */\n readonly home: string;\n /** The route. */\n readonly routeId: string;\n /** The artifact's own ID (as its manifest names it). */\n readonly artifactId: string;\n /** The link, once it exists. */\n readonly tokenId?: string;\n}\n\n/**\n * Per link and artifact (D161): an interstitial before the page, the longest link lifetime and an\n * idle expiry (durations such as `7d`), the after-submit line, the footer's wording (it can't be\n * hidden on a public link), and the made-with mark.\n */\nexport interface LinkPolicy extends Cacheable {\n /** A page the shell shows before the artifact, once per browser and link; its message as text. */\n readonly interstitial?: { readonly kind: string; readonly message?: string };\n /** The longest a link may live from when it was minted. */\n readonly maxTtl?: string;\n /**\n * A link without a view for this long expires: judged from its last view before the one being\n * opened (or from its minting), so a fresh visit to an idle link is refused as well (MT-03).\n */\n readonly idleExpiry?: string;\n /** The line after \"Your answer was sent.\", as text. */\n readonly afterSubmit?: string;\n /** The footer's wording in place of \"Never enter passwords\", as text. */\n readonly footer?: string;\n /** Whether the made-with mark shows, and where it links. */\n readonly madeWith?: { readonly show: boolean; readonly href?: string };\n}\n\nconst duration = z.string().regex(/^[1-9][0-9]{0,8}[smhd]$/);\n\n/** The schema the server checks `policy.link`'s answer against. */\nexport const LinkPolicy: z.ZodType<LinkPolicy> = z.object({\n interstitial: z\n .object({ kind: z.string().min(1).max(64), message: z.string().max(2_000).exactOptional() })\n .exactOptional(),\n maxTtl: duration.exactOptional(),\n idleExpiry: duration.exactOptional(),\n afterSubmit: z.string().max(500).exactOptional(),\n footer: z.string().min(1).max(500).exactOptional(),\n madeWith: z\n .object({ show: z.boolean(), href: z.url({ protocol: /^https$/ }).exactOptional() })\n .exactOptional(),\n cacheForMs: cacheFor,\n});\n\n/**\n * How Mostra behaves in one chat host (D160): how a page renders there (an MCP App resource, or\n * the hosted link), and what a reached limit may say (`limit-reached` only, or the operator's\n * message).\n */\nexport interface ChatHostPolicy {\n /** `app`: through the MCP Apps resource; `link`: the hosted link only. */\n readonly render?: \"app\" | \"link\";\n /** What a reached limit may say there. */\n readonly quota?: \"limit-reached\" | \"message\";\n}\n\n/** The schema of the `ChatHostPolicy` type, for configuration and `policy.chatHost`. */\nexport const ChatHostPolicy: z.ZodType<ChatHostPolicy> = z.object({\n render: z.enum([\"app\", \"link\"]).exactOptional(),\n quota: z.enum([\"limit-reached\", \"message\"]).exactOptional(),\n});\n\n// ── routing ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * `routing.resolve`'s answer for an exact `Host` the server doesn't serve by itself (any host but\n * a configured user-content domain's apex and its routes' labels):\n *\n * - `shell`: the host shows the hosted shell (`/a/<routeId>`) for one home's routes, whose frames\n * are served on `<route label>.<domain>`. `domain` is a configured user-content domain, or one\n * the operator supplies (an organization's own, whose TLS the operator's edge terminates for the\n * host and every label under `domain`); the server serves those labels once the host is\n * recorded, without asking again.\n * - `route`: the host shows the shell of one route only (`/a/<routeId>`), with its frames on its\n * label under the active domain: a chosen, readable name.\n * - `null`: nothing is served (421).\n *\n * A host the operator supplies is recorded like the server's own labels, bound to its home\n * forever: never issued to another home, so no origin's storage passes between tenants (D165).\n */\nexport type RoutingAnswer =\n | ({ readonly shell: { readonly domain: string; readonly home: string } } & Cacheable)\n | ({ readonly route: { readonly home: string; readonly routeId: string } } & Cacheable)\n | null;\n\n/**\n * A host name of at least two labels, lower case; a port only as a local test server's hosts carry\n * one (the server's own configuration allows the same).\n */\nconst hostName = z\n .string()\n .regex(\n /^(?=.{1,253}(:|$))[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+(:\\d{1,5})?$/,\n );\n\n/** The schema the server checks `routing.resolve`'s answer against. */\nexport const RoutingAnswer: z.ZodType<RoutingAnswer> = z.union([\n z.object({\n shell: z.object({ domain: hostName, home: z.string().min(1) }),\n cacheForMs: cacheFor,\n }),\n z.object({\n route: z.object({ home: z.string().min(1), routeId: z.string().min(1) }),\n cacheForMs: cacheFor,\n }),\n z.null(),\n]);\n\n/** The schema of `routing.linkHost`'s answer: a shell host, or `null` for the active domain. */\nexport const LinkHost: z.ZodType<string | null> = hostName.nullable();\n\n// ── events ──────────────────────────────────────────────────────────────────────────────\n\n/** The kind of an outbound event. */\nexport type OperatorEventKind =\n | \"submission.accepted\"\n | \"version.pushed\"\n | \"run.ended\"\n | \"roster.completed\"\n | (string & {});\n\n/**\n * One outbound event, delivered at least once with a stable `eventId`. `payload`:\n * `submission.accepted` carries the submission's `Results` (INTERFACES §8, the `Results` type of `@mostra/protocol`); `version.pushed`\n * `{ versionId, number }`; `run.ended` `{ runId, action, status }`; `roster.completed`\n * `{ round, respondents, submissions: { ref, submissionId }[] }`, when every expected respondent\n * answered (D168).\n * `label` is the route's label, so an operator running several servers behind one front learns\n * which serves which label (WP-30).\n */\nexport interface OperatorEvent {\n /** Stable across retries. */\n readonly eventId: string;\n /** What happened. */\n readonly kind: OperatorEventKind;\n /** The account that owns the route. */\n readonly account: string;\n /** Its hosted home. */\n readonly home: string;\n /** The route. */\n readonly routeId: string;\n /** The route's label. */\n readonly label: string;\n /** The artifact's own ID (as its manifest names it). */\n readonly artifactId: string;\n /** When it happened. */\n readonly at: string;\n /** What the kind carries. */\n readonly payload: unknown;\n}\n\n// ── the module ──────────────────────────────────────────────────────────────────────────\n\n/** The ports an operator module implements; each is optional, with the default named. */\nexport interface OperatorPorts {\n /** Allows or refuses an operation for an account. Default: allow. */\n readonly limits?: { check(q: LimitQuery): Promise<LimitAnswer> };\n /** Counters in batches, at least once. Default: discard. */\n readonly metering?: { record(batch: MeterBatch): Promise<void> };\n /**\n * Identity providers beside the configured ones, asked at each sign-in so the set can change\n * while the server runs (WP-30). Default: none.\n */\n readonly identity?: {\n providers(): Promise<readonly IdentityProvider[]> | readonly IdentityProvider[];\n };\n /**\n * Sign-in identities to accounts, a first sign-in step, and credentials the operator issued.\n * Default: the server's own accounts, no step, no outside credential.\n */\n readonly accounts?: {\n resolve(\n identity: SignInIdentity,\n context: { readonly steps: number },\n ): Promise<AccountResolution>;\n authenticate?(\n bearer: string,\n context: { readonly resource: CredentialResource },\n ): Promise<AuthenticatedCredential | null>;\n status?(account: string): Promise<\"active\" | \"suspended\">;\n };\n /** Reports and the after-push hook. Default: nothing. */\n readonly abuse?: {\n report(r: AbuseReport): Promise<void>;\n pushed?(v: PushedVersion): Promise<PushedAnswer>;\n };\n /** Per link and per chat host. Default: nothing beyond configuration. */\n readonly policy?: {\n link(q: LinkQuery): Promise<LinkPolicy>;\n chatHost?(client: {\n readonly name: string;\n readonly redirectHost?: string;\n }): Promise<ChatHostPolicy | null>;\n };\n /**\n * Hosts the operator supplies, and the host a new link is minted on. Default: the server's own\n * labels, and links on the active domain.\n */\n readonly routing?: {\n resolve(host: string): Promise<RoutingAnswer>;\n /**\n * The shell host a new link of this route is minted on (one `resolve` answers `shell` or\n * `route` for), or `null` for the active domain (WP-30). A link keeps the host it was minted\n * on (D137).\n */\n linkHost?(q: {\n readonly account: string;\n readonly home: string;\n readonly routeId: string;\n }): Promise<string | null>;\n };\n /** Outbound events, at least once with stable IDs. Default: discard. */\n readonly events?: { deliver(e: OperatorEvent): Promise<void> };\n /**\n * Invitations to expected respondents (D121, D168): for each respondent a hosted roster names\n * with an `email`, when they are added or their personal link is replaced, so the operator can\n * mail them their link. At least once, ordered per home, with a stable `invitationId`. No mailer\n * ships: the open server only hands them over. Default: none sent.\n */\n readonly invitations?: { send(invitation: Invitation): Promise<void> };\n}\n\n/**\n * One invitation (D168). `url` is the respondent's personal link, a capability URL whose secret is\n * in its fragment: the server never stores or logs it (it builds it from the link's token when it\n * hands the invitation over), so the operator mails it and keeps it no longer than that.\n */\nexport interface Invitation {\n /** Stable across retries: `<home>:<tokenId>`, one per personal link. */\n readonly invitationId: string;\n /** The account that owns the route. */\n readonly account: string;\n /** Its hosted home. */\n readonly home: string;\n /** The route. */\n readonly routeId: string;\n /** The route's label. */\n readonly label: string;\n /** The artifact's ID. */\n readonly artifactId: string;\n /** The artifact's title, as its latest version names it. */\n readonly title: string;\n /** Who is invited: the owner's key for them, their name and the address to write to. */\n readonly respondent: { readonly ref: string; readonly name?: string; readonly email: string };\n /** Who invites: the owner's display name and the provider that verified it, when one did. */\n readonly sender: { readonly name?: string; readonly verifiedBy?: string };\n /** The personal link. */\n readonly url: string;\n /** When the link stops working, when it has a lifetime. */\n readonly expiresAt?: string;\n /** When the respondent was added, or their link replaced. */\n readonly at: string;\n}\n\n/** A hosted route, or one version of it: what the handle's quarantine and release act on. */\nexport type RouteTarget =\n | { readonly routeId: string }\n | { readonly routeId: string; readonly versionId: string };\n\n/**\n * What the server gives its operator module (INTERFACES §18.6). Every target names a hosted route.\n * Each call is durable when it resolves.\n */\nexport interface ServerHandle {\n /** The operator boundary's revision this server speaks. */\n readonly revision: string;\n /** The server's API origin. */\n readonly apiOrigin: string;\n /** A neutral \"under review\" page from the shell; data kept; `release` restores it. */\n quarantine(target: RouteTarget, reason: string): Promise<void>;\n /** Ends a quarantine. */\n release(target: RouteTarget): Promise<void>;\n /** Views keep working; submissions and relayed actions are refused; only the operator resumes. */\n pause(routeId: string, reason: string): Promise<void>;\n /** Ends an operator's pause (and an owner's, too). */\n resume(routeId: string): Promise<void>;\n /** Refuses the home's bindings, pushes, links and pages until `resumeHome`. */\n suspendHome(home: string, reason: string): Promise<void>;\n /** Ends a suspension. */\n resumeHome(home: string): Promise<void>;\n /** Revokes every link of a route; answers how many were live. */\n revokeLinks(routeId: string): Promise<number>;\n /** Revokes one link (410 from then on). */\n revokeLink(tokenId: string): Promise<void>;\n /** Closes the home and refuses to reopen it, to move it between data directories. */\n drainHome(home: string): Promise<void>;\n /** Serves a drained home again. */\n releaseHome(home: string): Promise<void>;\n /** A restore from a backup: rotates the home's incarnation before it serves anything. */\n restored(home: string): Promise<void>;\n /** Deletion: explicit, never part of another action. The route's label is never issued again. */\n remove(routeId: string): Promise<void>;\n}\n\n/** An operator module's default export. */\nexport type OperatorModule = (server: ServerHandle) => OperatorPorts | Promise<OperatorPorts>;\n\n/** Types an operator module's default export; returns it unchanged. */\nexport function defineOperator(module: OperatorModule): OperatorModule {\n return module;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,oBAAoB;;AAGjC,MAAa,uBAST;CACF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;CACV,UAAU;CACV,cAAc;CACd,QAAQ;CACR,UAAU;AACZ;AAmEA,MAAM,WAAW,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAU,CAAC,CAAC,cAAc;;AAG9D,MAAa,cAAsC,EAAE,MAAM,CACzD,EAAE,OAAO;CAAE,SAAS,EAAE,QAAQ,IAAI;CAAG,YAAY;AAAS,CAAC,GAC3D,EAAE,OAAO;CACP,SAAS,EAAE,QAAQ,KAAK;CACxB,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAC/B,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,GAAK;CAC7B,cAAc,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAU,CAAC,CAAC,cAAc;CAC3D,YAAY;AACd,CAAC,CACH,CAAC;;AAoFD,MAAa,iBAA4C,EAAE,OAAO;CAChE,UAAU,EAAE,OAAO,CAAC,CAAC,MAAM,wBAAwB;CACnD,SAAS,EAAE,OAAO,C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,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EAAE,CAAC;EACvE,YAAY;CACd,CAAC;CACD,EAAE,KAAK;AACT,CAAC;;AAGD,MAAa,WAAqC,SAAS,SAAS;;AA6LpE,SAAgB,eAAe,QAAwC;CACrE,OAAO;AACT"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
//#region src/team-settings.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* What viewers see of each other's respondent status and presence (CO-07, D168): `private` (their
|
|
5
|
+
* own entry only), `counts` (their own entry and how many stand where), `names` (everyone's name and
|
|
6
|
+
* status). The manifest's `team.visibility`; owners, agents and hosts always see everything.
|
|
7
|
+
*/
|
|
8
|
+
export type TeamVisibility = "private" | "counts" | "names";
|
|
9
|
+
/** The Zod schema of the `TeamVisibility` type. */
|
|
10
|
+
export declare const TeamVisibility: z.ZodType<TeamVisibility>;
|
|
11
|
+
/** The visibility an artifact gets when its manifest names none (D168: private unless it opts in). */
|
|
12
|
+
export declare const DEFAULT_TEAM_VISIBILITY: TeamVisibility;
|
|
13
|
+
/** The manifest's `team` settings (D168). */
|
|
14
|
+
export interface TeamSettings {
|
|
15
|
+
/** What viewers see of each other's status and presence; default `private`. */
|
|
16
|
+
readonly visibility?: TeamVisibility;
|
|
17
|
+
}
|
|
18
|
+
/** The Zod schema of the `TeamSettings` type. */
|
|
19
|
+
export declare const TeamSettings: z.ZodType<TeamSettings>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//# sourceMappingURL=team-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-settings.d.ts","names":[],"sources":["../src/team-settings.ts"],"mappings":";;;;;;;YAYY;;qBAGC,gBAAgB,EAAE,QAAQ;;qBAQ1B,yBAAyB;;iBAGrB;;WAEN,aAAa;;;qBAIX,cAAc,EAAE,QAAQ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { wireRegistry } from "./wire-registry.js";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
//#region src/team-settings.ts
|
|
4
|
+
/**
|
|
5
|
+
* The manifest's `team` settings (D168): a module of its own, with no other import of the
|
|
6
|
+
* protocol, so the manifest reads them without the team wire types.
|
|
7
|
+
*/
|
|
8
|
+
/** The Zod schema of the `TeamVisibility` type. */
|
|
9
|
+
const TeamVisibility = z.enum([
|
|
10
|
+
"private",
|
|
11
|
+
"counts",
|
|
12
|
+
"names"
|
|
13
|
+
]).register(wireRegistry, {
|
|
14
|
+
id: "TeamVisibility",
|
|
15
|
+
description: "What viewers see of each other: private, counts or names (D168)."
|
|
16
|
+
});
|
|
17
|
+
/** The visibility an artifact gets when its manifest names none (D168: private unless it opts in). */
|
|
18
|
+
const DEFAULT_TEAM_VISIBILITY = "private";
|
|
19
|
+
/** The Zod schema of the `TeamSettings` type. */
|
|
20
|
+
const TeamSettings = z.object({ visibility: TeamVisibility.exactOptional() }).register(wireRegistry, {
|
|
21
|
+
id: "TeamSettings",
|
|
22
|
+
description: "An artifact's team settings: what viewers see of each other (D168)."
|
|
23
|
+
});
|
|
24
|
+
//#endregion
|
|
25
|
+
export { DEFAULT_TEAM_VISIBILITY, TeamSettings, TeamVisibility };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=team-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-settings.js","names":[],"sources":["../src/team-settings.ts"],"sourcesContent":["/**\n * The manifest's `team` settings (D168): a module of its own, with no other import of the\n * protocol, so the manifest reads them without the team wire types.\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/**\n * What viewers see of each other's respondent status and presence (CO-07, D168): `private` (their\n * own entry only), `counts` (their own entry and how many stand where), `names` (everyone's name and\n * status). The manifest's `team.visibility`; owners, agents and hosts always see everything.\n */\nexport type TeamVisibility = \"private\" | \"counts\" | \"names\";\n\n/** The Zod schema of the `TeamVisibility` type. */\nexport const TeamVisibility: z.ZodType<TeamVisibility> = z\n .enum([\"private\", \"counts\", \"names\"])\n .register(wireRegistry, {\n id: \"TeamVisibility\",\n description: \"What viewers see of each other: private, counts or names (D168).\",\n });\n\n/** The visibility an artifact gets when its manifest names none (D168: private unless it opts in). */\nexport const DEFAULT_TEAM_VISIBILITY: TeamVisibility = \"private\";\n\n/** The manifest's `team` settings (D168). */\nexport interface TeamSettings {\n /** What viewers see of each other's status and presence; default `private`. */\n readonly visibility?: TeamVisibility;\n}\n\n/** The Zod schema of the `TeamSettings` type. */\nexport const TeamSettings: z.ZodType<TeamSettings> = z\n .object({ visibility: TeamVisibility.exactOptional() })\n .register(wireRegistry, {\n id: \"TeamSettings\",\n description: \"An artifact's team settings: what viewers see of each other (D168).\",\n });\n"],"mappings":";;;;;;;;AAeA,MAAa,iBAA4C,EACtD,KAAK;CAAC;CAAW;CAAU;AAAO,CAAC,CAAC,CACpC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,0BAA0C;;AASvD,MAAa,eAAwC,EAClD,OAAO,EAAE,YAAY,eAAe,cAAc,EAAE,CAAC,CAAC,CACtD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC"}
|