@mostra/protocol 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +30 -4
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +14 -4
- package/dist/actions.js.map +1 -1
- package/dist/artifact.d.ts +2 -1
- package/dist/artifact.d.ts.map +1 -1
- package/dist/artifact.js +2 -1
- package/dist/artifact.js.map +1 -1
- package/dist/browser.d.ts +47 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +36 -3
- package/dist/browser.js.map +1 -1
- package/dist/capability.d.ts +0 -9
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +1 -17
- package/dist/capability.js.map +1 -1
- package/dist/diagnostics/codes/action.d.ts +1 -1
- package/dist/diagnostics/codes/action.d.ts.map +1 -1
- package/dist/diagnostics/codes/action.js +12 -1
- package/dist/diagnostics/codes/action.js.map +1 -1
- package/dist/diagnostics/codes/artifact.d.ts +1 -1
- package/dist/diagnostics/codes/artifact.d.ts.map +1 -1
- package/dist/diagnostics/codes/artifact.js +12 -1
- package/dist/diagnostics/codes/artifact.js.map +1 -1
- package/dist/diagnostics/codes/home.d.ts +1 -1
- package/dist/diagnostics/codes/home.d.ts.map +1 -1
- package/dist/diagnostics/codes/home.js +12 -1
- package/dist/diagnostics/codes/home.js.map +1 -1
- package/dist/diagnostics/codes/index.d.ts +3 -2
- package/dist/diagnostics/codes/index.d.ts.map +1 -1
- package/dist/diagnostics/codes/index.js +3 -1
- package/dist/diagnostics/codes/index.js.map +1 -1
- package/dist/diagnostics/codes/remote.d.ts +8 -0
- package/dist/diagnostics/codes/remote.d.ts.map +1 -0
- package/dist/diagnostics/codes/remote.js +176 -0
- package/dist/diagnostics/codes/remote.js.map +1 -0
- package/dist/diagnostics/codes/submit.d.ts +1 -1
- package/dist/diagnostics/codes/submit.d.ts.map +1 -1
- package/dist/diagnostics/codes/submit.js +12 -1
- package/dist/diagnostics/codes/submit.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.d.ts.map +1 -1
- package/dist/diagnostics/diagnostic.js +2 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/duration.d.ts +13 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/duration.js +27 -0
- package/dist/duration.js.map +1 -0
- package/dist/ids.d.ts +17 -1
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +9 -1
- package/dist/ids.js.map +1 -1
- package/dist/index.d.ts +33 -8
- package/dist/index.js +33 -8
- package/dist/interaction.d.ts +33 -2
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +22 -6
- package/dist/interaction.js.map +1 -1
- package/dist/manifest.d.ts +59 -14
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +63 -15
- package/dist/manifest.js.map +1 -1
- package/dist/methods/artifact/export.d.ts +40 -0
- package/dist/methods/artifact/export.d.ts.map +1 -0
- package/dist/methods/artifact/export.js +36 -0
- package/dist/methods/artifact/export.js.map +1 -0
- package/dist/methods/artifact/import.d.ts +23 -0
- package/dist/methods/artifact/import.d.ts.map +1 -0
- package/dist/methods/artifact/import.js +25 -0
- package/dist/methods/artifact/import.js.map +1 -0
- package/dist/methods/artifact/pause.d.ts +33 -0
- package/dist/methods/artifact/pause.d.ts.map +1 -0
- package/dist/methods/artifact/pause.js +33 -0
- package/dist/methods/artifact/pause.js.map +1 -0
- package/dist/methods/artifact/publish.d.ts +2 -1
- package/dist/methods/artifact/publish.d.ts.map +1 -1
- package/dist/methods/artifact/publish.js +1 -1
- package/dist/methods/hosted/push.d.ts +76 -0
- package/dist/methods/hosted/push.d.ts.map +1 -0
- package/dist/methods/hosted/push.js +71 -0
- package/dist/methods/hosted/push.js.map +1 -0
- package/dist/methods/hosted/submission.d.ts +18 -0
- package/dist/methods/hosted/submission.d.ts.map +1 -0
- package/dist/methods/hosted/submission.js +23 -0
- package/dist/methods/hosted/submission.js.map +1 -0
- package/dist/methods/index.d.ts.map +1 -1
- package/dist/methods/index.js +44 -2
- package/dist/methods/index.js.map +1 -1
- package/dist/methods/instance/status.d.ts +3 -0
- package/dist/methods/instance/status.d.ts.map +1 -1
- package/dist/methods/instance/status.js +3 -1
- package/dist/methods/instance/status.js.map +1 -1
- package/dist/methods/mostra/initialize.d.ts +17 -3
- package/dist/methods/mostra/initialize.d.ts.map +1 -1
- package/dist/methods/mostra/initialize.js +11 -3
- package/dist/methods/mostra/initialize.js.map +1 -1
- package/dist/methods/port/relay-author.d.ts +28 -0
- package/dist/methods/port/relay-author.d.ts.map +1 -0
- package/dist/methods/port/relay-author.js +42 -0
- package/dist/methods/port/relay-author.js.map +1 -0
- package/dist/methods/port/relay-call.d.ts +33 -0
- package/dist/methods/port/relay-call.d.ts.map +1 -0
- package/dist/methods/port/relay-call.js +31 -0
- package/dist/methods/port/relay-call.js.map +1 -0
- package/dist/methods/port/relay-cancel.d.ts +16 -0
- package/dist/methods/port/relay-cancel.d.ts.map +1 -0
- package/dist/methods/port/relay-cancel.js +21 -0
- package/dist/methods/port/relay-cancel.js.map +1 -0
- package/dist/methods/port/relay-live.d.ts +25 -0
- package/dist/methods/port/relay-live.d.ts.map +1 -0
- package/dist/methods/port/relay-live.js +32 -0
- package/dist/methods/port/relay-live.js.map +1 -0
- package/dist/methods/port/relay-reconcile.d.ts +39 -0
- package/dist/methods/port/relay-reconcile.d.ts.map +1 -0
- package/dist/methods/port/relay-reconcile.js +35 -0
- package/dist/methods/port/relay-reconcile.js.map +1 -0
- package/dist/methods/port/relay-run.d.ts +47 -0
- package/dist/methods/port/relay-run.d.ts.map +1 -0
- package/dist/methods/port/relay-run.js +41 -0
- package/dist/methods/port/relay-run.js.map +1 -0
- package/dist/methods/port/submissions-deliver.d.ts +8 -0
- package/dist/methods/port/submissions-deliver.d.ts.map +1 -1
- package/dist/methods/port/submissions-deliver.js +4 -2
- package/dist/methods/port/submissions-deliver.js.map +1 -1
- package/dist/methods/relay/call-batch.d.ts +26 -0
- package/dist/methods/relay/call-batch.d.ts.map +1 -0
- package/dist/methods/relay/call-batch.js +30 -0
- package/dist/methods/relay/call-batch.js.map +1 -0
- package/dist/methods/relay/effect.d.ts +31 -0
- package/dist/methods/relay/effect.d.ts.map +1 -0
- package/dist/methods/relay/effect.js +30 -0
- package/dist/methods/relay/effect.js.map +1 -0
- package/dist/methods/relay/live-value.d.ts +33 -0
- package/dist/methods/relay/live-value.d.ts.map +1 -0
- package/dist/methods/relay/live-value.js +32 -0
- package/dist/methods/relay/live-value.js.map +1 -0
- package/dist/methods/relay/run-update.d.ts +46 -0
- package/dist/methods/relay/run-update.d.ts.map +1 -0
- package/dist/methods/relay/run-update.js +45 -0
- package/dist/methods/relay/run-update.js.map +1 -0
- package/dist/methods/remote/link.d.ts +40 -0
- package/dist/methods/remote/link.d.ts.map +1 -0
- package/dist/methods/remote/link.js +40 -0
- package/dist/methods/remote/link.js.map +1 -0
- package/dist/methods/remote/login-wait.d.ts +30 -0
- package/dist/methods/remote/login-wait.d.ts.map +1 -0
- package/dist/methods/remote/login-wait.js +36 -0
- package/dist/methods/remote/login-wait.js.map +1 -0
- package/dist/methods/remote/login.d.ts +41 -0
- package/dist/methods/remote/login.d.ts.map +1 -0
- package/dist/methods/remote/login.js +37 -0
- package/dist/methods/remote/login.js.map +1 -0
- package/dist/methods/remote/logout.d.ts +25 -0
- package/dist/methods/remote/logout.d.ts.map +1 -0
- package/dist/methods/remote/logout.js +28 -0
- package/dist/methods/remote/logout.js.map +1 -0
- package/dist/methods/remote/status.d.ts +14 -0
- package/dist/methods/remote/status.d.ts.map +1 -0
- package/dist/methods/remote/status.js +22 -0
- package/dist/methods/remote/status.js.map +1 -0
- package/dist/methods/remote/token.d.ts +19 -0
- package/dist/methods/remote/token.d.ts.map +1 -0
- package/dist/methods/remote/token.js +24 -0
- package/dist/methods/remote/token.js.map +1 -0
- package/dist/methods/share/start.d.ts +5 -2
- package/dist/methods/share/start.d.ts.map +1 -1
- package/dist/methods/share/start.js +6 -3
- package/dist/methods/share/start.js.map +1 -1
- package/dist/methods/state/patch.d.ts +7 -0
- package/dist/methods/state/patch.d.ts.map +1 -1
- package/dist/methods/state/patch.js +2 -1
- package/dist/methods/state/patch.js.map +1 -1
- package/dist/methods/view/url.d.ts +2 -1
- package/dist/methods/view/url.d.ts.map +1 -1
- package/dist/methods/view/url.js +2 -1
- package/dist/methods/view/url.js.map +1 -1
- package/dist/operator.d.ts +464 -0
- package/dist/operator.d.ts.map +1 -0
- package/dist/operator.js +134 -0
- package/dist/operator.js.map +1 -0
- package/dist/policy.d.ts +18 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +23 -0
- package/dist/policy.js.map +1 -0
- package/dist/remote.d.ts +55 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +52 -0
- package/dist/remote.js.map +1 -0
- package/dist/view.d.ts +1 -1
- package/dist/view.js +1 -1
- package/dist/view.js.map +1 -1
- package/package.json +12 -2
- package/schemas/protocol.draft-07.json +1839 -99
- package/schemas/protocol.schema.json +1787 -111
- package/src/actions.ts +45 -5
- package/src/browser.ts +70 -0
- package/src/capability.ts +0 -23
- package/src/diagnostics/codes/action.ts +12 -0
- package/src/diagnostics/codes/artifact.ts +12 -0
- package/src/diagnostics/codes/home.ts +12 -0
- package/src/diagnostics/codes/index.ts +6 -2
- package/src/diagnostics/codes/remote.ts +197 -0
- package/src/diagnostics/codes/submit.ts +12 -0
- package/src/diagnostics/diagnostic.ts +3 -1
- package/src/duration.ts +29 -0
- package/src/ids.ts +33 -1
- package/src/index.ts +143 -8
- package/src/interaction.ts +48 -2
- package/src/manifest.ts +115 -24
- package/src/methods/artifact/export.ts +68 -0
- package/src/methods/artifact/import.ts +39 -0
- package/src/methods/artifact/pause.ts +59 -0
- package/src/methods/hosted/push.ts +146 -0
- package/src/methods/hosted/submission.ts +34 -0
- package/src/methods/index.ts +42 -0
- package/src/methods/instance/status.ts +4 -0
- package/src/methods/mostra/initialize.ts +19 -3
- package/src/methods/port/relay-author.ts +57 -0
- package/src/methods/port/relay-call.ts +58 -0
- package/src/methods/port/relay-cancel.ts +33 -0
- package/src/methods/port/relay-live.ts +48 -0
- package/src/methods/port/relay-reconcile.ts +71 -0
- package/src/methods/port/relay-run.ts +80 -0
- package/src/methods/port/submissions-deliver.ts +13 -1
- package/src/methods/relay/call-batch.ts +52 -0
- package/src/methods/relay/effect.ts +55 -0
- package/src/methods/relay/live-value.ts +54 -0
- package/src/methods/relay/run-update.ts +81 -0
- package/src/methods/remote/link.ts +65 -0
- package/src/methods/remote/login-wait.ts +55 -0
- package/src/methods/remote/login.ts +72 -0
- package/src/methods/remote/logout.ts +42 -0
- package/src/methods/remote/status.ts +34 -0
- package/src/methods/remote/token.ts +39 -0
- package/src/methods/share/start.ts +12 -4
- package/src/methods/state/patch.ts +6 -0
- package/src/methods/view/url.ts +2 -1
- package/src/operator.ts +621 -0
- package/src/policy.ts +30 -0
- package/src/remote.ts +89 -0
- package/src/view.ts +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** Who paused an artifact (D165 item 14). */
|
|
7
|
+
export type PausedBy = "owner" | "operator";
|
|
8
|
+
|
|
9
|
+
/** The params of `artifact/pause` (INTERFACES §18.2, D165 item 14). */
|
|
10
|
+
export interface ArtifactPauseParams {
|
|
11
|
+
/** The artifact to pause or resume. */
|
|
12
|
+
readonly artifact: ArtifactRef;
|
|
13
|
+
/** `true` pauses it, `false` resumes it. */
|
|
14
|
+
readonly paused: boolean;
|
|
15
|
+
/** Why, shown to viewers as text while it is paused. */
|
|
16
|
+
readonly reason?: string;
|
|
17
|
+
/** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */
|
|
18
|
+
readonly requestId?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The result of `artifact/pause`: whether the artifact is paused now, and by whom. */
|
|
22
|
+
export interface ArtifactPauseResult {
|
|
23
|
+
/** Whether it is paused after the call. */
|
|
24
|
+
readonly paused: boolean;
|
|
25
|
+
/** Who paused it, while it is paused. */
|
|
26
|
+
readonly by?: PausedBy;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const params: z.ZodType<ArtifactPauseParams> = z
|
|
30
|
+
.object({
|
|
31
|
+
artifact: ArtifactRef,
|
|
32
|
+
paused: z.boolean(),
|
|
33
|
+
reason: z.string().max(500).exactOptional(),
|
|
34
|
+
requestId: z.string().min(1).exactOptional(),
|
|
35
|
+
})
|
|
36
|
+
.register(wireRegistry, { id: "ArtifactPauseParams" });
|
|
37
|
+
|
|
38
|
+
const result: z.ZodType<ArtifactPauseResult> = z
|
|
39
|
+
.object({
|
|
40
|
+
paused: z.boolean(),
|
|
41
|
+
by: z.enum(["owner", "operator"]).exactOptional(),
|
|
42
|
+
})
|
|
43
|
+
.register(wireRegistry, { id: "ArtifactPauseResult" });
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `artifact/pause`: pauses or resumes an artifact. While paused it stays viewable and its shell
|
|
47
|
+
* says so; submissions answer 423 `MOSTRA_SUBMIT_PAUSED` and actions 423 `MOSTRA_ACTION_PAUSED`,
|
|
48
|
+
* each keeping the draft; links stay valid. On an owner instance it acts on the local artifact and,
|
|
49
|
+
* for a hosted one, on every server it is hosted on. An operator's pause can't be resumed by the
|
|
50
|
+
* owner (`MOSTRA_REMOTE_PAUSED_BY_OPERATOR`).
|
|
51
|
+
*/
|
|
52
|
+
export const artifactPauseMethod: MethodDefinition<ArtifactPauseParams, ArtifactPauseResult> =
|
|
53
|
+
defineMethod({
|
|
54
|
+
method: "artifact/pause",
|
|
55
|
+
direction: "client-to-instance",
|
|
56
|
+
mutating: true,
|
|
57
|
+
params,
|
|
58
|
+
result,
|
|
59
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ArtifactId } from "../../ids.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { SubmissionPolicy } from "../../policy.ts";
|
|
5
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
6
|
+
|
|
7
|
+
/** One built file of a version: `[path, executable, sha256, size]` (DATA_MODEL §2). */
|
|
8
|
+
export type ListingEntry = readonly [
|
|
9
|
+
path: string,
|
|
10
|
+
executable: boolean,
|
|
11
|
+
sha256: string,
|
|
12
|
+
size: number,
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A version as an owner instance pushes it to its hosted home (INTERFACES §18.2, D165 item 3): its
|
|
17
|
+
* identity, its manifest, registry and lockfile, and the listing of every built file, server files
|
|
18
|
+
* included, whose digest is `outputDigest`. Never sources, never server code.
|
|
19
|
+
*/
|
|
20
|
+
export interface VersionPush {
|
|
21
|
+
/** The version ID (D89): the hosted home checks it against the artifact ID and both digests. */
|
|
22
|
+
readonly versionId: string;
|
|
23
|
+
/** Its number in the owner's home, kept in the hosted one. */
|
|
24
|
+
readonly number: number;
|
|
25
|
+
/** The source tree's digest (DATA_MODEL §2). */
|
|
26
|
+
readonly sourceDigest: string;
|
|
27
|
+
/** The environment's digest. */
|
|
28
|
+
readonly envDigest: string;
|
|
29
|
+
/** The output listing's digest: `listing` must hash to it. */
|
|
30
|
+
readonly outputDigest: string;
|
|
31
|
+
/** The version's `manifest.json`, as text. */
|
|
32
|
+
readonly manifest: string;
|
|
33
|
+
/** Its `registry.json`, as text. */
|
|
34
|
+
readonly registry: string;
|
|
35
|
+
/** Its `lock.yaml`, as text. */
|
|
36
|
+
readonly lock: string;
|
|
37
|
+
/** Every built file, server files included, as `[path, executable, sha256, size]`. */
|
|
38
|
+
readonly listing: readonly ListingEntry[];
|
|
39
|
+
/**
|
|
40
|
+
* The submission policy in force for the artifact in the owner's home (D102), which its hosted
|
|
41
|
+
* home follows: the owner's host decides it, never the server (D165 item 1).
|
|
42
|
+
*/
|
|
43
|
+
readonly policy?: SubmissionPolicy;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The params of `hosted/push`. */
|
|
47
|
+
export interface HostedPushParams {
|
|
48
|
+
/** The artifact, by its own ID (its manifest's). */
|
|
49
|
+
readonly artifactId: string;
|
|
50
|
+
/** The version to host. */
|
|
51
|
+
readonly version: VersionPush;
|
|
52
|
+
/** Makes a retry idempotent; the push is idempotent by version ID anyway. */
|
|
53
|
+
readonly requestId?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** An artifact's hosted route: its `rte_` ID and random label (INTERFACES §18.4). */
|
|
57
|
+
export interface HostedRoute {
|
|
58
|
+
/** The route's `rte_` ID, in the hosted shell's paths (`/a/<routeId>`). */
|
|
59
|
+
readonly routeId: string;
|
|
60
|
+
/** The route's DNS label on the user-content domain, never issued twice. */
|
|
61
|
+
readonly label: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The result of `hosted/push`: the files the server still lacks, or the hosted version. */
|
|
65
|
+
export type HostedPushResult =
|
|
66
|
+
| {
|
|
67
|
+
readonly status: "complete";
|
|
68
|
+
readonly versionId: string;
|
|
69
|
+
readonly number: number;
|
|
70
|
+
readonly route: HostedRoute;
|
|
71
|
+
}
|
|
72
|
+
| { readonly status: "missing"; readonly files: readonly string[]; readonly route: HostedRoute };
|
|
73
|
+
|
|
74
|
+
const Sha256 = z.string().regex(/^[0-9a-f]{64}$/);
|
|
75
|
+
|
|
76
|
+
/** The Zod schema of the `VersionPush` type. */
|
|
77
|
+
export const VersionPush: z.ZodType<VersionPush> = z
|
|
78
|
+
.object({
|
|
79
|
+
versionId: z.string().min(1),
|
|
80
|
+
number: z.int().min(1),
|
|
81
|
+
sourceDigest: Sha256,
|
|
82
|
+
envDigest: Sha256,
|
|
83
|
+
outputDigest: Sha256,
|
|
84
|
+
manifest: z.string().max(4 * 1024 * 1024),
|
|
85
|
+
registry: z.string().max(16 * 1024 * 1024),
|
|
86
|
+
lock: z.string().max(16 * 1024 * 1024),
|
|
87
|
+
listing: z
|
|
88
|
+
.array(z.tuple([z.string().min(1), z.boolean(), Sha256, z.int().min(0)]).readonly())
|
|
89
|
+
.max(100_000)
|
|
90
|
+
.readonly(),
|
|
91
|
+
policy: SubmissionPolicy.exactOptional(),
|
|
92
|
+
})
|
|
93
|
+
.register(wireRegistry, {
|
|
94
|
+
id: "VersionPush",
|
|
95
|
+
description:
|
|
96
|
+
"A version an owner pushes to its hosted home: its identity, manifest, registry, lockfile and output listing.",
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/** The Zod schema of the `HostedRoute` type. */
|
|
100
|
+
export const HostedRoute: z.ZodType<HostedRoute> = z
|
|
101
|
+
.object({ routeId: z.string(), label: z.string() })
|
|
102
|
+
.register(wireRegistry, {
|
|
103
|
+
id: "HostedRoute",
|
|
104
|
+
description: "An artifact's hosted route: its rte_ ID and random label.",
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const params: z.ZodType<HostedPushParams> = z
|
|
108
|
+
.object({
|
|
109
|
+
artifactId: ArtifactId.schema,
|
|
110
|
+
version: VersionPush,
|
|
111
|
+
requestId: z.string().min(1).exactOptional(),
|
|
112
|
+
})
|
|
113
|
+
.register(wireRegistry, { id: "HostedPushParams" });
|
|
114
|
+
|
|
115
|
+
const result: z.ZodType<HostedPushResult> = z
|
|
116
|
+
.discriminatedUnion("status", [
|
|
117
|
+
z.object({
|
|
118
|
+
status: z.literal("complete"),
|
|
119
|
+
versionId: z.string(),
|
|
120
|
+
number: z.int(),
|
|
121
|
+
route: HostedRoute,
|
|
122
|
+
}),
|
|
123
|
+
z.object({
|
|
124
|
+
status: z.literal("missing"),
|
|
125
|
+
files: z.array(Sha256).readonly(),
|
|
126
|
+
route: HostedRoute,
|
|
127
|
+
}),
|
|
128
|
+
])
|
|
129
|
+
.register(wireRegistry, {
|
|
130
|
+
id: "HostedPushResult",
|
|
131
|
+
description: "A push's state: the client files the server still lacks, or the hosted version.",
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* `hosted/push`: on a hosted home, makes a version of the owner's artifact hosted (D165 item 3).
|
|
136
|
+
* The server stores the client files the listing names, never the server files, and answers the
|
|
137
|
+
* SHA-256s it lacks until every client file was uploaded to `/files/<sha256>`. Idempotent by
|
|
138
|
+
* `versionId`; it mints the artifact's hosted route on the first push.
|
|
139
|
+
*/
|
|
140
|
+
export const hostedPushMethod: MethodDefinition<HostedPushParams, HostedPushResult> = defineMethod({
|
|
141
|
+
method: "hosted/push",
|
|
142
|
+
direction: "client-to-instance",
|
|
143
|
+
mutating: true,
|
|
144
|
+
params,
|
|
145
|
+
result,
|
|
146
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { SubmissionId } from "../../ids.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
import { SubmissionEnvelope } from "../port/submissions-deliver.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `hosted/submission` (INTERFACES §18.2). */
|
|
8
|
+
export interface HostedSubmissionParams {
|
|
9
|
+
/** The hosted submission the owner instance is missing. */
|
|
10
|
+
readonly submissionId: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The result of `hosted/submission`: the submission as its delivery to this owner carries it. */
|
|
14
|
+
export type HostedSubmissionResult = SubmissionEnvelope;
|
|
15
|
+
|
|
16
|
+
const params: z.ZodType<HostedSubmissionParams> = z
|
|
17
|
+
.object({ submissionId: SubmissionId.schema })
|
|
18
|
+
.register(wireRegistry, { id: "HostedSubmissionParams" });
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `hosted/submission`: an owner instance reads one of its artifacts' hosted submissions again,
|
|
22
|
+
* with its snapshot, when it follows a `submission.created` it doesn't hold (its home was restored
|
|
23
|
+
* from a backup taken before it, FAILURE_MODEL §11.2), and imports it as a delivery would.
|
|
24
|
+
*/
|
|
25
|
+
export const hostedSubmissionMethod: MethodDefinition<
|
|
26
|
+
HostedSubmissionParams,
|
|
27
|
+
HostedSubmissionResult
|
|
28
|
+
> = defineMethod({
|
|
29
|
+
method: "hosted/submission",
|
|
30
|
+
direction: "client-to-instance",
|
|
31
|
+
mutating: false,
|
|
32
|
+
params,
|
|
33
|
+
result: SubmissionEnvelope,
|
|
34
|
+
});
|
package/src/methods/index.ts
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
import type { AnyMethod, AnyNotification } from "../method.ts";
|
|
6
6
|
import { ARTIFACT_PROGRESS, ArtifactProgressParams } from "../verify.ts";
|
|
7
7
|
import { artifactCreateMethod } from "./artifact/create.ts";
|
|
8
|
+
import { artifactExportMethod } from "./artifact/export.ts";
|
|
8
9
|
import { artifactGetMethod } from "./artifact/get.ts";
|
|
10
|
+
import { artifactImportMethod } from "./artifact/import.ts";
|
|
9
11
|
import { artifactListMethod } from "./artifact/list.ts";
|
|
12
|
+
import { artifactPauseMethod } from "./artifact/pause.ts";
|
|
10
13
|
import { artifactPublishMethod } from "./artifact/publish.ts";
|
|
11
14
|
import { artifactVerifyMethod } from "./artifact/verify.ts";
|
|
12
15
|
import { depsAddMethod } from "./deps/add.ts";
|
|
@@ -17,6 +20,8 @@ import { eventsReadMethod } from "./events/read.ts";
|
|
|
17
20
|
import { EVENTS_NOTIFY, EventsNotifyParams, eventsSubscribeMethod } from "./events/subscribe.ts";
|
|
18
21
|
import { eventsUnsubscribeMethod } from "./events/unsubscribe.ts";
|
|
19
22
|
import { gcRunMethod } from "./gc/run.ts";
|
|
23
|
+
import { hostedPushMethod } from "./hosted/push.ts";
|
|
24
|
+
import { hostedSubmissionMethod } from "./hosted/submission.ts";
|
|
20
25
|
import { instanceCheckMethod } from "./instance/check.ts";
|
|
21
26
|
import { instanceStatusMethod } from "./instance/status.ts";
|
|
22
27
|
import { livePushMethod } from "./live/push.ts";
|
|
@@ -25,10 +30,26 @@ import { mostraShutdownMethod } from "./mostra/shutdown.ts";
|
|
|
25
30
|
import { portAddressingExternalBaseMethod } from "./port/addressing-external-base.ts";
|
|
26
31
|
import { portDraftsMirrorMethod } from "./port/drafts-mirror.ts";
|
|
27
32
|
import { portIdentityResolveMethod } from "./port/identity-resolve.ts";
|
|
33
|
+
import { portRelayAuthorMethod } from "./port/relay-author.ts";
|
|
34
|
+
import { portRelayCallMethod } from "./port/relay-call.ts";
|
|
35
|
+
import { portRelayCancelMethod } from "./port/relay-cancel.ts";
|
|
36
|
+
import { portRelayLiveMethod } from "./port/relay-live.ts";
|
|
37
|
+
import { portRelayReconcileMethod } from "./port/relay-reconcile.ts";
|
|
38
|
+
import { portRelayRunMethod } from "./port/relay-run.ts";
|
|
28
39
|
import { portSecretsGetMethod } from "./port/secrets-get.ts";
|
|
29
40
|
import { portSubmissionsDeliverMethod } from "./port/submissions-deliver.ts";
|
|
30
41
|
import { portTrustedControlsActivatedMethod } from "./port/trusted-controls-activated.ts";
|
|
31
42
|
import { portTrustedControlsPolicyMethod } from "./port/trusted-controls-policy.ts";
|
|
43
|
+
import { relayCallBatchMethod } from "./relay/call-batch.ts";
|
|
44
|
+
import { relayEffectMethod } from "./relay/effect.ts";
|
|
45
|
+
import { relayLiveValueMethod } from "./relay/live-value.ts";
|
|
46
|
+
import { relayRunUpdateMethod } from "./relay/run-update.ts";
|
|
47
|
+
import { remoteLinkMethod } from "./remote/link.ts";
|
|
48
|
+
import { remoteLoginMethod } from "./remote/login.ts";
|
|
49
|
+
import { remoteLoginWaitMethod } from "./remote/login-wait.ts";
|
|
50
|
+
import { remoteLogoutMethod } from "./remote/logout.ts";
|
|
51
|
+
import { remoteStatusMethod } from "./remote/status.ts";
|
|
52
|
+
import { remoteTokenMethod } from "./remote/token.ts";
|
|
32
53
|
import { resultsGetMethod } from "./results/get.ts";
|
|
33
54
|
import { secretDeleteMethod } from "./secret/delete.ts";
|
|
34
55
|
import { secretListMethod } from "./secret/list.ts";
|
|
@@ -88,6 +109,27 @@ export const hostMethods: readonly AnyMethod[] = [
|
|
|
88
109
|
shareStopMethod,
|
|
89
110
|
shareListMethod,
|
|
90
111
|
portAddressingExternalBaseMethod,
|
|
112
|
+
artifactExportMethod,
|
|
113
|
+
artifactImportMethod,
|
|
114
|
+
remoteLoginMethod,
|
|
115
|
+
remoteLoginWaitMethod,
|
|
116
|
+
remoteLogoutMethod,
|
|
117
|
+
remoteStatusMethod,
|
|
118
|
+
remoteTokenMethod,
|
|
119
|
+
hostedPushMethod,
|
|
120
|
+
portRelayRunMethod,
|
|
121
|
+
portRelayCancelMethod,
|
|
122
|
+
portRelayReconcileMethod,
|
|
123
|
+
portRelayCallMethod,
|
|
124
|
+
relayRunUpdateMethod,
|
|
125
|
+
relayCallBatchMethod,
|
|
126
|
+
relayEffectMethod,
|
|
127
|
+
portRelayLiveMethod,
|
|
128
|
+
relayLiveValueMethod,
|
|
129
|
+
hostedSubmissionMethod,
|
|
130
|
+
artifactPauseMethod,
|
|
131
|
+
portRelayAuthorMethod,
|
|
132
|
+
remoteLinkMethod,
|
|
91
133
|
// gen:methods
|
|
92
134
|
];
|
|
93
135
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
3
|
+
import { RemoteLink } from "../../remote.ts";
|
|
3
4
|
import { wireRegistry } from "../../wire-registry.ts";
|
|
4
5
|
import { InstanceInfo } from "../mostra/initialize.ts";
|
|
5
6
|
import { Share } from "../share/start.ts";
|
|
@@ -76,6 +77,8 @@ export interface InstanceStatusResult {
|
|
|
76
77
|
* out here, since status is printed where a link's secret mustn't appear: `share/list` gives it.
|
|
77
78
|
*/
|
|
78
79
|
readonly shares?: readonly Share[];
|
|
80
|
+
/** This home's links to remote servers (WP-29, `remote/status`), for `mostra status`. */
|
|
81
|
+
readonly links?: readonly RemoteLink[];
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
/** One artifact version's worker (RT-03, D62). */
|
|
@@ -196,6 +199,7 @@ const result: z.ZodType<InstanceStatusResult> = z
|
|
|
196
199
|
workers: z.array(WorkerStatus).readonly().exactOptional(),
|
|
197
200
|
idleExitAt: z.string().exactOptional(),
|
|
198
201
|
shares: z.array(Share).readonly().exactOptional(),
|
|
202
|
+
links: z.array(RemoteLink).readonly().exactOptional(),
|
|
199
203
|
})
|
|
200
204
|
.register(wireRegistry, { id: "InstanceStatusResult" });
|
|
201
205
|
|
|
@@ -3,6 +3,7 @@ import { Diagnostic } from "../../diagnostics/diagnostic.ts";
|
|
|
3
3
|
import { SubmitChannel } from "../../interaction.ts";
|
|
4
4
|
import { SubmissionPolicy } from "../../manifest.ts";
|
|
5
5
|
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
6
|
+
import { OwnerLinkInfo } from "../../remote.ts";
|
|
6
7
|
import { Revision } from "../../revision.ts";
|
|
7
8
|
import { wireRegistry } from "../../wire-registry.ts";
|
|
8
9
|
|
|
@@ -121,6 +122,11 @@ export interface MostraInitializeParams {
|
|
|
121
122
|
readonly ports: readonly PortName[];
|
|
122
123
|
/** Home settings and the home check. */
|
|
123
124
|
readonly home?: HomeConfig;
|
|
125
|
+
/**
|
|
126
|
+
* On a binding to a remote server, the owner instance's link (INTERFACES §18.2): its `lnk_` ID,
|
|
127
|
+
* its relay mark and the hosted home's position it committed. Other sessions send none.
|
|
128
|
+
*/
|
|
129
|
+
readonly link?: OwnerLinkInfo;
|
|
124
130
|
}
|
|
125
131
|
|
|
126
132
|
/** The instance a client is connected to. */
|
|
@@ -133,8 +139,15 @@ export interface InstanceInfo {
|
|
|
133
139
|
readonly platform: string;
|
|
134
140
|
/** The supervisor's process ID. */
|
|
135
141
|
readonly pid: number;
|
|
136
|
-
/**
|
|
137
|
-
|
|
142
|
+
/**
|
|
143
|
+
* `host` when spawned over stdio (`mostra-runtime host`), `daemon` when started as a daemon,
|
|
144
|
+
* `hosted` for a hosted home on a remote server (INTERFACES §18.2).
|
|
145
|
+
*/
|
|
146
|
+
readonly mode: "host" | "daemon" | "hosted";
|
|
147
|
+
/** A hosted home's current incarnation, rotated when it is restored from a backup. */
|
|
148
|
+
readonly incarnation?: string;
|
|
149
|
+
/** A hosted home's head: its newest event cursor. */
|
|
150
|
+
readonly cursor?: string;
|
|
138
151
|
}
|
|
139
152
|
|
|
140
153
|
/** What the instance offers (D84). */
|
|
@@ -194,7 +207,9 @@ export const InstanceInfo: z.ZodType<InstanceInfo> = z
|
|
|
194
207
|
home: z.string(),
|
|
195
208
|
platform: z.string(),
|
|
196
209
|
pid: z.int().min(1),
|
|
197
|
-
mode: z.enum(["host", "daemon"]),
|
|
210
|
+
mode: z.enum(["host", "daemon", "hosted"]),
|
|
211
|
+
incarnation: z.string().exactOptional(),
|
|
212
|
+
cursor: z.string().exactOptional(),
|
|
198
213
|
})
|
|
199
214
|
.register(wireRegistry, {
|
|
200
215
|
id: "InstanceInfo",
|
|
@@ -220,6 +235,7 @@ const params: z.ZodType<MostraInitializeParams> = z
|
|
|
220
235
|
capabilities: ClientCapabilities,
|
|
221
236
|
ports: z.array(PortName).readonly(),
|
|
222
237
|
home: HomeConfig.exactOptional(),
|
|
238
|
+
link: OwnerLinkInfo.exactOptional(),
|
|
223
239
|
})
|
|
224
240
|
.register(wireRegistry, { id: "MostraInitializeParams" });
|
|
225
241
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
3
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* What remote MCP may ask an owner instance to do for it (INTERFACES §18.8, D165 item 5): the
|
|
7
|
+
* authoring methods of the host protocol, and the owner's workspace (`McpWorkspace`, its root and
|
|
8
|
+
* its artifacts' files) and verify's screenshots, which only that machine holds.
|
|
9
|
+
*/
|
|
10
|
+
export const RELAY_AUTHOR_METHODS = [
|
|
11
|
+
"artifact/create",
|
|
12
|
+
"artifact/verify",
|
|
13
|
+
"artifact/publish",
|
|
14
|
+
"artifact/get",
|
|
15
|
+
"workspace/root",
|
|
16
|
+
"workspace/allocate",
|
|
17
|
+
"workspace/read",
|
|
18
|
+
"workspace/apply",
|
|
19
|
+
"verify/screenshot",
|
|
20
|
+
] as const;
|
|
21
|
+
|
|
22
|
+
/** One of {@link RELAY_AUTHOR_METHODS}. */
|
|
23
|
+
export type RelayAuthorMethod = (typeof RELAY_AUTHOR_METHODS)[number];
|
|
24
|
+
|
|
25
|
+
/** The params of `port/relay.author` (INTERFACES §18.3). */
|
|
26
|
+
export interface PortRelayAuthorParams {
|
|
27
|
+
/** What to do on the owner instance. */
|
|
28
|
+
readonly method: RelayAuthorMethod;
|
|
29
|
+
/** Its params: the host protocol method's, or the workspace operation's. */
|
|
30
|
+
readonly params: unknown;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The result of `port/relay.author`: the method's own result. */
|
|
34
|
+
export type PortRelayAuthorResult = unknown;
|
|
35
|
+
|
|
36
|
+
const params: z.ZodType<PortRelayAuthorParams> = z
|
|
37
|
+
.object({ method: z.enum(RELAY_AUTHOR_METHODS), params: z.unknown() })
|
|
38
|
+
.register(wireRegistry, { id: "PortRelayAuthorParams" });
|
|
39
|
+
|
|
40
|
+
const result: z.ZodType<PortRelayAuthorResult> = z
|
|
41
|
+
.unknown()
|
|
42
|
+
.register(wireRegistry, { id: "PortRelayAuthorResult" });
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `port/relay.author`: the remote MCP server relays an authoring step to the account's default
|
|
46
|
+
* owner instance (D165 item 5), which runs it in its own workspace, builder and `verify`, and
|
|
47
|
+
* answers its result or its diagnostic. A publish through it also hosts the version on the server
|
|
48
|
+
* that asked and answers the hosted link. Workspace paths stay inside the owner's workspace.
|
|
49
|
+
*/
|
|
50
|
+
export const portRelayAuthorMethod: MethodDefinition<PortRelayAuthorParams, PortRelayAuthorResult> =
|
|
51
|
+
defineMethod({
|
|
52
|
+
method: "port/relay.author",
|
|
53
|
+
direction: "instance-to-host",
|
|
54
|
+
mutating: true,
|
|
55
|
+
params,
|
|
56
|
+
result,
|
|
57
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { Batches } from "../../actions.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
import { RelayViewer } from "./relay-run.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `port/relay.call` (INTERFACES §18.3). */
|
|
8
|
+
export interface PortRelayCallParams {
|
|
9
|
+
/** The hosted home's ID for this call: its batches come back as `relay/call.batch`. */
|
|
10
|
+
readonly callId: string;
|
|
11
|
+
/** The artifact, by its own ID. */
|
|
12
|
+
readonly artifactId: string;
|
|
13
|
+
/** The version whose server code answers it: the view's. */
|
|
14
|
+
readonly versionId: string;
|
|
15
|
+
/** The server function. */
|
|
16
|
+
readonly fnId: string;
|
|
17
|
+
/** Its serialized arguments. */
|
|
18
|
+
readonly args: Batches;
|
|
19
|
+
/** Who called it. */
|
|
20
|
+
readonly viewer?: RelayViewer;
|
|
21
|
+
/** The hosted view that called it. */
|
|
22
|
+
readonly viewId?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The result of `port/relay.call`. */
|
|
26
|
+
export interface PortRelayCallResult {
|
|
27
|
+
/** Always `true`: the owner's worker has the call. */
|
|
28
|
+
readonly accepted: true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const params: z.ZodType<PortRelayCallParams> = z
|
|
32
|
+
.object({
|
|
33
|
+
callId: z.string().min(1),
|
|
34
|
+
artifactId: z.string().min(1),
|
|
35
|
+
versionId: z.string().min(1),
|
|
36
|
+
fnId: z.string().min(1),
|
|
37
|
+
args: Batches,
|
|
38
|
+
viewer: RelayViewer.exactOptional(),
|
|
39
|
+
viewId: z.string().exactOptional(),
|
|
40
|
+
})
|
|
41
|
+
.register(wireRegistry, { id: "PortRelayCallParams" });
|
|
42
|
+
|
|
43
|
+
const result: z.ZodType<PortRelayCallResult> = z
|
|
44
|
+
.object({ accepted: z.literal(true) })
|
|
45
|
+
.register(wireRegistry, { id: "PortRelayCallResult" });
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `port/relay.call`: a plain call relayed to the owner while it is connected (D165 item 4); it
|
|
49
|
+
* leaves no record, and its batches and end come back as `relay/call.batch`.
|
|
50
|
+
*/
|
|
51
|
+
export const portRelayCallMethod: MethodDefinition<PortRelayCallParams, PortRelayCallResult> =
|
|
52
|
+
defineMethod({
|
|
53
|
+
method: "port/relay.call",
|
|
54
|
+
direction: "instance-to-host",
|
|
55
|
+
mutating: false,
|
|
56
|
+
params,
|
|
57
|
+
result,
|
|
58
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
3
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
4
|
+
|
|
5
|
+
/** The params of `port/relay.cancel` (INTERFACES §18.3). */
|
|
6
|
+
export interface PortRelayCancelParams {
|
|
7
|
+
/** The hosted run to cancel. */
|
|
8
|
+
readonly runId: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The result of `port/relay.cancel`. */
|
|
12
|
+
export type PortRelayCancelResult = Record<string, never>;
|
|
13
|
+
|
|
14
|
+
const params: z.ZodType<PortRelayCancelParams> = z
|
|
15
|
+
.object({ runId: z.string().min(1) })
|
|
16
|
+
.register(wireRegistry, { id: "PortRelayCancelParams" });
|
|
17
|
+
|
|
18
|
+
const result: z.ZodType<PortRelayCancelResult> = z
|
|
19
|
+
.object({})
|
|
20
|
+
.register(wireRegistry, { id: "PortRelayCancelResult" });
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `port/relay.cancel`: a viewer cancelled a relayed run; the owner fires its `abortSignal` if it
|
|
24
|
+
* still runs (AC-04). A cancel made while the owner was away arrives on reconnect.
|
|
25
|
+
*/
|
|
26
|
+
export const portRelayCancelMethod: MethodDefinition<PortRelayCancelParams, PortRelayCancelResult> =
|
|
27
|
+
defineMethod({
|
|
28
|
+
method: "port/relay.cancel",
|
|
29
|
+
direction: "instance-to-host",
|
|
30
|
+
mutating: false,
|
|
31
|
+
params,
|
|
32
|
+
result,
|
|
33
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { LIVE_KEY_PATTERN } from "../../actions.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `port/relay.live` (INTERFACES §18.3). */
|
|
7
|
+
export interface PortRelayLiveParams {
|
|
8
|
+
/** The artifact, by its own ID. */
|
|
9
|
+
readonly artifactId: string;
|
|
10
|
+
/** The version whose producers are wanted: the artifact's latest on the hosted home. */
|
|
11
|
+
readonly versionId: string;
|
|
12
|
+
/**
|
|
13
|
+
* `start` and `renew` keep the producers of `keys` running for a minute; `stop` lets them stop;
|
|
14
|
+
* `refresh` asks them to load again now.
|
|
15
|
+
*/
|
|
16
|
+
readonly interest: "start" | "renew" | "stop" | "refresh";
|
|
17
|
+
/** The live sources' keys. */
|
|
18
|
+
readonly keys: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The result of `port/relay.live`. */
|
|
22
|
+
export type PortRelayLiveResult = Record<string, never>;
|
|
23
|
+
|
|
24
|
+
const params: z.ZodType<PortRelayLiveParams> = z
|
|
25
|
+
.object({
|
|
26
|
+
artifactId: z.string().min(1),
|
|
27
|
+
versionId: z.string().min(1),
|
|
28
|
+
interest: z.enum(["start", "renew", "stop", "refresh"]),
|
|
29
|
+
keys: z.array(z.string().regex(LIVE_KEY_PATTERN)).max(1000).readonly(),
|
|
30
|
+
})
|
|
31
|
+
.register(wireRegistry, { id: "PortRelayLiveParams" });
|
|
32
|
+
|
|
33
|
+
const result: z.ZodType<PortRelayLiveResult> = z
|
|
34
|
+
.object({})
|
|
35
|
+
.register(wireRegistry, { id: "PortRelayLiveResult" });
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* `port/relay.live`: viewers of a hosted page want (or no longer want) its live sources, so their
|
|
39
|
+
* producers run on the owner instance while someone views (D165 item 4).
|
|
40
|
+
*/
|
|
41
|
+
export const portRelayLiveMethod: MethodDefinition<PortRelayLiveParams, PortRelayLiveResult> =
|
|
42
|
+
defineMethod({
|
|
43
|
+
method: "port/relay.live",
|
|
44
|
+
direction: "instance-to-host",
|
|
45
|
+
mutating: false,
|
|
46
|
+
params,
|
|
47
|
+
result,
|
|
48
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { RunState } from "../../actions.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** What the hosted home holds of a run already, so the owner answers only what is newer. */
|
|
7
|
+
export interface RelayHeld {
|
|
8
|
+
/** The run. */
|
|
9
|
+
readonly runId: string;
|
|
10
|
+
/** How many log lines it holds. */
|
|
11
|
+
readonly log: number;
|
|
12
|
+
/** How many result batches it holds. */
|
|
13
|
+
readonly batches: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The params of `port/relay.reconcile` (INTERFACES §18.3). */
|
|
17
|
+
export interface PortRelayReconcileParams {
|
|
18
|
+
/** The runs the owner accepted and the hosted home holds no end for. */
|
|
19
|
+
readonly runs: readonly string[];
|
|
20
|
+
/** What the hosted home holds of each (additive: the owner answers from there). */
|
|
21
|
+
readonly held?: readonly RelayHeld[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** One run as the owner knows it, or `unknown-to-owner` when its ledger has no such run. */
|
|
25
|
+
export interface RelayReconciled {
|
|
26
|
+
/** The run. */
|
|
27
|
+
readonly runId: string;
|
|
28
|
+
/** Its state from the held positions on, or `unknown-to-owner`. */
|
|
29
|
+
readonly state: RunState | "unknown-to-owner";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The result of `port/relay.reconcile`. */
|
|
33
|
+
export interface PortRelayReconcileResult {
|
|
34
|
+
/** One answer per run asked about. */
|
|
35
|
+
readonly runs: readonly RelayReconciled[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const held: z.ZodType<RelayHeld> = z
|
|
39
|
+
.object({ runId: z.string().min(1), log: z.int().min(0), batches: z.int().min(0) })
|
|
40
|
+
.register(wireRegistry, { id: "RelayHeld" });
|
|
41
|
+
|
|
42
|
+
const params: z.ZodType<PortRelayReconcileParams> = z
|
|
43
|
+
.object({
|
|
44
|
+
runs: z.array(z.string().min(1)).max(10_000).readonly(),
|
|
45
|
+
held: z.array(held).max(10_000).readonly().exactOptional(),
|
|
46
|
+
})
|
|
47
|
+
.register(wireRegistry, { id: "PortRelayReconcileParams" });
|
|
48
|
+
|
|
49
|
+
const reconciled: z.ZodType<RelayReconciled> = z
|
|
50
|
+
.object({ runId: z.string(), state: z.union([RunState, z.literal("unknown-to-owner")]) })
|
|
51
|
+
.register(wireRegistry, { id: "RelayReconciled" });
|
|
52
|
+
|
|
53
|
+
const result: z.ZodType<PortRelayReconcileResult> = z
|
|
54
|
+
.object({ runs: z.array(reconciled).readonly() })
|
|
55
|
+
.register(wireRegistry, { id: "PortRelayReconcileResult" });
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* `port/relay.reconcile`: after every reconnect, before any waiting run drains, the hosted home
|
|
59
|
+
* asks its owner for the runs it accepted and hasn't finished (D165 item 4); a run the owner
|
|
60
|
+
* doesn't know becomes `unknown` and is never sent again.
|
|
61
|
+
*/
|
|
62
|
+
export const portRelayReconcileMethod: MethodDefinition<
|
|
63
|
+
PortRelayReconcileParams,
|
|
64
|
+
PortRelayReconcileResult
|
|
65
|
+
> = defineMethod({
|
|
66
|
+
method: "port/relay.reconcile",
|
|
67
|
+
direction: "instance-to-host",
|
|
68
|
+
mutating: false,
|
|
69
|
+
params,
|
|
70
|
+
result,
|
|
71
|
+
});
|