@moxt-ai/mobius 0.0.143 → 0.0.144

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 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.143",
3384
+ version: "0.0.144",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -42470,15 +42470,21 @@ var turnsSchema = external_exports.object({
42470
42470
  });
42471
42471
  var itemTypeSchema = external_exports.object({ type: external_exports.string().min(1).max(80) });
42472
42472
  var userMessageSchema = external_exports.object({
42473
- content: external_exports.array(external_exports.unknown()).max(1e4)
42473
+ content: external_exports.array(external_exports.unknown()).max(1e4),
42474
+ type: external_exports.literal("userMessage")
42474
42475
  });
42475
42476
  var textSchema = external_exports.object({ text: external_exports.string() });
42476
42477
  var imageSchema = external_exports.object({ url: external_exports.string() });
42477
- var agentMessageSchema = textSchema.extend({ phase: external_exports.string().nullish() });
42478
+ var agentMessageSchema = textSchema.extend({
42479
+ id: external_exports.string().optional(),
42480
+ phase: external_exports.string().nullish(),
42481
+ type: external_exports.literal("agentMessage")
42482
+ });
42478
42483
  var reasoningSchema = external_exports.object({
42479
42484
  id: external_exports.string(),
42480
42485
  summary: external_exports.array(external_exports.string()).max(1e4),
42481
- content: external_exports.array(external_exports.string()).max(1e4)
42486
+ content: external_exports.array(external_exports.string()).max(1e4),
42487
+ type: external_exports.literal("reasoning")
42482
42488
  });
42483
42489
  var commandExecutionSchema = external_exports.object({
42484
42490
  id: external_exports.string(),
@@ -42487,8 +42493,45 @@ var commandExecutionSchema = external_exports.object({
42487
42493
  status: external_exports.string(),
42488
42494
  commandActions: external_exports.array(external_exports.object({ type: external_exports.string() }).passthrough()).max(100),
42489
42495
  aggregatedOutput: external_exports.string().nullish(),
42490
- exitCode: external_exports.number().int().nullish()
42496
+ exitCode: external_exports.number().int().nullish(),
42497
+ type: external_exports.literal("commandExecution")
42498
+ });
42499
+ var fileChangeSchema = external_exports.object({
42500
+ changes: external_exports.array(external_exports.object({ diff: external_exports.string(), path: external_exports.string() })).max(1e4),
42501
+ id: external_exports.string(),
42502
+ status: external_exports.string(),
42503
+ type: external_exports.literal("fileChange")
42504
+ });
42505
+ var mcpToolCallSchema = external_exports.object({
42506
+ arguments: external_exports.unknown().optional(),
42507
+ error: external_exports.unknown().nullish(),
42508
+ id: external_exports.string(),
42509
+ result: external_exports.unknown().nullish(),
42510
+ server: external_exports.string(),
42511
+ status: external_exports.string(),
42512
+ tool: external_exports.string(),
42513
+ type: external_exports.literal("mcpToolCall")
42491
42514
  });
42515
+ var dynamicToolCallSchema = external_exports.object({
42516
+ arguments: external_exports.unknown().optional(),
42517
+ contentItems: external_exports.array(external_exports.unknown()).max(1e4).nullish(),
42518
+ id: external_exports.string(),
42519
+ namespace: external_exports.string().nullish(),
42520
+ status: external_exports.string(),
42521
+ tool: external_exports.string(),
42522
+ type: external_exports.literal("dynamicToolCall")
42523
+ });
42524
+ var planSchema = external_exports.object({ id: external_exports.string(), text: external_exports.string(), type: external_exports.literal("plan") });
42525
+ var historyItemSchema = external_exports.discriminatedUnion("type", [
42526
+ userMessageSchema,
42527
+ agentMessageSchema,
42528
+ reasoningSchema,
42529
+ commandExecutionSchema,
42530
+ fileChangeSchema,
42531
+ mcpToolCallSchema,
42532
+ dynamicToolCallSchema,
42533
+ planSchema
42534
+ ]);
42492
42535
  function bounded(value, maximum) {
42493
42536
  return value.slice(0, maximum);
42494
42537
  }
@@ -42519,6 +42562,33 @@ function errorMessage(value) {
42519
42562
  }
42520
42563
  return JSON.stringify(value) ?? "Codex stopped before completing this turn.";
42521
42564
  }
42565
+ function formatted(value) {
42566
+ if (value === void 0) {
42567
+ return "";
42568
+ }
42569
+ if (typeof value === "string") {
42570
+ return value;
42571
+ }
42572
+ return JSON.stringify(value) ?? "";
42573
+ }
42574
+ function toolStatus(status) {
42575
+ return status === "inProgress" ? "running" : status === "completed" ? "completed" : "failed";
42576
+ }
42577
+ function diffDisplayContent(path3, newText) {
42578
+ return {
42579
+ artifactId: "",
42580
+ data: "",
42581
+ mimeType: "",
42582
+ name: "",
42583
+ newText,
42584
+ oldText: "",
42585
+ path: path3,
42586
+ terminalId: "",
42587
+ text: "",
42588
+ type: "diff",
42589
+ uri: ""
42590
+ };
42591
+ }
42522
42592
  function messageSize(message) {
42523
42593
  return message.text.length + (message.role === "assistant" ? JSON.stringify(message.activities).length + JSON.stringify(message.content).length : 0);
42524
42594
  }
@@ -42556,8 +42626,8 @@ function fitActivities(activities, maximumCharacters) {
42556
42626
  const maximumActivityCharacters = Math.floor(Math.max(0, maximumCharacters - arrayCharacters) / activities.length);
42557
42627
  return activities.map((activity2) => fitActivity(activity2, maximumActivityCharacters));
42558
42628
  }
42559
- function fitHistoryMessage(message) {
42560
- const text2 = message.text.slice(-SESSION_HISTORY_MESSAGE_CHARACTER_LIMIT);
42629
+ function fitHistoryMessage(message, maximumCharacters = SESSION_HISTORY_MESSAGE_CHARACTER_LIMIT) {
42630
+ const text2 = message.text.slice(-maximumCharacters);
42561
42631
  if (message.role === "user") {
42562
42632
  return {
42563
42633
  message: { ...message, text: text2 },
@@ -42567,12 +42637,12 @@ function fitHistoryMessage(message) {
42567
42637
  let activities = message.activities;
42568
42638
  const content = message.content;
42569
42639
  let fitted = { ...message, activities, content, text: text2 };
42570
- if (messageSize(fitted) > SESSION_HISTORY_MESSAGE_CHARACTER_LIMIT && activities.length > 0) {
42571
- const maximumCharacters = SESSION_HISTORY_MESSAGE_CHARACTER_LIMIT - text2.length - JSON.stringify(content).length;
42572
- activities = fitActivities(activities, maximumCharacters);
42640
+ if (messageSize(fitted) > maximumCharacters && activities.length > 0) {
42641
+ const maximumActivityCharacters = maximumCharacters - text2.length - JSON.stringify(content).length;
42642
+ activities = fitActivities(activities, maximumActivityCharacters);
42573
42643
  fitted = { ...fitted, activities };
42574
42644
  }
42575
- const excess = Math.max(0, messageSize(fitted) - SESSION_HISTORY_MESSAGE_CHARACTER_LIMIT);
42645
+ const excess = Math.max(0, messageSize(fitted) - maximumCharacters);
42576
42646
  if (excess > 0) {
42577
42647
  const maximumTextLength = Math.max(0, fitted.text.length - excess);
42578
42648
  fitted = {
@@ -42610,128 +42680,209 @@ function decodeHistory(thread, value, options) {
42610
42680
  let truncated = page.nextCursor != null;
42611
42681
  for (const turn of page.data.toReversed()) {
42612
42682
  const outcome = turnOutcome(turn.status);
42613
- const activities = [];
42614
- let assignedActivityCount = 0;
42683
+ const turnMessageCharacterLimit = Math.max(
42684
+ 1,
42685
+ Math.floor(SESSION_HISTORY_CHARACTER_LIMIT / Math.max(1, turn.items.length + (turn.error == null ? 0 : 1)))
42686
+ );
42615
42687
  let sequence = 0;
42616
42688
  let assistantMessageIndex = null;
42617
- const activitySlice = () => {
42618
- const assigned = activities.slice(assignedActivityCount).slice(-100);
42619
- assignedActivityCount = activities.length;
42620
- return assigned;
42689
+ const append = (message) => {
42690
+ const fitted = fitHistoryMessage(message, turnMessageCharacterLimit);
42691
+ if (fitted.message.text.length === 0 && (fitted.message.images?.length ?? 0) === 0 && (fitted.message.role === "user" || fitted.message.activities.length === 0 && fitted.message.content.length === 0)) {
42692
+ return;
42693
+ }
42694
+ truncated ||= fitted.truncated;
42695
+ messages.push(fitted.message);
42696
+ if (fitted.message.role === "assistant") {
42697
+ assistantMessageIndex = messages.length - 1;
42698
+ }
42699
+ characters += messageSize(fitted.message);
42621
42700
  };
42622
42701
  for (const item of turn.items) {
42623
- const { type } = itemTypeSchema.parse(item);
42624
- let message;
42625
- if (type === "userMessage") {
42626
- const { content } = userMessageSchema.parse(item);
42627
- const text2 = content.map((block) => {
42628
- const { type: type2 } = itemTypeSchema.parse(block);
42629
- if (type2 === "text") {
42702
+ const decoded = historyItemSchema.safeParse(item);
42703
+ if (!decoded.success) {
42704
+ continue;
42705
+ }
42706
+ const historyItem = decoded.data;
42707
+ if (historyItem.type === "userMessage") {
42708
+ const text2 = historyItem.content.map((block) => {
42709
+ const { type } = itemTypeSchema.parse(block);
42710
+ if (type === "text") {
42630
42711
  return textSchema.parse(block).text;
42631
42712
  }
42632
- if (type2 === "image") {
42713
+ if (type === "image") {
42633
42714
  return `[@image](${imageSchema.parse(block).url})`;
42634
42715
  }
42635
42716
  return "[Attachment]";
42636
42717
  }).join("");
42637
- message = {
42718
+ append({
42638
42719
  role: "user",
42639
42720
  text: text2
42640
- };
42641
- } else if (type === "agentMessage") {
42642
- const agent = agentMessageSchema.parse(item);
42643
- if (agent.phase === "commentary") {
42644
- if (options.detail === "rich" && agent.text.length > 0) {
42645
- activities.push(
42646
- activity(`progress-${sequence.toString()}`, "progress", sequence, {
42721
+ });
42722
+ } else if (historyItem.type === "agentMessage") {
42723
+ if (historyItem.phase === "commentary") {
42724
+ if (options.detail === "rich" && historyItem.text.length > 0) {
42725
+ append({
42726
+ activities: [
42727
+ activity(historyItem.id ?? `progress-${sequence.toString()}`, "progress", sequence, {
42728
+ input: "",
42729
+ locations: [],
42730
+ name: "",
42731
+ output: historyItem.text,
42732
+ status: "completed",
42733
+ title: "Progress",
42734
+ toolKind: ""
42735
+ })
42736
+ ],
42737
+ content: [],
42738
+ role: "assistant",
42739
+ text: ""
42740
+ });
42741
+ sequence += 1;
42742
+ }
42743
+ continue;
42744
+ }
42745
+ append({ activities: [], content: [], role: "assistant", text: historyItem.text });
42746
+ } else if (historyItem.type === "reasoning" && options.detail === "rich") {
42747
+ const output2 = (historyItem.summary.length > 0 ? historyItem.summary : historyItem.content).join(
42748
+ "\n\n"
42749
+ );
42750
+ if (output2.length > 0) {
42751
+ append({
42752
+ activities: [
42753
+ activity(historyItem.id, "reasoning", sequence, {
42647
42754
  input: "",
42648
42755
  locations: [],
42649
42756
  name: "",
42650
- output: agent.text,
42757
+ output: output2,
42651
42758
  status: "completed",
42652
- title: "Progress",
42759
+ title: "Reasoning",
42653
42760
  toolKind: ""
42654
42761
  })
42655
- );
42656
- sequence += 1;
42657
- }
42658
- continue;
42762
+ ],
42763
+ content: [],
42764
+ role: "assistant",
42765
+ text: ""
42766
+ });
42767
+ sequence += 1;
42659
42768
  }
42660
- message = { activities: activitySlice(), content: [], role: "assistant", text: agent.text };
42661
- } else if (type === "reasoning" && options.detail === "rich") {
42662
- const reasoning = reasoningSchema.parse(item);
42663
- const output2 = (reasoning.summary.length > 0 ? reasoning.summary : reasoning.content).join("\n\n");
42664
- if (output2.length > 0) {
42665
- activities.push(
42666
- activity(reasoning.id, "reasoning", sequence, {
42769
+ } else if (historyItem.type === "commandExecution" && options.detail === "rich") {
42770
+ const action = historyItem.commandActions[0]?.type ?? "execute";
42771
+ append({
42772
+ activities: [
42773
+ activity(historyItem.id, "tool", sequence, {
42774
+ input: JSON.stringify({ command: historyItem.command, cwd: historyItem.cwd }),
42775
+ locations: [historyItem.cwd],
42776
+ name: "",
42777
+ output: JSON.stringify({
42778
+ formatted_output: historyItem.aggregatedOutput ?? "",
42779
+ ...historyItem.exitCode == null ? {} : { exit_code: historyItem.exitCode }
42780
+ }),
42781
+ status: toolStatus(historyItem.status),
42782
+ title: historyItem.command,
42783
+ toolKind: action
42784
+ })
42785
+ ],
42786
+ content: [],
42787
+ role: "assistant",
42788
+ text: ""
42789
+ });
42790
+ sequence += 1;
42791
+ } else if (historyItem.type === "fileChange" && options.detail === "rich") {
42792
+ const paths = historyItem.changes.map((change) => change.path);
42793
+ const content = historyItem.changes.map(
42794
+ (change) => diffDisplayContent(change.path, change.diff)
42795
+ );
42796
+ append({
42797
+ activities: [
42798
+ activity(historyItem.id, "tool", sequence, {
42799
+ input: JSON.stringify({ changes: paths }),
42800
+ locations: paths,
42801
+ name: "",
42802
+ output: "",
42803
+ status: toolStatus(historyItem.status),
42804
+ title: paths.join(", "),
42805
+ toolKind: "edit"
42806
+ })
42807
+ ].map((entry) => ({ ...entry, content })),
42808
+ content: [],
42809
+ role: "assistant",
42810
+ text: ""
42811
+ });
42812
+ sequence += 1;
42813
+ } else if (historyItem.type === "mcpToolCall" && options.detail === "rich") {
42814
+ append({
42815
+ activities: [
42816
+ activity(historyItem.id, "tool", sequence, {
42817
+ input: formatted(historyItem.arguments),
42818
+ locations: [],
42819
+ name: historyItem.tool,
42820
+ output: formatted(historyItem.error ?? historyItem.result),
42821
+ status: toolStatus(historyItem.status),
42822
+ title: `${historyItem.server}/${historyItem.tool}`,
42823
+ toolKind: "other"
42824
+ })
42825
+ ],
42826
+ content: [],
42827
+ role: "assistant",
42828
+ text: ""
42829
+ });
42830
+ sequence += 1;
42831
+ } else if (historyItem.type === "dynamicToolCall" && options.detail === "rich") {
42832
+ append({
42833
+ activities: [
42834
+ activity(historyItem.id, "tool", sequence, {
42835
+ input: formatted(historyItem.arguments),
42836
+ locations: [],
42837
+ name: historyItem.tool,
42838
+ output: formatted(historyItem.contentItems),
42839
+ status: toolStatus(historyItem.status),
42840
+ title: historyItem.namespace == null ? historyItem.tool : `${historyItem.namespace}/${historyItem.tool}`,
42841
+ toolKind: "other"
42842
+ })
42843
+ ],
42844
+ content: [],
42845
+ role: "assistant",
42846
+ text: ""
42847
+ });
42848
+ sequence += 1;
42849
+ } else if (historyItem.type === "plan" && options.detail === "rich") {
42850
+ append({
42851
+ activities: [
42852
+ activity(historyItem.id, "plan", sequence, {
42667
42853
  input: "",
42668
42854
  locations: [],
42669
42855
  name: "",
42670
- output: output2,
42856
+ output: historyItem.text,
42671
42857
  status: "completed",
42672
- title: "Reasoning",
42858
+ title: "Plan",
42673
42859
  toolKind: ""
42674
42860
  })
42675
- );
42676
- sequence += 1;
42677
- }
42678
- continue;
42679
- } else if (type === "commandExecution" && options.detail === "rich") {
42680
- const command = commandExecutionSchema.parse(item);
42681
- const action = command.commandActions[0]?.type ?? "execute";
42682
- activities.push(
42683
- activity(command.id, "tool", sequence, {
42684
- input: JSON.stringify({ command: command.command, cwd: command.cwd }),
42685
- locations: [command.cwd],
42686
- name: "",
42687
- output: JSON.stringify({
42688
- formatted_output: command.aggregatedOutput ?? "",
42689
- ...command.exitCode == null ? {} : { exit_code: command.exitCode }
42690
- }),
42691
- status: command.status === "completed" ? "completed" : "failed",
42692
- title: command.command,
42693
- toolKind: action
42694
- })
42695
- );
42861
+ ],
42862
+ content: [],
42863
+ role: "assistant",
42864
+ text: ""
42865
+ });
42696
42866
  sequence += 1;
42697
- continue;
42698
- } else {
42699
- continue;
42700
- }
42701
- const fitted = fitHistoryMessage(message);
42702
- if (fitted.message.text.length === 0 && (fitted.message.images?.length ?? 0) === 0) {
42703
- continue;
42704
42867
  }
42705
- truncated ||= fitted.truncated;
42706
- messages.push(fitted.message);
42707
- if (message.role === "assistant") {
42708
- assistantMessageIndex = messages.length - 1;
42709
- }
42710
- characters += messageSize(fitted.message);
42711
42868
  }
42712
42869
  if (options.detail === "rich" && turn.error != null) {
42713
- activities.push(
42714
- activity(`agent-error-${sequence.toString()}`, "tool", sequence, {
42715
- input: "",
42716
- locations: [],
42717
- name: "",
42718
- output: errorMessage(turn.error),
42719
- status: "failed",
42720
- title: "Agent error",
42721
- toolKind: "other"
42722
- })
42723
- );
42724
- }
42725
- if (options.detail === "rich" && activities.length > assignedActivityCount) {
42726
- const message = {
42727
- activities: activitySlice(),
42870
+ append({
42871
+ activities: [
42872
+ activity(`agent-error-${sequence.toString()}`, "tool", sequence, {
42873
+ input: "",
42874
+ locations: [],
42875
+ name: "",
42876
+ output: errorMessage(turn.error),
42877
+ status: "failed",
42878
+ title: "Agent error",
42879
+ toolKind: "other"
42880
+ })
42881
+ ],
42728
42882
  content: [],
42729
42883
  role: "assistant",
42730
42884
  text: ""
42731
- };
42732
- messages.push(message);
42733
- assistantMessageIndex = messages.length - 1;
42734
- characters += messageSize(message);
42885
+ });
42735
42886
  }
42736
42887
  if (assistantMessageIndex !== null) {
42737
42888
  const assistant = messages[assistantMessageIndex];
@@ -42741,20 +42892,20 @@ function decodeHistory(thread, value, options) {
42741
42892
  ...assistant,
42742
42893
  ...outcome === void 0 ? {} : { outcome }
42743
42894
  };
42744
- const fitted = fitHistoryMessage(updated);
42895
+ const fitted = fitHistoryMessage(updated, turnMessageCharacterLimit);
42745
42896
  truncated ||= fitted.truncated;
42746
42897
  messages[assistantMessageIndex] = fitted.message;
42747
42898
  characters += messageSize(fitted.message);
42748
42899
  }
42749
- } else if (activities.length > 0 || outcome !== void 0) {
42900
+ } else if (outcome !== void 0) {
42750
42901
  const message = {
42751
- activities: activities.slice(-100),
42902
+ activities: [],
42752
42903
  content: [],
42753
42904
  role: "assistant",
42754
42905
  ...outcome === void 0 ? {} : { outcome },
42755
42906
  text: ""
42756
42907
  };
42757
- const fitted = fitHistoryMessage(message);
42908
+ const fitted = fitHistoryMessage(message, turnMessageCharacterLimit);
42758
42909
  truncated ||= fitted.truncated;
42759
42910
  messages.push(fitted.message);
42760
42911
  characters += messageSize(fitted.message);