@spencerboucher/switchyard-client 0.0.0-stage → 0.16.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/LICENSE +21 -0
- package/README.md +24 -2
- package/dist/index.js +4007 -0
- package/dist/types/api.d.ts +28 -0
- package/dist/types/client.d.ts +56 -0
- package/dist/types/connection.d.ts +66 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/protocol/adapter-preview.d.ts +455 -0
- package/dist/types/protocol/adapters.d.ts +113 -0
- package/dist/types/protocol/agent-wire.d.ts +269 -0
- package/dist/types/protocol/api.d.ts +1501 -0
- package/dist/types/protocol/backoff.d.ts +5 -0
- package/dist/types/protocol/client-wire.d.ts +1806 -0
- package/dist/types/protocol/contributions.d.ts +62 -0
- package/dist/types/protocol/entities.d.ts +1389 -0
- package/dist/types/protocol/errors.d.ts +115 -0
- package/dist/types/protocol/events.d.ts +1136 -0
- package/dist/types/protocol/github.d.ts +510 -0
- package/dist/types/protocol/host-wire.d.ts +1517 -0
- package/dist/types/protocol/ids.d.ts +7 -0
- package/dist/types/protocol/index.d.ts +29 -0
- package/dist/types/protocol/policies.d.ts +576 -0
- package/dist/types/protocol/terminal-wire.d.ts +45 -0
- package/dist/types/protocol/titles.d.ts +9 -0
- package/dist/types/protocol/trackers.d.ts +244 -0
- package/dist/types/protocol/ui.d.ts +164 -0
- package/dist/types/protocol/views.d.ts +14 -0
- package/dist/types/protocol/web-bridge.d.ts +30 -0
- package/dist/types/store.d.ts +59 -0
- package/dist/types/wait.d.ts +20 -0
- package/package.json +32 -4
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Host feature: the host answers `tracker.*` commands. */
|
|
3
|
+
export declare const TRACKERS_FEATURE = "trackers.v1";
|
|
4
|
+
export declare const GitHubLogin: z.ZodString;
|
|
5
|
+
export declare const TrackerStatusOption: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type TrackerStatusOption = z.infer<typeof TrackerStatusOption>;
|
|
10
|
+
export declare const TrackerBoard: z.ZodObject<{
|
|
11
|
+
projectNumber: z.ZodNumber;
|
|
12
|
+
statusField: z.ZodDefault<z.ZodString>;
|
|
13
|
+
onStart: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
onReview: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type TrackerBoard = z.infer<typeof TrackerBoard>;
|
|
17
|
+
export declare const Tracker: z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
provider: z.ZodLiteral<"github">;
|
|
21
|
+
hostId: z.ZodString;
|
|
22
|
+
owner: z.ZodString;
|
|
23
|
+
repositories: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
24
|
+
extraRepositories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
board: z.ZodNullable<z.ZodObject<{
|
|
26
|
+
projectNumber: z.ZodNumber;
|
|
27
|
+
statusField: z.ZodDefault<z.ZodString>;
|
|
28
|
+
onStart: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
onReview: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
writeBack: z.ZodBoolean;
|
|
32
|
+
moveShared: z.ZodBoolean;
|
|
33
|
+
enabled: z.ZodBoolean;
|
|
34
|
+
login: z.ZodNullable<z.ZodString>;
|
|
35
|
+
lastSyncedAt: z.ZodNullable<z.ZodString>;
|
|
36
|
+
lastError: z.ZodNullable<z.ZodString>;
|
|
37
|
+
createdAt: z.ZodString;
|
|
38
|
+
updatedAt: z.ZodString;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type Tracker = z.infer<typeof Tracker>;
|
|
41
|
+
export declare const TrackerInput: z.ZodObject<{
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
hostId: z.ZodString;
|
|
44
|
+
owner: z.ZodString;
|
|
45
|
+
repositories: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
46
|
+
extraRepositories: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
47
|
+
board: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
48
|
+
projectNumber: z.ZodNumber;
|
|
49
|
+
statusField: z.ZodDefault<z.ZodString>;
|
|
50
|
+
onStart: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
onReview: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
52
|
+
}, z.core.$strip>>>;
|
|
53
|
+
writeBack: z.ZodDefault<z.ZodBoolean>;
|
|
54
|
+
moveShared: z.ZodDefault<z.ZodBoolean>;
|
|
55
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export type TrackerInput = z.input<typeof TrackerInput>;
|
|
58
|
+
export declare const TrackerPatch: z.ZodObject<{
|
|
59
|
+
name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
hostId: z.ZodOptional<z.ZodString>;
|
|
61
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
62
|
+
repositories: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
63
|
+
extraRepositories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
board: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
65
|
+
projectNumber: z.ZodNumber;
|
|
66
|
+
statusField: z.ZodDefault<z.ZodString>;
|
|
67
|
+
onStart: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
68
|
+
onReview: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
69
|
+
}, z.core.$strip>>>;
|
|
70
|
+
writeBack: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
moveShared: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export type TrackerPatch = z.input<typeof TrackerPatch>;
|
|
75
|
+
export declare const TrackerItemBoard: z.ZodObject<{
|
|
76
|
+
projectId: z.ZodString;
|
|
77
|
+
projectItemId: z.ZodString;
|
|
78
|
+
fieldId: z.ZodString;
|
|
79
|
+
status: z.ZodNullable<z.ZodString>;
|
|
80
|
+
statusOptionId: z.ZodNullable<z.ZodString>;
|
|
81
|
+
options: z.ZodArray<z.ZodObject<{
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
name: z.ZodString;
|
|
84
|
+
}, z.core.$strip>>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
export type TrackerItemBoard = z.infer<typeof TrackerItemBoard>;
|
|
87
|
+
export declare const TrackerPullRequest: z.ZodObject<{
|
|
88
|
+
number: z.ZodNumber;
|
|
89
|
+
state: z.ZodEnum<{
|
|
90
|
+
CLOSED: "CLOSED";
|
|
91
|
+
MERGED: "MERGED";
|
|
92
|
+
OPEN: "OPEN";
|
|
93
|
+
}>;
|
|
94
|
+
url: z.ZodString;
|
|
95
|
+
headRefName: z.ZodString;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
export type TrackerPullRequest = z.infer<typeof TrackerPullRequest>;
|
|
98
|
+
export declare const TrackerItem: z.ZodObject<{
|
|
99
|
+
itemId: z.ZodString;
|
|
100
|
+
repository: z.ZodString;
|
|
101
|
+
number: z.ZodNumber;
|
|
102
|
+
title: z.ZodString;
|
|
103
|
+
url: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
104
|
+
assignees: z.ZodArray<z.ZodString>;
|
|
105
|
+
branches: z.ZodArray<z.ZodString>;
|
|
106
|
+
pullRequest: z.ZodNullable<z.ZodObject<{
|
|
107
|
+
number: z.ZodNumber;
|
|
108
|
+
state: z.ZodEnum<{
|
|
109
|
+
CLOSED: "CLOSED";
|
|
110
|
+
MERGED: "MERGED";
|
|
111
|
+
OPEN: "OPEN";
|
|
112
|
+
}>;
|
|
113
|
+
url: z.ZodString;
|
|
114
|
+
headRefName: z.ZodString;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
board: z.ZodNullable<z.ZodObject<{
|
|
117
|
+
projectId: z.ZodString;
|
|
118
|
+
projectItemId: z.ZodString;
|
|
119
|
+
fieldId: z.ZodString;
|
|
120
|
+
status: z.ZodNullable<z.ZodString>;
|
|
121
|
+
statusOptionId: z.ZodNullable<z.ZodString>;
|
|
122
|
+
options: z.ZodArray<z.ZodObject<{
|
|
123
|
+
id: z.ZodString;
|
|
124
|
+
name: z.ZodString;
|
|
125
|
+
}, z.core.$strip>>;
|
|
126
|
+
}, z.core.$strip>>;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
export type TrackerItem = z.infer<typeof TrackerItem>;
|
|
129
|
+
export declare const TrackerSyncResult: z.ZodObject<{
|
|
130
|
+
login: z.ZodString;
|
|
131
|
+
items: z.ZodArray<z.ZodObject<{
|
|
132
|
+
itemId: z.ZodString;
|
|
133
|
+
repository: z.ZodString;
|
|
134
|
+
number: z.ZodNumber;
|
|
135
|
+
title: z.ZodString;
|
|
136
|
+
url: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
137
|
+
assignees: z.ZodArray<z.ZodString>;
|
|
138
|
+
branches: z.ZodArray<z.ZodString>;
|
|
139
|
+
pullRequest: z.ZodNullable<z.ZodObject<{
|
|
140
|
+
number: z.ZodNumber;
|
|
141
|
+
state: z.ZodEnum<{
|
|
142
|
+
CLOSED: "CLOSED";
|
|
143
|
+
MERGED: "MERGED";
|
|
144
|
+
OPEN: "OPEN";
|
|
145
|
+
}>;
|
|
146
|
+
url: z.ZodString;
|
|
147
|
+
headRefName: z.ZodString;
|
|
148
|
+
}, z.core.$strip>>;
|
|
149
|
+
board: z.ZodNullable<z.ZodObject<{
|
|
150
|
+
projectId: z.ZodString;
|
|
151
|
+
projectItemId: z.ZodString;
|
|
152
|
+
fieldId: z.ZodString;
|
|
153
|
+
status: z.ZodNullable<z.ZodString>;
|
|
154
|
+
statusOptionId: z.ZodNullable<z.ZodString>;
|
|
155
|
+
options: z.ZodArray<z.ZodObject<{
|
|
156
|
+
id: z.ZodString;
|
|
157
|
+
name: z.ZodString;
|
|
158
|
+
}, z.core.$strip>>;
|
|
159
|
+
}, z.core.$strip>>;
|
|
160
|
+
}, z.core.$strip>>;
|
|
161
|
+
truncated: z.ZodBoolean;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
export type TrackerSyncResult = z.infer<typeof TrackerSyncResult>;
|
|
164
|
+
/** A task's link to its tracker item (server-owned). */
|
|
165
|
+
export declare const TaskTracker: z.ZodObject<{
|
|
166
|
+
trackerId: z.ZodString;
|
|
167
|
+
itemId: z.ZodString;
|
|
168
|
+
repository: z.ZodString;
|
|
169
|
+
number: z.ZodNumber;
|
|
170
|
+
assignees: z.ZodArray<z.ZodString>;
|
|
171
|
+
branch: z.ZodNullable<z.ZodString>;
|
|
172
|
+
workspaceId: z.ZodNullable<z.ZodString>;
|
|
173
|
+
pullRequest: z.ZodNullable<z.ZodObject<{
|
|
174
|
+
number: z.ZodNumber;
|
|
175
|
+
state: z.ZodEnum<{
|
|
176
|
+
CLOSED: "CLOSED";
|
|
177
|
+
MERGED: "MERGED";
|
|
178
|
+
OPEN: "OPEN";
|
|
179
|
+
}>;
|
|
180
|
+
url: z.ZodString;
|
|
181
|
+
headRefName: z.ZodString;
|
|
182
|
+
}, z.core.$strip>>;
|
|
183
|
+
board: z.ZodNullable<z.ZodObject<{
|
|
184
|
+
projectId: z.ZodString;
|
|
185
|
+
projectItemId: z.ZodString;
|
|
186
|
+
fieldId: z.ZodString;
|
|
187
|
+
status: z.ZodNullable<z.ZodString>;
|
|
188
|
+
statusOptionId: z.ZodNullable<z.ZodString>;
|
|
189
|
+
options: z.ZodArray<z.ZodObject<{
|
|
190
|
+
id: z.ZodString;
|
|
191
|
+
name: z.ZodString;
|
|
192
|
+
}, z.core.$strip>>;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
}, z.core.$strip>;
|
|
195
|
+
export type TaskTracker = z.infer<typeof TaskTracker>;
|
|
196
|
+
export declare const TrackerSetStatusResult: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
197
|
+
status: z.ZodLiteral<"moved">;
|
|
198
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
199
|
+
status: z.ZodLiteral<"skipped">;
|
|
200
|
+
reason: z.ZodEnum<{
|
|
201
|
+
not_assigned: "not_assigned";
|
|
202
|
+
shared: "shared";
|
|
203
|
+
stale: "stale";
|
|
204
|
+
}>;
|
|
205
|
+
}, z.core.$strip>], "status">;
|
|
206
|
+
export type TrackerSetStatusResult = z.infer<typeof TrackerSetStatusResult>;
|
|
207
|
+
/** POST /api/tasks/:id/tracker/status */
|
|
208
|
+
export declare const TrackerStatusRequest: z.ZodObject<{
|
|
209
|
+
status: z.ZodString;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
/** Host command bodies (without `type`). */
|
|
212
|
+
export declare const TrackerHostSyncRequest: z.ZodObject<{
|
|
213
|
+
owner: z.ZodString;
|
|
214
|
+
repositories: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
215
|
+
board: z.ZodNullable<z.ZodObject<{
|
|
216
|
+
projectNumber: z.ZodNumber;
|
|
217
|
+
statusField: z.ZodString;
|
|
218
|
+
}, z.core.$strip>>;
|
|
219
|
+
}, z.core.$strip>;
|
|
220
|
+
export type TrackerHostSyncRequest = z.infer<typeof TrackerHostSyncRequest>;
|
|
221
|
+
export declare const TrackerHostPrepareBranchRequest: z.ZodObject<{
|
|
222
|
+
checkoutPath: z.ZodString;
|
|
223
|
+
branch: z.ZodString;
|
|
224
|
+
}, z.core.$strip>;
|
|
225
|
+
export declare const TrackerHostStartIssueRequest: z.ZodObject<{
|
|
226
|
+
checkoutPath: z.ZodString;
|
|
227
|
+
repository: z.ZodString;
|
|
228
|
+
number: z.ZodNumber;
|
|
229
|
+
branch: z.ZodString;
|
|
230
|
+
base: z.ZodString;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
export type TrackerHostStartIssueRequest = z.infer<typeof TrackerHostStartIssueRequest>;
|
|
233
|
+
export declare const TrackerHostSetStatusRequest: z.ZodObject<{
|
|
234
|
+
projectId: z.ZodString;
|
|
235
|
+
projectItemId: z.ZodString;
|
|
236
|
+
fieldId: z.ZodString;
|
|
237
|
+
statusField: z.ZodString;
|
|
238
|
+
optionId: z.ZodString;
|
|
239
|
+
expectedOptionId: z.ZodNullable<z.ZodString>;
|
|
240
|
+
login: z.ZodString;
|
|
241
|
+
allowShared: z.ZodBoolean;
|
|
242
|
+
}, z.core.$strip>;
|
|
243
|
+
export type TrackerHostSetStatusRequest = z.infer<typeof TrackerHostSetStatusRequest>;
|
|
244
|
+
//# sourceMappingURL=trackers.d.ts.map
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Portable UI components rendered by every client (web, mobile, terminal). */
|
|
3
|
+
export type Tone = "default" | "muted" | "success" | "warning" | "danger";
|
|
4
|
+
export type ActionTone = "default" | "primary" | "danger";
|
|
5
|
+
export interface ShowIf {
|
|
6
|
+
field: string;
|
|
7
|
+
values: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface FieldOption {
|
|
10
|
+
value: string;
|
|
11
|
+
label: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
preview?: string;
|
|
14
|
+
}
|
|
15
|
+
export type Field = {
|
|
16
|
+
kind: "select";
|
|
17
|
+
name: string;
|
|
18
|
+
label: string;
|
|
19
|
+
options: FieldOption[];
|
|
20
|
+
allowOther?: {
|
|
21
|
+
label: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
};
|
|
24
|
+
showIf?: ShowIf;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "multiselect";
|
|
27
|
+
name: string;
|
|
28
|
+
label: string;
|
|
29
|
+
options: FieldOption[];
|
|
30
|
+
allowOther?: {
|
|
31
|
+
label: string;
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
};
|
|
34
|
+
min?: number;
|
|
35
|
+
max?: number;
|
|
36
|
+
showIf?: ShowIf;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "text";
|
|
39
|
+
name: string;
|
|
40
|
+
label: string;
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
multiline?: boolean;
|
|
43
|
+
prefill?: string;
|
|
44
|
+
showIf?: ShowIf;
|
|
45
|
+
};
|
|
46
|
+
export type UIRef = {
|
|
47
|
+
kind: "file";
|
|
48
|
+
path: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: "session";
|
|
51
|
+
sessionId: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: "task";
|
|
54
|
+
taskId: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "native_session";
|
|
57
|
+
hostId: string;
|
|
58
|
+
sessionFile: string;
|
|
59
|
+
};
|
|
60
|
+
export type UINode = {
|
|
61
|
+
t: "text";
|
|
62
|
+
text: string;
|
|
63
|
+
tone?: Tone;
|
|
64
|
+
} | {
|
|
65
|
+
t: "markdown";
|
|
66
|
+
text: string;
|
|
67
|
+
} | {
|
|
68
|
+
t: "code";
|
|
69
|
+
text: string;
|
|
70
|
+
lang?: string;
|
|
71
|
+
} | {
|
|
72
|
+
t: "diff";
|
|
73
|
+
patch: string;
|
|
74
|
+
} | {
|
|
75
|
+
t: "list";
|
|
76
|
+
items: UINode[];
|
|
77
|
+
ordered?: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
t: "table";
|
|
80
|
+
columns: string[];
|
|
81
|
+
rows: string[][];
|
|
82
|
+
} | {
|
|
83
|
+
t: "section";
|
|
84
|
+
title?: string;
|
|
85
|
+
collapsible?: boolean;
|
|
86
|
+
children: UINode[];
|
|
87
|
+
} | {
|
|
88
|
+
t: "tabs";
|
|
89
|
+
tabs: {
|
|
90
|
+
id: string;
|
|
91
|
+
label: string;
|
|
92
|
+
children: UINode[];
|
|
93
|
+
}[];
|
|
94
|
+
} | {
|
|
95
|
+
t: "progress";
|
|
96
|
+
label: string;
|
|
97
|
+
value?: number;
|
|
98
|
+
status?: "running" | "ok" | "error";
|
|
99
|
+
} | {
|
|
100
|
+
t: "ref";
|
|
101
|
+
ref: UIRef;
|
|
102
|
+
label: string;
|
|
103
|
+
} | {
|
|
104
|
+
t: "form";
|
|
105
|
+
formId: string;
|
|
106
|
+
fields: Field[];
|
|
107
|
+
submitLabel: string;
|
|
108
|
+
cancelLabel?: string;
|
|
109
|
+
} | {
|
|
110
|
+
t: "confirm";
|
|
111
|
+
message: string;
|
|
112
|
+
confirmLabel: string;
|
|
113
|
+
cancelLabel: string;
|
|
114
|
+
destructive?: boolean;
|
|
115
|
+
} | {
|
|
116
|
+
t: "actions";
|
|
117
|
+
actions: {
|
|
118
|
+
id: string;
|
|
119
|
+
label: string;
|
|
120
|
+
tone?: ActionTone;
|
|
121
|
+
}[];
|
|
122
|
+
};
|
|
123
|
+
export declare const FieldSchema: z.ZodType<Field>;
|
|
124
|
+
export declare const UINodeSchema: z.ZodType<UINode>;
|
|
125
|
+
export declare const UI_MAX_DEPTH = 12;
|
|
126
|
+
export declare const UI_MAX_NODES = 2000;
|
|
127
|
+
/** Parse and bound a UI tree. Throws SwitchyardError(ui_tree_too_large) past the limits. */
|
|
128
|
+
export declare function validateUINode(input: unknown): UINode;
|
|
129
|
+
/** Whether a field with `showIf` is visible given current form values. */
|
|
130
|
+
export declare function isFieldVisible(field: Field, values: Record<string, FormValue | undefined>): boolean;
|
|
131
|
+
export type FormValue = string | string[] | {
|
|
132
|
+
other: string;
|
|
133
|
+
};
|
|
134
|
+
export declare const FormValueSchema: z.ZodType<FormValue>;
|
|
135
|
+
export declare const InteractionResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
136
|
+
kind: z.ZodLiteral<"form">;
|
|
137
|
+
values: z.ZodRecord<z.ZodString, z.ZodType<FormValue, unknown, z.core.$ZodTypeInternals<FormValue, unknown>>>;
|
|
138
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
139
|
+
kind: z.ZodLiteral<"confirm">;
|
|
140
|
+
confirmed: z.ZodBoolean;
|
|
141
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
142
|
+
kind: z.ZodLiteral<"action">;
|
|
143
|
+
actionId: z.ZodString;
|
|
144
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
145
|
+
kind: z.ZodLiteral<"cancel">;
|
|
146
|
+
}, z.core.$strip>], "kind">;
|
|
147
|
+
export type InteractionResponse = z.infer<typeof InteractionResponseSchema>;
|
|
148
|
+
/** Small builders for adapters. */
|
|
149
|
+
export declare const ui: {
|
|
150
|
+
text: (text: string, tone?: Tone) => UINode;
|
|
151
|
+
markdown: (text: string) => UINode;
|
|
152
|
+
code: (text: string, lang?: string) => UINode;
|
|
153
|
+
diff: (patch: string) => UINode;
|
|
154
|
+
list: (items: UINode[], ordered?: boolean) => UINode;
|
|
155
|
+
table: (columns: string[], rows: string[][]) => UINode;
|
|
156
|
+
section: (title: string | undefined, children: UINode[], collapsible?: boolean) => UINode;
|
|
157
|
+
progress: (label: string, value?: number, status?: "running" | "ok" | "error") => UINode;
|
|
158
|
+
actions: (actions: {
|
|
159
|
+
id: string;
|
|
160
|
+
label: string;
|
|
161
|
+
tone?: ActionTone;
|
|
162
|
+
}[]) => UINode;
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Session, Task, View, ViewClient, Workspace } from "./entities.js";
|
|
2
|
+
/** A client counts as open in a view while its last report is younger than this. */
|
|
3
|
+
export declare const CLIENT_OPEN_MS: number;
|
|
4
|
+
type WorkspaceLookup = Record<string, Pick<Workspace, "projectId">> | Map<string, Pick<Workspace, "projectId">>;
|
|
5
|
+
/** Is a session in a view? Archived sessions never are. */
|
|
6
|
+
export declare function sessionInView(view: View, s: Pick<Session, "id" | "projectId" | "workspaceId" | "hostId" | "archivedAt">, workspaces: WorkspaceLookup): boolean;
|
|
7
|
+
/** Clients that reported recently, sorted by kind then name. */
|
|
8
|
+
export declare function openClients(view: View, now?: number): ViewClient[];
|
|
9
|
+
/** Resolve a view by id, else by case-insensitive name; null if absent or ambiguous. */
|
|
10
|
+
export declare function findView(views: View[], ref: string): View | null;
|
|
11
|
+
/** Is a task in a view? By its project, or because its session is pinned. Host filters do not apply to tasks. */
|
|
12
|
+
export declare function taskInView(view: View, t: Pick<Task, "projectId" | "sessionId">): boolean;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=views.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { UINode } from "./ui.js";
|
|
3
|
+
/**
|
|
4
|
+
* Messages between the web client and a custom adapter renderer running in an isolated
|
|
5
|
+
* `<iframe sandbox="allow-scripts">` (no allow-same-origin, no credentials). The parent posts
|
|
6
|
+
* `render`; the frame posts `action` and `resize`. Parents must validate every frame message
|
|
7
|
+
* with `parseFrameMessage` and forward actions only through the adapter action API.
|
|
8
|
+
*/
|
|
9
|
+
export interface RenderMessage {
|
|
10
|
+
type: "render";
|
|
11
|
+
node: UINode | null;
|
|
12
|
+
state: unknown;
|
|
13
|
+
}
|
|
14
|
+
export type ParentToFrameMessage = RenderMessage;
|
|
15
|
+
export interface FrameActionMessage {
|
|
16
|
+
type: "action";
|
|
17
|
+
actionId: string;
|
|
18
|
+
payload?: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface FrameResizeMessage {
|
|
21
|
+
type: "resize";
|
|
22
|
+
height: number;
|
|
23
|
+
}
|
|
24
|
+
export type FrameToParentMessage = FrameActionMessage | FrameResizeMessage;
|
|
25
|
+
export declare const FRAME_MAX_HEIGHT = 4000;
|
|
26
|
+
export declare const FrameToParentMessageSchema: z.ZodType<FrameToParentMessage>;
|
|
27
|
+
/** Validate a message received from a frame; undefined when it is not a bridge message. */
|
|
28
|
+
export declare function parseFrameMessage(data: unknown): FrameToParentMessage | undefined;
|
|
29
|
+
export declare function renderMessage(node: UINode | null, state: unknown): RenderMessage;
|
|
30
|
+
//# sourceMappingURL=web-bridge.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AttentionItem, Automation, Checkout, Device, EventEnvelope, Host, Interaction, Panel, Profile, Project, Run, Session, SyncState, Task, View, Workspace } from "./protocol/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Normalized client state of coordinator entities and its pure reducers: durable events apply
|
|
4
|
+
* once in `seq` order, a snapshot replaces every entity. Transcripts and stream deltas are not kept.
|
|
5
|
+
*/
|
|
6
|
+
export type ById<T> = Record<string, T>;
|
|
7
|
+
export type ConnectionState = "connecting" | "live" | "reconnecting" | "logged_out";
|
|
8
|
+
export interface ClientState {
|
|
9
|
+
/** Last applied durable event seq (the WS cursor), null before any sync. */
|
|
10
|
+
seq: number | null;
|
|
11
|
+
synced: boolean;
|
|
12
|
+
connection: {
|
|
13
|
+
state: ConnectionState;
|
|
14
|
+
attempts: number;
|
|
15
|
+
reason: string | null;
|
|
16
|
+
};
|
|
17
|
+
hosts: ById<Host>;
|
|
18
|
+
projects: ById<Project>;
|
|
19
|
+
checkouts: ById<Checkout>;
|
|
20
|
+
workspaces: ById<Workspace>;
|
|
21
|
+
profiles: ById<Profile>;
|
|
22
|
+
views: ById<View>;
|
|
23
|
+
sessions: ById<Session>;
|
|
24
|
+
tasks: ById<Task>;
|
|
25
|
+
runs: ById<Run>;
|
|
26
|
+
automations: ById<Automation>;
|
|
27
|
+
/** Open (unresolved) attention items. */
|
|
28
|
+
attention: ById<AttentionItem>;
|
|
29
|
+
/** Interactions of any state, so resolution summaries stay visible. */
|
|
30
|
+
interactions: ById<Interaction>;
|
|
31
|
+
panels: ById<Panel>;
|
|
32
|
+
devices: ById<Device>;
|
|
33
|
+
dispatchPaused: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function emptyState(): ClientState;
|
|
36
|
+
export declare function panelKey(sessionId: string, adapterId: string, slot: string): string;
|
|
37
|
+
/** Replace every entity with a server snapshot. */
|
|
38
|
+
export declare function applySnapshot(state: ClientState, seq: number, snap: SyncState): ClientState;
|
|
39
|
+
/** Insert or replace an interaction unless a newer revision is already known. */
|
|
40
|
+
export declare function upsertInteraction(state: ClientState, i: Interaction): ClientState;
|
|
41
|
+
/** Apply one durable event; events at or below the cursor are ignored. */
|
|
42
|
+
export declare function applyEvent(state: ClientState, event: EventEnvelope): ClientState;
|
|
43
|
+
/** Apply a replay batch in `seq` order and record the server's current seq. */
|
|
44
|
+
export declare function applyReplay(state: ClientState, seq: number, events: EventEnvelope[]): ClientState;
|
|
45
|
+
export declare function setConnection(state: ClientState, connection: Partial<ClientState["connection"]>): ClientState;
|
|
46
|
+
type Listener = () => void;
|
|
47
|
+
/** A tiny observable holder for `ClientState` (usable with `useSyncExternalStore`). */
|
|
48
|
+
export declare class Store {
|
|
49
|
+
private state;
|
|
50
|
+
private listeners;
|
|
51
|
+
private versions;
|
|
52
|
+
private resetVersion;
|
|
53
|
+
revision(kind: "sessions" | "tasks", id: string): number;
|
|
54
|
+
getState: () => ClientState;
|
|
55
|
+
subscribe: (fn: Listener) => (() => void);
|
|
56
|
+
update(fn: (s: ClientState) => ClientState, reset?: boolean): void;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Session, Task } from "./protocol/index.js";
|
|
2
|
+
import type { ClientConnection } from "./connection.js";
|
|
3
|
+
type Entity = Session | Task;
|
|
4
|
+
export interface WaitOptions {
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}
|
|
8
|
+
export type WaitCode = "session_failed" | "session_interrupted" | "session_stopped" | "task_canceled" | "not_found" | "unauthorized" | "timeout" | "aborted" | "closed" | "invalid_request";
|
|
9
|
+
export declare class WaitError extends Error {
|
|
10
|
+
readonly code: WaitCode;
|
|
11
|
+
readonly lastEntity: Entity | null;
|
|
12
|
+
constructor(code: WaitCode, message: string, lastEntity?: Entity | null);
|
|
13
|
+
}
|
|
14
|
+
/** A single entity waiter; global events do not invalidate an in-flight REST read. */
|
|
15
|
+
export declare function waitForEntity<T extends Entity>(connection: ClientConnection, kind: "sessions" | "tasks", id: string, decide: (entity: T) => {
|
|
16
|
+
done?: boolean;
|
|
17
|
+
error?: WaitCode;
|
|
18
|
+
}, options?: WaitOptions): Promise<T>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=wait.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spencerboucher/switchyard-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"description": "Node.js REST and WebSocket SDK for Switchyard",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/justmytwospence/switchyard.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=24"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/types/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"ws": "^8.22.0",
|
|
27
|
+
"zod": "^4.6.7",
|
|
28
|
+
"@types/ws": "^8.18.2",
|
|
29
|
+
"@types/node": "^26.6.5"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|