@fnndsc/calypso 0.6.1 → 0.7.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/calypso.js +53 -3
- package/dist/calypso.js.map +1 -1
- package/dist/daemon/attachFile.d.ts +43 -0
- package/dist/daemon/attachFile.js +80 -0
- package/dist/daemon/attachFile.js.map +1 -0
- package/dist/daemon/engine.d.ts +16 -0
- package/dist/daemon/face.d.ts +127 -0
- package/dist/daemon/face.js +419 -0
- package/dist/daemon/face.js.map +1 -0
- package/dist/daemon/launch.d.ts +21 -6
- package/dist/daemon/launch.js +76 -14
- package/dist/daemon/launch.js.map +1 -1
- package/dist/daemon/server.d.ts +83 -4
- package/dist/daemon/server.js +157 -5
- package/dist/daemon/server.js.map +1 -1
- package/dist/index.d.ts +15 -8
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
- package/dist/protocol/envelope.d.ts +0 -136
- package/dist/protocol/envelope.js +0 -46
- package/dist/protocol/envelope.js.map +0 -1
- package/dist/protocol/index.d.ts +0 -16
- package/dist/protocol/index.js +0 -17
- package/dist/protocol/index.js.map +0 -1
- package/dist/protocol/messages.d.ts +0 -1568
- package/dist/protocol/messages.js +0 -281
- package/dist/protocol/messages.js.map +0 -1
- package/dist/protocol/validate.d.ts +0 -57
- package/dist/protocol/validate.js +0 -88
- package/dist/protocol/validate.js.map +0 -1
- package/dist/protocol/version.d.ts +0 -25
- package/dist/protocol/version.js +0 -28
- package/dist/protocol/version.js.map +0 -1
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file The wire-contract message schemas.
|
|
3
|
-
*
|
|
4
|
-
* Two discriminated unions, one per direction, keyed on a `type` tag:
|
|
5
|
-
* {@link clientMessageSchema} (surface → daemon) and
|
|
6
|
-
* {@link serverMessageSchema} (daemon → surface). Every request carries a
|
|
7
|
-
* correlation `id` so its reply and any streamed output can be matched to
|
|
8
|
-
* it, and output events carry the sink channel they belong to. These schemas
|
|
9
|
-
* are the single source of truth for the protocol; the human-readable
|
|
10
|
-
* description in `docs/calypso.adoc` is checked against them.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
import { z } from 'zod';
|
|
15
|
-
import { PROC_PROMPT_STATES } from '@fnndsc/cumin/proc-prompt';
|
|
16
|
-
import { PROGRESS_KINDS, PROGRESS_OPERATIONS, PROGRESS_PHASES, PROGRESS_STATUSES, PROGRESS_UNITS, } from '@fnndsc/brasa/progress';
|
|
17
|
-
import { commandEnvelopeSchema } from './envelope.js';
|
|
18
|
-
/** The sink channel an output event belongs to. */
|
|
19
|
-
export const channelSchema = z.enum(['data', 'err', 'status']);
|
|
20
|
-
// --- Surface → daemon ------------------------------------------------------
|
|
21
|
-
/** Capabilities an attaching surface can safely execute on its own machine. */
|
|
22
|
-
export const surfaceCapabilitiesMessageSchema = z.object({
|
|
23
|
-
shellCommands: z.boolean(),
|
|
24
|
-
hiddenInput: z.boolean().optional(),
|
|
25
|
-
});
|
|
26
|
-
/** Attach to a session: declares the contract version, token, and surface capabilities. */
|
|
27
|
-
export const attachMessageSchema = z.object({
|
|
28
|
-
type: z.literal('attach'),
|
|
29
|
-
protocolVersion: z.number().int(),
|
|
30
|
-
token: z.string(),
|
|
31
|
-
session: z.string().optional(),
|
|
32
|
-
capabilities: surfaceCapabilitiesMessageSchema.optional(),
|
|
33
|
-
});
|
|
34
|
-
/** Execute one input line, correlated by `id`. */
|
|
35
|
-
export const executeMessageSchema = z.object({
|
|
36
|
-
type: z.literal('execute'),
|
|
37
|
-
id: z.string(),
|
|
38
|
-
line: z.string(),
|
|
39
|
-
});
|
|
40
|
-
/** Requests cancellation of the caller's currently executing command. */
|
|
41
|
-
export const cancelMessageSchema = z.object({
|
|
42
|
-
type: z.literal('cancel'),
|
|
43
|
-
id: z.string(),
|
|
44
|
-
});
|
|
45
|
-
/** Request completion candidates for a partial line, correlated by `id`. */
|
|
46
|
-
export const completeRequestSchema = z.object({
|
|
47
|
-
type: z.literal('complete'),
|
|
48
|
-
id: z.string(),
|
|
49
|
-
prefix: z.string(),
|
|
50
|
-
});
|
|
51
|
-
/** Answers a prompt the daemon requested during a command, correlated by `promptId`. */
|
|
52
|
-
export const promptAnswerMessageSchema = z.object({
|
|
53
|
-
type: z.literal('promptAnswer'),
|
|
54
|
-
promptId: z.string(),
|
|
55
|
-
answer: z.string(),
|
|
56
|
-
});
|
|
57
|
-
/** Reports a prompt failure to the daemon (surface cannot or did not answer), correlated by `promptId`. */
|
|
58
|
-
export const promptErrorMessageSchema = z.object({
|
|
59
|
-
type: z.literal('promptError'),
|
|
60
|
-
promptId: z.string(),
|
|
61
|
-
reason: z.string(),
|
|
62
|
-
});
|
|
63
|
-
/** Returns the output of a pipeline segment the daemon asked the surface to run, correlated by `pipeId`. */
|
|
64
|
-
export const pipeResultMessageSchema = z.object({
|
|
65
|
-
type: z.literal('pipeResult'),
|
|
66
|
-
pipeId: z.string(),
|
|
67
|
-
output: z.string(),
|
|
68
|
-
});
|
|
69
|
-
/** Returns a pipeline-segment failure to the daemon, correlated by `pipeId`. */
|
|
70
|
-
export const pipeErrorMessageSchema = z.object({
|
|
71
|
-
type: z.literal('pipeError'),
|
|
72
|
-
pipeId: z.string(),
|
|
73
|
-
reason: z.string(),
|
|
74
|
-
});
|
|
75
|
-
/** Returns the exit code of a shell command the daemon asked the surface to run. */
|
|
76
|
-
export const shellResultMessageSchema = z.object({
|
|
77
|
-
type: z.literal('shellResult'),
|
|
78
|
-
shellId: z.string(),
|
|
79
|
-
exitCode: z.number().int(),
|
|
80
|
-
});
|
|
81
|
-
/** Returns a surface shell-launch failure to the daemon, correlated by `shellId`. */
|
|
82
|
-
export const shellErrorMessageSchema = z.object({
|
|
83
|
-
type: z.literal('shellError'),
|
|
84
|
-
shellId: z.string(),
|
|
85
|
-
reason: z.string(),
|
|
86
|
-
});
|
|
87
|
-
/** Returns the edited content from a local-edit the daemon requested, correlated by `editId`. */
|
|
88
|
-
export const editResultMessageSchema = z.object({
|
|
89
|
-
type: z.literal('editResult'),
|
|
90
|
-
editId: z.string(),
|
|
91
|
-
content: z.string(),
|
|
92
|
-
changed: z.boolean(),
|
|
93
|
-
});
|
|
94
|
-
/** Reports a local-edit failure to the daemon, correlated by `editId`. */
|
|
95
|
-
export const editErrorMessageSchema = z.object({
|
|
96
|
-
type: z.literal('editError'),
|
|
97
|
-
editId: z.string(),
|
|
98
|
-
reason: z.string(),
|
|
99
|
-
});
|
|
100
|
-
/** Any message a surface may send to the daemon. */
|
|
101
|
-
export const clientMessageSchema = z.discriminatedUnion('type', [
|
|
102
|
-
attachMessageSchema,
|
|
103
|
-
executeMessageSchema,
|
|
104
|
-
cancelMessageSchema,
|
|
105
|
-
completeRequestSchema,
|
|
106
|
-
promptAnswerMessageSchema,
|
|
107
|
-
promptErrorMessageSchema,
|
|
108
|
-
pipeResultMessageSchema,
|
|
109
|
-
pipeErrorMessageSchema,
|
|
110
|
-
shellResultMessageSchema,
|
|
111
|
-
shellErrorMessageSchema,
|
|
112
|
-
editResultMessageSchema,
|
|
113
|
-
editErrorMessageSchema,
|
|
114
|
-
]);
|
|
115
|
-
// --- Daemon → surface ------------------------------------------------------
|
|
116
|
-
/**
|
|
117
|
-
* Acknowledges a successful attach. The optional `stack` block reports the
|
|
118
|
-
* daemon's own installed versions and build hash, so a remote surface can
|
|
119
|
-
* greet with the truth of the process it attached to rather than whatever is
|
|
120
|
-
* installed client-side; older daemons simply omit it.
|
|
121
|
-
*/
|
|
122
|
-
export const attachedMessageSchema = z.object({
|
|
123
|
-
type: z.literal('attached'),
|
|
124
|
-
session: z.string(),
|
|
125
|
-
protocolVersion: z.number().int(),
|
|
126
|
-
stack: z
|
|
127
|
-
.object({
|
|
128
|
-
chell: z.string(),
|
|
129
|
-
calypso: z.string(),
|
|
130
|
-
build: z.string(),
|
|
131
|
-
brasa: z.string().optional(),
|
|
132
|
-
chili: z.string().optional(),
|
|
133
|
-
salsa: z.string().optional(),
|
|
134
|
-
cumin: z.string().optional(),
|
|
135
|
-
})
|
|
136
|
-
.optional(),
|
|
137
|
-
});
|
|
138
|
-
/** The final result of one executed line: one envelope per command. */
|
|
139
|
-
export const resultMessageSchema = z.object({
|
|
140
|
-
type: z.literal('result'),
|
|
141
|
-
id: z.string(),
|
|
142
|
-
envelopes: z.array(commandEnvelopeSchema),
|
|
143
|
-
});
|
|
144
|
-
/** The reply to a completion request. */
|
|
145
|
-
export const completeReplySchema = z.object({
|
|
146
|
-
type: z.literal('complete'),
|
|
147
|
-
id: z.string(),
|
|
148
|
-
prefix: z.string(),
|
|
149
|
-
candidates: z.array(z.string()),
|
|
150
|
-
});
|
|
151
|
-
/** A streamed output event on one channel, correlated to its command. */
|
|
152
|
-
export const outputMessageSchema = z.object({
|
|
153
|
-
type: z.literal('output'),
|
|
154
|
-
id: z.string(),
|
|
155
|
-
channel: channelSchema,
|
|
156
|
-
chunk: z.string(),
|
|
157
|
-
});
|
|
158
|
-
/** The operation producing structured progress. */
|
|
159
|
-
export const progressOperationSchema = z.enum(PROGRESS_OPERATIONS);
|
|
160
|
-
/** Broad class of progress producer. */
|
|
161
|
-
export const progressKindSchema = z.enum(PROGRESS_KINDS);
|
|
162
|
-
/** Lifecycle phase of a progress operation. */
|
|
163
|
-
export const progressPhaseSchema = z.enum(PROGRESS_PHASES);
|
|
164
|
-
/** Unit used by the primary progress counter. */
|
|
165
|
-
export const progressUnitSchema = z.enum(PROGRESS_UNITS);
|
|
166
|
-
/** State of the operation or item being reported. */
|
|
167
|
-
export const progressStatusSchema = z.enum(PROGRESS_STATUSES);
|
|
168
|
-
/** A structured progress event correlated to a command. */
|
|
169
|
-
export const progressMessageSchema = z.object({
|
|
170
|
-
type: z.literal('progress'),
|
|
171
|
-
id: z.string(),
|
|
172
|
-
operation: progressOperationSchema,
|
|
173
|
-
kind: progressKindSchema.optional(),
|
|
174
|
-
phase: progressPhaseSchema,
|
|
175
|
-
label: z.string().optional(),
|
|
176
|
-
itemId: z.string().optional(),
|
|
177
|
-
current: z.number().nonnegative().optional(),
|
|
178
|
-
total: z.number().nonnegative().optional(),
|
|
179
|
-
percent: z.number().min(0).max(100).optional(),
|
|
180
|
-
unit: progressUnitSchema.optional(),
|
|
181
|
-
status: progressStatusSchema.optional(),
|
|
182
|
-
});
|
|
183
|
-
/** A session-bus broadcast: an envelope tagged with its originating surface. */
|
|
184
|
-
export const sessionMessageSchema = z.object({
|
|
185
|
-
type: z.literal('session'),
|
|
186
|
-
surface: z.string(),
|
|
187
|
-
envelope: commandEnvelopeSchema,
|
|
188
|
-
});
|
|
189
|
-
/** A boundary error: a refused attach, a malformed message, correlated when possible. */
|
|
190
|
-
export const errorMessageSchema = z.object({
|
|
191
|
-
type: z.literal('error'),
|
|
192
|
-
id: z.string().optional(),
|
|
193
|
-
reason: z.string(),
|
|
194
|
-
});
|
|
195
|
-
/**
|
|
196
|
-
* A prompt request the daemon raises during a command: the surface that
|
|
197
|
-
* submitted the command must answer it (with `promptAnswer`) before the
|
|
198
|
-
* command can proceed. `hidden` requests no-echo entry (password).
|
|
199
|
-
*/
|
|
200
|
-
export const promptMessageSchema = z.object({
|
|
201
|
-
type: z.literal('prompt'),
|
|
202
|
-
promptId: z.string(),
|
|
203
|
-
message: z.string(),
|
|
204
|
-
hidden: z.boolean(),
|
|
205
|
-
});
|
|
206
|
-
/**
|
|
207
|
-
* The engine-known facts a prompt reflects, independent of any theme.
|
|
208
|
-
*
|
|
209
|
-
* The daemon knows the session context but not how a given surface renders it,
|
|
210
|
-
* so it ships these facts and each surface themes them with its own settings.
|
|
211
|
-
* Rendering inputs a surface owns (theme, segments, terminal width) are not
|
|
212
|
-
* carried here.
|
|
213
|
-
*/
|
|
214
|
-
export const promptContextSchema = z.object({
|
|
215
|
-
user: z.string(),
|
|
216
|
-
uri: z.string(),
|
|
217
|
-
cwd: z.string(),
|
|
218
|
-
pacsserver: z.string().nullable(),
|
|
219
|
-
physicalMode: z.boolean(),
|
|
220
|
-
lastExitCode: z.number(),
|
|
221
|
-
lastCommandDurationMs: z.number(),
|
|
222
|
-
procWarmup: z.object({
|
|
223
|
-
loaded: z.number(),
|
|
224
|
-
total: z.number().optional(),
|
|
225
|
-
restored: z.boolean().optional(),
|
|
226
|
-
state: z.enum(PROC_PROMPT_STATES).optional(),
|
|
227
|
-
}).optional(),
|
|
228
|
-
});
|
|
229
|
-
/**
|
|
230
|
-
* The prompt context, pushed by the daemon with each result and on any context
|
|
231
|
-
* change. The daemon knows the session context; each surface renders it with
|
|
232
|
-
* its own theme, so prompt themes are a per-surface choice rather than the
|
|
233
|
-
* daemon's.
|
|
234
|
-
*/
|
|
235
|
-
export const promptLineMessageSchema = z.object({
|
|
236
|
-
type: z.literal('promptline'),
|
|
237
|
-
context: promptContextSchema,
|
|
238
|
-
});
|
|
239
|
-
/**
|
|
240
|
-
* Asks the surface to run a pipeline segment on its own machine (never on the
|
|
241
|
-
* daemon host) and return the output. `input` and the reply's `output` are
|
|
242
|
-
* base64, since segment data is arbitrary bytes.
|
|
243
|
-
*/
|
|
244
|
-
export const pipeMessageSchema = z.object({
|
|
245
|
-
type: z.literal('pipe'),
|
|
246
|
-
pipeId: z.string(),
|
|
247
|
-
command: z.string(),
|
|
248
|
-
input: z.string(),
|
|
249
|
-
});
|
|
250
|
-
/** Asks the surface to run a shell command on its own machine, never on the daemon host. */
|
|
251
|
-
export const shellMessageSchema = z.object({
|
|
252
|
-
type: z.literal('shell'),
|
|
253
|
-
shellId: z.string(),
|
|
254
|
-
command: z.string(),
|
|
255
|
-
});
|
|
256
|
-
/**
|
|
257
|
-
* Asks the surface to open content in its local editor (never on the daemon
|
|
258
|
-
* host) and return the edited result.
|
|
259
|
-
*/
|
|
260
|
-
export const editMessageSchema = z.object({
|
|
261
|
-
type: z.literal('edit'),
|
|
262
|
-
editId: z.string(),
|
|
263
|
-
content: z.string(),
|
|
264
|
-
extension: z.string().optional(),
|
|
265
|
-
});
|
|
266
|
-
/** Any message the daemon may send to a surface. */
|
|
267
|
-
export const serverMessageSchema = z.discriminatedUnion('type', [
|
|
268
|
-
attachedMessageSchema,
|
|
269
|
-
resultMessageSchema,
|
|
270
|
-
completeReplySchema,
|
|
271
|
-
outputMessageSchema,
|
|
272
|
-
progressMessageSchema,
|
|
273
|
-
sessionMessageSchema,
|
|
274
|
-
errorMessageSchema,
|
|
275
|
-
promptMessageSchema,
|
|
276
|
-
promptLineMessageSchema,
|
|
277
|
-
pipeMessageSchema,
|
|
278
|
-
shellMessageSchema,
|
|
279
|
-
editMessageSchema,
|
|
280
|
-
]);
|
|
281
|
-
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/protocol/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,mDAAmD;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE/D,8EAA8E;AAE9E,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;IAC1B,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAEH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,OAAO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;IAClB,mBAAmB;IACnB,uBAAuB;IACvB,iBAAiB;IACjB,kBAAkB;IAClB,iBAAiB;CAClB,CAAC,CAAC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
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>>;
|
|
@@ -1,88 +0,0 @@
|
|
|
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
|
-
* @param schema - The schema to validate against.
|
|
21
|
-
* @param raw - The untrusted input.
|
|
22
|
-
* @returns The parse result.
|
|
23
|
-
*/
|
|
24
|
-
function schema_parse(schema, raw) {
|
|
25
|
-
const result = schema.safeParse(raw);
|
|
26
|
-
if (result.success) {
|
|
27
|
-
return { ok: true, value: result.data };
|
|
28
|
-
}
|
|
29
|
-
return { ok: false, error: zodError_format(result.error) };
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Validates a message a surface sent to the daemon.
|
|
33
|
-
*
|
|
34
|
-
* @param raw - The untrusted input (already JSON-parsed).
|
|
35
|
-
* @returns The parse result.
|
|
36
|
-
*/
|
|
37
|
-
export function clientMessage_parse(raw) {
|
|
38
|
-
return schema_parse(clientMessageSchema, raw);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Validates a message the daemon sent to a surface.
|
|
42
|
-
*
|
|
43
|
-
* @param raw - The untrusted input (already JSON-parsed).
|
|
44
|
-
* @returns The parse result.
|
|
45
|
-
*/
|
|
46
|
-
export function serverMessage_parse(raw) {
|
|
47
|
-
return schema_parse(serverMessageSchema, raw);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Parses a JSON string into a client message, rejecting both malformed JSON
|
|
51
|
-
* and structurally invalid messages with a clear reason.
|
|
52
|
-
*
|
|
53
|
-
* @param json - The raw JSON text received on the socket.
|
|
54
|
-
* @returns The parse result.
|
|
55
|
-
*/
|
|
56
|
-
export function clientMessage_fromJson(json) {
|
|
57
|
-
let parsed;
|
|
58
|
-
try {
|
|
59
|
-
parsed = JSON.parse(json);
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
63
|
-
return { ok: false, error: `malformed JSON: ${message}` };
|
|
64
|
-
}
|
|
65
|
-
return clientMessage_parse(parsed);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Validates an attach message and checks its declared contract version
|
|
69
|
-
* against this build. A structurally valid attach on an incompatible major
|
|
70
|
-
* is rejected with a clear reason.
|
|
71
|
-
*
|
|
72
|
-
* @param raw - The untrusted input (already JSON-parsed).
|
|
73
|
-
* @returns The parse result; an incompatible version is a validation failure.
|
|
74
|
-
*/
|
|
75
|
-
export function attach_parse(raw) {
|
|
76
|
-
const parsed = schema_parse(attachMessageSchema, raw);
|
|
77
|
-
if (!parsed.ok || parsed.value === undefined) {
|
|
78
|
-
return parsed;
|
|
79
|
-
}
|
|
80
|
-
if (!version_isCompatible(parsed.value.protocolVersion)) {
|
|
81
|
-
return {
|
|
82
|
-
ok: false,
|
|
83
|
-
error: `incompatible contract version ${parsed.value.protocolVersion}`,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return parsed;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/protocol/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;;;;;;GAMG;AACH,SAAS,YAAY,CAAI,MAAoB,EAAE,GAAY;IACzD,MAAM,MAAM,GAAsC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACxE,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,E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Ae,EAAE;SACvE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
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;
|
package/dist/protocol/version.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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 const CONTRACT_VERSION = 1;
|
|
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 function version_isCompatible(clientVersion) {
|
|
26
|
-
return clientVersion === CONTRACT_VERSION;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=version.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/protocol/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAW,CAAC,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,aAAqB;IACxD,OAAO,aAAa,KAAK,gBAAgB,CAAC;AAC5C,CAAC"}
|