@moxt-ai/mobius-protocol 0.0.10 → 0.0.12

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.
@@ -20,11 +20,41 @@ export declare function parseNativeHistoryText(text: string): {
20
20
  readonly text: string;
21
21
  readonly images: readonly NativeHistoryImage[];
22
22
  };
23
- declare const historyMessage: z.ZodReadonly<z.ZodObject<{
24
- role: z.ZodEnum<{
25
- assistant: "assistant";
26
- user: "user";
27
- }>;
23
+ declare const nativeMessageActivitySchema: z.ZodReadonly<z.ZodObject<{
24
+ activityId: z.ZodString;
25
+ activityType: z.ZodString;
26
+ content: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
27
+ artifactId: z.ZodDefault<z.ZodString>;
28
+ data: z.ZodString;
29
+ mimeType: z.ZodString;
30
+ name: z.ZodString;
31
+ newText: z.ZodString;
32
+ oldText: z.ZodString;
33
+ path: z.ZodString;
34
+ terminalId: z.ZodString;
35
+ text: z.ZodString;
36
+ type: z.ZodEnum<{
37
+ diff: "diff";
38
+ image: "image";
39
+ resource: "resource";
40
+ resource_link: "resource_link";
41
+ terminal: "terminal";
42
+ text: "text";
43
+ video: "video";
44
+ }>;
45
+ uri: z.ZodString;
46
+ }, z.core.$strict>>>>;
47
+ input: z.ZodString;
48
+ locations: z.ZodReadonly<z.ZodArray<z.ZodString>>;
49
+ name: z.ZodString;
50
+ output: z.ZodString;
51
+ sequence: z.ZodNumber;
52
+ status: z.ZodString;
53
+ title: z.ZodString;
54
+ toolKind: z.ZodString;
55
+ }, z.core.$strict>>;
56
+ declare const historyMessage: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
57
+ role: z.ZodLiteral<"user">;
28
58
  text: z.ZodString;
29
59
  images: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
30
60
  data: z.ZodString;
@@ -36,14 +66,78 @@ declare const historyMessage: z.ZodReadonly<z.ZodObject<{
36
66
  }>;
37
67
  name: z.ZodString;
38
68
  }, z.core.$strict>>>>>;
39
- }, z.core.$strict>>;
69
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
70
+ activities: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
71
+ activityId: z.ZodString;
72
+ activityType: z.ZodString;
73
+ content: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
74
+ artifactId: z.ZodDefault<z.ZodString>;
75
+ data: z.ZodString;
76
+ mimeType: z.ZodString;
77
+ name: z.ZodString;
78
+ newText: z.ZodString;
79
+ oldText: z.ZodString;
80
+ path: z.ZodString;
81
+ terminalId: z.ZodString;
82
+ text: z.ZodString;
83
+ type: z.ZodEnum<{
84
+ diff: "diff";
85
+ image: "image";
86
+ resource: "resource";
87
+ resource_link: "resource_link";
88
+ terminal: "terminal";
89
+ text: "text";
90
+ video: "video";
91
+ }>;
92
+ uri: z.ZodString;
93
+ }, z.core.$strict>>>>;
94
+ input: z.ZodString;
95
+ locations: z.ZodReadonly<z.ZodArray<z.ZodString>>;
96
+ name: z.ZodString;
97
+ output: z.ZodString;
98
+ sequence: z.ZodNumber;
99
+ status: z.ZodString;
100
+ title: z.ZodString;
101
+ toolKind: z.ZodString;
102
+ }, z.core.$strict>>>>>;
103
+ content: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
104
+ artifactId: z.ZodDefault<z.ZodString>;
105
+ data: z.ZodString;
106
+ mimeType: z.ZodString;
107
+ name: z.ZodString;
108
+ newText: z.ZodString;
109
+ oldText: z.ZodString;
110
+ path: z.ZodString;
111
+ terminalId: z.ZodString;
112
+ text: z.ZodString;
113
+ type: z.ZodEnum<{
114
+ diff: "diff";
115
+ image: "image";
116
+ resource: "resource";
117
+ resource_link: "resource_link";
118
+ terminal: "terminal";
119
+ text: "text";
120
+ video: "video";
121
+ }>;
122
+ uri: z.ZodString;
123
+ }, z.core.$strict>>>>>;
124
+ role: z.ZodLiteral<"assistant">;
125
+ text: z.ZodString;
126
+ images: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
127
+ data: z.ZodString;
128
+ mimeType: z.ZodEnum<{
129
+ "image/gif": "image/gif";
130
+ "image/jpeg": "image/jpeg";
131
+ "image/png": "image/png";
132
+ "image/webp": "image/webp";
133
+ }>;
134
+ name: z.ZodString;
135
+ }, z.core.$strict>>>>>;
136
+ }, z.core.$strict>>], "role">;
40
137
  declare const sessionHistorySchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
41
138
  status: z.ZodLiteral<"available">;
42
- messages: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
43
- role: z.ZodEnum<{
44
- assistant: "assistant";
45
- user: "user";
46
- }>;
139
+ messages: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
140
+ role: z.ZodLiteral<"user">;
47
141
  text: z.ZodString;
48
142
  images: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
49
143
  data: z.ZodString;
@@ -55,15 +149,184 @@ declare const sessionHistorySchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.Zod
55
149
  }>;
56
150
  name: z.ZodString;
57
151
  }, z.core.$strict>>>>>;
58
- }, z.core.$strict>>>>;
152
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
153
+ activities: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
154
+ activityId: z.ZodString;
155
+ activityType: z.ZodString;
156
+ content: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
157
+ artifactId: z.ZodDefault<z.ZodString>;
158
+ data: z.ZodString;
159
+ mimeType: z.ZodString;
160
+ name: z.ZodString;
161
+ newText: z.ZodString;
162
+ oldText: z.ZodString;
163
+ path: z.ZodString;
164
+ terminalId: z.ZodString;
165
+ text: z.ZodString;
166
+ type: z.ZodEnum<{
167
+ diff: "diff";
168
+ image: "image";
169
+ resource: "resource";
170
+ resource_link: "resource_link";
171
+ terminal: "terminal";
172
+ text: "text";
173
+ video: "video";
174
+ }>;
175
+ uri: z.ZodString;
176
+ }, z.core.$strict>>>>;
177
+ input: z.ZodString;
178
+ locations: z.ZodReadonly<z.ZodArray<z.ZodString>>;
179
+ name: z.ZodString;
180
+ output: z.ZodString;
181
+ sequence: z.ZodNumber;
182
+ status: z.ZodString;
183
+ title: z.ZodString;
184
+ toolKind: z.ZodString;
185
+ }, z.core.$strict>>>>>;
186
+ content: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
187
+ artifactId: z.ZodDefault<z.ZodString>;
188
+ data: z.ZodString;
189
+ mimeType: z.ZodString;
190
+ name: z.ZodString;
191
+ newText: z.ZodString;
192
+ oldText: z.ZodString;
193
+ path: z.ZodString;
194
+ terminalId: z.ZodString;
195
+ text: z.ZodString;
196
+ type: z.ZodEnum<{
197
+ diff: "diff";
198
+ image: "image";
199
+ resource: "resource";
200
+ resource_link: "resource_link";
201
+ terminal: "terminal";
202
+ text: "text";
203
+ video: "video";
204
+ }>;
205
+ uri: z.ZodString;
206
+ }, z.core.$strict>>>>>;
207
+ role: z.ZodLiteral<"assistant">;
208
+ text: z.ZodString;
209
+ images: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
210
+ data: z.ZodString;
211
+ mimeType: z.ZodEnum<{
212
+ "image/gif": "image/gif";
213
+ "image/jpeg": "image/jpeg";
214
+ "image/png": "image/png";
215
+ "image/webp": "image/webp";
216
+ }>;
217
+ name: z.ZodString;
218
+ }, z.core.$strict>>>>>;
219
+ }, z.core.$strict>>], "role">>>;
59
220
  truncated: z.ZodBoolean;
60
221
  coveredCommandIds: z.ZodReadonly<z.ZodArray<z.ZodString>>;
61
222
  coveredMessageIds: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
62
223
  }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
63
224
  status: z.ZodLiteral<"unavailable">;
225
+ cause: z.ZodReadonly<z.ZodObject<{
226
+ code: z.ZodString;
227
+ message: z.ZodString;
228
+ }, z.core.$strict>>;
64
229
  }, z.core.$strict>>], "status">;
65
230
  export type NativeSessionHistory = z.infer<typeof sessionHistorySchema>;
66
231
  export type NativeHistoryMessage = z.infer<typeof historyMessage>;
232
+ export type NativeMessageActivity = z.infer<typeof nativeMessageActivitySchema>;
233
+ declare const nativeMessagePageSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
234
+ status: z.ZodLiteral<"available">;
235
+ messages: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
236
+ role: z.ZodLiteral<"user">;
237
+ text: z.ZodString;
238
+ images: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
239
+ data: z.ZodString;
240
+ mimeType: z.ZodEnum<{
241
+ "image/gif": "image/gif";
242
+ "image/jpeg": "image/jpeg";
243
+ "image/png": "image/png";
244
+ "image/webp": "image/webp";
245
+ }>;
246
+ name: z.ZodString;
247
+ }, z.core.$strict>>>>>;
248
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
249
+ activities: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
250
+ activityId: z.ZodString;
251
+ activityType: z.ZodString;
252
+ content: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
253
+ artifactId: z.ZodDefault<z.ZodString>;
254
+ data: z.ZodString;
255
+ mimeType: z.ZodString;
256
+ name: z.ZodString;
257
+ newText: z.ZodString;
258
+ oldText: z.ZodString;
259
+ path: z.ZodString;
260
+ terminalId: z.ZodString;
261
+ text: z.ZodString;
262
+ type: z.ZodEnum<{
263
+ diff: "diff";
264
+ image: "image";
265
+ resource: "resource";
266
+ resource_link: "resource_link";
267
+ terminal: "terminal";
268
+ text: "text";
269
+ video: "video";
270
+ }>;
271
+ uri: z.ZodString;
272
+ }, z.core.$strict>>>>;
273
+ input: z.ZodString;
274
+ locations: z.ZodReadonly<z.ZodArray<z.ZodString>>;
275
+ name: z.ZodString;
276
+ output: z.ZodString;
277
+ sequence: z.ZodNumber;
278
+ status: z.ZodString;
279
+ title: z.ZodString;
280
+ toolKind: z.ZodString;
281
+ }, z.core.$strict>>>>>;
282
+ content: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
283
+ artifactId: z.ZodDefault<z.ZodString>;
284
+ data: z.ZodString;
285
+ mimeType: z.ZodString;
286
+ name: z.ZodString;
287
+ newText: z.ZodString;
288
+ oldText: z.ZodString;
289
+ path: z.ZodString;
290
+ terminalId: z.ZodString;
291
+ text: z.ZodString;
292
+ type: z.ZodEnum<{
293
+ diff: "diff";
294
+ image: "image";
295
+ resource: "resource";
296
+ resource_link: "resource_link";
297
+ terminal: "terminal";
298
+ text: "text";
299
+ video: "video";
300
+ }>;
301
+ uri: z.ZodString;
302
+ }, z.core.$strict>>>>>;
303
+ role: z.ZodLiteral<"assistant">;
304
+ text: z.ZodString;
305
+ images: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
306
+ data: z.ZodString;
307
+ mimeType: z.ZodEnum<{
308
+ "image/gif": "image/gif";
309
+ "image/jpeg": "image/jpeg";
310
+ "image/png": "image/png";
311
+ "image/webp": "image/webp";
312
+ }>;
313
+ name: z.ZodString;
314
+ }, z.core.$strict>>>>>;
315
+ }, z.core.$strict>>], "role">>>;
316
+ truncated: z.ZodBoolean;
317
+ coveredCommandIds: z.ZodReadonly<z.ZodArray<z.ZodString>>;
318
+ coveredMessageIds: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
319
+ nextCursor: z.ZodNullable<z.ZodString>;
320
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
321
+ status: z.ZodLiteral<"unavailable">;
322
+ cause: z.ZodReadonly<z.ZodObject<{
323
+ code: z.ZodString;
324
+ message: z.ZodString;
325
+ }, z.core.$strict>>;
326
+ nextCursor: z.ZodNull;
327
+ }, z.core.$strict>>], "status">;
328
+ export type NativeMessagePage = z.infer<typeof nativeMessagePageSchema>;
67
329
  export declare const decodeNativeSessionHistory: (value: unknown) => NativeSessionHistory;
68
- export { sessionHistorySchema };
330
+ export declare const decodeNativeMessagePage: (value: unknown) => NativeMessagePage;
331
+ export { nativeMessagePageSchema, sessionHistorySchema };
69
332
  //# sourceMappingURL=session-history.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-history.d.ts","sourceRoot":"","sources":["../src/session-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,+BAA+B,SAAU,CAAC;AACvD,eAAO,MAAM,6BAA6B,OAAQ,CAAC;AACnD,eAAO,MAAM,qCAAqC,KAAK,CAAC;AACxD,eAAO,MAAM,qCAAqC,UAAY,CAAC;AAE/D,QAAA,MAAM,YAAY;;;;;;;;;mBAUH,CAAC;AAEhB,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE9D;oEACoE;AACpE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAC;CAClD,CAyBA;AAED,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;mBAML,CAAC;AAEhB,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;+BA8BrB,CAAC;AAEN,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CA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,CAAC;AAClE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAKU,CAAC;AACxC,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,0BAA0B,UAAW,OAAO,KAAG,oBAM3D,CAAC;AACF,eAAO,MAAM,uBAAuB,UAAW,OAAO,KAAG,iBAMxD,CAAC;AACF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { ProtocolMessageError } from "./codecs/messages.js";
3
+ import { displayContentSchema } from "./control-messages.js";
3
4
  export const SESSION_HISTORY_CHARACTER_LIMIT = 256_000;
4
5
  export const SESSION_HISTORY_MESSAGE_LIMIT = 1_000;
5
6
  export const SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT = 10;
@@ -41,37 +42,83 @@ export function parseNativeHistoryText(text) {
41
42
  });
42
43
  return { text: plainText, images };
43
44
  }
44
- const historyMessage = z
45
+ const nativeMessageActivitySchema = z
45
46
  .strictObject({
46
- role: z.enum(["user", "assistant"]),
47
+ activityId: z.string().min(1).max(128),
48
+ activityType: z.string().min(1).max(128),
49
+ content: z.array(displayContentSchema).max(100).readonly(),
50
+ input: z.string().max(100_000),
51
+ locations: z.array(z.string().min(1).max(2_048)).max(100).readonly(),
52
+ name: z.string().max(128),
53
+ output: z.string().max(100_000),
54
+ sequence: z.number().int().nonnegative(),
55
+ status: z.string().min(1).max(64),
56
+ title: z.string().max(500),
57
+ toolKind: z.string().max(64),
58
+ })
59
+ .readonly();
60
+ const userHistoryMessage = z
61
+ .strictObject({
62
+ role: z.literal("user"),
47
63
  text: z.string().max(SESSION_HISTORY_CHARACTER_LIMIT),
48
64
  images: z.array(historyImage).max(8).readonly().optional(),
49
65
  })
50
66
  .readonly();
51
- const sessionHistorySchema = z
52
- .discriminatedUnion("status", [
53
- z
67
+ const assistantHistoryMessage = z
68
+ .strictObject({
69
+ activities: z.array(nativeMessageActivitySchema).max(100).readonly().default([]),
70
+ content: z.array(displayContentSchema).max(100).readonly().default([]),
71
+ role: z.literal("assistant"),
72
+ text: z.string().max(SESSION_HISTORY_CHARACTER_LIMIT),
73
+ images: z.array(historyImage).max(8).readonly().optional(),
74
+ })
75
+ .readonly();
76
+ const historyMessage = z.discriminatedUnion("role", [userHistoryMessage, assistantHistoryMessage]);
77
+ const availableSessionHistoryObjectSchema = z.strictObject({
78
+ status: z.literal("available"),
79
+ messages: z.array(historyMessage).max(SESSION_HISTORY_MESSAGE_LIMIT).readonly(),
80
+ truncated: z.boolean(),
81
+ coveredCommandIds: z
82
+ .array(z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/))
83
+ .max(10_000)
84
+ .readonly(),
85
+ coveredMessageIds: z
86
+ .array(z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}:(?:user|agent)$/))
87
+ .max(20_000)
88
+ .readonly()
89
+ .default([]),
90
+ });
91
+ const availableSessionHistorySchema = availableSessionHistoryObjectSchema.readonly();
92
+ const unavailableSessionHistoryObjectSchema = z.strictObject({
93
+ status: z.literal("unavailable"),
94
+ cause: z
54
95
  .strictObject({
55
- status: z.literal("available"),
56
- messages: z.array(historyMessage).max(SESSION_HISTORY_MESSAGE_LIMIT).readonly(),
57
- truncated: z.boolean(),
58
- coveredCommandIds: z
59
- .array(z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/))
60
- .max(10_000)
61
- .readonly(),
62
- coveredMessageIds: z
63
- .array(z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}:(?:user|agent)$/))
64
- .max(20_000)
65
- .readonly()
66
- .default([]),
96
+ code: z.string().regex(/^[a-z][a-z0-9_]{0,127}$/),
97
+ message: z.string().min(1).max(1_000),
67
98
  })
68
99
  .readonly(),
69
- z.strictObject({ status: z.literal("unavailable") }).readonly(),
100
+ });
101
+ const unavailableSessionHistorySchema = unavailableSessionHistoryObjectSchema.readonly();
102
+ function withinHistoryContentLimits(history) {
103
+ if (history.status === "unavailable" || history.messages === undefined) {
104
+ return true;
105
+ }
106
+ return (history.messages.reduce((total, message) => total +
107
+ message.text.length +
108
+ (message.role === "assistant"
109
+ ? JSON.stringify(message.activities).length + JSON.stringify(message.content).length
110
+ : 0), 0) <= SESSION_HISTORY_CHARACTER_LIMIT &&
111
+ history.messages.reduce((total, message) => total + (message.images ?? []).reduce((size, image) => size + image.data.length, 0), 0) <= SESSION_HISTORY_IMAGE_CHARACTER_LIMIT);
112
+ }
113
+ const sessionHistorySchema = z
114
+ .discriminatedUnion("status", [availableSessionHistorySchema, unavailableSessionHistorySchema])
115
+ .refine(withinHistoryContentLimits);
116
+ const nativeMessagePageSchema = z
117
+ .discriminatedUnion("status", [
118
+ availableSessionHistoryObjectSchema.extend({ nextCursor: z.string().max(512).nullable() }).readonly(),
119
+ unavailableSessionHistoryObjectSchema.extend({ nextCursor: z.null() }).readonly(),
70
120
  ])
71
- .refine((history) => history.status === "unavailable" ||
72
- (history.messages.reduce((total, message) => total + message.text.length, 0) <=
73
- SESSION_HISTORY_CHARACTER_LIMIT &&
74
- history.messages.reduce((total, message) => total + (message.images ?? []).reduce((size, image) => size + image.data.length, 0), 0) <= SESSION_HISTORY_IMAGE_CHARACTER_LIMIT));
121
+ .refine(withinHistoryContentLimits);
75
122
  export const decodeNativeSessionHistory = (value) => {
76
123
  try {
77
124
  return sessionHistorySchema.parse(value);
@@ -80,5 +127,13 @@ export const decodeNativeSessionHistory = (value) => {
80
127
  throw new ProtocolMessageError("Invalid native session history", { cause });
81
128
  }
82
129
  };
83
- export { sessionHistorySchema };
130
+ export const decodeNativeMessagePage = (value) => {
131
+ try {
132
+ return nativeMessagePageSchema.parse(value);
133
+ }
134
+ catch (cause) {
135
+ throw new ProtocolMessageError("Invalid native message page", { cause });
136
+ }
137
+ };
138
+ export { nativeMessagePageSchema, sessionHistorySchema };
84
139
  //# sourceMappingURL=session-history.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-history.js","sourceRoot":"","sources":["../src/session-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,CAAC,MAAM,+BAA+B,GAAG,OAAO,CAAC;AACvD,MAAM,CAAC,MAAM,6BAA6B,GAAG,KAAK,CAAC;AACnD,MAAM,CAAC,MAAM,qCAAqC,GAAG,EAAE,CAAC;AACxD,MAAM,CAAC,MAAM,qCAAqC,GAAG,SAAS,CAAC;AAE/D,MAAM,YAAY,GAAG,CAAC;KACjB,YAAY,CAAC;IACV,IAAI,EAAE,CAAC;SACF,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,qCAAqC,CAAC;SAC1C,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnF,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACxE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACnC,CAAC;KACD,QAAQ,EAAE,CAAC;AAIhB;oEACoE;AACpE,MAAM,UAAU,sBAAsB,CAAC,IAAY;IAI/C,MAAM,MAAM,GAAyB,EAAE,CAAC;IACxC,IAAI,eAAe,GA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KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAChF,CAAC;AACL,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAc,EAAqB,EAAE;IACzE,IAAI,CAAC;QACD,OAAO,uBAAuB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;AACL,CAAC,CAAC;AACF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,118 @@
1
+ import { z } from "zod";
2
+ export declare const SESSION_LIVE_HISTORY_LOAD_KIND = "session.live-history.load";
3
+ export declare const SESSION_LIVE_HISTORY_LOADED_KIND = "session.live-history.loaded";
4
+ declare const sessionLiveHistoryLoadSchema: z.ZodReadonly<z.ZodObject<{
5
+ additionalDirectoryIds: z.ZodReadonly<z.ZodArray<z.ZodString>>;
6
+ agentId: z.ZodString;
7
+ bindingId: z.ZodString;
8
+ directoryId: z.ZodString;
9
+ kind: z.ZodLiteral<"session.live-history.load">;
10
+ requestId: z.ZodString;
11
+ sessionId: z.ZodString;
12
+ }, z.core.$strict>>;
13
+ declare const sessionLiveHistoryLoadedSchema: z.ZodReadonly<z.ZodObject<{
14
+ history: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
15
+ status: z.ZodLiteral<"available">;
16
+ messages: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
17
+ role: z.ZodLiteral<"user">;
18
+ text: z.ZodString;
19
+ images: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
20
+ data: z.ZodString;
21
+ mimeType: z.ZodEnum<{
22
+ "image/gif": "image/gif";
23
+ "image/jpeg": "image/jpeg";
24
+ "image/png": "image/png";
25
+ "image/webp": "image/webp";
26
+ }>;
27
+ name: z.ZodString;
28
+ }, z.core.$strict>>>>>;
29
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
30
+ activities: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
31
+ activityId: z.ZodString;
32
+ activityType: z.ZodString;
33
+ content: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
34
+ artifactId: z.ZodDefault<z.ZodString>;
35
+ data: z.ZodString;
36
+ mimeType: z.ZodString;
37
+ name: z.ZodString;
38
+ newText: z.ZodString;
39
+ oldText: z.ZodString;
40
+ path: z.ZodString;
41
+ terminalId: z.ZodString;
42
+ text: z.ZodString;
43
+ type: z.ZodEnum<{
44
+ diff: "diff";
45
+ image: "image";
46
+ resource: "resource";
47
+ resource_link: "resource_link";
48
+ terminal: "terminal";
49
+ text: "text";
50
+ video: "video";
51
+ }>;
52
+ uri: z.ZodString;
53
+ }, z.core.$strict>>>>;
54
+ input: z.ZodString;
55
+ locations: z.ZodReadonly<z.ZodArray<z.ZodString>>;
56
+ name: z.ZodString;
57
+ output: z.ZodString;
58
+ sequence: z.ZodNumber;
59
+ status: z.ZodString;
60
+ title: z.ZodString;
61
+ toolKind: z.ZodString;
62
+ }, z.core.$strict>>>>>;
63
+ content: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
64
+ artifactId: z.ZodDefault<z.ZodString>;
65
+ data: z.ZodString;
66
+ mimeType: z.ZodString;
67
+ name: z.ZodString;
68
+ newText: z.ZodString;
69
+ oldText: z.ZodString;
70
+ path: z.ZodString;
71
+ terminalId: z.ZodString;
72
+ text: z.ZodString;
73
+ type: z.ZodEnum<{
74
+ diff: "diff";
75
+ image: "image";
76
+ resource: "resource";
77
+ resource_link: "resource_link";
78
+ terminal: "terminal";
79
+ text: "text";
80
+ video: "video";
81
+ }>;
82
+ uri: z.ZodString;
83
+ }, z.core.$strict>>>>>;
84
+ role: z.ZodLiteral<"assistant">;
85
+ text: z.ZodString;
86
+ images: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
87
+ data: z.ZodString;
88
+ mimeType: z.ZodEnum<{
89
+ "image/gif": "image/gif";
90
+ "image/jpeg": "image/jpeg";
91
+ "image/png": "image/png";
92
+ "image/webp": "image/webp";
93
+ }>;
94
+ name: z.ZodString;
95
+ }, z.core.$strict>>>>>;
96
+ }, z.core.$strict>>], "role">>>;
97
+ truncated: z.ZodBoolean;
98
+ coveredCommandIds: z.ZodReadonly<z.ZodArray<z.ZodString>>;
99
+ coveredMessageIds: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
100
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
101
+ status: z.ZodLiteral<"unavailable">;
102
+ cause: z.ZodReadonly<z.ZodObject<{
103
+ code: z.ZodString;
104
+ message: z.ZodString;
105
+ }, z.core.$strict>>;
106
+ }, z.core.$strict>>], "status">;
107
+ kind: z.ZodLiteral<"session.live-history.loaded">;
108
+ requestId: z.ZodString;
109
+ sessionId: z.ZodString;
110
+ }, z.core.$strict>>;
111
+ export type SessionLiveHistoryLoad = z.infer<typeof sessionLiveHistoryLoadSchema>;
112
+ export type SessionLiveHistoryLoaded = z.infer<typeof sessionLiveHistoryLoadedSchema>;
113
+ export declare const decodeSessionLiveHistoryLoad: (encoded: string) => SessionLiveHistoryLoad;
114
+ export declare const decodeSessionLiveHistoryLoaded: (encoded: string) => SessionLiveHistoryLoaded;
115
+ export declare const encodeSessionLiveHistoryLoad: (value: SessionLiveHistoryLoad) => string;
116
+ export declare const encodeSessionLiveHistoryLoaded: (value: SessionLiveHistoryLoaded) => string;
117
+ export {};
118
+ //# sourceMappingURL=session-live-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-live-history.d.ts","sourceRoot":"","sources":["../src/session-live-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAC1E,eAAO,MAAM,gCAAgC,gCAAgC,CAAC;AAK9E,QAAA,MAAM,4BAA4B;;;;;;;;mBAUnB,CAAC;AAEhB,QAAA,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAOrB,CAAC;AAEhB,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAWtF,eAAO,MAAM,4BAA4B,YAAa,MAAM,KAAG,sBACd,CAAC;AAClD,eAAO,MAAM,8BAA8B,YAAa,MAAM,KAAG,wBACd,CAAC;AACpD,eAAO,MAAM,4BAA4B,UAAW,sBAAsB,KAAG,MAChB,CAAC;AAC9D,eAAO,MAAM,8BAA8B,UAAW,wBAAwB,KAAG,MAClB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ import { ProtocolMessageError } from "./codecs/messages.js";
3
+ import { sessionHistorySchema } from "./session-history.js";
4
+ export const SESSION_LIVE_HISTORY_LOAD_KIND = "session.live-history.load";
5
+ export const SESSION_LIVE_HISTORY_LOADED_KIND = "session.live-history.loaded";
6
+ const identifier = z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/);
7
+ const directoryIdentifier = z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
8
+ const sessionLiveHistoryLoadSchema = z
9
+ .strictObject({
10
+ additionalDirectoryIds: z.array(directoryIdentifier).max(16).readonly(),
11
+ agentId: identifier,
12
+ bindingId: identifier,
13
+ directoryId: directoryIdentifier,
14
+ kind: z.literal(SESSION_LIVE_HISTORY_LOAD_KIND),
15
+ requestId: identifier,
16
+ sessionId: identifier,
17
+ })
18
+ .readonly();
19
+ const sessionLiveHistoryLoadedSchema = z
20
+ .strictObject({
21
+ history: sessionHistorySchema,
22
+ kind: z.literal(SESSION_LIVE_HISTORY_LOADED_KIND),
23
+ requestId: identifier,
24
+ sessionId: identifier,
25
+ })
26
+ .readonly();
27
+ function decode(schema, encoded) {
28
+ try {
29
+ const value = JSON.parse(encoded);
30
+ return schema.parse(value);
31
+ }
32
+ catch (cause) {
33
+ throw new ProtocolMessageError("Invalid live Session history message", { cause });
34
+ }
35
+ }
36
+ export const decodeSessionLiveHistoryLoad = (encoded) => decode(sessionLiveHistoryLoadSchema, encoded);
37
+ export const decodeSessionLiveHistoryLoaded = (encoded) => decode(sessionLiveHistoryLoadedSchema, encoded);
38
+ export const encodeSessionLiveHistoryLoad = (value) => JSON.stringify(sessionLiveHistoryLoadSchema.parse(value));
39
+ export const encodeSessionLiveHistoryLoaded = (value) => JSON.stringify(sessionLiveHistoryLoadedSchema.parse(value));
40
+ //# sourceMappingURL=session-live-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-live-history.js","sourceRoot":"","sources":["../src/session-live-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,CAAC,MAAM,8BAA8B,GAAG,2BAA2B,CAAC;AAC1E,MAAM,CAAC,MAAM,gCAAgC,GAAG,6BAA6B,CAAC;AAE9E,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;AAC3E,MAAM,mBAAmB,G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MAAM,4BAA4B,GAAG,CAAC,KAA6B,EAAU,EAAE,CAClF,IAAI,CAAC,SAAS,CAAC,4BAA4B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,KAA+B,EAAU,EAAE,CACtF,IAAI,CAAC,SAAS,CAAC,8BAA8B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxt-ai/mobius-protocol",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Versioned public Mobius protocol resources and codecs.",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",