@isoplan/protocol 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/dist/facts.d.ts +330 -0
- package/dist/facts.js +105 -0
- package/dist/facts.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +567 -0
- package/dist/messages.js +95 -0
- package/dist/messages.js.map +1 -0
- package/dist/project-id.d.ts +12 -0
- package/dist/project-id.js +37 -0
- package/dist/project-id.js.map +1 -0
- package/package.json +31 -4
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Adam Linscott
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/facts.d.ts
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const SourceSchema: z.ZodEnum<{
|
|
3
|
+
"claude-code": "claude-code";
|
|
4
|
+
}>;
|
|
5
|
+
export declare const SessionFactSchema: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
source: z.ZodEnum<{
|
|
8
|
+
"claude-code": "claude-code";
|
|
9
|
+
}>;
|
|
10
|
+
lead: z.ZodString;
|
|
11
|
+
title: z.ZodNullable<z.ZodString>;
|
|
12
|
+
titleFrom: z.ZodEnum<{
|
|
13
|
+
branch: "branch";
|
|
14
|
+
source: "source";
|
|
15
|
+
}>;
|
|
16
|
+
branch: z.ZodNullable<z.ZodString>;
|
|
17
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
18
|
+
lastActive: z.ZodISODateTime;
|
|
19
|
+
status: z.ZodEnum<{
|
|
20
|
+
active: "active";
|
|
21
|
+
idle: "idle";
|
|
22
|
+
}>;
|
|
23
|
+
lights: z.ZodEnum<{
|
|
24
|
+
off: "off";
|
|
25
|
+
on: "on";
|
|
26
|
+
}>;
|
|
27
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export declare const AgentFactSchema: z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
source: z.ZodEnum<{
|
|
32
|
+
"claude-code": "claude-code";
|
|
33
|
+
}>;
|
|
34
|
+
session: z.ZodString;
|
|
35
|
+
startedBy: z.ZodNullable<z.ZodString>;
|
|
36
|
+
agentType: z.ZodNullable<z.ZodString>;
|
|
37
|
+
task: z.ZodNullable<z.ZodString>;
|
|
38
|
+
status: z.ZodEnum<{
|
|
39
|
+
done: "done";
|
|
40
|
+
failed: "failed";
|
|
41
|
+
idle: "idle";
|
|
42
|
+
stalled: "stalled";
|
|
43
|
+
stopped: "stopped";
|
|
44
|
+
working: "working";
|
|
45
|
+
}>;
|
|
46
|
+
statusSince: z.ZodISODateTime;
|
|
47
|
+
lastActive: z.ZodISODateTime;
|
|
48
|
+
doing: z.ZodNullable<z.ZodObject<{
|
|
49
|
+
kind: z.ZodEnum<{
|
|
50
|
+
read: "read";
|
|
51
|
+
run: "run";
|
|
52
|
+
search: "search";
|
|
53
|
+
talk: "talk";
|
|
54
|
+
write: "write";
|
|
55
|
+
}>;
|
|
56
|
+
file: z.ZodOptional<z.ZodString>;
|
|
57
|
+
since: z.ZodISODateTime;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
60
|
+
input: z.ZodNumber;
|
|
61
|
+
cacheWrite: z.ZodNumber;
|
|
62
|
+
cacheWrite1h: z.ZodNumber;
|
|
63
|
+
cacheRead: z.ZodNumber;
|
|
64
|
+
output: z.ZodNumber;
|
|
65
|
+
model: z.ZodString;
|
|
66
|
+
context: z.ZodNumber;
|
|
67
|
+
over100k: z.ZodObject<{
|
|
68
|
+
input: z.ZodNumber;
|
|
69
|
+
cacheWrite: z.ZodNumber;
|
|
70
|
+
cacheWrite1h: z.ZodNumber;
|
|
71
|
+
cacheRead: z.ZodNumber;
|
|
72
|
+
output: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
at: z.ZodISODateTime;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
77
|
+
branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
78
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
/** An edit or a read: `file` is relative to the repo root, with forward slashes. */
|
|
81
|
+
export declare const FileFactSchema: z.ZodObject<{
|
|
82
|
+
agent: z.ZodString;
|
|
83
|
+
file: z.ZodString;
|
|
84
|
+
at: z.ZodISODateTime;
|
|
85
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
export declare const WaitFactSchema: z.ZodObject<{
|
|
88
|
+
waiter: z.ZodString;
|
|
89
|
+
on: z.ZodString;
|
|
90
|
+
since: z.ZodISODateTime;
|
|
91
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
export declare const ReportFactSchema: z.ZodObject<{
|
|
94
|
+
agent: z.ZodString;
|
|
95
|
+
at: z.ZodISODateTime;
|
|
96
|
+
text: z.ZodString;
|
|
97
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
export declare const FactsSchema: z.ZodObject<{
|
|
100
|
+
session: z.ZodObject<{
|
|
101
|
+
id: z.ZodString;
|
|
102
|
+
source: z.ZodEnum<{
|
|
103
|
+
"claude-code": "claude-code";
|
|
104
|
+
}>;
|
|
105
|
+
lead: z.ZodString;
|
|
106
|
+
title: z.ZodNullable<z.ZodString>;
|
|
107
|
+
titleFrom: z.ZodEnum<{
|
|
108
|
+
branch: "branch";
|
|
109
|
+
source: "source";
|
|
110
|
+
}>;
|
|
111
|
+
branch: z.ZodNullable<z.ZodString>;
|
|
112
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
113
|
+
lastActive: z.ZodISODateTime;
|
|
114
|
+
status: z.ZodEnum<{
|
|
115
|
+
active: "active";
|
|
116
|
+
idle: "idle";
|
|
117
|
+
}>;
|
|
118
|
+
lights: z.ZodEnum<{
|
|
119
|
+
off: "off";
|
|
120
|
+
on: "on";
|
|
121
|
+
}>;
|
|
122
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
agents: z.ZodArray<z.ZodObject<{
|
|
125
|
+
id: z.ZodString;
|
|
126
|
+
source: z.ZodEnum<{
|
|
127
|
+
"claude-code": "claude-code";
|
|
128
|
+
}>;
|
|
129
|
+
session: z.ZodString;
|
|
130
|
+
startedBy: z.ZodNullable<z.ZodString>;
|
|
131
|
+
agentType: z.ZodNullable<z.ZodString>;
|
|
132
|
+
task: z.ZodNullable<z.ZodString>;
|
|
133
|
+
status: z.ZodEnum<{
|
|
134
|
+
done: "done";
|
|
135
|
+
failed: "failed";
|
|
136
|
+
idle: "idle";
|
|
137
|
+
stalled: "stalled";
|
|
138
|
+
stopped: "stopped";
|
|
139
|
+
working: "working";
|
|
140
|
+
}>;
|
|
141
|
+
statusSince: z.ZodISODateTime;
|
|
142
|
+
lastActive: z.ZodISODateTime;
|
|
143
|
+
doing: z.ZodNullable<z.ZodObject<{
|
|
144
|
+
kind: z.ZodEnum<{
|
|
145
|
+
read: "read";
|
|
146
|
+
run: "run";
|
|
147
|
+
search: "search";
|
|
148
|
+
talk: "talk";
|
|
149
|
+
write: "write";
|
|
150
|
+
}>;
|
|
151
|
+
file: z.ZodOptional<z.ZodString>;
|
|
152
|
+
since: z.ZodISODateTime;
|
|
153
|
+
}, z.core.$strip>>;
|
|
154
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
155
|
+
input: z.ZodNumber;
|
|
156
|
+
cacheWrite: z.ZodNumber;
|
|
157
|
+
cacheWrite1h: z.ZodNumber;
|
|
158
|
+
cacheRead: z.ZodNumber;
|
|
159
|
+
output: z.ZodNumber;
|
|
160
|
+
model: z.ZodString;
|
|
161
|
+
context: z.ZodNumber;
|
|
162
|
+
over100k: z.ZodObject<{
|
|
163
|
+
input: z.ZodNumber;
|
|
164
|
+
cacheWrite: z.ZodNumber;
|
|
165
|
+
cacheWrite1h: z.ZodNumber;
|
|
166
|
+
cacheRead: z.ZodNumber;
|
|
167
|
+
output: z.ZodNumber;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
at: z.ZodISODateTime;
|
|
170
|
+
}, z.core.$strip>>;
|
|
171
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
172
|
+
branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
173
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
edits: z.ZodArray<z.ZodObject<{
|
|
176
|
+
agent: z.ZodString;
|
|
177
|
+
file: z.ZodString;
|
|
178
|
+
at: z.ZodISODateTime;
|
|
179
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
180
|
+
}, z.core.$strip>>;
|
|
181
|
+
reads: z.ZodArray<z.ZodObject<{
|
|
182
|
+
agent: z.ZodString;
|
|
183
|
+
file: z.ZodString;
|
|
184
|
+
at: z.ZodISODateTime;
|
|
185
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
186
|
+
}, z.core.$strip>>;
|
|
187
|
+
waits: z.ZodArray<z.ZodObject<{
|
|
188
|
+
waiter: z.ZodString;
|
|
189
|
+
on: z.ZodString;
|
|
190
|
+
since: z.ZodISODateTime;
|
|
191
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
192
|
+
}, z.core.$strip>>;
|
|
193
|
+
reports: z.ZodArray<z.ZodObject<{
|
|
194
|
+
agent: z.ZodString;
|
|
195
|
+
at: z.ZodISODateTime;
|
|
196
|
+
text: z.ZodString;
|
|
197
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
198
|
+
}, z.core.$strip>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
/** The records that changed, each replacing the one with the same key. */
|
|
201
|
+
export declare const FactUpsertSchema: z.ZodObject<{
|
|
202
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
203
|
+
id: z.ZodString;
|
|
204
|
+
source: z.ZodEnum<{
|
|
205
|
+
"claude-code": "claude-code";
|
|
206
|
+
}>;
|
|
207
|
+
lead: z.ZodString;
|
|
208
|
+
title: z.ZodNullable<z.ZodString>;
|
|
209
|
+
titleFrom: z.ZodEnum<{
|
|
210
|
+
branch: "branch";
|
|
211
|
+
source: "source";
|
|
212
|
+
}>;
|
|
213
|
+
branch: z.ZodNullable<z.ZodString>;
|
|
214
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
215
|
+
lastActive: z.ZodISODateTime;
|
|
216
|
+
status: z.ZodEnum<{
|
|
217
|
+
active: "active";
|
|
218
|
+
idle: "idle";
|
|
219
|
+
}>;
|
|
220
|
+
lights: z.ZodEnum<{
|
|
221
|
+
off: "off";
|
|
222
|
+
on: "on";
|
|
223
|
+
}>;
|
|
224
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
225
|
+
}, z.core.$strip>>;
|
|
226
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
227
|
+
id: z.ZodString;
|
|
228
|
+
source: z.ZodEnum<{
|
|
229
|
+
"claude-code": "claude-code";
|
|
230
|
+
}>;
|
|
231
|
+
session: z.ZodString;
|
|
232
|
+
startedBy: z.ZodNullable<z.ZodString>;
|
|
233
|
+
agentType: z.ZodNullable<z.ZodString>;
|
|
234
|
+
task: z.ZodNullable<z.ZodString>;
|
|
235
|
+
status: z.ZodEnum<{
|
|
236
|
+
done: "done";
|
|
237
|
+
failed: "failed";
|
|
238
|
+
idle: "idle";
|
|
239
|
+
stalled: "stalled";
|
|
240
|
+
stopped: "stopped";
|
|
241
|
+
working: "working";
|
|
242
|
+
}>;
|
|
243
|
+
statusSince: z.ZodISODateTime;
|
|
244
|
+
lastActive: z.ZodISODateTime;
|
|
245
|
+
doing: z.ZodNullable<z.ZodObject<{
|
|
246
|
+
kind: z.ZodEnum<{
|
|
247
|
+
read: "read";
|
|
248
|
+
run: "run";
|
|
249
|
+
search: "search";
|
|
250
|
+
talk: "talk";
|
|
251
|
+
write: "write";
|
|
252
|
+
}>;
|
|
253
|
+
file: z.ZodOptional<z.ZodString>;
|
|
254
|
+
since: z.ZodISODateTime;
|
|
255
|
+
}, z.core.$strip>>;
|
|
256
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
257
|
+
input: z.ZodNumber;
|
|
258
|
+
cacheWrite: z.ZodNumber;
|
|
259
|
+
cacheWrite1h: z.ZodNumber;
|
|
260
|
+
cacheRead: z.ZodNumber;
|
|
261
|
+
output: z.ZodNumber;
|
|
262
|
+
model: z.ZodString;
|
|
263
|
+
context: z.ZodNumber;
|
|
264
|
+
over100k: z.ZodObject<{
|
|
265
|
+
input: z.ZodNumber;
|
|
266
|
+
cacheWrite: z.ZodNumber;
|
|
267
|
+
cacheWrite1h: z.ZodNumber;
|
|
268
|
+
cacheRead: z.ZodNumber;
|
|
269
|
+
output: z.ZodNumber;
|
|
270
|
+
}, z.core.$strip>;
|
|
271
|
+
at: z.ZodISODateTime;
|
|
272
|
+
}, z.core.$strip>>;
|
|
273
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
274
|
+
branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
275
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
276
|
+
}, z.core.$strip>>>;
|
|
277
|
+
edits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
278
|
+
agent: z.ZodString;
|
|
279
|
+
file: z.ZodString;
|
|
280
|
+
at: z.ZodISODateTime;
|
|
281
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
282
|
+
}, z.core.$strip>>>;
|
|
283
|
+
reads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
284
|
+
agent: z.ZodString;
|
|
285
|
+
file: z.ZodString;
|
|
286
|
+
at: z.ZodISODateTime;
|
|
287
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
288
|
+
}, z.core.$strip>>>;
|
|
289
|
+
waits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
290
|
+
waiter: z.ZodString;
|
|
291
|
+
on: z.ZodString;
|
|
292
|
+
since: z.ZodISODateTime;
|
|
293
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
294
|
+
}, z.core.$strip>>>;
|
|
295
|
+
reports: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
296
|
+
agent: z.ZodString;
|
|
297
|
+
at: z.ZodISODateTime;
|
|
298
|
+
text: z.ZodString;
|
|
299
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
300
|
+
}, z.core.$strip>>>;
|
|
301
|
+
}, z.core.$strip>;
|
|
302
|
+
/**
|
|
303
|
+
* The keys of records that went away: an agent by its id, an edit or read by agent and file, a
|
|
304
|
+
* wait by waiter and on, a report by its agent. The session itself goes with the connection.
|
|
305
|
+
*/
|
|
306
|
+
export declare const FactRemoveSchema: z.ZodObject<{
|
|
307
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
308
|
+
edits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
309
|
+
agent: z.ZodString;
|
|
310
|
+
file: z.ZodString;
|
|
311
|
+
}, z.core.$strip>>>;
|
|
312
|
+
reads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
313
|
+
agent: z.ZodString;
|
|
314
|
+
file: z.ZodString;
|
|
315
|
+
}, z.core.$strip>>>;
|
|
316
|
+
waits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
317
|
+
waiter: z.ZodString;
|
|
318
|
+
on: z.ZodString;
|
|
319
|
+
}, z.core.$strip>>>;
|
|
320
|
+
reports: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
321
|
+
}, z.core.$strip>;
|
|
322
|
+
export type Source = z.infer<typeof SourceSchema>;
|
|
323
|
+
export type SessionFact = z.infer<typeof SessionFactSchema>;
|
|
324
|
+
export type AgentFact = z.infer<typeof AgentFactSchema>;
|
|
325
|
+
export type FileFact = z.infer<typeof FileFactSchema>;
|
|
326
|
+
export type WaitFact = z.infer<typeof WaitFactSchema>;
|
|
327
|
+
export type ReportFact = z.infer<typeof ReportFactSchema>;
|
|
328
|
+
export type Facts = z.infer<typeof FactsSchema>;
|
|
329
|
+
export type FactUpsert = z.infer<typeof FactUpsertSchema>;
|
|
330
|
+
export type FactRemove = z.infer<typeof FactRemoveSchema>;
|
package/dist/facts.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// One session's facts, as its data layer reports them: v1's office model minus everything derived
|
|
3
|
+
// (rooms, roles, meaning) and minus what the hello already says (the owner, the project).
|
|
4
|
+
/** ISO time, with Z or an offset. */
|
|
5
|
+
const Time = z.iso.datetime({ offset: true });
|
|
6
|
+
/** Tool-specific detail that views never rely on. */
|
|
7
|
+
const Extra = z.record(z.string(), z.unknown()).optional();
|
|
8
|
+
export const SourceSchema = z.enum(["claude-code"]);
|
|
9
|
+
export const SessionFactSchema = z.object({
|
|
10
|
+
id: z.string().min(1),
|
|
11
|
+
source: SourceSchema,
|
|
12
|
+
lead: z.string().min(1),
|
|
13
|
+
title: z.string().nullable(),
|
|
14
|
+
titleFrom: z.enum(["source", "branch"]),
|
|
15
|
+
branch: z.string().nullable(),
|
|
16
|
+
checkout: z.string().optional(),
|
|
17
|
+
lastActive: Time,
|
|
18
|
+
status: z.enum(["active", "idle"]),
|
|
19
|
+
lights: z.enum(["on", "off"]),
|
|
20
|
+
extra: Extra,
|
|
21
|
+
});
|
|
22
|
+
const TokenCount = z.number().int().nonnegative();
|
|
23
|
+
const TokenCounts = z.object({
|
|
24
|
+
input: TokenCount,
|
|
25
|
+
cacheWrite: TokenCount,
|
|
26
|
+
cacheWrite1h: TokenCount,
|
|
27
|
+
cacheRead: TokenCount,
|
|
28
|
+
output: TokenCount,
|
|
29
|
+
});
|
|
30
|
+
export const AgentFactSchema = z.object({
|
|
31
|
+
id: z.string().min(1),
|
|
32
|
+
source: SourceSchema,
|
|
33
|
+
session: z.string().min(1),
|
|
34
|
+
startedBy: z.string().min(1).nullable(),
|
|
35
|
+
agentType: z.string().nullable(),
|
|
36
|
+
task: z.string().nullable(),
|
|
37
|
+
status: z.enum(["working", "idle", "done", "stalled", "stopped", "failed"]),
|
|
38
|
+
statusSince: Time,
|
|
39
|
+
lastActive: Time,
|
|
40
|
+
doing: z
|
|
41
|
+
.object({
|
|
42
|
+
kind: z.enum(["write", "read", "run", "search", "talk"]),
|
|
43
|
+
file: z.string().optional(),
|
|
44
|
+
since: Time,
|
|
45
|
+
})
|
|
46
|
+
.nullable(),
|
|
47
|
+
usage: TokenCounts.extend({
|
|
48
|
+
model: z.string().min(1),
|
|
49
|
+
context: TokenCount,
|
|
50
|
+
over100k: TokenCounts,
|
|
51
|
+
at: Time,
|
|
52
|
+
}).nullable(),
|
|
53
|
+
checkout: z.string().optional(),
|
|
54
|
+
branch: z.string().nullable().optional(),
|
|
55
|
+
extra: Extra,
|
|
56
|
+
});
|
|
57
|
+
/** An edit or a read: `file` is relative to the repo root, with forward slashes. */
|
|
58
|
+
export const FileFactSchema = z.object({
|
|
59
|
+
agent: z.string().min(1),
|
|
60
|
+
file: z.string().min(1),
|
|
61
|
+
at: Time,
|
|
62
|
+
extra: Extra,
|
|
63
|
+
});
|
|
64
|
+
export const WaitFactSchema = z.object({
|
|
65
|
+
waiter: z.string().min(1),
|
|
66
|
+
on: z.string().min(1),
|
|
67
|
+
since: Time,
|
|
68
|
+
extra: Extra,
|
|
69
|
+
});
|
|
70
|
+
export const ReportFactSchema = z.object({
|
|
71
|
+
agent: z.string().min(1),
|
|
72
|
+
at: Time,
|
|
73
|
+
text: z.string(),
|
|
74
|
+
extra: Extra,
|
|
75
|
+
});
|
|
76
|
+
export const FactsSchema = z.object({
|
|
77
|
+
session: SessionFactSchema,
|
|
78
|
+
agents: z.array(AgentFactSchema),
|
|
79
|
+
edits: z.array(FileFactSchema),
|
|
80
|
+
reads: z.array(FileFactSchema),
|
|
81
|
+
waits: z.array(WaitFactSchema),
|
|
82
|
+
reports: z.array(ReportFactSchema),
|
|
83
|
+
});
|
|
84
|
+
/** The records that changed, each replacing the one with the same key. */
|
|
85
|
+
export const FactUpsertSchema = z.object({
|
|
86
|
+
session: SessionFactSchema.optional(),
|
|
87
|
+
agents: z.array(AgentFactSchema).optional(),
|
|
88
|
+
edits: z.array(FileFactSchema).optional(),
|
|
89
|
+
reads: z.array(FileFactSchema).optional(),
|
|
90
|
+
waits: z.array(WaitFactSchema).optional(),
|
|
91
|
+
reports: z.array(ReportFactSchema).optional(),
|
|
92
|
+
});
|
|
93
|
+
const FileKey = FileFactSchema.pick({ agent: true, file: true });
|
|
94
|
+
/**
|
|
95
|
+
* The keys of records that went away: an agent by its id, an edit or read by agent and file, a
|
|
96
|
+
* wait by waiter and on, a report by its agent. The session itself goes with the connection.
|
|
97
|
+
*/
|
|
98
|
+
export const FactRemoveSchema = z.object({
|
|
99
|
+
agents: z.array(z.string().min(1)).optional(),
|
|
100
|
+
edits: z.array(FileKey).optional(),
|
|
101
|
+
reads: z.array(FileKey).optional(),
|
|
102
|
+
waits: z.array(WaitFactSchema.pick({ waiter: true, on: true })).optional(),
|
|
103
|
+
reports: z.array(z.string().min(1)).optional(),
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=facts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts.js","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kGAAkG;AAClG,0FAA0F;AAE1F,qCAAqC;AACrC,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAE9C,qDAAqD;AACrD,MAAM,KAAK,G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AC/C,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The protocol version every message carries as `v`. Adding optional fields doesn't change it;
|
|
4
|
+
* changing what a field means, or removing one, does.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PROTOCOL_VERSION = 1;
|
|
7
|
+
export declare const ProjectSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
/** The first message on a connection: who is reporting, from where, about which session. */
|
|
12
|
+
export declare const HelloMessageSchema: z.ZodObject<{
|
|
13
|
+
type: z.ZodLiteral<"hello">;
|
|
14
|
+
v: z.ZodLiteral<1>;
|
|
15
|
+
source: z.ZodEnum<{
|
|
16
|
+
"claude-code": "claude-code";
|
|
17
|
+
}>;
|
|
18
|
+
account: z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
machine: z.ZodObject<{
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
session: z.ZodString;
|
|
26
|
+
project: z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
/** All of the session's facts. Sent on connect and on repair. */
|
|
32
|
+
export declare const FullMessageSchema: z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"full">;
|
|
34
|
+
v: z.ZodLiteral<1>;
|
|
35
|
+
seq: z.ZodNumber;
|
|
36
|
+
facts: z.ZodObject<{
|
|
37
|
+
session: z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
source: z.ZodEnum<{
|
|
40
|
+
"claude-code": "claude-code";
|
|
41
|
+
}>;
|
|
42
|
+
lead: z.ZodString;
|
|
43
|
+
title: z.ZodNullable<z.ZodString>;
|
|
44
|
+
titleFrom: z.ZodEnum<{
|
|
45
|
+
branch: "branch";
|
|
46
|
+
source: "source";
|
|
47
|
+
}>;
|
|
48
|
+
branch: z.ZodNullable<z.ZodString>;
|
|
49
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
50
|
+
lastActive: z.ZodISODateTime;
|
|
51
|
+
status: z.ZodEnum<{
|
|
52
|
+
active: "active";
|
|
53
|
+
idle: "idle";
|
|
54
|
+
}>;
|
|
55
|
+
lights: z.ZodEnum<{
|
|
56
|
+
off: "off";
|
|
57
|
+
on: "on";
|
|
58
|
+
}>;
|
|
59
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
agents: z.ZodArray<z.ZodObject<{
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
source: z.ZodEnum<{
|
|
64
|
+
"claude-code": "claude-code";
|
|
65
|
+
}>;
|
|
66
|
+
session: z.ZodString;
|
|
67
|
+
startedBy: z.ZodNullable<z.ZodString>;
|
|
68
|
+
agentType: z.ZodNullable<z.ZodString>;
|
|
69
|
+
task: z.ZodNullable<z.ZodString>;
|
|
70
|
+
status: z.ZodEnum<{
|
|
71
|
+
done: "done";
|
|
72
|
+
failed: "failed";
|
|
73
|
+
idle: "idle";
|
|
74
|
+
stalled: "stalled";
|
|
75
|
+
stopped: "stopped";
|
|
76
|
+
working: "working";
|
|
77
|
+
}>;
|
|
78
|
+
statusSince: z.ZodISODateTime;
|
|
79
|
+
lastActive: z.ZodISODateTime;
|
|
80
|
+
doing: z.ZodNullable<z.ZodObject<{
|
|
81
|
+
kind: z.ZodEnum<{
|
|
82
|
+
read: "read";
|
|
83
|
+
run: "run";
|
|
84
|
+
search: "search";
|
|
85
|
+
talk: "talk";
|
|
86
|
+
write: "write";
|
|
87
|
+
}>;
|
|
88
|
+
file: z.ZodOptional<z.ZodString>;
|
|
89
|
+
since: z.ZodISODateTime;
|
|
90
|
+
}, z.core.$strip>>;
|
|
91
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
92
|
+
input: z.ZodNumber;
|
|
93
|
+
cacheWrite: z.ZodNumber;
|
|
94
|
+
cacheWrite1h: z.ZodNumber;
|
|
95
|
+
cacheRead: z.ZodNumber;
|
|
96
|
+
output: z.ZodNumber;
|
|
97
|
+
model: z.ZodString;
|
|
98
|
+
context: z.ZodNumber;
|
|
99
|
+
over100k: z.ZodObject<{
|
|
100
|
+
input: z.ZodNumber;
|
|
101
|
+
cacheWrite: z.ZodNumber;
|
|
102
|
+
cacheWrite1h: z.ZodNumber;
|
|
103
|
+
cacheRead: z.ZodNumber;
|
|
104
|
+
output: z.ZodNumber;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
at: z.ZodISODateTime;
|
|
107
|
+
}, z.core.$strip>>;
|
|
108
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
109
|
+
branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
110
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
edits: z.ZodArray<z.ZodObject<{
|
|
113
|
+
agent: z.ZodString;
|
|
114
|
+
file: z.ZodString;
|
|
115
|
+
at: z.ZodISODateTime;
|
|
116
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
117
|
+
}, z.core.$strip>>;
|
|
118
|
+
reads: z.ZodArray<z.ZodObject<{
|
|
119
|
+
agent: z.ZodString;
|
|
120
|
+
file: z.ZodString;
|
|
121
|
+
at: z.ZodISODateTime;
|
|
122
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
123
|
+
}, z.core.$strip>>;
|
|
124
|
+
waits: z.ZodArray<z.ZodObject<{
|
|
125
|
+
waiter: z.ZodString;
|
|
126
|
+
on: z.ZodString;
|
|
127
|
+
since: z.ZodISODateTime;
|
|
128
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
reports: z.ZodArray<z.ZodObject<{
|
|
131
|
+
agent: z.ZodString;
|
|
132
|
+
at: z.ZodISODateTime;
|
|
133
|
+
text: z.ZodString;
|
|
134
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
135
|
+
}, z.core.$strip>>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
/** What changed since the last message. `seq` goes up by one per message, so a gap shows. */
|
|
139
|
+
export declare const ChangesMessageSchema: z.ZodObject<{
|
|
140
|
+
type: z.ZodLiteral<"changes">;
|
|
141
|
+
v: z.ZodLiteral<1>;
|
|
142
|
+
seq: z.ZodNumber;
|
|
143
|
+
upsert: z.ZodObject<{
|
|
144
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
source: z.ZodEnum<{
|
|
147
|
+
"claude-code": "claude-code";
|
|
148
|
+
}>;
|
|
149
|
+
lead: z.ZodString;
|
|
150
|
+
title: z.ZodNullable<z.ZodString>;
|
|
151
|
+
titleFrom: z.ZodEnum<{
|
|
152
|
+
branch: "branch";
|
|
153
|
+
source: "source";
|
|
154
|
+
}>;
|
|
155
|
+
branch: z.ZodNullable<z.ZodString>;
|
|
156
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
157
|
+
lastActive: z.ZodISODateTime;
|
|
158
|
+
status: z.ZodEnum<{
|
|
159
|
+
active: "active";
|
|
160
|
+
idle: "idle";
|
|
161
|
+
}>;
|
|
162
|
+
lights: z.ZodEnum<{
|
|
163
|
+
off: "off";
|
|
164
|
+
on: "on";
|
|
165
|
+
}>;
|
|
166
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
167
|
+
}, z.core.$strip>>;
|
|
168
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
169
|
+
id: z.ZodString;
|
|
170
|
+
source: z.ZodEnum<{
|
|
171
|
+
"claude-code": "claude-code";
|
|
172
|
+
}>;
|
|
173
|
+
session: z.ZodString;
|
|
174
|
+
startedBy: z.ZodNullable<z.ZodString>;
|
|
175
|
+
agentType: z.ZodNullable<z.ZodString>;
|
|
176
|
+
task: z.ZodNullable<z.ZodString>;
|
|
177
|
+
status: z.ZodEnum<{
|
|
178
|
+
done: "done";
|
|
179
|
+
failed: "failed";
|
|
180
|
+
idle: "idle";
|
|
181
|
+
stalled: "stalled";
|
|
182
|
+
stopped: "stopped";
|
|
183
|
+
working: "working";
|
|
184
|
+
}>;
|
|
185
|
+
statusSince: z.ZodISODateTime;
|
|
186
|
+
lastActive: z.ZodISODateTime;
|
|
187
|
+
doing: z.ZodNullable<z.ZodObject<{
|
|
188
|
+
kind: z.ZodEnum<{
|
|
189
|
+
read: "read";
|
|
190
|
+
run: "run";
|
|
191
|
+
search: "search";
|
|
192
|
+
talk: "talk";
|
|
193
|
+
write: "write";
|
|
194
|
+
}>;
|
|
195
|
+
file: z.ZodOptional<z.ZodString>;
|
|
196
|
+
since: z.ZodISODateTime;
|
|
197
|
+
}, z.core.$strip>>;
|
|
198
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
199
|
+
input: z.ZodNumber;
|
|
200
|
+
cacheWrite: z.ZodNumber;
|
|
201
|
+
cacheWrite1h: z.ZodNumber;
|
|
202
|
+
cacheRead: z.ZodNumber;
|
|
203
|
+
output: z.ZodNumber;
|
|
204
|
+
model: z.ZodString;
|
|
205
|
+
context: z.ZodNumber;
|
|
206
|
+
over100k: z.ZodObject<{
|
|
207
|
+
input: z.ZodNumber;
|
|
208
|
+
cacheWrite: z.ZodNumber;
|
|
209
|
+
cacheWrite1h: z.ZodNumber;
|
|
210
|
+
cacheRead: z.ZodNumber;
|
|
211
|
+
output: z.ZodNumber;
|
|
212
|
+
}, z.core.$strip>;
|
|
213
|
+
at: z.ZodISODateTime;
|
|
214
|
+
}, z.core.$strip>>;
|
|
215
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
216
|
+
branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
217
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
218
|
+
}, z.core.$strip>>>;
|
|
219
|
+
edits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
220
|
+
agent: z.ZodString;
|
|
221
|
+
file: z.ZodString;
|
|
222
|
+
at: z.ZodISODateTime;
|
|
223
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
224
|
+
}, z.core.$strip>>>;
|
|
225
|
+
reads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
226
|
+
agent: z.ZodString;
|
|
227
|
+
file: z.ZodString;
|
|
228
|
+
at: z.ZodISODateTime;
|
|
229
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
230
|
+
}, z.core.$strip>>>;
|
|
231
|
+
waits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
232
|
+
waiter: z.ZodString;
|
|
233
|
+
on: z.ZodString;
|
|
234
|
+
since: z.ZodISODateTime;
|
|
235
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
236
|
+
}, z.core.$strip>>>;
|
|
237
|
+
reports: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
238
|
+
agent: z.ZodString;
|
|
239
|
+
at: z.ZodISODateTime;
|
|
240
|
+
text: z.ZodString;
|
|
241
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
242
|
+
}, z.core.$strip>>>;
|
|
243
|
+
}, z.core.$strip>;
|
|
244
|
+
remove: z.ZodObject<{
|
|
245
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
246
|
+
edits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
247
|
+
agent: z.ZodString;
|
|
248
|
+
file: z.ZodString;
|
|
249
|
+
}, z.core.$strip>>>;
|
|
250
|
+
reads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
251
|
+
agent: z.ZodString;
|
|
252
|
+
file: z.ZodString;
|
|
253
|
+
}, z.core.$strip>>>;
|
|
254
|
+
waits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
255
|
+
waiter: z.ZodString;
|
|
256
|
+
on: z.ZodString;
|
|
257
|
+
}, z.core.$strip>>>;
|
|
258
|
+
reports: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
259
|
+
}, z.core.$strip>;
|
|
260
|
+
}, z.core.$strip>;
|
|
261
|
+
export declare const DataLayerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
262
|
+
type: z.ZodLiteral<"hello">;
|
|
263
|
+
v: z.ZodLiteral<1>;
|
|
264
|
+
source: z.ZodEnum<{
|
|
265
|
+
"claude-code": "claude-code";
|
|
266
|
+
}>;
|
|
267
|
+
account: z.ZodObject<{
|
|
268
|
+
id: z.ZodString;
|
|
269
|
+
name: z.ZodString;
|
|
270
|
+
}, z.core.$strip>;
|
|
271
|
+
machine: z.ZodObject<{
|
|
272
|
+
name: z.ZodString;
|
|
273
|
+
}, z.core.$strip>;
|
|
274
|
+
session: z.ZodString;
|
|
275
|
+
project: z.ZodObject<{
|
|
276
|
+
id: z.ZodString;
|
|
277
|
+
name: z.ZodString;
|
|
278
|
+
}, z.core.$strip>;
|
|
279
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
280
|
+
type: z.ZodLiteral<"full">;
|
|
281
|
+
v: z.ZodLiteral<1>;
|
|
282
|
+
seq: z.ZodNumber;
|
|
283
|
+
facts: z.ZodObject<{
|
|
284
|
+
session: z.ZodObject<{
|
|
285
|
+
id: z.ZodString;
|
|
286
|
+
source: z.ZodEnum<{
|
|
287
|
+
"claude-code": "claude-code";
|
|
288
|
+
}>;
|
|
289
|
+
lead: z.ZodString;
|
|
290
|
+
title: z.ZodNullable<z.ZodString>;
|
|
291
|
+
titleFrom: z.ZodEnum<{
|
|
292
|
+
branch: "branch";
|
|
293
|
+
source: "source";
|
|
294
|
+
}>;
|
|
295
|
+
branch: z.ZodNullable<z.ZodString>;
|
|
296
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
297
|
+
lastActive: z.ZodISODateTime;
|
|
298
|
+
status: z.ZodEnum<{
|
|
299
|
+
active: "active";
|
|
300
|
+
idle: "idle";
|
|
301
|
+
}>;
|
|
302
|
+
lights: z.ZodEnum<{
|
|
303
|
+
off: "off";
|
|
304
|
+
on: "on";
|
|
305
|
+
}>;
|
|
306
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
307
|
+
}, z.core.$strip>;
|
|
308
|
+
agents: z.ZodArray<z.ZodObject<{
|
|
309
|
+
id: z.ZodString;
|
|
310
|
+
source: z.ZodEnum<{
|
|
311
|
+
"claude-code": "claude-code";
|
|
312
|
+
}>;
|
|
313
|
+
session: z.ZodString;
|
|
314
|
+
startedBy: z.ZodNullable<z.ZodString>;
|
|
315
|
+
agentType: z.ZodNullable<z.ZodString>;
|
|
316
|
+
task: z.ZodNullable<z.ZodString>;
|
|
317
|
+
status: z.ZodEnum<{
|
|
318
|
+
done: "done";
|
|
319
|
+
failed: "failed";
|
|
320
|
+
idle: "idle";
|
|
321
|
+
stalled: "stalled";
|
|
322
|
+
stopped: "stopped";
|
|
323
|
+
working: "working";
|
|
324
|
+
}>;
|
|
325
|
+
statusSince: z.ZodISODateTime;
|
|
326
|
+
lastActive: z.ZodISODateTime;
|
|
327
|
+
doing: z.ZodNullable<z.ZodObject<{
|
|
328
|
+
kind: z.ZodEnum<{
|
|
329
|
+
read: "read";
|
|
330
|
+
run: "run";
|
|
331
|
+
search: "search";
|
|
332
|
+
talk: "talk";
|
|
333
|
+
write: "write";
|
|
334
|
+
}>;
|
|
335
|
+
file: z.ZodOptional<z.ZodString>;
|
|
336
|
+
since: z.ZodISODateTime;
|
|
337
|
+
}, z.core.$strip>>;
|
|
338
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
339
|
+
input: z.ZodNumber;
|
|
340
|
+
cacheWrite: z.ZodNumber;
|
|
341
|
+
cacheWrite1h: z.ZodNumber;
|
|
342
|
+
cacheRead: z.ZodNumber;
|
|
343
|
+
output: z.ZodNumber;
|
|
344
|
+
model: z.ZodString;
|
|
345
|
+
context: z.ZodNumber;
|
|
346
|
+
over100k: z.ZodObject<{
|
|
347
|
+
input: z.ZodNumber;
|
|
348
|
+
cacheWrite: z.ZodNumber;
|
|
349
|
+
cacheWrite1h: z.ZodNumber;
|
|
350
|
+
cacheRead: z.ZodNumber;
|
|
351
|
+
output: z.ZodNumber;
|
|
352
|
+
}, z.core.$strip>;
|
|
353
|
+
at: z.ZodISODateTime;
|
|
354
|
+
}, z.core.$strip>>;
|
|
355
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
356
|
+
branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
357
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
358
|
+
}, z.core.$strip>>;
|
|
359
|
+
edits: z.ZodArray<z.ZodObject<{
|
|
360
|
+
agent: z.ZodString;
|
|
361
|
+
file: z.ZodString;
|
|
362
|
+
at: z.ZodISODateTime;
|
|
363
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
364
|
+
}, z.core.$strip>>;
|
|
365
|
+
reads: z.ZodArray<z.ZodObject<{
|
|
366
|
+
agent: z.ZodString;
|
|
367
|
+
file: z.ZodString;
|
|
368
|
+
at: z.ZodISODateTime;
|
|
369
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
370
|
+
}, z.core.$strip>>;
|
|
371
|
+
waits: z.ZodArray<z.ZodObject<{
|
|
372
|
+
waiter: z.ZodString;
|
|
373
|
+
on: z.ZodString;
|
|
374
|
+
since: z.ZodISODateTime;
|
|
375
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
376
|
+
}, z.core.$strip>>;
|
|
377
|
+
reports: z.ZodArray<z.ZodObject<{
|
|
378
|
+
agent: z.ZodString;
|
|
379
|
+
at: z.ZodISODateTime;
|
|
380
|
+
text: z.ZodString;
|
|
381
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
382
|
+
}, z.core.$strip>>;
|
|
383
|
+
}, z.core.$strip>;
|
|
384
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
385
|
+
type: z.ZodLiteral<"changes">;
|
|
386
|
+
v: z.ZodLiteral<1>;
|
|
387
|
+
seq: z.ZodNumber;
|
|
388
|
+
upsert: z.ZodObject<{
|
|
389
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
390
|
+
id: z.ZodString;
|
|
391
|
+
source: z.ZodEnum<{
|
|
392
|
+
"claude-code": "claude-code";
|
|
393
|
+
}>;
|
|
394
|
+
lead: z.ZodString;
|
|
395
|
+
title: z.ZodNullable<z.ZodString>;
|
|
396
|
+
titleFrom: z.ZodEnum<{
|
|
397
|
+
branch: "branch";
|
|
398
|
+
source: "source";
|
|
399
|
+
}>;
|
|
400
|
+
branch: z.ZodNullable<z.ZodString>;
|
|
401
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
402
|
+
lastActive: z.ZodISODateTime;
|
|
403
|
+
status: z.ZodEnum<{
|
|
404
|
+
active: "active";
|
|
405
|
+
idle: "idle";
|
|
406
|
+
}>;
|
|
407
|
+
lights: z.ZodEnum<{
|
|
408
|
+
off: "off";
|
|
409
|
+
on: "on";
|
|
410
|
+
}>;
|
|
411
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
412
|
+
}, z.core.$strip>>;
|
|
413
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
414
|
+
id: z.ZodString;
|
|
415
|
+
source: z.ZodEnum<{
|
|
416
|
+
"claude-code": "claude-code";
|
|
417
|
+
}>;
|
|
418
|
+
session: z.ZodString;
|
|
419
|
+
startedBy: z.ZodNullable<z.ZodString>;
|
|
420
|
+
agentType: z.ZodNullable<z.ZodString>;
|
|
421
|
+
task: z.ZodNullable<z.ZodString>;
|
|
422
|
+
status: z.ZodEnum<{
|
|
423
|
+
done: "done";
|
|
424
|
+
failed: "failed";
|
|
425
|
+
idle: "idle";
|
|
426
|
+
stalled: "stalled";
|
|
427
|
+
stopped: "stopped";
|
|
428
|
+
working: "working";
|
|
429
|
+
}>;
|
|
430
|
+
statusSince: z.ZodISODateTime;
|
|
431
|
+
lastActive: z.ZodISODateTime;
|
|
432
|
+
doing: z.ZodNullable<z.ZodObject<{
|
|
433
|
+
kind: z.ZodEnum<{
|
|
434
|
+
read: "read";
|
|
435
|
+
run: "run";
|
|
436
|
+
search: "search";
|
|
437
|
+
talk: "talk";
|
|
438
|
+
write: "write";
|
|
439
|
+
}>;
|
|
440
|
+
file: z.ZodOptional<z.ZodString>;
|
|
441
|
+
since: z.ZodISODateTime;
|
|
442
|
+
}, z.core.$strip>>;
|
|
443
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
444
|
+
input: z.ZodNumber;
|
|
445
|
+
cacheWrite: z.ZodNumber;
|
|
446
|
+
cacheWrite1h: z.ZodNumber;
|
|
447
|
+
cacheRead: z.ZodNumber;
|
|
448
|
+
output: z.ZodNumber;
|
|
449
|
+
model: z.ZodString;
|
|
450
|
+
context: z.ZodNumber;
|
|
451
|
+
over100k: z.ZodObject<{
|
|
452
|
+
input: z.ZodNumber;
|
|
453
|
+
cacheWrite: z.ZodNumber;
|
|
454
|
+
cacheWrite1h: z.ZodNumber;
|
|
455
|
+
cacheRead: z.ZodNumber;
|
|
456
|
+
output: z.ZodNumber;
|
|
457
|
+
}, z.core.$strip>;
|
|
458
|
+
at: z.ZodISODateTime;
|
|
459
|
+
}, z.core.$strip>>;
|
|
460
|
+
checkout: z.ZodOptional<z.ZodString>;
|
|
461
|
+
branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
462
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
463
|
+
}, z.core.$strip>>>;
|
|
464
|
+
edits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
465
|
+
agent: z.ZodString;
|
|
466
|
+
file: z.ZodString;
|
|
467
|
+
at: z.ZodISODateTime;
|
|
468
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
469
|
+
}, z.core.$strip>>>;
|
|
470
|
+
reads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
471
|
+
agent: z.ZodString;
|
|
472
|
+
file: z.ZodString;
|
|
473
|
+
at: z.ZodISODateTime;
|
|
474
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
475
|
+
}, z.core.$strip>>>;
|
|
476
|
+
waits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
477
|
+
waiter: z.ZodString;
|
|
478
|
+
on: z.ZodString;
|
|
479
|
+
since: z.ZodISODateTime;
|
|
480
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
481
|
+
}, z.core.$strip>>>;
|
|
482
|
+
reports: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
483
|
+
agent: z.ZodString;
|
|
484
|
+
at: z.ZodISODateTime;
|
|
485
|
+
text: z.ZodString;
|
|
486
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
487
|
+
}, z.core.$strip>>>;
|
|
488
|
+
}, z.core.$strip>;
|
|
489
|
+
remove: z.ZodObject<{
|
|
490
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
491
|
+
edits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
492
|
+
agent: z.ZodString;
|
|
493
|
+
file: z.ZodString;
|
|
494
|
+
}, z.core.$strip>>>;
|
|
495
|
+
reads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
496
|
+
agent: z.ZodString;
|
|
497
|
+
file: z.ZodString;
|
|
498
|
+
}, z.core.$strip>>>;
|
|
499
|
+
waits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
500
|
+
waiter: z.ZodString;
|
|
501
|
+
on: z.ZodString;
|
|
502
|
+
}, z.core.$strip>>>;
|
|
503
|
+
reports: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
504
|
+
}, z.core.$strip>;
|
|
505
|
+
}, z.core.$strip>], "type">;
|
|
506
|
+
/** Asks the data layer to send its facts in full. */
|
|
507
|
+
export declare const RepairMessageSchema: z.ZodObject<{
|
|
508
|
+
type: z.ZodLiteral<"repair">;
|
|
509
|
+
v: z.ZodLiteral<1>;
|
|
510
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
511
|
+
}, z.core.$strip>;
|
|
512
|
+
/** A note for the later editor of `file`, which the data layer adds to `agent`'s next tool result. */
|
|
513
|
+
export declare const ConflictMessageSchema: z.ZodObject<{
|
|
514
|
+
type: z.ZodLiteral<"conflict">;
|
|
515
|
+
v: z.ZodLiteral<1>;
|
|
516
|
+
agent: z.ZodString;
|
|
517
|
+
file: z.ZodString;
|
|
518
|
+
text: z.ZodString;
|
|
519
|
+
}, z.core.$strip>;
|
|
520
|
+
/** Something the data layer should show. */
|
|
521
|
+
export declare const ErrorMessageSchema: z.ZodObject<{
|
|
522
|
+
type: z.ZodLiteral<"error">;
|
|
523
|
+
v: z.ZodLiteral<1>;
|
|
524
|
+
code: z.ZodString;
|
|
525
|
+
message: z.ZodString;
|
|
526
|
+
}, z.core.$strip>;
|
|
527
|
+
export declare const OfficeServerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
528
|
+
type: z.ZodLiteral<"repair">;
|
|
529
|
+
v: z.ZodLiteral<1>;
|
|
530
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
531
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
532
|
+
type: z.ZodLiteral<"conflict">;
|
|
533
|
+
v: z.ZodLiteral<1>;
|
|
534
|
+
agent: z.ZodString;
|
|
535
|
+
file: z.ZodString;
|
|
536
|
+
text: z.ZodString;
|
|
537
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
538
|
+
type: z.ZodLiteral<"error">;
|
|
539
|
+
v: z.ZodLiteral<1>;
|
|
540
|
+
code: z.ZodString;
|
|
541
|
+
message: z.ZodString;
|
|
542
|
+
}, z.core.$strip>], "type">;
|
|
543
|
+
export type Project = z.infer<typeof ProjectSchema>;
|
|
544
|
+
export type HelloMessage = z.infer<typeof HelloMessageSchema>;
|
|
545
|
+
export type FullMessage = z.infer<typeof FullMessageSchema>;
|
|
546
|
+
export type ChangesMessage = z.infer<typeof ChangesMessageSchema>;
|
|
547
|
+
export type DataLayerMessage = z.infer<typeof DataLayerMessageSchema>;
|
|
548
|
+
export type RepairMessage = z.infer<typeof RepairMessageSchema>;
|
|
549
|
+
export type ConflictMessage = z.infer<typeof ConflictMessageSchema>;
|
|
550
|
+
export type ErrorMessage = z.infer<typeof ErrorMessageSchema>;
|
|
551
|
+
export type OfficeServerMessage = z.infer<typeof OfficeServerMessageSchema>;
|
|
552
|
+
/**
|
|
553
|
+
* A parsed message, or why it was refused: `unsupported-version` when it carries a protocol
|
|
554
|
+
* version this side doesn't speak, `invalid` for anything else wrong with it.
|
|
555
|
+
*/
|
|
556
|
+
export type ParseResult<T> = {
|
|
557
|
+
ok: true;
|
|
558
|
+
message: T;
|
|
559
|
+
} | {
|
|
560
|
+
ok: false;
|
|
561
|
+
kind: "invalid" | "unsupported-version";
|
|
562
|
+
error: string;
|
|
563
|
+
};
|
|
564
|
+
/** Validates a message an office server received from a data layer. */
|
|
565
|
+
export declare function parseDataLayerMessage(value: unknown): ParseResult<DataLayerMessage>;
|
|
566
|
+
/** Validates a message a data layer received from an office server. */
|
|
567
|
+
export declare function parseOfficeServerMessage(value: unknown): ParseResult<OfficeServerMessage>;
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { FactRemoveSchema, FactsSchema, FactUpsertSchema, SourceSchema } from "./facts.js";
|
|
3
|
+
/**
|
|
4
|
+
* The protocol version every message carries as `v`. Adding optional fields doesn't change it;
|
|
5
|
+
* changing what a field means, or removing one, does.
|
|
6
|
+
*/
|
|
7
|
+
export const PROTOCOL_VERSION = 1;
|
|
8
|
+
const Version = z.literal(PROTOCOL_VERSION);
|
|
9
|
+
const Seq = z.number().int().nonnegative();
|
|
10
|
+
export const ProjectSchema = z.object({
|
|
11
|
+
id: z.string().min(1),
|
|
12
|
+
name: z.string().min(1),
|
|
13
|
+
});
|
|
14
|
+
// Data layer → office server.
|
|
15
|
+
/** The first message on a connection: who is reporting, from where, about which session. */
|
|
16
|
+
export const HelloMessageSchema = z.object({
|
|
17
|
+
type: z.literal("hello"),
|
|
18
|
+
v: Version,
|
|
19
|
+
source: SourceSchema,
|
|
20
|
+
account: z.object({ id: z.string().min(1), name: z.string() }),
|
|
21
|
+
machine: z.object({ name: z.string().min(1) }),
|
|
22
|
+
session: z.string().min(1),
|
|
23
|
+
project: ProjectSchema,
|
|
24
|
+
});
|
|
25
|
+
/** All of the session's facts. Sent on connect and on repair. */
|
|
26
|
+
export const FullMessageSchema = z.object({
|
|
27
|
+
type: z.literal("full"),
|
|
28
|
+
v: Version,
|
|
29
|
+
seq: Seq,
|
|
30
|
+
facts: FactsSchema,
|
|
31
|
+
});
|
|
32
|
+
/** What changed since the last message. `seq` goes up by one per message, so a gap shows. */
|
|
33
|
+
export const ChangesMessageSchema = z.object({
|
|
34
|
+
type: z.literal("changes"),
|
|
35
|
+
v: Version,
|
|
36
|
+
seq: Seq,
|
|
37
|
+
upsert: FactUpsertSchema,
|
|
38
|
+
remove: FactRemoveSchema,
|
|
39
|
+
});
|
|
40
|
+
export const DataLayerMessageSchema = z.discriminatedUnion("type", [
|
|
41
|
+
HelloMessageSchema,
|
|
42
|
+
FullMessageSchema,
|
|
43
|
+
ChangesMessageSchema,
|
|
44
|
+
]);
|
|
45
|
+
// Office server → data layer.
|
|
46
|
+
/** Asks the data layer to send its facts in full. */
|
|
47
|
+
export const RepairMessageSchema = z.object({
|
|
48
|
+
type: z.literal("repair"),
|
|
49
|
+
v: Version,
|
|
50
|
+
reason: z.string().optional(),
|
|
51
|
+
});
|
|
52
|
+
/** A note for the later editor of `file`, which the data layer adds to `agent`'s next tool result. */
|
|
53
|
+
export const ConflictMessageSchema = z.object({
|
|
54
|
+
type: z.literal("conflict"),
|
|
55
|
+
v: Version,
|
|
56
|
+
agent: z.string().min(1),
|
|
57
|
+
file: z.string().min(1),
|
|
58
|
+
text: z.string().min(1),
|
|
59
|
+
});
|
|
60
|
+
/** Something the data layer should show. */
|
|
61
|
+
export const ErrorMessageSchema = z.object({
|
|
62
|
+
type: z.literal("error"),
|
|
63
|
+
v: Version,
|
|
64
|
+
code: z.string().min(1),
|
|
65
|
+
message: z.string(),
|
|
66
|
+
});
|
|
67
|
+
export const OfficeServerMessageSchema = z.discriminatedUnion("type", [
|
|
68
|
+
RepairMessageSchema,
|
|
69
|
+
ConflictMessageSchema,
|
|
70
|
+
ErrorMessageSchema,
|
|
71
|
+
]);
|
|
72
|
+
/** Validates a message an office server received from a data layer. */
|
|
73
|
+
export function parseDataLayerMessage(value) {
|
|
74
|
+
return parse(DataLayerMessageSchema, value);
|
|
75
|
+
}
|
|
76
|
+
/** Validates a message a data layer received from an office server. */
|
|
77
|
+
export function parseOfficeServerMessage(value) {
|
|
78
|
+
return parse(OfficeServerMessageSchema, value);
|
|
79
|
+
}
|
|
80
|
+
function parse(schema, value) {
|
|
81
|
+
// The version is checked first, so a newer peer is told so rather than given a field-by-field
|
|
82
|
+
// list of what changed.
|
|
83
|
+
if (typeof value === "object" && value !== null && "v" in value && typeof value.v === "number" && value.v !== PROTOCOL_VERSION) {
|
|
84
|
+
return {
|
|
85
|
+
ok: false,
|
|
86
|
+
kind: "unsupported-version",
|
|
87
|
+
error: `protocol version ${JSON.stringify(value.v)} is not supported; this side speaks version ${PROTOCOL_VERSION}`,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const result = schema.safeParse(value);
|
|
91
|
+
if (result.success)
|
|
92
|
+
return { ok: true, message: result.data };
|
|
93
|
+
return { ok: false, kind: "invalid", error: z.prettifyError(result.error) };
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3F;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC5C,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,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,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,OAAO,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,KAAK,CAAI,MAAoB,EAAE,KAAc;IACpD,8FAA8F;IAC9F,wBAAwB;IACxB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,KAAK,gBAAgB,EAAE,CAAC;QAC/H,OAAO;YACL,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,qBAAqB;YAC3B,KAAK,EAAE,oBAAoB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,+CAA+C,gBAAgB,EAAE;SACpH,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9D,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Project } from "./messages.js";
|
|
2
|
+
/**
|
|
3
|
+
* A project's id and name. With a git remote the id is `host/owner/repo` (any deeper path kept, as
|
|
4
|
+
* for GitLab subgroups), the same whichever form or letter case the remote is written in, so a
|
|
5
|
+
* repository cloned on several machines is one project. A repo with no remote, a remote that is a
|
|
6
|
+
* local path, or one that can't be read is `local:<machine>/<root>`, its working tree's root path.
|
|
7
|
+
* Never throws, so a remote's credentials never reach an error message.
|
|
8
|
+
*/
|
|
9
|
+
export declare function projectId(remoteUrl: string | null, local: {
|
|
10
|
+
machine: string;
|
|
11
|
+
root: string;
|
|
12
|
+
}): Project;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A project's id and name. With a git remote the id is `host/owner/repo` (any deeper path kept, as
|
|
3
|
+
* for GitLab subgroups), the same whichever form or letter case the remote is written in, so a
|
|
4
|
+
* repository cloned on several machines is one project. A repo with no remote, a remote that is a
|
|
5
|
+
* local path, or one that can't be read is `local:<machine>/<root>`, its working tree's root path.
|
|
6
|
+
* Never throws, so a remote's credentials never reach an error message.
|
|
7
|
+
*/
|
|
8
|
+
export function projectId(remoteUrl, local) {
|
|
9
|
+
const remote = remoteUrl === null || isLocalPath(remoteUrl.trim()) ? null : splitRemote(remoteUrl.trim());
|
|
10
|
+
const segments = remote?.path
|
|
11
|
+
.replace(/\/+$/, "")
|
|
12
|
+
.replace(/\.git$/, "")
|
|
13
|
+
.split("/")
|
|
14
|
+
.filter(Boolean);
|
|
15
|
+
if (!remote || !segments || segments.length === 0) {
|
|
16
|
+
const root = local.root.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
17
|
+
return { id: `local:${local.machine}/${root}`, name: root.split("/").pop() || root };
|
|
18
|
+
}
|
|
19
|
+
// Hosts and the big forges treat owner and repo names case-insensitively.
|
|
20
|
+
return { id: [remote.host, ...segments].join("/").toLowerCase(), name: segments[segments.length - 1] };
|
|
21
|
+
}
|
|
22
|
+
// An empty remote, a path (`/srv/x.git`, `./x`, `~/x`, `C:\x`, `\\server\x`) or a `file:` URL.
|
|
23
|
+
function isLocalPath(remote) {
|
|
24
|
+
return remote === "" || /^(?:[/.~\\]|[A-Za-z]:[\\/]|file:)/.test(remote);
|
|
25
|
+
}
|
|
26
|
+
// `scheme://[user[:password]@]host[:port]/path`, or scp-like `[user@]host:path`; null when neither.
|
|
27
|
+
function splitRemote(remote) {
|
|
28
|
+
if (remote.includes("://")) {
|
|
29
|
+
if (!URL.canParse(remote))
|
|
30
|
+
return null;
|
|
31
|
+
const url = new URL(remote);
|
|
32
|
+
return url.hostname ? { host: url.hostname, path: url.pathname } : null;
|
|
33
|
+
}
|
|
34
|
+
const scp = /^(?:[^@/]+@)?([^:/]+):(.+)$/.exec(remote);
|
|
35
|
+
return scp ? { host: scp[1], path: scp[2] } : null;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=project-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-id.js","sourceRoot":"","sources":["../src/project-id.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,SAAwB,EAAE,KAAwC;IAC1F,MAAM,MAAM,GAAG,SAAS,KAAK,IAAI,IAAI,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1G,MAAM,QAAQ,GAAG,MAAM,EAAE,IAAI;SAC1B,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChE,OAAO,EAAE,EAAE,EAAE,SAAS,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;IACvF,CAAC;IACD,0EAA0E;IAC1E,OAAO,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAE,EAAE,CAAC;AAC1G,CAAC;AAED,+FAA+F;AAC/F,SAAS,WAAW,CAAC,MAAc;IACjC,OAAO,MAAM,KAAK,EAAE,IAAI,mCAAmC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC3E,CAAC;AAED,oGAAoG;AACpG,SAAS,WAAW,CAAC,MAAc;IACjC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;QACvC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5B,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1E,CAAC;IACD,MAAM,GAAG,GAAG,6BAA6B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvD,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAE,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isoplan/protocol",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The wire protocol between Isoplan's Claude Code plugin and an office server: message and fact types, with zod parsers.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/adamlinscott/isoplan-plugin.git",
|
|
9
|
+
"directory": "packages/protocol"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc -p tsconfig.build.json",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"prepublishOnly": "tsc -p tsconfig.build.json"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"zod": "^4.6.7"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/README.md
DELETED