@moxt-ai/mobius 0.0.337 → 0.0.339
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1117 -1190
- package/dist/cli.js.map +4 -4
- package/dist/daemon/upgrades/upgrade.d.ts.map +1 -1
- package/dist/daemon/upgrades/upgrade.js +25 -2
- package/dist/daemon/upgrades/upgrade.js.map +1 -1
- package/dist/runtime.js +829 -921
- package/dist/runtime.js.map +4 -4
- package/dist/session/live/session-configurations.d.ts.map +1 -1
- package/dist/session/live/session-configurations.js +10 -12
- package/dist/session/live/session-configurations.js.map +1 -1
- package/dist/session/turn/runtime-turn-activity.d.ts +12 -1
- package/dist/session/turn/runtime-turn-activity.d.ts.map +1 -1
- package/dist/session/turn/runtime-turn-activity.js +52 -26
- package/dist/session/turn/runtime-turn-activity.js.map +1 -1
- package/package.json +2 -2
package/dist/runtime.js
CHANGED
|
@@ -21252,145 +21252,6 @@ var encodeSessionRenameCommand = (message) => encodeZodMessage(message, sessionR
|
|
|
21252
21252
|
var decodeSessionRenamedEvent = (encoded) => decodeZodMessage(encoded, sessionRenamedEventSchema);
|
|
21253
21253
|
var encodeSessionRenamedEvent = (message) => encodeZodMessage(message, sessionRenamedEventSchema);
|
|
21254
21254
|
|
|
21255
|
-
// ../mobius-sdk/src/protocol/session/files/index.ts
|
|
21256
|
-
var FILE_READ_KIND = "file.read";
|
|
21257
|
-
var FILE_BEGIN_KIND = "file.begin";
|
|
21258
|
-
var FILE_END_KIND = "file.end";
|
|
21259
|
-
var FILE_FAILED_KIND = "file.failed";
|
|
21260
|
-
var CONTENT_WRITE_KIND = "content.write";
|
|
21261
|
-
var CONTENT_COMMIT_KIND = "content.commit";
|
|
21262
|
-
var CONTENT_READY_KIND = "content.ready";
|
|
21263
|
-
var CONTENT_AVAILABLE_KIND = "content.available";
|
|
21264
|
-
var CONTENT_CHUNK_MAX_BYTES = 192 * 1024;
|
|
21265
|
-
var CONTENT_WRITE_MAX_BYTES = 32 * 1024 * 1024;
|
|
21266
|
-
var PROMPT_IMAGE_MAX_BYTES = 5e6;
|
|
21267
|
-
var CONTENT_CHUNK_MAGIC = new Uint8Array([77, 66, 67, 49]);
|
|
21268
|
-
var CONTENT_CHUNK_HEADER_BYTES = CONTENT_CHUNK_MAGIC.byteLength + 1 + 4;
|
|
21269
|
-
var fileReadCommandSchema = external_exports.object({
|
|
21270
|
-
kind: external_exports.literal(FILE_READ_KIND),
|
|
21271
|
-
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
21272
|
-
requestId: identifierStringSchema,
|
|
21273
|
-
sessionId: identifierStringSchema,
|
|
21274
|
-
path: external_exports.string().min(1).max(4096)
|
|
21275
|
-
}).readonly();
|
|
21276
|
-
var fileBeginEventSchema = external_exports.object({
|
|
21277
|
-
byteLength: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
21278
|
-
kind: external_exports.literal(FILE_BEGIN_KIND),
|
|
21279
|
-
mediaType: external_exports.string().min(1).max(255),
|
|
21280
|
-
modifiedAt: external_exports.iso.datetime({ offset: true }),
|
|
21281
|
-
name: external_exports.string().min(1).max(500),
|
|
21282
|
-
requestId: identifierStringSchema,
|
|
21283
|
-
sessionId: identifierStringSchema
|
|
21284
|
-
}).readonly();
|
|
21285
|
-
var contentWriteCommandSchema = external_exports.object({
|
|
21286
|
-
byteLength: external_exports.number().int().positive().max(CONTENT_WRITE_MAX_BYTES),
|
|
21287
|
-
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
21288
|
-
contentKind: external_exports.enum(["image", "resource"]),
|
|
21289
|
-
kind: external_exports.literal(CONTENT_WRITE_KIND),
|
|
21290
|
-
mediaType: external_exports.string().min(1).max(255),
|
|
21291
|
-
name: external_exports.string().min(1).max(500),
|
|
21292
|
-
requestId: identifierStringSchema,
|
|
21293
|
-
sessionId: identifierStringSchema
|
|
21294
|
-
}).readonly();
|
|
21295
|
-
var contentCommitCommandSchema = external_exports.object({
|
|
21296
|
-
kind: external_exports.literal(CONTENT_COMMIT_KIND),
|
|
21297
|
-
requestId: identifierStringSchema,
|
|
21298
|
-
sessionId: identifierStringSchema
|
|
21299
|
-
}).readonly();
|
|
21300
|
-
var contentReadyEventSchema = external_exports.object({
|
|
21301
|
-
kind: external_exports.literal(CONTENT_READY_KIND),
|
|
21302
|
-
requestId: identifierStringSchema,
|
|
21303
|
-
sessionId: identifierStringSchema
|
|
21304
|
-
}).readonly();
|
|
21305
|
-
var contentAvailableEventSchema = external_exports.object({
|
|
21306
|
-
byteLength: external_exports.number().int().positive().max(CONTENT_WRITE_MAX_BYTES),
|
|
21307
|
-
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
21308
|
-
kind: external_exports.literal(CONTENT_AVAILABLE_KIND),
|
|
21309
|
-
requestId: identifierStringSchema,
|
|
21310
|
-
sessionId: identifierStringSchema
|
|
21311
|
-
}).readonly();
|
|
21312
|
-
function binaryBytes(value) {
|
|
21313
|
-
if (value instanceof ArrayBuffer) {
|
|
21314
|
-
return new Uint8Array(value);
|
|
21315
|
-
}
|
|
21316
|
-
if (ArrayBuffer.isView(value)) {
|
|
21317
|
-
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
21318
|
-
}
|
|
21319
|
-
throw new Error("Content chunk must be a binary WebSocket frame");
|
|
21320
|
-
}
|
|
21321
|
-
function encodeContentChunkFrame(frame) {
|
|
21322
|
-
if (!isIdentifier(frame.requestId)) {
|
|
21323
|
-
throw new Error("Content chunk request identifier is invalid");
|
|
21324
|
-
}
|
|
21325
|
-
if (!Number.isSafeInteger(frame.sequence) || frame.sequence < 0 || frame.sequence > 4294967295) {
|
|
21326
|
-
throw new Error("Content chunk sequence is invalid");
|
|
21327
|
-
}
|
|
21328
|
-
if (frame.bytes.byteLength < 1 || frame.bytes.byteLength > CONTENT_CHUNK_MAX_BYTES) {
|
|
21329
|
-
throw new Error("Content chunk size is invalid");
|
|
21330
|
-
}
|
|
21331
|
-
const requestId = new TextEncoder().encode(frame.requestId);
|
|
21332
|
-
if (requestId.byteLength > 255) {
|
|
21333
|
-
throw new Error("Content chunk request identifier is too long");
|
|
21334
|
-
}
|
|
21335
|
-
const encoded = new Uint8Array(CONTENT_CHUNK_HEADER_BYTES + requestId.byteLength + frame.bytes.byteLength);
|
|
21336
|
-
encoded.set(CONTENT_CHUNK_MAGIC, 0);
|
|
21337
|
-
encoded[CONTENT_CHUNK_MAGIC.byteLength] = requestId.byteLength;
|
|
21338
|
-
new DataView(encoded.buffer).setUint32(CONTENT_CHUNK_MAGIC.byteLength + 1, frame.sequence);
|
|
21339
|
-
encoded.set(requestId, CONTENT_CHUNK_HEADER_BYTES);
|
|
21340
|
-
encoded.set(frame.bytes, CONTENT_CHUNK_HEADER_BYTES + requestId.byteLength);
|
|
21341
|
-
return encoded;
|
|
21342
|
-
}
|
|
21343
|
-
function decodeContentChunkFrame(value) {
|
|
21344
|
-
const encoded = binaryBytes(value);
|
|
21345
|
-
if (encoded.byteLength <= CONTENT_CHUNK_HEADER_BYTES || !CONTENT_CHUNK_MAGIC.every((byte, index2) => encoded[index2] === byte)) {
|
|
21346
|
-
throw new Error("Content chunk frame header is invalid");
|
|
21347
|
-
}
|
|
21348
|
-
const requestIdLength = encoded[CONTENT_CHUNK_MAGIC.byteLength] ?? 0;
|
|
21349
|
-
const payloadOffset = CONTENT_CHUNK_HEADER_BYTES + requestIdLength;
|
|
21350
|
-
if (requestIdLength < 1 || payloadOffset >= encoded.byteLength) {
|
|
21351
|
-
throw new Error("Content chunk frame length is invalid");
|
|
21352
|
-
}
|
|
21353
|
-
const requestId = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
|
|
21354
|
-
encoded.subarray(CONTENT_CHUNK_HEADER_BYTES, payloadOffset)
|
|
21355
|
-
);
|
|
21356
|
-
const bytes = encoded.slice(payloadOffset);
|
|
21357
|
-
const sequence = new DataView(encoded.buffer, encoded.byteOffset, encoded.byteLength).getUint32(
|
|
21358
|
-
CONTENT_CHUNK_MAGIC.byteLength + 1
|
|
21359
|
-
);
|
|
21360
|
-
if (!isIdentifier(requestId) || bytes.byteLength > CONTENT_CHUNK_MAX_BYTES) {
|
|
21361
|
-
throw new Error("Content chunk frame is invalid");
|
|
21362
|
-
}
|
|
21363
|
-
return { bytes, requestId, sequence };
|
|
21364
|
-
}
|
|
21365
|
-
var fileEndEventSchema = external_exports.object({
|
|
21366
|
-
kind: external_exports.literal(FILE_END_KIND),
|
|
21367
|
-
requestId: identifierStringSchema,
|
|
21368
|
-
sessionId: identifierStringSchema
|
|
21369
|
-
}).readonly();
|
|
21370
|
-
var fileFailedEventSchema = external_exports.object({
|
|
21371
|
-
code: identifierStringSchema,
|
|
21372
|
-
kind: external_exports.literal(FILE_FAILED_KIND),
|
|
21373
|
-
message: external_exports.string().min(1).max(500),
|
|
21374
|
-
requestId: identifierStringSchema,
|
|
21375
|
-
sessionId: identifierStringSchema
|
|
21376
|
-
}).readonly();
|
|
21377
|
-
var decodeFileReadCommand = (encoded) => decodeZodMessage(encoded, fileReadCommandSchema);
|
|
21378
|
-
var encodeFileReadCommand = (message) => encodeZodMessage(message, fileReadCommandSchema);
|
|
21379
|
-
var decodeFileBeginEvent = (encoded) => decodeZodMessage(encoded, fileBeginEventSchema);
|
|
21380
|
-
var encodeFileBeginEvent = (message) => encodeZodMessage(message, fileBeginEventSchema);
|
|
21381
|
-
var decodeFileEndEvent = (encoded) => decodeZodMessage(encoded, fileEndEventSchema);
|
|
21382
|
-
var encodeFileEndEvent = (message) => encodeZodMessage(message, fileEndEventSchema);
|
|
21383
|
-
var decodeFileFailedEvent = (encoded) => decodeZodMessage(encoded, fileFailedEventSchema);
|
|
21384
|
-
var encodeFileFailedEvent = (message) => encodeZodMessage(message, fileFailedEventSchema);
|
|
21385
|
-
var decodeContentWriteCommand = (encoded) => decodeZodMessage(encoded, contentWriteCommandSchema);
|
|
21386
|
-
var encodeContentWriteCommand = (message) => encodeZodMessage(message, contentWriteCommandSchema);
|
|
21387
|
-
var decodeContentCommitCommand = (encoded) => decodeZodMessage(encoded, contentCommitCommandSchema);
|
|
21388
|
-
var encodeContentCommitCommand = (message) => encodeZodMessage(message, contentCommitCommandSchema);
|
|
21389
|
-
var decodeContentReadyEvent = (encoded) => decodeZodMessage(encoded, contentReadyEventSchema);
|
|
21390
|
-
var encodeContentReadyEvent = (message) => encodeZodMessage(message, contentReadyEventSchema);
|
|
21391
|
-
var decodeContentAvailableEvent = (encoded) => decodeZodMessage(encoded, contentAvailableEventSchema);
|
|
21392
|
-
var encodeContentAvailableEvent = (message) => encodeZodMessage(message, contentAvailableEventSchema);
|
|
21393
|
-
|
|
21394
21255
|
// ../mobius-sdk/src/protocol/shared/tool-input.ts
|
|
21395
21256
|
var MAX_CONTENT_LENGTH = 1e6;
|
|
21396
21257
|
var MAX_COLLECTION_SIZE = 1e3;
|
|
@@ -21547,6 +21408,600 @@ var encodeSessionPermissionRespondCommand = (message) => encodeZodMessage(messag
|
|
|
21547
21408
|
var decodeSessionElicitationRespondCommand = (encoded) => decodeZodMessage(encoded, sessionElicitationRespondCommandSchema);
|
|
21548
21409
|
var encodeSessionElicitationRespondCommand = (message) => encodeZodMessage(message, sessionElicitationRespondCommandSchema);
|
|
21549
21410
|
|
|
21411
|
+
// ../mobius-sdk/src/protocol/session/events/index.ts
|
|
21412
|
+
var MAX_EVENT_COUNT = 1e4;
|
|
21413
|
+
var MAX_COLLECTION_SIZE2 = 1e3;
|
|
21414
|
+
var MAX_CONTENT_LENGTH2 = 1e6;
|
|
21415
|
+
var SESSION_EVENT_KIND = "session.event.v2";
|
|
21416
|
+
var SESSION_EVENT_BATCH_MAX_SIZE = 1e3;
|
|
21417
|
+
var boundedString2 = external_exports.string().max(MAX_CONTENT_LENGTH2);
|
|
21418
|
+
var shortString = external_exports.string().max(2048);
|
|
21419
|
+
var externalContentKeySchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
21420
|
+
var annotationsSchema = external_exports.object({
|
|
21421
|
+
audience: external_exports.array(external_exports.enum(["assistant", "user"])).max(2).readonly().nullable().optional(),
|
|
21422
|
+
lastModified: shortString.nullable().optional(),
|
|
21423
|
+
priority: external_exports.number().finite().nullable().optional()
|
|
21424
|
+
}).readonly();
|
|
21425
|
+
var contentFields = { annotations: annotationsSchema.nullable().optional() };
|
|
21426
|
+
var textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
|
|
21427
|
+
var imageContentSchema = external_exports.object({
|
|
21428
|
+
...contentFields,
|
|
21429
|
+
data: external_exports.string(),
|
|
21430
|
+
mimeType: shortString,
|
|
21431
|
+
type: external_exports.literal("image"),
|
|
21432
|
+
uri: boundedString2.nullable().optional()
|
|
21433
|
+
}).readonly();
|
|
21434
|
+
var audioContentSchema = external_exports.object({ ...contentFields, data: external_exports.string(), mimeType: shortString, type: external_exports.literal("audio") }).readonly();
|
|
21435
|
+
var externalImageContentSchema = external_exports.object({
|
|
21436
|
+
...contentFields,
|
|
21437
|
+
byteLength: external_exports.number().int().positive().safe(),
|
|
21438
|
+
imageKey: externalContentKeySchema,
|
|
21439
|
+
mimeType: shortString,
|
|
21440
|
+
type: external_exports.literal("external_image"),
|
|
21441
|
+
uri: boundedString2.nullable().optional()
|
|
21442
|
+
}).readonly();
|
|
21443
|
+
var externalAudioContentSchema = external_exports.object({
|
|
21444
|
+
...contentFields,
|
|
21445
|
+
audioKey: externalContentKeySchema,
|
|
21446
|
+
byteLength: external_exports.number().int().positive().safe(),
|
|
21447
|
+
mimeType: shortString,
|
|
21448
|
+
type: external_exports.literal("external_audio")
|
|
21449
|
+
}).readonly();
|
|
21450
|
+
var externalResourceContentSchema = external_exports.object({
|
|
21451
|
+
...contentFields,
|
|
21452
|
+
byteLength: external_exports.number().int().positive().safe(),
|
|
21453
|
+
encoding: external_exports.enum(["binary", "text"]),
|
|
21454
|
+
mimeType: shortString.nullable().optional(),
|
|
21455
|
+
resourceKey: externalContentKeySchema,
|
|
21456
|
+
type: external_exports.literal("external_resource"),
|
|
21457
|
+
uri: boundedString2
|
|
21458
|
+
}).readonly();
|
|
21459
|
+
var resourceLinkSchema = external_exports.object({
|
|
21460
|
+
...contentFields,
|
|
21461
|
+
description: boundedString2.nullable().optional(),
|
|
21462
|
+
mimeType: shortString.nullable().optional(),
|
|
21463
|
+
name: shortString,
|
|
21464
|
+
size: external_exports.number().int().nonnegative().safe().nullable().optional(),
|
|
21465
|
+
title: shortString.nullable().optional(),
|
|
21466
|
+
type: external_exports.literal("resource_link"),
|
|
21467
|
+
uri: boundedString2
|
|
21468
|
+
}).readonly();
|
|
21469
|
+
var textResourceSchema = external_exports.object({
|
|
21470
|
+
mimeType: shortString.nullable().optional(),
|
|
21471
|
+
text: boundedString2,
|
|
21472
|
+
uri: boundedString2
|
|
21473
|
+
}).readonly();
|
|
21474
|
+
var blobResourceSchema = external_exports.object({
|
|
21475
|
+
blob: external_exports.string(),
|
|
21476
|
+
mimeType: shortString.nullable().optional(),
|
|
21477
|
+
uri: boundedString2
|
|
21478
|
+
}).readonly();
|
|
21479
|
+
var embeddedResourceSchema = external_exports.object({
|
|
21480
|
+
...contentFields,
|
|
21481
|
+
resource: external_exports.union([textResourceSchema, blobResourceSchema]),
|
|
21482
|
+
type: external_exports.literal("resource")
|
|
21483
|
+
}).readonly();
|
|
21484
|
+
var contentBlockSchema = external_exports.discriminatedUnion("type", [
|
|
21485
|
+
textContentSchema,
|
|
21486
|
+
imageContentSchema,
|
|
21487
|
+
audioContentSchema,
|
|
21488
|
+
resourceLinkSchema,
|
|
21489
|
+
embeddedResourceSchema,
|
|
21490
|
+
externalImageContentSchema,
|
|
21491
|
+
externalAudioContentSchema,
|
|
21492
|
+
externalResourceContentSchema
|
|
21493
|
+
]);
|
|
21494
|
+
var toolCallContentSchema = external_exports.discriminatedUnion("type", [
|
|
21495
|
+
external_exports.object({ content: contentBlockSchema, type: external_exports.literal("content") }).readonly(),
|
|
21496
|
+
external_exports.object({
|
|
21497
|
+
newText: boundedString2,
|
|
21498
|
+
oldText: boundedString2.nullable().optional(),
|
|
21499
|
+
path: boundedString2,
|
|
21500
|
+
type: external_exports.literal("diff")
|
|
21501
|
+
}).readonly(),
|
|
21502
|
+
external_exports.object({ terminalId: shortString, type: external_exports.literal("terminal") }).readonly()
|
|
21503
|
+
]);
|
|
21504
|
+
var toolKindSchema = external_exports.enum([
|
|
21505
|
+
"read",
|
|
21506
|
+
"edit",
|
|
21507
|
+
"delete",
|
|
21508
|
+
"move",
|
|
21509
|
+
"search",
|
|
21510
|
+
"execute",
|
|
21511
|
+
"think",
|
|
21512
|
+
"fetch",
|
|
21513
|
+
"switch_mode",
|
|
21514
|
+
"other"
|
|
21515
|
+
]);
|
|
21516
|
+
var toolStatusSchema = external_exports.enum(["pending", "in_progress", "completed", "failed"]);
|
|
21517
|
+
var backgroundTaskSchema = external_exports.object({
|
|
21518
|
+
id: shortString,
|
|
21519
|
+
status: external_exports.enum(["running", "completed", "failed", "stopped", "unknown"])
|
|
21520
|
+
}).readonly();
|
|
21521
|
+
var toolPatchFields = {
|
|
21522
|
+
backgroundTask: backgroundTaskSchema.optional(),
|
|
21523
|
+
content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
|
|
21524
|
+
kind: toolKindSchema.nullable().optional(),
|
|
21525
|
+
locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
|
|
21526
|
+
name: shortString.nullable().optional(),
|
|
21527
|
+
rawInput: boundedJsonSchema.optional(),
|
|
21528
|
+
rawOutput: boundedJsonSchema.optional(),
|
|
21529
|
+
status: toolStatusSchema.nullable().optional(),
|
|
21530
|
+
title: boundedString2.nullable().optional()
|
|
21531
|
+
};
|
|
21532
|
+
var planEntrySchema = external_exports.object({
|
|
21533
|
+
content: boundedString2,
|
|
21534
|
+
priority: external_exports.enum(["high", "medium", "low"]),
|
|
21535
|
+
status: external_exports.enum(["pending", "in_progress", "completed"])
|
|
21536
|
+
}).readonly();
|
|
21537
|
+
var planContentSchema = external_exports.discriminatedUnion("type", [
|
|
21538
|
+
external_exports.object({
|
|
21539
|
+
entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
21540
|
+
planId: shortString,
|
|
21541
|
+
type: external_exports.literal("items")
|
|
21542
|
+
}).readonly(),
|
|
21543
|
+
external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString2 }).readonly(),
|
|
21544
|
+
external_exports.object({
|
|
21545
|
+
content: boundedString2,
|
|
21546
|
+
planId: shortString,
|
|
21547
|
+
type: external_exports.literal("markdown")
|
|
21548
|
+
}).readonly()
|
|
21549
|
+
]);
|
|
21550
|
+
var commandSchema = external_exports.object({
|
|
21551
|
+
description: boundedString2,
|
|
21552
|
+
input: external_exports.object({ hint: boundedString2 }).readonly().nullable().optional(),
|
|
21553
|
+
name: shortString
|
|
21554
|
+
}).readonly();
|
|
21555
|
+
var configSelectOptionSchema = external_exports.object({
|
|
21556
|
+
description: boundedString2.nullable().optional(),
|
|
21557
|
+
name: shortString,
|
|
21558
|
+
value: shortString
|
|
21559
|
+
}).readonly();
|
|
21560
|
+
var configSelectGroupSchema = external_exports.object({
|
|
21561
|
+
group: shortString,
|
|
21562
|
+
name: shortString,
|
|
21563
|
+
options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
21564
|
+
}).readonly();
|
|
21565
|
+
var configBaseFields = {
|
|
21566
|
+
category: shortString.nullable().optional(),
|
|
21567
|
+
description: boundedString2.nullable().optional(),
|
|
21568
|
+
id: shortString,
|
|
21569
|
+
name: shortString
|
|
21570
|
+
};
|
|
21571
|
+
var sessionConfigOptionSchema2 = external_exports.discriminatedUnion("type", [
|
|
21572
|
+
external_exports.object({
|
|
21573
|
+
...configBaseFields,
|
|
21574
|
+
currentValue: shortString,
|
|
21575
|
+
options: external_exports.union([
|
|
21576
|
+
external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
21577
|
+
external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
21578
|
+
]),
|
|
21579
|
+
type: external_exports.literal("select")
|
|
21580
|
+
}).readonly(),
|
|
21581
|
+
external_exports.object({ ...configBaseFields, currentValue: external_exports.boolean(), type: external_exports.literal("boolean") }).readonly()
|
|
21582
|
+
]);
|
|
21583
|
+
var contentChunkFields = {
|
|
21584
|
+
content: contentBlockSchema,
|
|
21585
|
+
messageId: shortString.nullable().optional()
|
|
21586
|
+
};
|
|
21587
|
+
var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate", [
|
|
21588
|
+
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("user_message_chunk") }).readonly(),
|
|
21589
|
+
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_message_chunk") }).readonly(),
|
|
21590
|
+
external_exports.object({
|
|
21591
|
+
...contentChunkFields,
|
|
21592
|
+
meta: external_exports.object({ truncated: external_exports.boolean().optional() }).readonly().optional(),
|
|
21593
|
+
sessionUpdate: external_exports.literal("agent_thought_chunk")
|
|
21594
|
+
}).readonly(),
|
|
21595
|
+
external_exports.object({
|
|
21596
|
+
backgroundTask: backgroundTaskSchema.optional(),
|
|
21597
|
+
content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
21598
|
+
kind: toolKindSchema.optional(),
|
|
21599
|
+
locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
21600
|
+
name: shortString.nullable().optional(),
|
|
21601
|
+
rawInput: boundedJsonSchema.optional(),
|
|
21602
|
+
rawOutput: boundedJsonSchema.optional(),
|
|
21603
|
+
sessionUpdate: external_exports.literal("tool_call"),
|
|
21604
|
+
status: toolStatusSchema.optional(),
|
|
21605
|
+
title: boundedString2,
|
|
21606
|
+
toolCallId: shortString
|
|
21607
|
+
}).readonly(),
|
|
21608
|
+
external_exports.object({ ...toolPatchFields, sessionUpdate: external_exports.literal("tool_call_update"), toolCallId: shortString }).readonly(),
|
|
21609
|
+
external_exports.object({
|
|
21610
|
+
entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
21611
|
+
sessionUpdate: external_exports.literal("plan")
|
|
21612
|
+
}).readonly(),
|
|
21613
|
+
external_exports.object({ plan: planContentSchema, sessionUpdate: external_exports.literal("plan_update") }).readonly(),
|
|
21614
|
+
external_exports.object({ planId: shortString, sessionUpdate: external_exports.literal("plan_removed") }).readonly(),
|
|
21615
|
+
external_exports.object({
|
|
21616
|
+
availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
21617
|
+
sessionUpdate: external_exports.literal("available_commands_update")
|
|
21618
|
+
}).readonly(),
|
|
21619
|
+
external_exports.object({
|
|
21620
|
+
currentModeId: shortString,
|
|
21621
|
+
sessionUpdate: external_exports.literal("current_mode_update")
|
|
21622
|
+
}).readonly(),
|
|
21623
|
+
external_exports.object({
|
|
21624
|
+
configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
21625
|
+
sessionUpdate: external_exports.literal("config_option_update")
|
|
21626
|
+
}).readonly(),
|
|
21627
|
+
external_exports.object({
|
|
21628
|
+
sessionUpdate: external_exports.literal("session_info_update"),
|
|
21629
|
+
title: boundedString2.nullable().optional(),
|
|
21630
|
+
updatedAt: shortString.nullable().optional()
|
|
21631
|
+
}).readonly(),
|
|
21632
|
+
external_exports.object({
|
|
21633
|
+
cost: external_exports.object({ amount: external_exports.number().finite(), currency: external_exports.string().max(16) }).readonly().nullable().optional(),
|
|
21634
|
+
sessionUpdate: external_exports.literal("usage_update"),
|
|
21635
|
+
size: external_exports.number().int().nonnegative().safe(),
|
|
21636
|
+
used: external_exports.number().int().nonnegative().safe()
|
|
21637
|
+
}).readonly(),
|
|
21638
|
+
external_exports.object({
|
|
21639
|
+
compactionId: shortString,
|
|
21640
|
+
error: boundedString2.nullable().optional(),
|
|
21641
|
+
sessionUpdate: external_exports.literal("compaction_update"),
|
|
21642
|
+
status: shortString,
|
|
21643
|
+
summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional()
|
|
21644
|
+
}).readonly(),
|
|
21645
|
+
external_exports.object({
|
|
21646
|
+
compactionId: shortString,
|
|
21647
|
+
content: contentBlockSchema,
|
|
21648
|
+
sessionUpdate: external_exports.literal("compaction_summary_chunk")
|
|
21649
|
+
}).readonly()
|
|
21650
|
+
]);
|
|
21651
|
+
var lifecycleBase = { commandId: identifierStringSchema };
|
|
21652
|
+
var promptExecutionContextSchema = external_exports.object({
|
|
21653
|
+
agentId: identifierStringSchema,
|
|
21654
|
+
directoryId: DIRECTORY_IDENTIFIER,
|
|
21655
|
+
additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly()
|
|
21656
|
+
}).readonly();
|
|
21657
|
+
var lifecycleMetadataSchema = external_exports.discriminatedUnion("kind", [
|
|
21658
|
+
external_exports.object({ kind: external_exports.literal("session.queue.changed") }).readonly(),
|
|
21659
|
+
external_exports.object({ event: sessionPermissionRequestedEventSchema, kind: external_exports.literal("session.permission.requested") }).readonly(),
|
|
21660
|
+
external_exports.object({ event: sessionPermissionResolvedEventSchema, kind: external_exports.literal("session.permission.resolved") }).readonly(),
|
|
21661
|
+
external_exports.object({ event: sessionElicitationRequestedEventSchema, kind: external_exports.literal("session.elicitation.requested") }).readonly(),
|
|
21662
|
+
external_exports.object({ event: sessionElicitationResolvedEventSchema, kind: external_exports.literal("session.elicitation.resolved") }).readonly(),
|
|
21663
|
+
external_exports.object({
|
|
21664
|
+
...lifecycleBase,
|
|
21665
|
+
content: external_exports.array(contentBlockSchema).min(1).max(100).readonly(),
|
|
21666
|
+
disposition: shortString.optional(),
|
|
21667
|
+
kind: external_exports.literal("prompt.requested"),
|
|
21668
|
+
context: promptExecutionContextSchema.optional(),
|
|
21669
|
+
targetCommandId: identifierStringSchema.optional()
|
|
21670
|
+
}).readonly(),
|
|
21671
|
+
external_exports.object({ ...lifecycleBase, attemptId: identifierStringSchema, epoch: identifierStringSchema, kind: external_exports.literal("prompt.started") }).readonly(),
|
|
21672
|
+
external_exports.object({
|
|
21673
|
+
...lifecycleBase,
|
|
21674
|
+
kind: external_exports.literal("prompt.completed"),
|
|
21675
|
+
stopReason: shortString
|
|
21676
|
+
}).readonly(),
|
|
21677
|
+
external_exports.object({
|
|
21678
|
+
...lifecycleBase,
|
|
21679
|
+
code: identifierStringSchema,
|
|
21680
|
+
kind: external_exports.literal("prompt.failed-before-start"),
|
|
21681
|
+
message: external_exports.string().min(1).max(500)
|
|
21682
|
+
}).readonly(),
|
|
21683
|
+
external_exports.object({
|
|
21684
|
+
...lifecycleBase,
|
|
21685
|
+
attemptId: identifierStringSchema,
|
|
21686
|
+
code: identifierStringSchema,
|
|
21687
|
+
kind: external_exports.literal("prompt.failed"),
|
|
21688
|
+
message: external_exports.string().min(1).max(500)
|
|
21689
|
+
}).readonly()
|
|
21690
|
+
]);
|
|
21691
|
+
var sessionEventPayloadSchema = external_exports.discriminatedUnion("type", [
|
|
21692
|
+
external_exports.object({ payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
21693
|
+
external_exports.object({ payload: lifecycleMetadataSchema, type: external_exports.literal("lifecycle-metadata") }).readonly()
|
|
21694
|
+
]);
|
|
21695
|
+
var positionSchema = external_exports.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
21696
|
+
var sharedSessionEventFields = {
|
|
21697
|
+
eventId: identifierStringSchema,
|
|
21698
|
+
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).readonly().optional(),
|
|
21699
|
+
recordedAt: external_exports.iso.datetime({ offset: true }),
|
|
21700
|
+
sessionGenerationId: identifierStringSchema,
|
|
21701
|
+
sessionId: identifierStringSchema
|
|
21702
|
+
};
|
|
21703
|
+
var sessionLiveEventFields = { ...sharedSessionEventFields, position: positionSchema };
|
|
21704
|
+
var sessionEventSchema = external_exports.object({ ...sharedSessionEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly();
|
|
21705
|
+
var sessionLiveEventSchema = external_exports.discriminatedUnion("type", [
|
|
21706
|
+
external_exports.object({ ...sessionLiveEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
21707
|
+
external_exports.object({
|
|
21708
|
+
...sessionLiveEventFields,
|
|
21709
|
+
payload: lifecycleMetadataSchema,
|
|
21710
|
+
type: external_exports.literal("lifecycle-metadata")
|
|
21711
|
+
}).readonly()
|
|
21712
|
+
]);
|
|
21713
|
+
var wireLifecyclePayloadSchema = external_exports.object({
|
|
21714
|
+
kind: identifierStringSchema,
|
|
21715
|
+
commandId: identifierStringSchema.optional(),
|
|
21716
|
+
context: promptExecutionContextSchema.unwrap().passthrough().readonly().optional(),
|
|
21717
|
+
event: external_exports.object({ interactionId: identifierStringSchema.optional() }).passthrough().readonly().optional()
|
|
21718
|
+
}).passthrough().readonly();
|
|
21719
|
+
var wireEventFields = {
|
|
21720
|
+
...sessionLiveEventFields,
|
|
21721
|
+
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).passthrough().readonly().optional()
|
|
21722
|
+
};
|
|
21723
|
+
var sessionWireEventSchema = external_exports.union([
|
|
21724
|
+
external_exports.object({
|
|
21725
|
+
...wireEventFields,
|
|
21726
|
+
type: external_exports.literal("acp"),
|
|
21727
|
+
payload: external_exports.object({ sessionUpdate: identifierStringSchema }).passthrough().readonly()
|
|
21728
|
+
}).passthrough().readonly(),
|
|
21729
|
+
external_exports.object({
|
|
21730
|
+
...wireEventFields,
|
|
21731
|
+
type: external_exports.literal("lifecycle-metadata"),
|
|
21732
|
+
payload: wireLifecyclePayloadSchema
|
|
21733
|
+
}).passthrough().readonly(),
|
|
21734
|
+
external_exports.object({
|
|
21735
|
+
...wireEventFields,
|
|
21736
|
+
type: identifierStringSchema.refine((type) => type !== "acp" && type !== "lifecycle-metadata"),
|
|
21737
|
+
payload: external_exports.record(external_exports.string(), external_exports.unknown()).readonly()
|
|
21738
|
+
}).passthrough().readonly()
|
|
21739
|
+
]);
|
|
21740
|
+
var sessionWireEnvelopeSchema = external_exports.object({
|
|
21741
|
+
kind: external_exports.literal(SESSION_EVENT_KIND),
|
|
21742
|
+
events: external_exports.array(sessionWireEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly()
|
|
21743
|
+
}).passthrough().readonly();
|
|
21744
|
+
function isRecord3(value) {
|
|
21745
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21746
|
+
}
|
|
21747
|
+
var sessionEventBatchSchema = external_exports.array(sessionEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
21748
|
+
var sessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
21749
|
+
var sessionExportSchema = external_exports.object({
|
|
21750
|
+
binding: external_exports.object({
|
|
21751
|
+
bindingId: identifierStringSchema,
|
|
21752
|
+
runtimeId: identifierStringSchema
|
|
21753
|
+
}).readonly(),
|
|
21754
|
+
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
21755
|
+
sessionId: identifierStringSchema,
|
|
21756
|
+
truncated: external_exports.boolean()
|
|
21757
|
+
}).readonly().superRefine((session, context) => {
|
|
21758
|
+
const eventIds = /* @__PURE__ */ new Set();
|
|
21759
|
+
for (const [index2, event] of session.events.entries()) {
|
|
21760
|
+
if (event.sessionId !== session.sessionId) {
|
|
21761
|
+
context.addIssue({
|
|
21762
|
+
code: "custom",
|
|
21763
|
+
message: "Exported event belongs to a different Session",
|
|
21764
|
+
path: ["events", index2, "sessionId"]
|
|
21765
|
+
});
|
|
21766
|
+
}
|
|
21767
|
+
if (eventIds.has(event.eventId)) {
|
|
21768
|
+
context.addIssue({
|
|
21769
|
+
code: "custom",
|
|
21770
|
+
message: "Exported event identities are not unique",
|
|
21771
|
+
path: ["events", index2, "eventId"]
|
|
21772
|
+
});
|
|
21773
|
+
}
|
|
21774
|
+
eventIds.add(event.eventId);
|
|
21775
|
+
}
|
|
21776
|
+
});
|
|
21777
|
+
var mobiusSessionExportSchema = external_exports.object({
|
|
21778
|
+
formatVersion: external_exports.literal("2"),
|
|
21779
|
+
session: sessionExportSchema
|
|
21780
|
+
}).readonly();
|
|
21781
|
+
var sessionEventEnvelopeSchema = external_exports.object({ events: sessionLiveEventBatchSchema, kind: external_exports.literal(SESSION_EVENT_KIND) }).readonly();
|
|
21782
|
+
var sessionEventLogPageSchema = external_exports.object({
|
|
21783
|
+
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
21784
|
+
nextCursor: external_exports.string().min(1).max(512).nullable(),
|
|
21785
|
+
sessionGenerationId: identifierStringSchema,
|
|
21786
|
+
tailCursor: external_exports.string().max(512),
|
|
21787
|
+
// The generation-scoped live position covered by this snapshot, including
|
|
21788
|
+
// coalesced and omitted events. Absent only on older Runtime versions.
|
|
21789
|
+
throughPosition: positionSchema.optional(),
|
|
21790
|
+
truncated: external_exports.boolean(),
|
|
21791
|
+
version: external_exports.literal(2)
|
|
21792
|
+
}).readonly();
|
|
21793
|
+
var sessionEventOmissionSchema = external_exports.literal("agent-reasoning");
|
|
21794
|
+
var nativeEventPageRequestSchema = external_exports.object({
|
|
21795
|
+
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21796
|
+
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21797
|
+
// Legacy callers may still send this option; readers must ignore it.
|
|
21798
|
+
omit: external_exports.array(sessionEventOmissionSchema).max(1).readonly().optional()
|
|
21799
|
+
}).readonly();
|
|
21800
|
+
var queuedPromptRequestEventLogSchema = external_exports.object({
|
|
21801
|
+
commandId: identifierStringSchema,
|
|
21802
|
+
content: external_exports.array(contentBlockSchema).min(1).max(100).readonly(),
|
|
21803
|
+
disposition: shortString.optional(),
|
|
21804
|
+
targetCommandId: identifierStringSchema.optional()
|
|
21805
|
+
}).readonly();
|
|
21806
|
+
var nativeSessionEventsSchema = external_exports.object({
|
|
21807
|
+
events: sessionEventLogPageSchema,
|
|
21808
|
+
queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
21809
|
+
}).readonly();
|
|
21810
|
+
function inputValue(value) {
|
|
21811
|
+
if (typeof value !== "string") {
|
|
21812
|
+
return value;
|
|
21813
|
+
}
|
|
21814
|
+
try {
|
|
21815
|
+
return JSON.parse(value);
|
|
21816
|
+
} catch (cause) {
|
|
21817
|
+
throw new ProtocolMessageError("Session Event Log V2 message is not valid JSON", { cause });
|
|
21818
|
+
}
|
|
21819
|
+
}
|
|
21820
|
+
function decode3(value, schema) {
|
|
21821
|
+
const result = schema.safeParse(inputValue(value));
|
|
21822
|
+
if (!result.success) {
|
|
21823
|
+
throw new ProtocolMessageError("Session Event Log V2 message does not match its schema", {
|
|
21824
|
+
cause: result.error
|
|
21825
|
+
});
|
|
21826
|
+
}
|
|
21827
|
+
return result.data;
|
|
21828
|
+
}
|
|
21829
|
+
function encode3(value, schema) {
|
|
21830
|
+
return JSON.stringify(decode3(value, schema));
|
|
21831
|
+
}
|
|
21832
|
+
function decodedEntries(value, schema, maximum) {
|
|
21833
|
+
return Array.isArray(value) && value.length <= maximum ? value.flatMap((entry) => {
|
|
21834
|
+
const decoded = schema.safeParse(entry);
|
|
21835
|
+
return decoded.success ? [decoded.data] : [];
|
|
21836
|
+
}) : value;
|
|
21837
|
+
}
|
|
21838
|
+
function sanitizeConsumableNativeSessionEvents(value) {
|
|
21839
|
+
const input2 = inputValue(value);
|
|
21840
|
+
if (!isRecord3(input2)) {
|
|
21841
|
+
return input2;
|
|
21842
|
+
}
|
|
21843
|
+
const page = input2["events"];
|
|
21844
|
+
const queuedPromptRequests = input2["queuedPromptRequests"];
|
|
21845
|
+
return {
|
|
21846
|
+
...input2,
|
|
21847
|
+
events: isRecord3(page) ? { ...page, events: decodedEntries(page["events"], sessionEventSchema, MAX_EVENT_COUNT) } : page,
|
|
21848
|
+
queuedPromptRequests: decodedEntries(
|
|
21849
|
+
queuedPromptRequests,
|
|
21850
|
+
queuedPromptRequestEventLogSchema,
|
|
21851
|
+
MAX_COLLECTION_SIZE2
|
|
21852
|
+
)
|
|
21853
|
+
};
|
|
21854
|
+
}
|
|
21855
|
+
var knownSessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
21856
|
+
var decodeSessionEvent = (value) => decode3(value, sessionEventSchema);
|
|
21857
|
+
var decodeKnownSessionEventPayload = (value) => {
|
|
21858
|
+
const decoded = sessionEventPayloadSchema.safeParse(inputValue(value));
|
|
21859
|
+
return decoded.success ? decoded.data : null;
|
|
21860
|
+
};
|
|
21861
|
+
var decodeSessionEventEnvelope = (value) => decode3(value, sessionEventEnvelopeSchema);
|
|
21862
|
+
var encodeSessionEventEnvelope = (value) => encode3(value, sessionEventEnvelopeSchema);
|
|
21863
|
+
var decodeAcpSessionUpdate = (value) => decode3(value, acpSessionUpdateSchema);
|
|
21864
|
+
var decodeKnownNativeSessionEvents = (value) => decode3(sanitizeConsumableNativeSessionEvents(value), nativeSessionEventsSchema);
|
|
21865
|
+
|
|
21866
|
+
// ../mobius-sdk/src/protocol/session/files/index.ts
|
|
21867
|
+
var FILE_READ_KIND = "file.read";
|
|
21868
|
+
var FILE_BEGIN_KIND = "file.begin";
|
|
21869
|
+
var FILE_END_KIND = "file.end";
|
|
21870
|
+
var FILE_FAILED_KIND = "file.failed";
|
|
21871
|
+
var CONTENT_WRITE_KIND = "content.write";
|
|
21872
|
+
var CONTENT_COMMIT_KIND = "content.commit";
|
|
21873
|
+
var CONTENT_READY_KIND = "content.ready";
|
|
21874
|
+
var CONTENT_AVAILABLE_KIND = "content.available";
|
|
21875
|
+
var CONTENT_CHUNK_MAX_BYTES = 192 * 1024;
|
|
21876
|
+
var CONTENT_WRITE_MAX_BYTES = 32 * 1024 * 1024;
|
|
21877
|
+
var PROMPT_IMAGE_MAX_BYTES = 5e6;
|
|
21878
|
+
var CONTENT_CHUNK_MAGIC = new Uint8Array([77, 66, 67, 49]);
|
|
21879
|
+
var CONTENT_CHUNK_HEADER_BYTES = CONTENT_CHUNK_MAGIC.byteLength + 1 + 4;
|
|
21880
|
+
var fileReadCommandSchema = external_exports.object({
|
|
21881
|
+
kind: external_exports.literal(FILE_READ_KIND),
|
|
21882
|
+
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
21883
|
+
requestId: identifierStringSchema,
|
|
21884
|
+
sessionId: identifierStringSchema,
|
|
21885
|
+
path: external_exports.string().min(1).max(4096)
|
|
21886
|
+
}).readonly();
|
|
21887
|
+
var fileBeginEventSchema = external_exports.object({
|
|
21888
|
+
byteLength: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
21889
|
+
kind: external_exports.literal(FILE_BEGIN_KIND),
|
|
21890
|
+
mediaType: external_exports.string().min(1).max(255),
|
|
21891
|
+
modifiedAt: external_exports.iso.datetime({ offset: true }),
|
|
21892
|
+
name: external_exports.string().min(1).max(500),
|
|
21893
|
+
requestId: identifierStringSchema,
|
|
21894
|
+
sessionId: identifierStringSchema
|
|
21895
|
+
}).readonly();
|
|
21896
|
+
var contentWriteCommandSchema = external_exports.object({
|
|
21897
|
+
byteLength: external_exports.number().int().positive().max(CONTENT_WRITE_MAX_BYTES),
|
|
21898
|
+
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
21899
|
+
contentKind: external_exports.enum(["image", "resource"]),
|
|
21900
|
+
kind: external_exports.literal(CONTENT_WRITE_KIND),
|
|
21901
|
+
mediaType: external_exports.string().min(1).max(255),
|
|
21902
|
+
name: external_exports.string().min(1).max(500),
|
|
21903
|
+
requestId: identifierStringSchema,
|
|
21904
|
+
sessionId: identifierStringSchema
|
|
21905
|
+
}).readonly();
|
|
21906
|
+
var contentCommitCommandSchema = external_exports.object({
|
|
21907
|
+
kind: external_exports.literal(CONTENT_COMMIT_KIND),
|
|
21908
|
+
requestId: identifierStringSchema,
|
|
21909
|
+
sessionId: identifierStringSchema
|
|
21910
|
+
}).readonly();
|
|
21911
|
+
var contentReadyEventSchema = external_exports.object({
|
|
21912
|
+
kind: external_exports.literal(CONTENT_READY_KIND),
|
|
21913
|
+
requestId: identifierStringSchema,
|
|
21914
|
+
sessionId: identifierStringSchema
|
|
21915
|
+
}).readonly();
|
|
21916
|
+
var contentAvailableEventSchema = external_exports.object({
|
|
21917
|
+
byteLength: external_exports.number().int().positive().max(CONTENT_WRITE_MAX_BYTES),
|
|
21918
|
+
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
21919
|
+
kind: external_exports.literal(CONTENT_AVAILABLE_KIND),
|
|
21920
|
+
requestId: identifierStringSchema,
|
|
21921
|
+
sessionId: identifierStringSchema
|
|
21922
|
+
}).readonly();
|
|
21923
|
+
function binaryBytes(value) {
|
|
21924
|
+
if (value instanceof ArrayBuffer) {
|
|
21925
|
+
return new Uint8Array(value);
|
|
21926
|
+
}
|
|
21927
|
+
if (ArrayBuffer.isView(value)) {
|
|
21928
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
21929
|
+
}
|
|
21930
|
+
throw new Error("Content chunk must be a binary WebSocket frame");
|
|
21931
|
+
}
|
|
21932
|
+
function encodeContentChunkFrame(frame) {
|
|
21933
|
+
if (!isIdentifier(frame.requestId)) {
|
|
21934
|
+
throw new Error("Content chunk request identifier is invalid");
|
|
21935
|
+
}
|
|
21936
|
+
if (!Number.isSafeInteger(frame.sequence) || frame.sequence < 0 || frame.sequence > 4294967295) {
|
|
21937
|
+
throw new Error("Content chunk sequence is invalid");
|
|
21938
|
+
}
|
|
21939
|
+
if (frame.bytes.byteLength < 1 || frame.bytes.byteLength > CONTENT_CHUNK_MAX_BYTES) {
|
|
21940
|
+
throw new Error("Content chunk size is invalid");
|
|
21941
|
+
}
|
|
21942
|
+
const requestId = new TextEncoder().encode(frame.requestId);
|
|
21943
|
+
if (requestId.byteLength > 255) {
|
|
21944
|
+
throw new Error("Content chunk request identifier is too long");
|
|
21945
|
+
}
|
|
21946
|
+
const encoded = new Uint8Array(CONTENT_CHUNK_HEADER_BYTES + requestId.byteLength + frame.bytes.byteLength);
|
|
21947
|
+
encoded.set(CONTENT_CHUNK_MAGIC, 0);
|
|
21948
|
+
encoded[CONTENT_CHUNK_MAGIC.byteLength] = requestId.byteLength;
|
|
21949
|
+
new DataView(encoded.buffer).setUint32(CONTENT_CHUNK_MAGIC.byteLength + 1, frame.sequence);
|
|
21950
|
+
encoded.set(requestId, CONTENT_CHUNK_HEADER_BYTES);
|
|
21951
|
+
encoded.set(frame.bytes, CONTENT_CHUNK_HEADER_BYTES + requestId.byteLength);
|
|
21952
|
+
return encoded;
|
|
21953
|
+
}
|
|
21954
|
+
function decodeContentChunkFrame(value) {
|
|
21955
|
+
const encoded = binaryBytes(value);
|
|
21956
|
+
if (encoded.byteLength <= CONTENT_CHUNK_HEADER_BYTES || !CONTENT_CHUNK_MAGIC.every((byte, index2) => encoded[index2] === byte)) {
|
|
21957
|
+
throw new Error("Content chunk frame header is invalid");
|
|
21958
|
+
}
|
|
21959
|
+
const requestIdLength = encoded[CONTENT_CHUNK_MAGIC.byteLength] ?? 0;
|
|
21960
|
+
const payloadOffset = CONTENT_CHUNK_HEADER_BYTES + requestIdLength;
|
|
21961
|
+
if (requestIdLength < 1 || payloadOffset >= encoded.byteLength) {
|
|
21962
|
+
throw new Error("Content chunk frame length is invalid");
|
|
21963
|
+
}
|
|
21964
|
+
const requestId = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
|
|
21965
|
+
encoded.subarray(CONTENT_CHUNK_HEADER_BYTES, payloadOffset)
|
|
21966
|
+
);
|
|
21967
|
+
const bytes = encoded.slice(payloadOffset);
|
|
21968
|
+
const sequence = new DataView(encoded.buffer, encoded.byteOffset, encoded.byteLength).getUint32(
|
|
21969
|
+
CONTENT_CHUNK_MAGIC.byteLength + 1
|
|
21970
|
+
);
|
|
21971
|
+
if (!isIdentifier(requestId) || bytes.byteLength > CONTENT_CHUNK_MAX_BYTES) {
|
|
21972
|
+
throw new Error("Content chunk frame is invalid");
|
|
21973
|
+
}
|
|
21974
|
+
return { bytes, requestId, sequence };
|
|
21975
|
+
}
|
|
21976
|
+
var fileEndEventSchema = external_exports.object({
|
|
21977
|
+
kind: external_exports.literal(FILE_END_KIND),
|
|
21978
|
+
requestId: identifierStringSchema,
|
|
21979
|
+
sessionId: identifierStringSchema
|
|
21980
|
+
}).readonly();
|
|
21981
|
+
var fileFailedEventSchema = external_exports.object({
|
|
21982
|
+
code: identifierStringSchema,
|
|
21983
|
+
kind: external_exports.literal(FILE_FAILED_KIND),
|
|
21984
|
+
message: external_exports.string().min(1).max(500),
|
|
21985
|
+
requestId: identifierStringSchema,
|
|
21986
|
+
sessionId: identifierStringSchema
|
|
21987
|
+
}).readonly();
|
|
21988
|
+
var decodeFileReadCommand = (encoded) => decodeZodMessage(encoded, fileReadCommandSchema);
|
|
21989
|
+
var encodeFileReadCommand = (message) => encodeZodMessage(message, fileReadCommandSchema);
|
|
21990
|
+
var decodeFileBeginEvent = (encoded) => decodeZodMessage(encoded, fileBeginEventSchema);
|
|
21991
|
+
var encodeFileBeginEvent = (message) => encodeZodMessage(message, fileBeginEventSchema);
|
|
21992
|
+
var decodeFileEndEvent = (encoded) => decodeZodMessage(encoded, fileEndEventSchema);
|
|
21993
|
+
var encodeFileEndEvent = (message) => encodeZodMessage(message, fileEndEventSchema);
|
|
21994
|
+
var decodeFileFailedEvent = (encoded) => decodeZodMessage(encoded, fileFailedEventSchema);
|
|
21995
|
+
var encodeFileFailedEvent = (message) => encodeZodMessage(message, fileFailedEventSchema);
|
|
21996
|
+
var decodeContentWriteCommand = (encoded) => decodeZodMessage(encoded, contentWriteCommandSchema);
|
|
21997
|
+
var encodeContentWriteCommand = (message) => encodeZodMessage(message, contentWriteCommandSchema);
|
|
21998
|
+
var decodeContentCommitCommand = (encoded) => decodeZodMessage(encoded, contentCommitCommandSchema);
|
|
21999
|
+
var encodeContentCommitCommand = (message) => encodeZodMessage(message, contentCommitCommandSchema);
|
|
22000
|
+
var decodeContentReadyEvent = (encoded) => decodeZodMessage(encoded, contentReadyEventSchema);
|
|
22001
|
+
var encodeContentReadyEvent = (message) => encodeZodMessage(message, contentReadyEventSchema);
|
|
22002
|
+
var decodeContentAvailableEvent = (encoded) => decodeZodMessage(encoded, contentAvailableEventSchema);
|
|
22003
|
+
var encodeContentAvailableEvent = (message) => encodeZodMessage(message, contentAvailableEventSchema);
|
|
22004
|
+
|
|
21550
22005
|
// ../mobius-sdk/src/protocol/session/lifecycle/index.ts
|
|
21551
22006
|
var SESSION_PREPARE_KIND = "session.prepare";
|
|
21552
22007
|
var SESSION_READY_KIND = "session.ready";
|
|
@@ -21802,739 +22257,176 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21802
22257
|
...value["historyPolicy"] === void 0 ? {} : {
|
|
21803
22258
|
historyPolicy: readHistoryPolicy(value)
|
|
21804
22259
|
},
|
|
21805
|
-
kind: SESSION_PROMPT_KIND,
|
|
21806
|
-
prompt,
|
|
21807
|
-
...hasSessionConfigurations ? { sessionConfigurations } : {},
|
|
21808
|
-
sessionId: readIdentifier(value, "sessionId"),
|
|
21809
|
-
targetCommandId
|
|
21810
|
-
};
|
|
21811
|
-
}
|
|
21812
|
-
function readHistoryPolicy(value) {
|
|
21813
|
-
const field = value["historyPolicy"];
|
|
21814
|
-
if (field === SessionHistoryPolicy.Eager || field === SessionHistoryPolicy.ExecutionOnly) {
|
|
21815
|
-
return field;
|
|
21816
|
-
}
|
|
21817
|
-
throw new ProtocolMessageError("Invalid value field: historyPolicy");
|
|
21818
|
-
}
|
|
21819
|
-
function decodeSessionCancelCommand(encoded) {
|
|
21820
|
-
const value = parseJson(encoded);
|
|
21821
|
-
assertKind(value, SESSION_CANCEL_KIND);
|
|
21822
|
-
return {
|
|
21823
|
-
commandId: readIdentifier(value, "commandId"),
|
|
21824
|
-
kind: SESSION_CANCEL_KIND,
|
|
21825
|
-
sessionId: readIdentifier(value, "sessionId")
|
|
21826
|
-
};
|
|
21827
|
-
}
|
|
21828
|
-
function decodeSessionPromptDispositionCommand(encoded) {
|
|
21829
|
-
const value = parseJson(encoded);
|
|
21830
|
-
assertKind(value, SESSION_PROMPT_DISPOSITION_KIND);
|
|
21831
|
-
if (readPromptDisposition(value) !== SessionPromptDisposition.Steer) {
|
|
21832
|
-
throw new ProtocolMessageError("Only queued prompts can be steered");
|
|
21833
|
-
}
|
|
21834
|
-
return {
|
|
21835
|
-
commandId: readIdentifier(value, "commandId"),
|
|
21836
|
-
disposition: SessionPromptDisposition.Steer,
|
|
21837
|
-
kind: SESSION_PROMPT_DISPOSITION_KIND,
|
|
21838
|
-
sessionId: readIdentifier(value, "sessionId")
|
|
21839
|
-
};
|
|
21840
|
-
}
|
|
21841
|
-
function encodeSessionPromptCommand(message) {
|
|
21842
|
-
const command = decodeSessionPromptCommand(JSON.stringify(message));
|
|
21843
|
-
return JSON.stringify({
|
|
21844
|
-
...command,
|
|
21845
|
-
// Keep text prompts compatible with the previous Runtime release while
|
|
21846
|
-
// attachments move to the content-key protocol. Older Runtimes ignore
|
|
21847
|
-
// `attachments` and require both legacy arrays to be present.
|
|
21848
|
-
images: [],
|
|
21849
|
-
resources: []
|
|
21850
|
-
});
|
|
21851
|
-
}
|
|
21852
|
-
function encodeSessionCancelCommand(message) {
|
|
21853
|
-
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
21854
|
-
}
|
|
21855
|
-
function encodeSessionPromptDispositionCommand(message) {
|
|
21856
|
-
return JSON.stringify(decodeSessionPromptDispositionCommand(JSON.stringify(message)));
|
|
21857
|
-
}
|
|
21858
|
-
|
|
21859
|
-
// ../mobius-sdk/src/protocol/session/native/index.ts
|
|
21860
|
-
var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
21861
|
-
var NATIVE_SESSION_RESULT_KIND = "native.session.result";
|
|
21862
|
-
var NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
|
|
21863
|
-
var envelope = {
|
|
21864
|
-
requestId: identifierStringSchema,
|
|
21865
|
-
sessionId: identifierStringSchema
|
|
21866
|
-
};
|
|
21867
|
-
var activeTurnSnapshotSchema = external_exports.object({
|
|
21868
|
-
commandId: identifierStringSchema,
|
|
21869
|
-
epoch: identifierStringSchema,
|
|
21870
|
-
interaction: external_exports.discriminatedUnion("kind", [sessionPermissionRequestedEventSchema, sessionElicitationRequestedEventSchema]).nullable(),
|
|
21871
|
-
sequence: external_exports.number().int().nonnegative(),
|
|
21872
|
-
state: external_exports.literal("running")
|
|
21873
|
-
}).readonly();
|
|
21874
|
-
var identity = {
|
|
21875
|
-
...envelope,
|
|
21876
|
-
kind: external_exports.literal(NATIVE_SESSION_REQUEST_KIND),
|
|
21877
|
-
additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
|
|
21878
|
-
agentId: identifierStringSchema,
|
|
21879
|
-
bindingId: identifierStringSchema,
|
|
21880
|
-
directoryId: DIRECTORY_IDENTIFIER
|
|
21881
|
-
};
|
|
21882
|
-
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
21883
|
-
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
21884
|
-
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21885
|
-
external_exports.object({
|
|
21886
|
-
...identity,
|
|
21887
|
-
action: external_exports.literal("list"),
|
|
21888
|
-
cursor: identifierStringSchema.nullable()
|
|
21889
|
-
}).readonly(),
|
|
21890
|
-
external_exports.object({
|
|
21891
|
-
...identity,
|
|
21892
|
-
action: external_exports.enum(["import", "fork"]),
|
|
21893
|
-
entryId: identifierStringSchema,
|
|
21894
|
-
targetSessionId: identifierStringSchema
|
|
21895
|
-
}).readonly()
|
|
21896
|
-
]);
|
|
21897
|
-
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
21898
|
-
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
21899
|
-
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21900
|
-
external_exports.object({
|
|
21901
|
-
...identity,
|
|
21902
|
-
action: external_exports.literal("list"),
|
|
21903
|
-
cursor: identifierStringSchema.nullable()
|
|
21904
|
-
}).readonly(),
|
|
21905
|
-
external_exports.object({
|
|
21906
|
-
...identity,
|
|
21907
|
-
action: external_exports.enum(["import", "fork"]),
|
|
21908
|
-
entryId: identifierStringSchema,
|
|
21909
|
-
targetSessionId: identifierStringSchema
|
|
21910
|
-
}).readonly()
|
|
21911
|
-
]);
|
|
21912
|
-
var nativeSessionEntrySchema = external_exports.object({
|
|
21913
|
-
entryId: identifierStringSchema,
|
|
21914
|
-
mobiusSessionIds: external_exports.array(identifierStringSchema).max(500).readonly(),
|
|
21915
|
-
nativeSessionId: identifierStringSchema,
|
|
21916
|
-
title: external_exports.string().max(500),
|
|
21917
|
-
directoryId: DIRECTORY_IDENTIFIER,
|
|
21918
|
-
directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
|
|
21919
|
-
updatedAt: external_exports.iso.datetime({ offset: true }).nullable(),
|
|
21920
|
-
additionalDirectories: external_exports.array(external_exports.object({ directoryId: DIRECTORY_IDENTIFIER, name: external_exports.string().min(1).max(255) }).readonly()).max(16).readonly()
|
|
21921
|
-
}).readonly();
|
|
21922
|
-
var resultEnvelope = {
|
|
21923
|
-
...envelope,
|
|
21924
|
-
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
21925
|
-
};
|
|
21926
|
-
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
21927
|
-
external_exports.object({
|
|
21928
|
-
...resultEnvelope,
|
|
21929
|
-
action: external_exports.literal("active-turn"),
|
|
21930
|
-
targetSessionId: identifierStringSchema,
|
|
21931
|
-
queued: external_exports.array(
|
|
21932
|
-
external_exports.object({
|
|
21933
|
-
commandId: identifierStringSchema,
|
|
21934
|
-
prompt: external_exports.string().max(1e5),
|
|
21935
|
-
attachments: external_exports.array(promptAttachmentSchema).max(16).readonly()
|
|
21936
|
-
}).readonly()
|
|
21937
|
-
).readonly(),
|
|
21938
|
-
turn: activeTurnSnapshotSchema.nullable()
|
|
21939
|
-
}).readonly(),
|
|
21940
|
-
external_exports.object({
|
|
21941
|
-
...resultEnvelope,
|
|
21942
|
-
action: external_exports.literal("find"),
|
|
21943
|
-
entry: nativeSessionEntrySchema
|
|
21944
|
-
}).readonly(),
|
|
21945
|
-
external_exports.object({
|
|
21946
|
-
...resultEnvelope,
|
|
21947
|
-
action: external_exports.literal("list"),
|
|
21948
|
-
capabilities: sessionCapabilitiesSchema,
|
|
21949
|
-
entries: external_exports.array(nativeSessionEntrySchema).max(500).readonly(),
|
|
21950
|
-
nextCursor: identifierStringSchema.nullable()
|
|
21951
|
-
}).readonly(),
|
|
21952
|
-
external_exports.object({
|
|
21953
|
-
...resultEnvelope,
|
|
21954
|
-
action: external_exports.enum(["import", "fork"]),
|
|
21955
|
-
targetSessionId: identifierStringSchema,
|
|
21956
|
-
ready: sessionReadyEventSchema,
|
|
21957
|
-
title: external_exports.string().max(500)
|
|
21958
|
-
}).readonly()
|
|
21959
|
-
]);
|
|
21960
|
-
var nativeSessionCancelSchema = external_exports.object({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
|
|
21961
|
-
function decode3(schema, encoded) {
|
|
21962
|
-
try {
|
|
21963
|
-
const value = JSON.parse(encoded);
|
|
21964
|
-
return schema.parse(value);
|
|
21965
|
-
} catch (cause) {
|
|
21966
|
-
throw new ProtocolMessageError("Invalid native session message", { cause });
|
|
21967
|
-
}
|
|
21968
|
-
}
|
|
21969
|
-
var decodeNativeSessionCommand = (encoded) => decode3(nativeSessionCommandSchema, encoded);
|
|
21970
|
-
var encodeNativeSessionCommand = (value) => JSON.stringify(nativeSessionCommandSchema.parse(value));
|
|
21971
|
-
var decodeNativeSessionResult = (encoded) => decode3(nativeSessionResultSchema, encoded);
|
|
21972
|
-
var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
|
|
21973
|
-
var decodeNativeSessionCancel = (encoded) => decode3(nativeSessionCancelSchema, encoded);
|
|
21974
|
-
var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
|
|
21975
|
-
|
|
21976
|
-
// ../mobius-sdk/src/protocol/session/observability/event-log.ts
|
|
21977
|
-
var MAX_EVENT_COUNT = 1e4;
|
|
21978
|
-
var MAX_COLLECTION_SIZE2 = 1e3;
|
|
21979
|
-
var MAX_CONTENT_LENGTH2 = 1e6;
|
|
21980
|
-
var SESSION_EVENT_KIND = "session.event.v2";
|
|
21981
|
-
var SESSION_EVENT_BATCH_MAX_SIZE = 1e3;
|
|
21982
|
-
var boundedString2 = external_exports.string().max(MAX_CONTENT_LENGTH2);
|
|
21983
|
-
var shortString = external_exports.string().max(2048);
|
|
21984
|
-
var externalContentKeySchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
21985
|
-
var annotationsSchema = external_exports.object({
|
|
21986
|
-
audience: external_exports.array(external_exports.enum(["assistant", "user"])).max(2).readonly().nullable().optional(),
|
|
21987
|
-
lastModified: shortString.nullable().optional(),
|
|
21988
|
-
priority: external_exports.number().finite().nullable().optional()
|
|
21989
|
-
}).readonly();
|
|
21990
|
-
var contentFields = { annotations: annotationsSchema.nullable().optional() };
|
|
21991
|
-
var textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
|
|
21992
|
-
var imageContentSchema = external_exports.object({
|
|
21993
|
-
...contentFields,
|
|
21994
|
-
data: external_exports.string(),
|
|
21995
|
-
mimeType: shortString,
|
|
21996
|
-
type: external_exports.literal("image"),
|
|
21997
|
-
uri: boundedString2.nullable().optional()
|
|
21998
|
-
}).readonly();
|
|
21999
|
-
var audioContentSchema = external_exports.object({ ...contentFields, data: external_exports.string(), mimeType: shortString, type: external_exports.literal("audio") }).readonly();
|
|
22000
|
-
var externalImageContentSchema = external_exports.object({
|
|
22001
|
-
...contentFields,
|
|
22002
|
-
byteLength: external_exports.number().int().positive().safe(),
|
|
22003
|
-
imageKey: externalContentKeySchema,
|
|
22004
|
-
mimeType: shortString,
|
|
22005
|
-
type: external_exports.literal("external_image"),
|
|
22006
|
-
uri: boundedString2.nullable().optional()
|
|
22007
|
-
}).readonly();
|
|
22008
|
-
var externalAudioContentSchema = external_exports.object({
|
|
22009
|
-
...contentFields,
|
|
22010
|
-
audioKey: externalContentKeySchema,
|
|
22011
|
-
byteLength: external_exports.number().int().positive().safe(),
|
|
22012
|
-
mimeType: shortString,
|
|
22013
|
-
type: external_exports.literal("external_audio")
|
|
22014
|
-
}).readonly();
|
|
22015
|
-
var externalResourceContentSchema = external_exports.object({
|
|
22016
|
-
...contentFields,
|
|
22017
|
-
byteLength: external_exports.number().int().positive().safe(),
|
|
22018
|
-
encoding: external_exports.enum(["binary", "text"]),
|
|
22019
|
-
mimeType: shortString.nullable().optional(),
|
|
22020
|
-
resourceKey: externalContentKeySchema,
|
|
22021
|
-
type: external_exports.literal("external_resource"),
|
|
22022
|
-
uri: boundedString2
|
|
22023
|
-
}).readonly();
|
|
22024
|
-
var resourceLinkSchema = external_exports.object({
|
|
22025
|
-
...contentFields,
|
|
22026
|
-
description: boundedString2.nullable().optional(),
|
|
22027
|
-
mimeType: shortString.nullable().optional(),
|
|
22028
|
-
name: shortString,
|
|
22029
|
-
size: external_exports.number().int().nonnegative().safe().nullable().optional(),
|
|
22030
|
-
title: shortString.nullable().optional(),
|
|
22031
|
-
type: external_exports.literal("resource_link"),
|
|
22032
|
-
uri: boundedString2
|
|
22033
|
-
}).readonly();
|
|
22034
|
-
var textResourceSchema = external_exports.object({
|
|
22035
|
-
mimeType: shortString.nullable().optional(),
|
|
22036
|
-
text: boundedString2,
|
|
22037
|
-
uri: boundedString2
|
|
22038
|
-
}).readonly();
|
|
22039
|
-
var blobResourceSchema = external_exports.object({
|
|
22040
|
-
blob: external_exports.string(),
|
|
22041
|
-
mimeType: shortString.nullable().optional(),
|
|
22042
|
-
uri: boundedString2
|
|
22043
|
-
}).readonly();
|
|
22044
|
-
var embeddedResourceSchema = external_exports.object({
|
|
22045
|
-
...contentFields,
|
|
22046
|
-
resource: external_exports.union([textResourceSchema, blobResourceSchema]),
|
|
22047
|
-
type: external_exports.literal("resource")
|
|
22048
|
-
}).readonly();
|
|
22049
|
-
var contentBlockSchema = external_exports.discriminatedUnion("type", [
|
|
22050
|
-
textContentSchema,
|
|
22051
|
-
imageContentSchema,
|
|
22052
|
-
audioContentSchema,
|
|
22053
|
-
resourceLinkSchema,
|
|
22054
|
-
embeddedResourceSchema,
|
|
22055
|
-
externalImageContentSchema,
|
|
22056
|
-
externalAudioContentSchema,
|
|
22057
|
-
externalResourceContentSchema
|
|
22058
|
-
]);
|
|
22059
|
-
var toolCallContentSchema = external_exports.discriminatedUnion("type", [
|
|
22060
|
-
external_exports.object({ content: contentBlockSchema, type: external_exports.literal("content") }).readonly(),
|
|
22061
|
-
external_exports.object({
|
|
22062
|
-
newText: boundedString2,
|
|
22063
|
-
oldText: boundedString2.nullable().optional(),
|
|
22064
|
-
path: boundedString2,
|
|
22065
|
-
type: external_exports.literal("diff")
|
|
22066
|
-
}).readonly(),
|
|
22067
|
-
external_exports.object({ terminalId: shortString, type: external_exports.literal("terminal") }).readonly()
|
|
22068
|
-
]);
|
|
22069
|
-
var toolKindSchema = external_exports.enum([
|
|
22070
|
-
"read",
|
|
22071
|
-
"edit",
|
|
22072
|
-
"delete",
|
|
22073
|
-
"move",
|
|
22074
|
-
"search",
|
|
22075
|
-
"execute",
|
|
22076
|
-
"think",
|
|
22077
|
-
"fetch",
|
|
22078
|
-
"switch_mode",
|
|
22079
|
-
"other"
|
|
22080
|
-
]);
|
|
22081
|
-
var toolStatusSchema = external_exports.enum(["pending", "in_progress", "completed", "failed"]);
|
|
22082
|
-
var backgroundTaskSchema = external_exports.object({
|
|
22083
|
-
id: shortString,
|
|
22084
|
-
status: external_exports.enum(["running", "completed", "failed", "stopped", "unknown"])
|
|
22085
|
-
}).readonly();
|
|
22086
|
-
var toolPatchFields = {
|
|
22087
|
-
backgroundTask: backgroundTaskSchema.optional(),
|
|
22088
|
-
content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
|
|
22089
|
-
kind: toolKindSchema.nullable().optional(),
|
|
22090
|
-
locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
|
|
22091
|
-
name: shortString.nullable().optional(),
|
|
22092
|
-
rawInput: boundedJsonSchema.optional(),
|
|
22093
|
-
rawOutput: boundedJsonSchema.optional(),
|
|
22094
|
-
status: toolStatusSchema.nullable().optional(),
|
|
22095
|
-
title: boundedString2.nullable().optional()
|
|
22260
|
+
kind: SESSION_PROMPT_KIND,
|
|
22261
|
+
prompt,
|
|
22262
|
+
...hasSessionConfigurations ? { sessionConfigurations } : {},
|
|
22263
|
+
sessionId: readIdentifier(value, "sessionId"),
|
|
22264
|
+
targetCommandId
|
|
22265
|
+
};
|
|
22266
|
+
}
|
|
22267
|
+
function readHistoryPolicy(value) {
|
|
22268
|
+
const field = value["historyPolicy"];
|
|
22269
|
+
if (field === SessionHistoryPolicy.Eager || field === SessionHistoryPolicy.ExecutionOnly) {
|
|
22270
|
+
return field;
|
|
22271
|
+
}
|
|
22272
|
+
throw new ProtocolMessageError("Invalid value field: historyPolicy");
|
|
22273
|
+
}
|
|
22274
|
+
function decodeSessionCancelCommand(encoded) {
|
|
22275
|
+
const value = parseJson(encoded);
|
|
22276
|
+
assertKind(value, SESSION_CANCEL_KIND);
|
|
22277
|
+
return {
|
|
22278
|
+
commandId: readIdentifier(value, "commandId"),
|
|
22279
|
+
kind: SESSION_CANCEL_KIND,
|
|
22280
|
+
sessionId: readIdentifier(value, "sessionId")
|
|
22281
|
+
};
|
|
22282
|
+
}
|
|
22283
|
+
function decodeSessionPromptDispositionCommand(encoded) {
|
|
22284
|
+
const value = parseJson(encoded);
|
|
22285
|
+
assertKind(value, SESSION_PROMPT_DISPOSITION_KIND);
|
|
22286
|
+
if (readPromptDisposition(value) !== SessionPromptDisposition.Steer) {
|
|
22287
|
+
throw new ProtocolMessageError("Only queued prompts can be steered");
|
|
22288
|
+
}
|
|
22289
|
+
return {
|
|
22290
|
+
commandId: readIdentifier(value, "commandId"),
|
|
22291
|
+
disposition: SessionPromptDisposition.Steer,
|
|
22292
|
+
kind: SESSION_PROMPT_DISPOSITION_KIND,
|
|
22293
|
+
sessionId: readIdentifier(value, "sessionId")
|
|
22294
|
+
};
|
|
22295
|
+
}
|
|
22296
|
+
function encodeSessionPromptCommand(message) {
|
|
22297
|
+
const command = decodeSessionPromptCommand(JSON.stringify(message));
|
|
22298
|
+
return JSON.stringify({
|
|
22299
|
+
...command,
|
|
22300
|
+
// Keep text prompts compatible with the previous Runtime release while
|
|
22301
|
+
// attachments move to the content-key protocol. Older Runtimes ignore
|
|
22302
|
+
// `attachments` and require both legacy arrays to be present.
|
|
22303
|
+
images: [],
|
|
22304
|
+
resources: []
|
|
22305
|
+
});
|
|
22306
|
+
}
|
|
22307
|
+
function encodeSessionCancelCommand(message) {
|
|
22308
|
+
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
22309
|
+
}
|
|
22310
|
+
function encodeSessionPromptDispositionCommand(message) {
|
|
22311
|
+
return JSON.stringify(decodeSessionPromptDispositionCommand(JSON.stringify(message)));
|
|
22312
|
+
}
|
|
22313
|
+
|
|
22314
|
+
// ../mobius-sdk/src/protocol/session/native/index.ts
|
|
22315
|
+
var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
22316
|
+
var NATIVE_SESSION_RESULT_KIND = "native.session.result";
|
|
22317
|
+
var NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
|
|
22318
|
+
var envelope = {
|
|
22319
|
+
requestId: identifierStringSchema,
|
|
22320
|
+
sessionId: identifierStringSchema
|
|
22096
22321
|
};
|
|
22097
|
-
var
|
|
22098
|
-
|
|
22099
|
-
|
|
22100
|
-
|
|
22322
|
+
var activeTurnSnapshotSchema = external_exports.object({
|
|
22323
|
+
commandId: identifierStringSchema,
|
|
22324
|
+
epoch: identifierStringSchema,
|
|
22325
|
+
interaction: external_exports.discriminatedUnion("kind", [sessionPermissionRequestedEventSchema, sessionElicitationRequestedEventSchema]).nullable(),
|
|
22326
|
+
sequence: external_exports.number().int().nonnegative(),
|
|
22327
|
+
state: external_exports.literal("running")
|
|
22101
22328
|
}).readonly();
|
|
22102
|
-
var
|
|
22329
|
+
var identity = {
|
|
22330
|
+
...envelope,
|
|
22331
|
+
kind: external_exports.literal(NATIVE_SESSION_REQUEST_KIND),
|
|
22332
|
+
additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
|
|
22333
|
+
agentId: identifierStringSchema,
|
|
22334
|
+
bindingId: identifierStringSchema,
|
|
22335
|
+
directoryId: DIRECTORY_IDENTIFIER
|
|
22336
|
+
};
|
|
22337
|
+
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
22338
|
+
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
22339
|
+
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
22103
22340
|
external_exports.object({
|
|
22104
|
-
|
|
22105
|
-
|
|
22106
|
-
|
|
22341
|
+
...identity,
|
|
22342
|
+
action: external_exports.literal("list"),
|
|
22343
|
+
cursor: identifierStringSchema.nullable()
|
|
22107
22344
|
}).readonly(),
|
|
22108
|
-
external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString2 }).readonly(),
|
|
22109
22345
|
external_exports.object({
|
|
22110
|
-
|
|
22111
|
-
|
|
22112
|
-
|
|
22346
|
+
...identity,
|
|
22347
|
+
action: external_exports.enum(["import", "fork"]),
|
|
22348
|
+
entryId: identifierStringSchema,
|
|
22349
|
+
targetSessionId: identifierStringSchema
|
|
22113
22350
|
}).readonly()
|
|
22114
22351
|
]);
|
|
22115
|
-
var
|
|
22116
|
-
|
|
22117
|
-
|
|
22118
|
-
name: shortString
|
|
22119
|
-
}).readonly();
|
|
22120
|
-
var configSelectOptionSchema = external_exports.object({
|
|
22121
|
-
description: boundedString2.nullable().optional(),
|
|
22122
|
-
name: shortString,
|
|
22123
|
-
value: shortString
|
|
22124
|
-
}).readonly();
|
|
22125
|
-
var configSelectGroupSchema = external_exports.object({
|
|
22126
|
-
group: shortString,
|
|
22127
|
-
name: shortString,
|
|
22128
|
-
options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
22129
|
-
}).readonly();
|
|
22130
|
-
var configBaseFields = {
|
|
22131
|
-
category: shortString.nullable().optional(),
|
|
22132
|
-
description: boundedString2.nullable().optional(),
|
|
22133
|
-
id: shortString,
|
|
22134
|
-
name: shortString
|
|
22135
|
-
};
|
|
22136
|
-
var sessionConfigOptionSchema2 = external_exports.discriminatedUnion("type", [
|
|
22137
|
-
external_exports.object({
|
|
22138
|
-
...configBaseFields,
|
|
22139
|
-
currentValue: shortString,
|
|
22140
|
-
options: external_exports.union([
|
|
22141
|
-
external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
22142
|
-
external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
22143
|
-
]),
|
|
22144
|
-
type: external_exports.literal("select")
|
|
22145
|
-
}).readonly(),
|
|
22146
|
-
external_exports.object({ ...configBaseFields, currentValue: external_exports.boolean(), type: external_exports.literal("boolean") }).readonly()
|
|
22147
|
-
]);
|
|
22148
|
-
var contentChunkFields = {
|
|
22149
|
-
content: contentBlockSchema,
|
|
22150
|
-
messageId: shortString.nullable().optional()
|
|
22151
|
-
};
|
|
22152
|
-
var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate", [
|
|
22153
|
-
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("user_message_chunk") }).readonly(),
|
|
22154
|
-
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_message_chunk") }).readonly(),
|
|
22155
|
-
external_exports.object({
|
|
22156
|
-
...contentChunkFields,
|
|
22157
|
-
meta: external_exports.object({ truncated: external_exports.boolean().optional() }).readonly().optional(),
|
|
22158
|
-
sessionUpdate: external_exports.literal("agent_thought_chunk")
|
|
22159
|
-
}).readonly(),
|
|
22160
|
-
external_exports.object({
|
|
22161
|
-
backgroundTask: backgroundTaskSchema.optional(),
|
|
22162
|
-
content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
22163
|
-
kind: toolKindSchema.optional(),
|
|
22164
|
-
locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
22165
|
-
name: shortString.nullable().optional(),
|
|
22166
|
-
rawInput: boundedJsonSchema.optional(),
|
|
22167
|
-
rawOutput: boundedJsonSchema.optional(),
|
|
22168
|
-
sessionUpdate: external_exports.literal("tool_call"),
|
|
22169
|
-
status: toolStatusSchema.optional(),
|
|
22170
|
-
title: boundedString2,
|
|
22171
|
-
toolCallId: shortString
|
|
22172
|
-
}).readonly(),
|
|
22173
|
-
external_exports.object({ ...toolPatchFields, sessionUpdate: external_exports.literal("tool_call_update"), toolCallId: shortString }).readonly(),
|
|
22174
|
-
external_exports.object({
|
|
22175
|
-
entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
22176
|
-
sessionUpdate: external_exports.literal("plan")
|
|
22177
|
-
}).readonly(),
|
|
22178
|
-
external_exports.object({ plan: planContentSchema, sessionUpdate: external_exports.literal("plan_update") }).readonly(),
|
|
22179
|
-
external_exports.object({ planId: shortString, sessionUpdate: external_exports.literal("plan_removed") }).readonly(),
|
|
22180
|
-
external_exports.object({
|
|
22181
|
-
availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
22182
|
-
sessionUpdate: external_exports.literal("available_commands_update")
|
|
22183
|
-
}).readonly(),
|
|
22184
|
-
external_exports.object({
|
|
22185
|
-
currentModeId: shortString,
|
|
22186
|
-
sessionUpdate: external_exports.literal("current_mode_update")
|
|
22187
|
-
}).readonly(),
|
|
22188
|
-
external_exports.object({
|
|
22189
|
-
configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
22190
|
-
sessionUpdate: external_exports.literal("config_option_update")
|
|
22191
|
-
}).readonly(),
|
|
22192
|
-
external_exports.object({
|
|
22193
|
-
sessionUpdate: external_exports.literal("session_info_update"),
|
|
22194
|
-
title: boundedString2.nullable().optional(),
|
|
22195
|
-
updatedAt: shortString.nullable().optional()
|
|
22196
|
-
}).readonly(),
|
|
22197
|
-
external_exports.object({
|
|
22198
|
-
cost: external_exports.object({ amount: external_exports.number().finite(), currency: external_exports.string().max(16) }).readonly().nullable().optional(),
|
|
22199
|
-
sessionUpdate: external_exports.literal("usage_update"),
|
|
22200
|
-
size: external_exports.number().int().nonnegative().safe(),
|
|
22201
|
-
used: external_exports.number().int().nonnegative().safe()
|
|
22202
|
-
}).readonly(),
|
|
22352
|
+
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
22353
|
+
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
22354
|
+
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
22203
22355
|
external_exports.object({
|
|
22204
|
-
|
|
22205
|
-
|
|
22206
|
-
|
|
22207
|
-
status: shortString,
|
|
22208
|
-
summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional()
|
|
22356
|
+
...identity,
|
|
22357
|
+
action: external_exports.literal("list"),
|
|
22358
|
+
cursor: identifierStringSchema.nullable()
|
|
22209
22359
|
}).readonly(),
|
|
22210
22360
|
external_exports.object({
|
|
22211
|
-
|
|
22212
|
-
|
|
22213
|
-
|
|
22361
|
+
...identity,
|
|
22362
|
+
action: external_exports.enum(["import", "fork"]),
|
|
22363
|
+
entryId: identifierStringSchema,
|
|
22364
|
+
targetSessionId: identifierStringSchema
|
|
22214
22365
|
}).readonly()
|
|
22215
22366
|
]);
|
|
22216
|
-
var
|
|
22217
|
-
|
|
22218
|
-
|
|
22367
|
+
var nativeSessionEntrySchema = external_exports.object({
|
|
22368
|
+
entryId: identifierStringSchema,
|
|
22369
|
+
mobiusSessionIds: external_exports.array(identifierStringSchema).max(500).readonly(),
|
|
22370
|
+
nativeSessionId: identifierStringSchema,
|
|
22371
|
+
title: external_exports.string().max(500),
|
|
22219
22372
|
directoryId: DIRECTORY_IDENTIFIER,
|
|
22220
|
-
|
|
22373
|
+
directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
|
|
22374
|
+
updatedAt: external_exports.iso.datetime({ offset: true }).nullable(),
|
|
22375
|
+
additionalDirectories: external_exports.array(external_exports.object({ directoryId: DIRECTORY_IDENTIFIER, name: external_exports.string().min(1).max(255) }).readonly()).max(16).readonly()
|
|
22221
22376
|
}).readonly();
|
|
22222
|
-
var
|
|
22223
|
-
|
|
22224
|
-
|
|
22225
|
-
|
|
22226
|
-
|
|
22227
|
-
external_exports.object({ event: sessionElicitationResolvedEventSchema, kind: external_exports.literal("session.elicitation.resolved") }).readonly(),
|
|
22377
|
+
var resultEnvelope = {
|
|
22378
|
+
...envelope,
|
|
22379
|
+
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
22380
|
+
};
|
|
22381
|
+
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
22228
22382
|
external_exports.object({
|
|
22229
|
-
...
|
|
22230
|
-
|
|
22231
|
-
|
|
22232
|
-
|
|
22233
|
-
|
|
22234
|
-
|
|
22383
|
+
...resultEnvelope,
|
|
22384
|
+
action: external_exports.literal("active-turn"),
|
|
22385
|
+
targetSessionId: identifierStringSchema,
|
|
22386
|
+
queued: external_exports.array(
|
|
22387
|
+
external_exports.object({
|
|
22388
|
+
commandId: identifierStringSchema,
|
|
22389
|
+
prompt: external_exports.string().max(1e5),
|
|
22390
|
+
attachments: external_exports.array(promptAttachmentSchema).max(16).readonly()
|
|
22391
|
+
}).readonly()
|
|
22392
|
+
).readonly(),
|
|
22393
|
+
turn: activeTurnSnapshotSchema.nullable()
|
|
22235
22394
|
}).readonly(),
|
|
22236
|
-
external_exports.object({ ...lifecycleBase, attemptId: identifierStringSchema, epoch: identifierStringSchema, kind: external_exports.literal("prompt.started") }).readonly(),
|
|
22237
22395
|
external_exports.object({
|
|
22238
|
-
...
|
|
22239
|
-
|
|
22240
|
-
|
|
22396
|
+
...resultEnvelope,
|
|
22397
|
+
action: external_exports.literal("find"),
|
|
22398
|
+
entry: nativeSessionEntrySchema
|
|
22241
22399
|
}).readonly(),
|
|
22242
22400
|
external_exports.object({
|
|
22243
|
-
...
|
|
22244
|
-
|
|
22245
|
-
|
|
22246
|
-
|
|
22401
|
+
...resultEnvelope,
|
|
22402
|
+
action: external_exports.literal("list"),
|
|
22403
|
+
capabilities: sessionCapabilitiesSchema,
|
|
22404
|
+
entries: external_exports.array(nativeSessionEntrySchema).max(500).readonly(),
|
|
22405
|
+
nextCursor: identifierStringSchema.nullable()
|
|
22247
22406
|
}).readonly(),
|
|
22248
22407
|
external_exports.object({
|
|
22249
|
-
...
|
|
22250
|
-
|
|
22251
|
-
|
|
22252
|
-
|
|
22253
|
-
|
|
22254
|
-
}).readonly()
|
|
22255
|
-
]);
|
|
22256
|
-
var sessionEventPayloadSchema = external_exports.discriminatedUnion("type", [
|
|
22257
|
-
external_exports.object({ payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
22258
|
-
external_exports.object({ payload: lifecycleMetadataSchema, type: external_exports.literal("lifecycle-metadata") }).readonly()
|
|
22259
|
-
]);
|
|
22260
|
-
var positionSchema = external_exports.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
22261
|
-
var sharedSessionEventFields = {
|
|
22262
|
-
eventId: identifierStringSchema,
|
|
22263
|
-
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).readonly().optional(),
|
|
22264
|
-
recordedAt: external_exports.iso.datetime({ offset: true }),
|
|
22265
|
-
sessionGenerationId: identifierStringSchema,
|
|
22266
|
-
sessionId: identifierStringSchema
|
|
22267
|
-
};
|
|
22268
|
-
var sessionLiveEventFields = { ...sharedSessionEventFields, position: positionSchema };
|
|
22269
|
-
var sessionEventSchema = external_exports.object({ ...sharedSessionEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly();
|
|
22270
|
-
var sessionLiveEventSchema = external_exports.discriminatedUnion("type", [
|
|
22271
|
-
external_exports.object({ ...sessionLiveEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
22272
|
-
external_exports.object({
|
|
22273
|
-
...sessionLiveEventFields,
|
|
22274
|
-
payload: lifecycleMetadataSchema,
|
|
22275
|
-
type: external_exports.literal("lifecycle-metadata")
|
|
22408
|
+
...resultEnvelope,
|
|
22409
|
+
action: external_exports.enum(["import", "fork"]),
|
|
22410
|
+
targetSessionId: identifierStringSchema,
|
|
22411
|
+
ready: sessionReadyEventSchema,
|
|
22412
|
+
title: external_exports.string().max(500)
|
|
22276
22413
|
}).readonly()
|
|
22277
22414
|
]);
|
|
22278
|
-
var
|
|
22279
|
-
|
|
22280
|
-
commandId: identifierStringSchema.optional(),
|
|
22281
|
-
context: promptExecutionContextSchema.unwrap().passthrough().readonly().optional(),
|
|
22282
|
-
event: external_exports.object({ interactionId: identifierStringSchema.optional() }).passthrough().readonly().optional()
|
|
22283
|
-
}).passthrough().readonly();
|
|
22284
|
-
var wireEventFields = {
|
|
22285
|
-
...sessionLiveEventFields,
|
|
22286
|
-
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).passthrough().readonly().optional()
|
|
22287
|
-
};
|
|
22288
|
-
var sessionWireEventSchema = external_exports.union([
|
|
22289
|
-
external_exports.object({
|
|
22290
|
-
...wireEventFields,
|
|
22291
|
-
type: external_exports.literal("acp"),
|
|
22292
|
-
payload: external_exports.object({ sessionUpdate: identifierStringSchema }).passthrough().readonly()
|
|
22293
|
-
}).passthrough().readonly(),
|
|
22294
|
-
external_exports.object({
|
|
22295
|
-
...wireEventFields,
|
|
22296
|
-
type: external_exports.literal("lifecycle-metadata"),
|
|
22297
|
-
payload: wireLifecyclePayloadSchema
|
|
22298
|
-
}).passthrough().readonly(),
|
|
22299
|
-
external_exports.object({
|
|
22300
|
-
...wireEventFields,
|
|
22301
|
-
type: identifierStringSchema.refine((type) => type !== "acp" && type !== "lifecycle-metadata"),
|
|
22302
|
-
payload: external_exports.record(external_exports.string(), external_exports.unknown()).readonly()
|
|
22303
|
-
}).passthrough().readonly()
|
|
22304
|
-
]);
|
|
22305
|
-
var sessionWireEnvelopeSchema = external_exports.object({
|
|
22306
|
-
kind: external_exports.literal(SESSION_EVENT_KIND),
|
|
22307
|
-
events: external_exports.array(sessionWireEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly()
|
|
22308
|
-
}).passthrough().readonly();
|
|
22309
|
-
var knownContentBlockTypes = /* @__PURE__ */ new Set([
|
|
22310
|
-
"text",
|
|
22311
|
-
"image",
|
|
22312
|
-
"audio",
|
|
22313
|
-
"resource_link",
|
|
22314
|
-
"resource",
|
|
22315
|
-
"external_image",
|
|
22316
|
-
"external_audio",
|
|
22317
|
-
"external_resource"
|
|
22318
|
-
]);
|
|
22319
|
-
var knownToolCallContentTypes = /* @__PURE__ */ new Set(["content", "diff", "terminal"]);
|
|
22320
|
-
var knownPlanTypes = /* @__PURE__ */ new Set(["items", "file", "markdown"]);
|
|
22321
|
-
var knownConfigOptionTypes = /* @__PURE__ */ new Set(["select", "boolean"]);
|
|
22322
|
-
var knownSessionUpdates = /* @__PURE__ */ new Set([
|
|
22323
|
-
"user_message_chunk",
|
|
22324
|
-
"agent_message_chunk",
|
|
22325
|
-
"agent_thought_chunk",
|
|
22326
|
-
"tool_call",
|
|
22327
|
-
"tool_call_update",
|
|
22328
|
-
"plan",
|
|
22329
|
-
"plan_update",
|
|
22330
|
-
"plan_removed",
|
|
22331
|
-
"available_commands_update",
|
|
22332
|
-
"current_mode_update",
|
|
22333
|
-
"config_option_update",
|
|
22334
|
-
"session_info_update",
|
|
22335
|
-
"usage_update",
|
|
22336
|
-
"compaction_update",
|
|
22337
|
-
"compaction_summary_chunk"
|
|
22338
|
-
]);
|
|
22339
|
-
var knownLifecycleKinds = /* @__PURE__ */ new Set([
|
|
22340
|
-
"session.queue.changed",
|
|
22341
|
-
"session.permission.requested",
|
|
22342
|
-
"session.permission.resolved",
|
|
22343
|
-
"session.elicitation.requested",
|
|
22344
|
-
"session.elicitation.resolved",
|
|
22345
|
-
"prompt.requested",
|
|
22346
|
-
"prompt.started",
|
|
22347
|
-
"prompt.completed",
|
|
22348
|
-
"prompt.failed-before-start",
|
|
22349
|
-
"prompt.failed"
|
|
22350
|
-
]);
|
|
22351
|
-
function isRecord3(value) {
|
|
22352
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22353
|
-
}
|
|
22354
|
-
function hasUnknownDiscriminator(value, key, known) {
|
|
22355
|
-
if (!isRecord3(value)) {
|
|
22356
|
-
return false;
|
|
22357
|
-
}
|
|
22358
|
-
const variant = value[key];
|
|
22359
|
-
return typeof variant === "string" && !known.has(variant);
|
|
22360
|
-
}
|
|
22361
|
-
function containsUnknownContentBlock(value) {
|
|
22362
|
-
return hasUnknownDiscriminator(value, "type", knownContentBlockTypes);
|
|
22363
|
-
}
|
|
22364
|
-
function containsUnknownToolCallContent(value) {
|
|
22365
|
-
if (hasUnknownDiscriminator(value, "type", knownToolCallContentTypes)) {
|
|
22366
|
-
return true;
|
|
22367
|
-
}
|
|
22368
|
-
return isRecord3(value) && value["type"] === "content" && containsUnknownContentBlock(value["content"]);
|
|
22369
|
-
}
|
|
22370
|
-
function arrayContainsUnknown(value, predicate) {
|
|
22371
|
-
return Array.isArray(value) && value.some(predicate);
|
|
22372
|
-
}
|
|
22373
|
-
function containsUnknownAcpVariant(payload) {
|
|
22374
|
-
const update = payload["sessionUpdate"];
|
|
22375
|
-
if (typeof update !== "string") {
|
|
22376
|
-
return false;
|
|
22377
|
-
}
|
|
22378
|
-
if (!knownSessionUpdates.has(update)) {
|
|
22379
|
-
return true;
|
|
22380
|
-
}
|
|
22381
|
-
if (["user_message_chunk", "agent_message_chunk", "agent_thought_chunk", "compaction_summary_chunk"].includes(
|
|
22382
|
-
update
|
|
22383
|
-
)) {
|
|
22384
|
-
return containsUnknownContentBlock(payload["content"]);
|
|
22385
|
-
}
|
|
22386
|
-
if (update === "tool_call" || update === "tool_call_update") {
|
|
22387
|
-
return arrayContainsUnknown(payload["content"], containsUnknownToolCallContent);
|
|
22388
|
-
}
|
|
22389
|
-
if (update === "plan_update") {
|
|
22390
|
-
return hasUnknownDiscriminator(payload["plan"], "type", knownPlanTypes);
|
|
22391
|
-
}
|
|
22392
|
-
if (update === "config_option_update") {
|
|
22393
|
-
return arrayContainsUnknown(
|
|
22394
|
-
payload["configOptions"],
|
|
22395
|
-
(option) => hasUnknownDiscriminator(option, "type", knownConfigOptionTypes)
|
|
22396
|
-
);
|
|
22397
|
-
}
|
|
22398
|
-
if (update === "compaction_update") {
|
|
22399
|
-
return arrayContainsUnknown(payload["summary"], containsUnknownContentBlock);
|
|
22400
|
-
}
|
|
22401
|
-
return false;
|
|
22402
|
-
}
|
|
22403
|
-
function isKnownSessionEventVariant(value) {
|
|
22404
|
-
if (!isRecord3(value)) {
|
|
22405
|
-
return true;
|
|
22406
|
-
}
|
|
22407
|
-
const type = value["type"];
|
|
22408
|
-
if (typeof type !== "string") {
|
|
22409
|
-
return true;
|
|
22410
|
-
}
|
|
22411
|
-
if (type === "acp") {
|
|
22412
|
-
const payload = value["payload"];
|
|
22413
|
-
return !isRecord3(payload) || !containsUnknownAcpVariant(payload);
|
|
22414
|
-
}
|
|
22415
|
-
if (type === "lifecycle-metadata") {
|
|
22416
|
-
const payload = value["payload"];
|
|
22417
|
-
if (!isRecord3(payload)) {
|
|
22418
|
-
return true;
|
|
22419
|
-
}
|
|
22420
|
-
const kind = payload["kind"];
|
|
22421
|
-
if (typeof kind === "string" && !knownLifecycleKinds.has(kind)) {
|
|
22422
|
-
return false;
|
|
22423
|
-
}
|
|
22424
|
-
return kind !== "prompt.requested" || !arrayContainsUnknown(payload["content"], containsUnknownContentBlock);
|
|
22425
|
-
}
|
|
22426
|
-
return false;
|
|
22427
|
-
}
|
|
22428
|
-
function filterKnownSessionEventVariants(events) {
|
|
22429
|
-
return Array.isArray(events) ? events.filter(isKnownSessionEventVariant) : events;
|
|
22430
|
-
}
|
|
22431
|
-
var sessionEventBatchSchema = external_exports.array(sessionEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
22432
|
-
var sessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
22433
|
-
var sessionExportSchema = external_exports.object({
|
|
22434
|
-
binding: external_exports.object({
|
|
22435
|
-
bindingId: identifierStringSchema,
|
|
22436
|
-
runtimeId: identifierStringSchema
|
|
22437
|
-
}).readonly(),
|
|
22438
|
-
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
22439
|
-
sessionId: identifierStringSchema,
|
|
22440
|
-
truncated: external_exports.boolean()
|
|
22441
|
-
}).readonly().superRefine((session, context) => {
|
|
22442
|
-
const eventIds = /* @__PURE__ */ new Set();
|
|
22443
|
-
for (const [index2, event] of session.events.entries()) {
|
|
22444
|
-
if (event.sessionId !== session.sessionId) {
|
|
22445
|
-
context.addIssue({
|
|
22446
|
-
code: "custom",
|
|
22447
|
-
message: "Exported event belongs to a different Session",
|
|
22448
|
-
path: ["events", index2, "sessionId"]
|
|
22449
|
-
});
|
|
22450
|
-
}
|
|
22451
|
-
if (eventIds.has(event.eventId)) {
|
|
22452
|
-
context.addIssue({
|
|
22453
|
-
code: "custom",
|
|
22454
|
-
message: "Exported event identities are not unique",
|
|
22455
|
-
path: ["events", index2, "eventId"]
|
|
22456
|
-
});
|
|
22457
|
-
}
|
|
22458
|
-
eventIds.add(event.eventId);
|
|
22459
|
-
}
|
|
22460
|
-
});
|
|
22461
|
-
var mobiusSessionExportSchema = external_exports.object({
|
|
22462
|
-
formatVersion: external_exports.literal("2"),
|
|
22463
|
-
session: sessionExportSchema
|
|
22464
|
-
}).readonly();
|
|
22465
|
-
var sessionEventEnvelopeSchema = external_exports.object({ events: sessionLiveEventBatchSchema, kind: external_exports.literal(SESSION_EVENT_KIND) }).readonly();
|
|
22466
|
-
var sessionEventLogPageSchema = external_exports.object({
|
|
22467
|
-
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
22468
|
-
nextCursor: external_exports.string().min(1).max(512).nullable(),
|
|
22469
|
-
sessionGenerationId: identifierStringSchema,
|
|
22470
|
-
tailCursor: external_exports.string().max(512),
|
|
22471
|
-
// The generation-scoped live position covered by this snapshot, including
|
|
22472
|
-
// coalesced and omitted events. Absent only on older Runtime versions.
|
|
22473
|
-
throughPosition: positionSchema.optional(),
|
|
22474
|
-
truncated: external_exports.boolean(),
|
|
22475
|
-
version: external_exports.literal(2)
|
|
22476
|
-
}).readonly();
|
|
22477
|
-
var sessionEventOmissionSchema = external_exports.literal("agent-reasoning");
|
|
22478
|
-
var nativeEventPageRequestSchema = external_exports.object({
|
|
22479
|
-
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
22480
|
-
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
22481
|
-
// Legacy callers may still send this option; readers must ignore it.
|
|
22482
|
-
omit: external_exports.array(sessionEventOmissionSchema).max(1).readonly().optional()
|
|
22483
|
-
}).readonly();
|
|
22484
|
-
var queuedPromptRequestEventLogSchema = external_exports.object({
|
|
22485
|
-
commandId: identifierStringSchema,
|
|
22486
|
-
content: external_exports.array(contentBlockSchema).min(1).max(100).readonly(),
|
|
22487
|
-
disposition: shortString.optional(),
|
|
22488
|
-
targetCommandId: identifierStringSchema.optional()
|
|
22489
|
-
}).readonly();
|
|
22490
|
-
var nativeSessionEventsSchema = external_exports.object({
|
|
22491
|
-
events: sessionEventLogPageSchema,
|
|
22492
|
-
queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
22493
|
-
}).readonly();
|
|
22494
|
-
function inputValue(value) {
|
|
22495
|
-
if (typeof value !== "string") {
|
|
22496
|
-
return value;
|
|
22497
|
-
}
|
|
22415
|
+
var nativeSessionCancelSchema = external_exports.object({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
|
|
22416
|
+
function decode4(schema, encoded) {
|
|
22498
22417
|
try {
|
|
22499
|
-
|
|
22418
|
+
const value = JSON.parse(encoded);
|
|
22419
|
+
return schema.parse(value);
|
|
22500
22420
|
} catch (cause) {
|
|
22501
|
-
throw new ProtocolMessageError("
|
|
22502
|
-
}
|
|
22503
|
-
}
|
|
22504
|
-
function decode4(value, schema) {
|
|
22505
|
-
const result = schema.safeParse(inputValue(value));
|
|
22506
|
-
if (!result.success) {
|
|
22507
|
-
throw new ProtocolMessageError("Session Event Log V2 message does not match its schema", {
|
|
22508
|
-
cause: result.error
|
|
22509
|
-
});
|
|
22510
|
-
}
|
|
22511
|
-
return result.data;
|
|
22512
|
-
}
|
|
22513
|
-
function encode3(value, schema) {
|
|
22514
|
-
return JSON.stringify(decode4(value, schema));
|
|
22515
|
-
}
|
|
22516
|
-
function sanitizeKnownNativeSessionEvents(value) {
|
|
22517
|
-
const input2 = inputValue(value);
|
|
22518
|
-
if (!isRecord3(input2)) {
|
|
22519
|
-
return input2;
|
|
22421
|
+
throw new ProtocolMessageError("Invalid native session message", { cause });
|
|
22520
22422
|
}
|
|
22521
|
-
const page = input2["events"];
|
|
22522
|
-
const queuedPromptRequests = input2["queuedPromptRequests"];
|
|
22523
|
-
return {
|
|
22524
|
-
...input2,
|
|
22525
|
-
events: isRecord3(page) ? { ...page, events: filterKnownSessionEventVariants(page["events"]) } : page,
|
|
22526
|
-
queuedPromptRequests: Array.isArray(queuedPromptRequests) ? queuedPromptRequests.filter(
|
|
22527
|
-
(prompt) => !isRecord3(prompt) || !arrayContainsUnknown(prompt["content"], containsUnknownContentBlock)
|
|
22528
|
-
) : queuedPromptRequests
|
|
22529
|
-
};
|
|
22530
22423
|
}
|
|
22531
|
-
var
|
|
22532
|
-
var
|
|
22533
|
-
var
|
|
22534
|
-
var
|
|
22535
|
-
var
|
|
22536
|
-
var
|
|
22537
|
-
var decodeKnownNativeSessionEvents = (value) => decode4(sanitizeKnownNativeSessionEvents(value), nativeSessionEventsSchema);
|
|
22424
|
+
var decodeNativeSessionCommand = (encoded) => decode4(nativeSessionCommandSchema, encoded);
|
|
22425
|
+
var encodeNativeSessionCommand = (value) => JSON.stringify(nativeSessionCommandSchema.parse(value));
|
|
22426
|
+
var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema, encoded);
|
|
22427
|
+
var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
|
|
22428
|
+
var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
|
|
22429
|
+
var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
|
|
22538
22430
|
|
|
22539
22431
|
// ../mobius-sdk/src/protocol/session/observability/history.ts
|
|
22540
22432
|
var SESSION_HISTORY_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
@@ -22852,28 +22744,17 @@ var serviceToDaemonSignatures = {
|
|
|
22852
22744
|
)
|
|
22853
22745
|
};
|
|
22854
22746
|
var serviceToDaemonRegistry = serviceToDaemonSignatures;
|
|
22855
|
-
var knownNativeActions = /* @__PURE__ */ new Set(["active-turn", "find", "list", "import", "fork"]);
|
|
22856
|
-
function isRecord4(value) {
|
|
22857
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22858
|
-
}
|
|
22859
|
-
function hasUnknownDiscriminator2(value, key, known) {
|
|
22860
|
-
if (!isRecord4(value)) {
|
|
22861
|
-
return false;
|
|
22862
|
-
}
|
|
22863
|
-
const variant = value[key];
|
|
22864
|
-
return typeof variant === "string" && !known.has(variant);
|
|
22865
|
-
}
|
|
22866
|
-
function hasUnknownServiceVariant(kind, value) {
|
|
22867
|
-
return kind === NATIVE_SESSION_REQUEST_KIND && hasUnknownDiscriminator2(value, "action", knownNativeActions);
|
|
22868
|
-
}
|
|
22869
22747
|
function decodeKnownServiceToDaemonMessage(encoded) {
|
|
22870
22748
|
const kind = decodeMessageKind(encoded);
|
|
22871
22749
|
const signature = serviceToDaemonRegistry[kind];
|
|
22872
22750
|
if (signature === void 0) {
|
|
22873
22751
|
return null;
|
|
22874
22752
|
}
|
|
22875
|
-
|
|
22876
|
-
|
|
22753
|
+
try {
|
|
22754
|
+
return signature.decoder(encoded);
|
|
22755
|
+
} catch {
|
|
22756
|
+
return null;
|
|
22757
|
+
}
|
|
22877
22758
|
}
|
|
22878
22759
|
var daemonToServiceSignatures = {
|
|
22879
22760
|
[SESSION_CLOSED_KIND]: defineMessageSignature(
|
|
@@ -23089,7 +22970,7 @@ var SessionConfigProtocolError = class extends Error {
|
|
|
23089
22970
|
this.name = "SessionConfigProtocolError";
|
|
23090
22971
|
}
|
|
23091
22972
|
};
|
|
23092
|
-
function
|
|
22973
|
+
function isRecord4(value) {
|
|
23093
22974
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23094
22975
|
}
|
|
23095
22976
|
function readString3(value, fallback = "") {
|
|
@@ -23120,7 +23001,7 @@ function normalizeConfigValues(value) {
|
|
|
23120
23001
|
}
|
|
23121
23002
|
const normalized = [];
|
|
23122
23003
|
for (const entry of value) {
|
|
23123
|
-
if (!
|
|
23004
|
+
if (!isRecord4(entry)) {
|
|
23124
23005
|
continue;
|
|
23125
23006
|
}
|
|
23126
23007
|
const groupedOptions = entry["options"];
|
|
@@ -23128,7 +23009,7 @@ function normalizeConfigValues(value) {
|
|
|
23128
23009
|
const groupId = readString3(entry["group"]);
|
|
23129
23010
|
const groupName = readString3(entry["name"]);
|
|
23130
23011
|
for (const groupedOption of groupedOptions) {
|
|
23131
|
-
if (
|
|
23012
|
+
if (isRecord4(groupedOption)) {
|
|
23132
23013
|
const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
|
|
23133
23014
|
if (normalizedValue !== void 0) {
|
|
23134
23015
|
normalized.push(normalizedValue);
|
|
@@ -23153,7 +23034,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
23153
23034
|
const normalized = [];
|
|
23154
23035
|
if (Array.isArray(value)) {
|
|
23155
23036
|
for (const option of value) {
|
|
23156
|
-
if (!
|
|
23037
|
+
if (!isRecord4(option)) {
|
|
23157
23038
|
continue;
|
|
23158
23039
|
}
|
|
23159
23040
|
const id = truncate2(readString3(option["id"]), 128);
|
|
@@ -23193,12 +23074,12 @@ function normalizeConfigOptions(value, modes) {
|
|
|
23193
23074
|
}
|
|
23194
23075
|
}
|
|
23195
23076
|
}
|
|
23196
|
-
if (
|
|
23077
|
+
if (isRecord4(modes)) {
|
|
23197
23078
|
const values = [];
|
|
23198
23079
|
const availableModes = modes["availableModes"];
|
|
23199
23080
|
if (Array.isArray(availableModes)) {
|
|
23200
23081
|
for (const mode of availableModes) {
|
|
23201
|
-
if (!
|
|
23082
|
+
if (!isRecord4(mode)) {
|
|
23202
23083
|
continue;
|
|
23203
23084
|
}
|
|
23204
23085
|
const id = truncate2(readString3(mode["id"]), 500);
|
|
@@ -23231,7 +23112,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
23231
23112
|
return normalized.slice(0, MAXIMUM_CONFIG_OPTIONS);
|
|
23232
23113
|
}
|
|
23233
23114
|
function normalizeStandardLifecycle(response) {
|
|
23234
|
-
const lifecycle =
|
|
23115
|
+
const lifecycle = isRecord4(response) ? response : {};
|
|
23235
23116
|
return normalizeConfigOptions(lifecycle["configOptions"], lifecycle["modes"]);
|
|
23236
23117
|
}
|
|
23237
23118
|
function replaceStandardConfigOptions(current, value) {
|
|
@@ -23273,7 +23154,7 @@ var StandardSessionConfigProtocol = class {
|
|
|
23273
23154
|
"ACP agent exited while changing session configuration",
|
|
23274
23155
|
change.signal
|
|
23275
23156
|
);
|
|
23276
|
-
if (!
|
|
23157
|
+
if (!isRecord4(response) || !Array.isArray(response["configOptions"])) {
|
|
23277
23158
|
throw new SessionConfigProtocolError("The Agent returned an invalid session configuration response");
|
|
23278
23159
|
}
|
|
23279
23160
|
return replaceStandardConfigOptions(current, response["configOptions"]);
|
|
@@ -32333,7 +32214,7 @@ var toolImageSchema = external_exports.union([
|
|
|
32333
32214
|
file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
|
|
32334
32215
|
}).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
|
|
32335
32216
|
]);
|
|
32336
|
-
function
|
|
32217
|
+
function isRecord5(value) {
|
|
32337
32218
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32338
32219
|
}
|
|
32339
32220
|
var AcpContentExternalizer = class {
|
|
@@ -32440,13 +32321,13 @@ var AcpContentExternalizer = class {
|
|
|
32440
32321
|
}
|
|
32441
32322
|
return result2;
|
|
32442
32323
|
}
|
|
32443
|
-
if (!
|
|
32324
|
+
if (!isRecord5(value)) {
|
|
32444
32325
|
return value;
|
|
32445
32326
|
}
|
|
32446
32327
|
const image = toolImageSchema.safeParse(value);
|
|
32447
32328
|
if (image.success && image.data.data.length > 0) {
|
|
32448
32329
|
const prepared = await this.#content(sessionId, image.data, signal);
|
|
32449
|
-
if (
|
|
32330
|
+
if (isRecord5(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
32450
32331
|
images.set(prepared.event["imageKey"], prepared);
|
|
32451
32332
|
} else {
|
|
32452
32333
|
images.set(`unavailable:${images.size}`, prepared);
|
|
@@ -32477,7 +32358,7 @@ var AcpContentExternalizer = class {
|
|
|
32477
32358
|
const prepared = await this.#content(sessionId, content, signal);
|
|
32478
32359
|
agentContent.push({ ...item, content: prepared.agent });
|
|
32479
32360
|
eventContent.push({ ...item, content: prepared.event });
|
|
32480
|
-
if (
|
|
32361
|
+
if (isRecord5(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
32481
32362
|
images.delete(prepared.event["imageKey"]);
|
|
32482
32363
|
}
|
|
32483
32364
|
}
|
|
@@ -32557,7 +32438,7 @@ import { fetch as fetch3 } from "undici";
|
|
|
32557
32438
|
// package.json
|
|
32558
32439
|
var package_default = {
|
|
32559
32440
|
name: "@moxt-ai/mobius",
|
|
32560
|
-
version: "0.0.
|
|
32441
|
+
version: "0.0.339",
|
|
32561
32442
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
32562
32443
|
type: "module",
|
|
32563
32444
|
bin: {
|
|
@@ -69835,7 +69716,7 @@ var DESTINATIONS = /* @__PURE__ */ new Set([
|
|
|
69835
69716
|
]);
|
|
69836
69717
|
var BEHAVIORS = /* @__PURE__ */ new Set(["allow", "deny", "ask"]);
|
|
69837
69718
|
var MODES = /* @__PURE__ */ new Set(["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto"]);
|
|
69838
|
-
function
|
|
69719
|
+
function isRecord6(value) {
|
|
69839
69720
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
69840
69721
|
}
|
|
69841
69722
|
function isDestination(value) {
|
|
@@ -69852,13 +69733,13 @@ function safePlainString(value, maxLength) {
|
|
|
69852
69733
|
});
|
|
69853
69734
|
}
|
|
69854
69735
|
function isRule(value) {
|
|
69855
|
-
if (!
|
|
69736
|
+
if (!isRecord6(value) || !safePlainString(value.toolName, MAX_TOOL_NAME_LENGTH)) {
|
|
69856
69737
|
return false;
|
|
69857
69738
|
}
|
|
69858
69739
|
return value.ruleContent === void 0 || safePlainString(value.ruleContent, MAX_RULE_CONTENT_LENGTH);
|
|
69859
69740
|
}
|
|
69860
69741
|
function isKnownUpdate(value) {
|
|
69861
|
-
if (!
|
|
69742
|
+
if (!isRecord6(value) || !isDestination(value.destination) || typeof value.type !== "string") {
|
|
69862
69743
|
return false;
|
|
69863
69744
|
}
|
|
69864
69745
|
switch (value.type) {
|
|
@@ -73734,16 +73615,20 @@ var ClaudeAcpAgent = class {
|
|
|
73734
73615
|
}, message.tool_use_id !== void 0)
|
|
73735
73616
|
});
|
|
73736
73617
|
}
|
|
73737
|
-
backgroundTasks.delete(message.task_id);
|
|
73738
73618
|
if (message.skip_transcript) {
|
|
73619
|
+
backgroundTasks.delete(message.task_id);
|
|
73739
73620
|
awaitingBackgroundResults.delete(message.task_id);
|
|
73740
|
-
} else {
|
|
73621
|
+
} else if (backgroundTasks.delete(message.task_id)) {
|
|
73741
73622
|
awaitingBackgroundResults.add(message.task_id);
|
|
73742
73623
|
}
|
|
73743
73624
|
reportBackgroundActivity();
|
|
73744
73625
|
session.liveBackgroundTasks.delete(message.task_id);
|
|
73745
73626
|
break;
|
|
73746
73627
|
case "task_updated":
|
|
73628
|
+
if (!hasBackgroundLevel && message.patch.is_backgrounded === true) {
|
|
73629
|
+
backgroundTasks.add(message.task_id);
|
|
73630
|
+
reportBackgroundActivity();
|
|
73631
|
+
}
|
|
73747
73632
|
if (message.patch.status === "completed" || message.patch.status === "failed" || message.patch.status === "killed") {
|
|
73748
73633
|
session.liveBackgroundTasks.delete(message.task_id);
|
|
73749
73634
|
if (backgroundTasks.delete(message.task_id)) {
|
|
@@ -82813,7 +82698,7 @@ var AgentCatalogPublishError = class extends Error {
|
|
|
82813
82698
|
this.name = "AgentCatalogPublishError";
|
|
82814
82699
|
}
|
|
82815
82700
|
};
|
|
82816
|
-
function
|
|
82701
|
+
function isRecord7(value) {
|
|
82817
82702
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
82818
82703
|
}
|
|
82819
82704
|
function isSafeRelayErrorMessage(value) {
|
|
@@ -82826,7 +82711,7 @@ async function rejectedCatalogError(response) {
|
|
|
82826
82711
|
} catch {
|
|
82827
82712
|
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
82828
82713
|
}
|
|
82829
|
-
if (!
|
|
82714
|
+
if (!isRecord7(value) || !isRecord7(value["error"])) {
|
|
82830
82715
|
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
82831
82716
|
}
|
|
82832
82717
|
const code = value["error"]["code"];
|
|
@@ -83248,7 +83133,7 @@ var RuntimeInstallationStoreError = class extends Error {
|
|
|
83248
83133
|
this.name = "RuntimeInstallationStoreError";
|
|
83249
83134
|
}
|
|
83250
83135
|
};
|
|
83251
|
-
function
|
|
83136
|
+
function isRecord8(value) {
|
|
83252
83137
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
83253
83138
|
}
|
|
83254
83139
|
function hasExactKeys(value, expectedKeys) {
|
|
@@ -83315,7 +83200,7 @@ function installationId() {
|
|
|
83315
83200
|
return `min_${randomUUID13().replaceAll("-", "")}`;
|
|
83316
83201
|
}
|
|
83317
83202
|
function decodeInstallationPointer(value) {
|
|
83318
|
-
if (!
|
|
83203
|
+
if (!isRecord8(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
|
|
83319
83204
|
throw new RuntimeInstallationStoreError("invalid_installation", "The local installation record is invalid");
|
|
83320
83205
|
}
|
|
83321
83206
|
const storedInstallationId = value["installationId"];
|
|
@@ -83325,7 +83210,7 @@ function decodeInstallationPointer(value) {
|
|
|
83325
83210
|
return { installationId: validateInstallationId(storedInstallationId) };
|
|
83326
83211
|
}
|
|
83327
83212
|
function decodeChannelIndex(value) {
|
|
83328
|
-
if (!
|
|
83213
|
+
if (!isRecord8(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
|
|
83329
83214
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
83330
83215
|
}
|
|
83331
83216
|
const applicationId = value["applicationId"];
|
|
@@ -83375,7 +83260,7 @@ function decodeVerifiedConnection(value) {
|
|
|
83375
83260
|
);
|
|
83376
83261
|
}
|
|
83377
83262
|
function decodeConnection(value) {
|
|
83378
|
-
if (!
|
|
83263
|
+
if (!isRecord8(value)) {
|
|
83379
83264
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
83380
83265
|
}
|
|
83381
83266
|
return decodeVerifiedConnection(value);
|
|
@@ -84794,17 +84679,14 @@ var SessionInteractions = class {
|
|
|
84794
84679
|
};
|
|
84795
84680
|
|
|
84796
84681
|
// src/session/live/session-configurations.ts
|
|
84797
|
-
var
|
|
84798
|
-
external_exports.
|
|
84799
|
-
|
|
84800
|
-
|
|
84801
|
-
|
|
84802
|
-
|
|
84803
|
-
|
|
84804
|
-
|
|
84805
|
-
(configuration) => typeof configuration !== "object" || configuration === null || !("type" in configuration) || typeof configuration.type !== "string" || configuration.type === "boolean" || configuration.type === "select"
|
|
84806
|
-
) : value
|
|
84807
|
-
);
|
|
84682
|
+
var storedSessionConfigurationSchema = external_exports.discriminatedUnion("type", [
|
|
84683
|
+
external_exports.object({ booleanValue: external_exports.boolean(), configId: external_exports.string().max(128), type: external_exports.literal("boolean") }),
|
|
84684
|
+
external_exports.object({ configId: external_exports.string().max(128), type: external_exports.literal("select"), value: external_exports.string().max(500) })
|
|
84685
|
+
]);
|
|
84686
|
+
var decodeStoredSessionConfigurations = (value) => external_exports.array(external_exports.unknown()).max(100).parse(value).flatMap((configuration) => {
|
|
84687
|
+
const decoded = storedSessionConfigurationSchema.safeParse(configuration);
|
|
84688
|
+
return decoded.success ? [decoded.data] : [];
|
|
84689
|
+
});
|
|
84808
84690
|
var SessionConfigurations = class {
|
|
84809
84691
|
#selected = [];
|
|
84810
84692
|
stored = () => this.#selected;
|
|
@@ -87460,56 +87342,82 @@ var ExecutionReceipts = class {
|
|
|
87460
87342
|
var RuntimeTurnActivity = class {
|
|
87461
87343
|
#turns = /* @__PURE__ */ new Set();
|
|
87462
87344
|
#backgroundSources = /* @__PURE__ */ new Set();
|
|
87463
|
-
#
|
|
87464
|
-
|
|
87345
|
+
#idleWaiters = /* @__PURE__ */ new Set();
|
|
87346
|
+
// When work last started or stopped; the quiet period is measured from here.
|
|
87347
|
+
#changedAt = Date.now();
|
|
87348
|
+
#reserved = false;
|
|
87349
|
+
acceptsPrompts = () => !this.#reserved;
|
|
87465
87350
|
count = () => this.#turns.size + this.#backgroundSources.size;
|
|
87351
|
+
describe = () => ({
|
|
87352
|
+
turns: this.#turns.size,
|
|
87353
|
+
backgroundSources: this.#backgroundSources.size
|
|
87354
|
+
});
|
|
87466
87355
|
setBackgroundActivity = (source, active) => {
|
|
87356
|
+
if (active === this.#backgroundSources.has(source)) {
|
|
87357
|
+
return;
|
|
87358
|
+
}
|
|
87467
87359
|
if (active) {
|
|
87468
87360
|
this.#backgroundSources.add(source);
|
|
87469
87361
|
} else {
|
|
87470
87362
|
this.#backgroundSources.delete(source);
|
|
87471
87363
|
}
|
|
87472
|
-
this.#
|
|
87364
|
+
this.#changed();
|
|
87473
87365
|
};
|
|
87474
|
-
#reserveIfIdle() {
|
|
87475
|
-
if (this.count() === 0 && this.#admission.kind === "waiting") {
|
|
87476
|
-
this.#admission.reserve();
|
|
87477
|
-
}
|
|
87478
|
-
}
|
|
87479
87366
|
start = (turn) => {
|
|
87480
87367
|
this.#turns.add(turn);
|
|
87368
|
+
this.#changed();
|
|
87481
87369
|
};
|
|
87482
87370
|
finish = (turn) => {
|
|
87483
87371
|
this.#turns.delete(turn);
|
|
87484
|
-
this.#
|
|
87372
|
+
this.#changed();
|
|
87485
87373
|
};
|
|
87486
|
-
|
|
87374
|
+
#changed() {
|
|
87375
|
+
this.#changedAt = Date.now();
|
|
87376
|
+
if (this.count() === 0) {
|
|
87377
|
+
for (const resolve19 of this.#idleWaiters) {
|
|
87378
|
+
resolve19();
|
|
87379
|
+
}
|
|
87380
|
+
this.#idleWaiters.clear();
|
|
87381
|
+
}
|
|
87382
|
+
}
|
|
87383
|
+
whenIdle = (signal) => {
|
|
87487
87384
|
signal.throwIfAborted();
|
|
87488
|
-
if (this
|
|
87489
|
-
|
|
87385
|
+
if (this.count() === 0) {
|
|
87386
|
+
return Promise.resolve();
|
|
87490
87387
|
}
|
|
87491
87388
|
return new Promise((resolve19, reject2) => {
|
|
87492
87389
|
const abort = () => {
|
|
87493
|
-
this.#
|
|
87494
|
-
signal.removeEventListener("abort", abort);
|
|
87390
|
+
this.#idleWaiters.delete(idle);
|
|
87495
87391
|
reject2(signal.reason);
|
|
87496
87392
|
};
|
|
87497
|
-
const
|
|
87498
|
-
this.#admission = { kind: "reserved" };
|
|
87393
|
+
const idle = () => {
|
|
87499
87394
|
signal.removeEventListener("abort", abort);
|
|
87500
|
-
resolve19(
|
|
87501
|
-
[Symbol.dispose]: () => {
|
|
87502
|
-
this.#admission = { kind: "open" };
|
|
87503
|
-
}
|
|
87504
|
-
});
|
|
87395
|
+
resolve19();
|
|
87505
87396
|
};
|
|
87506
|
-
this.#
|
|
87397
|
+
this.#idleWaiters.add(idle);
|
|
87507
87398
|
signal.addEventListener("abort", abort, { once: true });
|
|
87508
|
-
if (this.count() === 0) {
|
|
87509
|
-
reserve();
|
|
87510
|
-
}
|
|
87511
87399
|
});
|
|
87512
87400
|
};
|
|
87401
|
+
/**
|
|
87402
|
+
* Close admission only after the Runtime has had no work for `quietMilliseconds`.
|
|
87403
|
+
* The moment a reply finishes is when a user is most likely to continue, so idle
|
|
87404
|
+
* alone is not an upgrade window. Checking and reserving happen synchronously, so
|
|
87405
|
+
* no prompt can be admitted between them.
|
|
87406
|
+
*/
|
|
87407
|
+
reserveIfQuiet = (quietMilliseconds) => {
|
|
87408
|
+
if (this.#reserved) {
|
|
87409
|
+
throw new Error("A daemon upgrade already owns admission");
|
|
87410
|
+
}
|
|
87411
|
+
if (this.count() > 0 || Date.now() - this.#changedAt < quietMilliseconds) {
|
|
87412
|
+
return null;
|
|
87413
|
+
}
|
|
87414
|
+
this.#reserved = true;
|
|
87415
|
+
return {
|
|
87416
|
+
[Symbol.dispose]: () => {
|
|
87417
|
+
this.#reserved = false;
|
|
87418
|
+
}
|
|
87419
|
+
};
|
|
87420
|
+
};
|
|
87513
87421
|
};
|
|
87514
87422
|
|
|
87515
87423
|
// src/session/turn/active-turn.ts
|