@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/cli.js
CHANGED
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.145",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -29512,6 +29512,23 @@ var activeTurnActivitySchema = external_exports.strictObject({
|
|
|
29512
29512
|
title: external_exports.string().max(500),
|
|
29513
29513
|
toolKind: external_exports.string().max(64)
|
|
29514
29514
|
}).readonly();
|
|
29515
|
+
var activeTurnUserMessageSchema = external_exports.strictObject({
|
|
29516
|
+
id: identifierStringSchema,
|
|
29517
|
+
images: external_exports.array(promptImageSchema).max(8).readonly().optional(),
|
|
29518
|
+
role: external_exports.literal("user"),
|
|
29519
|
+
text: external_exports.string().max(SESSION_HISTORY_CHARACTER_LIMIT)
|
|
29520
|
+
}).readonly();
|
|
29521
|
+
var activeTurnAssistantMessageSchema = external_exports.strictObject({
|
|
29522
|
+
activities: external_exports.array(activeTurnActivitySchema).max(100).readonly().default([]),
|
|
29523
|
+
content: external_exports.array(displayContentSchema).max(100).readonly().default([]),
|
|
29524
|
+
id: identifierStringSchema,
|
|
29525
|
+
role: external_exports.literal("assistant"),
|
|
29526
|
+
text: external_exports.string().max(SESSION_HISTORY_CHARACTER_LIMIT)
|
|
29527
|
+
}).readonly();
|
|
29528
|
+
var activeTurnMessageSchema = external_exports.discriminatedUnion("role", [
|
|
29529
|
+
activeTurnUserMessageSchema,
|
|
29530
|
+
activeTurnAssistantMessageSchema
|
|
29531
|
+
]);
|
|
29515
29532
|
var activeTurnSnapshotSchema = external_exports.strictObject({
|
|
29516
29533
|
activities: external_exports.array(activeTurnActivitySchema).readonly(),
|
|
29517
29534
|
commandId: identifierStringSchema,
|
|
@@ -29521,7 +29538,7 @@ var activeTurnSnapshotSchema = external_exports.strictObject({
|
|
|
29521
29538
|
truncated: external_exports.boolean(),
|
|
29522
29539
|
epoch: identifierStringSchema,
|
|
29523
29540
|
interaction: external_exports.discriminatedUnion("kind", [sessionPermissionRequestedEventSchema, sessionElicitationRequestedEventSchema]).nullable(),
|
|
29524
|
-
messages: external_exports.array(
|
|
29541
|
+
messages: external_exports.array(activeTurnMessageSchema).max(SESSION_HISTORY_MESSAGE_LIMIT).readonly(),
|
|
29525
29542
|
sequence: external_exports.number().int().nonnegative(),
|
|
29526
29543
|
state: external_exports.literal("running")
|
|
29527
29544
|
}).readonly();
|
|
@@ -42099,7 +42116,7 @@ var ActiveDaemonTurn = class {
|
|
|
42099
42116
|
#text = "";
|
|
42100
42117
|
#activities = /* @__PURE__ */ new Map();
|
|
42101
42118
|
#content = /* @__PURE__ */ new Map();
|
|
42102
|
-
#timeline
|
|
42119
|
+
#timeline;
|
|
42103
42120
|
#sequence = 0;
|
|
42104
42121
|
#interaction = null;
|
|
42105
42122
|
#epoch = decodeIdentifier(randomUUID2());
|
|
@@ -42108,6 +42125,9 @@ var ActiveDaemonTurn = class {
|
|
|
42108
42125
|
this.command = command;
|
|
42109
42126
|
this.#controller = new AbortController();
|
|
42110
42127
|
this.#dispatch = { kind: "pending" };
|
|
42128
|
+
this.#timeline = [
|
|
42129
|
+
{ id: decodeIdentifier(command.commandId), images: command.images, kind: "user", text: command.prompt }
|
|
42130
|
+
];
|
|
42111
42131
|
}
|
|
42112
42132
|
enqueue = () => {
|
|
42113
42133
|
if (this.#dispatch.kind !== "pending") {
|
|
@@ -42151,7 +42171,10 @@ var ActiveDaemonTurn = class {
|
|
|
42151
42171
|
}
|
|
42152
42172
|
if (event.kind === AGENT_ACTIVITY_KIND) {
|
|
42153
42173
|
if (!this.#activities.has(event.activityId)) {
|
|
42154
|
-
this.#timeline = [
|
|
42174
|
+
this.#timeline = [
|
|
42175
|
+
...this.#timeline,
|
|
42176
|
+
{ activityId: event.activityId, id: decodeIdentifier(randomUUID2()), kind: "activity" }
|
|
42177
|
+
];
|
|
42155
42178
|
}
|
|
42156
42179
|
this.#activities.set(event.activityId, {
|
|
42157
42180
|
activityId: event.activityId,
|
|
@@ -42169,7 +42192,10 @@ var ActiveDaemonTurn = class {
|
|
|
42169
42192
|
} else if (event.kind === AGENT_ACTIVITY_NARRATION_KIND) {
|
|
42170
42193
|
const previous = this.#activities.get(event.activityId);
|
|
42171
42194
|
if (previous === void 0) {
|
|
42172
|
-
this.#timeline = [
|
|
42195
|
+
this.#timeline = [
|
|
42196
|
+
...this.#timeline,
|
|
42197
|
+
{ activityId: event.activityId, id: decodeIdentifier(randomUUID2()), kind: "activity" }
|
|
42198
|
+
];
|
|
42173
42199
|
}
|
|
42174
42200
|
this.#activities.set(event.activityId, {
|
|
42175
42201
|
activityId: event.activityId,
|
|
@@ -42187,15 +42213,16 @@ var ActiveDaemonTurn = class {
|
|
|
42187
42213
|
} else if (event.kind === AGENT_CONTENT_KIND) {
|
|
42188
42214
|
this.#content.set(event.contentId, event.content);
|
|
42189
42215
|
const target = this.#timeline.findLastIndex(
|
|
42190
|
-
(entry) => entry.kind === "message" && entry.
|
|
42216
|
+
(entry) => entry.kind === "message" && entry.sourceMessageId === event.messageId
|
|
42191
42217
|
);
|
|
42192
42218
|
if (target < 0) {
|
|
42193
42219
|
this.#timeline = [
|
|
42194
42220
|
...this.#timeline,
|
|
42195
42221
|
{
|
|
42196
42222
|
content: /* @__PURE__ */ new Map([[event.contentId, event.content]]),
|
|
42223
|
+
id: decodeIdentifier(randomUUID2()),
|
|
42197
42224
|
kind: "message",
|
|
42198
|
-
|
|
42225
|
+
sourceMessageId: event.messageId,
|
|
42199
42226
|
text: ""
|
|
42200
42227
|
}
|
|
42201
42228
|
];
|
|
@@ -42218,7 +42245,7 @@ var ActiveDaemonTurn = class {
|
|
|
42218
42245
|
let remaining = text2;
|
|
42219
42246
|
while (remaining.length > 0) {
|
|
42220
42247
|
const latest = this.#timeline.at(-1);
|
|
42221
|
-
if (latest?.kind === "message" && latest.
|
|
42248
|
+
if (latest?.kind === "message" && latest.sourceMessageId === messageId) {
|
|
42222
42249
|
const available = SESSION_HISTORY_CHARACTER_LIMIT - latest.text.length;
|
|
42223
42250
|
if (available > 0) {
|
|
42224
42251
|
this.#timeline = [
|
|
@@ -42233,28 +42260,43 @@ var ActiveDaemonTurn = class {
|
|
|
42233
42260
|
...this.#timeline,
|
|
42234
42261
|
{
|
|
42235
42262
|
content: /* @__PURE__ */ new Map(),
|
|
42263
|
+
id: decodeIdentifier(randomUUID2()),
|
|
42236
42264
|
kind: "message",
|
|
42237
|
-
messageId,
|
|
42265
|
+
sourceMessageId: messageId,
|
|
42238
42266
|
text: remaining.slice(0, SESSION_HISTORY_CHARACTER_LIMIT)
|
|
42239
42267
|
}
|
|
42240
42268
|
];
|
|
42241
42269
|
remaining = remaining.slice(SESSION_HISTORY_CHARACTER_LIMIT);
|
|
42242
42270
|
}
|
|
42243
42271
|
}
|
|
42272
|
+
recordSteeringPrompt = (command) => {
|
|
42273
|
+
if (this.#dispatch.kind !== "running" || command.sessionId !== this.command.sessionId || command.targetCommandId !== this.command.commandId) {
|
|
42274
|
+
return null;
|
|
42275
|
+
}
|
|
42276
|
+
this.#timeline = [
|
|
42277
|
+
...this.#timeline,
|
|
42278
|
+
{ id: decodeIdentifier(command.commandId), images: command.images, kind: "user", text: command.prompt }
|
|
42279
|
+
];
|
|
42280
|
+
return this.updated();
|
|
42281
|
+
};
|
|
42244
42282
|
timelineMessages() {
|
|
42245
42283
|
return this.#timeline.flatMap((entry) => {
|
|
42284
|
+
if (entry.kind === "user") {
|
|
42285
|
+
return [{ id: entry.id, images: entry.images, role: "user", text: entry.text }];
|
|
42286
|
+
}
|
|
42246
42287
|
if (entry.kind === "message") {
|
|
42247
42288
|
return [
|
|
42248
42289
|
{
|
|
42249
42290
|
activities: [],
|
|
42250
42291
|
content: [...entry.content.values()],
|
|
42292
|
+
id: entry.id,
|
|
42251
42293
|
role: "assistant",
|
|
42252
42294
|
text: entry.text
|
|
42253
42295
|
}
|
|
42254
42296
|
];
|
|
42255
42297
|
}
|
|
42256
42298
|
const activity2 = this.#activities.get(entry.activityId);
|
|
42257
|
-
return activity2 === void 0 ? [] : [{ activities: [activity2], content: [], role: "assistant", text: "" }];
|
|
42299
|
+
return activity2 === void 0 ? [] : [{ activities: [activity2], content: [], id: entry.id, role: "assistant", text: "" }];
|
|
42258
42300
|
});
|
|
42259
42301
|
}
|
|
42260
42302
|
updated = () => {
|
|
@@ -42364,6 +42406,10 @@ var DaemonTurnRegistry = class {
|
|
|
42364
42406
|
}
|
|
42365
42407
|
return event;
|
|
42366
42408
|
};
|
|
42409
|
+
recordSteeringPrompt = (command) => {
|
|
42410
|
+
const target = this.#turns.get(command.targetCommandId);
|
|
42411
|
+
return target?.recordSteeringPrompt(command) ?? null;
|
|
42412
|
+
};
|
|
42367
42413
|
executionSnapshot = async (matches) => {
|
|
42368
42414
|
const matching = [];
|
|
42369
42415
|
for (const turn of this.#turns.values()) {
|
|
@@ -44773,6 +44819,14 @@ function boundedActiveMessages(messages, messageLimit, characterLimit) {
|
|
|
44773
44819
|
truncated: selected.length !== messages.length
|
|
44774
44820
|
};
|
|
44775
44821
|
}
|
|
44822
|
+
function nativeActiveMessage(message) {
|
|
44823
|
+
return message.role === "user" ? { role: "user", text: message.text } : {
|
|
44824
|
+
activities: message.activities,
|
|
44825
|
+
content: message.content,
|
|
44826
|
+
role: "assistant",
|
|
44827
|
+
text: message.text
|
|
44828
|
+
};
|
|
44829
|
+
}
|
|
44776
44830
|
function paginateAcpSessionHistory(history, sessionId, cursor, limit) {
|
|
44777
44831
|
if (history.status === "unavailable") {
|
|
44778
44832
|
if (cursor !== null) {
|
|
@@ -44805,20 +44859,27 @@ function paginateLiveSessionHistory(history, activeTurn, sessionId, cursor, limi
|
|
|
44805
44859
|
}
|
|
44806
44860
|
if (history.status === "unavailable") {
|
|
44807
44861
|
const bounded3 = boundedActiveMessages(
|
|
44808
|
-
activeTurn.messages,
|
|
44809
|
-
|
|
44810
|
-
|
|
44862
|
+
activeTurn.messages.map(nativeActiveMessage),
|
|
44863
|
+
limit,
|
|
44864
|
+
SESSION_HISTORY_CHARACTER_LIMIT
|
|
44811
44865
|
);
|
|
44812
44866
|
return {
|
|
44813
44867
|
coveredCommandIds: [],
|
|
44814
44868
|
coveredMessageIds: [],
|
|
44815
|
-
messages:
|
|
44869
|
+
messages: bounded3.messages,
|
|
44816
44870
|
nextCursor: null,
|
|
44817
44871
|
status: "available",
|
|
44818
44872
|
truncated: activeTurn.truncated || bounded3.truncated
|
|
44819
44873
|
};
|
|
44820
44874
|
}
|
|
44821
|
-
const
|
|
44875
|
+
const activeRoot = activeTurn.messages.find(
|
|
44876
|
+
(message) => message.role === "user" && message.id === activeTurn.commandId
|
|
44877
|
+
);
|
|
44878
|
+
const coveredActiveRoot = history.coveredCommandIds.includes(activeTurn.commandId);
|
|
44879
|
+
const matchingActiveUserIndex = coveredActiveRoot ? history.messages.findLastIndex(
|
|
44880
|
+
(message) => message.role === "user" && message.text === (activeRoot?.text ?? activeTurn.prompt)
|
|
44881
|
+
) : -1;
|
|
44882
|
+
const activeUserIndex = matchingActiveUserIndex >= 0 ? matchingActiveUserIndex : liveHistoryCoveredTurnRanges(history).find((range) => range.commandId === activeTurn.commandId)?.userIndex ?? -1;
|
|
44822
44883
|
if (activeUserIndex >= 0) {
|
|
44823
44884
|
history = {
|
|
44824
44885
|
...history,
|
|
@@ -44830,19 +44891,13 @@ function paginateLiveSessionHistory(history, activeTurn, sessionId, cursor, limi
|
|
|
44830
44891
|
};
|
|
44831
44892
|
}
|
|
44832
44893
|
const latestNativeMessage = history.messages.at(-1);
|
|
44833
|
-
const
|
|
44834
|
-
const
|
|
44835
|
-
|
|
44836
|
-
|
|
44837
|
-
Math.max(0, SESSION_HISTORY_CHARACTER_LIMIT - (includeActivePrompt ? activeTurn.prompt.length : 0))
|
|
44838
|
-
);
|
|
44839
|
-
const activeMessages = [
|
|
44840
|
-
...includeActivePrompt ? [{ role: "user", text: activeTurn.prompt }] : [],
|
|
44841
|
-
...bounded2.messages
|
|
44842
|
-
];
|
|
44894
|
+
const firstActiveMessage = activeTurn.messages[0];
|
|
44895
|
+
const preserveNativeRoot = activeUserIndex >= 0 || firstActiveMessage?.role === "user" && latestNativeMessage?.role === "user" && latestNativeMessage.text === firstActiveMessage.text;
|
|
44896
|
+
const activeMessages = activeTurn.messages.slice(preserveNativeRoot ? 1 : 0).map(nativeActiveMessage);
|
|
44897
|
+
const bounded2 = boundedActiveMessages(activeMessages, limit, SESSION_HISTORY_CHARACTER_LIMIT);
|
|
44843
44898
|
let historicalMessageCount = 0;
|
|
44844
|
-
let remainingCharacters = SESSION_HISTORY_CHARACTER_LIMIT - bounded2.characters
|
|
44845
|
-
const historicalMessageLimit = Math.max(0, limit -
|
|
44899
|
+
let remainingCharacters = SESSION_HISTORY_CHARACTER_LIMIT - bounded2.characters;
|
|
44900
|
+
const historicalMessageLimit = Math.max(0, limit - bounded2.messages.length);
|
|
44846
44901
|
for (let index = history.messages.length - 1; index >= 0 && historicalMessageCount < historicalMessageLimit; index -= 1) {
|
|
44847
44902
|
const message = history.messages[index];
|
|
44848
44903
|
if (message === void 0) {
|
|
@@ -44865,7 +44920,7 @@ function paginateLiveSessionHistory(history, activeTurn, sessionId, cursor, limi
|
|
|
44865
44920
|
} : paginateAcpSessionHistory(history, sessionId, null, historicalMessageCount);
|
|
44866
44921
|
return {
|
|
44867
44922
|
...page,
|
|
44868
|
-
messages: [...page.messages, ...
|
|
44923
|
+
messages: [...page.messages, ...bounded2.messages],
|
|
44869
44924
|
truncated: page.truncated || activeTurn.truncated || bounded2.truncated
|
|
44870
44925
|
};
|
|
44871
44926
|
}
|
|
@@ -45316,6 +45371,7 @@ async function executePrompt({
|
|
|
45316
45371
|
timer,
|
|
45317
45372
|
signal,
|
|
45318
45373
|
recordLiveEvent,
|
|
45374
|
+
recordSteeringPrompt,
|
|
45319
45375
|
cancellationRequested
|
|
45320
45376
|
}) {
|
|
45321
45377
|
const events = new CoalescingAgentEventPublisher(timer, (event) => {
|
|
@@ -45396,6 +45452,17 @@ async function executePrompt({
|
|
|
45396
45452
|
sessionId: command.sessionId
|
|
45397
45453
|
});
|
|
45398
45454
|
operations.transitionExecution(command.commandId, "running");
|
|
45455
|
+
if (availability.disposition === SessionPromptDisposition.Steer) {
|
|
45456
|
+
const updated = recordSteeringPrompt();
|
|
45457
|
+
if (updated === null) {
|
|
45458
|
+
throw new AcpExecutionError(
|
|
45459
|
+
"The steering target is unavailable",
|
|
45460
|
+
{},
|
|
45461
|
+
"prompt_queue_target_unavailable"
|
|
45462
|
+
);
|
|
45463
|
+
}
|
|
45464
|
+
publisher.publish(command.sessionId, updated);
|
|
45465
|
+
}
|
|
45399
45466
|
const stream = activateAttempt();
|
|
45400
45467
|
publisher.publish(command.sessionId, {
|
|
45401
45468
|
commandId: command.commandId,
|
|
@@ -46015,6 +46082,7 @@ function createDaemonCommandHandler({
|
|
|
46015
46082
|
timer,
|
|
46016
46083
|
signal: turn.signal,
|
|
46017
46084
|
recordLiveEvent: turn.recordEvent,
|
|
46085
|
+
recordSteeringPrompt: () => activeTurns.recordSteeringPrompt(command),
|
|
46018
46086
|
cancellationRequested: turn.cancellationRequested
|
|
46019
46087
|
}).catch((error62) => {
|
|
46020
46088
|
console.error("Mobius daemon turn failed", error62);
|