@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,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",
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
/** The params of `relay/call.batch` (INTERFACES §18.3). */
|
|
7
|
+
export interface RelayCallBatchParams {
|
|
8
|
+
/** The hosted home's call. */
|
|
9
|
+
readonly callId: string;
|
|
10
|
+
/** Grows by one per message of the call. */
|
|
11
|
+
readonly seq: number;
|
|
12
|
+
/** Serialized batches of the result, in order. */
|
|
13
|
+
readonly batches?: Batches;
|
|
14
|
+
/** The call's end: the last message. */
|
|
15
|
+
readonly end?: {
|
|
16
|
+
readonly status: "succeeded" | "failed";
|
|
17
|
+
readonly error?: { readonly message: string; readonly code?: string };
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The result of `relay/call.batch`. */
|
|
22
|
+
export type RelayCallBatchResult = Record<string, never>;
|
|
23
|
+
|
|
24
|
+
const params: z.ZodType<RelayCallBatchParams> = z
|
|
25
|
+
.object({
|
|
26
|
+
callId: z.string().min(1),
|
|
27
|
+
seq: z.int().min(1),
|
|
28
|
+
batches: Batches.exactOptional(),
|
|
29
|
+
end: z
|
|
30
|
+
.object({
|
|
31
|
+
status: z.enum(["succeeded", "failed"]),
|
|
32
|
+
error: z
|
|
33
|
+
.object({ message: z.string().max(10_000), code: z.string().max(200).exactOptional() })
|
|
34
|
+
.exactOptional(),
|
|
35
|
+
})
|
|
36
|
+
.exactOptional(),
|
|
37
|
+
})
|
|
38
|
+
.register(wireRegistry, { id: "RelayCallBatchParams" });
|
|
39
|
+
|
|
40
|
+
const result: z.ZodType<RelayCallBatchResult> = z
|
|
41
|
+
.object({})
|
|
42
|
+
.register(wireRegistry, { id: "RelayCallBatchResult" });
|
|
43
|
+
|
|
44
|
+
/** `relay/call.batch`: the owner streams a relayed plain call's result back, then its end. */
|
|
45
|
+
export const relayCallBatchMethod: MethodDefinition<RelayCallBatchParams, RelayCallBatchResult> =
|
|
46
|
+
defineMethod({
|
|
47
|
+
method: "relay/call.batch",
|
|
48
|
+
direction: "client-to-instance",
|
|
49
|
+
mutating: false,
|
|
50
|
+
params,
|
|
51
|
+
result,
|
|
52
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { Cursor } from "../../ids.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `relay/effect` (INTERFACES §18.3). */
|
|
7
|
+
export interface RelayEffectParams {
|
|
8
|
+
/** The artifact, by its own ID. */
|
|
9
|
+
readonly artifactId: string;
|
|
10
|
+
/** The relayed run whose server code raised it. */
|
|
11
|
+
readonly runId?: string;
|
|
12
|
+
/** Or the relayed plain call. */
|
|
13
|
+
readonly callId?: string;
|
|
14
|
+
/** `signal()` or `emit()` (§2.4). */
|
|
15
|
+
readonly kind: "signal" | "emit";
|
|
16
|
+
/** The signal's name, or the host event's type (`host.…`). */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** Its JSON payload, at most 64 KiB. */
|
|
19
|
+
readonly payload?: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The result of `relay/effect`: the event's cursor in the hosted home. */
|
|
23
|
+
export interface RelayEffectResult {
|
|
24
|
+
/** Where the hosted home appended it. */
|
|
25
|
+
readonly cursor: Cursor;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const params: z.ZodType<RelayEffectParams> = z
|
|
29
|
+
.object({
|
|
30
|
+
artifactId: z.string().min(1),
|
|
31
|
+
runId: z.string().exactOptional(),
|
|
32
|
+
callId: z.string().exactOptional(),
|
|
33
|
+
kind: z.enum(["signal", "emit"]),
|
|
34
|
+
name: z.string().min(1).max(200),
|
|
35
|
+
payload: z.unknown().exactOptional(),
|
|
36
|
+
})
|
|
37
|
+
.register(wireRegistry, { id: "RelayEffectParams" });
|
|
38
|
+
|
|
39
|
+
const result: z.ZodType<RelayEffectResult> = z
|
|
40
|
+
.object({ cursor: Cursor.schema })
|
|
41
|
+
.register(wireRegistry, { id: "RelayEffectResult" });
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* `relay/effect`: a relayed run's or call's server code raised a signal or emitted a host event;
|
|
45
|
+
* the hosted home appends it with the run's causation and the viewer who pressed it (D165 item 4),
|
|
46
|
+
* where the page and the owner's follow see it.
|
|
47
|
+
*/
|
|
48
|
+
export const relayEffectMethod: MethodDefinition<RelayEffectParams, RelayEffectResult> =
|
|
49
|
+
defineMethod({
|
|
50
|
+
method: "relay/effect",
|
|
51
|
+
direction: "client-to-instance",
|
|
52
|
+
mutating: true,
|
|
53
|
+
params,
|
|
54
|
+
result,
|
|
55
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { Batches, 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 `relay/live.value` (INTERFACES §18.3). */
|
|
7
|
+
export interface RelayLiveValueParams {
|
|
8
|
+
/** The artifact, by its own ID. */
|
|
9
|
+
readonly artifactId: string;
|
|
10
|
+
/** The version whose producer made it. */
|
|
11
|
+
readonly versionId: string;
|
|
12
|
+
/** The live source's key. */
|
|
13
|
+
readonly key: string;
|
|
14
|
+
/** The value, serialized. */
|
|
15
|
+
readonly value?: Batches;
|
|
16
|
+
/** What went wrong instead. */
|
|
17
|
+
readonly error?: { readonly message: string; readonly code?: string };
|
|
18
|
+
/** When the owner's producer made it. */
|
|
19
|
+
readonly at: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The result of `relay/live.value`. */
|
|
23
|
+
export interface RelayLiveValueResult {
|
|
24
|
+
/** The value's revision on the hosted home; absent for an error. */
|
|
25
|
+
readonly revision?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const params: z.ZodType<RelayLiveValueParams> = z
|
|
29
|
+
.object({
|
|
30
|
+
artifactId: z.string().min(1),
|
|
31
|
+
versionId: z.string().min(1),
|
|
32
|
+
key: z.string().regex(LIVE_KEY_PATTERN),
|
|
33
|
+
value: Batches.exactOptional(),
|
|
34
|
+
error: z.object({ message: z.string(), code: z.string().exactOptional() }).exactOptional(),
|
|
35
|
+
at: z.string(),
|
|
36
|
+
})
|
|
37
|
+
.register(wireRegistry, { id: "RelayLiveValueParams" });
|
|
38
|
+
|
|
39
|
+
const result: z.ZodType<RelayLiveValueResult> = z
|
|
40
|
+
.object({ revision: z.string().exactOptional() })
|
|
41
|
+
.register(wireRegistry, { id: "RelayLiveValueResult" });
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* `relay/live.value`: a value (or failure) of a hosted artifact's live source, which a producer on
|
|
45
|
+
* the owner instance made; the hosted home keeps it and its ring and serves it to viewers.
|
|
46
|
+
*/
|
|
47
|
+
export const relayLiveValueMethod: MethodDefinition<RelayLiveValueParams, RelayLiveValueResult> =
|
|
48
|
+
defineMethod({
|
|
49
|
+
method: "relay/live.value",
|
|
50
|
+
direction: "client-to-instance",
|
|
51
|
+
mutating: true,
|
|
52
|
+
params,
|
|
53
|
+
result,
|
|
54
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { Batches, RunProgress } from "../../actions.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** How a relayed run ended, as the owner ran it. */
|
|
7
|
+
export interface RelayRunEnd {
|
|
8
|
+
/** The run's final state. */
|
|
9
|
+
readonly status: "succeeded" | "failed" | "cancelled";
|
|
10
|
+
/** Why, as a local run's `reason`. */
|
|
11
|
+
readonly reason?: string;
|
|
12
|
+
/** What went wrong, without the stack. */
|
|
13
|
+
readonly error?: { readonly message: string; readonly code?: string };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The params of `relay/run.update` (INTERFACES §18.3). */
|
|
17
|
+
export interface RelayRunUpdateParams {
|
|
18
|
+
/** The hosted run. */
|
|
19
|
+
readonly runId: string;
|
|
20
|
+
/** Grows by one per update of the run; a repeat is ignored. */
|
|
21
|
+
readonly seq: number;
|
|
22
|
+
/** Its worker has it now. */
|
|
23
|
+
readonly running?: boolean;
|
|
24
|
+
/** Its latest progress. */
|
|
25
|
+
readonly progress?: RunProgress;
|
|
26
|
+
/** New log lines, from `logFrom`. */
|
|
27
|
+
readonly log?: readonly string[];
|
|
28
|
+
/** The index of `log`'s first line (additive: positions make a repeat harmless). */
|
|
29
|
+
readonly logFrom?: number;
|
|
30
|
+
/** New result batches, from `batchFrom`. */
|
|
31
|
+
readonly batches?: Batches;
|
|
32
|
+
/** The index of `batches`' first batch. */
|
|
33
|
+
readonly batchFrom?: number;
|
|
34
|
+
/** The run's end: the last update. */
|
|
35
|
+
readonly end?: RelayRunEnd;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The result of `relay/run.update`. */
|
|
39
|
+
export type RelayRunUpdateResult = Record<string, never>;
|
|
40
|
+
|
|
41
|
+
const end: z.ZodType<RelayRunEnd> = z
|
|
42
|
+
.object({
|
|
43
|
+
status: z.enum(["succeeded", "failed", "cancelled"]),
|
|
44
|
+
reason: z.string().max(200).exactOptional(),
|
|
45
|
+
error: z
|
|
46
|
+
.object({ message: z.string().max(10_000), code: z.string().max(200).exactOptional() })
|
|
47
|
+
.exactOptional(),
|
|
48
|
+
})
|
|
49
|
+
.register(wireRegistry, { id: "RelayRunEnd" });
|
|
50
|
+
|
|
51
|
+
const params: z.ZodType<RelayRunUpdateParams> = z
|
|
52
|
+
.object({
|
|
53
|
+
runId: z.string().min(1),
|
|
54
|
+
seq: z.int().min(1),
|
|
55
|
+
running: z.boolean().exactOptional(),
|
|
56
|
+
progress: RunProgress.exactOptional(),
|
|
57
|
+
log: z.array(z.string()).readonly().exactOptional(),
|
|
58
|
+
logFrom: z.int().min(0).exactOptional(),
|
|
59
|
+
batches: Batches.exactOptional(),
|
|
60
|
+
batchFrom: z.int().min(0).exactOptional(),
|
|
61
|
+
end: end.exactOptional(),
|
|
62
|
+
})
|
|
63
|
+
.register(wireRegistry, { id: "RelayRunUpdateParams" });
|
|
64
|
+
|
|
65
|
+
const result: z.ZodType<RelayRunUpdateResult> = z
|
|
66
|
+
.object({})
|
|
67
|
+
.register(wireRegistry, { id: "RelayRunUpdateResult" });
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* `relay/run.update`: the owner instance reports a relayed run's progress, log, result and end to
|
|
71
|
+
* its hosted home, in order and idempotently; an update for a run the hosted home doesn't know is
|
|
72
|
+
* dropped and logged (D165 item 4).
|
|
73
|
+
*/
|
|
74
|
+
export const relayRunUpdateMethod: MethodDefinition<RelayRunUpdateParams, RelayRunUpdateResult> =
|
|
75
|
+
defineMethod({
|
|
76
|
+
method: "relay/run.update",
|
|
77
|
+
direction: "client-to-instance",
|
|
78
|
+
mutating: true,
|
|
79
|
+
params,
|
|
80
|
+
result,
|
|
81
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
3
|
+
import { ServerOrigin } from "../../remote.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `remote/link` (INTERFACES §18.2). */
|
|
7
|
+
export interface RemoteLinkParams {
|
|
8
|
+
/** The server's API origin. */
|
|
9
|
+
readonly server: ServerOrigin;
|
|
10
|
+
/**
|
|
11
|
+
* A credential the server's operator issued for an account (`accounts.authenticate`, §18.6), in
|
|
12
|
+
* place of a person's sign-in: a program runs an always-on owner instance with it. Kept in the
|
|
13
|
+
* home, owner-only, like a refresh token; never logged.
|
|
14
|
+
*/
|
|
15
|
+
readonly key: string;
|
|
16
|
+
/** Makes this instance the account's default: the one chat-host authoring goes to (D165 item 1b). */
|
|
17
|
+
readonly default?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The result of `remote/link`: this home is linked to the server for the key's account. */
|
|
21
|
+
export interface RemoteLinkResult {
|
|
22
|
+
/** The server linked to. */
|
|
23
|
+
readonly server: ServerOrigin;
|
|
24
|
+
/** The account the key is the operator's credential for. */
|
|
25
|
+
readonly account: { readonly id: string; readonly name?: string };
|
|
26
|
+
/** This home's instance link on that server (`lnk_…`), one per key's subject. */
|
|
27
|
+
readonly instanceId: string;
|
|
28
|
+
/** Whether this instance is the account's default. */
|
|
29
|
+
readonly default: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const params: z.ZodType<RemoteLinkParams> = z
|
|
33
|
+
.object({
|
|
34
|
+
server: ServerOrigin,
|
|
35
|
+
key: z.string().min(20).max(512),
|
|
36
|
+
default: z.boolean().exactOptional(),
|
|
37
|
+
})
|
|
38
|
+
.register(wireRegistry, { id: "RemoteLinkParams" });
|
|
39
|
+
|
|
40
|
+
const result: z.ZodType<RemoteLinkResult> = z
|
|
41
|
+
.object({
|
|
42
|
+
server: ServerOrigin,
|
|
43
|
+
account: z.object({ id: z.string(), name: z.string().exactOptional() }),
|
|
44
|
+
instanceId: z.string(),
|
|
45
|
+
default: z.boolean(),
|
|
46
|
+
})
|
|
47
|
+
.register(wireRegistry, {
|
|
48
|
+
id: "RemoteLinkResult",
|
|
49
|
+
description: "A home linked to a remote server with an operator-issued key.",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* `remote/link`: links this home to a remote server with a key its operator issued for an account,
|
|
54
|
+
* in place of `remote/login`'s device grant, so a program can run an always-on owner instance
|
|
55
|
+
* (WP-30, D167). Linking again with a key is idempotent by nature, so it takes no `requestId`: the
|
|
56
|
+
* ledger never records the key's digest. A key the server doesn't admit is
|
|
57
|
+
* `MOSTRA_REMOTE_LOGIN_FAILED`.
|
|
58
|
+
*/
|
|
59
|
+
export const remoteLinkMethod: MethodDefinition<RemoteLinkParams, RemoteLinkResult> = defineMethod({
|
|
60
|
+
method: "remote/link",
|
|
61
|
+
direction: "client-to-instance",
|
|
62
|
+
mutating: false,
|
|
63
|
+
params,
|
|
64
|
+
result,
|
|
65
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
3
|
+
import { ServerOrigin } from "../../remote.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `remote/login.wait` (INTERFACES §18.2). */
|
|
7
|
+
export interface RemoteLoginWaitParams {
|
|
8
|
+
/** The sign-in `remote/login` started. */
|
|
9
|
+
readonly loginId: string;
|
|
10
|
+
/** How long to wait, 0 to check once. */
|
|
11
|
+
readonly timeoutMs: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The result of `remote/login.wait`: signed in, or still waiting for the person. */
|
|
15
|
+
export type RemoteLoginWaitResult =
|
|
16
|
+
| {
|
|
17
|
+
readonly status: "signed-in";
|
|
18
|
+
readonly server: ServerOrigin;
|
|
19
|
+
readonly account: { readonly id: string; readonly name?: string };
|
|
20
|
+
/** This home's instance link there (`lnk_…`). */
|
|
21
|
+
readonly instanceId: string;
|
|
22
|
+
}
|
|
23
|
+
| { readonly status: "pending" };
|
|
24
|
+
|
|
25
|
+
const params: z.ZodType<RemoteLoginWaitParams> = z
|
|
26
|
+
.object({ loginId: z.string().min(1), timeoutMs: z.int().min(0).max(2_147_483_647) })
|
|
27
|
+
.register(wireRegistry, { id: "RemoteLoginWaitParams" });
|
|
28
|
+
|
|
29
|
+
const result: z.ZodType<RemoteLoginWaitResult> = z
|
|
30
|
+
.discriminatedUnion("status", [
|
|
31
|
+
z.object({
|
|
32
|
+
status: z.literal("signed-in"),
|
|
33
|
+
server: ServerOrigin,
|
|
34
|
+
account: z.object({ id: z.string(), name: z.string().exactOptional() }),
|
|
35
|
+
instanceId: z.string(),
|
|
36
|
+
}),
|
|
37
|
+
z.object({ status: z.literal("pending") }),
|
|
38
|
+
])
|
|
39
|
+
.register(wireRegistry, {
|
|
40
|
+
id: "RemoteLoginWaitResult",
|
|
41
|
+
description: "A sign-in's end: signed in with the account and instance link, or pending.",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `remote/login.wait`: waits for a sign-in `remote/login` started; a refused or expired code is
|
|
46
|
+
* `MOSTRA_REMOTE_LOGIN_FAILED`.
|
|
47
|
+
*/
|
|
48
|
+
export const remoteLoginWaitMethod: MethodDefinition<RemoteLoginWaitParams, RemoteLoginWaitResult> =
|
|
49
|
+
defineMethod({
|
|
50
|
+
method: "remote/login.wait",
|
|
51
|
+
direction: "client-to-instance",
|
|
52
|
+
mutating: false,
|
|
53
|
+
params,
|
|
54
|
+
result,
|
|
55
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
3
|
+
import { ServerOrigin } from "../../remote.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `remote/login` (INTERFACES §18.2). */
|
|
7
|
+
export interface RemoteLoginParams {
|
|
8
|
+
/** The server's API origin. Default: the home's default server. */
|
|
9
|
+
readonly server?: ServerOrigin;
|
|
10
|
+
/**
|
|
11
|
+
* Makes this instance the account's default: the one chat-host authoring goes to (D165 item
|
|
12
|
+
* 1b). Without it, an account's first linked instance is its default.
|
|
13
|
+
*/
|
|
14
|
+
readonly default?: boolean;
|
|
15
|
+
/** Makes a retry return the same sign-in. */
|
|
16
|
+
readonly requestId?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The result of `remote/login`: a sign-in by the OAuth device authorization grant (RFC 8628) has
|
|
21
|
+
* started; the person opens `verificationUri` and enters `userCode`.
|
|
22
|
+
*/
|
|
23
|
+
export interface RemoteLoginResult {
|
|
24
|
+
/** The sign-in, for `remote/login.wait`. */
|
|
25
|
+
readonly loginId: string;
|
|
26
|
+
/** The server signed in to. */
|
|
27
|
+
readonly server: ServerOrigin;
|
|
28
|
+
/** The page the person opens. */
|
|
29
|
+
readonly verificationUri: string;
|
|
30
|
+
/** The address with the code filled in, when the server offers one. */
|
|
31
|
+
readonly verificationUriComplete?: string;
|
|
32
|
+
/** The code the person enters there. */
|
|
33
|
+
readonly userCode: string;
|
|
34
|
+
/** When the code stops working. */
|
|
35
|
+
readonly expiresAt: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const params: z.ZodType<RemoteLoginParams> = z
|
|
39
|
+
.object({
|
|
40
|
+
server: ServerOrigin.exactOptional(),
|
|
41
|
+
default: z.boolean().exactOptional(),
|
|
42
|
+
requestId: z.string().min(1).exactOptional(),
|
|
43
|
+
})
|
|
44
|
+
.register(wireRegistry, { id: "RemoteLoginParams" });
|
|
45
|
+
|
|
46
|
+
const result: z.ZodType<RemoteLoginResult> = z
|
|
47
|
+
.object({
|
|
48
|
+
loginId: z.string(),
|
|
49
|
+
server: ServerOrigin,
|
|
50
|
+
verificationUri: z.string(),
|
|
51
|
+
verificationUriComplete: z.string().exactOptional(),
|
|
52
|
+
userCode: z.string(),
|
|
53
|
+
expiresAt: z.string(),
|
|
54
|
+
})
|
|
55
|
+
.register(wireRegistry, {
|
|
56
|
+
id: "RemoteLoginResult",
|
|
57
|
+
description: "A device-grant sign-in that started: where to go and the code to enter.",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* `remote/login`: starts signing this home in to a remote server by the device authorization
|
|
62
|
+
* grant, and polls for its token in the background (D165 item 2). The instance keeps the refresh
|
|
63
|
+
* token in the home, owner-only; a home already linked there rebinds its instance link.
|
|
64
|
+
*/
|
|
65
|
+
export const remoteLoginMethod: MethodDefinition<RemoteLoginParams, RemoteLoginResult> =
|
|
66
|
+
defineMethod({
|
|
67
|
+
method: "remote/login",
|
|
68
|
+
direction: "client-to-instance",
|
|
69
|
+
mutating: true,
|
|
70
|
+
params,
|
|
71
|
+
result,
|
|
72
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
3
|
+
import { ServerOrigin } from "../../remote.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `remote/logout` (INTERFACES §18.2). */
|
|
7
|
+
export interface RemoteLogoutParams {
|
|
8
|
+
/** The server. Default: every server this home is signed in to. */
|
|
9
|
+
readonly server?: ServerOrigin;
|
|
10
|
+
/**
|
|
11
|
+
* Also forgets the instance link, after which this home owns none of the artifacts it shared
|
|
12
|
+
* there. Without it, the next sign-in rebinds the same link.
|
|
13
|
+
*/
|
|
14
|
+
readonly forget?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The result of `remote/logout`: the servers signed out of. */
|
|
18
|
+
export interface RemoteLogoutResult {
|
|
19
|
+
/** The servers this home is no longer signed in to. */
|
|
20
|
+
readonly servers: readonly ServerOrigin[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const params: z.ZodType<RemoteLogoutParams> = z
|
|
24
|
+
.object({ server: ServerOrigin.exactOptional(), forget: z.boolean().exactOptional() })
|
|
25
|
+
.register(wireRegistry, { id: "RemoteLogoutParams" });
|
|
26
|
+
|
|
27
|
+
const result: z.ZodType<RemoteLogoutResult> = z
|
|
28
|
+
.object({ servers: z.array(ServerOrigin).readonly() })
|
|
29
|
+
.register(wireRegistry, { id: "RemoteLogoutResult", description: "The servers signed out of." });
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* `remote/logout`: revokes this home's grant on a server and removes its tokens, keeping the
|
|
33
|
+
* instance link unless `forget` (D165, after the Opus review).
|
|
34
|
+
*/
|
|
35
|
+
export const remoteLogoutMethod: MethodDefinition<RemoteLogoutParams, RemoteLogoutResult> =
|
|
36
|
+
defineMethod({
|
|
37
|
+
method: "remote/logout",
|
|
38
|
+
direction: "client-to-instance",
|
|
39
|
+
mutating: true,
|
|
40
|
+
params,
|
|
41
|
+
result,
|
|
42
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
3
|
+
import { RemoteLink } from "../../remote.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `remote/status` (INTERFACES §18.2). */
|
|
7
|
+
export type RemoteStatusParams = Record<string, never>;
|
|
8
|
+
|
|
9
|
+
/** The result of `remote/status`: every server this home is linked to. */
|
|
10
|
+
export interface RemoteStatusResult {
|
|
11
|
+
/** Each server this home is linked to. */
|
|
12
|
+
readonly links: readonly RemoteLink[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const params: z.ZodType<RemoteStatusParams> = z
|
|
16
|
+
.object({})
|
|
17
|
+
.register(wireRegistry, { id: "RemoteStatusParams" });
|
|
18
|
+
|
|
19
|
+
const result: z.ZodType<RemoteStatusResult> = z
|
|
20
|
+
.object({ links: z.array(RemoteLink).readonly() })
|
|
21
|
+
.register(wireRegistry, {
|
|
22
|
+
id: "RemoteStatusResult",
|
|
23
|
+
description: "Every remote server this home is linked to.",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/** `remote/status`: the remote servers this home is linked to and each link's state. */
|
|
27
|
+
export const remoteStatusMethod: MethodDefinition<RemoteStatusParams, RemoteStatusResult> =
|
|
28
|
+
defineMethod({
|
|
29
|
+
method: "remote/status",
|
|
30
|
+
direction: "client-to-instance",
|
|
31
|
+
mutating: false,
|
|
32
|
+
params,
|
|
33
|
+
result,
|
|
34
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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 `remote/token` (INTERFACES §18.2): a fresh access token, sent in band. */
|
|
6
|
+
export interface RemoteTokenParams {
|
|
7
|
+
/** A fresh access token of the binding's own grant. */
|
|
8
|
+
readonly accessToken: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The result of `remote/token`: when the binding now closes unless refreshed again. */
|
|
12
|
+
export interface RemoteTokenResult {
|
|
13
|
+
/** When the new token expires. */
|
|
14
|
+
readonly expiresAt: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const params: z.ZodType<RemoteTokenParams> = z
|
|
18
|
+
.object({ accessToken: z.string().min(1) })
|
|
19
|
+
.register(wireRegistry, { id: "RemoteTokenParams" });
|
|
20
|
+
|
|
21
|
+
const result: z.ZodType<RemoteTokenResult> = z
|
|
22
|
+
.object({ expiresAt: z.string() })
|
|
23
|
+
.register(wireRegistry, {
|
|
24
|
+
id: "RemoteTokenResult",
|
|
25
|
+
description: "When the binding closes unless its token is refreshed again.",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* `remote/token`: on a binding to a remote server, replaces the session's access token with a
|
|
30
|
+
* fresh one for the same grant, so the server doesn't close the binding at the old one's expiry.
|
|
31
|
+
*/
|
|
32
|
+
export const remoteTokenMethod: MethodDefinition<RemoteTokenParams, RemoteTokenResult> =
|
|
33
|
+
defineMethod({
|
|
34
|
+
method: "remote/token",
|
|
35
|
+
direction: "client-to-instance",
|
|
36
|
+
mutating: false,
|
|
37
|
+
params,
|
|
38
|
+
result,
|
|
39
|
+
});
|