@mostra/protocol 0.8.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 +45 -1
- package/dist/diagnostics/codes/artifact.js.map +1 -1
- package/dist/diagnostics/codes/env.d.ts +1 -1
- package/dist/diagnostics/codes/env.d.ts.map +1 -1
- package/dist/diagnostics/codes/env.js +12 -1
- package/dist/diagnostics/codes/env.js.map +1 -1
- package/dist/diagnostics/codes/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/codes/submit.js +3 -3
- 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/hygiene.d.ts +4 -1
- package/dist/hygiene.d.ts.map +1 -1
- package/dist/hygiene.js +4 -0
- package/dist/hygiene.js.map +1 -1
- 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 +48 -0
- package/src/diagnostics/codes/env.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/codes/submit.ts +3 -3
- package/src/diagnostics/diagnostic.ts +3 -1
- package/src/duration.ts +29 -0
- package/src/hygiene.ts +12 -1
- 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,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,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
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
-
import { CapabilityScope
|
|
3
|
+
import { CapabilityScope } from "../../capability.ts";
|
|
4
|
+
import { Duration } from "../../duration.ts";
|
|
4
5
|
import { ArtifactId, ShareId, TokenId } from "../../ids.ts";
|
|
5
6
|
import { ViewerSpec } from "../../interaction.ts";
|
|
6
7
|
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
@@ -11,14 +12,15 @@ import { wireRegistry } from "../../wire-registry.ts";
|
|
|
11
12
|
* user's tailnet, who are known by name; `funnel` through Tailscale Funnel and `cloudflare`
|
|
12
13
|
* through a Cloudflare quick tunnel, both public, where the link is all that admits a viewer.
|
|
13
14
|
*/
|
|
14
|
-
export type ShareVia = "tailnet" | "funnel" | "cloudflare";
|
|
15
|
+
export type ShareVia = "tailnet" | "funnel" | "cloudflare" | "remote";
|
|
15
16
|
|
|
16
17
|
/** The Zod schema of the `ShareVia` type. */
|
|
17
18
|
export const ShareVia: z.ZodType<ShareVia> = z
|
|
18
|
-
.enum(["tailnet", "funnel", "cloudflare"])
|
|
19
|
+
.enum(["tailnet", "funnel", "cloudflare", "remote"])
|
|
19
20
|
.register(wireRegistry, {
|
|
20
21
|
id: "ShareVia",
|
|
21
|
-
description:
|
|
22
|
+
description:
|
|
23
|
+
"How a share reaches its viewers: tailnet, funnel or cloudflare, or remote: hosted on a remote server (D165).",
|
|
22
24
|
});
|
|
23
25
|
|
|
24
26
|
/** The longest a public share (Funnel or Cloudflare) may last: 7 days (D158). */
|
|
@@ -33,6 +35,8 @@ export interface ShareStartParams {
|
|
|
33
35
|
readonly artifact: ArtifactRef;
|
|
34
36
|
/** The tunnel. A public one (`funnel`, `cloudflare`) is explicit: never a fallback. */
|
|
35
37
|
readonly via: ShareVia;
|
|
38
|
+
/** For `remote`: the server's API origin. Default: the home's default server (D165 item 15). */
|
|
39
|
+
readonly server?: string;
|
|
36
40
|
/**
|
|
37
41
|
* How long the share and its link last, such as `30m` or `24h`. Public shares: 1 hour by
|
|
38
42
|
* default, at most 7 days. Tailnet shares: until stopped, unless given.
|
|
@@ -121,6 +125,10 @@ const params: z.ZodType<ShareStartParams> = z
|
|
|
121
125
|
.object({
|
|
122
126
|
artifact: ArtifactRef,
|
|
123
127
|
via: ShareVia,
|
|
128
|
+
server: z
|
|
129
|
+
.string()
|
|
130
|
+
.regex(/^https?:\/\/[^/?#\s]+$/)
|
|
131
|
+
.exactOptional(),
|
|
124
132
|
ttl: Duration.exactOptional(),
|
|
125
133
|
scopes: z.array(CapabilityScope).min(1).readonly().exactOptional(),
|
|
126
134
|
viewer: ViewerSpec.exactOptional(),
|
|
@@ -23,6 +23,11 @@ export interface StatePatchParams {
|
|
|
23
23
|
readonly mutationId: string;
|
|
24
24
|
/** Who writes: `agent` (the default) or `host`, recorded as each field's last writer. */
|
|
25
25
|
readonly as?: "agent" | "host";
|
|
26
|
+
/**
|
|
27
|
+
* The relayed run whose server code writes it (`state` in `@mostra/server`, D165 item 4): the
|
|
28
|
+
* change is recorded as that run's, as a local run's own write is.
|
|
29
|
+
*/
|
|
30
|
+
readonly causation?: { readonly runId: string };
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
/** The result of `state/patch`. */
|
|
@@ -35,6 +40,7 @@ const params: z.ZodType<StatePatchParams> = z
|
|
|
35
40
|
baseRevision: DocumentRevision.exactOptional(),
|
|
36
41
|
mutationId: MutationId.schema,
|
|
37
42
|
as: z.enum(["agent", "host"]).exactOptional(),
|
|
43
|
+
causation: z.object({ runId: z.string().min(1) }).exactOptional(),
|
|
38
44
|
})
|
|
39
45
|
.register(wireRegistry, { id: "StatePatchParams" });
|
|
40
46
|
|
package/src/methods/view/url.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
-
import { CapabilityScope
|
|
3
|
+
import { CapabilityScope } from "../../capability.ts";
|
|
4
|
+
import { Duration } from "../../duration.ts";
|
|
4
5
|
import { TokenId, VersionId } from "../../ids.ts";
|
|
5
6
|
import { Viewer, ViewerSpec } from "../../interaction.ts";
|
|
6
7
|
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
package/src/policy.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The submission policy (D10, D39, D63): a module of its own, so the shell bridge's view context
|
|
3
|
+
* reads it without the whole manifest schema in its bundle.
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { wireRegistry } from "./wire-registry.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The submission policy an artifact requests (D10, D39, D63). The host decides the policy in force;
|
|
10
|
+
* the manifest only asks for one.
|
|
11
|
+
*/
|
|
12
|
+
export type SubmissionPolicy =
|
|
13
|
+
| { readonly policy: "once"; readonly scope?: "per-artifact" | "per-viewer" }
|
|
14
|
+
| { readonly policy: "epochs" }
|
|
15
|
+
| { readonly policy: "none" };
|
|
16
|
+
|
|
17
|
+
/** The Zod schema of the `SubmissionPolicy` type. */
|
|
18
|
+
export const SubmissionPolicy: z.ZodType<SubmissionPolicy> = z
|
|
19
|
+
.discriminatedUnion("policy", [
|
|
20
|
+
z.object({
|
|
21
|
+
policy: z.literal("once"),
|
|
22
|
+
scope: z.enum(["per-artifact", "per-viewer"]).exactOptional(),
|
|
23
|
+
}),
|
|
24
|
+
z.object({ policy: z.literal("epochs") }),
|
|
25
|
+
z.object({ policy: z.literal("none") }),
|
|
26
|
+
])
|
|
27
|
+
.register(wireRegistry, {
|
|
28
|
+
id: "SubmissionPolicy",
|
|
29
|
+
description: "A submission policy: once (per-artifact or per-viewer), epochs, or none.",
|
|
30
|
+
});
|