@moxt-ai/mobius 0.0.337 → 0.0.338
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 +1087 -1037
- 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 +860 -830
- package/dist/runtime.js.map +4 -4
- 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/cli.js
CHANGED
|
@@ -2086,7 +2086,7 @@ var init_package = __esm({
|
|
|
2086
2086
|
"package.json"() {
|
|
2087
2087
|
package_default = {
|
|
2088
2088
|
name: "@moxt-ai/mobius",
|
|
2089
|
-
version: "0.0.
|
|
2089
|
+
version: "0.0.338",
|
|
2090
2090
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
2091
2091
|
type: "module",
|
|
2092
2092
|
bin: {
|
|
@@ -68539,16 +68539,20 @@ var init_acp_agent = __esm({
|
|
|
68539
68539
|
}, message.tool_use_id !== void 0)
|
|
68540
68540
|
});
|
|
68541
68541
|
}
|
|
68542
|
-
backgroundTasks.delete(message.task_id);
|
|
68543
68542
|
if (message.skip_transcript) {
|
|
68543
|
+
backgroundTasks.delete(message.task_id);
|
|
68544
68544
|
awaitingBackgroundResults.delete(message.task_id);
|
|
68545
|
-
} else {
|
|
68545
|
+
} else if (backgroundTasks.delete(message.task_id)) {
|
|
68546
68546
|
awaitingBackgroundResults.add(message.task_id);
|
|
68547
68547
|
}
|
|
68548
68548
|
reportBackgroundActivity();
|
|
68549
68549
|
session.liveBackgroundTasks.delete(message.task_id);
|
|
68550
68550
|
break;
|
|
68551
68551
|
case "task_updated":
|
|
68552
|
+
if (!hasBackgroundLevel && message.patch.is_backgrounded === true) {
|
|
68553
|
+
backgroundTasks.add(message.task_id);
|
|
68554
|
+
reportBackgroundActivity();
|
|
68555
|
+
}
|
|
68552
68556
|
if (message.patch.status === "completed" || message.patch.status === "failed" || message.patch.status === "killed") {
|
|
68553
68557
|
session.liveBackgroundTasks.delete(message.task_id);
|
|
68554
68558
|
if (backgroundTasks.delete(message.task_id)) {
|
|
@@ -74489,154 +74493,6 @@ var init_title = __esm({
|
|
|
74489
74493
|
}
|
|
74490
74494
|
});
|
|
74491
74495
|
|
|
74492
|
-
// ../mobius-sdk/src/protocol/session/files/index.ts
|
|
74493
|
-
function binaryBytes(value) {
|
|
74494
|
-
if (value instanceof ArrayBuffer) {
|
|
74495
|
-
return new Uint8Array(value);
|
|
74496
|
-
}
|
|
74497
|
-
if (ArrayBuffer.isView(value)) {
|
|
74498
|
-
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
74499
|
-
}
|
|
74500
|
-
throw new Error("Content chunk must be a binary WebSocket frame");
|
|
74501
|
-
}
|
|
74502
|
-
function encodeContentChunkFrame(frame) {
|
|
74503
|
-
if (!isIdentifier(frame.requestId)) {
|
|
74504
|
-
throw new Error("Content chunk request identifier is invalid");
|
|
74505
|
-
}
|
|
74506
|
-
if (!Number.isSafeInteger(frame.sequence) || frame.sequence < 0 || frame.sequence > 4294967295) {
|
|
74507
|
-
throw new Error("Content chunk sequence is invalid");
|
|
74508
|
-
}
|
|
74509
|
-
if (frame.bytes.byteLength < 1 || frame.bytes.byteLength > CONTENT_CHUNK_MAX_BYTES) {
|
|
74510
|
-
throw new Error("Content chunk size is invalid");
|
|
74511
|
-
}
|
|
74512
|
-
const requestId = new TextEncoder().encode(frame.requestId);
|
|
74513
|
-
if (requestId.byteLength > 255) {
|
|
74514
|
-
throw new Error("Content chunk request identifier is too long");
|
|
74515
|
-
}
|
|
74516
|
-
const encoded = new Uint8Array(CONTENT_CHUNK_HEADER_BYTES + requestId.byteLength + frame.bytes.byteLength);
|
|
74517
|
-
encoded.set(CONTENT_CHUNK_MAGIC, 0);
|
|
74518
|
-
encoded[CONTENT_CHUNK_MAGIC.byteLength] = requestId.byteLength;
|
|
74519
|
-
new DataView(encoded.buffer).setUint32(CONTENT_CHUNK_MAGIC.byteLength + 1, frame.sequence);
|
|
74520
|
-
encoded.set(requestId, CONTENT_CHUNK_HEADER_BYTES);
|
|
74521
|
-
encoded.set(frame.bytes, CONTENT_CHUNK_HEADER_BYTES + requestId.byteLength);
|
|
74522
|
-
return encoded;
|
|
74523
|
-
}
|
|
74524
|
-
function decodeContentChunkFrame(value) {
|
|
74525
|
-
const encoded = binaryBytes(value);
|
|
74526
|
-
if (encoded.byteLength <= CONTENT_CHUNK_HEADER_BYTES || !CONTENT_CHUNK_MAGIC.every((byte, index2) => encoded[index2] === byte)) {
|
|
74527
|
-
throw new Error("Content chunk frame header is invalid");
|
|
74528
|
-
}
|
|
74529
|
-
const requestIdLength = encoded[CONTENT_CHUNK_MAGIC.byteLength] ?? 0;
|
|
74530
|
-
const payloadOffset = CONTENT_CHUNK_HEADER_BYTES + requestIdLength;
|
|
74531
|
-
if (requestIdLength < 1 || payloadOffset >= encoded.byteLength) {
|
|
74532
|
-
throw new Error("Content chunk frame length is invalid");
|
|
74533
|
-
}
|
|
74534
|
-
const requestId = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
|
|
74535
|
-
encoded.subarray(CONTENT_CHUNK_HEADER_BYTES, payloadOffset)
|
|
74536
|
-
);
|
|
74537
|
-
const bytes = encoded.slice(payloadOffset);
|
|
74538
|
-
const sequence = new DataView(encoded.buffer, encoded.byteOffset, encoded.byteLength).getUint32(
|
|
74539
|
-
CONTENT_CHUNK_MAGIC.byteLength + 1
|
|
74540
|
-
);
|
|
74541
|
-
if (!isIdentifier(requestId) || bytes.byteLength > CONTENT_CHUNK_MAX_BYTES) {
|
|
74542
|
-
throw new Error("Content chunk frame is invalid");
|
|
74543
|
-
}
|
|
74544
|
-
return { bytes, requestId, sequence };
|
|
74545
|
-
}
|
|
74546
|
-
var FILE_READ_KIND, FILE_BEGIN_KIND, FILE_END_KIND, FILE_FAILED_KIND, CONTENT_WRITE_KIND, CONTENT_COMMIT_KIND, CONTENT_READY_KIND, CONTENT_AVAILABLE_KIND, CONTENT_CHUNK_MAX_BYTES, CONTENT_WRITE_MAX_BYTES, PROMPT_IMAGE_MAX_BYTES, CONTENT_CHUNK_MAGIC, CONTENT_CHUNK_HEADER_BYTES, fileReadCommandSchema, fileBeginEventSchema, contentWriteCommandSchema, contentCommitCommandSchema, contentReadyEventSchema, contentAvailableEventSchema, fileEndEventSchema, fileFailedEventSchema, decodeFileReadCommand, encodeFileReadCommand, decodeFileBeginEvent, encodeFileBeginEvent, decodeFileEndEvent, encodeFileEndEvent, decodeFileFailedEvent, encodeFileFailedEvent, decodeContentWriteCommand, encodeContentWriteCommand, decodeContentCommitCommand, encodeContentCommitCommand, decodeContentReadyEvent, encodeContentReadyEvent, decodeContentAvailableEvent, encodeContentAvailableEvent;
|
|
74547
|
-
var init_files = __esm({
|
|
74548
|
-
"../mobius-sdk/src/protocol/session/files/index.ts"() {
|
|
74549
|
-
"use strict";
|
|
74550
|
-
init_zod();
|
|
74551
|
-
init_identifier();
|
|
74552
|
-
init_message_codec();
|
|
74553
|
-
FILE_READ_KIND = "file.read";
|
|
74554
|
-
FILE_BEGIN_KIND = "file.begin";
|
|
74555
|
-
FILE_END_KIND = "file.end";
|
|
74556
|
-
FILE_FAILED_KIND = "file.failed";
|
|
74557
|
-
CONTENT_WRITE_KIND = "content.write";
|
|
74558
|
-
CONTENT_COMMIT_KIND = "content.commit";
|
|
74559
|
-
CONTENT_READY_KIND = "content.ready";
|
|
74560
|
-
CONTENT_AVAILABLE_KIND = "content.available";
|
|
74561
|
-
CONTENT_CHUNK_MAX_BYTES = 192 * 1024;
|
|
74562
|
-
CONTENT_WRITE_MAX_BYTES = 32 * 1024 * 1024;
|
|
74563
|
-
PROMPT_IMAGE_MAX_BYTES = 5e6;
|
|
74564
|
-
CONTENT_CHUNK_MAGIC = new Uint8Array([77, 66, 67, 49]);
|
|
74565
|
-
CONTENT_CHUNK_HEADER_BYTES = CONTENT_CHUNK_MAGIC.byteLength + 1 + 4;
|
|
74566
|
-
fileReadCommandSchema = external_exports.object({
|
|
74567
|
-
kind: external_exports.literal(FILE_READ_KIND),
|
|
74568
|
-
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
74569
|
-
requestId: identifierStringSchema,
|
|
74570
|
-
sessionId: identifierStringSchema,
|
|
74571
|
-
path: external_exports.string().min(1).max(4096)
|
|
74572
|
-
}).readonly();
|
|
74573
|
-
fileBeginEventSchema = external_exports.object({
|
|
74574
|
-
byteLength: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
74575
|
-
kind: external_exports.literal(FILE_BEGIN_KIND),
|
|
74576
|
-
mediaType: external_exports.string().min(1).max(255),
|
|
74577
|
-
modifiedAt: external_exports.iso.datetime({ offset: true }),
|
|
74578
|
-
name: external_exports.string().min(1).max(500),
|
|
74579
|
-
requestId: identifierStringSchema,
|
|
74580
|
-
sessionId: identifierStringSchema
|
|
74581
|
-
}).readonly();
|
|
74582
|
-
contentWriteCommandSchema = external_exports.object({
|
|
74583
|
-
byteLength: external_exports.number().int().positive().max(CONTENT_WRITE_MAX_BYTES),
|
|
74584
|
-
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
74585
|
-
contentKind: external_exports.enum(["image", "resource"]),
|
|
74586
|
-
kind: external_exports.literal(CONTENT_WRITE_KIND),
|
|
74587
|
-
mediaType: external_exports.string().min(1).max(255),
|
|
74588
|
-
name: external_exports.string().min(1).max(500),
|
|
74589
|
-
requestId: identifierStringSchema,
|
|
74590
|
-
sessionId: identifierStringSchema
|
|
74591
|
-
}).readonly();
|
|
74592
|
-
contentCommitCommandSchema = external_exports.object({
|
|
74593
|
-
kind: external_exports.literal(CONTENT_COMMIT_KIND),
|
|
74594
|
-
requestId: identifierStringSchema,
|
|
74595
|
-
sessionId: identifierStringSchema
|
|
74596
|
-
}).readonly();
|
|
74597
|
-
contentReadyEventSchema = external_exports.object({
|
|
74598
|
-
kind: external_exports.literal(CONTENT_READY_KIND),
|
|
74599
|
-
requestId: identifierStringSchema,
|
|
74600
|
-
sessionId: identifierStringSchema
|
|
74601
|
-
}).readonly();
|
|
74602
|
-
contentAvailableEventSchema = external_exports.object({
|
|
74603
|
-
byteLength: external_exports.number().int().positive().max(CONTENT_WRITE_MAX_BYTES),
|
|
74604
|
-
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
74605
|
-
kind: external_exports.literal(CONTENT_AVAILABLE_KIND),
|
|
74606
|
-
requestId: identifierStringSchema,
|
|
74607
|
-
sessionId: identifierStringSchema
|
|
74608
|
-
}).readonly();
|
|
74609
|
-
fileEndEventSchema = external_exports.object({
|
|
74610
|
-
kind: external_exports.literal(FILE_END_KIND),
|
|
74611
|
-
requestId: identifierStringSchema,
|
|
74612
|
-
sessionId: identifierStringSchema
|
|
74613
|
-
}).readonly();
|
|
74614
|
-
fileFailedEventSchema = external_exports.object({
|
|
74615
|
-
code: identifierStringSchema,
|
|
74616
|
-
kind: external_exports.literal(FILE_FAILED_KIND),
|
|
74617
|
-
message: external_exports.string().min(1).max(500),
|
|
74618
|
-
requestId: identifierStringSchema,
|
|
74619
|
-
sessionId: identifierStringSchema
|
|
74620
|
-
}).readonly();
|
|
74621
|
-
decodeFileReadCommand = (encoded) => decodeZodMessage(encoded, fileReadCommandSchema);
|
|
74622
|
-
encodeFileReadCommand = (message) => encodeZodMessage(message, fileReadCommandSchema);
|
|
74623
|
-
decodeFileBeginEvent = (encoded) => decodeZodMessage(encoded, fileBeginEventSchema);
|
|
74624
|
-
encodeFileBeginEvent = (message) => encodeZodMessage(message, fileBeginEventSchema);
|
|
74625
|
-
decodeFileEndEvent = (encoded) => decodeZodMessage(encoded, fileEndEventSchema);
|
|
74626
|
-
encodeFileEndEvent = (message) => encodeZodMessage(message, fileEndEventSchema);
|
|
74627
|
-
decodeFileFailedEvent = (encoded) => decodeZodMessage(encoded, fileFailedEventSchema);
|
|
74628
|
-
encodeFileFailedEvent = (message) => encodeZodMessage(message, fileFailedEventSchema);
|
|
74629
|
-
decodeContentWriteCommand = (encoded) => decodeZodMessage(encoded, contentWriteCommandSchema);
|
|
74630
|
-
encodeContentWriteCommand = (message) => encodeZodMessage(message, contentWriteCommandSchema);
|
|
74631
|
-
decodeContentCommitCommand = (encoded) => decodeZodMessage(encoded, contentCommitCommandSchema);
|
|
74632
|
-
encodeContentCommitCommand = (message) => encodeZodMessage(message, contentCommitCommandSchema);
|
|
74633
|
-
decodeContentReadyEvent = (encoded) => decodeZodMessage(encoded, contentReadyEventSchema);
|
|
74634
|
-
encodeContentReadyEvent = (message) => encodeZodMessage(message, contentReadyEventSchema);
|
|
74635
|
-
decodeContentAvailableEvent = (encoded) => decodeZodMessage(encoded, contentAvailableEventSchema);
|
|
74636
|
-
encodeContentAvailableEvent = (message) => encodeZodMessage(message, contentAvailableEventSchema);
|
|
74637
|
-
}
|
|
74638
|
-
});
|
|
74639
|
-
|
|
74640
74496
|
// ../mobius-sdk/src/protocol/shared/tool-input.ts
|
|
74641
74497
|
function boundedJsonIssue(value, depth = 0) {
|
|
74642
74498
|
if (depth > MAX_JSON_DEPTH) {
|
|
@@ -74811,123 +74667,847 @@ var init_interactions = __esm({
|
|
|
74811
74667
|
}
|
|
74812
74668
|
});
|
|
74813
74669
|
|
|
74814
|
-
// ../mobius-sdk/src/protocol/session/
|
|
74815
|
-
|
|
74816
|
-
|
|
74817
|
-
|
|
74670
|
+
// ../mobius-sdk/src/protocol/session/events/index.ts
|
|
74671
|
+
function isRecord4(value) {
|
|
74672
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
74673
|
+
}
|
|
74674
|
+
function hasUnknownDiscriminator(value, key, known) {
|
|
74675
|
+
if (!isRecord4(value)) {
|
|
74676
|
+
return false;
|
|
74677
|
+
}
|
|
74678
|
+
const variant = value[key];
|
|
74679
|
+
return typeof variant === "string" && !known.has(variant);
|
|
74680
|
+
}
|
|
74681
|
+
function containsUnknownContentBlock(value) {
|
|
74682
|
+
return hasUnknownDiscriminator(value, "type", knownContentBlockTypes);
|
|
74683
|
+
}
|
|
74684
|
+
function containsUnknownToolCallContent(value) {
|
|
74685
|
+
if (hasUnknownDiscriminator(value, "type", knownToolCallContentTypes)) {
|
|
74686
|
+
return true;
|
|
74687
|
+
}
|
|
74688
|
+
return isRecord4(value) && value["type"] === "content" && containsUnknownContentBlock(value["content"]);
|
|
74689
|
+
}
|
|
74690
|
+
function arrayContainsUnknown(value, predicate) {
|
|
74691
|
+
return Array.isArray(value) && value.some(predicate);
|
|
74692
|
+
}
|
|
74693
|
+
function containsUnknownAcpVariant(payload) {
|
|
74694
|
+
const update = payload["sessionUpdate"];
|
|
74695
|
+
if (typeof update !== "string") {
|
|
74696
|
+
return false;
|
|
74697
|
+
}
|
|
74698
|
+
if (!knownSessionUpdates.has(update)) {
|
|
74699
|
+
return true;
|
|
74700
|
+
}
|
|
74701
|
+
if (["user_message_chunk", "agent_message_chunk", "agent_thought_chunk", "compaction_summary_chunk"].includes(
|
|
74702
|
+
update
|
|
74703
|
+
)) {
|
|
74704
|
+
return containsUnknownContentBlock(payload["content"]);
|
|
74705
|
+
}
|
|
74706
|
+
if (update === "tool_call" || update === "tool_call_update") {
|
|
74707
|
+
return arrayContainsUnknown(payload["content"], containsUnknownToolCallContent);
|
|
74708
|
+
}
|
|
74709
|
+
if (update === "plan_update") {
|
|
74710
|
+
return hasUnknownDiscriminator(payload["plan"], "type", knownPlanTypes);
|
|
74711
|
+
}
|
|
74712
|
+
if (update === "config_option_update") {
|
|
74713
|
+
return arrayContainsUnknown(
|
|
74714
|
+
payload["configOptions"],
|
|
74715
|
+
(option) => hasUnknownDiscriminator(option, "type", knownConfigOptionTypes)
|
|
74716
|
+
);
|
|
74717
|
+
}
|
|
74718
|
+
if (update === "compaction_update") {
|
|
74719
|
+
return arrayContainsUnknown(payload["summary"], containsUnknownContentBlock);
|
|
74720
|
+
}
|
|
74721
|
+
return false;
|
|
74722
|
+
}
|
|
74723
|
+
function isKnownSessionEventVariant(value) {
|
|
74724
|
+
if (!isRecord4(value)) {
|
|
74725
|
+
return true;
|
|
74726
|
+
}
|
|
74727
|
+
const type = value["type"];
|
|
74728
|
+
if (typeof type !== "string") {
|
|
74729
|
+
return true;
|
|
74730
|
+
}
|
|
74731
|
+
if (type === "acp") {
|
|
74732
|
+
const payload = value["payload"];
|
|
74733
|
+
return !isRecord4(payload) || !containsUnknownAcpVariant(payload);
|
|
74734
|
+
}
|
|
74735
|
+
if (type === "lifecycle-metadata") {
|
|
74736
|
+
const payload = value["payload"];
|
|
74737
|
+
if (!isRecord4(payload)) {
|
|
74738
|
+
return true;
|
|
74739
|
+
}
|
|
74740
|
+
const kind = payload["kind"];
|
|
74741
|
+
if (typeof kind === "string" && !knownLifecycleKinds.has(kind)) {
|
|
74742
|
+
return false;
|
|
74743
|
+
}
|
|
74744
|
+
return kind !== "prompt.requested" || !arrayContainsUnknown(payload["content"], containsUnknownContentBlock);
|
|
74745
|
+
}
|
|
74746
|
+
return false;
|
|
74747
|
+
}
|
|
74748
|
+
function filterKnownSessionEventVariants(events) {
|
|
74749
|
+
return Array.isArray(events) ? events.filter(isKnownSessionEventVariant) : events;
|
|
74750
|
+
}
|
|
74751
|
+
function inputValue(value) {
|
|
74752
|
+
if (typeof value !== "string") {
|
|
74753
|
+
return value;
|
|
74754
|
+
}
|
|
74755
|
+
try {
|
|
74756
|
+
return JSON.parse(value);
|
|
74757
|
+
} catch (cause) {
|
|
74758
|
+
throw new ProtocolMessageError("Session Event Log V2 message is not valid JSON", { cause });
|
|
74759
|
+
}
|
|
74760
|
+
}
|
|
74761
|
+
function decode3(value, schema) {
|
|
74762
|
+
const result = schema.safeParse(inputValue(value));
|
|
74763
|
+
if (!result.success) {
|
|
74764
|
+
throw new ProtocolMessageError("Session Event Log V2 message does not match its schema", {
|
|
74765
|
+
cause: result.error
|
|
74766
|
+
});
|
|
74767
|
+
}
|
|
74768
|
+
return result.data;
|
|
74769
|
+
}
|
|
74770
|
+
function encode3(value, schema) {
|
|
74771
|
+
return JSON.stringify(decode3(value, schema));
|
|
74772
|
+
}
|
|
74773
|
+
function sanitizeKnownNativeSessionEvents(value) {
|
|
74774
|
+
const input2 = inputValue(value);
|
|
74775
|
+
if (!isRecord4(input2)) {
|
|
74776
|
+
return input2;
|
|
74777
|
+
}
|
|
74778
|
+
const page = input2["events"];
|
|
74779
|
+
const queuedPromptRequests = input2["queuedPromptRequests"];
|
|
74780
|
+
return {
|
|
74781
|
+
...input2,
|
|
74782
|
+
events: isRecord4(page) ? { ...page, events: filterKnownSessionEventVariants(page["events"]) } : page,
|
|
74783
|
+
queuedPromptRequests: Array.isArray(queuedPromptRequests) ? queuedPromptRequests.filter(
|
|
74784
|
+
(prompt) => !isRecord4(prompt) || !arrayContainsUnknown(prompt["content"], containsUnknownContentBlock)
|
|
74785
|
+
) : queuedPromptRequests
|
|
74786
|
+
};
|
|
74787
|
+
}
|
|
74788
|
+
var MAX_EVENT_COUNT, MAX_COLLECTION_SIZE2, MAX_CONTENT_LENGTH2, SESSION_EVENT_KIND, SESSION_EVENT_BATCH_MAX_SIZE, boundedString2, shortString, externalContentKeySchema, annotationsSchema, contentFields, textContentSchema, imageContentSchema, audioContentSchema, externalImageContentSchema, externalAudioContentSchema, externalResourceContentSchema, resourceLinkSchema, textResourceSchema, blobResourceSchema, embeddedResourceSchema, contentBlockSchema, toolCallContentSchema, toolKindSchema, toolStatusSchema, backgroundTaskSchema, toolPatchFields, planEntrySchema, planContentSchema, commandSchema, configSelectOptionSchema, configSelectGroupSchema, configBaseFields, sessionConfigOptionSchema2, contentChunkFields, acpSessionUpdateSchema, lifecycleBase, promptExecutionContextSchema, lifecycleMetadataSchema, sessionEventPayloadSchema, positionSchema, sharedSessionEventFields, sessionLiveEventFields, sessionEventSchema, sessionLiveEventSchema, wireLifecyclePayloadSchema, wireEventFields, sessionWireEventSchema, sessionWireEnvelopeSchema, knownContentBlockTypes, knownToolCallContentTypes, knownPlanTypes, knownConfigOptionTypes, knownSessionUpdates, knownLifecycleKinds, sessionEventBatchSchema, sessionLiveEventBatchSchema, sessionExportSchema, mobiusSessionExportSchema, sessionEventEnvelopeSchema, sessionEventLogPageSchema, sessionEventOmissionSchema, nativeEventPageRequestSchema, queuedPromptRequestEventLogSchema, nativeSessionEventsSchema, knownSessionLiveEventBatchSchema, decodeSessionEvent, decodeKnownSessionEventPayload, decodeSessionEventEnvelope, encodeSessionEventEnvelope, decodeAcpSessionUpdate, decodeKnownNativeSessionEvents;
|
|
74789
|
+
var init_events = __esm({
|
|
74790
|
+
"../mobius-sdk/src/protocol/session/events/index.ts"() {
|
|
74818
74791
|
"use strict";
|
|
74819
74792
|
init_zod();
|
|
74793
|
+
init_directory();
|
|
74794
|
+
init_tool_input();
|
|
74795
|
+
init_tool_input();
|
|
74820
74796
|
init_identifier();
|
|
74797
|
+
init_message_codec();
|
|
74821
74798
|
init_interactions();
|
|
74822
|
-
|
|
74823
|
-
|
|
74824
|
-
|
|
74825
|
-
|
|
74826
|
-
|
|
74827
|
-
|
|
74828
|
-
|
|
74799
|
+
MAX_EVENT_COUNT = 1e4;
|
|
74800
|
+
MAX_COLLECTION_SIZE2 = 1e3;
|
|
74801
|
+
MAX_CONTENT_LENGTH2 = 1e6;
|
|
74802
|
+
SESSION_EVENT_KIND = "session.event.v2";
|
|
74803
|
+
SESSION_EVENT_BATCH_MAX_SIZE = 1e3;
|
|
74804
|
+
boundedString2 = external_exports.string().max(MAX_CONTENT_LENGTH2);
|
|
74805
|
+
shortString = external_exports.string().max(2048);
|
|
74806
|
+
externalContentKeySchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
74807
|
+
annotationsSchema = external_exports.object({
|
|
74808
|
+
audience: external_exports.array(external_exports.enum(["assistant", "user"])).max(2).readonly().nullable().optional(),
|
|
74809
|
+
lastModified: shortString.nullable().optional(),
|
|
74810
|
+
priority: external_exports.number().finite().nullable().optional()
|
|
74829
74811
|
}).readonly();
|
|
74830
|
-
|
|
74831
|
-
|
|
74832
|
-
|
|
74833
|
-
|
|
74834
|
-
|
|
74835
|
-
|
|
74836
|
-
|
|
74812
|
+
contentFields = { annotations: annotationsSchema.nullable().optional() };
|
|
74813
|
+
textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
|
|
74814
|
+
imageContentSchema = external_exports.object({
|
|
74815
|
+
...contentFields,
|
|
74816
|
+
data: external_exports.string(),
|
|
74817
|
+
mimeType: shortString,
|
|
74818
|
+
type: external_exports.literal("image"),
|
|
74819
|
+
uri: boundedString2.nullable().optional()
|
|
74837
74820
|
}).readonly();
|
|
74838
|
-
|
|
74839
|
-
|
|
74840
|
-
|
|
74841
|
-
|
|
74821
|
+
audioContentSchema = external_exports.object({ ...contentFields, data: external_exports.string(), mimeType: shortString, type: external_exports.literal("audio") }).readonly();
|
|
74822
|
+
externalImageContentSchema = external_exports.object({
|
|
74823
|
+
...contentFields,
|
|
74824
|
+
byteLength: external_exports.number().int().positive().safe(),
|
|
74825
|
+
imageKey: externalContentKeySchema,
|
|
74826
|
+
mimeType: shortString,
|
|
74827
|
+
type: external_exports.literal("external_image"),
|
|
74828
|
+
uri: boundedString2.nullable().optional()
|
|
74842
74829
|
}).readonly();
|
|
74843
|
-
|
|
74844
|
-
|
|
74830
|
+
externalAudioContentSchema = external_exports.object({
|
|
74831
|
+
...contentFields,
|
|
74832
|
+
audioKey: externalContentKeySchema,
|
|
74833
|
+
byteLength: external_exports.number().int().positive().safe(),
|
|
74834
|
+
mimeType: shortString,
|
|
74835
|
+
type: external_exports.literal("external_audio")
|
|
74836
|
+
}).readonly();
|
|
74837
|
+
externalResourceContentSchema = external_exports.object({
|
|
74838
|
+
...contentFields,
|
|
74839
|
+
byteLength: external_exports.number().int().positive().safe(),
|
|
74840
|
+
encoding: external_exports.enum(["binary", "text"]),
|
|
74841
|
+
mimeType: shortString.nullable().optional(),
|
|
74842
|
+
resourceKey: externalContentKeySchema,
|
|
74843
|
+
type: external_exports.literal("external_resource"),
|
|
74844
|
+
uri: boundedString2
|
|
74845
|
+
}).readonly();
|
|
74846
|
+
resourceLinkSchema = external_exports.object({
|
|
74847
|
+
...contentFields,
|
|
74848
|
+
description: boundedString2.nullable().optional(),
|
|
74849
|
+
mimeType: shortString.nullable().optional(),
|
|
74850
|
+
name: shortString,
|
|
74851
|
+
size: external_exports.number().int().nonnegative().safe().nullable().optional(),
|
|
74852
|
+
title: shortString.nullable().optional(),
|
|
74853
|
+
type: external_exports.literal("resource_link"),
|
|
74854
|
+
uri: boundedString2
|
|
74855
|
+
}).readonly();
|
|
74856
|
+
textResourceSchema = external_exports.object({
|
|
74857
|
+
mimeType: shortString.nullable().optional(),
|
|
74858
|
+
text: boundedString2,
|
|
74859
|
+
uri: boundedString2
|
|
74860
|
+
}).readonly();
|
|
74861
|
+
blobResourceSchema = external_exports.object({
|
|
74862
|
+
blob: external_exports.string(),
|
|
74863
|
+
mimeType: shortString.nullable().optional(),
|
|
74864
|
+
uri: boundedString2
|
|
74865
|
+
}).readonly();
|
|
74866
|
+
embeddedResourceSchema = external_exports.object({
|
|
74867
|
+
...contentFields,
|
|
74868
|
+
resource: external_exports.union([textResourceSchema, blobResourceSchema]),
|
|
74869
|
+
type: external_exports.literal("resource")
|
|
74870
|
+
}).readonly();
|
|
74871
|
+
contentBlockSchema = external_exports.discriminatedUnion("type", [
|
|
74872
|
+
textContentSchema,
|
|
74873
|
+
imageContentSchema,
|
|
74874
|
+
audioContentSchema,
|
|
74875
|
+
resourceLinkSchema,
|
|
74876
|
+
embeddedResourceSchema,
|
|
74877
|
+
externalImageContentSchema,
|
|
74878
|
+
externalAudioContentSchema,
|
|
74879
|
+
externalResourceContentSchema
|
|
74880
|
+
]);
|
|
74881
|
+
toolCallContentSchema = external_exports.discriminatedUnion("type", [
|
|
74882
|
+
external_exports.object({ content: contentBlockSchema, type: external_exports.literal("content") }).readonly(),
|
|
74845
74883
|
external_exports.object({
|
|
74846
|
-
|
|
74847
|
-
|
|
74848
|
-
|
|
74849
|
-
|
|
74884
|
+
newText: boundedString2,
|
|
74885
|
+
oldText: boundedString2.nullable().optional(),
|
|
74886
|
+
path: boundedString2,
|
|
74887
|
+
type: external_exports.literal("diff")
|
|
74850
74888
|
}).readonly(),
|
|
74889
|
+
external_exports.object({ terminalId: shortString, type: external_exports.literal("terminal") }).readonly()
|
|
74890
|
+
]);
|
|
74891
|
+
toolKindSchema = external_exports.enum([
|
|
74892
|
+
"read",
|
|
74893
|
+
"edit",
|
|
74894
|
+
"delete",
|
|
74895
|
+
"move",
|
|
74896
|
+
"search",
|
|
74897
|
+
"execute",
|
|
74898
|
+
"think",
|
|
74899
|
+
"fetch",
|
|
74900
|
+
"switch_mode",
|
|
74901
|
+
"other"
|
|
74902
|
+
]);
|
|
74903
|
+
toolStatusSchema = external_exports.enum(["pending", "in_progress", "completed", "failed"]);
|
|
74904
|
+
backgroundTaskSchema = external_exports.object({
|
|
74905
|
+
id: shortString,
|
|
74906
|
+
status: external_exports.enum(["running", "completed", "failed", "stopped", "unknown"])
|
|
74907
|
+
}).readonly();
|
|
74908
|
+
toolPatchFields = {
|
|
74909
|
+
backgroundTask: backgroundTaskSchema.optional(),
|
|
74910
|
+
content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
|
|
74911
|
+
kind: toolKindSchema.nullable().optional(),
|
|
74912
|
+
locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
|
|
74913
|
+
name: shortString.nullable().optional(),
|
|
74914
|
+
rawInput: boundedJsonSchema.optional(),
|
|
74915
|
+
rawOutput: boundedJsonSchema.optional(),
|
|
74916
|
+
status: toolStatusSchema.nullable().optional(),
|
|
74917
|
+
title: boundedString2.nullable().optional()
|
|
74918
|
+
};
|
|
74919
|
+
planEntrySchema = external_exports.object({
|
|
74920
|
+
content: boundedString2,
|
|
74921
|
+
priority: external_exports.enum(["high", "medium", "low"]),
|
|
74922
|
+
status: external_exports.enum(["pending", "in_progress", "completed"])
|
|
74923
|
+
}).readonly();
|
|
74924
|
+
planContentSchema = external_exports.discriminatedUnion("type", [
|
|
74851
74925
|
external_exports.object({
|
|
74852
|
-
|
|
74853
|
-
|
|
74854
|
-
|
|
74855
|
-
external_exports.object({
|
|
74856
|
-
kind: external_exports.literal("response_applied"),
|
|
74857
|
-
respondedAt: timestampSchema,
|
|
74858
|
-
responderId: identifierSchema,
|
|
74859
|
-
response: interactionResponseSchema
|
|
74860
|
-
}).readonly()
|
|
74861
|
-
]),
|
|
74862
|
-
resolvedAt: timestampSchema
|
|
74926
|
+
entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
74927
|
+
planId: shortString,
|
|
74928
|
+
type: external_exports.literal("items")
|
|
74863
74929
|
}).readonly(),
|
|
74864
|
-
external_exports.object({
|
|
74930
|
+
external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString2 }).readonly(),
|
|
74865
74931
|
external_exports.object({
|
|
74866
|
-
|
|
74867
|
-
|
|
74932
|
+
content: boundedString2,
|
|
74933
|
+
planId: shortString,
|
|
74934
|
+
type: external_exports.literal("markdown")
|
|
74868
74935
|
}).readonly()
|
|
74869
74936
|
]);
|
|
74870
|
-
|
|
74871
|
-
|
|
74872
|
-
|
|
74873
|
-
|
|
74874
|
-
sessionId: identifierSchema,
|
|
74875
|
-
state: interactionStateSchema,
|
|
74876
|
-
turnId: identifierSchema
|
|
74877
|
-
}).readonly();
|
|
74878
|
-
}
|
|
74879
|
-
});
|
|
74880
|
-
|
|
74881
|
-
// ../mobius-sdk/src/protocol/session/lifecycle/index.ts
|
|
74882
|
-
var SESSION_PREPARE_KIND, SESSION_READY_KIND, SESSION_LIST_KIND, SESSION_LISTED_KIND, SESSION_QUERY_KIND, SESSION_QUERIED_KIND, SESSION_RESTORE_KIND, SESSION_RESTORED_KIND, SESSION_CLOSE_KIND, SESSION_CLOSED_KIND, SESSION_CLOSE_NOTICE_KIND, SESSION_CLOSED_ERROR_CODE, SESSION_STATUS_CHANGED_KIND, SESSION_COMMANDS_UPDATED_KIND, SESSION_INFO_UPDATED_KIND, SESSION_OPERATION_FAILED_KIND, sessionStatusChangedEventSchema, sessionMetadataSchema, sessionListCommandSchema, sessionsListedEventSchema, sessionQueryCommandSchema, sessionsQueriedEventSchema, sessionRestoreCommandSchema, sessionCloseCommandSchema, sessionPrepareCommandSchema, runtimeTimingsSchema, sessionReadyEventSchema, sessionRestoredEventSchema, sessionClosedEventSchema, sessionCloseNoticeEventSchema, sessionCommandsUpdatedEventSchema, sessionInfoUpdatedEventSchema, sessionOperationFailedEventSchema, decodeSessionListCommand, encodeSessionListCommand, decodeSessionsListedEvent, encodeSessionsListedEvent, decodeSessionQueryCommand, encodeSessionQueryCommand, decodeSessionsQueriedEvent, encodeSessionsQueriedEvent, decodeSessionRestoreCommand, encodeSessionRestoreCommand, decodeSessionRestoredEvent, encodeSessionRestoredEvent, decodeSessionCloseCommand, encodeSessionCloseCommand, decodeSessionClosedEvent, encodeSessionClosedEvent, decodeSessionCloseNoticeEvent, encodeSessionCloseNoticeEvent, decodeSessionStatusChangedEvent, encodeSessionStatusChangedEvent, decodeSessionPrepareCommand, encodeSessionPrepareCommand, decodeSessionReadyEvent, encodeSessionReadyEvent, decodeSessionInfoUpdatedEvent, encodeSessionInfoUpdatedEvent, decodeSessionOperationFailedEvent, encodeSessionOperationFailedEvent;
|
|
74883
|
-
var init_lifecycle = __esm({
|
|
74884
|
-
"../mobius-sdk/src/protocol/session/lifecycle/index.ts"() {
|
|
74885
|
-
"use strict";
|
|
74886
|
-
init_zod();
|
|
74887
|
-
init_directory();
|
|
74888
|
-
init_identifier();
|
|
74889
|
-
init_message_codec();
|
|
74890
|
-
init_configuration();
|
|
74891
|
-
init_shared2();
|
|
74892
|
-
SESSION_PREPARE_KIND = "session.prepare";
|
|
74893
|
-
SESSION_READY_KIND = "session.ready";
|
|
74894
|
-
SESSION_LIST_KIND = "session.list";
|
|
74895
|
-
SESSION_LISTED_KIND = "session.listed";
|
|
74896
|
-
SESSION_QUERY_KIND = "session.query";
|
|
74897
|
-
SESSION_QUERIED_KIND = "session.queried";
|
|
74898
|
-
SESSION_RESTORE_KIND = "session.restore";
|
|
74899
|
-
SESSION_RESTORED_KIND = "session.restored";
|
|
74900
|
-
SESSION_CLOSE_KIND = "session.close";
|
|
74901
|
-
SESSION_CLOSED_KIND = "session.closed";
|
|
74902
|
-
SESSION_CLOSE_NOTICE_KIND = "session.close.notice";
|
|
74903
|
-
SESSION_CLOSED_ERROR_CODE = "session_closed";
|
|
74904
|
-
SESSION_STATUS_CHANGED_KIND = "session.status.changed";
|
|
74905
|
-
SESSION_COMMANDS_UPDATED_KIND = "session.commands.updated";
|
|
74906
|
-
SESSION_INFO_UPDATED_KIND = "session.info.updated";
|
|
74907
|
-
SESSION_OPERATION_FAILED_KIND = "session.operation.failed";
|
|
74908
|
-
sessionStatusChangedEventSchema = external_exports.object({
|
|
74909
|
-
kind: external_exports.literal(SESSION_STATUS_CHANGED_KIND),
|
|
74910
|
-
sessionId: identifierStringSchema,
|
|
74911
|
-
status: sessionStatusSchema
|
|
74937
|
+
commandSchema = external_exports.object({
|
|
74938
|
+
description: boundedString2,
|
|
74939
|
+
input: external_exports.object({ hint: boundedString2 }).readonly().nullable().optional(),
|
|
74940
|
+
name: shortString
|
|
74912
74941
|
}).readonly();
|
|
74913
|
-
|
|
74914
|
-
|
|
74915
|
-
|
|
74916
|
-
|
|
74917
|
-
directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
|
|
74918
|
-
prompted: external_exports.boolean(),
|
|
74919
|
-
sessionId: identifierStringSchema,
|
|
74920
|
-
status: sessionStatusSchema.default({ kind: "idle" }),
|
|
74921
|
-
title: external_exports.string().max(500),
|
|
74922
|
-
updatedAt: external_exports.iso.datetime({ offset: true })
|
|
74942
|
+
configSelectOptionSchema = external_exports.object({
|
|
74943
|
+
description: boundedString2.nullable().optional(),
|
|
74944
|
+
name: shortString,
|
|
74945
|
+
value: shortString
|
|
74923
74946
|
}).readonly();
|
|
74924
|
-
|
|
74925
|
-
|
|
74926
|
-
|
|
74927
|
-
|
|
74947
|
+
configSelectGroupSchema = external_exports.object({
|
|
74948
|
+
group: shortString,
|
|
74949
|
+
name: shortString,
|
|
74950
|
+
options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
74928
74951
|
}).readonly();
|
|
74929
|
-
|
|
74930
|
-
|
|
74952
|
+
configBaseFields = {
|
|
74953
|
+
category: shortString.nullable().optional(),
|
|
74954
|
+
description: boundedString2.nullable().optional(),
|
|
74955
|
+
id: shortString,
|
|
74956
|
+
name: shortString
|
|
74957
|
+
};
|
|
74958
|
+
sessionConfigOptionSchema2 = external_exports.discriminatedUnion("type", [
|
|
74959
|
+
external_exports.object({
|
|
74960
|
+
...configBaseFields,
|
|
74961
|
+
currentValue: shortString,
|
|
74962
|
+
options: external_exports.union([
|
|
74963
|
+
external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
74964
|
+
external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
74965
|
+
]),
|
|
74966
|
+
type: external_exports.literal("select")
|
|
74967
|
+
}).readonly(),
|
|
74968
|
+
external_exports.object({ ...configBaseFields, currentValue: external_exports.boolean(), type: external_exports.literal("boolean") }).readonly()
|
|
74969
|
+
]);
|
|
74970
|
+
contentChunkFields = {
|
|
74971
|
+
content: contentBlockSchema,
|
|
74972
|
+
messageId: shortString.nullable().optional()
|
|
74973
|
+
};
|
|
74974
|
+
acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate", [
|
|
74975
|
+
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("user_message_chunk") }).readonly(),
|
|
74976
|
+
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_message_chunk") }).readonly(),
|
|
74977
|
+
external_exports.object({
|
|
74978
|
+
...contentChunkFields,
|
|
74979
|
+
meta: external_exports.object({ truncated: external_exports.boolean().optional() }).readonly().optional(),
|
|
74980
|
+
sessionUpdate: external_exports.literal("agent_thought_chunk")
|
|
74981
|
+
}).readonly(),
|
|
74982
|
+
external_exports.object({
|
|
74983
|
+
backgroundTask: backgroundTaskSchema.optional(),
|
|
74984
|
+
content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
74985
|
+
kind: toolKindSchema.optional(),
|
|
74986
|
+
locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
74987
|
+
name: shortString.nullable().optional(),
|
|
74988
|
+
rawInput: boundedJsonSchema.optional(),
|
|
74989
|
+
rawOutput: boundedJsonSchema.optional(),
|
|
74990
|
+
sessionUpdate: external_exports.literal("tool_call"),
|
|
74991
|
+
status: toolStatusSchema.optional(),
|
|
74992
|
+
title: boundedString2,
|
|
74993
|
+
toolCallId: shortString
|
|
74994
|
+
}).readonly(),
|
|
74995
|
+
external_exports.object({ ...toolPatchFields, sessionUpdate: external_exports.literal("tool_call_update"), toolCallId: shortString }).readonly(),
|
|
74996
|
+
external_exports.object({
|
|
74997
|
+
entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
74998
|
+
sessionUpdate: external_exports.literal("plan")
|
|
74999
|
+
}).readonly(),
|
|
75000
|
+
external_exports.object({ plan: planContentSchema, sessionUpdate: external_exports.literal("plan_update") }).readonly(),
|
|
75001
|
+
external_exports.object({ planId: shortString, sessionUpdate: external_exports.literal("plan_removed") }).readonly(),
|
|
75002
|
+
external_exports.object({
|
|
75003
|
+
availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
75004
|
+
sessionUpdate: external_exports.literal("available_commands_update")
|
|
75005
|
+
}).readonly(),
|
|
75006
|
+
external_exports.object({
|
|
75007
|
+
currentModeId: shortString,
|
|
75008
|
+
sessionUpdate: external_exports.literal("current_mode_update")
|
|
75009
|
+
}).readonly(),
|
|
75010
|
+
external_exports.object({
|
|
75011
|
+
configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
75012
|
+
sessionUpdate: external_exports.literal("config_option_update")
|
|
75013
|
+
}).readonly(),
|
|
75014
|
+
external_exports.object({
|
|
75015
|
+
sessionUpdate: external_exports.literal("session_info_update"),
|
|
75016
|
+
title: boundedString2.nullable().optional(),
|
|
75017
|
+
updatedAt: shortString.nullable().optional()
|
|
75018
|
+
}).readonly(),
|
|
75019
|
+
external_exports.object({
|
|
75020
|
+
cost: external_exports.object({ amount: external_exports.number().finite(), currency: external_exports.string().max(16) }).readonly().nullable().optional(),
|
|
75021
|
+
sessionUpdate: external_exports.literal("usage_update"),
|
|
75022
|
+
size: external_exports.number().int().nonnegative().safe(),
|
|
75023
|
+
used: external_exports.number().int().nonnegative().safe()
|
|
75024
|
+
}).readonly(),
|
|
75025
|
+
external_exports.object({
|
|
75026
|
+
compactionId: shortString,
|
|
75027
|
+
error: boundedString2.nullable().optional(),
|
|
75028
|
+
sessionUpdate: external_exports.literal("compaction_update"),
|
|
75029
|
+
status: shortString,
|
|
75030
|
+
summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional()
|
|
75031
|
+
}).readonly(),
|
|
75032
|
+
external_exports.object({
|
|
75033
|
+
compactionId: shortString,
|
|
75034
|
+
content: contentBlockSchema,
|
|
75035
|
+
sessionUpdate: external_exports.literal("compaction_summary_chunk")
|
|
75036
|
+
}).readonly()
|
|
75037
|
+
]);
|
|
75038
|
+
lifecycleBase = { commandId: identifierStringSchema };
|
|
75039
|
+
promptExecutionContextSchema = external_exports.object({
|
|
75040
|
+
agentId: identifierStringSchema,
|
|
75041
|
+
directoryId: DIRECTORY_IDENTIFIER,
|
|
75042
|
+
additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly()
|
|
75043
|
+
}).readonly();
|
|
75044
|
+
lifecycleMetadataSchema = external_exports.discriminatedUnion("kind", [
|
|
75045
|
+
external_exports.object({ kind: external_exports.literal("session.queue.changed") }).readonly(),
|
|
75046
|
+
external_exports.object({ event: sessionPermissionRequestedEventSchema, kind: external_exports.literal("session.permission.requested") }).readonly(),
|
|
75047
|
+
external_exports.object({ event: sessionPermissionResolvedEventSchema, kind: external_exports.literal("session.permission.resolved") }).readonly(),
|
|
75048
|
+
external_exports.object({ event: sessionElicitationRequestedEventSchema, kind: external_exports.literal("session.elicitation.requested") }).readonly(),
|
|
75049
|
+
external_exports.object({ event: sessionElicitationResolvedEventSchema, kind: external_exports.literal("session.elicitation.resolved") }).readonly(),
|
|
75050
|
+
external_exports.object({
|
|
75051
|
+
...lifecycleBase,
|
|
75052
|
+
content: external_exports.array(contentBlockSchema).min(1).max(100).readonly(),
|
|
75053
|
+
disposition: shortString.optional(),
|
|
75054
|
+
kind: external_exports.literal("prompt.requested"),
|
|
75055
|
+
context: promptExecutionContextSchema.optional(),
|
|
75056
|
+
targetCommandId: identifierStringSchema.optional()
|
|
75057
|
+
}).readonly(),
|
|
75058
|
+
external_exports.object({ ...lifecycleBase, attemptId: identifierStringSchema, epoch: identifierStringSchema, kind: external_exports.literal("prompt.started") }).readonly(),
|
|
75059
|
+
external_exports.object({
|
|
75060
|
+
...lifecycleBase,
|
|
75061
|
+
kind: external_exports.literal("prompt.completed"),
|
|
75062
|
+
stopReason: shortString
|
|
75063
|
+
}).readonly(),
|
|
75064
|
+
external_exports.object({
|
|
75065
|
+
...lifecycleBase,
|
|
75066
|
+
code: identifierStringSchema,
|
|
75067
|
+
kind: external_exports.literal("prompt.failed-before-start"),
|
|
75068
|
+
message: external_exports.string().min(1).max(500)
|
|
75069
|
+
}).readonly(),
|
|
75070
|
+
external_exports.object({
|
|
75071
|
+
...lifecycleBase,
|
|
75072
|
+
attemptId: identifierStringSchema,
|
|
75073
|
+
code: identifierStringSchema,
|
|
75074
|
+
kind: external_exports.literal("prompt.failed"),
|
|
75075
|
+
message: external_exports.string().min(1).max(500)
|
|
75076
|
+
}).readonly()
|
|
75077
|
+
]);
|
|
75078
|
+
sessionEventPayloadSchema = external_exports.discriminatedUnion("type", [
|
|
75079
|
+
external_exports.object({ payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
75080
|
+
external_exports.object({ payload: lifecycleMetadataSchema, type: external_exports.literal("lifecycle-metadata") }).readonly()
|
|
75081
|
+
]);
|
|
75082
|
+
positionSchema = external_exports.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
75083
|
+
sharedSessionEventFields = {
|
|
75084
|
+
eventId: identifierStringSchema,
|
|
75085
|
+
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).readonly().optional(),
|
|
75086
|
+
recordedAt: external_exports.iso.datetime({ offset: true }),
|
|
75087
|
+
sessionGenerationId: identifierStringSchema,
|
|
75088
|
+
sessionId: identifierStringSchema
|
|
75089
|
+
};
|
|
75090
|
+
sessionLiveEventFields = { ...sharedSessionEventFields, position: positionSchema };
|
|
75091
|
+
sessionEventSchema = external_exports.object({ ...sharedSessionEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly();
|
|
75092
|
+
sessionLiveEventSchema = external_exports.discriminatedUnion("type", [
|
|
75093
|
+
external_exports.object({ ...sessionLiveEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
75094
|
+
external_exports.object({
|
|
75095
|
+
...sessionLiveEventFields,
|
|
75096
|
+
payload: lifecycleMetadataSchema,
|
|
75097
|
+
type: external_exports.literal("lifecycle-metadata")
|
|
75098
|
+
}).readonly()
|
|
75099
|
+
]);
|
|
75100
|
+
wireLifecyclePayloadSchema = external_exports.object({
|
|
75101
|
+
kind: identifierStringSchema,
|
|
75102
|
+
commandId: identifierStringSchema.optional(),
|
|
75103
|
+
context: promptExecutionContextSchema.unwrap().passthrough().readonly().optional(),
|
|
75104
|
+
event: external_exports.object({ interactionId: identifierStringSchema.optional() }).passthrough().readonly().optional()
|
|
75105
|
+
}).passthrough().readonly();
|
|
75106
|
+
wireEventFields = {
|
|
75107
|
+
...sessionLiveEventFields,
|
|
75108
|
+
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).passthrough().readonly().optional()
|
|
75109
|
+
};
|
|
75110
|
+
sessionWireEventSchema = external_exports.union([
|
|
75111
|
+
external_exports.object({
|
|
75112
|
+
...wireEventFields,
|
|
75113
|
+
type: external_exports.literal("acp"),
|
|
75114
|
+
payload: external_exports.object({ sessionUpdate: identifierStringSchema }).passthrough().readonly()
|
|
75115
|
+
}).passthrough().readonly(),
|
|
75116
|
+
external_exports.object({
|
|
75117
|
+
...wireEventFields,
|
|
75118
|
+
type: external_exports.literal("lifecycle-metadata"),
|
|
75119
|
+
payload: wireLifecyclePayloadSchema
|
|
75120
|
+
}).passthrough().readonly(),
|
|
75121
|
+
external_exports.object({
|
|
75122
|
+
...wireEventFields,
|
|
75123
|
+
type: identifierStringSchema.refine((type) => type !== "acp" && type !== "lifecycle-metadata"),
|
|
75124
|
+
payload: external_exports.record(external_exports.string(), external_exports.unknown()).readonly()
|
|
75125
|
+
}).passthrough().readonly()
|
|
75126
|
+
]);
|
|
75127
|
+
sessionWireEnvelopeSchema = external_exports.object({
|
|
75128
|
+
kind: external_exports.literal(SESSION_EVENT_KIND),
|
|
75129
|
+
events: external_exports.array(sessionWireEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly()
|
|
75130
|
+
}).passthrough().readonly();
|
|
75131
|
+
knownContentBlockTypes = /* @__PURE__ */ new Set([
|
|
75132
|
+
"text",
|
|
75133
|
+
"image",
|
|
75134
|
+
"audio",
|
|
75135
|
+
"resource_link",
|
|
75136
|
+
"resource",
|
|
75137
|
+
"external_image",
|
|
75138
|
+
"external_audio",
|
|
75139
|
+
"external_resource"
|
|
75140
|
+
]);
|
|
75141
|
+
knownToolCallContentTypes = /* @__PURE__ */ new Set(["content", "diff", "terminal"]);
|
|
75142
|
+
knownPlanTypes = /* @__PURE__ */ new Set(["items", "file", "markdown"]);
|
|
75143
|
+
knownConfigOptionTypes = /* @__PURE__ */ new Set(["select", "boolean"]);
|
|
75144
|
+
knownSessionUpdates = /* @__PURE__ */ new Set([
|
|
75145
|
+
"user_message_chunk",
|
|
75146
|
+
"agent_message_chunk",
|
|
75147
|
+
"agent_thought_chunk",
|
|
75148
|
+
"tool_call",
|
|
75149
|
+
"tool_call_update",
|
|
75150
|
+
"plan",
|
|
75151
|
+
"plan_update",
|
|
75152
|
+
"plan_removed",
|
|
75153
|
+
"available_commands_update",
|
|
75154
|
+
"current_mode_update",
|
|
75155
|
+
"config_option_update",
|
|
75156
|
+
"session_info_update",
|
|
75157
|
+
"usage_update",
|
|
75158
|
+
"compaction_update",
|
|
75159
|
+
"compaction_summary_chunk"
|
|
75160
|
+
]);
|
|
75161
|
+
knownLifecycleKinds = /* @__PURE__ */ new Set([
|
|
75162
|
+
"session.queue.changed",
|
|
75163
|
+
"session.permission.requested",
|
|
75164
|
+
"session.permission.resolved",
|
|
75165
|
+
"session.elicitation.requested",
|
|
75166
|
+
"session.elicitation.resolved",
|
|
75167
|
+
"prompt.requested",
|
|
75168
|
+
"prompt.started",
|
|
75169
|
+
"prompt.completed",
|
|
75170
|
+
"prompt.failed-before-start",
|
|
75171
|
+
"prompt.failed"
|
|
75172
|
+
]);
|
|
75173
|
+
sessionEventBatchSchema = external_exports.array(sessionEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
75174
|
+
sessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
75175
|
+
sessionExportSchema = external_exports.object({
|
|
75176
|
+
binding: external_exports.object({
|
|
75177
|
+
bindingId: identifierStringSchema,
|
|
75178
|
+
runtimeId: identifierStringSchema
|
|
75179
|
+
}).readonly(),
|
|
75180
|
+
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
75181
|
+
sessionId: identifierStringSchema,
|
|
75182
|
+
truncated: external_exports.boolean()
|
|
75183
|
+
}).readonly().superRefine((session, context) => {
|
|
75184
|
+
const eventIds = /* @__PURE__ */ new Set();
|
|
75185
|
+
for (const [index2, event] of session.events.entries()) {
|
|
75186
|
+
if (event.sessionId !== session.sessionId) {
|
|
75187
|
+
context.addIssue({
|
|
75188
|
+
code: "custom",
|
|
75189
|
+
message: "Exported event belongs to a different Session",
|
|
75190
|
+
path: ["events", index2, "sessionId"]
|
|
75191
|
+
});
|
|
75192
|
+
}
|
|
75193
|
+
if (eventIds.has(event.eventId)) {
|
|
75194
|
+
context.addIssue({
|
|
75195
|
+
code: "custom",
|
|
75196
|
+
message: "Exported event identities are not unique",
|
|
75197
|
+
path: ["events", index2, "eventId"]
|
|
75198
|
+
});
|
|
75199
|
+
}
|
|
75200
|
+
eventIds.add(event.eventId);
|
|
75201
|
+
}
|
|
75202
|
+
});
|
|
75203
|
+
mobiusSessionExportSchema = external_exports.object({
|
|
75204
|
+
formatVersion: external_exports.literal("2"),
|
|
75205
|
+
session: sessionExportSchema
|
|
75206
|
+
}).readonly();
|
|
75207
|
+
sessionEventEnvelopeSchema = external_exports.object({ events: sessionLiveEventBatchSchema, kind: external_exports.literal(SESSION_EVENT_KIND) }).readonly();
|
|
75208
|
+
sessionEventLogPageSchema = external_exports.object({
|
|
75209
|
+
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
75210
|
+
nextCursor: external_exports.string().min(1).max(512).nullable(),
|
|
75211
|
+
sessionGenerationId: identifierStringSchema,
|
|
75212
|
+
tailCursor: external_exports.string().max(512),
|
|
75213
|
+
// The generation-scoped live position covered by this snapshot, including
|
|
75214
|
+
// coalesced and omitted events. Absent only on older Runtime versions.
|
|
75215
|
+
throughPosition: positionSchema.optional(),
|
|
75216
|
+
truncated: external_exports.boolean(),
|
|
75217
|
+
version: external_exports.literal(2)
|
|
75218
|
+
}).readonly();
|
|
75219
|
+
sessionEventOmissionSchema = external_exports.literal("agent-reasoning");
|
|
75220
|
+
nativeEventPageRequestSchema = external_exports.object({
|
|
75221
|
+
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
75222
|
+
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
75223
|
+
// Legacy callers may still send this option; readers must ignore it.
|
|
75224
|
+
omit: external_exports.array(sessionEventOmissionSchema).max(1).readonly().optional()
|
|
75225
|
+
}).readonly();
|
|
75226
|
+
queuedPromptRequestEventLogSchema = external_exports.object({
|
|
75227
|
+
commandId: identifierStringSchema,
|
|
75228
|
+
content: external_exports.array(contentBlockSchema).min(1).max(100).readonly(),
|
|
75229
|
+
disposition: shortString.optional(),
|
|
75230
|
+
targetCommandId: identifierStringSchema.optional()
|
|
75231
|
+
}).readonly();
|
|
75232
|
+
nativeSessionEventsSchema = external_exports.object({
|
|
75233
|
+
events: sessionEventLogPageSchema,
|
|
75234
|
+
queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
75235
|
+
}).readonly();
|
|
75236
|
+
knownSessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
75237
|
+
decodeSessionEvent = (value) => decode3(value, sessionEventSchema);
|
|
75238
|
+
decodeKnownSessionEventPayload = (value) => isKnownSessionEventVariant(value) ? decode3(value, sessionEventPayloadSchema) : null;
|
|
75239
|
+
decodeSessionEventEnvelope = (value) => decode3(value, sessionEventEnvelopeSchema);
|
|
75240
|
+
encodeSessionEventEnvelope = (value) => encode3(value, sessionEventEnvelopeSchema);
|
|
75241
|
+
decodeAcpSessionUpdate = (value) => decode3(value, acpSessionUpdateSchema);
|
|
75242
|
+
decodeKnownNativeSessionEvents = (value) => decode3(sanitizeKnownNativeSessionEvents(value), nativeSessionEventsSchema);
|
|
75243
|
+
}
|
|
75244
|
+
});
|
|
75245
|
+
|
|
75246
|
+
// ../mobius-sdk/src/protocol/session/files/index.ts
|
|
75247
|
+
function binaryBytes(value) {
|
|
75248
|
+
if (value instanceof ArrayBuffer) {
|
|
75249
|
+
return new Uint8Array(value);
|
|
75250
|
+
}
|
|
75251
|
+
if (ArrayBuffer.isView(value)) {
|
|
75252
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
75253
|
+
}
|
|
75254
|
+
throw new Error("Content chunk must be a binary WebSocket frame");
|
|
75255
|
+
}
|
|
75256
|
+
function encodeContentChunkFrame(frame) {
|
|
75257
|
+
if (!isIdentifier(frame.requestId)) {
|
|
75258
|
+
throw new Error("Content chunk request identifier is invalid");
|
|
75259
|
+
}
|
|
75260
|
+
if (!Number.isSafeInteger(frame.sequence) || frame.sequence < 0 || frame.sequence > 4294967295) {
|
|
75261
|
+
throw new Error("Content chunk sequence is invalid");
|
|
75262
|
+
}
|
|
75263
|
+
if (frame.bytes.byteLength < 1 || frame.bytes.byteLength > CONTENT_CHUNK_MAX_BYTES) {
|
|
75264
|
+
throw new Error("Content chunk size is invalid");
|
|
75265
|
+
}
|
|
75266
|
+
const requestId = new TextEncoder().encode(frame.requestId);
|
|
75267
|
+
if (requestId.byteLength > 255) {
|
|
75268
|
+
throw new Error("Content chunk request identifier is too long");
|
|
75269
|
+
}
|
|
75270
|
+
const encoded = new Uint8Array(CONTENT_CHUNK_HEADER_BYTES + requestId.byteLength + frame.bytes.byteLength);
|
|
75271
|
+
encoded.set(CONTENT_CHUNK_MAGIC, 0);
|
|
75272
|
+
encoded[CONTENT_CHUNK_MAGIC.byteLength] = requestId.byteLength;
|
|
75273
|
+
new DataView(encoded.buffer).setUint32(CONTENT_CHUNK_MAGIC.byteLength + 1, frame.sequence);
|
|
75274
|
+
encoded.set(requestId, CONTENT_CHUNK_HEADER_BYTES);
|
|
75275
|
+
encoded.set(frame.bytes, CONTENT_CHUNK_HEADER_BYTES + requestId.byteLength);
|
|
75276
|
+
return encoded;
|
|
75277
|
+
}
|
|
75278
|
+
function decodeContentChunkFrame(value) {
|
|
75279
|
+
const encoded = binaryBytes(value);
|
|
75280
|
+
if (encoded.byteLength <= CONTENT_CHUNK_HEADER_BYTES || !CONTENT_CHUNK_MAGIC.every((byte, index2) => encoded[index2] === byte)) {
|
|
75281
|
+
throw new Error("Content chunk frame header is invalid");
|
|
75282
|
+
}
|
|
75283
|
+
const requestIdLength = encoded[CONTENT_CHUNK_MAGIC.byteLength] ?? 0;
|
|
75284
|
+
const payloadOffset = CONTENT_CHUNK_HEADER_BYTES + requestIdLength;
|
|
75285
|
+
if (requestIdLength < 1 || payloadOffset >= encoded.byteLength) {
|
|
75286
|
+
throw new Error("Content chunk frame length is invalid");
|
|
75287
|
+
}
|
|
75288
|
+
const requestId = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
|
|
75289
|
+
encoded.subarray(CONTENT_CHUNK_HEADER_BYTES, payloadOffset)
|
|
75290
|
+
);
|
|
75291
|
+
const bytes = encoded.slice(payloadOffset);
|
|
75292
|
+
const sequence = new DataView(encoded.buffer, encoded.byteOffset, encoded.byteLength).getUint32(
|
|
75293
|
+
CONTENT_CHUNK_MAGIC.byteLength + 1
|
|
75294
|
+
);
|
|
75295
|
+
if (!isIdentifier(requestId) || bytes.byteLength > CONTENT_CHUNK_MAX_BYTES) {
|
|
75296
|
+
throw new Error("Content chunk frame is invalid");
|
|
75297
|
+
}
|
|
75298
|
+
return { bytes, requestId, sequence };
|
|
75299
|
+
}
|
|
75300
|
+
var FILE_READ_KIND, FILE_BEGIN_KIND, FILE_END_KIND, FILE_FAILED_KIND, CONTENT_WRITE_KIND, CONTENT_COMMIT_KIND, CONTENT_READY_KIND, CONTENT_AVAILABLE_KIND, CONTENT_CHUNK_MAX_BYTES, CONTENT_WRITE_MAX_BYTES, PROMPT_IMAGE_MAX_BYTES, CONTENT_CHUNK_MAGIC, CONTENT_CHUNK_HEADER_BYTES, fileReadCommandSchema, fileBeginEventSchema, contentWriteCommandSchema, contentCommitCommandSchema, contentReadyEventSchema, contentAvailableEventSchema, fileEndEventSchema, fileFailedEventSchema, decodeFileReadCommand, encodeFileReadCommand, decodeFileBeginEvent, encodeFileBeginEvent, decodeFileEndEvent, encodeFileEndEvent, decodeFileFailedEvent, encodeFileFailedEvent, decodeContentWriteCommand, encodeContentWriteCommand, decodeContentCommitCommand, encodeContentCommitCommand, decodeContentReadyEvent, encodeContentReadyEvent, decodeContentAvailableEvent, encodeContentAvailableEvent;
|
|
75301
|
+
var init_files = __esm({
|
|
75302
|
+
"../mobius-sdk/src/protocol/session/files/index.ts"() {
|
|
75303
|
+
"use strict";
|
|
75304
|
+
init_zod();
|
|
75305
|
+
init_identifier();
|
|
75306
|
+
init_message_codec();
|
|
75307
|
+
FILE_READ_KIND = "file.read";
|
|
75308
|
+
FILE_BEGIN_KIND = "file.begin";
|
|
75309
|
+
FILE_END_KIND = "file.end";
|
|
75310
|
+
FILE_FAILED_KIND = "file.failed";
|
|
75311
|
+
CONTENT_WRITE_KIND = "content.write";
|
|
75312
|
+
CONTENT_COMMIT_KIND = "content.commit";
|
|
75313
|
+
CONTENT_READY_KIND = "content.ready";
|
|
75314
|
+
CONTENT_AVAILABLE_KIND = "content.available";
|
|
75315
|
+
CONTENT_CHUNK_MAX_BYTES = 192 * 1024;
|
|
75316
|
+
CONTENT_WRITE_MAX_BYTES = 32 * 1024 * 1024;
|
|
75317
|
+
PROMPT_IMAGE_MAX_BYTES = 5e6;
|
|
75318
|
+
CONTENT_CHUNK_MAGIC = new Uint8Array([77, 66, 67, 49]);
|
|
75319
|
+
CONTENT_CHUNK_HEADER_BYTES = CONTENT_CHUNK_MAGIC.byteLength + 1 + 4;
|
|
75320
|
+
fileReadCommandSchema = external_exports.object({
|
|
75321
|
+
kind: external_exports.literal(FILE_READ_KIND),
|
|
75322
|
+
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
75323
|
+
requestId: identifierStringSchema,
|
|
75324
|
+
sessionId: identifierStringSchema,
|
|
75325
|
+
path: external_exports.string().min(1).max(4096)
|
|
75326
|
+
}).readonly();
|
|
75327
|
+
fileBeginEventSchema = external_exports.object({
|
|
75328
|
+
byteLength: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
75329
|
+
kind: external_exports.literal(FILE_BEGIN_KIND),
|
|
75330
|
+
mediaType: external_exports.string().min(1).max(255),
|
|
75331
|
+
modifiedAt: external_exports.iso.datetime({ offset: true }),
|
|
75332
|
+
name: external_exports.string().min(1).max(500),
|
|
75333
|
+
requestId: identifierStringSchema,
|
|
75334
|
+
sessionId: identifierStringSchema
|
|
75335
|
+
}).readonly();
|
|
75336
|
+
contentWriteCommandSchema = external_exports.object({
|
|
75337
|
+
byteLength: external_exports.number().int().positive().max(CONTENT_WRITE_MAX_BYTES),
|
|
75338
|
+
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
75339
|
+
contentKind: external_exports.enum(["image", "resource"]),
|
|
75340
|
+
kind: external_exports.literal(CONTENT_WRITE_KIND),
|
|
75341
|
+
mediaType: external_exports.string().min(1).max(255),
|
|
75342
|
+
name: external_exports.string().min(1).max(500),
|
|
75343
|
+
requestId: identifierStringSchema,
|
|
75344
|
+
sessionId: identifierStringSchema
|
|
75345
|
+
}).readonly();
|
|
75346
|
+
contentCommitCommandSchema = external_exports.object({
|
|
75347
|
+
kind: external_exports.literal(CONTENT_COMMIT_KIND),
|
|
75348
|
+
requestId: identifierStringSchema,
|
|
75349
|
+
sessionId: identifierStringSchema
|
|
75350
|
+
}).readonly();
|
|
75351
|
+
contentReadyEventSchema = external_exports.object({
|
|
75352
|
+
kind: external_exports.literal(CONTENT_READY_KIND),
|
|
75353
|
+
requestId: identifierStringSchema,
|
|
75354
|
+
sessionId: identifierStringSchema
|
|
75355
|
+
}).readonly();
|
|
75356
|
+
contentAvailableEventSchema = external_exports.object({
|
|
75357
|
+
byteLength: external_exports.number().int().positive().max(CONTENT_WRITE_MAX_BYTES),
|
|
75358
|
+
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
75359
|
+
kind: external_exports.literal(CONTENT_AVAILABLE_KIND),
|
|
75360
|
+
requestId: identifierStringSchema,
|
|
75361
|
+
sessionId: identifierStringSchema
|
|
75362
|
+
}).readonly();
|
|
75363
|
+
fileEndEventSchema = external_exports.object({
|
|
75364
|
+
kind: external_exports.literal(FILE_END_KIND),
|
|
75365
|
+
requestId: identifierStringSchema,
|
|
75366
|
+
sessionId: identifierStringSchema
|
|
75367
|
+
}).readonly();
|
|
75368
|
+
fileFailedEventSchema = external_exports.object({
|
|
75369
|
+
code: identifierStringSchema,
|
|
75370
|
+
kind: external_exports.literal(FILE_FAILED_KIND),
|
|
75371
|
+
message: external_exports.string().min(1).max(500),
|
|
75372
|
+
requestId: identifierStringSchema,
|
|
75373
|
+
sessionId: identifierStringSchema
|
|
75374
|
+
}).readonly();
|
|
75375
|
+
decodeFileReadCommand = (encoded) => decodeZodMessage(encoded, fileReadCommandSchema);
|
|
75376
|
+
encodeFileReadCommand = (message) => encodeZodMessage(message, fileReadCommandSchema);
|
|
75377
|
+
decodeFileBeginEvent = (encoded) => decodeZodMessage(encoded, fileBeginEventSchema);
|
|
75378
|
+
encodeFileBeginEvent = (message) => encodeZodMessage(message, fileBeginEventSchema);
|
|
75379
|
+
decodeFileEndEvent = (encoded) => decodeZodMessage(encoded, fileEndEventSchema);
|
|
75380
|
+
encodeFileEndEvent = (message) => encodeZodMessage(message, fileEndEventSchema);
|
|
75381
|
+
decodeFileFailedEvent = (encoded) => decodeZodMessage(encoded, fileFailedEventSchema);
|
|
75382
|
+
encodeFileFailedEvent = (message) => encodeZodMessage(message, fileFailedEventSchema);
|
|
75383
|
+
decodeContentWriteCommand = (encoded) => decodeZodMessage(encoded, contentWriteCommandSchema);
|
|
75384
|
+
encodeContentWriteCommand = (message) => encodeZodMessage(message, contentWriteCommandSchema);
|
|
75385
|
+
decodeContentCommitCommand = (encoded) => decodeZodMessage(encoded, contentCommitCommandSchema);
|
|
75386
|
+
encodeContentCommitCommand = (message) => encodeZodMessage(message, contentCommitCommandSchema);
|
|
75387
|
+
decodeContentReadyEvent = (encoded) => decodeZodMessage(encoded, contentReadyEventSchema);
|
|
75388
|
+
encodeContentReadyEvent = (message) => encodeZodMessage(message, contentReadyEventSchema);
|
|
75389
|
+
decodeContentAvailableEvent = (encoded) => decodeZodMessage(encoded, contentAvailableEventSchema);
|
|
75390
|
+
encodeContentAvailableEvent = (message) => encodeZodMessage(message, contentAvailableEventSchema);
|
|
75391
|
+
}
|
|
75392
|
+
});
|
|
75393
|
+
|
|
75394
|
+
// ../mobius-sdk/src/protocol/session/interactions/model.ts
|
|
75395
|
+
var timestampSchema, permissionRequestSchema, elicitationRequestSchema, interactionRequestSchema, interactionResponseSchema, interactionStateSchema, interactionSchema;
|
|
75396
|
+
var init_model = __esm({
|
|
75397
|
+
"../mobius-sdk/src/protocol/session/interactions/model.ts"() {
|
|
75398
|
+
"use strict";
|
|
75399
|
+
init_zod();
|
|
75400
|
+
init_identifier();
|
|
75401
|
+
init_interactions();
|
|
75402
|
+
timestampSchema = external_exports.string().datetime({ offset: true });
|
|
75403
|
+
permissionRequestSchema = external_exports.object({
|
|
75404
|
+
kind: external_exports.literal("permission"),
|
|
75405
|
+
options: external_exports.array(permissionOptionSchema).min(1).max(20).readonly(),
|
|
75406
|
+
title: external_exports.string().min(1).max(500),
|
|
75407
|
+
toolCallId: external_exports.string().min(1).max(255),
|
|
75408
|
+
toolKind: external_exports.string().max(64)
|
|
75409
|
+
}).readonly();
|
|
75410
|
+
elicitationRequestSchema = external_exports.object({
|
|
75411
|
+
elicitationId: external_exports.string().max(255),
|
|
75412
|
+
fields: external_exports.array(elicitationFieldSchema).max(100).readonly(),
|
|
75413
|
+
kind: external_exports.literal("elicitation"),
|
|
75414
|
+
message: external_exports.string().min(1).max(2e3),
|
|
75415
|
+
mode: external_exports.enum(["form", "url"]),
|
|
75416
|
+
url: external_exports.string().max(4096)
|
|
75417
|
+
}).readonly();
|
|
75418
|
+
interactionRequestSchema = external_exports.discriminatedUnion("kind", [permissionRequestSchema, elicitationRequestSchema]);
|
|
75419
|
+
interactionResponseSchema = external_exports.object({
|
|
75420
|
+
content: external_exports.string().max(1e5),
|
|
75421
|
+
kind: external_exports.enum(["permission", "elicitation"])
|
|
75422
|
+
}).readonly();
|
|
75423
|
+
interactionStateSchema = external_exports.discriminatedUnion("kind", [
|
|
75424
|
+
external_exports.object({ kind: external_exports.literal("pending") }).readonly(),
|
|
75425
|
+
external_exports.object({
|
|
75426
|
+
kind: external_exports.literal("responded"),
|
|
75427
|
+
respondedAt: timestampSchema,
|
|
75428
|
+
responderId: identifierSchema,
|
|
75429
|
+
response: interactionResponseSchema
|
|
75430
|
+
}).readonly(),
|
|
75431
|
+
external_exports.object({
|
|
75432
|
+
kind: external_exports.literal("resolved"),
|
|
75433
|
+
resolution: external_exports.discriminatedUnion("kind", [
|
|
75434
|
+
external_exports.object({ kind: external_exports.literal("without_response") }).readonly(),
|
|
75435
|
+
external_exports.object({
|
|
75436
|
+
kind: external_exports.literal("response_applied"),
|
|
75437
|
+
respondedAt: timestampSchema,
|
|
75438
|
+
responderId: identifierSchema,
|
|
75439
|
+
response: interactionResponseSchema
|
|
75440
|
+
}).readonly()
|
|
75441
|
+
]),
|
|
75442
|
+
resolvedAt: timestampSchema
|
|
75443
|
+
}).readonly(),
|
|
75444
|
+
external_exports.object({ expiredAt: timestampSchema, kind: external_exports.literal("expired") }).readonly(),
|
|
75445
|
+
external_exports.object({
|
|
75446
|
+
cancelledAt: timestampSchema,
|
|
75447
|
+
kind: external_exports.literal("cancelled")
|
|
75448
|
+
}).readonly()
|
|
75449
|
+
]);
|
|
75450
|
+
interactionSchema = external_exports.object({
|
|
75451
|
+
attemptId: identifierSchema,
|
|
75452
|
+
interactionId: identifierSchema,
|
|
75453
|
+
request: interactionRequestSchema,
|
|
75454
|
+
sessionId: identifierSchema,
|
|
75455
|
+
state: interactionStateSchema,
|
|
75456
|
+
turnId: identifierSchema
|
|
75457
|
+
}).readonly();
|
|
75458
|
+
}
|
|
75459
|
+
});
|
|
75460
|
+
|
|
75461
|
+
// ../mobius-sdk/src/protocol/session/lifecycle/index.ts
|
|
75462
|
+
var SESSION_PREPARE_KIND, SESSION_READY_KIND, SESSION_LIST_KIND, SESSION_LISTED_KIND, SESSION_QUERY_KIND, SESSION_QUERIED_KIND, SESSION_RESTORE_KIND, SESSION_RESTORED_KIND, SESSION_CLOSE_KIND, SESSION_CLOSED_KIND, SESSION_CLOSE_NOTICE_KIND, SESSION_CLOSED_ERROR_CODE, SESSION_STATUS_CHANGED_KIND, SESSION_COMMANDS_UPDATED_KIND, SESSION_INFO_UPDATED_KIND, SESSION_OPERATION_FAILED_KIND, sessionStatusChangedEventSchema, sessionMetadataSchema, sessionListCommandSchema, sessionsListedEventSchema, sessionQueryCommandSchema, sessionsQueriedEventSchema, sessionRestoreCommandSchema, sessionCloseCommandSchema, sessionPrepareCommandSchema, runtimeTimingsSchema, sessionReadyEventSchema, sessionRestoredEventSchema, sessionClosedEventSchema, sessionCloseNoticeEventSchema, sessionCommandsUpdatedEventSchema, sessionInfoUpdatedEventSchema, sessionOperationFailedEventSchema, decodeSessionListCommand, encodeSessionListCommand, decodeSessionsListedEvent, encodeSessionsListedEvent, decodeSessionQueryCommand, encodeSessionQueryCommand, decodeSessionsQueriedEvent, encodeSessionsQueriedEvent, decodeSessionRestoreCommand, encodeSessionRestoreCommand, decodeSessionRestoredEvent, encodeSessionRestoredEvent, decodeSessionCloseCommand, encodeSessionCloseCommand, decodeSessionClosedEvent, encodeSessionClosedEvent, decodeSessionCloseNoticeEvent, encodeSessionCloseNoticeEvent, decodeSessionStatusChangedEvent, encodeSessionStatusChangedEvent, decodeSessionPrepareCommand, encodeSessionPrepareCommand, decodeSessionReadyEvent, encodeSessionReadyEvent, decodeSessionInfoUpdatedEvent, encodeSessionInfoUpdatedEvent, decodeSessionOperationFailedEvent, encodeSessionOperationFailedEvent;
|
|
75463
|
+
var init_lifecycle = __esm({
|
|
75464
|
+
"../mobius-sdk/src/protocol/session/lifecycle/index.ts"() {
|
|
75465
|
+
"use strict";
|
|
75466
|
+
init_zod();
|
|
75467
|
+
init_directory();
|
|
75468
|
+
init_identifier();
|
|
75469
|
+
init_message_codec();
|
|
75470
|
+
init_configuration();
|
|
75471
|
+
init_shared2();
|
|
75472
|
+
SESSION_PREPARE_KIND = "session.prepare";
|
|
75473
|
+
SESSION_READY_KIND = "session.ready";
|
|
75474
|
+
SESSION_LIST_KIND = "session.list";
|
|
75475
|
+
SESSION_LISTED_KIND = "session.listed";
|
|
75476
|
+
SESSION_QUERY_KIND = "session.query";
|
|
75477
|
+
SESSION_QUERIED_KIND = "session.queried";
|
|
75478
|
+
SESSION_RESTORE_KIND = "session.restore";
|
|
75479
|
+
SESSION_RESTORED_KIND = "session.restored";
|
|
75480
|
+
SESSION_CLOSE_KIND = "session.close";
|
|
75481
|
+
SESSION_CLOSED_KIND = "session.closed";
|
|
75482
|
+
SESSION_CLOSE_NOTICE_KIND = "session.close.notice";
|
|
75483
|
+
SESSION_CLOSED_ERROR_CODE = "session_closed";
|
|
75484
|
+
SESSION_STATUS_CHANGED_KIND = "session.status.changed";
|
|
75485
|
+
SESSION_COMMANDS_UPDATED_KIND = "session.commands.updated";
|
|
75486
|
+
SESSION_INFO_UPDATED_KIND = "session.info.updated";
|
|
75487
|
+
SESSION_OPERATION_FAILED_KIND = "session.operation.failed";
|
|
75488
|
+
sessionStatusChangedEventSchema = external_exports.object({
|
|
75489
|
+
kind: external_exports.literal(SESSION_STATUS_CHANGED_KIND),
|
|
75490
|
+
sessionId: identifierStringSchema,
|
|
75491
|
+
status: sessionStatusSchema
|
|
75492
|
+
}).readonly();
|
|
75493
|
+
sessionMetadataSchema = external_exports.object({
|
|
75494
|
+
additionalDirectories: external_exports.array(workspaceEntrySchema).max(16).readonly(),
|
|
75495
|
+
agentId: identifierStringSchema,
|
|
75496
|
+
directoryId: DIRECTORY_IDENTIFIER,
|
|
75497
|
+
directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
|
|
75498
|
+
prompted: external_exports.boolean(),
|
|
75499
|
+
sessionId: identifierStringSchema,
|
|
75500
|
+
status: sessionStatusSchema.default({ kind: "idle" }),
|
|
75501
|
+
title: external_exports.string().max(500),
|
|
75502
|
+
updatedAt: external_exports.iso.datetime({ offset: true })
|
|
75503
|
+
}).readonly();
|
|
75504
|
+
sessionListCommandSchema = external_exports.object({
|
|
75505
|
+
kind: external_exports.literal(SESSION_LIST_KIND),
|
|
75506
|
+
limit: external_exports.number().int().positive().max(500),
|
|
75507
|
+
requestId: identifierStringSchema
|
|
75508
|
+
}).readonly();
|
|
75509
|
+
sessionsListedEventSchema = external_exports.object({
|
|
75510
|
+
entries: external_exports.array(sessionMetadataSchema).max(500).readonly(),
|
|
74931
75511
|
kind: external_exports.literal(SESSION_LISTED_KIND),
|
|
74932
75512
|
requestId: identifierStringSchema
|
|
74933
75513
|
}).readonly();
|
|
@@ -75137,782 +75717,206 @@ function readHistoryPolicy(value) {
|
|
|
75137
75717
|
function decodeSessionCancelCommand(encoded) {
|
|
75138
75718
|
const value = parseJson(encoded);
|
|
75139
75719
|
assertKind(value, SESSION_CANCEL_KIND);
|
|
75140
|
-
return {
|
|
75141
|
-
commandId: readIdentifier(value, "commandId"),
|
|
75142
|
-
kind: SESSION_CANCEL_KIND,
|
|
75143
|
-
sessionId: readIdentifier(value, "sessionId")
|
|
75144
|
-
};
|
|
75145
|
-
}
|
|
75146
|
-
function decodeSessionPromptDispositionCommand(encoded) {
|
|
75147
|
-
const value = parseJson(encoded);
|
|
75148
|
-
assertKind(value, SESSION_PROMPT_DISPOSITION_KIND);
|
|
75149
|
-
if (readPromptDisposition(value) !== SessionPromptDisposition.Steer) {
|
|
75150
|
-
throw new ProtocolMessageError("Only queued prompts can be steered");
|
|
75151
|
-
}
|
|
75152
|
-
return {
|
|
75153
|
-
commandId: readIdentifier(value, "commandId"),
|
|
75154
|
-
disposition: SessionPromptDisposition.Steer,
|
|
75155
|
-
kind: SESSION_PROMPT_DISPOSITION_KIND,
|
|
75156
|
-
sessionId: readIdentifier(value, "sessionId")
|
|
75157
|
-
};
|
|
75158
|
-
}
|
|
75159
|
-
function encodeSessionPromptCommand(message) {
|
|
75160
|
-
const command = decodeSessionPromptCommand(JSON.stringify(message));
|
|
75161
|
-
return JSON.stringify({
|
|
75162
|
-
...command,
|
|
75163
|
-
// Keep text prompts compatible with the previous Runtime release while
|
|
75164
|
-
// attachments move to the content-key protocol. Older Runtimes ignore
|
|
75165
|
-
// `attachments` and require both legacy arrays to be present.
|
|
75166
|
-
images: [],
|
|
75167
|
-
resources: []
|
|
75168
|
-
});
|
|
75169
|
-
}
|
|
75170
|
-
function encodeSessionCancelCommand(message) {
|
|
75171
|
-
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
75172
|
-
}
|
|
75173
|
-
function encodeSessionPromptDispositionCommand(message) {
|
|
75174
|
-
return JSON.stringify(decodeSessionPromptDispositionCommand(JSON.stringify(message)));
|
|
75175
|
-
}
|
|
75176
|
-
var SESSION_PROMPT_KIND, SESSION_PROMPT_DISPOSITION_KIND, SESSION_CANCEL_KIND, SESSION_CANCEL_BEFORE_START_KIND, SessionPromptDisposition, SessionHistoryPolicy, MAX_PROMPT_LENGTH, MAX_PROMPT_ATTACHMENT_BYTES, encodeSessionCancelBeforeStartCommand, promptAttachmentSchema, decodePromptAttachmentsValue;
|
|
75177
|
-
var init_commands = __esm({
|
|
75178
|
-
"../mobius-sdk/src/protocol/session/prompt/commands.ts"() {
|
|
75179
|
-
"use strict";
|
|
75180
|
-
init_zod();
|
|
75181
|
-
init_identifier();
|
|
75182
|
-
init_message_codec();
|
|
75183
|
-
init_configuration();
|
|
75184
|
-
SESSION_PROMPT_KIND = "session.prompt";
|
|
75185
|
-
SESSION_PROMPT_DISPOSITION_KIND = "session.prompt.disposition";
|
|
75186
|
-
SESSION_CANCEL_KIND = "session.cancel";
|
|
75187
|
-
SESSION_CANCEL_BEFORE_START_KIND = "session.cancel-before-start";
|
|
75188
|
-
SessionPromptDisposition = Object.freeze({
|
|
75189
|
-
Queue: "queue",
|
|
75190
|
-
Reject: "reject",
|
|
75191
|
-
Steer: "steer"
|
|
75192
|
-
});
|
|
75193
|
-
SessionHistoryPolicy = Object.freeze({
|
|
75194
|
-
Eager: "eager",
|
|
75195
|
-
ExecutionOnly: "execution-only"
|
|
75196
|
-
});
|
|
75197
|
-
MAX_PROMPT_LENGTH = 1e5;
|
|
75198
|
-
MAX_PROMPT_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
75199
|
-
encodeSessionCancelBeforeStartCommand = (message) => JSON.stringify(decodeSessionCancelBeforeStartCommand(JSON.stringify(message)));
|
|
75200
|
-
promptAttachmentSchema = external_exports.object({
|
|
75201
|
-
byteLength: external_exports.number().int().positive().max(MAX_PROMPT_ATTACHMENT_BYTES),
|
|
75202
|
-
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
75203
|
-
kind: external_exports.enum(["image", "resource"]),
|
|
75204
|
-
mimeType: external_exports.string().min(1).max(255),
|
|
75205
|
-
name: external_exports.string().min(1).max(500),
|
|
75206
|
-
uri: external_exports.string().min(1).max(4096)
|
|
75207
|
-
}).readonly();
|
|
75208
|
-
decodePromptAttachmentsValue = (value) => decodeZodValue(value, external_exports.array(promptAttachmentSchema).max(16).readonly());
|
|
75209
|
-
}
|
|
75210
|
-
});
|
|
75211
|
-
|
|
75212
|
-
// ../mobius-sdk/src/protocol/session/native/index.ts
|
|
75213
|
-
function decode3(schema, encoded) {
|
|
75214
|
-
try {
|
|
75215
|
-
const value = JSON.parse(encoded);
|
|
75216
|
-
return schema.parse(value);
|
|
75217
|
-
} catch (cause) {
|
|
75218
|
-
throw new ProtocolMessageError("Invalid native session message", { cause });
|
|
75219
|
-
}
|
|
75220
|
-
}
|
|
75221
|
-
var NATIVE_SESSION_REQUEST_KIND, NATIVE_SESSION_RESULT_KIND, NATIVE_SESSION_CANCEL_KIND, envelope, activeTurnSnapshotSchema, identity, nativeSessionRequestSchema, nativeSessionCommandSchema, nativeSessionEntrySchema, resultEnvelope, nativeSessionResultSchema, nativeSessionCancelSchema, decodeNativeSessionCommand, encodeNativeSessionCommand, decodeNativeSessionResult, encodeNativeSessionResult, decodeNativeSessionCancel, encodeNativeSessionCancel;
|
|
75222
|
-
var init_native = __esm({
|
|
75223
|
-
"../mobius-sdk/src/protocol/session/native/index.ts"() {
|
|
75224
|
-
"use strict";
|
|
75225
|
-
init_zod();
|
|
75226
|
-
init_directory();
|
|
75227
|
-
init_identifier();
|
|
75228
|
-
init_message_codec();
|
|
75229
|
-
init_interactions();
|
|
75230
|
-
init_lifecycle();
|
|
75231
|
-
init_commands();
|
|
75232
|
-
init_shared2();
|
|
75233
|
-
NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
75234
|
-
NATIVE_SESSION_RESULT_KIND = "native.session.result";
|
|
75235
|
-
NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
|
|
75236
|
-
envelope = {
|
|
75237
|
-
requestId: identifierStringSchema,
|
|
75238
|
-
sessionId: identifierStringSchema
|
|
75239
|
-
};
|
|
75240
|
-
activeTurnSnapshotSchema = external_exports.object({
|
|
75241
|
-
commandId: identifierStringSchema,
|
|
75242
|
-
epoch: identifierStringSchema,
|
|
75243
|
-
interaction: external_exports.discriminatedUnion("kind", [sessionPermissionRequestedEventSchema, sessionElicitationRequestedEventSchema]).nullable(),
|
|
75244
|
-
sequence: external_exports.number().int().nonnegative(),
|
|
75245
|
-
state: external_exports.literal("running")
|
|
75246
|
-
}).readonly();
|
|
75247
|
-
identity = {
|
|
75248
|
-
...envelope,
|
|
75249
|
-
kind: external_exports.literal(NATIVE_SESSION_REQUEST_KIND),
|
|
75250
|
-
additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
|
|
75251
|
-
agentId: identifierStringSchema,
|
|
75252
|
-
bindingId: identifierStringSchema,
|
|
75253
|
-
directoryId: DIRECTORY_IDENTIFIER
|
|
75254
|
-
};
|
|
75255
|
-
nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
75256
|
-
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
75257
|
-
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
75258
|
-
external_exports.object({
|
|
75259
|
-
...identity,
|
|
75260
|
-
action: external_exports.literal("list"),
|
|
75261
|
-
cursor: identifierStringSchema.nullable()
|
|
75262
|
-
}).readonly(),
|
|
75263
|
-
external_exports.object({
|
|
75264
|
-
...identity,
|
|
75265
|
-
action: external_exports.enum(["import", "fork"]),
|
|
75266
|
-
entryId: identifierStringSchema,
|
|
75267
|
-
targetSessionId: identifierStringSchema
|
|
75268
|
-
}).readonly()
|
|
75269
|
-
]);
|
|
75270
|
-
nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
75271
|
-
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
75272
|
-
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
75273
|
-
external_exports.object({
|
|
75274
|
-
...identity,
|
|
75275
|
-
action: external_exports.literal("list"),
|
|
75276
|
-
cursor: identifierStringSchema.nullable()
|
|
75277
|
-
}).readonly(),
|
|
75278
|
-
external_exports.object({
|
|
75279
|
-
...identity,
|
|
75280
|
-
action: external_exports.enum(["import", "fork"]),
|
|
75281
|
-
entryId: identifierStringSchema,
|
|
75282
|
-
targetSessionId: identifierStringSchema
|
|
75283
|
-
}).readonly()
|
|
75284
|
-
]);
|
|
75285
|
-
nativeSessionEntrySchema = external_exports.object({
|
|
75286
|
-
entryId: identifierStringSchema,
|
|
75287
|
-
mobiusSessionIds: external_exports.array(identifierStringSchema).max(500).readonly(),
|
|
75288
|
-
nativeSessionId: identifierStringSchema,
|
|
75289
|
-
title: external_exports.string().max(500),
|
|
75290
|
-
directoryId: DIRECTORY_IDENTIFIER,
|
|
75291
|
-
directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
|
|
75292
|
-
updatedAt: external_exports.iso.datetime({ offset: true }).nullable(),
|
|
75293
|
-
additionalDirectories: external_exports.array(external_exports.object({ directoryId: DIRECTORY_IDENTIFIER, name: external_exports.string().min(1).max(255) }).readonly()).max(16).readonly()
|
|
75294
|
-
}).readonly();
|
|
75295
|
-
resultEnvelope = {
|
|
75296
|
-
...envelope,
|
|
75297
|
-
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
75298
|
-
};
|
|
75299
|
-
nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
75300
|
-
external_exports.object({
|
|
75301
|
-
...resultEnvelope,
|
|
75302
|
-
action: external_exports.literal("active-turn"),
|
|
75303
|
-
targetSessionId: identifierStringSchema,
|
|
75304
|
-
queued: external_exports.array(
|
|
75305
|
-
external_exports.object({
|
|
75306
|
-
commandId: identifierStringSchema,
|
|
75307
|
-
prompt: external_exports.string().max(1e5),
|
|
75308
|
-
attachments: external_exports.array(promptAttachmentSchema).max(16).readonly()
|
|
75309
|
-
}).readonly()
|
|
75310
|
-
).readonly(),
|
|
75311
|
-
turn: activeTurnSnapshotSchema.nullable()
|
|
75312
|
-
}).readonly(),
|
|
75313
|
-
external_exports.object({
|
|
75314
|
-
...resultEnvelope,
|
|
75315
|
-
action: external_exports.literal("find"),
|
|
75316
|
-
entry: nativeSessionEntrySchema
|
|
75317
|
-
}).readonly(),
|
|
75318
|
-
external_exports.object({
|
|
75319
|
-
...resultEnvelope,
|
|
75320
|
-
action: external_exports.literal("list"),
|
|
75321
|
-
capabilities: sessionCapabilitiesSchema,
|
|
75322
|
-
entries: external_exports.array(nativeSessionEntrySchema).max(500).readonly(),
|
|
75323
|
-
nextCursor: identifierStringSchema.nullable()
|
|
75324
|
-
}).readonly(),
|
|
75325
|
-
external_exports.object({
|
|
75326
|
-
...resultEnvelope,
|
|
75327
|
-
action: external_exports.enum(["import", "fork"]),
|
|
75328
|
-
targetSessionId: identifierStringSchema,
|
|
75329
|
-
ready: sessionReadyEventSchema,
|
|
75330
|
-
title: external_exports.string().max(500)
|
|
75331
|
-
}).readonly()
|
|
75332
|
-
]);
|
|
75333
|
-
nativeSessionCancelSchema = external_exports.object({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
|
|
75334
|
-
decodeNativeSessionCommand = (encoded) => decode3(nativeSessionCommandSchema, encoded);
|
|
75335
|
-
encodeNativeSessionCommand = (value) => JSON.stringify(nativeSessionCommandSchema.parse(value));
|
|
75336
|
-
decodeNativeSessionResult = (encoded) => decode3(nativeSessionResultSchema, encoded);
|
|
75337
|
-
encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
|
|
75338
|
-
decodeNativeSessionCancel = (encoded) => decode3(nativeSessionCancelSchema, encoded);
|
|
75339
|
-
encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
|
|
75340
|
-
}
|
|
75341
|
-
});
|
|
75342
|
-
|
|
75343
|
-
// ../mobius-sdk/src/protocol/session/observability/event-log.ts
|
|
75344
|
-
function isRecord4(value) {
|
|
75345
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
75346
|
-
}
|
|
75347
|
-
function hasUnknownDiscriminator(value, key, known) {
|
|
75348
|
-
if (!isRecord4(value)) {
|
|
75349
|
-
return false;
|
|
75350
|
-
}
|
|
75351
|
-
const variant = value[key];
|
|
75352
|
-
return typeof variant === "string" && !known.has(variant);
|
|
75353
|
-
}
|
|
75354
|
-
function containsUnknownContentBlock(value) {
|
|
75355
|
-
return hasUnknownDiscriminator(value, "type", knownContentBlockTypes);
|
|
75356
|
-
}
|
|
75357
|
-
function containsUnknownToolCallContent(value) {
|
|
75358
|
-
if (hasUnknownDiscriminator(value, "type", knownToolCallContentTypes)) {
|
|
75359
|
-
return true;
|
|
75360
|
-
}
|
|
75361
|
-
return isRecord4(value) && value["type"] === "content" && containsUnknownContentBlock(value["content"]);
|
|
75362
|
-
}
|
|
75363
|
-
function arrayContainsUnknown(value, predicate) {
|
|
75364
|
-
return Array.isArray(value) && value.some(predicate);
|
|
75365
|
-
}
|
|
75366
|
-
function containsUnknownAcpVariant(payload) {
|
|
75367
|
-
const update = payload["sessionUpdate"];
|
|
75368
|
-
if (typeof update !== "string") {
|
|
75369
|
-
return false;
|
|
75370
|
-
}
|
|
75371
|
-
if (!knownSessionUpdates.has(update)) {
|
|
75372
|
-
return true;
|
|
75373
|
-
}
|
|
75374
|
-
if (["user_message_chunk", "agent_message_chunk", "agent_thought_chunk", "compaction_summary_chunk"].includes(
|
|
75375
|
-
update
|
|
75376
|
-
)) {
|
|
75377
|
-
return containsUnknownContentBlock(payload["content"]);
|
|
75378
|
-
}
|
|
75379
|
-
if (update === "tool_call" || update === "tool_call_update") {
|
|
75380
|
-
return arrayContainsUnknown(payload["content"], containsUnknownToolCallContent);
|
|
75381
|
-
}
|
|
75382
|
-
if (update === "plan_update") {
|
|
75383
|
-
return hasUnknownDiscriminator(payload["plan"], "type", knownPlanTypes);
|
|
75384
|
-
}
|
|
75385
|
-
if (update === "config_option_update") {
|
|
75386
|
-
return arrayContainsUnknown(
|
|
75387
|
-
payload["configOptions"],
|
|
75388
|
-
(option) => hasUnknownDiscriminator(option, "type", knownConfigOptionTypes)
|
|
75389
|
-
);
|
|
75390
|
-
}
|
|
75391
|
-
if (update === "compaction_update") {
|
|
75392
|
-
return arrayContainsUnknown(payload["summary"], containsUnknownContentBlock);
|
|
75393
|
-
}
|
|
75394
|
-
return false;
|
|
75395
|
-
}
|
|
75396
|
-
function isKnownSessionEventVariant(value) {
|
|
75397
|
-
if (!isRecord4(value)) {
|
|
75398
|
-
return true;
|
|
75399
|
-
}
|
|
75400
|
-
const type = value["type"];
|
|
75401
|
-
if (typeof type !== "string") {
|
|
75402
|
-
return true;
|
|
75403
|
-
}
|
|
75404
|
-
if (type === "acp") {
|
|
75405
|
-
const payload = value["payload"];
|
|
75406
|
-
return !isRecord4(payload) || !containsUnknownAcpVariant(payload);
|
|
75407
|
-
}
|
|
75408
|
-
if (type === "lifecycle-metadata") {
|
|
75409
|
-
const payload = value["payload"];
|
|
75410
|
-
if (!isRecord4(payload)) {
|
|
75411
|
-
return true;
|
|
75412
|
-
}
|
|
75413
|
-
const kind = payload["kind"];
|
|
75414
|
-
if (typeof kind === "string" && !knownLifecycleKinds.has(kind)) {
|
|
75415
|
-
return false;
|
|
75416
|
-
}
|
|
75417
|
-
return kind !== "prompt.requested" || !arrayContainsUnknown(payload["content"], containsUnknownContentBlock);
|
|
75418
|
-
}
|
|
75419
|
-
return false;
|
|
75420
|
-
}
|
|
75421
|
-
function filterKnownSessionEventVariants(events) {
|
|
75422
|
-
return Array.isArray(events) ? events.filter(isKnownSessionEventVariant) : events;
|
|
75423
|
-
}
|
|
75424
|
-
function inputValue(value) {
|
|
75425
|
-
if (typeof value !== "string") {
|
|
75426
|
-
return value;
|
|
75427
|
-
}
|
|
75428
|
-
try {
|
|
75429
|
-
return JSON.parse(value);
|
|
75430
|
-
} catch (cause) {
|
|
75431
|
-
throw new ProtocolMessageError("Session Event Log V2 message is not valid JSON", { cause });
|
|
75432
|
-
}
|
|
75433
|
-
}
|
|
75434
|
-
function decode4(value, schema) {
|
|
75435
|
-
const result = schema.safeParse(inputValue(value));
|
|
75436
|
-
if (!result.success) {
|
|
75437
|
-
throw new ProtocolMessageError("Session Event Log V2 message does not match its schema", {
|
|
75438
|
-
cause: result.error
|
|
75439
|
-
});
|
|
75440
|
-
}
|
|
75441
|
-
return result.data;
|
|
75442
|
-
}
|
|
75443
|
-
function encode3(value, schema) {
|
|
75444
|
-
return JSON.stringify(decode4(value, schema));
|
|
75445
|
-
}
|
|
75446
|
-
function sanitizeKnownNativeSessionEvents(value) {
|
|
75447
|
-
const input2 = inputValue(value);
|
|
75448
|
-
if (!isRecord4(input2)) {
|
|
75449
|
-
return input2;
|
|
75450
|
-
}
|
|
75451
|
-
const page = input2["events"];
|
|
75452
|
-
const queuedPromptRequests = input2["queuedPromptRequests"];
|
|
75453
|
-
return {
|
|
75454
|
-
...input2,
|
|
75455
|
-
events: isRecord4(page) ? { ...page, events: filterKnownSessionEventVariants(page["events"]) } : page,
|
|
75456
|
-
queuedPromptRequests: Array.isArray(queuedPromptRequests) ? queuedPromptRequests.filter(
|
|
75457
|
-
(prompt) => !isRecord4(prompt) || !arrayContainsUnknown(prompt["content"], containsUnknownContentBlock)
|
|
75458
|
-
) : queuedPromptRequests
|
|
75459
|
-
};
|
|
75460
|
-
}
|
|
75461
|
-
var MAX_EVENT_COUNT, MAX_COLLECTION_SIZE2, MAX_CONTENT_LENGTH2, SESSION_EVENT_KIND, SESSION_EVENT_BATCH_MAX_SIZE, boundedString2, shortString, externalContentKeySchema, annotationsSchema, contentFields, textContentSchema, imageContentSchema, audioContentSchema, externalImageContentSchema, externalAudioContentSchema, externalResourceContentSchema, resourceLinkSchema, textResourceSchema, blobResourceSchema, embeddedResourceSchema, contentBlockSchema, toolCallContentSchema, toolKindSchema, toolStatusSchema, backgroundTaskSchema, toolPatchFields, planEntrySchema, planContentSchema, commandSchema, configSelectOptionSchema, configSelectGroupSchema, configBaseFields, sessionConfigOptionSchema2, contentChunkFields, acpSessionUpdateSchema, lifecycleBase, promptExecutionContextSchema, lifecycleMetadataSchema, sessionEventPayloadSchema, positionSchema, sharedSessionEventFields, sessionLiveEventFields, sessionEventSchema, sessionLiveEventSchema, wireLifecyclePayloadSchema, wireEventFields, sessionWireEventSchema, sessionWireEnvelopeSchema, knownContentBlockTypes, knownToolCallContentTypes, knownPlanTypes, knownConfigOptionTypes, knownSessionUpdates, knownLifecycleKinds, sessionEventBatchSchema, sessionLiveEventBatchSchema, sessionExportSchema, mobiusSessionExportSchema, sessionEventEnvelopeSchema, sessionEventLogPageSchema, sessionEventOmissionSchema, nativeEventPageRequestSchema, queuedPromptRequestEventLogSchema, nativeSessionEventsSchema, knownSessionLiveEventBatchSchema, decodeSessionEvent, decodeKnownSessionEventPayload, decodeSessionEventEnvelope, encodeSessionEventEnvelope, decodeAcpSessionUpdate, decodeKnownNativeSessionEvents;
|
|
75462
|
-
var init_event_log = __esm({
|
|
75463
|
-
"../mobius-sdk/src/protocol/session/observability/event-log.ts"() {
|
|
75464
|
-
"use strict";
|
|
75465
|
-
init_zod();
|
|
75466
|
-
init_directory();
|
|
75467
|
-
init_tool_input();
|
|
75468
|
-
init_tool_input();
|
|
75469
|
-
init_identifier();
|
|
75470
|
-
init_message_codec();
|
|
75471
|
-
init_interactions();
|
|
75472
|
-
MAX_EVENT_COUNT = 1e4;
|
|
75473
|
-
MAX_COLLECTION_SIZE2 = 1e3;
|
|
75474
|
-
MAX_CONTENT_LENGTH2 = 1e6;
|
|
75475
|
-
SESSION_EVENT_KIND = "session.event.v2";
|
|
75476
|
-
SESSION_EVENT_BATCH_MAX_SIZE = 1e3;
|
|
75477
|
-
boundedString2 = external_exports.string().max(MAX_CONTENT_LENGTH2);
|
|
75478
|
-
shortString = external_exports.string().max(2048);
|
|
75479
|
-
externalContentKeySchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
75480
|
-
annotationsSchema = external_exports.object({
|
|
75481
|
-
audience: external_exports.array(external_exports.enum(["assistant", "user"])).max(2).readonly().nullable().optional(),
|
|
75482
|
-
lastModified: shortString.nullable().optional(),
|
|
75483
|
-
priority: external_exports.number().finite().nullable().optional()
|
|
75484
|
-
}).readonly();
|
|
75485
|
-
contentFields = { annotations: annotationsSchema.nullable().optional() };
|
|
75486
|
-
textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
|
|
75487
|
-
imageContentSchema = external_exports.object({
|
|
75488
|
-
...contentFields,
|
|
75489
|
-
data: external_exports.string(),
|
|
75490
|
-
mimeType: shortString,
|
|
75491
|
-
type: external_exports.literal("image"),
|
|
75492
|
-
uri: boundedString2.nullable().optional()
|
|
75493
|
-
}).readonly();
|
|
75494
|
-
audioContentSchema = external_exports.object({ ...contentFields, data: external_exports.string(), mimeType: shortString, type: external_exports.literal("audio") }).readonly();
|
|
75495
|
-
externalImageContentSchema = external_exports.object({
|
|
75496
|
-
...contentFields,
|
|
75497
|
-
byteLength: external_exports.number().int().positive().safe(),
|
|
75498
|
-
imageKey: externalContentKeySchema,
|
|
75499
|
-
mimeType: shortString,
|
|
75500
|
-
type: external_exports.literal("external_image"),
|
|
75501
|
-
uri: boundedString2.nullable().optional()
|
|
75502
|
-
}).readonly();
|
|
75503
|
-
externalAudioContentSchema = external_exports.object({
|
|
75504
|
-
...contentFields,
|
|
75505
|
-
audioKey: externalContentKeySchema,
|
|
75506
|
-
byteLength: external_exports.number().int().positive().safe(),
|
|
75507
|
-
mimeType: shortString,
|
|
75508
|
-
type: external_exports.literal("external_audio")
|
|
75509
|
-
}).readonly();
|
|
75510
|
-
externalResourceContentSchema = external_exports.object({
|
|
75511
|
-
...contentFields,
|
|
75512
|
-
byteLength: external_exports.number().int().positive().safe(),
|
|
75513
|
-
encoding: external_exports.enum(["binary", "text"]),
|
|
75514
|
-
mimeType: shortString.nullable().optional(),
|
|
75515
|
-
resourceKey: externalContentKeySchema,
|
|
75516
|
-
type: external_exports.literal("external_resource"),
|
|
75517
|
-
uri: boundedString2
|
|
75518
|
-
}).readonly();
|
|
75519
|
-
resourceLinkSchema = external_exports.object({
|
|
75520
|
-
...contentFields,
|
|
75521
|
-
description: boundedString2.nullable().optional(),
|
|
75522
|
-
mimeType: shortString.nullable().optional(),
|
|
75523
|
-
name: shortString,
|
|
75524
|
-
size: external_exports.number().int().nonnegative().safe().nullable().optional(),
|
|
75525
|
-
title: shortString.nullable().optional(),
|
|
75526
|
-
type: external_exports.literal("resource_link"),
|
|
75527
|
-
uri: boundedString2
|
|
75528
|
-
}).readonly();
|
|
75529
|
-
textResourceSchema = external_exports.object({
|
|
75530
|
-
mimeType: shortString.nullable().optional(),
|
|
75531
|
-
text: boundedString2,
|
|
75532
|
-
uri: boundedString2
|
|
75533
|
-
}).readonly();
|
|
75534
|
-
blobResourceSchema = external_exports.object({
|
|
75535
|
-
blob: external_exports.string(),
|
|
75536
|
-
mimeType: shortString.nullable().optional(),
|
|
75537
|
-
uri: boundedString2
|
|
75538
|
-
}).readonly();
|
|
75539
|
-
embeddedResourceSchema = external_exports.object({
|
|
75540
|
-
...contentFields,
|
|
75541
|
-
resource: external_exports.union([textResourceSchema, blobResourceSchema]),
|
|
75542
|
-
type: external_exports.literal("resource")
|
|
75543
|
-
}).readonly();
|
|
75544
|
-
contentBlockSchema = external_exports.discriminatedUnion("type", [
|
|
75545
|
-
textContentSchema,
|
|
75546
|
-
imageContentSchema,
|
|
75547
|
-
audioContentSchema,
|
|
75548
|
-
resourceLinkSchema,
|
|
75549
|
-
embeddedResourceSchema,
|
|
75550
|
-
externalImageContentSchema,
|
|
75551
|
-
externalAudioContentSchema,
|
|
75552
|
-
externalResourceContentSchema
|
|
75553
|
-
]);
|
|
75554
|
-
toolCallContentSchema = external_exports.discriminatedUnion("type", [
|
|
75555
|
-
external_exports.object({ content: contentBlockSchema, type: external_exports.literal("content") }).readonly(),
|
|
75556
|
-
external_exports.object({
|
|
75557
|
-
newText: boundedString2,
|
|
75558
|
-
oldText: boundedString2.nullable().optional(),
|
|
75559
|
-
path: boundedString2,
|
|
75560
|
-
type: external_exports.literal("diff")
|
|
75561
|
-
}).readonly(),
|
|
75562
|
-
external_exports.object({ terminalId: shortString, type: external_exports.literal("terminal") }).readonly()
|
|
75563
|
-
]);
|
|
75564
|
-
toolKindSchema = external_exports.enum([
|
|
75565
|
-
"read",
|
|
75566
|
-
"edit",
|
|
75567
|
-
"delete",
|
|
75568
|
-
"move",
|
|
75569
|
-
"search",
|
|
75570
|
-
"execute",
|
|
75571
|
-
"think",
|
|
75572
|
-
"fetch",
|
|
75573
|
-
"switch_mode",
|
|
75574
|
-
"other"
|
|
75575
|
-
]);
|
|
75576
|
-
toolStatusSchema = external_exports.enum(["pending", "in_progress", "completed", "failed"]);
|
|
75577
|
-
backgroundTaskSchema = external_exports.object({
|
|
75578
|
-
id: shortString,
|
|
75579
|
-
status: external_exports.enum(["running", "completed", "failed", "stopped", "unknown"])
|
|
75720
|
+
return {
|
|
75721
|
+
commandId: readIdentifier(value, "commandId"),
|
|
75722
|
+
kind: SESSION_CANCEL_KIND,
|
|
75723
|
+
sessionId: readIdentifier(value, "sessionId")
|
|
75724
|
+
};
|
|
75725
|
+
}
|
|
75726
|
+
function decodeSessionPromptDispositionCommand(encoded) {
|
|
75727
|
+
const value = parseJson(encoded);
|
|
75728
|
+
assertKind(value, SESSION_PROMPT_DISPOSITION_KIND);
|
|
75729
|
+
if (readPromptDisposition(value) !== SessionPromptDisposition.Steer) {
|
|
75730
|
+
throw new ProtocolMessageError("Only queued prompts can be steered");
|
|
75731
|
+
}
|
|
75732
|
+
return {
|
|
75733
|
+
commandId: readIdentifier(value, "commandId"),
|
|
75734
|
+
disposition: SessionPromptDisposition.Steer,
|
|
75735
|
+
kind: SESSION_PROMPT_DISPOSITION_KIND,
|
|
75736
|
+
sessionId: readIdentifier(value, "sessionId")
|
|
75737
|
+
};
|
|
75738
|
+
}
|
|
75739
|
+
function encodeSessionPromptCommand(message) {
|
|
75740
|
+
const command = decodeSessionPromptCommand(JSON.stringify(message));
|
|
75741
|
+
return JSON.stringify({
|
|
75742
|
+
...command,
|
|
75743
|
+
// Keep text prompts compatible with the previous Runtime release while
|
|
75744
|
+
// attachments move to the content-key protocol. Older Runtimes ignore
|
|
75745
|
+
// `attachments` and require both legacy arrays to be present.
|
|
75746
|
+
images: [],
|
|
75747
|
+
resources: []
|
|
75748
|
+
});
|
|
75749
|
+
}
|
|
75750
|
+
function encodeSessionCancelCommand(message) {
|
|
75751
|
+
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
75752
|
+
}
|
|
75753
|
+
function encodeSessionPromptDispositionCommand(message) {
|
|
75754
|
+
return JSON.stringify(decodeSessionPromptDispositionCommand(JSON.stringify(message)));
|
|
75755
|
+
}
|
|
75756
|
+
var SESSION_PROMPT_KIND, SESSION_PROMPT_DISPOSITION_KIND, SESSION_CANCEL_KIND, SESSION_CANCEL_BEFORE_START_KIND, SessionPromptDisposition, SessionHistoryPolicy, MAX_PROMPT_LENGTH, MAX_PROMPT_ATTACHMENT_BYTES, encodeSessionCancelBeforeStartCommand, promptAttachmentSchema, decodePromptAttachmentsValue;
|
|
75757
|
+
var init_commands = __esm({
|
|
75758
|
+
"../mobius-sdk/src/protocol/session/prompt/commands.ts"() {
|
|
75759
|
+
"use strict";
|
|
75760
|
+
init_zod();
|
|
75761
|
+
init_identifier();
|
|
75762
|
+
init_message_codec();
|
|
75763
|
+
init_configuration();
|
|
75764
|
+
SESSION_PROMPT_KIND = "session.prompt";
|
|
75765
|
+
SESSION_PROMPT_DISPOSITION_KIND = "session.prompt.disposition";
|
|
75766
|
+
SESSION_CANCEL_KIND = "session.cancel";
|
|
75767
|
+
SESSION_CANCEL_BEFORE_START_KIND = "session.cancel-before-start";
|
|
75768
|
+
SessionPromptDisposition = Object.freeze({
|
|
75769
|
+
Queue: "queue",
|
|
75770
|
+
Reject: "reject",
|
|
75771
|
+
Steer: "steer"
|
|
75772
|
+
});
|
|
75773
|
+
SessionHistoryPolicy = Object.freeze({
|
|
75774
|
+
Eager: "eager",
|
|
75775
|
+
ExecutionOnly: "execution-only"
|
|
75776
|
+
});
|
|
75777
|
+
MAX_PROMPT_LENGTH = 1e5;
|
|
75778
|
+
MAX_PROMPT_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
75779
|
+
encodeSessionCancelBeforeStartCommand = (message) => JSON.stringify(decodeSessionCancelBeforeStartCommand(JSON.stringify(message)));
|
|
75780
|
+
promptAttachmentSchema = external_exports.object({
|
|
75781
|
+
byteLength: external_exports.number().int().positive().max(MAX_PROMPT_ATTACHMENT_BYTES),
|
|
75782
|
+
contentKey: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
75783
|
+
kind: external_exports.enum(["image", "resource"]),
|
|
75784
|
+
mimeType: external_exports.string().min(1).max(255),
|
|
75785
|
+
name: external_exports.string().min(1).max(500),
|
|
75786
|
+
uri: external_exports.string().min(1).max(4096)
|
|
75580
75787
|
}).readonly();
|
|
75581
|
-
|
|
75582
|
-
|
|
75583
|
-
|
|
75584
|
-
|
|
75585
|
-
|
|
75586
|
-
|
|
75587
|
-
|
|
75588
|
-
|
|
75589
|
-
|
|
75590
|
-
|
|
75788
|
+
decodePromptAttachmentsValue = (value) => decodeZodValue(value, external_exports.array(promptAttachmentSchema).max(16).readonly());
|
|
75789
|
+
}
|
|
75790
|
+
});
|
|
75791
|
+
|
|
75792
|
+
// ../mobius-sdk/src/protocol/session/native/index.ts
|
|
75793
|
+
function decode4(schema, encoded) {
|
|
75794
|
+
try {
|
|
75795
|
+
const value = JSON.parse(encoded);
|
|
75796
|
+
return schema.parse(value);
|
|
75797
|
+
} catch (cause) {
|
|
75798
|
+
throw new ProtocolMessageError("Invalid native session message", { cause });
|
|
75799
|
+
}
|
|
75800
|
+
}
|
|
75801
|
+
var NATIVE_SESSION_REQUEST_KIND, NATIVE_SESSION_RESULT_KIND, NATIVE_SESSION_CANCEL_KIND, envelope, activeTurnSnapshotSchema, identity, nativeSessionRequestSchema, nativeSessionCommandSchema, nativeSessionEntrySchema, resultEnvelope, nativeSessionResultSchema, nativeSessionCancelSchema, decodeNativeSessionCommand, encodeNativeSessionCommand, decodeNativeSessionResult, encodeNativeSessionResult, decodeNativeSessionCancel, encodeNativeSessionCancel;
|
|
75802
|
+
var init_native = __esm({
|
|
75803
|
+
"../mobius-sdk/src/protocol/session/native/index.ts"() {
|
|
75804
|
+
"use strict";
|
|
75805
|
+
init_zod();
|
|
75806
|
+
init_directory();
|
|
75807
|
+
init_identifier();
|
|
75808
|
+
init_message_codec();
|
|
75809
|
+
init_interactions();
|
|
75810
|
+
init_lifecycle();
|
|
75811
|
+
init_commands();
|
|
75812
|
+
init_shared2();
|
|
75813
|
+
NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
75814
|
+
NATIVE_SESSION_RESULT_KIND = "native.session.result";
|
|
75815
|
+
NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
|
|
75816
|
+
envelope = {
|
|
75817
|
+
requestId: identifierStringSchema,
|
|
75818
|
+
sessionId: identifierStringSchema
|
|
75591
75819
|
};
|
|
75592
|
-
|
|
75593
|
-
|
|
75594
|
-
|
|
75595
|
-
|
|
75820
|
+
activeTurnSnapshotSchema = external_exports.object({
|
|
75821
|
+
commandId: identifierStringSchema,
|
|
75822
|
+
epoch: identifierStringSchema,
|
|
75823
|
+
interaction: external_exports.discriminatedUnion("kind", [sessionPermissionRequestedEventSchema, sessionElicitationRequestedEventSchema]).nullable(),
|
|
75824
|
+
sequence: external_exports.number().int().nonnegative(),
|
|
75825
|
+
state: external_exports.literal("running")
|
|
75596
75826
|
}).readonly();
|
|
75597
|
-
|
|
75827
|
+
identity = {
|
|
75828
|
+
...envelope,
|
|
75829
|
+
kind: external_exports.literal(NATIVE_SESSION_REQUEST_KIND),
|
|
75830
|
+
additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
|
|
75831
|
+
agentId: identifierStringSchema,
|
|
75832
|
+
bindingId: identifierStringSchema,
|
|
75833
|
+
directoryId: DIRECTORY_IDENTIFIER
|
|
75834
|
+
};
|
|
75835
|
+
nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
75836
|
+
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
75837
|
+
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
75598
75838
|
external_exports.object({
|
|
75599
|
-
|
|
75600
|
-
|
|
75601
|
-
|
|
75839
|
+
...identity,
|
|
75840
|
+
action: external_exports.literal("list"),
|
|
75841
|
+
cursor: identifierStringSchema.nullable()
|
|
75602
75842
|
}).readonly(),
|
|
75603
|
-
external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString2 }).readonly(),
|
|
75604
75843
|
external_exports.object({
|
|
75605
|
-
|
|
75606
|
-
|
|
75607
|
-
|
|
75844
|
+
...identity,
|
|
75845
|
+
action: external_exports.enum(["import", "fork"]),
|
|
75846
|
+
entryId: identifierStringSchema,
|
|
75847
|
+
targetSessionId: identifierStringSchema
|
|
75608
75848
|
}).readonly()
|
|
75609
75849
|
]);
|
|
75610
|
-
|
|
75611
|
-
|
|
75612
|
-
|
|
75613
|
-
name: shortString
|
|
75614
|
-
}).readonly();
|
|
75615
|
-
configSelectOptionSchema = external_exports.object({
|
|
75616
|
-
description: boundedString2.nullable().optional(),
|
|
75617
|
-
name: shortString,
|
|
75618
|
-
value: shortString
|
|
75619
|
-
}).readonly();
|
|
75620
|
-
configSelectGroupSchema = external_exports.object({
|
|
75621
|
-
group: shortString,
|
|
75622
|
-
name: shortString,
|
|
75623
|
-
options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
75624
|
-
}).readonly();
|
|
75625
|
-
configBaseFields = {
|
|
75626
|
-
category: shortString.nullable().optional(),
|
|
75627
|
-
description: boundedString2.nullable().optional(),
|
|
75628
|
-
id: shortString,
|
|
75629
|
-
name: shortString
|
|
75630
|
-
};
|
|
75631
|
-
sessionConfigOptionSchema2 = external_exports.discriminatedUnion("type", [
|
|
75632
|
-
external_exports.object({
|
|
75633
|
-
...configBaseFields,
|
|
75634
|
-
currentValue: shortString,
|
|
75635
|
-
options: external_exports.union([
|
|
75636
|
-
external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
75637
|
-
external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
75638
|
-
]),
|
|
75639
|
-
type: external_exports.literal("select")
|
|
75640
|
-
}).readonly(),
|
|
75641
|
-
external_exports.object({ ...configBaseFields, currentValue: external_exports.boolean(), type: external_exports.literal("boolean") }).readonly()
|
|
75642
|
-
]);
|
|
75643
|
-
contentChunkFields = {
|
|
75644
|
-
content: contentBlockSchema,
|
|
75645
|
-
messageId: shortString.nullable().optional()
|
|
75646
|
-
};
|
|
75647
|
-
acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate", [
|
|
75648
|
-
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("user_message_chunk") }).readonly(),
|
|
75649
|
-
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_message_chunk") }).readonly(),
|
|
75650
|
-
external_exports.object({
|
|
75651
|
-
...contentChunkFields,
|
|
75652
|
-
meta: external_exports.object({ truncated: external_exports.boolean().optional() }).readonly().optional(),
|
|
75653
|
-
sessionUpdate: external_exports.literal("agent_thought_chunk")
|
|
75654
|
-
}).readonly(),
|
|
75655
|
-
external_exports.object({
|
|
75656
|
-
backgroundTask: backgroundTaskSchema.optional(),
|
|
75657
|
-
content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
75658
|
-
kind: toolKindSchema.optional(),
|
|
75659
|
-
locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
75660
|
-
name: shortString.nullable().optional(),
|
|
75661
|
-
rawInput: boundedJsonSchema.optional(),
|
|
75662
|
-
rawOutput: boundedJsonSchema.optional(),
|
|
75663
|
-
sessionUpdate: external_exports.literal("tool_call"),
|
|
75664
|
-
status: toolStatusSchema.optional(),
|
|
75665
|
-
title: boundedString2,
|
|
75666
|
-
toolCallId: shortString
|
|
75667
|
-
}).readonly(),
|
|
75668
|
-
external_exports.object({ ...toolPatchFields, sessionUpdate: external_exports.literal("tool_call_update"), toolCallId: shortString }).readonly(),
|
|
75669
|
-
external_exports.object({
|
|
75670
|
-
entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
75671
|
-
sessionUpdate: external_exports.literal("plan")
|
|
75672
|
-
}).readonly(),
|
|
75673
|
-
external_exports.object({ plan: planContentSchema, sessionUpdate: external_exports.literal("plan_update") }).readonly(),
|
|
75674
|
-
external_exports.object({ planId: shortString, sessionUpdate: external_exports.literal("plan_removed") }).readonly(),
|
|
75675
|
-
external_exports.object({
|
|
75676
|
-
availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
75677
|
-
sessionUpdate: external_exports.literal("available_commands_update")
|
|
75678
|
-
}).readonly(),
|
|
75679
|
-
external_exports.object({
|
|
75680
|
-
currentModeId: shortString,
|
|
75681
|
-
sessionUpdate: external_exports.literal("current_mode_update")
|
|
75682
|
-
}).readonly(),
|
|
75683
|
-
external_exports.object({
|
|
75684
|
-
configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
75685
|
-
sessionUpdate: external_exports.literal("config_option_update")
|
|
75686
|
-
}).readonly(),
|
|
75687
|
-
external_exports.object({
|
|
75688
|
-
sessionUpdate: external_exports.literal("session_info_update"),
|
|
75689
|
-
title: boundedString2.nullable().optional(),
|
|
75690
|
-
updatedAt: shortString.nullable().optional()
|
|
75691
|
-
}).readonly(),
|
|
75692
|
-
external_exports.object({
|
|
75693
|
-
cost: external_exports.object({ amount: external_exports.number().finite(), currency: external_exports.string().max(16) }).readonly().nullable().optional(),
|
|
75694
|
-
sessionUpdate: external_exports.literal("usage_update"),
|
|
75695
|
-
size: external_exports.number().int().nonnegative().safe(),
|
|
75696
|
-
used: external_exports.number().int().nonnegative().safe()
|
|
75697
|
-
}).readonly(),
|
|
75850
|
+
nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
75851
|
+
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
75852
|
+
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
75698
75853
|
external_exports.object({
|
|
75699
|
-
|
|
75700
|
-
|
|
75701
|
-
|
|
75702
|
-
status: shortString,
|
|
75703
|
-
summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional()
|
|
75854
|
+
...identity,
|
|
75855
|
+
action: external_exports.literal("list"),
|
|
75856
|
+
cursor: identifierStringSchema.nullable()
|
|
75704
75857
|
}).readonly(),
|
|
75705
75858
|
external_exports.object({
|
|
75706
|
-
|
|
75707
|
-
|
|
75708
|
-
|
|
75859
|
+
...identity,
|
|
75860
|
+
action: external_exports.enum(["import", "fork"]),
|
|
75861
|
+
entryId: identifierStringSchema,
|
|
75862
|
+
targetSessionId: identifierStringSchema
|
|
75709
75863
|
}).readonly()
|
|
75710
75864
|
]);
|
|
75711
|
-
|
|
75712
|
-
|
|
75713
|
-
|
|
75865
|
+
nativeSessionEntrySchema = external_exports.object({
|
|
75866
|
+
entryId: identifierStringSchema,
|
|
75867
|
+
mobiusSessionIds: external_exports.array(identifierStringSchema).max(500).readonly(),
|
|
75868
|
+
nativeSessionId: identifierStringSchema,
|
|
75869
|
+
title: external_exports.string().max(500),
|
|
75714
75870
|
directoryId: DIRECTORY_IDENTIFIER,
|
|
75715
|
-
|
|
75871
|
+
directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
|
|
75872
|
+
updatedAt: external_exports.iso.datetime({ offset: true }).nullable(),
|
|
75873
|
+
additionalDirectories: external_exports.array(external_exports.object({ directoryId: DIRECTORY_IDENTIFIER, name: external_exports.string().min(1).max(255) }).readonly()).max(16).readonly()
|
|
75716
75874
|
}).readonly();
|
|
75717
|
-
|
|
75718
|
-
|
|
75719
|
-
|
|
75720
|
-
|
|
75721
|
-
|
|
75722
|
-
external_exports.object({ event: sessionElicitationResolvedEventSchema, kind: external_exports.literal("session.elicitation.resolved") }).readonly(),
|
|
75875
|
+
resultEnvelope = {
|
|
75876
|
+
...envelope,
|
|
75877
|
+
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
75878
|
+
};
|
|
75879
|
+
nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
75723
75880
|
external_exports.object({
|
|
75724
|
-
...
|
|
75725
|
-
|
|
75726
|
-
|
|
75727
|
-
|
|
75728
|
-
|
|
75729
|
-
|
|
75881
|
+
...resultEnvelope,
|
|
75882
|
+
action: external_exports.literal("active-turn"),
|
|
75883
|
+
targetSessionId: identifierStringSchema,
|
|
75884
|
+
queued: external_exports.array(
|
|
75885
|
+
external_exports.object({
|
|
75886
|
+
commandId: identifierStringSchema,
|
|
75887
|
+
prompt: external_exports.string().max(1e5),
|
|
75888
|
+
attachments: external_exports.array(promptAttachmentSchema).max(16).readonly()
|
|
75889
|
+
}).readonly()
|
|
75890
|
+
).readonly(),
|
|
75891
|
+
turn: activeTurnSnapshotSchema.nullable()
|
|
75730
75892
|
}).readonly(),
|
|
75731
|
-
external_exports.object({ ...lifecycleBase, attemptId: identifierStringSchema, epoch: identifierStringSchema, kind: external_exports.literal("prompt.started") }).readonly(),
|
|
75732
75893
|
external_exports.object({
|
|
75733
|
-
...
|
|
75734
|
-
|
|
75735
|
-
|
|
75894
|
+
...resultEnvelope,
|
|
75895
|
+
action: external_exports.literal("find"),
|
|
75896
|
+
entry: nativeSessionEntrySchema
|
|
75736
75897
|
}).readonly(),
|
|
75737
75898
|
external_exports.object({
|
|
75738
|
-
...
|
|
75739
|
-
|
|
75740
|
-
|
|
75741
|
-
|
|
75899
|
+
...resultEnvelope,
|
|
75900
|
+
action: external_exports.literal("list"),
|
|
75901
|
+
capabilities: sessionCapabilitiesSchema,
|
|
75902
|
+
entries: external_exports.array(nativeSessionEntrySchema).max(500).readonly(),
|
|
75903
|
+
nextCursor: identifierStringSchema.nullable()
|
|
75742
75904
|
}).readonly(),
|
|
75743
75905
|
external_exports.object({
|
|
75744
|
-
...
|
|
75745
|
-
|
|
75746
|
-
|
|
75747
|
-
|
|
75748
|
-
|
|
75749
|
-
}).readonly()
|
|
75750
|
-
]);
|
|
75751
|
-
sessionEventPayloadSchema = external_exports.discriminatedUnion("type", [
|
|
75752
|
-
external_exports.object({ payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
75753
|
-
external_exports.object({ payload: lifecycleMetadataSchema, type: external_exports.literal("lifecycle-metadata") }).readonly()
|
|
75754
|
-
]);
|
|
75755
|
-
positionSchema = external_exports.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
75756
|
-
sharedSessionEventFields = {
|
|
75757
|
-
eventId: identifierStringSchema,
|
|
75758
|
-
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).readonly().optional(),
|
|
75759
|
-
recordedAt: external_exports.iso.datetime({ offset: true }),
|
|
75760
|
-
sessionGenerationId: identifierStringSchema,
|
|
75761
|
-
sessionId: identifierStringSchema
|
|
75762
|
-
};
|
|
75763
|
-
sessionLiveEventFields = { ...sharedSessionEventFields, position: positionSchema };
|
|
75764
|
-
sessionEventSchema = external_exports.object({ ...sharedSessionEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly();
|
|
75765
|
-
sessionLiveEventSchema = external_exports.discriminatedUnion("type", [
|
|
75766
|
-
external_exports.object({ ...sessionLiveEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
75767
|
-
external_exports.object({
|
|
75768
|
-
...sessionLiveEventFields,
|
|
75769
|
-
payload: lifecycleMetadataSchema,
|
|
75770
|
-
type: external_exports.literal("lifecycle-metadata")
|
|
75906
|
+
...resultEnvelope,
|
|
75907
|
+
action: external_exports.enum(["import", "fork"]),
|
|
75908
|
+
targetSessionId: identifierStringSchema,
|
|
75909
|
+
ready: sessionReadyEventSchema,
|
|
75910
|
+
title: external_exports.string().max(500)
|
|
75771
75911
|
}).readonly()
|
|
75772
75912
|
]);
|
|
75773
|
-
|
|
75774
|
-
|
|
75775
|
-
|
|
75776
|
-
|
|
75777
|
-
|
|
75778
|
-
|
|
75779
|
-
|
|
75780
|
-
...sessionLiveEventFields,
|
|
75781
|
-
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).passthrough().readonly().optional()
|
|
75782
|
-
};
|
|
75783
|
-
sessionWireEventSchema = external_exports.union([
|
|
75784
|
-
external_exports.object({
|
|
75785
|
-
...wireEventFields,
|
|
75786
|
-
type: external_exports.literal("acp"),
|
|
75787
|
-
payload: external_exports.object({ sessionUpdate: identifierStringSchema }).passthrough().readonly()
|
|
75788
|
-
}).passthrough().readonly(),
|
|
75789
|
-
external_exports.object({
|
|
75790
|
-
...wireEventFields,
|
|
75791
|
-
type: external_exports.literal("lifecycle-metadata"),
|
|
75792
|
-
payload: wireLifecyclePayloadSchema
|
|
75793
|
-
}).passthrough().readonly(),
|
|
75794
|
-
external_exports.object({
|
|
75795
|
-
...wireEventFields,
|
|
75796
|
-
type: identifierStringSchema.refine((type) => type !== "acp" && type !== "lifecycle-metadata"),
|
|
75797
|
-
payload: external_exports.record(external_exports.string(), external_exports.unknown()).readonly()
|
|
75798
|
-
}).passthrough().readonly()
|
|
75799
|
-
]);
|
|
75800
|
-
sessionWireEnvelopeSchema = external_exports.object({
|
|
75801
|
-
kind: external_exports.literal(SESSION_EVENT_KIND),
|
|
75802
|
-
events: external_exports.array(sessionWireEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly()
|
|
75803
|
-
}).passthrough().readonly();
|
|
75804
|
-
knownContentBlockTypes = /* @__PURE__ */ new Set([
|
|
75805
|
-
"text",
|
|
75806
|
-
"image",
|
|
75807
|
-
"audio",
|
|
75808
|
-
"resource_link",
|
|
75809
|
-
"resource",
|
|
75810
|
-
"external_image",
|
|
75811
|
-
"external_audio",
|
|
75812
|
-
"external_resource"
|
|
75813
|
-
]);
|
|
75814
|
-
knownToolCallContentTypes = /* @__PURE__ */ new Set(["content", "diff", "terminal"]);
|
|
75815
|
-
knownPlanTypes = /* @__PURE__ */ new Set(["items", "file", "markdown"]);
|
|
75816
|
-
knownConfigOptionTypes = /* @__PURE__ */ new Set(["select", "boolean"]);
|
|
75817
|
-
knownSessionUpdates = /* @__PURE__ */ new Set([
|
|
75818
|
-
"user_message_chunk",
|
|
75819
|
-
"agent_message_chunk",
|
|
75820
|
-
"agent_thought_chunk",
|
|
75821
|
-
"tool_call",
|
|
75822
|
-
"tool_call_update",
|
|
75823
|
-
"plan",
|
|
75824
|
-
"plan_update",
|
|
75825
|
-
"plan_removed",
|
|
75826
|
-
"available_commands_update",
|
|
75827
|
-
"current_mode_update",
|
|
75828
|
-
"config_option_update",
|
|
75829
|
-
"session_info_update",
|
|
75830
|
-
"usage_update",
|
|
75831
|
-
"compaction_update",
|
|
75832
|
-
"compaction_summary_chunk"
|
|
75833
|
-
]);
|
|
75834
|
-
knownLifecycleKinds = /* @__PURE__ */ new Set([
|
|
75835
|
-
"session.queue.changed",
|
|
75836
|
-
"session.permission.requested",
|
|
75837
|
-
"session.permission.resolved",
|
|
75838
|
-
"session.elicitation.requested",
|
|
75839
|
-
"session.elicitation.resolved",
|
|
75840
|
-
"prompt.requested",
|
|
75841
|
-
"prompt.started",
|
|
75842
|
-
"prompt.completed",
|
|
75843
|
-
"prompt.failed-before-start",
|
|
75844
|
-
"prompt.failed"
|
|
75845
|
-
]);
|
|
75846
|
-
sessionEventBatchSchema = external_exports.array(sessionEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
75847
|
-
sessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
75848
|
-
sessionExportSchema = external_exports.object({
|
|
75849
|
-
binding: external_exports.object({
|
|
75850
|
-
bindingId: identifierStringSchema,
|
|
75851
|
-
runtimeId: identifierStringSchema
|
|
75852
|
-
}).readonly(),
|
|
75853
|
-
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
75854
|
-
sessionId: identifierStringSchema,
|
|
75855
|
-
truncated: external_exports.boolean()
|
|
75856
|
-
}).readonly().superRefine((session, context) => {
|
|
75857
|
-
const eventIds = /* @__PURE__ */ new Set();
|
|
75858
|
-
for (const [index2, event] of session.events.entries()) {
|
|
75859
|
-
if (event.sessionId !== session.sessionId) {
|
|
75860
|
-
context.addIssue({
|
|
75861
|
-
code: "custom",
|
|
75862
|
-
message: "Exported event belongs to a different Session",
|
|
75863
|
-
path: ["events", index2, "sessionId"]
|
|
75864
|
-
});
|
|
75865
|
-
}
|
|
75866
|
-
if (eventIds.has(event.eventId)) {
|
|
75867
|
-
context.addIssue({
|
|
75868
|
-
code: "custom",
|
|
75869
|
-
message: "Exported event identities are not unique",
|
|
75870
|
-
path: ["events", index2, "eventId"]
|
|
75871
|
-
});
|
|
75872
|
-
}
|
|
75873
|
-
eventIds.add(event.eventId);
|
|
75874
|
-
}
|
|
75875
|
-
});
|
|
75876
|
-
mobiusSessionExportSchema = external_exports.object({
|
|
75877
|
-
formatVersion: external_exports.literal("2"),
|
|
75878
|
-
session: sessionExportSchema
|
|
75879
|
-
}).readonly();
|
|
75880
|
-
sessionEventEnvelopeSchema = external_exports.object({ events: sessionLiveEventBatchSchema, kind: external_exports.literal(SESSION_EVENT_KIND) }).readonly();
|
|
75881
|
-
sessionEventLogPageSchema = external_exports.object({
|
|
75882
|
-
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
75883
|
-
nextCursor: external_exports.string().min(1).max(512).nullable(),
|
|
75884
|
-
sessionGenerationId: identifierStringSchema,
|
|
75885
|
-
tailCursor: external_exports.string().max(512),
|
|
75886
|
-
// The generation-scoped live position covered by this snapshot, including
|
|
75887
|
-
// coalesced and omitted events. Absent only on older Runtime versions.
|
|
75888
|
-
throughPosition: positionSchema.optional(),
|
|
75889
|
-
truncated: external_exports.boolean(),
|
|
75890
|
-
version: external_exports.literal(2)
|
|
75891
|
-
}).readonly();
|
|
75892
|
-
sessionEventOmissionSchema = external_exports.literal("agent-reasoning");
|
|
75893
|
-
nativeEventPageRequestSchema = external_exports.object({
|
|
75894
|
-
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
75895
|
-
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
75896
|
-
// Legacy callers may still send this option; readers must ignore it.
|
|
75897
|
-
omit: external_exports.array(sessionEventOmissionSchema).max(1).readonly().optional()
|
|
75898
|
-
}).readonly();
|
|
75899
|
-
queuedPromptRequestEventLogSchema = external_exports.object({
|
|
75900
|
-
commandId: identifierStringSchema,
|
|
75901
|
-
content: external_exports.array(contentBlockSchema).min(1).max(100).readonly(),
|
|
75902
|
-
disposition: shortString.optional(),
|
|
75903
|
-
targetCommandId: identifierStringSchema.optional()
|
|
75904
|
-
}).readonly();
|
|
75905
|
-
nativeSessionEventsSchema = external_exports.object({
|
|
75906
|
-
events: sessionEventLogPageSchema,
|
|
75907
|
-
queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
75908
|
-
}).readonly();
|
|
75909
|
-
knownSessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
75910
|
-
decodeSessionEvent = (value) => decode4(value, sessionEventSchema);
|
|
75911
|
-
decodeKnownSessionEventPayload = (value) => isKnownSessionEventVariant(value) ? decode4(value, sessionEventPayloadSchema) : null;
|
|
75912
|
-
decodeSessionEventEnvelope = (value) => decode4(value, sessionEventEnvelopeSchema);
|
|
75913
|
-
encodeSessionEventEnvelope = (value) => encode3(value, sessionEventEnvelopeSchema);
|
|
75914
|
-
decodeAcpSessionUpdate = (value) => decode4(value, acpSessionUpdateSchema);
|
|
75915
|
-
decodeKnownNativeSessionEvents = (value) => decode4(sanitizeKnownNativeSessionEvents(value), nativeSessionEventsSchema);
|
|
75913
|
+
nativeSessionCancelSchema = external_exports.object({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
|
|
75914
|
+
decodeNativeSessionCommand = (encoded) => decode4(nativeSessionCommandSchema, encoded);
|
|
75915
|
+
encodeNativeSessionCommand = (value) => JSON.stringify(nativeSessionCommandSchema.parse(value));
|
|
75916
|
+
decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema, encoded);
|
|
75917
|
+
encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
|
|
75918
|
+
decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
|
|
75919
|
+
encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
|
|
75916
75920
|
}
|
|
75917
75921
|
});
|
|
75918
75922
|
|
|
@@ -75944,7 +75948,7 @@ var init_history2 = __esm({
|
|
|
75944
75948
|
init_directory();
|
|
75945
75949
|
init_identifier();
|
|
75946
75950
|
init_message_codec();
|
|
75947
|
-
|
|
75951
|
+
init_events();
|
|
75948
75952
|
SESSION_HISTORY_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
75949
75953
|
SESSION_HISTORY_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
75950
75954
|
SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
|
|
@@ -76101,7 +76105,7 @@ var init_recording = __esm({
|
|
|
76101
76105
|
init_zod();
|
|
76102
76106
|
init_directory();
|
|
76103
76107
|
init_identifier();
|
|
76104
|
-
|
|
76108
|
+
init_events();
|
|
76105
76109
|
sessionRecordingWriteSchema = external_exports.object({
|
|
76106
76110
|
envelope: sessionEventEnvelopeSchema,
|
|
76107
76111
|
projectId: identifierStringSchema,
|
|
@@ -76156,8 +76160,8 @@ var init_turn_history = __esm({
|
|
|
76156
76160
|
"use strict";
|
|
76157
76161
|
init_zod();
|
|
76158
76162
|
init_identifier();
|
|
76163
|
+
init_events();
|
|
76159
76164
|
init_interactions();
|
|
76160
|
-
init_event_log();
|
|
76161
76165
|
init_recording();
|
|
76162
76166
|
SESSION_RECORDING_TURN_PAGE_DECODE_MAX_ELEMENTS = 1e4;
|
|
76163
76167
|
SESSION_RECORDING_TURN_ITEM_ID_MAX_LENGTH = 4200;
|
|
@@ -76532,11 +76536,11 @@ var init_daemon_transport = __esm({
|
|
|
76532
76536
|
init_settings2();
|
|
76533
76537
|
init_configuration();
|
|
76534
76538
|
init_title();
|
|
76539
|
+
init_events();
|
|
76535
76540
|
init_files();
|
|
76536
76541
|
init_interactions();
|
|
76537
76542
|
init_lifecycle();
|
|
76538
76543
|
init_native();
|
|
76539
|
-
init_event_log();
|
|
76540
76544
|
init_history2();
|
|
76541
76545
|
init_commands();
|
|
76542
76546
|
init_workspace();
|
|
@@ -76818,12 +76822,12 @@ var init_protocol = __esm({
|
|
|
76818
76822
|
init_settings2();
|
|
76819
76823
|
init_configuration();
|
|
76820
76824
|
init_title();
|
|
76825
|
+
init_events();
|
|
76821
76826
|
init_files();
|
|
76822
76827
|
init_interactions();
|
|
76823
76828
|
init_model();
|
|
76824
76829
|
init_lifecycle();
|
|
76825
76830
|
init_native();
|
|
76826
|
-
init_event_log();
|
|
76827
76831
|
init_history2();
|
|
76828
76832
|
init_commands();
|
|
76829
76833
|
init_usage();
|
|
@@ -97830,56 +97834,82 @@ var init_runtime_turn_activity = __esm({
|
|
|
97830
97834
|
RuntimeTurnActivity = class {
|
|
97831
97835
|
#turns = /* @__PURE__ */ new Set();
|
|
97832
97836
|
#backgroundSources = /* @__PURE__ */ new Set();
|
|
97833
|
-
#
|
|
97834
|
-
|
|
97837
|
+
#idleWaiters = /* @__PURE__ */ new Set();
|
|
97838
|
+
// When work last started or stopped; the quiet period is measured from here.
|
|
97839
|
+
#changedAt = Date.now();
|
|
97840
|
+
#reserved = false;
|
|
97841
|
+
acceptsPrompts = () => !this.#reserved;
|
|
97835
97842
|
count = () => this.#turns.size + this.#backgroundSources.size;
|
|
97843
|
+
describe = () => ({
|
|
97844
|
+
turns: this.#turns.size,
|
|
97845
|
+
backgroundSources: this.#backgroundSources.size
|
|
97846
|
+
});
|
|
97836
97847
|
setBackgroundActivity = (source, active) => {
|
|
97848
|
+
if (active === this.#backgroundSources.has(source)) {
|
|
97849
|
+
return;
|
|
97850
|
+
}
|
|
97837
97851
|
if (active) {
|
|
97838
97852
|
this.#backgroundSources.add(source);
|
|
97839
97853
|
} else {
|
|
97840
97854
|
this.#backgroundSources.delete(source);
|
|
97841
97855
|
}
|
|
97842
|
-
this.#
|
|
97856
|
+
this.#changed();
|
|
97843
97857
|
};
|
|
97844
|
-
#reserveIfIdle() {
|
|
97845
|
-
if (this.count() === 0 && this.#admission.kind === "waiting") {
|
|
97846
|
-
this.#admission.reserve();
|
|
97847
|
-
}
|
|
97848
|
-
}
|
|
97849
97858
|
start = (turn) => {
|
|
97850
97859
|
this.#turns.add(turn);
|
|
97860
|
+
this.#changed();
|
|
97851
97861
|
};
|
|
97852
97862
|
finish = (turn) => {
|
|
97853
97863
|
this.#turns.delete(turn);
|
|
97854
|
-
this.#
|
|
97864
|
+
this.#changed();
|
|
97855
97865
|
};
|
|
97856
|
-
|
|
97866
|
+
#changed() {
|
|
97867
|
+
this.#changedAt = Date.now();
|
|
97868
|
+
if (this.count() === 0) {
|
|
97869
|
+
for (const resolve21 of this.#idleWaiters) {
|
|
97870
|
+
resolve21();
|
|
97871
|
+
}
|
|
97872
|
+
this.#idleWaiters.clear();
|
|
97873
|
+
}
|
|
97874
|
+
}
|
|
97875
|
+
whenIdle = (signal) => {
|
|
97857
97876
|
signal.throwIfAborted();
|
|
97858
|
-
if (this
|
|
97859
|
-
|
|
97877
|
+
if (this.count() === 0) {
|
|
97878
|
+
return Promise.resolve();
|
|
97860
97879
|
}
|
|
97861
97880
|
return new Promise((resolve21, reject2) => {
|
|
97862
97881
|
const abort = () => {
|
|
97863
|
-
this.#
|
|
97864
|
-
signal.removeEventListener("abort", abort);
|
|
97882
|
+
this.#idleWaiters.delete(idle);
|
|
97865
97883
|
reject2(signal.reason);
|
|
97866
97884
|
};
|
|
97867
|
-
const
|
|
97868
|
-
this.#admission = { kind: "reserved" };
|
|
97885
|
+
const idle = () => {
|
|
97869
97886
|
signal.removeEventListener("abort", abort);
|
|
97870
|
-
resolve21(
|
|
97871
|
-
[Symbol.dispose]: () => {
|
|
97872
|
-
this.#admission = { kind: "open" };
|
|
97873
|
-
}
|
|
97874
|
-
});
|
|
97887
|
+
resolve21();
|
|
97875
97888
|
};
|
|
97876
|
-
this.#
|
|
97889
|
+
this.#idleWaiters.add(idle);
|
|
97877
97890
|
signal.addEventListener("abort", abort, { once: true });
|
|
97878
|
-
if (this.count() === 0) {
|
|
97879
|
-
reserve();
|
|
97880
|
-
}
|
|
97881
97891
|
});
|
|
97882
97892
|
};
|
|
97893
|
+
/**
|
|
97894
|
+
* Close admission only after the Runtime has had no work for `quietMilliseconds`.
|
|
97895
|
+
* The moment a reply finishes is when a user is most likely to continue, so idle
|
|
97896
|
+
* alone is not an upgrade window. Checking and reserving happen synchronously, so
|
|
97897
|
+
* no prompt can be admitted between them.
|
|
97898
|
+
*/
|
|
97899
|
+
reserveIfQuiet = (quietMilliseconds) => {
|
|
97900
|
+
if (this.#reserved) {
|
|
97901
|
+
throw new Error("A daemon upgrade already owns admission");
|
|
97902
|
+
}
|
|
97903
|
+
if (this.count() > 0 || Date.now() - this.#changedAt < quietMilliseconds) {
|
|
97904
|
+
return null;
|
|
97905
|
+
}
|
|
97906
|
+
this.#reserved = true;
|
|
97907
|
+
return {
|
|
97908
|
+
[Symbol.dispose]: () => {
|
|
97909
|
+
this.#reserved = false;
|
|
97910
|
+
}
|
|
97911
|
+
};
|
|
97912
|
+
};
|
|
97883
97913
|
};
|
|
97884
97914
|
}
|
|
97885
97915
|
});
|
|
@@ -102857,6 +102887,21 @@ async function awaitDaemonReleaseSwitch(stateDirectory, id, signal) {
|
|
|
102857
102887
|
}
|
|
102858
102888
|
return outcome;
|
|
102859
102889
|
}
|
|
102890
|
+
async function reserveWhenQuiet(activity, signal) {
|
|
102891
|
+
for (; ; ) {
|
|
102892
|
+
await activity.whenIdle(signal);
|
|
102893
|
+
for await (const _tick of setInterval2(UPGRADE_QUIET_CHECK_MILLISECONDS, void 0, { signal })) {
|
|
102894
|
+
const reservation = activity.reserveIfQuiet(UPGRADE_QUIET_MILLISECONDS);
|
|
102895
|
+
if (reservation !== null) {
|
|
102896
|
+
return reservation;
|
|
102897
|
+
}
|
|
102898
|
+
if (activity.count() > 0) {
|
|
102899
|
+
break;
|
|
102900
|
+
}
|
|
102901
|
+
}
|
|
102902
|
+
signal.throwIfAborted();
|
|
102903
|
+
}
|
|
102904
|
+
}
|
|
102860
102905
|
async function checkDaemonReleaseUpgrade(signal, activity) {
|
|
102861
102906
|
var _stack = [];
|
|
102862
102907
|
try {
|
|
@@ -102870,17 +102915,20 @@ async function checkDaemonReleaseUpgrade(signal, activity) {
|
|
|
102870
102915
|
return;
|
|
102871
102916
|
}
|
|
102872
102917
|
const launch = await installDaemonReleaseVersion(version2, signal);
|
|
102873
|
-
|
|
102918
|
+
let reservation = activity.reserveIfQuiet(UPGRADE_QUIET_MILLISECONDS);
|
|
102919
|
+
if (reservation === null) {
|
|
102874
102920
|
new RuntimeDiagnosticLog(control.stateDirectory).record(
|
|
102875
102921
|
`Mobius daemon diagnostic ${JSON.stringify({
|
|
102876
102922
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
102877
102923
|
event: "daemon_upgrade_deferred",
|
|
102878
102924
|
version: version2,
|
|
102879
|
-
activeWork: activity.count()
|
|
102925
|
+
activeWork: activity.count(),
|
|
102926
|
+
...activity.describe()
|
|
102880
102927
|
})}`
|
|
102881
102928
|
);
|
|
102929
|
+
reservation = await reserveWhenQuiet(activity, signal);
|
|
102882
102930
|
}
|
|
102883
|
-
const _reservation = __using(_stack,
|
|
102931
|
+
const _reservation = __using(_stack, reservation);
|
|
102884
102932
|
signal.throwIfAborted();
|
|
102885
102933
|
await requestInstalledDaemonReleaseSwitch(control.stateDirectory, launch, signal);
|
|
102886
102934
|
await new Promise((resolve21) => {
|
|
@@ -102896,7 +102944,7 @@ async function checkDaemonReleaseUpgrade(signal, activity) {
|
|
|
102896
102944
|
__callDispose(_stack, _error, _hasError);
|
|
102897
102945
|
}
|
|
102898
102946
|
}
|
|
102899
|
-
var SWITCH_COMPLETION_MILLISECONDS, SWITCH_POLL_MILLISECONDS;
|
|
102947
|
+
var SWITCH_COMPLETION_MILLISECONDS, SWITCH_POLL_MILLISECONDS, UPGRADE_QUIET_MILLISECONDS, UPGRADE_QUIET_CHECK_MILLISECONDS;
|
|
102900
102948
|
var init_upgrade2 = __esm({
|
|
102901
102949
|
"src/daemon/upgrades/upgrade.ts"() {
|
|
102902
102950
|
"use strict";
|
|
@@ -102911,6 +102959,8 @@ var init_upgrade2 = __esm({
|
|
|
102911
102959
|
init_package2();
|
|
102912
102960
|
SWITCH_COMPLETION_MILLISECONDS = 3e5;
|
|
102913
102961
|
SWITCH_POLL_MILLISECONDS = 200;
|
|
102962
|
+
UPGRADE_QUIET_MILLISECONDS = 30 * 6e4;
|
|
102963
|
+
UPGRADE_QUIET_CHECK_MILLISECONDS = 6e4;
|
|
102914
102964
|
}
|
|
102915
102965
|
});
|
|
102916
102966
|
|