@ccmsg/protocol 1.20.0 → 1.22.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/README.md +2 -2
- package/package.json +1 -1
- package/src/attributes.ts +77 -52
- package/src/common/auth.ts +28 -28
- package/src/common/hello.ts +72 -34
- package/src/common/ping.ts +2 -2
- package/src/common/shutdown.ts +4 -4
- package/src/common/topics.ts +24 -19
- package/src/control/dump.ts +73 -66
- package/src/control/files.ts +24 -24
- package/src/control/kv.ts +6 -6
- package/src/control/launcher.ts +4 -4
- package/src/control/llm.ts +8 -8
- package/src/control/sandbox.ts +4 -4
- package/src/control/session-errors.ts +3 -3
- package/src/control/session-status.ts +2 -2
- package/src/control/session.ts +36 -35
- package/src/control/transcript.ts +6 -6
- package/src/control/translate.ts +2 -2
- package/src/envelope.ts +2 -2
- package/src/errors.ts +1 -1
- package/src/fixtures/common.ts +45 -32
- package/src/fixtures/control.ts +67 -67
- package/src/fixtures/index.ts +77 -63
- package/src/fixtures/messaging.ts +9 -9
- package/src/fixtures/topics.ts +9 -9
- package/src/identifiers.ts +8 -6
- package/src/messaging/message.ts +3 -3
- package/src/messaging/notify.ts +3 -3
- package/src/messaging/say.ts +9 -9
- package/src/schemas.ts +79 -67
- package/src/session-meta.ts +2 -1
package/src/fixtures/common.ts
CHANGED
|
@@ -4,10 +4,10 @@ import type {
|
|
|
4
4
|
AuthAssertResponse,
|
|
5
5
|
AuthChallengeRequest,
|
|
6
6
|
AuthChallengeResponse,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
AuthExtendRequest,
|
|
8
|
+
AuthExtendResponse,
|
|
9
|
+
AuthTokenRefreshRequest,
|
|
10
|
+
AuthTokenRefreshResponse,
|
|
11
11
|
AuthRegisterRequest,
|
|
12
12
|
AuthRegisterResponse,
|
|
13
13
|
AuthResolveRequest,
|
|
@@ -15,7 +15,12 @@ import type {
|
|
|
15
15
|
AuthRotateRequest,
|
|
16
16
|
AuthRotateResponse,
|
|
17
17
|
} from "../common/auth.ts";
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
HelloInstanceRequest,
|
|
20
|
+
HelloSessionRequest,
|
|
21
|
+
HelloSessionResponse,
|
|
22
|
+
HelloUserRequest,
|
|
23
|
+
} from "../common/hello.ts";
|
|
19
24
|
import type { InstancePingRequest, InstancePingResponse } from "../common/ping.ts";
|
|
20
25
|
import type {
|
|
21
26
|
InstanceShutdownRequest,
|
|
@@ -33,10 +38,9 @@ import { FIXTURE_IDS, FIXTURE_NOW } from "./ids.ts";
|
|
|
33
38
|
|
|
34
39
|
const { sid, instance, other_instance, endpoint, other_endpoint, request_id } = FIXTURE_IDS;
|
|
35
40
|
|
|
36
|
-
export const
|
|
41
|
+
export const HELLO_SESSION_REQUEST: Static<typeof HelloSessionRequest> = {
|
|
37
42
|
request_id,
|
|
38
|
-
op: "hello",
|
|
39
|
-
role: "session",
|
|
43
|
+
op: "hello.session",
|
|
40
44
|
protocol_version: 3,
|
|
41
45
|
sid,
|
|
42
46
|
client_version: "0.1.0",
|
|
@@ -51,12 +55,19 @@ export const HELLO_REQUEST: Static<typeof HelloRequest> = {
|
|
|
51
55
|
effort: "high",
|
|
52
56
|
};
|
|
53
57
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
/** A person greeting, which names neither a session nor a mesh claim. */
|
|
59
|
+
export const HELLO_USER_REQUEST: Static<typeof HelloUserRequest> = {
|
|
60
|
+
request_id,
|
|
61
|
+
op: "hello.user",
|
|
62
|
+
protocol_version: 3,
|
|
63
|
+
client_version: "0.1.0",
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** An instance greeting a peer, which carries the mesh claim in place of a
|
|
67
|
+
* session's meta. */
|
|
68
|
+
export const HELLO_INSTANCE_REQUEST: Static<typeof HelloInstanceRequest> = {
|
|
57
69
|
request_id,
|
|
58
|
-
op: "hello",
|
|
59
|
-
role: "instance",
|
|
70
|
+
op: "hello.instance",
|
|
60
71
|
protocol_version: 3,
|
|
61
72
|
mesh: {
|
|
62
73
|
ver: 1,
|
|
@@ -67,7 +78,9 @@ export const HELLO_MESH_REQUEST: Static<typeof HelloRequest> = {
|
|
|
67
78
|
},
|
|
68
79
|
};
|
|
69
80
|
|
|
70
|
-
|
|
81
|
+
/** One reply for all three greetings: what an instance answers does not turn
|
|
82
|
+
* on which of them asked. */
|
|
83
|
+
export const HELLO_RESPONSE: Static<typeof HelloSessionResponse> = {
|
|
71
84
|
ok: true,
|
|
72
85
|
request_id,
|
|
73
86
|
protocol_version: 3,
|
|
@@ -86,7 +99,7 @@ export const HELLO_RESPONSE: Static<typeof HelloResponse> = {
|
|
|
86
99
|
|
|
87
100
|
export const INSTANCE_PING_REQUEST: Static<typeof InstancePingRequest> = {
|
|
88
101
|
request_id,
|
|
89
|
-
op: "
|
|
102
|
+
op: "instance.ping",
|
|
90
103
|
};
|
|
91
104
|
|
|
92
105
|
export const INSTANCE_PING_RESPONSE: Static<typeof InstancePingResponse> = {
|
|
@@ -103,7 +116,7 @@ export const INSTANCE_PING_RESPONSE: Static<typeof InstancePingResponse> = {
|
|
|
103
116
|
|
|
104
117
|
export const INSTANCE_SHUTDOWN_REQUEST: Static<typeof InstanceShutdownRequest> = {
|
|
105
118
|
request_id,
|
|
106
|
-
op: "
|
|
119
|
+
op: "instance.shutdown",
|
|
107
120
|
};
|
|
108
121
|
|
|
109
122
|
export const INSTANCE_SHUTDOWN_RESPONSE: Static<typeof InstanceShutdownResponse> = {
|
|
@@ -113,7 +126,7 @@ export const INSTANCE_SHUTDOWN_RESPONSE: Static<typeof InstanceShutdownResponse>
|
|
|
113
126
|
|
|
114
127
|
export const SESSION_STOPPING_REQUEST: Static<typeof SessionStoppingRequest> = {
|
|
115
128
|
request_id,
|
|
116
|
-
op: "
|
|
129
|
+
op: "session.stopping",
|
|
117
130
|
reason: "prompt_input_exit",
|
|
118
131
|
};
|
|
119
132
|
|
|
@@ -125,7 +138,7 @@ export const SESSION_STOPPING_RESPONSE: Static<typeof SessionStoppingResponse> =
|
|
|
125
138
|
|
|
126
139
|
export const TOPIC_SUBSCRIBE_REQUEST: Static<typeof TopicSubscribeRequest> = {
|
|
127
140
|
request_id,
|
|
128
|
-
op: "
|
|
141
|
+
op: "topic.subscribe",
|
|
129
142
|
topic: "peers",
|
|
130
143
|
};
|
|
131
144
|
|
|
@@ -139,13 +152,13 @@ export const TOPIC_SUBSCRIBE_RESPONSE: Static<typeof TopicSubscribeResponse> = {
|
|
|
139
152
|
* are spelled. */
|
|
140
153
|
export const TOPIC_SUBSCRIBE_SESSION_REQUEST: Static<typeof TopicSubscribeRequest> = {
|
|
141
154
|
request_id,
|
|
142
|
-
op: "
|
|
155
|
+
op: "topic.subscribe",
|
|
143
156
|
topic: `transcript:${sid}`,
|
|
144
157
|
};
|
|
145
158
|
|
|
146
159
|
export const TOPIC_UNSUBSCRIBE_REQUEST: Static<typeof TopicUnsubscribeRequest> = {
|
|
147
160
|
request_id,
|
|
148
|
-
op: "
|
|
161
|
+
op: "topic.unsubscribe",
|
|
149
162
|
topic: "peers",
|
|
150
163
|
};
|
|
151
164
|
|
|
@@ -169,7 +182,7 @@ const SUBJECT = "personal-1";
|
|
|
169
182
|
|
|
170
183
|
export const AUTH_CHALLENGE_REQUEST: Static<typeof AuthChallengeRequest> = {
|
|
171
184
|
request_id,
|
|
172
|
-
op: "
|
|
185
|
+
op: "auth.challenge",
|
|
173
186
|
};
|
|
174
187
|
|
|
175
188
|
export const AUTH_CHALLENGE_RESPONSE: Static<typeof AuthChallengeResponse> = {
|
|
@@ -180,7 +193,7 @@ export const AUTH_CHALLENGE_RESPONSE: Static<typeof AuthChallengeResponse> = {
|
|
|
180
193
|
|
|
181
194
|
export const AUTH_REGISTER_REQUEST: Static<typeof AuthRegisterRequest> = {
|
|
182
195
|
request_id,
|
|
183
|
-
op: "
|
|
196
|
+
op: "auth.register",
|
|
184
197
|
token: REGISTER_TOKEN,
|
|
185
198
|
code: REGISTER_CODE,
|
|
186
199
|
device_label: "work laptop",
|
|
@@ -202,7 +215,7 @@ export const AUTH_REGISTER_RESPONSE: Static<typeof AuthRegisterResponse> = {
|
|
|
202
215
|
|
|
203
216
|
export const AUTH_ASSERT_REQUEST: Static<typeof AuthAssertRequest> = {
|
|
204
217
|
request_id,
|
|
205
|
-
op: "
|
|
218
|
+
op: "auth.assert",
|
|
206
219
|
challenge: CHALLENGE,
|
|
207
220
|
credential: {
|
|
208
221
|
raw_id: "Y3JlZC1pZA",
|
|
@@ -220,26 +233,26 @@ export const AUTH_ASSERT_RESPONSE: Static<typeof AuthAssertResponse> = {
|
|
|
220
233
|
access: ACCESS,
|
|
221
234
|
};
|
|
222
235
|
|
|
223
|
-
export const
|
|
236
|
+
export const AUTH_TOKEN_REFRESH_REQUEST: Static<typeof AuthTokenRefreshRequest> = {
|
|
224
237
|
request_id,
|
|
225
|
-
op: "
|
|
238
|
+
op: "auth.token.refresh",
|
|
226
239
|
reason: "reload",
|
|
227
240
|
};
|
|
228
241
|
|
|
229
|
-
export const
|
|
242
|
+
export const AUTH_TOKEN_REFRESH_RESPONSE: Static<typeof AuthTokenRefreshResponse> = {
|
|
230
243
|
ok: true,
|
|
231
244
|
request_id,
|
|
232
245
|
sub: SUBJECT,
|
|
233
246
|
access: ACCESS,
|
|
234
247
|
};
|
|
235
248
|
|
|
236
|
-
export const
|
|
249
|
+
export const AUTH_EXTEND_REQUEST: Static<typeof AuthExtendRequest> = {
|
|
237
250
|
request_id,
|
|
238
|
-
op: "
|
|
251
|
+
op: "auth.extend",
|
|
239
252
|
access_token: ACCESS.value,
|
|
240
253
|
};
|
|
241
254
|
|
|
242
|
-
export const
|
|
255
|
+
export const AUTH_EXTEND_RESPONSE: Static<typeof AuthExtendResponse> = {
|
|
243
256
|
ok: true,
|
|
244
257
|
request_id,
|
|
245
258
|
auth_expires_at: FIXTURE_NOW + 20_000_000,
|
|
@@ -247,7 +260,7 @@ export const AUTH_REFRESH_RESPONSE: Static<typeof AuthRefreshResponse> = {
|
|
|
247
260
|
|
|
248
261
|
export const AUTH_RESOLVE_REQUEST = {
|
|
249
262
|
request_id,
|
|
250
|
-
op: "
|
|
263
|
+
op: "auth.resolve",
|
|
251
264
|
to_instance: instance,
|
|
252
265
|
kind: "register",
|
|
253
266
|
token: REGISTER_TOKEN,
|
|
@@ -275,7 +288,7 @@ export const AUTH_RESOLVE_RESPONSE = {
|
|
|
275
288
|
* nothing beyond having spent it. */
|
|
276
289
|
export const AUTH_RESOLVE_CHALLENGE_REQUEST = {
|
|
277
290
|
request_id,
|
|
278
|
-
op: "
|
|
291
|
+
op: "auth.resolve",
|
|
279
292
|
to_instance: instance,
|
|
280
293
|
kind: "challenge",
|
|
281
294
|
challenge: CHALLENGE.challenge,
|
|
@@ -289,7 +302,7 @@ export const AUTH_RESOLVE_CHALLENGE_RESPONSE = {
|
|
|
289
302
|
|
|
290
303
|
export const AUTH_ROTATE_REQUEST: Static<typeof AuthRotateRequest> = {
|
|
291
304
|
request_id,
|
|
292
|
-
op: "
|
|
305
|
+
op: "auth.rotate",
|
|
293
306
|
to_instance: instance,
|
|
294
307
|
refresh_token: REFRESH.value,
|
|
295
308
|
reason: "reconnect",
|