@mostra/protocol 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +30 -4
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +14 -4
- package/dist/actions.js.map +1 -1
- package/dist/artifact.d.ts +2 -1
- package/dist/artifact.d.ts.map +1 -1
- package/dist/artifact.js +2 -1
- package/dist/artifact.js.map +1 -1
- package/dist/browser.d.ts +5 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +7 -2
- package/dist/browser.js.map +1 -1
- package/dist/capability.d.ts +0 -9
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +1 -17
- package/dist/capability.js.map +1 -1
- package/dist/diagnostics/codes/artifact.d.ts +1 -1
- package/dist/diagnostics/codes/artifact.d.ts.map +1 -1
- package/dist/diagnostics/codes/artifact.js +12 -1
- package/dist/diagnostics/codes/artifact.js.map +1 -1
- package/dist/diagnostics/codes/home.d.ts +1 -1
- package/dist/diagnostics/codes/home.d.ts.map +1 -1
- package/dist/diagnostics/codes/home.js +12 -1
- package/dist/diagnostics/codes/home.js.map +1 -1
- package/dist/diagnostics/codes/index.d.ts +3 -2
- package/dist/diagnostics/codes/index.d.ts.map +1 -1
- package/dist/diagnostics/codes/index.js +3 -1
- package/dist/diagnostics/codes/index.js.map +1 -1
- package/dist/diagnostics/codes/remote.d.ts +8 -0
- package/dist/diagnostics/codes/remote.d.ts.map +1 -0
- package/dist/diagnostics/codes/remote.js +99 -0
- package/dist/diagnostics/codes/remote.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.d.ts.map +1 -1
- package/dist/diagnostics/diagnostic.js +2 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/duration.d.ts +13 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/duration.js +27 -0
- package/dist/duration.js.map +1 -0
- package/dist/ids.d.ts +17 -1
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +9 -1
- package/dist/ids.js.map +1 -1
- package/dist/index.d.ts +30 -8
- package/dist/index.js +30 -8
- package/dist/interaction.d.ts +28 -2
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +20 -5
- package/dist/interaction.js.map +1 -1
- package/dist/manifest.d.ts +59 -14
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +63 -15
- package/dist/manifest.js.map +1 -1
- package/dist/methods/artifact/export.d.ts +40 -0
- package/dist/methods/artifact/export.d.ts.map +1 -0
- package/dist/methods/artifact/export.js +36 -0
- package/dist/methods/artifact/export.js.map +1 -0
- package/dist/methods/artifact/import.d.ts +23 -0
- package/dist/methods/artifact/import.d.ts.map +1 -0
- package/dist/methods/artifact/import.js +25 -0
- package/dist/methods/artifact/import.js.map +1 -0
- package/dist/methods/artifact/publish.d.ts +2 -1
- package/dist/methods/artifact/publish.d.ts.map +1 -1
- package/dist/methods/artifact/publish.js +1 -1
- package/dist/methods/hosted/push.d.ts +76 -0
- package/dist/methods/hosted/push.d.ts.map +1 -0
- package/dist/methods/hosted/push.js +71 -0
- package/dist/methods/hosted/push.js.map +1 -0
- package/dist/methods/hosted/submission.d.ts +18 -0
- package/dist/methods/hosted/submission.d.ts.map +1 -0
- package/dist/methods/hosted/submission.js +23 -0
- package/dist/methods/hosted/submission.js.map +1 -0
- package/dist/methods/index.d.ts.map +1 -1
- package/dist/methods/index.js +38 -2
- package/dist/methods/index.js.map +1 -1
- package/dist/methods/instance/status.d.ts +3 -0
- package/dist/methods/instance/status.d.ts.map +1 -1
- package/dist/methods/instance/status.js +3 -1
- package/dist/methods/instance/status.js.map +1 -1
- package/dist/methods/mostra/initialize.d.ts +17 -3
- package/dist/methods/mostra/initialize.d.ts.map +1 -1
- package/dist/methods/mostra/initialize.js +11 -3
- package/dist/methods/mostra/initialize.js.map +1 -1
- package/dist/methods/port/relay-call.d.ts +33 -0
- package/dist/methods/port/relay-call.d.ts.map +1 -0
- package/dist/methods/port/relay-call.js +31 -0
- package/dist/methods/port/relay-call.js.map +1 -0
- package/dist/methods/port/relay-cancel.d.ts +16 -0
- package/dist/methods/port/relay-cancel.d.ts.map +1 -0
- package/dist/methods/port/relay-cancel.js +21 -0
- package/dist/methods/port/relay-cancel.js.map +1 -0
- package/dist/methods/port/relay-live.d.ts +25 -0
- package/dist/methods/port/relay-live.d.ts.map +1 -0
- package/dist/methods/port/relay-live.js +32 -0
- package/dist/methods/port/relay-live.js.map +1 -0
- package/dist/methods/port/relay-reconcile.d.ts +39 -0
- package/dist/methods/port/relay-reconcile.d.ts.map +1 -0
- package/dist/methods/port/relay-reconcile.js +35 -0
- package/dist/methods/port/relay-reconcile.js.map +1 -0
- package/dist/methods/port/relay-run.d.ts +47 -0
- package/dist/methods/port/relay-run.d.ts.map +1 -0
- package/dist/methods/port/relay-run.js +41 -0
- package/dist/methods/port/relay-run.js.map +1 -0
- package/dist/methods/port/submissions-deliver.d.ts +8 -0
- package/dist/methods/port/submissions-deliver.d.ts.map +1 -1
- package/dist/methods/port/submissions-deliver.js +4 -2
- package/dist/methods/port/submissions-deliver.js.map +1 -1
- package/dist/methods/relay/call-batch.d.ts +26 -0
- package/dist/methods/relay/call-batch.d.ts.map +1 -0
- package/dist/methods/relay/call-batch.js +30 -0
- package/dist/methods/relay/call-batch.js.map +1 -0
- package/dist/methods/relay/effect.d.ts +31 -0
- package/dist/methods/relay/effect.d.ts.map +1 -0
- package/dist/methods/relay/effect.js +30 -0
- package/dist/methods/relay/effect.js.map +1 -0
- package/dist/methods/relay/live-value.d.ts +33 -0
- package/dist/methods/relay/live-value.d.ts.map +1 -0
- package/dist/methods/relay/live-value.js +32 -0
- package/dist/methods/relay/live-value.js.map +1 -0
- package/dist/methods/relay/run-update.d.ts +46 -0
- package/dist/methods/relay/run-update.d.ts.map +1 -0
- package/dist/methods/relay/run-update.js +45 -0
- package/dist/methods/relay/run-update.js.map +1 -0
- package/dist/methods/remote/login-wait.d.ts +30 -0
- package/dist/methods/remote/login-wait.d.ts.map +1 -0
- package/dist/methods/remote/login-wait.js +36 -0
- package/dist/methods/remote/login-wait.js.map +1 -0
- package/dist/methods/remote/login.d.ts +41 -0
- package/dist/methods/remote/login.d.ts.map +1 -0
- package/dist/methods/remote/login.js +37 -0
- package/dist/methods/remote/login.js.map +1 -0
- package/dist/methods/remote/logout.d.ts +25 -0
- package/dist/methods/remote/logout.d.ts.map +1 -0
- package/dist/methods/remote/logout.js +28 -0
- package/dist/methods/remote/logout.js.map +1 -0
- package/dist/methods/remote/status.d.ts +14 -0
- package/dist/methods/remote/status.d.ts.map +1 -0
- package/dist/methods/remote/status.js +22 -0
- package/dist/methods/remote/status.js.map +1 -0
- package/dist/methods/remote/token.d.ts +19 -0
- package/dist/methods/remote/token.d.ts.map +1 -0
- package/dist/methods/remote/token.js +24 -0
- package/dist/methods/remote/token.js.map +1 -0
- package/dist/methods/share/start.d.ts +5 -2
- package/dist/methods/share/start.d.ts.map +1 -1
- package/dist/methods/share/start.js +6 -3
- package/dist/methods/share/start.js.map +1 -1
- package/dist/methods/state/patch.d.ts +7 -0
- package/dist/methods/state/patch.d.ts.map +1 -1
- package/dist/methods/state/patch.js +2 -1
- package/dist/methods/state/patch.js.map +1 -1
- package/dist/methods/view/url.d.ts +2 -1
- package/dist/methods/view/url.d.ts.map +1 -1
- package/dist/methods/view/url.js +2 -1
- package/dist/methods/view/url.js.map +1 -1
- package/dist/policy.d.ts +18 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +23 -0
- package/dist/policy.js.map +1 -0
- package/dist/remote.d.ts +55 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +52 -0
- package/dist/remote.js.map +1 -0
- package/dist/view.d.ts +1 -1
- package/dist/view.js +1 -1
- package/dist/view.js.map +1 -1
- package/package.json +2 -2
- package/schemas/protocol.draft-07.json +1607 -126
- package/schemas/protocol.schema.json +1543 -126
- package/src/actions.ts +45 -5
- package/src/browser.ts +6 -0
- package/src/capability.ts +0 -23
- package/src/diagnostics/codes/artifact.ts +12 -0
- package/src/diagnostics/codes/home.ts +12 -0
- package/src/diagnostics/codes/index.ts +6 -2
- package/src/diagnostics/codes/remote.ts +113 -0
- package/src/diagnostics/diagnostic.ts +3 -1
- package/src/duration.ts +29 -0
- package/src/ids.ts +33 -1
- package/src/index.ts +124 -8
- package/src/interaction.ts +42 -2
- package/src/manifest.ts +115 -24
- package/src/methods/artifact/export.ts +68 -0
- package/src/methods/artifact/import.ts +39 -0
- package/src/methods/hosted/push.ts +146 -0
- package/src/methods/hosted/submission.ts +34 -0
- package/src/methods/index.ts +36 -0
- package/src/methods/instance/status.ts +4 -0
- package/src/methods/mostra/initialize.ts +19 -3
- package/src/methods/port/relay-call.ts +58 -0
- package/src/methods/port/relay-cancel.ts +33 -0
- package/src/methods/port/relay-live.ts +48 -0
- package/src/methods/port/relay-reconcile.ts +71 -0
- package/src/methods/port/relay-run.ts +80 -0
- package/src/methods/port/submissions-deliver.ts +13 -1
- package/src/methods/relay/call-batch.ts +52 -0
- package/src/methods/relay/effect.ts +55 -0
- package/src/methods/relay/live-value.ts +54 -0
- package/src/methods/relay/run-update.ts +81 -0
- package/src/methods/remote/login-wait.ts +55 -0
- package/src/methods/remote/login.ts +72 -0
- package/src/methods/remote/logout.ts +42 -0
- package/src/methods/remote/status.ts +34 -0
- package/src/methods/remote/token.ts +39 -0
- package/src/methods/share/start.ts +12 -4
- package/src/methods/state/patch.ts +6 -0
- package/src/methods/view/url.ts +2 -1
- package/src/policy.ts +30 -0
- package/src/remote.ts +89 -0
- package/src/view.ts +1 -1
|
@@ -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,7 +5,9 @@
|
|
|
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";
|
|
10
12
|
import { artifactPublishMethod } from "./artifact/publish.ts";
|
|
11
13
|
import { artifactVerifyMethod } from "./artifact/verify.ts";
|
|
@@ -17,6 +19,8 @@ import { eventsReadMethod } from "./events/read.ts";
|
|
|
17
19
|
import { EVENTS_NOTIFY, EventsNotifyParams, eventsSubscribeMethod } from "./events/subscribe.ts";
|
|
18
20
|
import { eventsUnsubscribeMethod } from "./events/unsubscribe.ts";
|
|
19
21
|
import { gcRunMethod } from "./gc/run.ts";
|
|
22
|
+
import { hostedPushMethod } from "./hosted/push.ts";
|
|
23
|
+
import { hostedSubmissionMethod } from "./hosted/submission.ts";
|
|
20
24
|
import { instanceCheckMethod } from "./instance/check.ts";
|
|
21
25
|
import { instanceStatusMethod } from "./instance/status.ts";
|
|
22
26
|
import { livePushMethod } from "./live/push.ts";
|
|
@@ -25,10 +29,24 @@ import { mostraShutdownMethod } from "./mostra/shutdown.ts";
|
|
|
25
29
|
import { portAddressingExternalBaseMethod } from "./port/addressing-external-base.ts";
|
|
26
30
|
import { portDraftsMirrorMethod } from "./port/drafts-mirror.ts";
|
|
27
31
|
import { portIdentityResolveMethod } from "./port/identity-resolve.ts";
|
|
32
|
+
import { portRelayCallMethod } from "./port/relay-call.ts";
|
|
33
|
+
import { portRelayCancelMethod } from "./port/relay-cancel.ts";
|
|
34
|
+
import { portRelayLiveMethod } from "./port/relay-live.ts";
|
|
35
|
+
import { portRelayReconcileMethod } from "./port/relay-reconcile.ts";
|
|
36
|
+
import { portRelayRunMethod } from "./port/relay-run.ts";
|
|
28
37
|
import { portSecretsGetMethod } from "./port/secrets-get.ts";
|
|
29
38
|
import { portSubmissionsDeliverMethod } from "./port/submissions-deliver.ts";
|
|
30
39
|
import { portTrustedControlsActivatedMethod } from "./port/trusted-controls-activated.ts";
|
|
31
40
|
import { portTrustedControlsPolicyMethod } from "./port/trusted-controls-policy.ts";
|
|
41
|
+
import { relayCallBatchMethod } from "./relay/call-batch.ts";
|
|
42
|
+
import { relayEffectMethod } from "./relay/effect.ts";
|
|
43
|
+
import { relayLiveValueMethod } from "./relay/live-value.ts";
|
|
44
|
+
import { relayRunUpdateMethod } from "./relay/run-update.ts";
|
|
45
|
+
import { remoteLoginMethod } from "./remote/login.ts";
|
|
46
|
+
import { remoteLoginWaitMethod } from "./remote/login-wait.ts";
|
|
47
|
+
import { remoteLogoutMethod } from "./remote/logout.ts";
|
|
48
|
+
import { remoteStatusMethod } from "./remote/status.ts";
|
|
49
|
+
import { remoteTokenMethod } from "./remote/token.ts";
|
|
32
50
|
import { resultsGetMethod } from "./results/get.ts";
|
|
33
51
|
import { secretDeleteMethod } from "./secret/delete.ts";
|
|
34
52
|
import { secretListMethod } from "./secret/list.ts";
|
|
@@ -88,6 +106,24 @@ export const hostMethods: readonly AnyMethod[] = [
|
|
|
88
106
|
shareStopMethod,
|
|
89
107
|
shareListMethod,
|
|
90
108
|
portAddressingExternalBaseMethod,
|
|
109
|
+
artifactExportMethod,
|
|
110
|
+
artifactImportMethod,
|
|
111
|
+
remoteLoginMethod,
|
|
112
|
+
remoteLoginWaitMethod,
|
|
113
|
+
remoteLogoutMethod,
|
|
114
|
+
remoteStatusMethod,
|
|
115
|
+
remoteTokenMethod,
|
|
116
|
+
hostedPushMethod,
|
|
117
|
+
portRelayRunMethod,
|
|
118
|
+
portRelayCancelMethod,
|
|
119
|
+
portRelayReconcileMethod,
|
|
120
|
+
portRelayCallMethod,
|
|
121
|
+
relayRunUpdateMethod,
|
|
122
|
+
relayCallBatchMethod,
|
|
123
|
+
relayEffectMethod,
|
|
124
|
+
portRelayLiveMethod,
|
|
125
|
+
relayLiveValueMethod,
|
|
126
|
+
hostedSubmissionMethod,
|
|
91
127
|
// gen:methods
|
|
92
128
|
];
|
|
93
129
|
|
|
@@ -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,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
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
|
|
6
|
+
/** Who pressed a relayed action, as its server code's `viewer()` reads it. */
|
|
7
|
+
export interface RelayViewer {
|
|
8
|
+
/** The hosted home's viewer ID. */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
/** The display name, when one is known. */
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The Zod schema of the `RelayViewer` type. */
|
|
15
|
+
export const RelayViewer: z.ZodType<RelayViewer> = z
|
|
16
|
+
.object({ id: z.string().min(1), name: z.string().exactOptional() })
|
|
17
|
+
.register(wireRegistry, {
|
|
18
|
+
id: "RelayViewer",
|
|
19
|
+
description: "The viewer a relayed run or call acts for: the hosted home's viewer ID and name.",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/** The params of `port/relay.run` (INTERFACES §18.3). */
|
|
23
|
+
export interface PortRelayRunParams {
|
|
24
|
+
/** The hosted home's run ID: the owner records the run under it, so a repeat joins it. */
|
|
25
|
+
readonly runId: string;
|
|
26
|
+
/** The run's relay sequence, unique per owner link and growing (the owner's `relayMark`). */
|
|
27
|
+
readonly seq: number;
|
|
28
|
+
/** The artifact, by its own ID. */
|
|
29
|
+
readonly artifactId: string;
|
|
30
|
+
/** The version whose server code runs it: the view's. */
|
|
31
|
+
readonly versionId: string;
|
|
32
|
+
/** The server function: `<module path>#<export>`. */
|
|
33
|
+
readonly fnId: string;
|
|
34
|
+
/** Its serialized arguments. */
|
|
35
|
+
readonly args: Batches;
|
|
36
|
+
/** The run's idempotency key, which the hosted home checked (D130). */
|
|
37
|
+
readonly key?: string;
|
|
38
|
+
/** Who pressed it. */
|
|
39
|
+
readonly viewer?: RelayViewer;
|
|
40
|
+
/** The hosted view that started it. */
|
|
41
|
+
readonly viewId?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The result of `port/relay.run`: the owner recorded the run, so it happens at most once. */
|
|
45
|
+
export interface PortRelayRunResult {
|
|
46
|
+
/** Always `true`: a run the owner can't record is an error. */
|
|
47
|
+
readonly accepted: true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const params: z.ZodType<PortRelayRunParams> = z
|
|
51
|
+
.object({
|
|
52
|
+
runId: z.string().min(1),
|
|
53
|
+
seq: z.int().min(1),
|
|
54
|
+
artifactId: z.string().min(1),
|
|
55
|
+
versionId: z.string().min(1),
|
|
56
|
+
fnId: z.string().min(1),
|
|
57
|
+
args: Batches,
|
|
58
|
+
key: z.string().exactOptional(),
|
|
59
|
+
viewer: RelayViewer.exactOptional(),
|
|
60
|
+
viewId: z.string().exactOptional(),
|
|
61
|
+
})
|
|
62
|
+
.register(wireRegistry, { id: "PortRelayRunParams" });
|
|
63
|
+
|
|
64
|
+
const result: z.ZodType<PortRelayRunResult> = z
|
|
65
|
+
.object({ accepted: z.literal(true) })
|
|
66
|
+
.register(wireRegistry, { id: "PortRelayRunResult" });
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* `port/relay.run`: a hosted home hands its owner instance a run to execute (D165 item 4), answered
|
|
70
|
+
* once the owner recorded it under the hosted run's ID; its progress, log, result and end come back
|
|
71
|
+
* as `relay/run.update`.
|
|
72
|
+
*/
|
|
73
|
+
export const portRelayRunMethod: MethodDefinition<PortRelayRunParams, PortRelayRunResult> =
|
|
74
|
+
defineMethod({
|
|
75
|
+
method: "port/relay.run",
|
|
76
|
+
direction: "instance-to-host",
|
|
77
|
+
mutating: false,
|
|
78
|
+
params,
|
|
79
|
+
result,
|
|
80
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
import { ArtifactId, DeliveryId, SubmissionId } from "../../ids.ts";
|
|
2
|
+
import { ArtifactId, Cursor, DeliveryId, SubmissionId } from "../../ids.ts";
|
|
3
3
|
import { Results } from "../../interaction.ts";
|
|
4
4
|
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
5
5
|
import { wireRegistry } from "../../wire-registry.ts";
|
|
@@ -18,6 +18,13 @@ export interface SubmissionEnvelope {
|
|
|
18
18
|
readonly attempt: number;
|
|
19
19
|
/** The complete submission (INTERFACES §8), built from the immutable submission alone. */
|
|
20
20
|
readonly results: Results;
|
|
21
|
+
/**
|
|
22
|
+
* The submission's stored snapshot, its canonical text, whose SHA-256 is `results.submission.digest`.
|
|
23
|
+
* A hosted home sends it to its owner instance, which keeps the same submission (D165 item 1).
|
|
24
|
+
*/
|
|
25
|
+
readonly snapshot?: string;
|
|
26
|
+
/** With `snapshot`: the cursor of the submission's `submission.created` in the hosted home. */
|
|
27
|
+
readonly cursor?: Cursor;
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
/** What a host answers a delivery. */
|
|
@@ -40,6 +47,11 @@ export const SubmissionEnvelope: z.ZodType<SubmissionEnvelope> = z
|
|
|
40
47
|
artifactId: ArtifactId.schema,
|
|
41
48
|
attempt: z.int().min(1),
|
|
42
49
|
results: Results,
|
|
50
|
+
snapshot: z
|
|
51
|
+
.string()
|
|
52
|
+
.max(40 * 1024 * 1024)
|
|
53
|
+
.exactOptional(),
|
|
54
|
+
cursor: Cursor.schema.exactOptional(),
|
|
43
55
|
})
|
|
44
56
|
.register(wireRegistry, {
|
|
45
57
|
id: "SubmissionEnvelope",
|