@mostra/protocol 0.1.0 → 0.3.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/artifact.d.ts.map +1 -1
- package/dist/artifact.js +8 -3
- package/dist/artifact.js.map +1 -1
- package/dist/diagnostics/codes/env.d.ts +1 -1
- package/dist/diagnostics/codes/env.d.ts.map +1 -1
- package/dist/diagnostics/codes/env.js +12 -1
- package/dist/diagnostics/codes/env.js.map +1 -1
- package/dist/diagnostics/codes/host.d.ts +1 -1
- package/dist/diagnostics/codes/host.d.ts.map +1 -1
- package/dist/diagnostics/codes/host.js +12 -1
- package/dist/diagnostics/codes/host.js.map +1 -1
- package/dist/diagnostics/codes/platform.js +2 -2
- package/dist/diagnostics/codes/platform.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -2
- package/dist/method.d.ts +12 -0
- package/dist/method.d.ts.map +1 -1
- package/dist/method.js.map +1 -1
- package/dist/methods/artifact/create.d.ts.map +1 -1
- package/dist/methods/artifact/create.js +2 -1
- package/dist/methods/artifact/create.js.map +1 -1
- package/dist/methods/index.d.ts +3 -1
- package/dist/methods/index.d.ts.map +1 -1
- package/dist/methods/index.js +22 -4
- package/dist/methods/index.js.map +1 -1
- package/dist/methods/mostra/initialize.d.ts +1 -1
- package/dist/methods/mostra/initialize.js.map +1 -1
- package/dist/methods/port/identity-resolve.d.ts +36 -0
- package/dist/methods/port/identity-resolve.d.ts.map +1 -0
- package/dist/methods/port/identity-resolve.js +35 -0
- package/dist/methods/port/identity-resolve.js.map +1 -0
- package/package.json +3 -3
- package/schemas/protocol.draft-07.json +416 -3
- package/schemas/protocol.schema.json +416 -3
- package/src/artifact.ts +7 -2
- package/src/diagnostics/codes/env.ts +12 -0
- package/src/diagnostics/codes/host.ts +12 -0
- package/src/diagnostics/codes/platform.ts +2 -2
- package/src/index.ts +9 -1
- package/src/method.ts +14 -0
- package/src/methods/artifact/create.ts +2 -1
- package/src/methods/index.ts +13 -3
- package/src/methods/mostra/initialize.ts +1 -1
- package/src/methods/port/identity-resolve.ts +67 -0
package/dist/methods/index.js
CHANGED
|
@@ -2,13 +2,14 @@ import { artifactCreateMethod } from "./artifact/create.js";
|
|
|
2
2
|
import { artifactGetMethod } from "./artifact/get.js";
|
|
3
3
|
import { artifactListMethod } from "./artifact/list.js";
|
|
4
4
|
import { artifactPublishMethod } from "./artifact/publish.js";
|
|
5
|
+
import { ARTIFACT_PROGRESS, ArtifactProgressParams } from "../verify.js";
|
|
5
6
|
import { artifactVerifyMethod } from "./artifact/verify.js";
|
|
6
7
|
import { depsAddMethod } from "./deps/add.js";
|
|
7
|
-
import { devStartMethod } from "./dev/start.js";
|
|
8
|
+
import { DEV_NOTIFY, DevNotifyParams, devStartMethod } from "./dev/start.js";
|
|
8
9
|
import { devStopMethod } from "./dev/stop.js";
|
|
9
10
|
import { eventsAckMethod } from "./events/ack.js";
|
|
10
11
|
import { eventsReadMethod } from "./events/read.js";
|
|
11
|
-
import { eventsSubscribeMethod } from "./events/subscribe.js";
|
|
12
|
+
import { EVENTS_NOTIFY, EventsNotifyParams, eventsSubscribeMethod } from "./events/subscribe.js";
|
|
12
13
|
import { eventsUnsubscribeMethod } from "./events/unsubscribe.js";
|
|
13
14
|
import { gcRunMethod } from "./gc/run.js";
|
|
14
15
|
import { instanceCheckMethod } from "./instance/check.js";
|
|
@@ -17,6 +18,7 @@ import { instanceStatusMethod } from "./instance/status.js";
|
|
|
17
18
|
import { livePushMethod } from "./live/push.js";
|
|
18
19
|
import { mostraShutdownMethod } from "./mostra/shutdown.js";
|
|
19
20
|
import { portDraftsMirrorMethod } from "./port/drafts-mirror.js";
|
|
21
|
+
import { portIdentityResolveMethod } from "./port/identity-resolve.js";
|
|
20
22
|
import { portSecretsGetMethod } from "./port/secrets-get.js";
|
|
21
23
|
import { portSubmissionsDeliverMethod } from "./port/submissions-deliver.js";
|
|
22
24
|
import { portTrustedControlsActivatedMethod } from "./port/trusted-controls-activated.js";
|
|
@@ -70,9 +72,25 @@ const hostMethods = [
|
|
|
70
72
|
gcRunMethod,
|
|
71
73
|
instanceCheckMethod,
|
|
72
74
|
devStartMethod,
|
|
73
|
-
devStopMethod
|
|
75
|
+
devStopMethod,
|
|
76
|
+
portIdentityResolveMethod
|
|
77
|
+
];
|
|
78
|
+
/** Every notification the instance sends to its clients (INTERFACES §6). */
|
|
79
|
+
const hostNotifications = [
|
|
80
|
+
{
|
|
81
|
+
method: EVENTS_NOTIFY,
|
|
82
|
+
params: EventsNotifyParams
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
method: ARTIFACT_PROGRESS,
|
|
86
|
+
params: ArtifactProgressParams
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
method: DEV_NOTIFY,
|
|
90
|
+
params: DevNotifyParams
|
|
91
|
+
}
|
|
74
92
|
];
|
|
75
93
|
//#endregion
|
|
76
|
-
export { hostMethods };
|
|
94
|
+
export { hostMethods, hostNotifications };
|
|
77
95
|
|
|
78
96
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/methods/index.ts"],"sourcesContent":["/**\n * Every host protocol method this package defines. `pnpm gen protocol-method` adds entries at the\n * markers; the method itself lives in its own module under `methods/<group>/`.\n */\nimport type { AnyMethod } from \"../method.ts\";\nimport { artifactCreateMethod } from \"./artifact/create.ts\";\nimport { artifactGetMethod } from \"./artifact/get.ts\";\nimport { artifactListMethod } from \"./artifact/list.ts\";\nimport { artifactPublishMethod } from \"./artifact/publish.ts\";\nimport { artifactVerifyMethod } from \"./artifact/verify.ts\";\nimport { depsAddMethod } from \"./deps/add.ts\";\nimport { devStartMethod } from \"./dev/start.ts\";\nimport { devStopMethod } from \"./dev/stop.ts\";\nimport { eventsAckMethod } from \"./events/ack.ts\";\nimport { eventsReadMethod } from \"./events/read.ts\";\nimport { eventsSubscribeMethod } from \"./events/subscribe.ts\";\nimport { eventsUnsubscribeMethod } from \"./events/unsubscribe.ts\";\nimport { gcRunMethod } from \"./gc/run.ts\";\nimport { instanceCheckMethod } from \"./instance/check.ts\";\nimport { instanceStatusMethod } from \"./instance/status.ts\";\nimport { livePushMethod } from \"./live/push.ts\";\nimport { mostraInitializeMethod } from \"./mostra/initialize.ts\";\nimport { mostraShutdownMethod } from \"./mostra/shutdown.ts\";\nimport { portDraftsMirrorMethod } from \"./port/drafts-mirror.ts\";\nimport { portSecretsGetMethod } from \"./port/secrets-get.ts\";\nimport { portSubmissionsDeliverMethod } from \"./port/submissions-deliver.ts\";\nimport { portTrustedControlsActivatedMethod } from \"./port/trusted-controls-activated.ts\";\nimport { portTrustedControlsPolicyMethod } from \"./port/trusted-controls-policy.ts\";\nimport { resultsGetMethod } from \"./results/get.ts\";\nimport { secretDeleteMethod } from \"./secret/delete.ts\";\nimport { secretListMethod } from \"./secret/list.ts\";\nimport { secretSetMethod } from \"./secret/set.ts\";\nimport { stateGetMethod } from \"./state/get.ts\";\nimport { statePatchMethod } from \"./state/patch.ts\";\nimport { viewDefaultMethod } from \"./view/default.ts\";\nimport { viewLaunchMethod } from \"./view/launch.ts\";\nimport { viewRevokeMethod } from \"./view/revoke.ts\";\nimport { viewRotateMethod } from \"./view/rotate.ts\";\nimport { viewUrlMethod } from \"./view/url.ts\";\nimport { waitMethod } from \"./wait/wait.ts\";\n// gen:method-imports\n\n/** Every host protocol method, in the order they were added. */\nexport const hostMethods: readonly AnyMethod[] = [\n mostraInitializeMethod,\n mostraShutdownMethod,\n instanceStatusMethod,\n artifactCreateMethod,\n artifactPublishMethod,\n artifactListMethod,\n artifactGetMethod,\n depsAddMethod,\n viewUrlMethod,\n viewRevokeMethod,\n viewRotateMethod,\n stateGetMethod,\n resultsGetMethod,\n waitMethod,\n eventsReadMethod,\n eventsSubscribeMethod,\n eventsUnsubscribeMethod,\n statePatchMethod,\n eventsAckMethod,\n portSubmissionsDeliverMethod,\n portDraftsMirrorMethod,\n portTrustedControlsPolicyMethod,\n portTrustedControlsActivatedMethod,\n secretSetMethod,\n secretListMethod,\n secretDeleteMethod,\n livePushMethod,\n portSecretsGetMethod,\n artifactVerifyMethod,\n viewDefaultMethod,\n viewLaunchMethod,\n gcRunMethod,\n instanceCheckMethod,\n devStartMethod,\n devStopMethod,\n // gen:methods\n];\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/methods/index.ts"],"sourcesContent":["/**\n * Every host protocol method this package defines. `pnpm gen protocol-method` adds entries at the\n * markers; the method itself lives in its own module under `methods/<group>/`.\n */\nimport type { AnyMethod, AnyNotification } from \"../method.ts\";\nimport { ARTIFACT_PROGRESS, ArtifactProgressParams } from \"../verify.ts\";\nimport { artifactCreateMethod } from \"./artifact/create.ts\";\nimport { artifactGetMethod } from \"./artifact/get.ts\";\nimport { artifactListMethod } from \"./artifact/list.ts\";\nimport { artifactPublishMethod } from \"./artifact/publish.ts\";\nimport { artifactVerifyMethod } from \"./artifact/verify.ts\";\nimport { depsAddMethod } from \"./deps/add.ts\";\nimport { DEV_NOTIFY, DevNotifyParams, devStartMethod } from \"./dev/start.ts\";\nimport { devStopMethod } from \"./dev/stop.ts\";\nimport { eventsAckMethod } from \"./events/ack.ts\";\nimport { eventsReadMethod } from \"./events/read.ts\";\nimport { EVENTS_NOTIFY, EventsNotifyParams, eventsSubscribeMethod } from \"./events/subscribe.ts\";\nimport { eventsUnsubscribeMethod } from \"./events/unsubscribe.ts\";\nimport { gcRunMethod } from \"./gc/run.ts\";\nimport { instanceCheckMethod } from \"./instance/check.ts\";\nimport { instanceStatusMethod } from \"./instance/status.ts\";\nimport { livePushMethod } from \"./live/push.ts\";\nimport { mostraInitializeMethod } from \"./mostra/initialize.ts\";\nimport { mostraShutdownMethod } from \"./mostra/shutdown.ts\";\nimport { portDraftsMirrorMethod } from \"./port/drafts-mirror.ts\";\nimport { portIdentityResolveMethod } from \"./port/identity-resolve.ts\";\nimport { portSecretsGetMethod } from \"./port/secrets-get.ts\";\nimport { portSubmissionsDeliverMethod } from \"./port/submissions-deliver.ts\";\nimport { portTrustedControlsActivatedMethod } from \"./port/trusted-controls-activated.ts\";\nimport { portTrustedControlsPolicyMethod } from \"./port/trusted-controls-policy.ts\";\nimport { resultsGetMethod } from \"./results/get.ts\";\nimport { secretDeleteMethod } from \"./secret/delete.ts\";\nimport { secretListMethod } from \"./secret/list.ts\";\nimport { secretSetMethod } from \"./secret/set.ts\";\nimport { stateGetMethod } from \"./state/get.ts\";\nimport { statePatchMethod } from \"./state/patch.ts\";\nimport { viewDefaultMethod } from \"./view/default.ts\";\nimport { viewLaunchMethod } from \"./view/launch.ts\";\nimport { viewRevokeMethod } from \"./view/revoke.ts\";\nimport { viewRotateMethod } from \"./view/rotate.ts\";\nimport { viewUrlMethod } from \"./view/url.ts\";\nimport { waitMethod } from \"./wait/wait.ts\";\n// gen:method-imports\n\n/** Every host protocol method, in the order they were added. */\nexport const hostMethods: readonly AnyMethod[] = [\n mostraInitializeMethod,\n mostraShutdownMethod,\n instanceStatusMethod,\n artifactCreateMethod,\n artifactPublishMethod,\n artifactListMethod,\n artifactGetMethod,\n depsAddMethod,\n viewUrlMethod,\n viewRevokeMethod,\n viewRotateMethod,\n stateGetMethod,\n resultsGetMethod,\n waitMethod,\n eventsReadMethod,\n eventsSubscribeMethod,\n eventsUnsubscribeMethod,\n statePatchMethod,\n eventsAckMethod,\n portSubmissionsDeliverMethod,\n portDraftsMirrorMethod,\n portTrustedControlsPolicyMethod,\n portTrustedControlsActivatedMethod,\n secretSetMethod,\n secretListMethod,\n secretDeleteMethod,\n livePushMethod,\n portSecretsGetMethod,\n artifactVerifyMethod,\n viewDefaultMethod,\n viewLaunchMethod,\n gcRunMethod,\n instanceCheckMethod,\n devStartMethod,\n devStopMethod,\n portIdentityResolveMethod,\n // gen:methods\n];\n\n/** Every notification the instance sends to its clients (INTERFACES §6). */\nexport const hostNotifications: readonly AnyNotification[] = [\n { method: EVENTS_NOTIFY, params: EventsNotifyParams as AnyNotification[\"params\"] },\n { method: ARTIFACT_PROGRESS, params: ArtifactProgressParams as AnyNotification[\"params\"] },\n { method: DEV_NOTIFY, params: DevNotifyParams as AnyNotification[\"params\"] },\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAa,cAAoC;CAC/C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAGA,MAAa,oBAAgD;CAC3D;EAAE,QAAQ;EAAe,QAAQ;CAAgD;CACjF;EAAE,QAAQ;EAAmB,QAAQ;CAAoD;CACzF;EAAE,QAAQ;EAAY,QAAQ;CAA6C;AAC7E"}
|
|
@@ -22,7 +22,7 @@ export declare const PortName: z.ZodType<PortName, string>;
|
|
|
22
22
|
export declare const CLI_CLIENT_NAME = "mostra-cli";
|
|
23
23
|
/** The client that opens a connection. */
|
|
24
24
|
export interface ClientInfo {
|
|
25
|
-
/** The client's name, for logs and status (`mostra-cli`, `
|
|
25
|
+
/** The client's name, for logs and status (`mostra-cli`, `my-host`). */
|
|
26
26
|
readonly name: string;
|
|
27
27
|
/** The client's own version. */
|
|
28
28
|
readonly version: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","names":[],"sources":["../../../src/methods/mostra/initialize.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { Diagnostic } from \"../../diagnostics/diagnostic.ts\";\nimport { SubmitChannel } from \"../../interaction.ts\";\nimport { SubmissionPolicy } from \"../../manifest.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { Revision } from \"../../revision.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/**\n * A host port name (INTERFACES §7). Port names are open strings on the wire, so an older instance\n * answers a newer port with a warning instead of refusing the session (D84). `ai` is reserved for\n * the AI port, which is not part of v1 (D46).\n */\nexport type PortName =\n | \"identity\"\n | \"submissions\"\n | \"drafts\"\n | \"reviews\"\n | \"addressing\"\n | \"trustedControls\"\n | \"capture\"\n | \"secrets\"\n | \"pty\"\n | \"ai\"\n | (string & {});\n\n/** The Zod schema of the `PortName` type. */\nexport const PortName: z.ZodType<PortName, string> = z\n .string()\n .regex(/^[a-z][a-zA-Z0-9]*$/)\n .register(wireRegistry, {\n id: \"PortName\",\n description:\n \"A host port name: identity, submissions, drafts, reviews, addressing, trustedControls, capture, secrets, pty, or ai (reserved). Open for later ports.\",\n });\n\n/**\n * The standalone CLI's client name (D140 item 4). The supervisor marks a home as configured by a\n * host when any other client sends `home` or `ports`, and the CLI never sends telemetry for such a\n * home. A host that uses this name as its own is out of scope.\n */\nexport const CLI_CLIENT_NAME = \"mostra-cli\";\n\n/** The client that opens a connection. */\nexport interface ClientInfo {\n /** The client's name, for logs and status (`mostra-cli`, `jcode`). */\n readonly name: string;\n /** The client's own version. */\n readonly version: string;\n}\n\n/** What the client can handle (D84). */\nexport interface ClientCapabilities {\n /** Notification methods the client accepts. The instance sends no others. */\n readonly notifications?: readonly string[];\n}\n\n/**\n * Home settings from a spawning host (INTERFACES §6). Each setting arrives with the package that\n * implements it.\n */\nexport interface HomeConfig {\n /**\n * The home the client expects. A check, not a setting (D84): the instance chose and locked its\n * home at start-up, and refuses the session with `MOSTRA_HOME_MISMATCH` when this names a\n * different one.\n */\n readonly path?: string;\n /**\n * The dependency policy (D43, D95), kept in the home's `config.json` for every later client:\n * `auto` (the default) installs any package an artifact imports; `explicit` installs only what\n * `deps/add` adds and reports other imports as `MOSTRA_DEP_MISSING`.\n */\n readonly dependencies?: DependencyPolicy;\n /**\n * The home's submission policy (D102), kept in `config.json`: it applies to every artifact whose\n * `artifact/publish` names no policy, before the manifest's request.\n */\n readonly submission?: SubmissionPolicy;\n /**\n * The ports this client always provides, kept in `config.json` under its `client.name` (D105).\n * Submissions made while it is away wait in the outbox for it; an empty list stops that.\n */\n readonly ports?: readonly PortName[];\n /**\n * The submit channels the home accepts (D40, D108), kept in `config.json`: `[\"shell\"]` lets only\n * the shell's trusted Submit and Choose make submissions and choices; absent, both channels are\n * allowed. A host's `trustedControls` port answers per view instead, when it is connected.\n */\n readonly submitChannels?: readonly SubmitChannel[];\n}\n\n/** How packages enter an artifact's lockfile (D43). */\nexport type DependencyPolicy = \"auto\" | \"explicit\";\n\n/** The Zod schema of the `DependencyPolicy` type. */\nexport const DependencyPolicy: z.ZodType<DependencyPolicy> = z\n .enum([\"auto\", \"explicit\"])\n .register(wireRegistry, {\n id: \"DependencyPolicy\",\n description:\n \"How packages enter an artifact's lockfile: auto installs what artifacts import; explicit only what deps/add adds (D43).\",\n });\n\n/** The params of `mostra/initialize` (INTERFACES §6). */\nexport interface MostraInitializeParams {\n /** Who is connecting. */\n readonly client: ClientInfo;\n /**\n * The host protocol revisions the client speaks. The instance picks the newest one it also\n * supports, or refuses with `MOSTRA_HOST_REVISION_UNSUPPORTED`. Entries that aren't revisions\n * never match.\n */\n readonly revisions: readonly string[];\n /** What the client can handle. */\n readonly capabilities: ClientCapabilities;\n /**\n * Ports the client implements. The instance calls a port only on the connection that registered\n * it; ports it doesn't support get a `MOSTRA_HOST_PORT_UNSUPPORTED` warning.\n */\n readonly ports: readonly PortName[];\n /** Home settings and the home check. */\n readonly home?: HomeConfig;\n}\n\n/** The instance a client is connected to. */\nexport interface InstanceInfo {\n /** The runtime release (`@mostra/runtime` version). */\n readonly version: string;\n /** The home's real path. */\n readonly home: string;\n /** The platform as `<os>-<arch>`, for example `darwin-arm64`. */\n readonly platform: string;\n /** The supervisor's process ID. */\n readonly pid: number;\n /** `host` when spawned over stdio (`mostra-runtime host`), `daemon` when started as a daemon. */\n readonly mode: \"host\" | \"daemon\";\n}\n\n/** What the instance offers (D84). */\nexport interface InstanceCapabilities {\n /** Every method the instance serves. */\n readonly methods: readonly string[];\n /** Every notification the instance may send. */\n readonly notifications: readonly string[];\n /** The ports the instance calls when a client registers them. */\n readonly ports: readonly PortName[];\n}\n\n/** The result of `mostra/initialize`. */\nexport interface MostraInitializeResult {\n /** The negotiated host protocol revision: the newest both sides support. */\n readonly revision: Revision;\n /** The instance the client is connected to. */\n readonly instance: InstanceInfo;\n /** What the instance offers. */\n readonly capabilities: InstanceCapabilities;\n /** Warnings about the session, such as ports the instance doesn't support. */\n readonly warnings: readonly Diagnostic[];\n}\n\n/** The Zod schema of the `ClientInfo` type. */\nexport const ClientInfo: z.ZodType<ClientInfo> = z\n .object({ name: z.string().min(1), version: z.string() })\n .register(wireRegistry, { id: \"ClientInfo\", description: \"The client that opens a connection.\" });\n\n/** The Zod schema of the `ClientCapabilities` type. */\nexport const ClientCapabilities: z.ZodType<ClientCapabilities> = z\n .object({ notifications: z.array(z.string()).readonly().exactOptional() })\n .register(wireRegistry, {\n id: \"ClientCapabilities\",\n description: \"What the client can handle: the notification methods it accepts.\",\n });\n\n/** The Zod schema of the `HomeConfig` type. */\nexport const HomeConfig: z.ZodType<HomeConfig> = z\n .object({\n path: z.string().min(1).exactOptional(),\n dependencies: DependencyPolicy.exactOptional(),\n submission: SubmissionPolicy.exactOptional(),\n ports: z.array(PortName).max(32).readonly().exactOptional(),\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"HomeConfig\",\n description:\n \"Home settings from a spawning host; path is a check against the instance's home (D84), dependencies the dependency policy (D43), submission the home's policy (D102), ports those the host always provides (D105).\",\n });\n\n/** The Zod schema of the `InstanceInfo` type. */\nexport const InstanceInfo: z.ZodType<InstanceInfo> = z\n .object({\n version: z.string(),\n home: z.string(),\n platform: z.string(),\n pid: z.int().min(1),\n mode: z.enum([\"host\", \"daemon\"]),\n })\n .register(wireRegistry, {\n id: \"InstanceInfo\",\n description: \"The instance a client is connected to.\",\n });\n\n/** The Zod schema of the `InstanceCapabilities` type. */\nexport const InstanceCapabilities: z.ZodType<InstanceCapabilities> = z\n .object({\n methods: z.array(z.string()).readonly(),\n notifications: z.array(z.string()).readonly(),\n ports: z.array(PortName).readonly(),\n })\n .register(wireRegistry, {\n id: \"InstanceCapabilities\",\n description: \"What the instance offers: methods, notifications and supported ports.\",\n });\n\nconst params: z.ZodType<MostraInitializeParams> = z\n .object({\n client: ClientInfo,\n revisions: z.array(z.string()).readonly(),\n capabilities: ClientCapabilities,\n ports: z.array(PortName).readonly(),\n home: HomeConfig.exactOptional(),\n })\n .register(wireRegistry, { id: \"MostraInitializeParams\" });\n\nconst result: z.ZodType<MostraInitializeResult> = z\n .object({\n revision: Revision.schema,\n instance: InstanceInfo,\n capabilities: InstanceCapabilities,\n warnings: z.array(Diagnostic).readonly(),\n })\n .register(wireRegistry, { id: \"MostraInitializeResult\" });\n\n/**\n * `mostra/initialize`: opens a session. It must be the first request on a connection and is sent\n * once. It negotiates the protocol revision, registers the client's ports on this connection and\n * checks the home (D59, D84).\n */\nexport const mostraInitializeMethod: MethodDefinition<\n MostraInitializeParams,\n MostraInitializeResult\n> = defineMethod({\n method: \"mostra/initialize\",\n direction: \"client-to-instance\",\n mutating: false,\n params,\n result,\n});\n"],"mappings":";;;;;;;;;AA2BA,MAAa,WAAwC,EAClD,OAAO,CAAC,CACR,MAAM,qBAAqB,CAAC,CAC5B,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;;;;;AAOH,MAAa,kBAAkB;;AAuD/B,MAAa,mBAAgD,EAC1D,KAAK,CAAC,QAAQ,UAAU,CAAC,CAAC,CAC1B,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AA4DH,MAAa,aAAoC,EAC9C,OAAO;CAAE,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAAG,SAAS,EAAE,OAAO;AAAE,CAAC,CAAC,CACxD,SAAS,cAAc;CAAE,IAAI;CAAc,aAAa;AAAsC,CAAC;;AAGlG,MAAa,qBAAoD,EAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CACzE,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,aAAoC,EAC9C,OAAO;CACN,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;CACtC,cAAc,iBAAiB,cAAc;CAC7C,YAAY,iBAAiB,cAAc;CAC3C,OAAO,EAAE,MAAM,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CAC1D,gBAAgB,EAAE,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;AAChF,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AAGH,MAAa,eAAwC,EAClD,OAAO;CACN,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;CACf,UAAU,EAAE,OAAO;CACnB,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CAClB,MAAM,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC;AACjC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,uBAAwD,EAClE,OAAO;CACN,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACtC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CAC5C,OAAO,EAAE,MAAM,QAAQ,CAAC,CAAC,SAAS;AACpC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;AAEH,MAAM,SAA4C,EAC/C,OAAO;CACN,QAAQ;CACR,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACxC,cAAc;CACd,OAAO,EAAE,MAAM,QAAQ,CAAC,CAAC,SAAS;CAClC,MAAM,WAAW,cAAc;AACjC,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,yBAAyB,CAAC;AAE1D,MAAM,SAA4C,EAC/C,OAAO;CACN,UAAU,SAAS;CACnB,UAAU;CACV,cAAc;CACd,UAAU,EAAE,MAAM,UAAU,CAAC,CAAC,SAAS;AACzC,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,yBAAyB,CAAC;;;;;;AAO1D,MAAa,yBAGT,aAAa;CACf,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"initialize.js","names":[],"sources":["../../../src/methods/mostra/initialize.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { Diagnostic } from \"../../diagnostics/diagnostic.ts\";\nimport { SubmitChannel } from \"../../interaction.ts\";\nimport { SubmissionPolicy } from \"../../manifest.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { Revision } from \"../../revision.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/**\n * A host port name (INTERFACES §7). Port names are open strings on the wire, so an older instance\n * answers a newer port with a warning instead of refusing the session (D84). `ai` is reserved for\n * the AI port, which is not part of v1 (D46).\n */\nexport type PortName =\n | \"identity\"\n | \"submissions\"\n | \"drafts\"\n | \"reviews\"\n | \"addressing\"\n | \"trustedControls\"\n | \"capture\"\n | \"secrets\"\n | \"pty\"\n | \"ai\"\n | (string & {});\n\n/** The Zod schema of the `PortName` type. */\nexport const PortName: z.ZodType<PortName, string> = z\n .string()\n .regex(/^[a-z][a-zA-Z0-9]*$/)\n .register(wireRegistry, {\n id: \"PortName\",\n description:\n \"A host port name: identity, submissions, drafts, reviews, addressing, trustedControls, capture, secrets, pty, or ai (reserved). Open for later ports.\",\n });\n\n/**\n * The standalone CLI's client name (D140 item 4). The supervisor marks a home as configured by a\n * host when any other client sends `home` or `ports`, and the CLI never sends telemetry for such a\n * home. A host that uses this name as its own is out of scope.\n */\nexport const CLI_CLIENT_NAME = \"mostra-cli\";\n\n/** The client that opens a connection. */\nexport interface ClientInfo {\n /** The client's name, for logs and status (`mostra-cli`, `my-host`). */\n readonly name: string;\n /** The client's own version. */\n readonly version: string;\n}\n\n/** What the client can handle (D84). */\nexport interface ClientCapabilities {\n /** Notification methods the client accepts. The instance sends no others. */\n readonly notifications?: readonly string[];\n}\n\n/**\n * Home settings from a spawning host (INTERFACES §6). Each setting arrives with the package that\n * implements it.\n */\nexport interface HomeConfig {\n /**\n * The home the client expects. A check, not a setting (D84): the instance chose and locked its\n * home at start-up, and refuses the session with `MOSTRA_HOME_MISMATCH` when this names a\n * different one.\n */\n readonly path?: string;\n /**\n * The dependency policy (D43, D95), kept in the home's `config.json` for every later client:\n * `auto` (the default) installs any package an artifact imports; `explicit` installs only what\n * `deps/add` adds and reports other imports as `MOSTRA_DEP_MISSING`.\n */\n readonly dependencies?: DependencyPolicy;\n /**\n * The home's submission policy (D102), kept in `config.json`: it applies to every artifact whose\n * `artifact/publish` names no policy, before the manifest's request.\n */\n readonly submission?: SubmissionPolicy;\n /**\n * The ports this client always provides, kept in `config.json` under its `client.name` (D105).\n * Submissions made while it is away wait in the outbox for it; an empty list stops that.\n */\n readonly ports?: readonly PortName[];\n /**\n * The submit channels the home accepts (D40, D108), kept in `config.json`: `[\"shell\"]` lets only\n * the shell's trusted Submit and Choose make submissions and choices; absent, both channels are\n * allowed. A host's `trustedControls` port answers per view instead, when it is connected.\n */\n readonly submitChannels?: readonly SubmitChannel[];\n}\n\n/** How packages enter an artifact's lockfile (D43). */\nexport type DependencyPolicy = \"auto\" | \"explicit\";\n\n/** The Zod schema of the `DependencyPolicy` type. */\nexport const DependencyPolicy: z.ZodType<DependencyPolicy> = z\n .enum([\"auto\", \"explicit\"])\n .register(wireRegistry, {\n id: \"DependencyPolicy\",\n description:\n \"How packages enter an artifact's lockfile: auto installs what artifacts import; explicit only what deps/add adds (D43).\",\n });\n\n/** The params of `mostra/initialize` (INTERFACES §6). */\nexport interface MostraInitializeParams {\n /** Who is connecting. */\n readonly client: ClientInfo;\n /**\n * The host protocol revisions the client speaks. The instance picks the newest one it also\n * supports, or refuses with `MOSTRA_HOST_REVISION_UNSUPPORTED`. Entries that aren't revisions\n * never match.\n */\n readonly revisions: readonly string[];\n /** What the client can handle. */\n readonly capabilities: ClientCapabilities;\n /**\n * Ports the client implements. The instance calls a port only on the connection that registered\n * it; ports it doesn't support get a `MOSTRA_HOST_PORT_UNSUPPORTED` warning.\n */\n readonly ports: readonly PortName[];\n /** Home settings and the home check. */\n readonly home?: HomeConfig;\n}\n\n/** The instance a client is connected to. */\nexport interface InstanceInfo {\n /** The runtime release (`@mostra/runtime` version). */\n readonly version: string;\n /** The home's real path. */\n readonly home: string;\n /** The platform as `<os>-<arch>`, for example `darwin-arm64`. */\n readonly platform: string;\n /** The supervisor's process ID. */\n readonly pid: number;\n /** `host` when spawned over stdio (`mostra-runtime host`), `daemon` when started as a daemon. */\n readonly mode: \"host\" | \"daemon\";\n}\n\n/** What the instance offers (D84). */\nexport interface InstanceCapabilities {\n /** Every method the instance serves. */\n readonly methods: readonly string[];\n /** Every notification the instance may send. */\n readonly notifications: readonly string[];\n /** The ports the instance calls when a client registers them. */\n readonly ports: readonly PortName[];\n}\n\n/** The result of `mostra/initialize`. */\nexport interface MostraInitializeResult {\n /** The negotiated host protocol revision: the newest both sides support. */\n readonly revision: Revision;\n /** The instance the client is connected to. */\n readonly instance: InstanceInfo;\n /** What the instance offers. */\n readonly capabilities: InstanceCapabilities;\n /** Warnings about the session, such as ports the instance doesn't support. */\n readonly warnings: readonly Diagnostic[];\n}\n\n/** The Zod schema of the `ClientInfo` type. */\nexport const ClientInfo: z.ZodType<ClientInfo> = z\n .object({ name: z.string().min(1), version: z.string() })\n .register(wireRegistry, { id: \"ClientInfo\", description: \"The client that opens a connection.\" });\n\n/** The Zod schema of the `ClientCapabilities` type. */\nexport const ClientCapabilities: z.ZodType<ClientCapabilities> = z\n .object({ notifications: z.array(z.string()).readonly().exactOptional() })\n .register(wireRegistry, {\n id: \"ClientCapabilities\",\n description: \"What the client can handle: the notification methods it accepts.\",\n });\n\n/** The Zod schema of the `HomeConfig` type. */\nexport const HomeConfig: z.ZodType<HomeConfig> = z\n .object({\n path: z.string().min(1).exactOptional(),\n dependencies: DependencyPolicy.exactOptional(),\n submission: SubmissionPolicy.exactOptional(),\n ports: z.array(PortName).max(32).readonly().exactOptional(),\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"HomeConfig\",\n description:\n \"Home settings from a spawning host; path is a check against the instance's home (D84), dependencies the dependency policy (D43), submission the home's policy (D102), ports those the host always provides (D105).\",\n });\n\n/** The Zod schema of the `InstanceInfo` type. */\nexport const InstanceInfo: z.ZodType<InstanceInfo> = z\n .object({\n version: z.string(),\n home: z.string(),\n platform: z.string(),\n pid: z.int().min(1),\n mode: z.enum([\"host\", \"daemon\"]),\n })\n .register(wireRegistry, {\n id: \"InstanceInfo\",\n description: \"The instance a client is connected to.\",\n });\n\n/** The Zod schema of the `InstanceCapabilities` type. */\nexport const InstanceCapabilities: z.ZodType<InstanceCapabilities> = z\n .object({\n methods: z.array(z.string()).readonly(),\n notifications: z.array(z.string()).readonly(),\n ports: z.array(PortName).readonly(),\n })\n .register(wireRegistry, {\n id: \"InstanceCapabilities\",\n description: \"What the instance offers: methods, notifications and supported ports.\",\n });\n\nconst params: z.ZodType<MostraInitializeParams> = z\n .object({\n client: ClientInfo,\n revisions: z.array(z.string()).readonly(),\n capabilities: ClientCapabilities,\n ports: z.array(PortName).readonly(),\n home: HomeConfig.exactOptional(),\n })\n .register(wireRegistry, { id: \"MostraInitializeParams\" });\n\nconst result: z.ZodType<MostraInitializeResult> = z\n .object({\n revision: Revision.schema,\n instance: InstanceInfo,\n capabilities: InstanceCapabilities,\n warnings: z.array(Diagnostic).readonly(),\n })\n .register(wireRegistry, { id: \"MostraInitializeResult\" });\n\n/**\n * `mostra/initialize`: opens a session. It must be the first request on a connection and is sent\n * once. It negotiates the protocol revision, registers the client's ports on this connection and\n * checks the home (D59, D84).\n */\nexport const mostraInitializeMethod: MethodDefinition<\n MostraInitializeParams,\n MostraInitializeResult\n> = defineMethod({\n method: \"mostra/initialize\",\n direction: \"client-to-instance\",\n mutating: false,\n params,\n result,\n});\n"],"mappings":";;;;;;;;;AA2BA,MAAa,WAAwC,EAClD,OAAO,CAAC,CACR,MAAM,qBAAqB,CAAC,CAC5B,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;;;;;AAOH,MAAa,kBAAkB;;AAuD/B,MAAa,mBAAgD,EAC1D,KAAK,CAAC,QAAQ,UAAU,CAAC,CAAC,CAC1B,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AA4DH,MAAa,aAAoC,EAC9C,OAAO;CAAE,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAAG,SAAS,EAAE,OAAO;AAAE,CAAC,CAAC,CACxD,SAAS,cAAc;CAAE,IAAI;CAAc,aAAa;AAAsC,CAAC;;AAGlG,MAAa,qBAAoD,EAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CACzE,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,aAAoC,EAC9C,OAAO;CACN,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;CACtC,cAAc,iBAAiB,cAAc;CAC7C,YAAY,iBAAiB,cAAc;CAC3C,OAAO,EAAE,MAAM,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CAC1D,gBAAgB,EAAE,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;AAChF,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AAGH,MAAa,eAAwC,EAClD,OAAO;CACN,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;CACf,UAAU,EAAE,OAAO;CACnB,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CAClB,MAAM,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC;AACjC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,uBAAwD,EAClE,OAAO;CACN,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACtC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CAC5C,OAAO,EAAE,MAAM,QAAQ,CAAC,CAAC,SAAS;AACpC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;AAEH,MAAM,SAA4C,EAC/C,OAAO;CACN,QAAQ;CACR,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACxC,cAAc;CACd,OAAO,EAAE,MAAM,QAAQ,CAAC,CAAC,SAAS;CAClC,MAAM,WAAW,cAAc;AACjC,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,yBAAyB,CAAC;AAE1D,MAAM,SAA4C,EAC/C,OAAO;CACN,UAAU,SAAS;CACnB,UAAU;CACV,cAAc;CACd,UAAU,EAAE,MAAM,UAAU,CAAC,CAAC,SAAS;AACzC,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,yBAAyB,CAAC;;;;;;AAO1D,MAAa,yBAGT,aAAa;CACf,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ViewerSpec } from "../../interaction.js";
|
|
2
|
+
import { MethodDefinition } from "../../method.js";
|
|
3
|
+
//#region src/methods/port/identity-resolve.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* How a browser's request reached the gateway (D143 item 2): `local` on the gateway's own
|
|
6
|
+
* address; `tailnet` through Tailscale Serve and `token` through a public share, where the link is
|
|
7
|
+
* all that identifies the viewer (both WP-13). An open string on the wire, so a host meets a newer
|
|
8
|
+
* value instead of a refusal.
|
|
9
|
+
*/
|
|
10
|
+
export type IdentityVia = "local" | "tailnet" | "token" | (string & {});
|
|
11
|
+
/** The params of `port/identity.resolve` (INTERFACES §7, D143 item 2). */
|
|
12
|
+
export interface PortIdentityResolveParams {
|
|
13
|
+
/** The artifact whose link is being opened. */
|
|
14
|
+
readonly artifactId: string;
|
|
15
|
+
/** How the request reached the gateway. */
|
|
16
|
+
readonly via: IdentityVia;
|
|
17
|
+
/**
|
|
18
|
+
* The request's headers, names in lower case, without `cookie` and without Mostra's own
|
|
19
|
+
* `x-mostra-*` headers: what a host's proxy or tunnel added (an identity header) is here.
|
|
20
|
+
*/
|
|
21
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The result of `port/identity.resolve`: the person, as the host's stable key and display name
|
|
25
|
+
* (one viewer of kind `host` per `ref`), or `null` for the standalone default.
|
|
26
|
+
*/
|
|
27
|
+
export type PortIdentityResolveResult = ViewerSpec | null;
|
|
28
|
+
/**
|
|
29
|
+
* `port/identity.resolve`: Mostra asks the host that registered the `identity` port who a browser
|
|
30
|
+
* is when it opens a link minted without a viewer (D143 item 2), with 5 seconds to answer. A
|
|
31
|
+
* failure, a timeout or an answer the schema refuses refuses the link's exchange with
|
|
32
|
+
* `MOSTRA_HOST_IDENTITY_UNAVAILABLE`; it never falls back to another person.
|
|
33
|
+
*/
|
|
34
|
+
export declare const portIdentityResolveMethod: MethodDefinition<PortIdentityResolveParams, PortIdentityResolveResult>;
|
|
35
|
+
//#endregion
|
|
36
|
+
//# sourceMappingURL=identity-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-resolve.d.ts","names":[],"sources":["../../../src/methods/port/identity-resolve.ts"],"mappings":";;;;;;;;;YAYY;;iBAGK;;WAEN;;WAEA,KAAK;;;;;WAKL,SAAS,SAAS;;;;;;YAOjB,4BAA4B;;;;;;;qBA0B3B,2BAA2B,iBACtC,2BACA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { wireRegistry } from "../../wire-registry.js";
|
|
2
|
+
import { ArtifactId } from "../../ids.js";
|
|
3
|
+
import { ViewerSpec } from "../../interaction.js";
|
|
4
|
+
import { defineMethod } from "../../method.js";
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
//#region src/methods/port/identity-resolve.ts
|
|
7
|
+
const params = z.object({
|
|
8
|
+
artifactId: ArtifactId.schema,
|
|
9
|
+
via: z.string().min(1),
|
|
10
|
+
headers: z.record(z.string(), z.string())
|
|
11
|
+
}).register(wireRegistry, {
|
|
12
|
+
id: "PortIdentityResolveParams",
|
|
13
|
+
description: "A browser opening a link without a viewer: the artifact, how the request arrived and its headers (no cookies, no Mostra headers)."
|
|
14
|
+
});
|
|
15
|
+
const result = ViewerSpec.nullable().register(wireRegistry, {
|
|
16
|
+
id: "PortIdentityResolveResult",
|
|
17
|
+
description: "The person the session acts for, by the host's stable key, or null for the default."
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* `port/identity.resolve`: Mostra asks the host that registered the `identity` port who a browser
|
|
21
|
+
* is when it opens a link minted without a viewer (D143 item 2), with 5 seconds to answer. A
|
|
22
|
+
* failure, a timeout or an answer the schema refuses refuses the link's exchange with
|
|
23
|
+
* `MOSTRA_HOST_IDENTITY_UNAVAILABLE`; it never falls back to another person.
|
|
24
|
+
*/
|
|
25
|
+
const portIdentityResolveMethod = defineMethod({
|
|
26
|
+
method: "port/identity.resolve",
|
|
27
|
+
direction: "instance-to-host",
|
|
28
|
+
mutating: false,
|
|
29
|
+
params,
|
|
30
|
+
result
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
export { portIdentityResolveMethod };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=identity-resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-resolve.js","names":[],"sources":["../../../src/methods/port/identity-resolve.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactId } 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 browser's request reached the gateway (D143 item 2): `local` on the gateway's own\n * address; `tailnet` through Tailscale Serve and `token` through a public share, where the link is\n * all that identifies the viewer (both WP-13). An open string on the wire, so a host meets a newer\n * value instead of a refusal.\n */\nexport type IdentityVia = \"local\" | \"tailnet\" | \"token\" | (string & {});\n\n/** The params of `port/identity.resolve` (INTERFACES §7, D143 item 2). */\nexport interface PortIdentityResolveParams {\n /** The artifact whose link is being opened. */\n readonly artifactId: string;\n /** How the request reached the gateway. */\n readonly via: IdentityVia;\n /**\n * The request's headers, names in lower case, without `cookie` and without Mostra's own\n * `x-mostra-*` headers: what a host's proxy or tunnel added (an identity header) is here.\n */\n readonly headers: Readonly<Record<string, string>>;\n}\n\n/**\n * The result of `port/identity.resolve`: the person, as the host's stable key and display name\n * (one viewer of kind `host` per `ref`), or `null` for the standalone default.\n */\nexport type PortIdentityResolveResult = ViewerSpec | null;\n\nconst params: z.ZodType<PortIdentityResolveParams> = z\n .object({\n artifactId: ArtifactId.schema,\n via: z.string().min(1),\n headers: z.record(z.string(), z.string()),\n })\n .register(wireRegistry, {\n id: \"PortIdentityResolveParams\",\n description:\n \"A browser opening a link without a viewer: the artifact, how the request arrived and its headers (no cookies, no Mostra headers).\",\n });\n\nconst result: z.ZodType<PortIdentityResolveResult> = ViewerSpec.nullable().register(wireRegistry, {\n id: \"PortIdentityResolveResult\",\n description:\n \"The person the session acts for, by the host's stable key, or null for the default.\",\n});\n\n/**\n * `port/identity.resolve`: Mostra asks the host that registered the `identity` port who a browser\n * is when it opens a link minted without a viewer (D143 item 2), with 5 seconds to answer. A\n * failure, a timeout or an answer the schema refuses refuses the link's exchange with\n * `MOSTRA_HOST_IDENTITY_UNAVAILABLE`; it never falls back to another person.\n */\nexport const portIdentityResolveMethod: MethodDefinition<\n PortIdentityResolveParams,\n PortIdentityResolveResult\n> = defineMethod({\n method: \"port/identity.resolve\",\n direction: \"instance-to-host\",\n mutating: false,\n params,\n result,\n});\n"],"mappings":";;;;;;AAiCA,MAAM,SAA+C,EAClD,OAAO;CACN,YAAY,WAAW;CACvB,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACrB,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;AAC1C,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;AAEH,MAAM,SAA+C,WAAW,SAAS,CAAC,CAAC,SAAS,cAAc;CAChG,IAAI;CACJ,aACE;AACJ,CAAC;;;;;;;AAQD,MAAa,4BAGT,aAAa;CACf,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mostra/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Mostra's shared protocol vocabulary: IDs, dated revisions and diagnostics, with Zod schemas and generated JSON Schema.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "The Mostra Authors",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"ignore": [
|
|
67
67
|
"zod"
|
|
68
68
|
],
|
|
69
|
-
"limit": "
|
|
69
|
+
"limit": "49 kB"
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
"name": "@mostra/protocol JSON-RPC core (D83, zod excluded)",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"ignore": [
|
|
94
94
|
"zod"
|
|
95
95
|
],
|
|
96
|
-
"limit": "8.
|
|
96
|
+
"limit": "8.75 kB"
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
"name": "@mostra/protocol server-function serializer (D54)",
|