@h-rig/transport-plugin 0.0.6-alpha.158

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/README.md ADDED
@@ -0,0 +1 @@
1
+ # @h-rig/transport-plugin
@@ -0,0 +1,43 @@
1
+ import { Stream } from "effect";
2
+ import type { HeartbeatRequest, ListedRegistryEntry, ProjectionIngestRequest, RegistryDiscoveryFrame, RegistryRunProjection, RegisterRequest, RegistryEntry, RegistrySnapshotFrame, RemoveRequest, WorkerProjectionFrame } from "./schema";
3
+ export type CollabRegistryFilter = {
4
+ readonly cwd?: string;
5
+ readonly selectedRepo?: string;
6
+ readonly githubUserId?: string;
7
+ readonly namespaceKey?: string;
8
+ };
9
+ export type RegistryClientOptions = {
10
+ readonly baseUrl: string;
11
+ readonly namespaceKey: string;
12
+ readonly fetch?: typeof fetch;
13
+ };
14
+ export type RegistryClient = {
15
+ registerRoom(room: RegisterRequest): Promise<RegistryEntry>;
16
+ heartbeatRoom(roomId: string, status: HeartbeatRequest["status"], projection?: RegistryRunProjection): Promise<RegistryEntry>;
17
+ ingestProjection(input: Omit<ProjectionIngestRequest, "namespaceKey" | "projection"> & {
18
+ readonly namespaceKey?: string;
19
+ readonly projection: RegistryRunProjection;
20
+ }): Promise<RegistryEntry>;
21
+ listRoomsByOwner(filter: CollabRegistryFilter): Promise<readonly ListedRegistryEntry[]>;
22
+ removeRoom(roomId: string): Promise<boolean>;
23
+ };
24
+ export type WorkerProjectionConnection = {
25
+ readonly ready: Promise<void>;
26
+ push(frame: WorkerProjectionFrame | RegistryRunProjection): void;
27
+ close(): void;
28
+ };
29
+ export type WorkerProjectionOptions = {
30
+ readonly baseUrl: string;
31
+ readonly namespaceKey: string;
32
+ readonly runId: string;
33
+ readonly WebSocket?: typeof WebSocket;
34
+ };
35
+ export type DiscoverySubscriptionOptions = {
36
+ readonly baseUrl: string;
37
+ readonly WebSocket?: typeof WebSocket;
38
+ };
39
+ export declare function connectWorkerProjection(input: WorkerProjectionOptions): WorkerProjectionConnection;
40
+ export declare function connectWorkerProjection(namespaceKey: string, runId: string, options: Omit<WorkerProjectionOptions, "namespaceKey" | "runId">): WorkerProjectionConnection;
41
+ export declare function subscribeDiscovery(namespaceKey: string, repo: string | null | undefined, options: DiscoverySubscriptionOptions): Stream.Stream<RegistrySnapshotFrame>;
42
+ export declare function createRegistryClient(options: RegistryClientOptions): RegistryClient;
43
+ export type { HeartbeatRequest, ListedRegistryEntry, ProjectionIngestRequest, RegisterRequest, RegistryDiscoveryFrame, RegistryEntry, RegistryRunProjection, RegistrySnapshotFrame, RemoveRequest, WorkerProjectionFrame };
@@ -0,0 +1,317 @@
1
+ import { Schema } from "@rig/contracts";
2
+ import type { RunJournalProjection, RunRecord, UnifiedInboxRequest } from "@rig/contracts";
3
+ export type { RunRecord, UnifiedInboxRequest };
4
+ export declare const RegistryOwner: Schema.Struct<{
5
+ readonly githubUserId: Schema.String;
6
+ readonly login: Schema.String;
7
+ readonly namespaceKey: Schema.String;
8
+ }>;
9
+ export type RegistryOwner = typeof RegistryOwner.Type;
10
+ export declare const REGISTRY_STATUS_VALUES: readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"];
11
+ export declare const RegistryStatus: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
12
+ export type RegistryStatus = typeof RegistryStatus.Type;
13
+ export declare function isRegistryStatus(value: unknown): value is RegistryStatus;
14
+ export declare function coerceRegistryStatus(value: unknown, fallback: RegistryStatus): RegistryStatus;
15
+ /**
16
+ * The relay is a transport/cache, not the source of truth. Projection payloads
17
+ * are the journal-derived wire subset of @rig/contracts RunRecord. This package
18
+ * deliberately does not re-declare the nested runtime schema: it decodes only
19
+ * owner-scoped envelope fields and carries `projection` verbatim.
20
+ */
21
+ export type RegistryRunProjection = Pick<RunRecord, "runId" | "taskId" | "title" | "status" | "source" | "startedAt" | "updatedAt" | "completedAt" | "joinLink" | "webLink" | "relayUrl" | "sessionPath" | "prUrl" | "worktreePath" | "pendingApprovals" | "pendingInputs" | "steeringCount" | "stallCount" | "errorSummary" | "timeline" | "collabCwd"> & {
22
+ readonly cwd?: string | null;
23
+ readonly dispatchHandle?: string | null;
24
+ readonly projection?: RunJournalProjection | null;
25
+ };
26
+ export declare const RegistryEntry: Schema.Struct<{
27
+ readonly roomId: Schema.String;
28
+ readonly owner: Schema.Struct<{
29
+ readonly githubUserId: Schema.String;
30
+ readonly login: Schema.String;
31
+ readonly namespaceKey: Schema.String;
32
+ }>;
33
+ readonly repo: Schema.String;
34
+ readonly title: Schema.String;
35
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
36
+ readonly joinLink: Schema.String;
37
+ readonly webLink: Schema.String;
38
+ readonly relayUrl: Schema.String;
39
+ readonly startedAt: Schema.String;
40
+ readonly cwd: Schema.optional<Schema.String>;
41
+ readonly sessionPath: Schema.optional<Schema.String>;
42
+ readonly heartbeatAt: Schema.String;
43
+ readonly pid: Schema.optional<Schema.Number>;
44
+ readonly projection: Schema.optional<Schema.Unknown>;
45
+ }>;
46
+ export type RegistryEntry = typeof RegistryEntry.Type;
47
+ export declare const RegisterRequest: Schema.Struct<{
48
+ readonly roomId: Schema.String;
49
+ readonly owner: Schema.Struct<{
50
+ readonly githubUserId: Schema.String;
51
+ readonly login: Schema.String;
52
+ readonly namespaceKey: Schema.String;
53
+ }>;
54
+ readonly repo: Schema.String;
55
+ readonly title: Schema.String;
56
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
57
+ readonly joinLink: Schema.String;
58
+ readonly webLink: Schema.String;
59
+ readonly relayUrl: Schema.String;
60
+ readonly startedAt: Schema.String;
61
+ readonly cwd: Schema.optional<Schema.String>;
62
+ readonly sessionPath: Schema.optional<Schema.String>;
63
+ readonly pid: Schema.optional<Schema.Number>;
64
+ readonly projection: Schema.optional<Schema.Unknown>;
65
+ }>;
66
+ export type RegisterRequest = typeof RegisterRequest.Type;
67
+ export declare const HeartbeatRequest: Schema.Struct<{
68
+ readonly roomId: Schema.String;
69
+ readonly namespaceKey: Schema.String;
70
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
71
+ readonly projection: Schema.optional<Schema.Unknown>;
72
+ }>;
73
+ export type HeartbeatRequest = typeof HeartbeatRequest.Type;
74
+ /**
75
+ * HTTP projection ingest:
76
+ * POST /registry/projection
77
+ * { namespaceKey, roomId?, owner?, repo?, projection: RegistryRunProjection }
78
+ *
79
+ * `namespaceKey` is the owner scope. There is no shared secret. If the matching
80
+ * room already exists, the relay updates that entry. If it is missing, HTTP
81
+ * ingest may create it only when owner+repo are supplied; worker WS ingest is
82
+ * update-only.
83
+ */
84
+ export declare const ProjectionIngestRequest: Schema.Struct<{
85
+ readonly namespaceKey: Schema.String;
86
+ readonly roomId: Schema.optional<Schema.String>;
87
+ readonly owner: Schema.optional<Schema.Struct<{
88
+ readonly githubUserId: Schema.String;
89
+ readonly login: Schema.String;
90
+ readonly namespaceKey: Schema.String;
91
+ }>>;
92
+ readonly repo: Schema.optional<Schema.String>;
93
+ readonly projection: Schema.Unknown;
94
+ }>;
95
+ export type ProjectionIngestRequest = typeof ProjectionIngestRequest.Type;
96
+ export declare const RemoveRequest: Schema.Struct<{
97
+ readonly namespaceKey: Schema.String;
98
+ readonly roomId: Schema.String;
99
+ }>;
100
+ export type RemoveRequest = typeof RemoveRequest.Type;
101
+ export declare const ListedRegistryEntry: Schema.Struct<{
102
+ readonly roomId: Schema.String;
103
+ readonly owner: Schema.Struct<{
104
+ readonly githubUserId: Schema.String;
105
+ readonly login: Schema.String;
106
+ readonly namespaceKey: Schema.String;
107
+ }>;
108
+ readonly repo: Schema.String;
109
+ readonly title: Schema.String;
110
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
111
+ readonly joinLink: Schema.String;
112
+ readonly webLink: Schema.String;
113
+ readonly relayUrl: Schema.String;
114
+ readonly startedAt: Schema.String;
115
+ readonly heartbeatAt: Schema.String;
116
+ readonly cwd: Schema.optional<Schema.String>;
117
+ readonly sessionPath: Schema.optional<Schema.String>;
118
+ readonly pid: Schema.optional<Schema.Number>;
119
+ readonly projection: Schema.optional<Schema.Unknown>;
120
+ readonly stale: Schema.Boolean;
121
+ }>;
122
+ export type ListedRegistryEntry = typeof ListedRegistryEntry.Type;
123
+ export declare const ListResponse: Schema.Struct<{
124
+ readonly entries: Schema.$Array<Schema.Struct<{
125
+ readonly roomId: Schema.String;
126
+ readonly owner: Schema.Struct<{
127
+ readonly githubUserId: Schema.String;
128
+ readonly login: Schema.String;
129
+ readonly namespaceKey: Schema.String;
130
+ }>;
131
+ readonly repo: Schema.String;
132
+ readonly title: Schema.String;
133
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
134
+ readonly joinLink: Schema.String;
135
+ readonly webLink: Schema.String;
136
+ readonly relayUrl: Schema.String;
137
+ readonly startedAt: Schema.String;
138
+ readonly heartbeatAt: Schema.String;
139
+ readonly cwd: Schema.optional<Schema.String>;
140
+ readonly sessionPath: Schema.optional<Schema.String>;
141
+ readonly pid: Schema.optional<Schema.Number>;
142
+ readonly projection: Schema.optional<Schema.Unknown>;
143
+ readonly stale: Schema.Boolean;
144
+ }>>;
145
+ }>;
146
+ export type ListResponse = {
147
+ readonly entries: readonly ListedRegistryEntry[];
148
+ };
149
+ export declare const RegisterResponse: Schema.Struct<{
150
+ readonly entry: Schema.Struct<{
151
+ readonly roomId: Schema.String;
152
+ readonly owner: Schema.Struct<{
153
+ readonly githubUserId: Schema.String;
154
+ readonly login: Schema.String;
155
+ readonly namespaceKey: Schema.String;
156
+ }>;
157
+ readonly repo: Schema.String;
158
+ readonly title: Schema.String;
159
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
160
+ readonly joinLink: Schema.String;
161
+ readonly webLink: Schema.String;
162
+ readonly relayUrl: Schema.String;
163
+ readonly startedAt: Schema.String;
164
+ readonly cwd: Schema.optional<Schema.String>;
165
+ readonly sessionPath: Schema.optional<Schema.String>;
166
+ readonly heartbeatAt: Schema.String;
167
+ readonly pid: Schema.optional<Schema.Number>;
168
+ readonly projection: Schema.optional<Schema.Unknown>;
169
+ }>;
170
+ }>;
171
+ export type RegisterResponse = {
172
+ readonly entry: RegistryEntry;
173
+ };
174
+ export declare const HeartbeatResponse: Schema.Struct<{
175
+ readonly entry: Schema.Struct<{
176
+ readonly roomId: Schema.String;
177
+ readonly owner: Schema.Struct<{
178
+ readonly githubUserId: Schema.String;
179
+ readonly login: Schema.String;
180
+ readonly namespaceKey: Schema.String;
181
+ }>;
182
+ readonly repo: Schema.String;
183
+ readonly title: Schema.String;
184
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
185
+ readonly joinLink: Schema.String;
186
+ readonly webLink: Schema.String;
187
+ readonly relayUrl: Schema.String;
188
+ readonly startedAt: Schema.String;
189
+ readonly cwd: Schema.optional<Schema.String>;
190
+ readonly sessionPath: Schema.optional<Schema.String>;
191
+ readonly heartbeatAt: Schema.String;
192
+ readonly pid: Schema.optional<Schema.Number>;
193
+ readonly projection: Schema.optional<Schema.Unknown>;
194
+ }>;
195
+ }>;
196
+ export type HeartbeatResponse = {
197
+ readonly entry: RegistryEntry;
198
+ };
199
+ export declare const ProjectionIngestResponse: Schema.Struct<{
200
+ readonly entry: Schema.Struct<{
201
+ readonly roomId: Schema.String;
202
+ readonly owner: Schema.Struct<{
203
+ readonly githubUserId: Schema.String;
204
+ readonly login: Schema.String;
205
+ readonly namespaceKey: Schema.String;
206
+ }>;
207
+ readonly repo: Schema.String;
208
+ readonly title: Schema.String;
209
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
210
+ readonly joinLink: Schema.String;
211
+ readonly webLink: Schema.String;
212
+ readonly relayUrl: Schema.String;
213
+ readonly startedAt: Schema.String;
214
+ readonly cwd: Schema.optional<Schema.String>;
215
+ readonly sessionPath: Schema.optional<Schema.String>;
216
+ readonly heartbeatAt: Schema.String;
217
+ readonly pid: Schema.optional<Schema.Number>;
218
+ readonly projection: Schema.optional<Schema.Unknown>;
219
+ }>;
220
+ }>;
221
+ export type ProjectionIngestResponse = {
222
+ readonly entry: RegistryEntry;
223
+ };
224
+ export declare const RemoveResponse: Schema.Struct<{
225
+ readonly removed: Schema.Boolean;
226
+ }>;
227
+ export type RemoveResponse = typeof RemoveResponse.Type;
228
+ /**
229
+ * Discovery WebSocket endpoint:
230
+ * GET /registry/ws?namespaceKey=<owner>&repo=<optional>
231
+ *
232
+ * Relay -> client. The first frame is a full snapshot. Later mutations are
233
+ * entry-scoped deltas; subscribeDiscovery folds them back into snapshot frames
234
+ * for existing callers that consume relay WS snapshots.
235
+ */
236
+ export declare const RegistrySnapshotFrame: Schema.Struct<{
237
+ readonly type: Schema.Literal<"registry.snapshot">;
238
+ readonly namespaceKey: Schema.String;
239
+ readonly sentAt: Schema.String;
240
+ readonly entries: Schema.$Array<Schema.Struct<{
241
+ readonly roomId: Schema.String;
242
+ readonly owner: Schema.Struct<{
243
+ readonly githubUserId: Schema.String;
244
+ readonly login: Schema.String;
245
+ readonly namespaceKey: Schema.String;
246
+ }>;
247
+ readonly repo: Schema.String;
248
+ readonly title: Schema.String;
249
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
250
+ readonly joinLink: Schema.String;
251
+ readonly webLink: Schema.String;
252
+ readonly relayUrl: Schema.String;
253
+ readonly startedAt: Schema.String;
254
+ readonly heartbeatAt: Schema.String;
255
+ readonly cwd: Schema.optional<Schema.String>;
256
+ readonly sessionPath: Schema.optional<Schema.String>;
257
+ readonly pid: Schema.optional<Schema.Number>;
258
+ readonly projection: Schema.optional<Schema.Unknown>;
259
+ readonly stale: Schema.Boolean;
260
+ }>>;
261
+ }>;
262
+ export type RegistrySnapshotFrame = {
263
+ readonly type: "registry.snapshot";
264
+ readonly namespaceKey: string;
265
+ readonly sentAt: string;
266
+ readonly entries: readonly ListedRegistryEntry[];
267
+ };
268
+ export declare const RegistryDeltaFrame: Schema.Struct<{
269
+ readonly type: Schema.Literal<"registry.delta">;
270
+ readonly namespaceKey: Schema.String;
271
+ readonly sentAt: Schema.String;
272
+ readonly action: Schema.Literals<readonly ["upsert", "remove"]>;
273
+ readonly roomId: Schema.String;
274
+ readonly entry: Schema.optional<Schema.Struct<{
275
+ readonly roomId: Schema.String;
276
+ readonly owner: Schema.Struct<{
277
+ readonly githubUserId: Schema.String;
278
+ readonly login: Schema.String;
279
+ readonly namespaceKey: Schema.String;
280
+ }>;
281
+ readonly repo: Schema.String;
282
+ readonly title: Schema.String;
283
+ readonly status: Schema.Literals<readonly [...("stopped" | "failed" | "queued" | "running" | "completed" | "created" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention")[], "starting", "waiting-input"]>;
284
+ readonly joinLink: Schema.String;
285
+ readonly webLink: Schema.String;
286
+ readonly relayUrl: Schema.String;
287
+ readonly startedAt: Schema.String;
288
+ readonly heartbeatAt: Schema.String;
289
+ readonly cwd: Schema.optional<Schema.String>;
290
+ readonly sessionPath: Schema.optional<Schema.String>;
291
+ readonly pid: Schema.optional<Schema.Number>;
292
+ readonly projection: Schema.optional<Schema.Unknown>;
293
+ readonly stale: Schema.Boolean;
294
+ }>>;
295
+ }>;
296
+ export type RegistryDeltaFrame = {
297
+ readonly type: "registry.delta";
298
+ readonly namespaceKey: string;
299
+ readonly sentAt: string;
300
+ readonly action: "upsert" | "remove";
301
+ readonly roomId: string;
302
+ readonly entry?: ListedRegistryEntry;
303
+ };
304
+ export type RegistryDiscoveryFrame = RegistrySnapshotFrame | RegistryDeltaFrame;
305
+ /**
306
+ * Worker projection WebSocket endpoint:
307
+ * GET /registry/worker?namespaceKey=<owner>&runId=<sessionId>
308
+ *
309
+ * Worker -> relay frames are projection updates. Per L7/L8, run state and
310
+ * control routing both belong to the unified relay surface; opaque collab-room
311
+ * control remains separate from discovery snapshots.
312
+ */
313
+ export declare const WorkerProjectionFrame: Schema.Struct<{
314
+ readonly type: Schema.Literal<"projection">;
315
+ readonly projection: Schema.Unknown;
316
+ }>;
317
+ export type WorkerProjectionFrame = typeof WorkerProjectionFrame.Type;
@@ -0,0 +1,33 @@
1
+ import { Stream } from "effect";
2
+ import { type ListedRegistryEntry, type RegistrySnapshotFrame } from "./relay-registry";
3
+ import type { RunDiscoveryFilter as CollabRegistryFilter, LiveRunCollabProjection as LiveCollabProjection } from "@rig/contracts";
4
+ export declare function registryBaseUrl(projectRoot?: string, env?: NodeJS.ProcessEnv): string;
5
+ export type RegistryBackedCollabProjection = LiveCollabProjection & {
6
+ readonly registryStatus?: ListedRegistryEntry["status"];
7
+ readonly registryProjection?: unknown;
8
+ };
9
+ export declare function collabFromRegistryEntry(entry: ListedRegistryEntry): RegistryBackedCollabProjection;
10
+ export declare function listActiveRunCollab(projectRoot: string, filter: CollabRegistryFilter): Promise<readonly LiveCollabProjection[]>;
11
+ export declare function defaultListActiveCollabSessions(projectRoot: string, filter: CollabRegistryFilter): Promise<readonly LiveCollabProjection[]>;
12
+ export declare function matchesRun(collab: LiveCollabProjection, runId: string, taskId?: string | null): boolean;
13
+ /** Build the discovery stream from relay registry snapshots only. */
14
+ export declare function runDiscoveryStream(projectRoot: string): Stream.Stream<void>;
15
+ export declare function registrySnapshotStream(projectRoot: string, filter?: CollabRegistryFilter): Stream.Stream<RegistrySnapshotFrame>;
16
+ export type RigExtensionAttachResult = {
17
+ readonly sessionPath: string | null;
18
+ readonly joinLink: string | null;
19
+ readonly collabSessionId: string | null;
20
+ };
21
+ export type AttachViaRelayInput = {
22
+ readonly runId: string;
23
+ readonly taskId?: string | null;
24
+ readonly identityFilter: CollabRegistryFilter;
25
+ readonly timeoutMs?: number;
26
+ readonly projectRoot?: string;
27
+ };
28
+ type AttachViaRelayDeps = {
29
+ readonly listActiveCollabSessions?: (filter: CollabRegistryFilter) => Promise<readonly LiveCollabProjection[]>;
30
+ readonly discoveryStream?: (projectRoot: string) => Stream.Stream<void>;
31
+ };
32
+ export declare function attachViaRelay(input: AttachViaRelayInput, deps?: AttachViaRelayDeps): Promise<RigExtensionAttachResult | null>;
33
+ export {};