@fnndsc/menu 0.3.1
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 +59 -0
- package/dist/dag.d.ts +629 -0
- package/dist/dag.js +137 -0
- package/dist/dag.js.map +1 -0
- package/dist/envelope.d.ts +153 -0
- package/dist/envelope.js +44 -0
- package/dist/envelope.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +2402 -0
- package/dist/messages.js +477 -0
- package/dist/messages.js.map +1 -0
- package/dist/pacs.d.ts +256 -0
- package/dist/pacs.js +53 -0
- package/dist/pacs.js.map +1 -0
- package/dist/proc.d.ts +63 -0
- package/dist/proc.js +22 -0
- package/dist/proc.js.map +1 -0
- package/dist/progress.d.ts +38 -0
- package/dist/progress.js +43 -0
- package/dist/progress.js.map +1 -0
- package/dist/validate.d.ts +57 -0
- package/dist/validate.js +93 -0
- package/dist/validate.js.map +1 -0
- package/dist/version.d.ts +25 -0
- package/dist/version.js +28 -0
- package/dist/version.js.map +1 -0
- package/package.json +52 -0
package/dist/pacs.d.ts
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The PACS query vocabulary: search results as typed envelope payloads.
|
|
3
|
+
*
|
|
4
|
+
* A `pacs query` answers with studies containing series; the terminal renders
|
|
5
|
+
* them as text while a graphical surface reads this model — the same
|
|
6
|
+
* one-command-two-projections pattern as the DAG models. Series carry their
|
|
7
|
+
* instance UIDs so a surface can lower a selection straight to
|
|
8
|
+
* `pacs pull SeriesInstanceUID:<uid>`.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
/** One series within a found study. */
|
|
14
|
+
export declare const pacsSeriesSchema: z.ZodObject<{
|
|
15
|
+
seriesUID: z.ZodString;
|
|
16
|
+
description: z.ZodString;
|
|
17
|
+
modality: z.ZodString;
|
|
18
|
+
fileCount: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
/** The series' own VFS path under the query — the pull's argument. */
|
|
20
|
+
vfsPath: z.ZodOptional<z.ZodString>;
|
|
21
|
+
/** True when CUBE already holds this series (a pull would just confirm). */
|
|
22
|
+
pulled: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
/** How many files CUBE holds, when known. */
|
|
24
|
+
pulledFiles: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
seriesUID: string;
|
|
27
|
+
description: string;
|
|
28
|
+
modality: string;
|
|
29
|
+
vfsPath?: string | undefined;
|
|
30
|
+
fileCount?: number | undefined;
|
|
31
|
+
pulled?: boolean | undefined;
|
|
32
|
+
pulledFiles?: number | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
seriesUID: string;
|
|
35
|
+
description: string;
|
|
36
|
+
modality: string;
|
|
37
|
+
vfsPath?: string | undefined;
|
|
38
|
+
fileCount?: number | undefined;
|
|
39
|
+
pulled?: boolean | undefined;
|
|
40
|
+
pulledFiles?: number | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
/** One found study and its series. */
|
|
43
|
+
export declare const pacsStudySchema: z.ZodObject<{
|
|
44
|
+
studyUID: z.ZodOptional<z.ZodString>;
|
|
45
|
+
/** The study's VFS path under the query — a study-level pull's argument. */
|
|
46
|
+
vfsPath: z.ZodOptional<z.ZodString>;
|
|
47
|
+
description: z.ZodString;
|
|
48
|
+
patientName: z.ZodString;
|
|
49
|
+
patientId: z.ZodString;
|
|
50
|
+
date: z.ZodString;
|
|
51
|
+
modalities: z.ZodString;
|
|
52
|
+
accession: z.ZodString;
|
|
53
|
+
series: z.ZodArray<z.ZodObject<{
|
|
54
|
+
seriesUID: z.ZodString;
|
|
55
|
+
description: z.ZodString;
|
|
56
|
+
modality: z.ZodString;
|
|
57
|
+
fileCount: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
/** The series' own VFS path under the query — the pull's argument. */
|
|
59
|
+
vfsPath: z.ZodOptional<z.ZodString>;
|
|
60
|
+
/** True when CUBE already holds this series (a pull would just confirm). */
|
|
61
|
+
pulled: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
/** How many files CUBE holds, when known. */
|
|
63
|
+
pulledFiles: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
seriesUID: string;
|
|
66
|
+
description: string;
|
|
67
|
+
modality: string;
|
|
68
|
+
vfsPath?: string | undefined;
|
|
69
|
+
fileCount?: number | undefined;
|
|
70
|
+
pulled?: boolean | undefined;
|
|
71
|
+
pulledFiles?: number | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
seriesUID: string;
|
|
74
|
+
description: string;
|
|
75
|
+
modality: string;
|
|
76
|
+
vfsPath?: string | undefined;
|
|
77
|
+
fileCount?: number | undefined;
|
|
78
|
+
pulled?: boolean | undefined;
|
|
79
|
+
pulledFiles?: number | undefined;
|
|
80
|
+
}>, "many">;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
date: string;
|
|
83
|
+
series: {
|
|
84
|
+
seriesUID: string;
|
|
85
|
+
description: string;
|
|
86
|
+
modality: string;
|
|
87
|
+
vfsPath?: string | undefined;
|
|
88
|
+
fileCount?: number | undefined;
|
|
89
|
+
pulled?: boolean | undefined;
|
|
90
|
+
pulledFiles?: number | undefined;
|
|
91
|
+
}[];
|
|
92
|
+
description: string;
|
|
93
|
+
patientName: string;
|
|
94
|
+
patientId: string;
|
|
95
|
+
modalities: string;
|
|
96
|
+
accession: string;
|
|
97
|
+
vfsPath?: string | undefined;
|
|
98
|
+
studyUID?: string | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
date: string;
|
|
101
|
+
series: {
|
|
102
|
+
seriesUID: string;
|
|
103
|
+
description: string;
|
|
104
|
+
modality: string;
|
|
105
|
+
vfsPath?: string | undefined;
|
|
106
|
+
fileCount?: number | undefined;
|
|
107
|
+
pulled?: boolean | undefined;
|
|
108
|
+
pulledFiles?: number | undefined;
|
|
109
|
+
}[];
|
|
110
|
+
description: string;
|
|
111
|
+
patientName: string;
|
|
112
|
+
patientId: string;
|
|
113
|
+
modalities: string;
|
|
114
|
+
accession: string;
|
|
115
|
+
vfsPath?: string | undefined;
|
|
116
|
+
studyUID?: string | undefined;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* The `pacs.query` model: one query's decoded result. `vfsPath` is where the
|
|
120
|
+
* query lives under `/net/pacs/queries` — a query is a persistent CUBE
|
|
121
|
+
* object, re-checkable later.
|
|
122
|
+
*/
|
|
123
|
+
export declare const pacsQueryModelSchema: z.ZodObject<{
|
|
124
|
+
queryId: z.ZodNumber;
|
|
125
|
+
vfsPath: z.ZodString;
|
|
126
|
+
pacsName: z.ZodString;
|
|
127
|
+
expression: z.ZodString;
|
|
128
|
+
studies: z.ZodArray<z.ZodObject<{
|
|
129
|
+
studyUID: z.ZodOptional<z.ZodString>;
|
|
130
|
+
/** The study's VFS path under the query — a study-level pull's argument. */
|
|
131
|
+
vfsPath: z.ZodOptional<z.ZodString>;
|
|
132
|
+
description: z.ZodString;
|
|
133
|
+
patientName: z.ZodString;
|
|
134
|
+
patientId: z.ZodString;
|
|
135
|
+
date: z.ZodString;
|
|
136
|
+
modalities: z.ZodString;
|
|
137
|
+
accession: z.ZodString;
|
|
138
|
+
series: z.ZodArray<z.ZodObject<{
|
|
139
|
+
seriesUID: z.ZodString;
|
|
140
|
+
description: z.ZodString;
|
|
141
|
+
modality: z.ZodString;
|
|
142
|
+
fileCount: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
/** The series' own VFS path under the query — the pull's argument. */
|
|
144
|
+
vfsPath: z.ZodOptional<z.ZodString>;
|
|
145
|
+
/** True when CUBE already holds this series (a pull would just confirm). */
|
|
146
|
+
pulled: z.ZodOptional<z.ZodBoolean>;
|
|
147
|
+
/** How many files CUBE holds, when known. */
|
|
148
|
+
pulledFiles: z.ZodOptional<z.ZodNumber>;
|
|
149
|
+
}, "strip", z.ZodTypeAny, {
|
|
150
|
+
seriesUID: string;
|
|
151
|
+
description: string;
|
|
152
|
+
modality: string;
|
|
153
|
+
vfsPath?: string | undefined;
|
|
154
|
+
fileCount?: number | undefined;
|
|
155
|
+
pulled?: boolean | undefined;
|
|
156
|
+
pulledFiles?: number | undefined;
|
|
157
|
+
}, {
|
|
158
|
+
seriesUID: string;
|
|
159
|
+
description: string;
|
|
160
|
+
modality: string;
|
|
161
|
+
vfsPath?: string | undefined;
|
|
162
|
+
fileCount?: number | undefined;
|
|
163
|
+
pulled?: boolean | undefined;
|
|
164
|
+
pulledFiles?: number | undefined;
|
|
165
|
+
}>, "many">;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
date: string;
|
|
168
|
+
series: {
|
|
169
|
+
seriesUID: string;
|
|
170
|
+
description: string;
|
|
171
|
+
modality: string;
|
|
172
|
+
vfsPath?: string | undefined;
|
|
173
|
+
fileCount?: number | undefined;
|
|
174
|
+
pulled?: boolean | undefined;
|
|
175
|
+
pulledFiles?: number | undefined;
|
|
176
|
+
}[];
|
|
177
|
+
description: string;
|
|
178
|
+
patientName: string;
|
|
179
|
+
patientId: string;
|
|
180
|
+
modalities: string;
|
|
181
|
+
accession: string;
|
|
182
|
+
vfsPath?: string | undefined;
|
|
183
|
+
studyUID?: string | undefined;
|
|
184
|
+
}, {
|
|
185
|
+
date: string;
|
|
186
|
+
series: {
|
|
187
|
+
seriesUID: string;
|
|
188
|
+
description: string;
|
|
189
|
+
modality: string;
|
|
190
|
+
vfsPath?: string | undefined;
|
|
191
|
+
fileCount?: number | undefined;
|
|
192
|
+
pulled?: boolean | undefined;
|
|
193
|
+
pulledFiles?: number | undefined;
|
|
194
|
+
}[];
|
|
195
|
+
description: string;
|
|
196
|
+
patientName: string;
|
|
197
|
+
patientId: string;
|
|
198
|
+
modalities: string;
|
|
199
|
+
accession: string;
|
|
200
|
+
vfsPath?: string | undefined;
|
|
201
|
+
studyUID?: string | undefined;
|
|
202
|
+
}>, "many">;
|
|
203
|
+
}, "strip", z.ZodTypeAny, {
|
|
204
|
+
vfsPath: string;
|
|
205
|
+
queryId: number;
|
|
206
|
+
pacsName: string;
|
|
207
|
+
expression: string;
|
|
208
|
+
studies: {
|
|
209
|
+
date: string;
|
|
210
|
+
series: {
|
|
211
|
+
seriesUID: string;
|
|
212
|
+
description: string;
|
|
213
|
+
modality: string;
|
|
214
|
+
vfsPath?: string | undefined;
|
|
215
|
+
fileCount?: number | undefined;
|
|
216
|
+
pulled?: boolean | undefined;
|
|
217
|
+
pulledFiles?: number | undefined;
|
|
218
|
+
}[];
|
|
219
|
+
description: string;
|
|
220
|
+
patientName: string;
|
|
221
|
+
patientId: string;
|
|
222
|
+
modalities: string;
|
|
223
|
+
accession: string;
|
|
224
|
+
vfsPath?: string | undefined;
|
|
225
|
+
studyUID?: string | undefined;
|
|
226
|
+
}[];
|
|
227
|
+
}, {
|
|
228
|
+
vfsPath: string;
|
|
229
|
+
queryId: number;
|
|
230
|
+
pacsName: string;
|
|
231
|
+
expression: string;
|
|
232
|
+
studies: {
|
|
233
|
+
date: string;
|
|
234
|
+
series: {
|
|
235
|
+
seriesUID: string;
|
|
236
|
+
description: string;
|
|
237
|
+
modality: string;
|
|
238
|
+
vfsPath?: string | undefined;
|
|
239
|
+
fileCount?: number | undefined;
|
|
240
|
+
pulled?: boolean | undefined;
|
|
241
|
+
pulledFiles?: number | undefined;
|
|
242
|
+
}[];
|
|
243
|
+
description: string;
|
|
244
|
+
patientName: string;
|
|
245
|
+
patientId: string;
|
|
246
|
+
modalities: string;
|
|
247
|
+
accession: string;
|
|
248
|
+
vfsPath?: string | undefined;
|
|
249
|
+
studyUID?: string | undefined;
|
|
250
|
+
}[];
|
|
251
|
+
}>;
|
|
252
|
+
export type PacsSeries = z.infer<typeof pacsSeriesSchema>;
|
|
253
|
+
export type PacsStudy = z.infer<typeof pacsStudySchema>;
|
|
254
|
+
export type PacsQueryModel = z.infer<typeof pacsQueryModelSchema>;
|
|
255
|
+
/** The model's envelope kind. */
|
|
256
|
+
export declare const PACS_QUERY_MODEL_KIND: "pacs.query";
|
package/dist/pacs.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The PACS query vocabulary: search results as typed envelope payloads.
|
|
3
|
+
*
|
|
4
|
+
* A `pacs query` answers with studies containing series; the terminal renders
|
|
5
|
+
* them as text while a graphical surface reads this model — the same
|
|
6
|
+
* one-command-two-projections pattern as the DAG models. Series carry their
|
|
7
|
+
* instance UIDs so a surface can lower a selection straight to
|
|
8
|
+
* `pacs pull SeriesInstanceUID:<uid>`.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
/** One series within a found study. */
|
|
14
|
+
export const pacsSeriesSchema = z.object({
|
|
15
|
+
seriesUID: z.string(),
|
|
16
|
+
description: z.string(),
|
|
17
|
+
modality: z.string(),
|
|
18
|
+
fileCount: z.number().optional(),
|
|
19
|
+
/** The series' own VFS path under the query — the pull's argument. */
|
|
20
|
+
vfsPath: z.string().optional(),
|
|
21
|
+
/** True when CUBE already holds this series (a pull would just confirm). */
|
|
22
|
+
pulled: z.boolean().optional(),
|
|
23
|
+
/** How many files CUBE holds, when known. */
|
|
24
|
+
pulledFiles: z.number().optional(),
|
|
25
|
+
});
|
|
26
|
+
/** One found study and its series. */
|
|
27
|
+
export const pacsStudySchema = z.object({
|
|
28
|
+
studyUID: z.string().optional(),
|
|
29
|
+
/** The study's VFS path under the query — a study-level pull's argument. */
|
|
30
|
+
vfsPath: z.string().optional(),
|
|
31
|
+
description: z.string(),
|
|
32
|
+
patientName: z.string(),
|
|
33
|
+
patientId: z.string(),
|
|
34
|
+
date: z.string(),
|
|
35
|
+
modalities: z.string(),
|
|
36
|
+
accession: z.string(),
|
|
37
|
+
series: z.array(pacsSeriesSchema),
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* The `pacs.query` model: one query's decoded result. `vfsPath` is where the
|
|
41
|
+
* query lives under `/net/pacs/queries` — a query is a persistent CUBE
|
|
42
|
+
* object, re-checkable later.
|
|
43
|
+
*/
|
|
44
|
+
export const pacsQueryModelSchema = z.object({
|
|
45
|
+
queryId: z.number(),
|
|
46
|
+
vfsPath: z.string(),
|
|
47
|
+
pacsName: z.string(),
|
|
48
|
+
expression: z.string(),
|
|
49
|
+
studies: z.array(pacsStudySchema),
|
|
50
|
+
});
|
|
51
|
+
/** The model's envelope kind. */
|
|
52
|
+
export const PACS_QUERY_MODEL_KIND = 'pacs.query';
|
|
53
|
+
//# sourceMappingURL=pacs.js.map
|
package/dist/pacs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pacs.js","sourceRoot":"","sources":["../src/pacs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,uCAAuC;AACvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,sEAAsE;IACtE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,4EAA4E;IAC5E,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,6CAA6C;IAC7C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAEH,sCAAsC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,4EAA4E;IAC5E,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC;CAClC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;CAClC,CAAC,CAAC;AAMH,iCAAiC;AACjC,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAqB,CAAC"}
|
package/dist/proc.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Prompt-facing process-index lifecycle state.
|
|
3
|
+
*
|
|
4
|
+
* This is contract vocabulary: it is narrowed by the prompt-context schema and
|
|
5
|
+
* read by every surface that draws a prompt, so it lives with the contract
|
|
6
|
+
* rather than with the cache that happens to produce it.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/** User-visible process-index states carried to prompt renderers. */
|
|
11
|
+
export declare const PROC_PROMPT_STATES: readonly ["cold", "cached", "failed"];
|
|
12
|
+
/** User-visible process-index state carried to prompt renderers. */
|
|
13
|
+
export type ProcPromptState = typeof PROC_PROMPT_STATES[number];
|
|
14
|
+
/**
|
|
15
|
+
* Prompt-facing progress for cache restoration and reconciliation.
|
|
16
|
+
*
|
|
17
|
+
* @property loaded - Plugin instances currently available.
|
|
18
|
+
* @property total - Authoritative total when CUBE has reported one.
|
|
19
|
+
* @property restored - Whether the available instances came from a checkpoint.
|
|
20
|
+
* @property state - Cold indexing, cached reconciliation, or failed refresh.
|
|
21
|
+
*/
|
|
22
|
+
export interface ProcPromptProgress {
|
|
23
|
+
loaded: number;
|
|
24
|
+
total?: number;
|
|
25
|
+
restored?: boolean;
|
|
26
|
+
state?: ProcPromptState;
|
|
27
|
+
/** Whether the global index sweep is what `loaded`/`total` describe; absent means yes (older daemons). */
|
|
28
|
+
sweeping?: boolean;
|
|
29
|
+
/** One feed's first-visit topology load in flight, when there is one. */
|
|
30
|
+
feed?: ProcFeedPromptProgress;
|
|
31
|
+
/** Feeds the roster gained (created or shared) in the last half minute. */
|
|
32
|
+
arrived?: number[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A warm-up step that failed behind the prompt and has not since succeeded.
|
|
36
|
+
*
|
|
37
|
+
* @property label - The boot-step label, as the readout named it.
|
|
38
|
+
* @property message - What the failure said.
|
|
39
|
+
*/
|
|
40
|
+
export interface WarmupFailureReport {
|
|
41
|
+
label: string;
|
|
42
|
+
message: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Prompt-facing progress of one feed's topology load.
|
|
46
|
+
*
|
|
47
|
+
* @property id - The feed being loaded.
|
|
48
|
+
* @property loaded - Plugin instances fetched so far.
|
|
49
|
+
* @property total - The server's count for the feed, zero while unknown.
|
|
50
|
+
*/
|
|
51
|
+
export interface ProcFeedPromptProgress {
|
|
52
|
+
id: number;
|
|
53
|
+
loaded: number;
|
|
54
|
+
total: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolves the prompt state, including compatibility with contexts that only
|
|
58
|
+
* carry the legacy `restored` flag.
|
|
59
|
+
*
|
|
60
|
+
* @param progress - Prompt-facing process-index progress.
|
|
61
|
+
* @returns Explicit state, or one derived from checkpoint restoration.
|
|
62
|
+
*/
|
|
63
|
+
export declare function procPromptState_get(progress: ProcPromptProgress): ProcPromptState;
|
package/dist/proc.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Prompt-facing process-index lifecycle state.
|
|
3
|
+
*
|
|
4
|
+
* This is contract vocabulary: it is narrowed by the prompt-context schema and
|
|
5
|
+
* read by every surface that draws a prompt, so it lives with the contract
|
|
6
|
+
* rather than with the cache that happens to produce it.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/** User-visible process-index states carried to prompt renderers. */
|
|
11
|
+
export const PROC_PROMPT_STATES = ['cold', 'cached', 'failed'];
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the prompt state, including compatibility with contexts that only
|
|
14
|
+
* carry the legacy `restored` flag.
|
|
15
|
+
*
|
|
16
|
+
* @param progress - Prompt-facing process-index progress.
|
|
17
|
+
* @returns Explicit state, or one derived from checkpoint restoration.
|
|
18
|
+
*/
|
|
19
|
+
export function procPromptState_get(progress) {
|
|
20
|
+
return progress.state ?? (progress.restored === true ? 'cached' : 'cold');
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=proc.js.map
|
package/dist/proc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proc.js","sourceRoot":"","sources":["../src/proc.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,qEAAqE;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAkDxE;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAA4B;IAC9D,OAAO,QAAQ,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The structured-progress vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* Progress is semantic live telemetry: not command output, never captured into
|
|
5
|
+
* envelopes, never consumed by pipes or redirects. These are the values it may
|
|
6
|
+
* carry. They live with the contract because the wire narrows to them and every
|
|
7
|
+
* surface reads them, while the engine merely produces them.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Operations that may produce structured progress.
|
|
13
|
+
*
|
|
14
|
+
* `task` is the deliberate none-of-the-above value: work whose activity has no
|
|
15
|
+
* useful name, such as a cache warm-up or a directory scan. It is also the
|
|
16
|
+
* value an unknown operation from a newer peer degrades to, so a surface built
|
|
17
|
+
* against an older enum renders such work generically instead of dropping it.
|
|
18
|
+
*/
|
|
19
|
+
export declare const PROGRESS_OPERATIONS: readonly ["upload", "download", "pull", "workflow", "pipeline", "group", "task"];
|
|
20
|
+
/** Broad structured-progress producer classes. */
|
|
21
|
+
export declare const PROGRESS_KINDS: readonly ["transfer", "retrieve", "workflow", "inspection"];
|
|
22
|
+
/**
|
|
23
|
+
* Lifecycle phases shared by structured-progress operations.
|
|
24
|
+
*
|
|
25
|
+
* `working` is indeterminate: work is under way and neither its extent nor its
|
|
26
|
+
* remaining time is known. The named phases all imply a specific activity,
|
|
27
|
+
* which is precisely what indeterminate work cannot claim.
|
|
28
|
+
*/
|
|
29
|
+
export declare const PROGRESS_PHASES: readonly ["scanning", "transferring", "watching", "retrying", "reading", "working", "complete", "failed"];
|
|
30
|
+
/** Units supported by counted progress. */
|
|
31
|
+
export declare const PROGRESS_UNITS: readonly ["files", "bytes", "series", "jobs", "nodes"];
|
|
32
|
+
/** Operation and item states supported by structured progress. */
|
|
33
|
+
export declare const PROGRESS_STATUSES: readonly ["running", "done", "unconfirmed", "stalled", "timeout", "error", "unknown"];
|
|
34
|
+
export type ProgressOperation = typeof PROGRESS_OPERATIONS[number];
|
|
35
|
+
export type ProgressKind = typeof PROGRESS_KINDS[number];
|
|
36
|
+
export type ProgressPhase = typeof PROGRESS_PHASES[number];
|
|
37
|
+
export type ProgressUnit = typeof PROGRESS_UNITS[number];
|
|
38
|
+
export type ProgressStatus = typeof PROGRESS_STATUSES[number];
|
package/dist/progress.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The structured-progress vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* Progress is semantic live telemetry: not command output, never captured into
|
|
5
|
+
* envelopes, never consumed by pipes or redirects. These are the values it may
|
|
6
|
+
* carry. They live with the contract because the wire narrows to them and every
|
|
7
|
+
* surface reads them, while the engine merely produces them.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Operations that may produce structured progress.
|
|
13
|
+
*
|
|
14
|
+
* `task` is the deliberate none-of-the-above value: work whose activity has no
|
|
15
|
+
* useful name, such as a cache warm-up or a directory scan. It is also the
|
|
16
|
+
* value an unknown operation from a newer peer degrades to, so a surface built
|
|
17
|
+
* against an older enum renders such work generically instead of dropping it.
|
|
18
|
+
*/
|
|
19
|
+
export const PROGRESS_OPERATIONS = [
|
|
20
|
+
'upload', 'download', 'pull', 'workflow', 'pipeline', 'group', 'task',
|
|
21
|
+
];
|
|
22
|
+
/** Broad structured-progress producer classes. */
|
|
23
|
+
export const PROGRESS_KINDS = ['transfer', 'retrieve', 'workflow', 'inspection'];
|
|
24
|
+
/**
|
|
25
|
+
* Lifecycle phases shared by structured-progress operations.
|
|
26
|
+
*
|
|
27
|
+
* `working` is indeterminate: work is under way and neither its extent nor its
|
|
28
|
+
* remaining time is known. The named phases all imply a specific activity,
|
|
29
|
+
* which is precisely what indeterminate work cannot claim.
|
|
30
|
+
*/
|
|
31
|
+
export const PROGRESS_PHASES = [
|
|
32
|
+
'scanning', 'transferring', 'watching', 'retrying', 'reading', 'working', 'complete', 'failed',
|
|
33
|
+
];
|
|
34
|
+
/** Units supported by counted progress. */
|
|
35
|
+
export const PROGRESS_UNITS = ['files', 'bytes', 'series', 'jobs', 'nodes'];
|
|
36
|
+
/** Operation and item states supported by structured progress. */
|
|
37
|
+
export const PROGRESS_STATUSES = [
|
|
38
|
+
'running', 'done', 'unconfirmed', 'stalled', 'timeout', 'error', 'unknown',
|
|
39
|
+
];
|
|
40
|
+
// `ProgressEvent` is not declared here. It is inferred from the wire schema in
|
|
41
|
+
// `messages.ts`, so the shape the engine emits and the shape the wire carries
|
|
42
|
+
// cannot be two things.
|
|
43
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM;CAC7D,CAAC;AACX,kDAAkD;AAClD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAU,CAAC;AAC1F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ;CACtF,CAAC;AACX,2CAA2C;AAC3C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AACrF,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS;CAClE,CAAC;AAQX,+EAA+E;AAC/E,8EAA8E;AAC9E,wBAAwB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Boundary validation.
|
|
3
|
+
*
|
|
4
|
+
* Every message is validated on the way in and out. Structural violations
|
|
5
|
+
* (missing required fields, wrong types, an unknown `type`) are rejected;
|
|
6
|
+
* unknown *additional* fields are tolerated (stripped), so a daemon accepts
|
|
7
|
+
* additive extensions from a newer minor without understanding them. Parsing
|
|
8
|
+
* never throws — it returns a {@link ParseResult} so the caller can answer a
|
|
9
|
+
* malformed message with an `error` message rather than dropping the socket.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { attachMessageSchema, type ClientMessage, type ServerMessage } from './messages.js';
|
|
15
|
+
/**
|
|
16
|
+
* The outcome of validating a message at the boundary.
|
|
17
|
+
*
|
|
18
|
+
* @property ok - Whether the input was a valid message.
|
|
19
|
+
* @property value - The parsed message, when `ok`.
|
|
20
|
+
* @property error - A human-readable reason, when not `ok`.
|
|
21
|
+
*/
|
|
22
|
+
export interface ParseResult<T> {
|
|
23
|
+
ok: boolean;
|
|
24
|
+
value?: T;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validates a message a surface sent to the daemon.
|
|
29
|
+
*
|
|
30
|
+
* @param raw - The untrusted input (already JSON-parsed).
|
|
31
|
+
* @returns The parse result.
|
|
32
|
+
*/
|
|
33
|
+
export declare function clientMessage_parse(raw: unknown): ParseResult<ClientMessage>;
|
|
34
|
+
/**
|
|
35
|
+
* Validates a message the daemon sent to a surface.
|
|
36
|
+
*
|
|
37
|
+
* @param raw - The untrusted input (already JSON-parsed).
|
|
38
|
+
* @returns The parse result.
|
|
39
|
+
*/
|
|
40
|
+
export declare function serverMessage_parse(raw: unknown): ParseResult<ServerMessage>;
|
|
41
|
+
/**
|
|
42
|
+
* Parses a JSON string into a client message, rejecting both malformed JSON
|
|
43
|
+
* and structurally invalid messages with a clear reason.
|
|
44
|
+
*
|
|
45
|
+
* @param json - The raw JSON text received on the socket.
|
|
46
|
+
* @returns The parse result.
|
|
47
|
+
*/
|
|
48
|
+
export declare function clientMessage_fromJson(json: string): ParseResult<ClientMessage>;
|
|
49
|
+
/**
|
|
50
|
+
* Validates an attach message and checks its declared contract version
|
|
51
|
+
* against this build. A structurally valid attach on an incompatible major
|
|
52
|
+
* is rejected with a clear reason.
|
|
53
|
+
*
|
|
54
|
+
* @param raw - The untrusted input (already JSON-parsed).
|
|
55
|
+
* @returns The parse result; an incompatible version is a validation failure.
|
|
56
|
+
*/
|
|
57
|
+
export declare function attach_parse(raw: unknown): ParseResult<z.infer<typeof attachMessageSchema>>;
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { clientMessageSchema, serverMessageSchema, attachMessageSchema, } from './messages.js';
|
|
2
|
+
import { version_isCompatible } from './version.js';
|
|
3
|
+
/**
|
|
4
|
+
* Formats a Zod error into a compact, single-line boundary reason.
|
|
5
|
+
*
|
|
6
|
+
* @param error - The Zod validation error.
|
|
7
|
+
* @returns A human-readable reason string.
|
|
8
|
+
*/
|
|
9
|
+
function zodError_format(error) {
|
|
10
|
+
return error.issues
|
|
11
|
+
.map((issue) => {
|
|
12
|
+
const path = issue.path.join('.');
|
|
13
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
14
|
+
})
|
|
15
|
+
.join('; ');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validates a raw value against a schema, never throwing.
|
|
19
|
+
*
|
|
20
|
+
* Generic over the schema rather than over a value type, because a schema that
|
|
21
|
+
* degrades unknown values (see `progressOperationSchema`) reads a wider input
|
|
22
|
+
* than it produces, and only the schema's own output type states what a caller
|
|
23
|
+
* receives.
|
|
24
|
+
*
|
|
25
|
+
* @param schema - The schema to validate against.
|
|
26
|
+
* @param raw - The untrusted input.
|
|
27
|
+
* @returns The parse result.
|
|
28
|
+
*/
|
|
29
|
+
function schema_parse(schema, raw) {
|
|
30
|
+
const result = schema.safeParse(raw);
|
|
31
|
+
if (result.success) {
|
|
32
|
+
return { ok: true, value: result.data };
|
|
33
|
+
}
|
|
34
|
+
return { ok: false, error: zodError_format(result.error) };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validates a message a surface sent to the daemon.
|
|
38
|
+
*
|
|
39
|
+
* @param raw - The untrusted input (already JSON-parsed).
|
|
40
|
+
* @returns The parse result.
|
|
41
|
+
*/
|
|
42
|
+
export function clientMessage_parse(raw) {
|
|
43
|
+
return schema_parse(clientMessageSchema, raw);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Validates a message the daemon sent to a surface.
|
|
47
|
+
*
|
|
48
|
+
* @param raw - The untrusted input (already JSON-parsed).
|
|
49
|
+
* @returns The parse result.
|
|
50
|
+
*/
|
|
51
|
+
export function serverMessage_parse(raw) {
|
|
52
|
+
return schema_parse(serverMessageSchema, raw);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parses a JSON string into a client message, rejecting both malformed JSON
|
|
56
|
+
* and structurally invalid messages with a clear reason.
|
|
57
|
+
*
|
|
58
|
+
* @param json - The raw JSON text received on the socket.
|
|
59
|
+
* @returns The parse result.
|
|
60
|
+
*/
|
|
61
|
+
export function clientMessage_fromJson(json) {
|
|
62
|
+
let parsed;
|
|
63
|
+
try {
|
|
64
|
+
parsed = JSON.parse(json);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
68
|
+
return { ok: false, error: `malformed JSON: ${message}` };
|
|
69
|
+
}
|
|
70
|
+
return clientMessage_parse(parsed);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Validates an attach message and checks its declared contract version
|
|
74
|
+
* against this build. A structurally valid attach on an incompatible major
|
|
75
|
+
* is rejected with a clear reason.
|
|
76
|
+
*
|
|
77
|
+
* @param raw - The untrusted input (already JSON-parsed).
|
|
78
|
+
* @returns The parse result; an incompatible version is a validation failure.
|
|
79
|
+
*/
|
|
80
|
+
export function attach_parse(raw) {
|
|
81
|
+
const parsed = schema_parse(attachMessageSchema, raw);
|
|
82
|
+
if (!parsed.ok || parsed.value === undefined) {
|
|
83
|
+
return parsed;
|
|
84
|
+
}
|
|
85
|
+
if (!version_isCompatible(parsed.value.protocolVersion)) {
|
|
86
|
+
return {
|
|
87
|
+
ok: false,
|
|
88
|
+
error: `incompatible contract version ${parsed.value.protocolVersion}`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return parsed;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAepD;;;;;GAKG;AACH,SAAS,eAAe,CAAC,KAAiB;IACxC,OAAO,KAAK,CAAC,MAAM;SAChB,GAAG,CAAC,CAAC,KAAiB,EAAU,EAAE;QACjC,MAAM,IAAI,GAAW,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;IAC5D,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,YAAY,CAAyB,MAAS,EAAE,GAAY;IACnE,MAAM,MAAM,GAAgD,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAClF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAO,YAAY,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAO,YAAY,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,OAAO,GAAW,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,OAAO,EAAE,EAAE,CAAC;IAC5D,CAAC;IACD,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,MAAM,MAAM,GAAqD,YAAY,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;IACxG,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC7C,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC;QACxD,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,iCAAiC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE;SACvE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The wire-contract version and its compatibility rule.
|
|
3
|
+
*
|
|
4
|
+
* The contract version is carried by a client in the attach handshake and
|
|
5
|
+
* refused by the daemon on mismatch, with no silent degradation. Per
|
|
6
|
+
* `docs/calypso.adoc`, it tracks the calypso package's major version at
|
|
7
|
+
* release; within a major, changes are additive only (new message types,
|
|
8
|
+
* new optional fields, new model kinds), so a daemon tolerates unknown
|
|
9
|
+
* additions from a newer minor but rejects a different major outright.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The wire-contract major version this build speaks.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CONTRACT_VERSION: number;
|
|
17
|
+
/**
|
|
18
|
+
* Decides whether a client's declared contract version is compatible with
|
|
19
|
+
* this build. Compatibility is exact-major: a client on a different major is
|
|
20
|
+
* refused, because a major bump removes or re-types something.
|
|
21
|
+
*
|
|
22
|
+
* @param clientVersion - The contract major the client declared at attach.
|
|
23
|
+
* @returns True when the client may attach.
|
|
24
|
+
*/
|
|
25
|
+
export declare function version_isCompatible(clientVersion: number): boolean;
|