@moxt-ai/mobius 0.0.144 → 0.0.145
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 +96 -28
- package/dist/cli.js.map +2 -2
- package/dist/daemon-active-turn.d.ts +1 -0
- package/dist/daemon-active-turn.d.ts.map +1 -1
- package/dist/daemon-active-turn.js +37 -8
- package/dist/daemon-active-turn.js.map +1 -1
- package/dist/daemon-command-handler.d.ts.map +1 -1
- package/dist/daemon-command-handler.js +1 -0
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-prompt-executor.d.ts +2 -1
- package/dist/daemon-prompt-executor.d.ts.map +1 -1
- package/dist/daemon-prompt-executor.js +8 -1
- package/dist/daemon-prompt-executor.js.map +1 -1
- package/dist/daemon-turn-registry.d.ts +13 -8
- package/dist/daemon-turn-registry.d.ts.map +1 -1
- package/dist/daemon-turn-registry.js +4 -0
- package/dist/daemon-turn-registry.js.map +1 -1
- package/dist/index.js +95 -27
- package/dist/index.js.map +2 -2
- package/dist/native-sessions/live-history-page.d.ts.map +1 -1
- package/dist/native-sessions/live-history-page.js +34 -17
- package/dist/native-sessions/live-history-page.js.map +1 -1
- package/dist/runtime.js +95 -27
- package/dist/runtime.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21026,6 +21026,23 @@ var activeTurnActivitySchema = external_exports.strictObject({
|
|
|
21026
21026
|
title: external_exports.string().max(500),
|
|
21027
21027
|
toolKind: external_exports.string().max(64)
|
|
21028
21028
|
}).readonly();
|
|
21029
|
+
var activeTurnUserMessageSchema = external_exports.strictObject({
|
|
21030
|
+
id: identifierStringSchema,
|
|
21031
|
+
images: external_exports.array(promptImageSchema).max(8).readonly().optional(),
|
|
21032
|
+
role: external_exports.literal("user"),
|
|
21033
|
+
text: external_exports.string().max(SESSION_HISTORY_CHARACTER_LIMIT)
|
|
21034
|
+
}).readonly();
|
|
21035
|
+
var activeTurnAssistantMessageSchema = external_exports.strictObject({
|
|
21036
|
+
activities: external_exports.array(activeTurnActivitySchema).max(100).readonly().default([]),
|
|
21037
|
+
content: external_exports.array(displayContentSchema).max(100).readonly().default([]),
|
|
21038
|
+
id: identifierStringSchema,
|
|
21039
|
+
role: external_exports.literal("assistant"),
|
|
21040
|
+
text: external_exports.string().max(SESSION_HISTORY_CHARACTER_LIMIT)
|
|
21041
|
+
}).readonly();
|
|
21042
|
+
var activeTurnMessageSchema = external_exports.discriminatedUnion("role", [
|
|
21043
|
+
activeTurnUserMessageSchema,
|
|
21044
|
+
activeTurnAssistantMessageSchema
|
|
21045
|
+
]);
|
|
21029
21046
|
var activeTurnSnapshotSchema = external_exports.strictObject({
|
|
21030
21047
|
activities: external_exports.array(activeTurnActivitySchema).readonly(),
|
|
21031
21048
|
commandId: identifierStringSchema,
|
|
@@ -21035,7 +21052,7 @@ var activeTurnSnapshotSchema = external_exports.strictObject({
|
|
|
21035
21052
|
truncated: external_exports.boolean(),
|
|
21036
21053
|
epoch: identifierStringSchema,
|
|
21037
21054
|
interaction: external_exports.discriminatedUnion("kind", [sessionPermissionRequestedEventSchema, sessionElicitationRequestedEventSchema]).nullable(),
|
|
21038
|
-
messages: external_exports.array(
|
|
21055
|
+
messages: external_exports.array(activeTurnMessageSchema).max(SESSION_HISTORY_MESSAGE_LIMIT).readonly(),
|
|
21039
21056
|
sequence: external_exports.number().int().nonnegative(),
|
|
21040
21057
|
state: external_exports.literal("running")
|
|
21041
21058
|
}).readonly();
|
|
@@ -38658,7 +38675,7 @@ var ActiveDaemonTurn = class {
|
|
|
38658
38675
|
#text = "";
|
|
38659
38676
|
#activities = /* @__PURE__ */ new Map();
|
|
38660
38677
|
#content = /* @__PURE__ */ new Map();
|
|
38661
|
-
#timeline
|
|
38678
|
+
#timeline;
|
|
38662
38679
|
#sequence = 0;
|
|
38663
38680
|
#interaction = null;
|
|
38664
38681
|
#epoch = decodeIdentifier(randomUUID2());
|
|
@@ -38667,6 +38684,9 @@ var ActiveDaemonTurn = class {
|
|
|
38667
38684
|
this.command = command;
|
|
38668
38685
|
this.#controller = new AbortController();
|
|
38669
38686
|
this.#dispatch = { kind: "pending" };
|
|
38687
|
+
this.#timeline = [
|
|
38688
|
+
{ id: decodeIdentifier(command.commandId), images: command.images, kind: "user", text: command.prompt }
|
|
38689
|
+
];
|
|
38670
38690
|
}
|
|
38671
38691
|
enqueue = () => {
|
|
38672
38692
|
if (this.#dispatch.kind !== "pending") {
|
|
@@ -38710,7 +38730,10 @@ var ActiveDaemonTurn = class {
|
|
|
38710
38730
|
}
|
|
38711
38731
|
if (event.kind === AGENT_ACTIVITY_KIND) {
|
|
38712
38732
|
if (!this.#activities.has(event.activityId)) {
|
|
38713
|
-
this.#timeline = [
|
|
38733
|
+
this.#timeline = [
|
|
38734
|
+
...this.#timeline,
|
|
38735
|
+
{ activityId: event.activityId, id: decodeIdentifier(randomUUID2()), kind: "activity" }
|
|
38736
|
+
];
|
|
38714
38737
|
}
|
|
38715
38738
|
this.#activities.set(event.activityId, {
|
|
38716
38739
|
activityId: event.activityId,
|
|
@@ -38728,7 +38751,10 @@ var ActiveDaemonTurn = class {
|
|
|
38728
38751
|
} else if (event.kind === AGENT_ACTIVITY_NARRATION_KIND) {
|
|
38729
38752
|
const previous = this.#activities.get(event.activityId);
|
|
38730
38753
|
if (previous === void 0) {
|
|
38731
|
-
this.#timeline = [
|
|
38754
|
+
this.#timeline = [
|
|
38755
|
+
...this.#timeline,
|
|
38756
|
+
{ activityId: event.activityId, id: decodeIdentifier(randomUUID2()), kind: "activity" }
|
|
38757
|
+
];
|
|
38732
38758
|
}
|
|
38733
38759
|
this.#activities.set(event.activityId, {
|
|
38734
38760
|
activityId: event.activityId,
|
|
@@ -38746,15 +38772,16 @@ var ActiveDaemonTurn = class {
|
|
|
38746
38772
|
} else if (event.kind === AGENT_CONTENT_KIND) {
|
|
38747
38773
|
this.#content.set(event.contentId, event.content);
|
|
38748
38774
|
const target = this.#timeline.findLastIndex(
|
|
38749
|
-
(entry) => entry.kind === "message" && entry.
|
|
38775
|
+
(entry) => entry.kind === "message" && entry.sourceMessageId === event.messageId
|
|
38750
38776
|
);
|
|
38751
38777
|
if (target < 0) {
|
|
38752
38778
|
this.#timeline = [
|
|
38753
38779
|
...this.#timeline,
|
|
38754
38780
|
{
|
|
38755
38781
|
content: /* @__PURE__ */ new Map([[event.contentId, event.content]]),
|
|
38782
|
+
id: decodeIdentifier(randomUUID2()),
|
|
38756
38783
|
kind: "message",
|
|
38757
|
-
|
|
38784
|
+
sourceMessageId: event.messageId,
|
|
38758
38785
|
text: ""
|
|
38759
38786
|
}
|
|
38760
38787
|
];
|
|
@@ -38777,7 +38804,7 @@ var ActiveDaemonTurn = class {
|
|
|
38777
38804
|
let remaining = text2;
|
|
38778
38805
|
while (remaining.length > 0) {
|
|
38779
38806
|
const latest = this.#timeline.at(-1);
|
|
38780
|
-
if (latest?.kind === "message" && latest.
|
|
38807
|
+
if (latest?.kind === "message" && latest.sourceMessageId === messageId) {
|
|
38781
38808
|
const available = SESSION_HISTORY_CHARACTER_LIMIT - latest.text.length;
|
|
38782
38809
|
if (available > 0) {
|
|
38783
38810
|
this.#timeline = [
|
|
@@ -38792,28 +38819,43 @@ var ActiveDaemonTurn = class {
|
|
|
38792
38819
|
...this.#timeline,
|
|
38793
38820
|
{
|
|
38794
38821
|
content: /* @__PURE__ */ new Map(),
|
|
38822
|
+
id: decodeIdentifier(randomUUID2()),
|
|
38795
38823
|
kind: "message",
|
|
38796
|
-
messageId,
|
|
38824
|
+
sourceMessageId: messageId,
|
|
38797
38825
|
text: remaining.slice(0, SESSION_HISTORY_CHARACTER_LIMIT)
|
|
38798
38826
|
}
|
|
38799
38827
|
];
|
|
38800
38828
|
remaining = remaining.slice(SESSION_HISTORY_CHARACTER_LIMIT);
|
|
38801
38829
|
}
|
|
38802
38830
|
}
|
|
38831
|
+
recordSteeringPrompt = (command) => {
|
|
38832
|
+
if (this.#dispatch.kind !== "running" || command.sessionId !== this.command.sessionId || command.targetCommandId !== this.command.commandId) {
|
|
38833
|
+
return null;
|
|
38834
|
+
}
|
|
38835
|
+
this.#timeline = [
|
|
38836
|
+
...this.#timeline,
|
|
38837
|
+
{ id: decodeIdentifier(command.commandId), images: command.images, kind: "user", text: command.prompt }
|
|
38838
|
+
];
|
|
38839
|
+
return this.updated();
|
|
38840
|
+
};
|
|
38803
38841
|
timelineMessages() {
|
|
38804
38842
|
return this.#timeline.flatMap((entry) => {
|
|
38843
|
+
if (entry.kind === "user") {
|
|
38844
|
+
return [{ id: entry.id, images: entry.images, role: "user", text: entry.text }];
|
|
38845
|
+
}
|
|
38805
38846
|
if (entry.kind === "message") {
|
|
38806
38847
|
return [
|
|
38807
38848
|
{
|
|
38808
38849
|
activities: [],
|
|
38809
38850
|
content: [...entry.content.values()],
|
|
38851
|
+
id: entry.id,
|
|
38810
38852
|
role: "assistant",
|
|
38811
38853
|
text: entry.text
|
|
38812
38854
|
}
|
|
38813
38855
|
];
|
|
38814
38856
|
}
|
|
38815
38857
|
const activity2 = this.#activities.get(entry.activityId);
|
|
38816
|
-
return activity2 === void 0 ? [] : [{ activities: [activity2], content: [], role: "assistant", text: "" }];
|
|
38858
|
+
return activity2 === void 0 ? [] : [{ activities: [activity2], content: [], id: entry.id, role: "assistant", text: "" }];
|
|
38817
38859
|
});
|
|
38818
38860
|
}
|
|
38819
38861
|
updated = () => {
|
|
@@ -38923,6 +38965,10 @@ var DaemonTurnRegistry = class {
|
|
|
38923
38965
|
}
|
|
38924
38966
|
return event;
|
|
38925
38967
|
};
|
|
38968
|
+
recordSteeringPrompt = (command) => {
|
|
38969
|
+
const target = this.#turns.get(command.targetCommandId);
|
|
38970
|
+
return target?.recordSteeringPrompt(command) ?? null;
|
|
38971
|
+
};
|
|
38926
38972
|
executionSnapshot = async (matches) => {
|
|
38927
38973
|
const matching = [];
|
|
38928
38974
|
for (const turn of this.#turns.values()) {
|
|
@@ -41332,6 +41378,14 @@ function boundedActiveMessages(messages, messageLimit, characterLimit) {
|
|
|
41332
41378
|
truncated: selected.length !== messages.length
|
|
41333
41379
|
};
|
|
41334
41380
|
}
|
|
41381
|
+
function nativeActiveMessage(message) {
|
|
41382
|
+
return message.role === "user" ? { role: "user", text: message.text } : {
|
|
41383
|
+
activities: message.activities,
|
|
41384
|
+
content: message.content,
|
|
41385
|
+
role: "assistant",
|
|
41386
|
+
text: message.text
|
|
41387
|
+
};
|
|
41388
|
+
}
|
|
41335
41389
|
function paginateAcpSessionHistory(history, sessionId, cursor, limit) {
|
|
41336
41390
|
if (history.status === "unavailable") {
|
|
41337
41391
|
if (cursor !== null) {
|
|
@@ -41364,20 +41418,27 @@ function paginateLiveSessionHistory(history, activeTurn, sessionId, cursor, limi
|
|
|
41364
41418
|
}
|
|
41365
41419
|
if (history.status === "unavailable") {
|
|
41366
41420
|
const bounded3 = boundedActiveMessages(
|
|
41367
|
-
activeTurn.messages,
|
|
41368
|
-
|
|
41369
|
-
|
|
41421
|
+
activeTurn.messages.map(nativeActiveMessage),
|
|
41422
|
+
limit,
|
|
41423
|
+
SESSION_HISTORY_CHARACTER_LIMIT
|
|
41370
41424
|
);
|
|
41371
41425
|
return {
|
|
41372
41426
|
coveredCommandIds: [],
|
|
41373
41427
|
coveredMessageIds: [],
|
|
41374
|
-
messages:
|
|
41428
|
+
messages: bounded3.messages,
|
|
41375
41429
|
nextCursor: null,
|
|
41376
41430
|
status: "available",
|
|
41377
41431
|
truncated: activeTurn.truncated || bounded3.truncated
|
|
41378
41432
|
};
|
|
41379
41433
|
}
|
|
41380
|
-
const
|
|
41434
|
+
const activeRoot = activeTurn.messages.find(
|
|
41435
|
+
(message) => message.role === "user" && message.id === activeTurn.commandId
|
|
41436
|
+
);
|
|
41437
|
+
const coveredActiveRoot = history.coveredCommandIds.includes(activeTurn.commandId);
|
|
41438
|
+
const matchingActiveUserIndex = coveredActiveRoot ? history.messages.findLastIndex(
|
|
41439
|
+
(message) => message.role === "user" && message.text === (activeRoot?.text ?? activeTurn.prompt)
|
|
41440
|
+
) : -1;
|
|
41441
|
+
const activeUserIndex = matchingActiveUserIndex >= 0 ? matchingActiveUserIndex : liveHistoryCoveredTurnRanges(history).find((range) => range.commandId === activeTurn.commandId)?.userIndex ?? -1;
|
|
41381
41442
|
if (activeUserIndex >= 0) {
|
|
41382
41443
|
history = {
|
|
41383
41444
|
...history,
|
|
@@ -41389,19 +41450,13 @@ function paginateLiveSessionHistory(history, activeTurn, sessionId, cursor, limi
|
|
|
41389
41450
|
};
|
|
41390
41451
|
}
|
|
41391
41452
|
const latestNativeMessage = history.messages.at(-1);
|
|
41392
|
-
const
|
|
41393
|
-
const
|
|
41394
|
-
|
|
41395
|
-
|
|
41396
|
-
Math.max(0, SESSION_HISTORY_CHARACTER_LIMIT - (includeActivePrompt ? activeTurn.prompt.length : 0))
|
|
41397
|
-
);
|
|
41398
|
-
const activeMessages = [
|
|
41399
|
-
...includeActivePrompt ? [{ role: "user", text: activeTurn.prompt }] : [],
|
|
41400
|
-
...bounded2.messages
|
|
41401
|
-
];
|
|
41453
|
+
const firstActiveMessage = activeTurn.messages[0];
|
|
41454
|
+
const preserveNativeRoot = activeUserIndex >= 0 || firstActiveMessage?.role === "user" && latestNativeMessage?.role === "user" && latestNativeMessage.text === firstActiveMessage.text;
|
|
41455
|
+
const activeMessages = activeTurn.messages.slice(preserveNativeRoot ? 1 : 0).map(nativeActiveMessage);
|
|
41456
|
+
const bounded2 = boundedActiveMessages(activeMessages, limit, SESSION_HISTORY_CHARACTER_LIMIT);
|
|
41402
41457
|
let historicalMessageCount = 0;
|
|
41403
|
-
let remainingCharacters = SESSION_HISTORY_CHARACTER_LIMIT - bounded2.characters
|
|
41404
|
-
const historicalMessageLimit = Math.max(0, limit -
|
|
41458
|
+
let remainingCharacters = SESSION_HISTORY_CHARACTER_LIMIT - bounded2.characters;
|
|
41459
|
+
const historicalMessageLimit = Math.max(0, limit - bounded2.messages.length);
|
|
41405
41460
|
for (let index = history.messages.length - 1; index >= 0 && historicalMessageCount < historicalMessageLimit; index -= 1) {
|
|
41406
41461
|
const message = history.messages[index];
|
|
41407
41462
|
if (message === void 0) {
|
|
@@ -41424,7 +41479,7 @@ function paginateLiveSessionHistory(history, activeTurn, sessionId, cursor, limi
|
|
|
41424
41479
|
} : paginateAcpSessionHistory(history, sessionId, null, historicalMessageCount);
|
|
41425
41480
|
return {
|
|
41426
41481
|
...page,
|
|
41427
|
-
messages: [...page.messages, ...
|
|
41482
|
+
messages: [...page.messages, ...bounded2.messages],
|
|
41428
41483
|
truncated: page.truncated || activeTurn.truncated || bounded2.truncated
|
|
41429
41484
|
};
|
|
41430
41485
|
}
|
|
@@ -41875,6 +41930,7 @@ async function executePrompt({
|
|
|
41875
41930
|
timer,
|
|
41876
41931
|
signal,
|
|
41877
41932
|
recordLiveEvent,
|
|
41933
|
+
recordSteeringPrompt,
|
|
41878
41934
|
cancellationRequested
|
|
41879
41935
|
}) {
|
|
41880
41936
|
const events = new CoalescingAgentEventPublisher(timer, (event) => {
|
|
@@ -41955,6 +42011,17 @@ async function executePrompt({
|
|
|
41955
42011
|
sessionId: command.sessionId
|
|
41956
42012
|
});
|
|
41957
42013
|
operations.transitionExecution(command.commandId, "running");
|
|
42014
|
+
if (availability.disposition === SessionPromptDisposition.Steer) {
|
|
42015
|
+
const updated = recordSteeringPrompt();
|
|
42016
|
+
if (updated === null) {
|
|
42017
|
+
throw new AcpExecutionError(
|
|
42018
|
+
"The steering target is unavailable",
|
|
42019
|
+
{},
|
|
42020
|
+
"prompt_queue_target_unavailable"
|
|
42021
|
+
);
|
|
42022
|
+
}
|
|
42023
|
+
publisher.publish(command.sessionId, updated);
|
|
42024
|
+
}
|
|
41958
42025
|
const stream = activateAttempt();
|
|
41959
42026
|
publisher.publish(command.sessionId, {
|
|
41960
42027
|
commandId: command.commandId,
|
|
@@ -42574,6 +42641,7 @@ function createDaemonCommandHandler({
|
|
|
42574
42641
|
timer,
|
|
42575
42642
|
signal: turn.signal,
|
|
42576
42643
|
recordLiveEvent: turn.recordEvent,
|
|
42644
|
+
recordSteeringPrompt: () => activeTurns.recordSteeringPrompt(command),
|
|
42577
42645
|
cancellationRequested: turn.cancellationRequested
|
|
42578
42646
|
}).catch((error62) => {
|
|
42579
42647
|
console.error("Mobius daemon turn failed", error62);
|