@fnndsc/calypso 0.2.0 → 0.3.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.d.ts +13 -0
- package/dist/calypso.js +45 -0
- package/dist/calypso.js.map +1 -0
- package/dist/daemon/discovery.d.ts +23 -0
- package/dist/daemon/discovery.js +55 -0
- package/dist/daemon/discovery.js.map +1 -0
- package/dist/daemon/engine.js +1 -2
- package/dist/daemon/launch.d.ts +9 -0
- package/dist/daemon/launch.js +83 -0
- package/dist/daemon/launch.js.map +1 -0
- package/dist/daemon/server.d.ts +6 -5
- package/dist/daemon/server.js +43 -41
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/token.js +8 -13
- package/dist/daemon/token.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -42
- package/dist/index.js.map +1 -1
- package/dist/protocol/envelope.js +20 -23
- package/dist/protocol/envelope.js.map +1 -1
- package/dist/protocol/messages.d.ts +175 -10
- package/dist/protocol/messages.js +132 -117
- package/dist/protocol/messages.js.map +1 -1
- package/dist/protocol/validate.js +10 -16
- package/dist/protocol/validate.js.map +1 -1
- package/dist/protocol/version.js +3 -7
- package/dist/protocol/version.js.map +1 -1
- package/package.json +10 -5
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serverMessageSchema = exports.editMessageSchema = exports.pipeMessageSchema = exports.promptLineMessageSchema = exports.promptMessageSchema = exports.errorMessageSchema = exports.sessionMessageSchema = exports.progressMessageSchema = exports.progressStatusSchema = exports.progressUnitSchema = exports.progressPhaseSchema = exports.progressKindSchema = exports.progressOperationSchema = exports.outputMessageSchema = exports.completeReplySchema = exports.resultMessageSchema = exports.attachedMessageSchema = exports.clientMessageSchema = exports.editResultMessageSchema = exports.pipeResultMessageSchema = exports.promptAnswerMessageSchema = exports.completeRequestSchema = exports.executeMessageSchema = exports.attachMessageSchema = exports.channelSchema = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @file The wire-contract message schemas.
|
|
6
3
|
*
|
|
@@ -14,176 +11,194 @@ exports.serverMessageSchema = exports.editMessageSchema = exports.pipeMessageSch
|
|
|
14
11
|
*
|
|
15
12
|
* @module
|
|
16
13
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import { commandEnvelopeSchema } from './envelope.js';
|
|
19
16
|
/** The sink channel an output event belongs to. */
|
|
20
|
-
|
|
17
|
+
export const channelSchema = z.enum(['data', 'err', 'status']);
|
|
21
18
|
// --- Surface → daemon ------------------------------------------------------
|
|
22
19
|
/** Attach to a session: declares the contract version and the attach token. */
|
|
23
|
-
|
|
24
|
-
type:
|
|
25
|
-
protocolVersion:
|
|
26
|
-
token:
|
|
27
|
-
session:
|
|
20
|
+
export const attachMessageSchema = z.object({
|
|
21
|
+
type: z.literal('attach'),
|
|
22
|
+
protocolVersion: z.number().int(),
|
|
23
|
+
token: z.string(),
|
|
24
|
+
session: z.string().optional(),
|
|
28
25
|
});
|
|
29
26
|
/** Execute one input line, correlated by `id`. */
|
|
30
|
-
|
|
31
|
-
type:
|
|
32
|
-
id:
|
|
33
|
-
line:
|
|
27
|
+
export const executeMessageSchema = z.object({
|
|
28
|
+
type: z.literal('execute'),
|
|
29
|
+
id: z.string(),
|
|
30
|
+
line: z.string(),
|
|
34
31
|
});
|
|
35
32
|
/** Request completion candidates for a partial line, correlated by `id`. */
|
|
36
|
-
|
|
37
|
-
type:
|
|
38
|
-
id:
|
|
39
|
-
prefix:
|
|
33
|
+
export const completeRequestSchema = z.object({
|
|
34
|
+
type: z.literal('complete'),
|
|
35
|
+
id: z.string(),
|
|
36
|
+
prefix: z.string(),
|
|
40
37
|
});
|
|
41
38
|
/** Answers a prompt the daemon requested during a command, correlated by `promptId`. */
|
|
42
|
-
|
|
43
|
-
type:
|
|
44
|
-
promptId:
|
|
45
|
-
answer:
|
|
39
|
+
export const promptAnswerMessageSchema = z.object({
|
|
40
|
+
type: z.literal('promptAnswer'),
|
|
41
|
+
promptId: z.string(),
|
|
42
|
+
answer: z.string(),
|
|
46
43
|
});
|
|
47
44
|
/** Returns the output of a pipeline segment the daemon asked the surface to run, correlated by `pipeId`. */
|
|
48
|
-
|
|
49
|
-
type:
|
|
50
|
-
pipeId:
|
|
51
|
-
output:
|
|
45
|
+
export const pipeResultMessageSchema = z.object({
|
|
46
|
+
type: z.literal('pipeResult'),
|
|
47
|
+
pipeId: z.string(),
|
|
48
|
+
output: z.string(),
|
|
52
49
|
});
|
|
53
50
|
/** Returns the edited content from a local-edit the daemon requested, correlated by `editId`. */
|
|
54
|
-
|
|
55
|
-
type:
|
|
56
|
-
editId:
|
|
57
|
-
content:
|
|
58
|
-
changed:
|
|
51
|
+
export const editResultMessageSchema = z.object({
|
|
52
|
+
type: z.literal('editResult'),
|
|
53
|
+
editId: z.string(),
|
|
54
|
+
content: z.string(),
|
|
55
|
+
changed: z.boolean(),
|
|
59
56
|
});
|
|
60
57
|
/** Any message a surface may send to the daemon. */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
export const clientMessageSchema = z.discriminatedUnion('type', [
|
|
59
|
+
attachMessageSchema,
|
|
60
|
+
executeMessageSchema,
|
|
61
|
+
completeRequestSchema,
|
|
62
|
+
promptAnswerMessageSchema,
|
|
63
|
+
pipeResultMessageSchema,
|
|
64
|
+
editResultMessageSchema,
|
|
68
65
|
]);
|
|
69
66
|
// --- Daemon → surface ------------------------------------------------------
|
|
70
67
|
/** Acknowledges a successful attach. */
|
|
71
|
-
|
|
72
|
-
type:
|
|
73
|
-
session:
|
|
74
|
-
protocolVersion:
|
|
68
|
+
export const attachedMessageSchema = z.object({
|
|
69
|
+
type: z.literal('attached'),
|
|
70
|
+
session: z.string(),
|
|
71
|
+
protocolVersion: z.number().int(),
|
|
75
72
|
});
|
|
76
73
|
/** The final result of one executed line: one envelope per command. */
|
|
77
|
-
|
|
78
|
-
type:
|
|
79
|
-
id:
|
|
80
|
-
envelopes:
|
|
74
|
+
export const resultMessageSchema = z.object({
|
|
75
|
+
type: z.literal('result'),
|
|
76
|
+
id: z.string(),
|
|
77
|
+
envelopes: z.array(commandEnvelopeSchema),
|
|
81
78
|
});
|
|
82
79
|
/** The reply to a completion request. */
|
|
83
|
-
|
|
84
|
-
type:
|
|
85
|
-
id:
|
|
86
|
-
prefix:
|
|
87
|
-
candidates:
|
|
80
|
+
export const completeReplySchema = z.object({
|
|
81
|
+
type: z.literal('complete'),
|
|
82
|
+
id: z.string(),
|
|
83
|
+
prefix: z.string(),
|
|
84
|
+
candidates: z.array(z.string()),
|
|
88
85
|
});
|
|
89
86
|
/** A streamed output event on one channel, correlated to its command. */
|
|
90
|
-
|
|
91
|
-
type:
|
|
92
|
-
id:
|
|
93
|
-
channel:
|
|
94
|
-
chunk:
|
|
87
|
+
export const outputMessageSchema = z.object({
|
|
88
|
+
type: z.literal('output'),
|
|
89
|
+
id: z.string(),
|
|
90
|
+
channel: channelSchema,
|
|
91
|
+
chunk: z.string(),
|
|
95
92
|
});
|
|
96
93
|
/** The operation producing structured progress. */
|
|
97
|
-
|
|
94
|
+
export const progressOperationSchema = z.enum(['upload', 'download', 'pull', 'workflow']);
|
|
98
95
|
/** Broad class of progress producer. */
|
|
99
|
-
|
|
96
|
+
export const progressKindSchema = z.enum(['transfer', 'retrieve', 'workflow']);
|
|
100
97
|
/** Lifecycle phase of a progress operation. */
|
|
101
|
-
|
|
98
|
+
export const progressPhaseSchema = z.enum(['scanning', 'transferring', 'watching', 'retrying', 'complete', 'failed']);
|
|
102
99
|
/** Unit used by the primary progress counter. */
|
|
103
|
-
|
|
100
|
+
export const progressUnitSchema = z.enum(['files', 'bytes', 'series', 'jobs', 'nodes']);
|
|
104
101
|
/** State of the operation or item being reported. */
|
|
105
|
-
|
|
102
|
+
export const progressStatusSchema = z.enum(['running', 'done', 'unconfirmed', 'stalled', 'timeout', 'error', 'unknown']);
|
|
106
103
|
/** A structured progress event correlated to a command. */
|
|
107
|
-
|
|
108
|
-
type:
|
|
109
|
-
id:
|
|
110
|
-
operation:
|
|
111
|
-
kind:
|
|
112
|
-
phase:
|
|
113
|
-
label:
|
|
114
|
-
itemId:
|
|
115
|
-
current:
|
|
116
|
-
total:
|
|
117
|
-
percent:
|
|
118
|
-
unit:
|
|
119
|
-
status:
|
|
104
|
+
export const progressMessageSchema = z.object({
|
|
105
|
+
type: z.literal('progress'),
|
|
106
|
+
id: z.string(),
|
|
107
|
+
operation: progressOperationSchema,
|
|
108
|
+
kind: progressKindSchema.optional(),
|
|
109
|
+
phase: progressPhaseSchema,
|
|
110
|
+
label: z.string().optional(),
|
|
111
|
+
itemId: z.string().optional(),
|
|
112
|
+
current: z.number().nonnegative().optional(),
|
|
113
|
+
total: z.number().nonnegative().optional(),
|
|
114
|
+
percent: z.number().min(0).max(100).optional(),
|
|
115
|
+
unit: progressUnitSchema.optional(),
|
|
116
|
+
status: progressStatusSchema.optional(),
|
|
120
117
|
});
|
|
121
118
|
/** A session-bus broadcast: an envelope tagged with its originating surface. */
|
|
122
|
-
|
|
123
|
-
type:
|
|
124
|
-
surface:
|
|
125
|
-
envelope:
|
|
119
|
+
export const sessionMessageSchema = z.object({
|
|
120
|
+
type: z.literal('session'),
|
|
121
|
+
surface: z.string(),
|
|
122
|
+
envelope: commandEnvelopeSchema,
|
|
126
123
|
});
|
|
127
124
|
/** A boundary error: a refused attach, a malformed message, correlated when possible. */
|
|
128
|
-
|
|
129
|
-
type:
|
|
130
|
-
id:
|
|
131
|
-
reason:
|
|
125
|
+
export const errorMessageSchema = z.object({
|
|
126
|
+
type: z.literal('error'),
|
|
127
|
+
id: z.string().optional(),
|
|
128
|
+
reason: z.string(),
|
|
132
129
|
});
|
|
133
130
|
/**
|
|
134
131
|
* A prompt request the daemon raises during a command: the surface that
|
|
135
132
|
* submitted the command must answer it (with `promptAnswer`) before the
|
|
136
133
|
* command can proceed. `hidden` requests no-echo entry (password).
|
|
137
134
|
*/
|
|
138
|
-
|
|
139
|
-
type:
|
|
140
|
-
promptId:
|
|
141
|
-
message:
|
|
142
|
-
hidden:
|
|
135
|
+
export const promptMessageSchema = z.object({
|
|
136
|
+
type: z.literal('prompt'),
|
|
137
|
+
promptId: z.string(),
|
|
138
|
+
message: z.string(),
|
|
139
|
+
hidden: z.boolean(),
|
|
143
140
|
});
|
|
144
141
|
/**
|
|
145
|
-
* The
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
142
|
+
* The engine-known facts a prompt reflects, independent of any theme.
|
|
143
|
+
*
|
|
144
|
+
* The daemon knows the session context but not how a given surface renders it,
|
|
145
|
+
* so it ships these facts and each surface themes them with its own settings.
|
|
146
|
+
* Rendering inputs a surface owns (theme, segments, terminal width) are not
|
|
147
|
+
* carried here.
|
|
148
|
+
*/
|
|
149
|
+
export const promptContextSchema = z.object({
|
|
150
|
+
user: z.string(),
|
|
151
|
+
uri: z.string(),
|
|
152
|
+
cwd: z.string(),
|
|
153
|
+
pacsserver: z.string().nullable(),
|
|
154
|
+
physicalMode: z.boolean(),
|
|
155
|
+
lastExitCode: z.number(),
|
|
156
|
+
lastCommandDurationMs: z.number(),
|
|
157
|
+
procWarmup: z.object({ loaded: z.number() }).optional(),
|
|
158
|
+
});
|
|
159
|
+
/**
|
|
160
|
+
* The prompt context, pushed by the daemon with each result and on any context
|
|
161
|
+
* change. The daemon knows the session context; each surface renders it with
|
|
162
|
+
* its own theme, so prompt themes are a per-surface choice rather than the
|
|
163
|
+
* daemon's.
|
|
149
164
|
*/
|
|
150
|
-
|
|
151
|
-
type:
|
|
152
|
-
|
|
165
|
+
export const promptLineMessageSchema = z.object({
|
|
166
|
+
type: z.literal('promptline'),
|
|
167
|
+
context: promptContextSchema,
|
|
153
168
|
});
|
|
154
169
|
/**
|
|
155
170
|
* Asks the surface to run a pipeline segment on its own machine (never on the
|
|
156
171
|
* daemon host) and return the output. `input` and the reply's `output` are
|
|
157
172
|
* base64, since segment data is arbitrary bytes.
|
|
158
173
|
*/
|
|
159
|
-
|
|
160
|
-
type:
|
|
161
|
-
pipeId:
|
|
162
|
-
command:
|
|
163
|
-
input:
|
|
174
|
+
export const pipeMessageSchema = z.object({
|
|
175
|
+
type: z.literal('pipe'),
|
|
176
|
+
pipeId: z.string(),
|
|
177
|
+
command: z.string(),
|
|
178
|
+
input: z.string(),
|
|
164
179
|
});
|
|
165
180
|
/**
|
|
166
181
|
* Asks the surface to open content in its local editor (never on the daemon
|
|
167
182
|
* host) and return the edited result.
|
|
168
183
|
*/
|
|
169
|
-
|
|
170
|
-
type:
|
|
171
|
-
editId:
|
|
172
|
-
content:
|
|
173
|
-
extension:
|
|
184
|
+
export const editMessageSchema = z.object({
|
|
185
|
+
type: z.literal('edit'),
|
|
186
|
+
editId: z.string(),
|
|
187
|
+
content: z.string(),
|
|
188
|
+
extension: z.string().optional(),
|
|
174
189
|
});
|
|
175
190
|
/** Any message the daemon may send to a surface. */
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
191
|
+
export const serverMessageSchema = z.discriminatedUnion('type', [
|
|
192
|
+
attachedMessageSchema,
|
|
193
|
+
resultMessageSchema,
|
|
194
|
+
completeReplySchema,
|
|
195
|
+
outputMessageSchema,
|
|
196
|
+
progressMessageSchema,
|
|
197
|
+
sessionMessageSchema,
|
|
198
|
+
errorMessageSchema,
|
|
199
|
+
promptMessageSchema,
|
|
200
|
+
promptLineMessageSchema,
|
|
201
|
+
pipeMessageSchema,
|
|
202
|
+
editMessageSchema,
|
|
188
203
|
]);
|
|
189
204
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/protocol/messages.ts"],"names":[],"mappings":"
|
|
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,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,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACzB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACjC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAEH,kDAAkD;AAClD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;CACnB,CAAC,CAAC;AAEH,wFAAwF;AACxF,MAAM,CAAC,MAAM,yBAAyB,GAAG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,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IAC7B,OAAO,EAAE,mBAAmB;CAC7B,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC9D,qBAAqB;IACrB,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;IACnB,qBAAqB;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,mBAAmB;IACnB,uBAAuB;IACvB,iBAAiB;IACjB,iBAAiB;CAClB,CAAC,CAAC"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.clientMessage_parse = clientMessage_parse;
|
|
4
|
-
exports.serverMessage_parse = serverMessage_parse;
|
|
5
|
-
exports.clientMessage_fromJson = clientMessage_fromJson;
|
|
6
|
-
exports.attach_parse = attach_parse;
|
|
7
|
-
const messages_js_1 = require("./messages.js");
|
|
8
|
-
const version_js_1 = require("./version.js");
|
|
1
|
+
import { clientMessageSchema, serverMessageSchema, attachMessageSchema, } from './messages.js';
|
|
2
|
+
import { version_isCompatible } from './version.js';
|
|
9
3
|
/**
|
|
10
4
|
* Formats a Zod error into a compact, single-line boundary reason.
|
|
11
5
|
*
|
|
@@ -40,8 +34,8 @@ function schema_parse(schema, raw) {
|
|
|
40
34
|
* @param raw - The untrusted input (already JSON-parsed).
|
|
41
35
|
* @returns The parse result.
|
|
42
36
|
*/
|
|
43
|
-
function clientMessage_parse(raw) {
|
|
44
|
-
return schema_parse(
|
|
37
|
+
export function clientMessage_parse(raw) {
|
|
38
|
+
return schema_parse(clientMessageSchema, raw);
|
|
45
39
|
}
|
|
46
40
|
/**
|
|
47
41
|
* Validates a message the daemon sent to a surface.
|
|
@@ -49,8 +43,8 @@ function clientMessage_parse(raw) {
|
|
|
49
43
|
* @param raw - The untrusted input (already JSON-parsed).
|
|
50
44
|
* @returns The parse result.
|
|
51
45
|
*/
|
|
52
|
-
function serverMessage_parse(raw) {
|
|
53
|
-
return schema_parse(
|
|
46
|
+
export function serverMessage_parse(raw) {
|
|
47
|
+
return schema_parse(serverMessageSchema, raw);
|
|
54
48
|
}
|
|
55
49
|
/**
|
|
56
50
|
* Parses a JSON string into a client message, rejecting both malformed JSON
|
|
@@ -59,7 +53,7 @@ function serverMessage_parse(raw) {
|
|
|
59
53
|
* @param json - The raw JSON text received on the socket.
|
|
60
54
|
* @returns The parse result.
|
|
61
55
|
*/
|
|
62
|
-
function clientMessage_fromJson(json) {
|
|
56
|
+
export function clientMessage_fromJson(json) {
|
|
63
57
|
let parsed;
|
|
64
58
|
try {
|
|
65
59
|
parsed = JSON.parse(json);
|
|
@@ -78,12 +72,12 @@ function clientMessage_fromJson(json) {
|
|
|
78
72
|
* @param raw - The untrusted input (already JSON-parsed).
|
|
79
73
|
* @returns The parse result; an incompatible version is a validation failure.
|
|
80
74
|
*/
|
|
81
|
-
function attach_parse(raw) {
|
|
82
|
-
const parsed = schema_parse(
|
|
75
|
+
export function attach_parse(raw) {
|
|
76
|
+
const parsed = schema_parse(attachMessageSchema, raw);
|
|
83
77
|
if (!parsed.ok || parsed.value === undefined) {
|
|
84
78
|
return parsed;
|
|
85
79
|
}
|
|
86
|
-
if (!
|
|
80
|
+
if (!version_isCompatible(parsed.value.protocolVersion)) {
|
|
87
81
|
return {
|
|
88
82
|
ok: false,
|
|
89
83
|
error: `incompatible contract version ${parsed.value.protocolVersion}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/protocol/validate.ts"],"names":[],"mappings":"
|
|
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,EAAE,EA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E;SACvE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/protocol/version.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @file The wire-contract version and its compatibility rule.
|
|
4
3
|
*
|
|
@@ -11,13 +10,10 @@
|
|
|
11
10
|
*
|
|
12
11
|
* @module
|
|
13
12
|
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CONTRACT_VERSION = void 0;
|
|
16
|
-
exports.version_isCompatible = version_isCompatible;
|
|
17
13
|
/**
|
|
18
14
|
* The wire-contract major version this build speaks.
|
|
19
15
|
*/
|
|
20
|
-
|
|
16
|
+
export const CONTRACT_VERSION = 1;
|
|
21
17
|
/**
|
|
22
18
|
* Decides whether a client's declared contract version is compatible with
|
|
23
19
|
* this build. Compatibility is exact-major: a client on a different major is
|
|
@@ -26,7 +22,7 @@ exports.CONTRACT_VERSION = 1;
|
|
|
26
22
|
* @param clientVersion - The contract major the client declared at attach.
|
|
27
23
|
* @returns True when the client may attach.
|
|
28
24
|
*/
|
|
29
|
-
function version_isCompatible(clientVersion) {
|
|
30
|
-
return clientVersion ===
|
|
25
|
+
export function version_isCompatible(clientVersion) {
|
|
26
|
+
return clientVersion === CONTRACT_VERSION;
|
|
31
27
|
}
|
|
32
28
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/protocol/version.ts"],"names":[],"mappings":"
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fnndsc/calypso",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The CALYPSO wire contract: typed protocol schemas and boundary validation for the ChRIS session daemon",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,20 +14,23 @@
|
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"module": "dist/index.js",
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"bin": {
|
|
19
|
+
"calypso": "./dist/calypso.js"
|
|
20
|
+
},
|
|
17
21
|
"files": [
|
|
18
22
|
"dist"
|
|
19
23
|
],
|
|
20
24
|
"exports": {
|
|
21
25
|
".": {
|
|
22
26
|
"import": "./dist/index.js",
|
|
23
|
-
"types": "./dist/index.d.ts"
|
|
24
|
-
"require": "./dist/index.js"
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
25
28
|
},
|
|
26
29
|
"./package.json": "./package.json"
|
|
27
30
|
},
|
|
28
31
|
"scripts": {
|
|
29
|
-
"build": "rm -fr dist && tsc",
|
|
30
|
-
"test": "jest --coverage",
|
|
32
|
+
"build": "rm -fr dist && tsc && chmod +x ./dist/calypso.js",
|
|
33
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules --disable-warning=ExperimentalWarning' jest --coverage",
|
|
31
34
|
"prepublishOnly": "npm run build"
|
|
32
35
|
},
|
|
33
36
|
"keywords": [
|
|
@@ -48,7 +51,9 @@
|
|
|
48
51
|
"typescript": "^5.0.0"
|
|
49
52
|
},
|
|
50
53
|
"dependencies": {
|
|
54
|
+
"@fnndsc/brasa": "^0.1.0",
|
|
51
55
|
"@fnndsc/cumin": "^3.5.0",
|
|
56
|
+
"chalk": "^4.1.2",
|
|
52
57
|
"ws": "^8.18.0",
|
|
53
58
|
"zod": "^3.23.8"
|
|
54
59
|
}
|