@ccmsg/protocol 1.19.0 → 1.21.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 +36 -21
- package/src/control/agents.ts +23 -4
- package/src/control/dump.ts +73 -66
- package/src/control/files.ts +24 -24
- package/src/control/instances.ts +21 -0
- package/src/control/kv.ts +6 -6
- package/src/control/launcher.ts +4 -4
- package/src/control/llm.ts +8 -8
- package/src/control/peers.ts +52 -68
- 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 +78 -63
- package/src/fixtures/messaging.ts +9 -9
- package/src/fixtures/topics.ts +40 -19
- package/src/identifiers.ts +8 -6
- package/src/index.ts +1 -0
- 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 +81 -67
- package/src/session-meta.ts +2 -1
package/src/fixtures/index.ts
CHANGED
|
@@ -26,135 +26,149 @@ export interface OpFixture {
|
|
|
26
26
|
* implementation. Every one of them passes the op's schema, which the
|
|
27
27
|
* contract's tests hold it to. */
|
|
28
28
|
export const OP_FIXTURES = {
|
|
29
|
-
hello: { request: common.
|
|
30
|
-
|
|
29
|
+
"hello.session": { request: common.HELLO_SESSION_REQUEST, response: common.HELLO_RESPONSE },
|
|
30
|
+
"hello.user": { request: common.HELLO_USER_REQUEST, response: common.HELLO_RESPONSE },
|
|
31
|
+
"hello.instance": {
|
|
32
|
+
request: common.HELLO_INSTANCE_REQUEST,
|
|
33
|
+
response: common.HELLO_RESPONSE,
|
|
34
|
+
},
|
|
35
|
+
"instance.ping": {
|
|
31
36
|
request: common.INSTANCE_PING_REQUEST,
|
|
32
37
|
response: common.INSTANCE_PING_RESPONSE,
|
|
33
38
|
},
|
|
34
|
-
|
|
39
|
+
"instance.shutdown": {
|
|
35
40
|
request: common.INSTANCE_SHUTDOWN_REQUEST,
|
|
36
41
|
response: common.INSTANCE_SHUTDOWN_RESPONSE,
|
|
37
42
|
},
|
|
38
|
-
|
|
43
|
+
"session.stopping": {
|
|
39
44
|
request: common.SESSION_STOPPING_REQUEST,
|
|
40
45
|
response: common.SESSION_STOPPING_RESPONSE,
|
|
41
46
|
},
|
|
42
|
-
|
|
47
|
+
"topic.subscribe": {
|
|
43
48
|
request: common.TOPIC_SUBSCRIBE_REQUEST,
|
|
44
49
|
response: common.TOPIC_SUBSCRIBE_RESPONSE,
|
|
45
50
|
},
|
|
46
|
-
|
|
51
|
+
"topic.unsubscribe": {
|
|
47
52
|
request: common.TOPIC_UNSUBSCRIBE_REQUEST,
|
|
48
53
|
response: common.TOPIC_UNSUBSCRIBE_RESPONSE,
|
|
49
54
|
},
|
|
50
|
-
|
|
55
|
+
"auth.challenge": {
|
|
51
56
|
request: common.AUTH_CHALLENGE_REQUEST,
|
|
52
57
|
response: common.AUTH_CHALLENGE_RESPONSE,
|
|
53
58
|
},
|
|
54
|
-
|
|
59
|
+
"auth.register": {
|
|
55
60
|
request: common.AUTH_REGISTER_REQUEST,
|
|
56
61
|
response: common.AUTH_REGISTER_RESPONSE,
|
|
57
62
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
request: common.
|
|
61
|
-
response: common.
|
|
63
|
+
"auth.assert": { request: common.AUTH_ASSERT_REQUEST, response: common.AUTH_ASSERT_RESPONSE },
|
|
64
|
+
"auth.token.refresh": {
|
|
65
|
+
request: common.AUTH_TOKEN_REFRESH_REQUEST,
|
|
66
|
+
response: common.AUTH_TOKEN_REFRESH_RESPONSE,
|
|
62
67
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
"auth.extend": { request: common.AUTH_EXTEND_REQUEST, response: common.AUTH_EXTEND_RESPONSE },
|
|
69
|
+
"auth.resolve": { request: common.AUTH_RESOLVE_REQUEST, response: common.AUTH_RESOLVE_RESPONSE },
|
|
70
|
+
"auth.rotate": { request: common.AUTH_ROTATE_REQUEST, response: common.AUTH_ROTATE_RESPONSE },
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
"message.send": {
|
|
68
73
|
request: messaging.MESSAGE_SEND_REQUEST,
|
|
69
74
|
response: messaging.MESSAGE_SEND_RESPONSE,
|
|
70
75
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
request: messaging.
|
|
74
|
-
response: messaging.
|
|
76
|
+
"say.post": { request: messaging.SAY_POST_REQUEST, response: messaging.SAY_POST_RESPONSE },
|
|
77
|
+
"say.unread.clear": {
|
|
78
|
+
request: messaging.SAY_UNREAD_CLEAR_REQUEST,
|
|
79
|
+
response: messaging.SAY_UNREAD_CLEAR_RESPONSE,
|
|
80
|
+
},
|
|
81
|
+
"notify.send": {
|
|
82
|
+
request: messaging.NOTIFY_SEND_REQUEST,
|
|
83
|
+
response: messaging.NOTIFY_SEND_RESPONSE,
|
|
75
84
|
},
|
|
76
|
-
notify_send: { request: messaging.NOTIFY_SEND_REQUEST, response: messaging.NOTIFY_SEND_RESPONSE },
|
|
77
85
|
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
"session.kill": {
|
|
87
|
+
request: control.SESSION_KILL_REQUEST,
|
|
88
|
+
response: control.SESSION_KILL_RESPONSE,
|
|
89
|
+
},
|
|
90
|
+
"session.rename": {
|
|
80
91
|
request: control.SESSION_RENAME_REQUEST,
|
|
81
92
|
response: control.SESSION_RENAME_RESPONSE,
|
|
82
93
|
},
|
|
83
|
-
|
|
94
|
+
"session.env.read": {
|
|
84
95
|
request: control.SESSION_ENV_READ_REQUEST,
|
|
85
96
|
response: control.SESSION_ENV_READ_RESPONSE,
|
|
86
97
|
},
|
|
87
|
-
|
|
98
|
+
"session.search": {
|
|
88
99
|
request: control.SESSION_SEARCH_REQUEST,
|
|
89
100
|
response: control.SESSION_SEARCH_RESPONSE,
|
|
90
101
|
},
|
|
91
|
-
|
|
102
|
+
"session.dump.write": {
|
|
92
103
|
request: control.SESSION_DUMP_WRITE_REQUEST,
|
|
93
104
|
response: control.SESSION_DUMP_WRITE_RESPONSE,
|
|
94
105
|
},
|
|
95
|
-
|
|
106
|
+
"dump.presets.read": {
|
|
96
107
|
request: control.DUMP_PRESETS_READ_REQUEST,
|
|
97
108
|
response: control.DUMP_PRESETS_READ_RESPONSE,
|
|
98
109
|
},
|
|
99
|
-
|
|
110
|
+
"transcript.read": {
|
|
100
111
|
request: control.TRANSCRIPT_READ_REQUEST,
|
|
101
112
|
response: control.TRANSCRIPT_READ_RESPONSE,
|
|
102
113
|
},
|
|
103
|
-
|
|
114
|
+
"transcript.items.read": {
|
|
104
115
|
request: control.TRANSCRIPT_ITEMS_READ_REQUEST,
|
|
105
116
|
response: control.TRANSCRIPT_ITEMS_READ_RESPONSE,
|
|
106
117
|
},
|
|
107
|
-
|
|
108
|
-
request: control.
|
|
109
|
-
response: control.
|
|
118
|
+
"session.fork.origin.read": {
|
|
119
|
+
request: control.SESSION_FORK_ORIGIN_READ_REQUEST,
|
|
120
|
+
response: control.SESSION_FORK_ORIGIN_READ_RESPONSE,
|
|
110
121
|
},
|
|
111
|
-
|
|
112
|
-
request: control.
|
|
113
|
-
response: control.
|
|
122
|
+
"session.forget": {
|
|
123
|
+
request: control.SESSION_FORGET_REQUEST,
|
|
124
|
+
response: control.SESSION_FORGET_RESPONSE,
|
|
114
125
|
},
|
|
115
126
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
request: control.
|
|
125
|
-
response: control.
|
|
126
|
-
},
|
|
127
|
-
|
|
127
|
+
"dir.list": { request: control.DIR_LIST_REQUEST, response: control.DIR_LIST_RESPONSE },
|
|
128
|
+
"file.read": { request: control.FILE_READ_REQUEST, response: control.FILE_READ_RESPONSE },
|
|
129
|
+
"file.write": { request: control.FILE_WRITE_REQUEST, response: control.FILE_WRITE_RESPONSE },
|
|
130
|
+
"file.create": { request: control.FILE_CREATE_REQUEST, response: control.FILE_CREATE_RESPONSE },
|
|
131
|
+
"file.edit": { request: control.FILE_EDIT_REQUEST, response: control.FILE_EDIT_RESPONSE },
|
|
132
|
+
"file.delete": { request: control.FILE_DELETE_REQUEST, response: control.FILE_DELETE_RESPONSE },
|
|
133
|
+
"file.find": { request: control.FILE_FIND_REQUEST, response: control.FILE_FIND_RESPONSE },
|
|
134
|
+
"file.stat": {
|
|
135
|
+
request: control.FILE_STAT_REQUEST,
|
|
136
|
+
response: control.FILE_STAT_RESPONSE,
|
|
137
|
+
},
|
|
138
|
+
"dir.tree": { request: control.DIR_TREE_REQUEST, response: control.DIR_TREE_RESPONSE },
|
|
128
139
|
|
|
129
|
-
|
|
140
|
+
"launcher.config.read": {
|
|
130
141
|
request: control.LAUNCHER_CONFIG_READ_REQUEST,
|
|
131
142
|
response: control.LAUNCHER_CONFIG_READ_RESPONSE,
|
|
132
143
|
},
|
|
133
|
-
|
|
134
|
-
|
|
144
|
+
"launcher.run": {
|
|
145
|
+
request: control.LAUNCHER_RUN_REQUEST,
|
|
146
|
+
response: control.LAUNCHER_RUN_RESPONSE,
|
|
147
|
+
},
|
|
148
|
+
"sandbox.grant": {
|
|
135
149
|
request: control.SANDBOX_GRANT_REQUEST,
|
|
136
150
|
response: control.SANDBOX_GRANT_RESPONSE,
|
|
137
151
|
},
|
|
138
|
-
|
|
152
|
+
"sandbox.revoke": {
|
|
139
153
|
request: control.SANDBOX_REVOKE_REQUEST,
|
|
140
154
|
response: control.SANDBOX_REVOKE_RESPONSE,
|
|
141
155
|
},
|
|
142
|
-
|
|
156
|
+
"translate.run": {
|
|
143
157
|
request: control.TRANSLATE_RUN_REQUEST,
|
|
144
158
|
response: control.TRANSLATE_RUN_RESPONSE,
|
|
145
159
|
},
|
|
146
|
-
|
|
160
|
+
"llm.usage.read": {
|
|
147
161
|
request: control.LLM_USAGE_READ_REQUEST,
|
|
148
162
|
response: control.LLM_USAGE_READ_RESPONSE,
|
|
149
163
|
},
|
|
150
|
-
|
|
164
|
+
"llm.stats.read": {
|
|
151
165
|
request: control.LLM_STATS_READ_REQUEST,
|
|
152
166
|
response: control.LLM_STATS_READ_RESPONSE,
|
|
153
167
|
},
|
|
154
168
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
169
|
+
"kv.read": { request: control.KV_READ_REQUEST, response: control.KV_READ_RESPONSE },
|
|
170
|
+
"kv.write": { request: control.KV_WRITE_REQUEST, response: control.KV_WRITE_RESPONSE },
|
|
171
|
+
"kv.delete": { request: control.KV_DELETE_REQUEST, response: control.KV_DELETE_RESPONSE },
|
|
158
172
|
} as const satisfies Record<OpName, OpFixture>;
|
|
159
173
|
|
|
160
174
|
/** A representative frame for every topic, each one the snapshot a subscriber
|
|
@@ -163,13 +177,14 @@ export const TOPIC_FIXTURES = {
|
|
|
163
177
|
inbox: topics.INBOX_FRAME,
|
|
164
178
|
notify: topics.NOTIFY_FRAME,
|
|
165
179
|
peers: topics.PEERS_FRAME,
|
|
180
|
+
instances: topics.INSTANCES_FRAME,
|
|
166
181
|
agents: topics.AGENTS_FRAME,
|
|
167
|
-
|
|
182
|
+
"session.status": topics.SESSION_STATUS_FRAME,
|
|
168
183
|
transcript: topics.TRANSCRIPT_FRAME,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
"transcript.items": topics.TRANSCRIPT_ITEMS_FRAME,
|
|
185
|
+
"session.errors": topics.SESSION_ERRORS_FRAME,
|
|
186
|
+
"llm.requests": topics.LLM_REQUESTS_FRAME,
|
|
187
|
+
"llm.status": topics.LLM_STATUS_FRAME,
|
|
173
188
|
kv: topics.KV_FRAME,
|
|
174
|
-
|
|
189
|
+
"auth.records": topics.AUTH_RECORDS_FRAME,
|
|
175
190
|
} as const satisfies Record<TopicKind, unknown>;
|
|
@@ -2,8 +2,8 @@ import type { Static } from "@sinclair/typebox";
|
|
|
2
2
|
import type { MessageSendRequest, MessageSendResponse } from "../messaging/message.ts";
|
|
3
3
|
import type { NotifySendRequest, NotifySendResponse } from "../messaging/notify.ts";
|
|
4
4
|
import type {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
SayUnreadClearRequest,
|
|
6
|
+
SayUnreadClearResponse,
|
|
7
7
|
SayPostRequest,
|
|
8
8
|
SayPostResponse,
|
|
9
9
|
} from "../messaging/say.ts";
|
|
@@ -13,7 +13,7 @@ const { sid, other_sid, instance, mid, request_id } = FIXTURE_IDS;
|
|
|
13
13
|
|
|
14
14
|
export const MESSAGE_SEND_REQUEST: Static<typeof MessageSendRequest> = {
|
|
15
15
|
request_id,
|
|
16
|
-
op: "
|
|
16
|
+
op: "message.send",
|
|
17
17
|
to: other_sid,
|
|
18
18
|
text: "契約の fixture を export した",
|
|
19
19
|
reply_to: mid,
|
|
@@ -23,7 +23,7 @@ export const MESSAGE_SEND_REQUEST: Static<typeof MessageSendRequest> = {
|
|
|
23
23
|
* fields and the identity it was called with. */
|
|
24
24
|
export const MESSAGE_SEND_FORWARDED_REQUEST: Static<typeof MessageSendRequest> = {
|
|
25
25
|
request_id,
|
|
26
|
-
op: "
|
|
26
|
+
op: "message.send",
|
|
27
27
|
to: other_sid,
|
|
28
28
|
text: "契約の fixture を export した",
|
|
29
29
|
from_instance: instance,
|
|
@@ -49,7 +49,7 @@ export const MESSAGE_SEND_HELD_RESPONSE: Static<typeof MessageSendResponse> = {
|
|
|
49
49
|
|
|
50
50
|
export const SAY_POST_REQUEST: Static<typeof SayPostRequest> = {
|
|
51
51
|
request_id,
|
|
52
|
-
op: "
|
|
52
|
+
op: "say.post",
|
|
53
53
|
text: "終わりました",
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -59,20 +59,20 @@ export const SAY_POST_RESPONSE: Static<typeof SayPostResponse> = {
|
|
|
59
59
|
posted_at: FIXTURE_NOW,
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export const
|
|
62
|
+
export const SAY_UNREAD_CLEAR_REQUEST: Static<typeof SayUnreadClearRequest> = {
|
|
63
63
|
request_id,
|
|
64
|
-
op: "
|
|
64
|
+
op: "say.unread.clear",
|
|
65
65
|
sid,
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
export const
|
|
68
|
+
export const SAY_UNREAD_CLEAR_RESPONSE: Static<typeof SayUnreadClearResponse> = {
|
|
69
69
|
ok: true,
|
|
70
70
|
request_id,
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
export const NOTIFY_SEND_REQUEST: Static<typeof NotifySendRequest> = {
|
|
74
74
|
request_id,
|
|
75
|
-
op: "
|
|
75
|
+
op: "notify.send",
|
|
76
76
|
sid,
|
|
77
77
|
text: "確認して",
|
|
78
78
|
};
|
package/src/fixtures/topics.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Static } from "@sinclair/typebox";
|
|
2
2
|
import type { AuthRecordsFrame } from "../common/auth.ts";
|
|
3
3
|
import type { AgentsFrame } from "../control/agents.ts";
|
|
4
|
+
import type { InstancesFrame } from "../control/instances.ts";
|
|
4
5
|
import type { KvFrame } from "../control/kv.ts";
|
|
5
6
|
import type { LlmRequestsFrame, LlmStatusFrame } from "../control/llm.ts";
|
|
6
7
|
import type { PeersFrame } from "../control/peers.ts";
|
|
@@ -94,16 +95,6 @@ export const PEERS_FRAME: Static<typeof PeersFrame> = {
|
|
|
94
95
|
repo: "ccmsg",
|
|
95
96
|
ws: "daemon-v2",
|
|
96
97
|
cwd: "/repos/kawaz/ccmsg/daemon-v2",
|
|
97
|
-
state: "live_unmanaged",
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
last_live: [
|
|
101
|
-
{
|
|
102
|
-
sid: other_sid,
|
|
103
|
-
instance,
|
|
104
|
-
repo: "ccmsg",
|
|
105
|
-
ws: "daemon-v2",
|
|
106
|
-
cwd: "/repos/kawaz/ccmsg/daemon-v2",
|
|
107
98
|
state: "paused",
|
|
108
99
|
last_seen_at: FIXTURE_NOW - 1_200_000,
|
|
109
100
|
stopped_at: FIXTURE_NOW - 1_000_000,
|
|
@@ -111,6 +102,28 @@ export const PEERS_FRAME: Static<typeof PeersFrame> = {
|
|
|
111
102
|
effort: "high",
|
|
112
103
|
},
|
|
113
104
|
],
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** A later frame: one row moved on, and one the instance forgot. */
|
|
109
|
+
export const PEERS_CHANGE_FRAME: Static<typeof PeersFrame> = {
|
|
110
|
+
ev: "topic",
|
|
111
|
+
topic: "peers",
|
|
112
|
+
instance,
|
|
113
|
+
data: {
|
|
114
|
+
peers: [
|
|
115
|
+
{ ...PEER, state: "live", gateway_active_at: FIXTURE_NOW + 1_000 },
|
|
116
|
+
{ sid: "1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f", instance, removed: true },
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const INSTANCES_FRAME: Static<typeof InstancesFrame> = {
|
|
122
|
+
ev: "topic",
|
|
123
|
+
topic: "instances",
|
|
124
|
+
snapshot: true,
|
|
125
|
+
instance,
|
|
126
|
+
data: {
|
|
114
127
|
instances: [
|
|
115
128
|
{ id: instance, endpoint, host: "mba", reachable: true },
|
|
116
129
|
{ id: other_instance, endpoint: other_endpoint, host: "nuc", reachable: false },
|
|
@@ -144,9 +157,17 @@ export const AGENTS_FRAME: Static<typeof AgentsFrame> = {
|
|
|
144
157
|
},
|
|
145
158
|
};
|
|
146
159
|
|
|
160
|
+
/** A later frame: the harness no longer reports one of the rows above. */
|
|
161
|
+
export const AGENTS_CHANGE_FRAME: Static<typeof AgentsFrame> = {
|
|
162
|
+
ev: "topic",
|
|
163
|
+
topic: "agents",
|
|
164
|
+
instance,
|
|
165
|
+
data: { agents: [{ sid: other_sid, instance, removed: true }], polled_at: FIXTURE_NOW + 5_000 },
|
|
166
|
+
};
|
|
167
|
+
|
|
147
168
|
export const SESSION_STATUS_FRAME: Static<typeof SessionStatusFrame> = {
|
|
148
169
|
ev: "topic",
|
|
149
|
-
topic: `
|
|
170
|
+
topic: `session.status:${sid}`,
|
|
150
171
|
snapshot: true,
|
|
151
172
|
instance,
|
|
152
173
|
data: {
|
|
@@ -276,7 +297,7 @@ export const TRANSCRIPT_SIZE_FRAME = {
|
|
|
276
297
|
/** The typed topic, whose frames carry items rather than bytes. */
|
|
277
298
|
export const TRANSCRIPT_ITEMS_FRAME = {
|
|
278
299
|
ev: "topic",
|
|
279
|
-
topic: `
|
|
300
|
+
topic: `transcript.items:${sid}`,
|
|
280
301
|
instance,
|
|
281
302
|
data: { sid, items: TRANSCRIPT_ITEMS.slice(-2) },
|
|
282
303
|
} satisfies Static<typeof TranscriptItemsFrame>;
|
|
@@ -285,7 +306,7 @@ export const TRANSCRIPT_ITEMS_FRAME = {
|
|
|
285
306
|
* every frame after it, so a subscriber appends both the same way. */
|
|
286
307
|
export const TRANSCRIPT_ITEMS_SNAPSHOT_FRAME = {
|
|
287
308
|
ev: "topic",
|
|
288
|
-
topic: `
|
|
309
|
+
topic: `transcript.items:${sid}`,
|
|
289
310
|
snapshot: true,
|
|
290
311
|
instance,
|
|
291
312
|
data: { sid, items: TRANSCRIPT_ITEMS },
|
|
@@ -293,7 +314,7 @@ export const TRANSCRIPT_ITEMS_SNAPSHOT_FRAME = {
|
|
|
293
314
|
|
|
294
315
|
export const SESSION_ERRORS_FRAME: Static<typeof SessionErrorsFrame> = {
|
|
295
316
|
ev: "topic",
|
|
296
|
-
topic: "
|
|
317
|
+
topic: "session.errors",
|
|
297
318
|
snapshot: true,
|
|
298
319
|
instance,
|
|
299
320
|
data: {
|
|
@@ -303,7 +324,7 @@ export const SESSION_ERRORS_FRAME: Static<typeof SessionErrorsFrame> = {
|
|
|
303
324
|
|
|
304
325
|
export const LLM_REQUESTS_FRAME: Static<typeof LlmRequestsFrame> = {
|
|
305
326
|
ev: "topic",
|
|
306
|
-
topic: "
|
|
327
|
+
topic: "llm.requests",
|
|
307
328
|
snapshot: true,
|
|
308
329
|
instance,
|
|
309
330
|
data: [
|
|
@@ -328,7 +349,7 @@ export const LLM_REQUESTS_FRAME: Static<typeof LlmRequestsFrame> = {
|
|
|
328
349
|
|
|
329
350
|
export const LLM_STATUS_FRAME: Static<typeof LlmStatusFrame> = {
|
|
330
351
|
ev: "topic",
|
|
331
|
-
topic: "
|
|
352
|
+
topic: "llm.status",
|
|
332
353
|
snapshot: true,
|
|
333
354
|
instance,
|
|
334
355
|
data: {
|
|
@@ -375,7 +396,7 @@ export const KV_FRAME: Static<typeof KvFrame> = {
|
|
|
375
396
|
|
|
376
397
|
export const AUTH_RECORDS_FRAME = {
|
|
377
398
|
ev: "topic",
|
|
378
|
-
topic: "
|
|
399
|
+
topic: "auth.records",
|
|
379
400
|
snapshot: true,
|
|
380
401
|
instance,
|
|
381
402
|
data: {
|
|
@@ -410,7 +431,7 @@ export const AUTH_RECORDS_FRAME = {
|
|
|
410
431
|
* issued it. */
|
|
411
432
|
export const AUTH_RECORDS_FAMILY_FRAME = {
|
|
412
433
|
ev: "topic",
|
|
413
|
-
topic: "
|
|
434
|
+
topic: "auth.records",
|
|
414
435
|
instance,
|
|
415
436
|
data: {
|
|
416
437
|
records: [
|
|
@@ -441,7 +462,7 @@ export const AUTH_RECORDS_FAMILY_FRAME = {
|
|
|
441
462
|
* family's is kept only as long as a refresh token could still arrive. */
|
|
442
463
|
export const AUTH_RECORDS_TOMBSTONE_FRAME = {
|
|
443
464
|
ev: "topic",
|
|
444
|
-
topic: "
|
|
465
|
+
topic: "auth.records",
|
|
445
466
|
instance,
|
|
446
467
|
data: {
|
|
447
468
|
records: [
|
package/src/identifiers.ts
CHANGED
|
@@ -81,12 +81,14 @@ export const Mid = Type.String({
|
|
|
81
81
|
});
|
|
82
82
|
export type Mid = Static<typeof Mid>;
|
|
83
83
|
|
|
84
|
-
/** Who a connection speaks as.
|
|
85
|
-
*
|
|
84
|
+
/** Who a connection speaks as. Settled once by the greeting that opened it —
|
|
85
|
+
* `hello.session`, `hello.user` or `hello.instance`, the op being what says
|
|
86
|
+
* which — and fixed for the connection's life; the op attribute table's
|
|
87
|
+
* `roles` is checked against it.
|
|
86
88
|
*
|
|
87
|
-
* Once
|
|
88
|
-
*
|
|
89
|
-
*
|
|
89
|
+
* Once means once: a second greeting on a connection whose identity is
|
|
90
|
+
* already settled is refused with `bad_request`, whether it is the same one
|
|
91
|
+
* again or another. */
|
|
90
92
|
export const Role = Type.Union(
|
|
91
93
|
[Type.Literal("session"), Type.Literal("user"), Type.Literal("instance")],
|
|
92
94
|
{ $id: "Role" },
|
|
@@ -100,7 +102,7 @@ export const Capability = Type.Union(
|
|
|
100
102
|
Type.Literal("fork"),
|
|
101
103
|
Type.Literal("launcher"),
|
|
102
104
|
/** A gateway webhook source is configured, so request activity arrives to
|
|
103
|
-
* be pushed on the `
|
|
105
|
+
* be pushed on the `llm.requests` topic. */
|
|
104
106
|
Type.Literal("llm_events"),
|
|
105
107
|
Type.Literal("llm_stats"),
|
|
106
108
|
Type.Literal("llm_status"),
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./common/topics.ts";
|
|
|
7
7
|
export * from "./control/agents.ts";
|
|
8
8
|
export * from "./control/dump.ts";
|
|
9
9
|
export * from "./control/files.ts";
|
|
10
|
+
export * from "./control/instances.ts";
|
|
10
11
|
export * from "./control/kv.ts";
|
|
11
12
|
export * from "./control/launcher.ts";
|
|
12
13
|
export * from "./control/llm.ts";
|
package/src/messaging/message.ts
CHANGED
|
@@ -65,8 +65,8 @@ export const MessageSendResult = Type.Object({
|
|
|
65
65
|
});
|
|
66
66
|
export type MessageSendResult = Static<typeof MessageSendResult>;
|
|
67
67
|
|
|
68
|
-
export const MessageSendRequest = request("
|
|
69
|
-
export const MessageSendResponse = response("
|
|
68
|
+
export const MessageSendRequest = request("message.send", MessageSendArgs);
|
|
69
|
+
export const MessageSendResponse = response("message.send", MessageSendResult);
|
|
70
70
|
|
|
71
71
|
/** A message as the recipient receives it, on topic `inbox`.
|
|
72
72
|
*
|
|
@@ -75,7 +75,7 @@ export const MessageSendResponse = response("message_send", MessageSendResult);
|
|
|
75
75
|
* whoever renders it — see `direct-delivery.ts` for the one route whose
|
|
76
76
|
* recipient reads text instead of this frame.
|
|
77
77
|
*
|
|
78
|
-
* A `from` of `user` is the exception: `
|
|
78
|
+
* A `from` of `user` is the exception: `message.send` addresses a sid, so there
|
|
79
79
|
* is no such thing as sending back to the person. An answer to one reaches them
|
|
80
80
|
* as a notification instead, which is the instance's to arrange — this contract
|
|
81
81
|
* only states that the sender can be a person, so a client stops treating one
|
package/src/messaging/notify.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { request, response, topicFrame } from "../envelope.ts";
|
|
|
3
3
|
import { Sid, Timestamp } from "../identifiers.ts";
|
|
4
4
|
|
|
5
5
|
/** A short line meant to reach a person watching, not the session's own turn.
|
|
6
|
-
* Delivery is best effort and unacknowledged; unlike `
|
|
6
|
+
* Delivery is best effort and unacknowledged; unlike `message.send`, nothing is
|
|
7
7
|
* held for later. */
|
|
8
8
|
export const NotifySendArgs = Type.Object({
|
|
9
9
|
/** The session the notification is about. Omit to mean the caller. */
|
|
@@ -15,8 +15,8 @@ export type NotifySendArgs = Static<typeof NotifySendArgs>;
|
|
|
15
15
|
export const NotifySendResult = Type.Object({});
|
|
16
16
|
export type NotifySendResult = Static<typeof NotifySendResult>;
|
|
17
17
|
|
|
18
|
-
export const NotifySendRequest = request("
|
|
19
|
-
export const NotifySendResponse = response("
|
|
18
|
+
export const NotifySendRequest = request("notify.send", NotifySendArgs);
|
|
19
|
+
export const NotifySendResponse = response("notify.send", NotifySendResult);
|
|
20
20
|
|
|
21
21
|
export const Notification = Type.Object(
|
|
22
22
|
{
|
package/src/messaging/say.ts
CHANGED
|
@@ -17,19 +17,19 @@ export const SayPostResult = Type.Object({
|
|
|
17
17
|
});
|
|
18
18
|
export type SayPostResult = Static<typeof SayPostResult>;
|
|
19
19
|
|
|
20
|
-
export const SayPostRequest = request("
|
|
21
|
-
export const SayPostResponse = response("
|
|
20
|
+
export const SayPostRequest = request("say.post", SayPostArgs);
|
|
21
|
+
export const SayPostResponse = response("say.post", SayPostResult);
|
|
22
22
|
|
|
23
|
-
/** Clears the unread mark a `
|
|
23
|
+
/** Clears the unread mark a `say.post` raised. The mark is instance state that
|
|
24
24
|
* a restart may forget — nothing depends on it surviving. */
|
|
25
|
-
export const
|
|
25
|
+
export const SayUnreadClearArgs = Type.Object({
|
|
26
26
|
/** The session whose unread mark is cleared. Omit to clear every one. */
|
|
27
27
|
sid: Type.Optional(Sid),
|
|
28
28
|
});
|
|
29
|
-
export type
|
|
29
|
+
export type SayUnreadClearArgs = Static<typeof SayUnreadClearArgs>;
|
|
30
30
|
|
|
31
|
-
export const
|
|
32
|
-
export type
|
|
31
|
+
export const SayUnreadClearResult = Type.Object({});
|
|
32
|
+
export type SayUnreadClearResult = Static<typeof SayUnreadClearResult>;
|
|
33
33
|
|
|
34
|
-
export const
|
|
35
|
-
export const
|
|
34
|
+
export const SayUnreadClearRequest = request("say.unread.clear", SayUnreadClearArgs);
|
|
35
|
+
export const SayUnreadClearResponse = response("say.unread.clear", SayUnreadClearResult);
|