@moxt-ai/mobius 0.0.352 → 0.0.354

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/engine.js CHANGED
@@ -19956,12 +19956,12 @@ function decodeRuntimeLivenessReadyEvent(encoded) {
19956
19956
  function decodeRuntimeHeartbeatEvent(encoded) {
19957
19957
  const value = parseJson(encoded);
19958
19958
  assertKind(value, RUNTIME_HEARTBEAT_KIND);
19959
- return "heartbeatId" in value ? { heartbeatId: readIdentifier(value, "heartbeatId"), kind: RUNTIME_HEARTBEAT_KIND } : { kind: RUNTIME_HEARTBEAT_KIND };
19959
+ return { kind: RUNTIME_HEARTBEAT_KIND };
19960
19960
  }
19961
19961
  function decodeRuntimeHeartbeatAckEvent(encoded) {
19962
19962
  const value = parseJson(encoded);
19963
19963
  assertKind(value, RUNTIME_HEARTBEAT_ACK_KIND);
19964
- return "heartbeatId" in value ? { heartbeatId: readIdentifier(value, "heartbeatId"), kind: RUNTIME_HEARTBEAT_ACK_KIND } : { kind: RUNTIME_HEARTBEAT_ACK_KIND };
19964
+ return { kind: RUNTIME_HEARTBEAT_ACK_KIND };
19965
19965
  }
19966
19966
  function decodeRuntimePingCommand(encoded) {
19967
19967
  const value = parseJson(encoded);
@@ -19977,12 +19977,12 @@ function encodeRuntimeLivenessReadyEvent(message) {
19977
19977
  return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
19978
19978
  }
19979
19979
  function encodeRuntimeHeartbeatEvent(message) {
19980
- const decoded = decodeRuntimeHeartbeatEvent(JSON.stringify(message));
19981
- return "heartbeatId" in decoded ? JSON.stringify(decoded) : RUNTIME_HEARTBEAT_MESSAGE;
19980
+ decodeRuntimeHeartbeatEvent(JSON.stringify(message));
19981
+ return RUNTIME_HEARTBEAT_MESSAGE;
19982
19982
  }
19983
19983
  function encodeRuntimeHeartbeatAckEvent(message) {
19984
- const decoded = decodeRuntimeHeartbeatAckEvent(JSON.stringify(message));
19985
- return "heartbeatId" in decoded ? JSON.stringify(decoded) : RUNTIME_HEARTBEAT_ACK_MESSAGE;
19984
+ decodeRuntimeHeartbeatAckEvent(JSON.stringify(message));
19985
+ return RUNTIME_HEARTBEAT_ACK_MESSAGE;
19986
19986
  }
19987
19987
  function encodeRuntimePingCommand(message) {
19988
19988
  return JSON.stringify(decodeRuntimePingCommand(JSON.stringify(message)));
@@ -59903,14 +59903,16 @@ function listEnvironmentSessions(environment, cwd, signal) {
59903
59903
 
59904
59904
  // src/engine/acp/harness/claude/upstream/dist/environment-session-messages.js
59905
59905
  var SESSION_MESSAGES_TIMEOUT_MILLISECONDS = 3e4;
59906
- function getEnvironmentSessionMessages(environment, sessionId, signal) {
59906
+ function getEnvironmentSessionMessages(environment, sessionId, cancellationSignal) {
59907
+ const signal = AbortSignal.any([cancellationSignal, AbortSignal.timeout(SESSION_MESSAGES_TIMEOUT_MILLISECONDS)]);
59907
59908
  return withEnvironment(environment, () => withDeadline(signal, SESSION_MESSAGES_TIMEOUT_MILLISECONDS, async () => {
59908
- const messages = await FZt(sessionId);
59909
59909
  const authenticationFailures = /* @__PURE__ */ new Set();
59910
+ const transcript = [];
59910
59911
  const nativeMetadata = /* @__PURE__ */ new Map();
59911
59912
  await GZt(sessionId, {
59912
59913
  append: async (_key, entries) => {
59913
59914
  signal.throwIfAborted();
59915
+ transcript.push(...entries);
59914
59916
  for (const entry of entries) {
59915
59917
  if (entry.type === "user" && typeof entry.uuid === "string") {
59916
59918
  nativeMetadata.set(entry.uuid, {
@@ -59926,9 +59928,143 @@ function getEnvironmentSessionMessages(environment, sessionId, signal) {
59926
59928
  load: async () => null
59927
59929
  }, { includeSubagents: false });
59928
59930
  signal.throwIfAborted();
59931
+ const messages = await readFullHistory(transcript, sessionId, signal) ?? await FZt(sessionId);
59929
59932
  return messages.filter((message) => !authenticationFailures.has(message.uuid)).map((message) => ({ ...message, ...nativeMetadata.get(message.uuid) }));
59930
59933
  }));
59931
59934
  }
59935
+ var chainEntrySchema = external_exports.object({
59936
+ type: external_exports.enum(["user", "assistant", "system", "progress", "attachment"]),
59937
+ uuid: external_exports.string(),
59938
+ parentUuid: external_exports.string().nullable(),
59939
+ logicalParentUuid: external_exports.string().nullable().optional(),
59940
+ subtype: external_exports.string().optional(),
59941
+ isCompactSummary: external_exports.boolean().optional(),
59942
+ compactMetadata: external_exports.object({
59943
+ preservedSegment: external_exports.object({ headUuid: external_exports.string(), tailUuid: external_exports.string(), anchorUuid: external_exports.string() }).optional(),
59944
+ preservedMessages: external_exports.object({ uuids: external_exports.array(external_exports.string()), anchorUuid: external_exports.string() }).optional()
59945
+ }).passthrough().optional()
59946
+ }).passthrough();
59947
+ async function readFullHistory(transcript, sessionId, signal) {
59948
+ const entries = /* @__PURE__ */ new Map();
59949
+ for (const [index2, raw] of transcript.entries()) {
59950
+ signal.throwIfAborted();
59951
+ if (typeof raw.uuid !== "string") {
59952
+ continue;
59953
+ }
59954
+ if (!["user", "assistant", "system", "progress", "attachment"].includes(raw.type)) {
59955
+ continue;
59956
+ }
59957
+ const parsed = chainEntrySchema.safeParse(raw);
59958
+ if (!parsed.success) {
59959
+ return null;
59960
+ }
59961
+ entries.set(parsed.data.uuid, { entry: parsed.data, index: index2 });
59962
+ }
59963
+ const validated = /* @__PURE__ */ new Set();
59964
+ for (const uuid3 of entries.keys()) {
59965
+ signal.throwIfAborted();
59966
+ const visiting = /* @__PURE__ */ new Set();
59967
+ let current = uuid3;
59968
+ while (current !== null && !validated.has(current)) {
59969
+ const node2 = entries.get(current);
59970
+ if (node2 === void 0 || visiting.has(current)) {
59971
+ return null;
59972
+ }
59973
+ visiting.add(current);
59974
+ const entry = node2.entry;
59975
+ current = entry.subtype === "compact_boundary" ? entry.logicalParentUuid ?? entry.parentUuid : entry.parentUuid;
59976
+ }
59977
+ for (const id of visiting) {
59978
+ validated.add(id);
59979
+ }
59980
+ }
59981
+ for (const { entry } of entries.values()) {
59982
+ if (entry.subtype !== "compact_boundary") {
59983
+ continue;
59984
+ }
59985
+ const preserved = entry.compactMetadata;
59986
+ const references = preserved?.preservedMessages !== void 0 ? [...preserved.preservedMessages.uuids, preserved.preservedMessages.anchorUuid] : preserved?.preservedSegment !== void 0 ? [
59987
+ preserved.preservedSegment.headUuid,
59988
+ preserved.preservedSegment.tailUuid,
59989
+ preserved.preservedSegment.anchorUuid
59990
+ ] : [];
59991
+ if (references.some((id) => !entries.has(id))) {
59992
+ return null;
59993
+ }
59994
+ }
59995
+ const project = async (source) => {
59996
+ signal.throwIfAborted();
59997
+ const messages = await FZt(sessionId, {
59998
+ includeSystemMessages: true,
59999
+ sessionStore: { append: async () => {
60000
+ }, load: async () => source }
60001
+ });
60002
+ signal.throwIfAborted();
60003
+ return messages;
60004
+ };
60005
+ const result = [];
60006
+ const seen = /* @__PURE__ */ new Set();
60007
+ const expanding = /* @__PURE__ */ new Set();
60008
+ const append = async (messages) => {
60009
+ let compactionId;
60010
+ for (const message of messages) {
60011
+ signal.throwIfAborted();
60012
+ const node2 = entries.get(message.uuid);
60013
+ if (node2 === void 0) {
60014
+ return false;
60015
+ }
60016
+ if (node2.entry.subtype === "compact_boundary") {
60017
+ compactionId = message.uuid;
60018
+ if (seen.has(message.uuid)) {
60019
+ continue;
60020
+ }
60021
+ if (expanding.has(message.uuid)) {
60022
+ return false;
60023
+ }
60024
+ expanding.add(message.uuid);
60025
+ const parent = node2.entry.logicalParentUuid;
60026
+ if (typeof parent === "string") {
60027
+ const ancestor = entries.get(parent);
60028
+ if (ancestor === void 0 || ancestor.index >= node2.index) {
60029
+ return false;
60030
+ }
60031
+ const anchor2 = `history-anchor-${message.uuid}`;
60032
+ if (entries.has(anchor2)) {
60033
+ return false;
60034
+ }
60035
+ const earlier = await project([
60036
+ ...transcript.slice(0, node2.index),
60037
+ {
60038
+ type: "user",
60039
+ uuid: anchor2,
60040
+ parentUuid: parent,
60041
+ sessionId,
60042
+ message: { role: "user", content: "" }
60043
+ }
60044
+ ]);
60045
+ if (!await append(earlier.filter((entry) => entry.uuid !== anchor2))) {
60046
+ return false;
60047
+ }
60048
+ }
60049
+ expanding.delete(message.uuid);
60050
+ seen.add(message.uuid);
60051
+ result.push({ ...message, nativeCompaction: { kind: "boundary", id: message.uuid } });
60052
+ } else if (!seen.has(message.uuid)) {
60053
+ seen.add(message.uuid);
60054
+ if (node2.entry.isCompactSummary === true) {
60055
+ if (compactionId === void 0) {
60056
+ return false;
60057
+ }
60058
+ result.push({ ...message, nativeCompaction: { kind: "summary", id: compactionId } });
60059
+ } else if (message.type !== "system") {
60060
+ result.push(message);
60061
+ }
60062
+ }
60063
+ }
60064
+ return true;
60065
+ };
60066
+ return await append(await project([...transcript])) ? result : null;
60067
+ }
59932
60068
 
59933
60069
  // src/engine/acp/harness/claude/upstream/dist/session-config-ids.js
59934
60070
  var DEFAULT_MODEL_ID = "default";
@@ -62750,9 +62886,16 @@ function stripMarkerTags(text2) {
62750
62886
  }
62751
62887
  return result + text2.slice(copiedUpTo);
62752
62888
  }
62753
- function stripLocalCommandMetadata(content) {
62889
+ function stripLocalCommandMetadata(content, options) {
62890
+ const strip = (text2) => {
62891
+ if (options?.preserveCompactionCommand === true && /<command-name>\/compact<\/command-name>/u.test(text2)) {
62892
+ const args = /<command-args>([\s\S]*?)<\/command-args>/u.exec(text2)?.[1]?.trim() ?? "";
62893
+ return stripMarkerTags(text2.replace(/<command-name>\/compact<\/command-name>/u, () => args.length > 0 ? `/compact ${args}` : "/compact")).trim();
62894
+ }
62895
+ return stripMarkerTags(text2);
62896
+ };
62754
62897
  if (typeof content === "string") {
62755
- const stripped = stripMarkerTags(content);
62898
+ const stripped = strip(content);
62756
62899
  return stripped.trim() === "" ? null : stripped;
62757
62900
  }
62758
62901
  if (!Array.isArray(content)) {
@@ -62761,7 +62904,7 @@ function stripLocalCommandMetadata(content) {
62761
62904
  const kept = [];
62762
62905
  for (const block of content) {
62763
62906
  if (block && typeof block === "object" && "type" in block && block.type === "text" && "text" in block && typeof block.text === "string") {
62764
- const stripped = stripMarkerTags(block.text);
62907
+ const stripped = strip(block.text);
62765
62908
  if (stripped.trim() === "") {
62766
62909
  continue;
62767
62910
  }
@@ -65053,6 +65196,35 @@ ${message.api_refusal_explanation}` : "";
65053
65196
  const forwardSubagentText = this.sessions[sessionId]?.forwardSubagentText ?? supportsSubagentTranscript(this.clientCapabilities);
65054
65197
  const seenTools = /* @__PURE__ */ new Set();
65055
65198
  for (const message of messages) {
65199
+ signal.throwIfAborted();
65200
+ if (message.nativeCompaction !== void 0) {
65201
+ const compaction = message.nativeCompaction;
65202
+ if (compaction.kind === "boundary") {
65203
+ await this.client.sessionUpdate({
65204
+ sessionId,
65205
+ update: {
65206
+ sessionUpdate: "compaction_update",
65207
+ compactionId: compaction.id,
65208
+ status: "completed"
65209
+ }
65210
+ });
65211
+ } else {
65212
+ const body = message.message;
65213
+ const content2 = typeof body === "object" && body !== null && "content" in body ? body.content : void 0;
65214
+ const text2 = typeof content2 === "string" ? content2 : Array.isArray(content2) ? content2.flatMap((block) => typeof block === "object" && block !== null && "type" in block && block.type === "text" && "text" in block && typeof block.text === "string" ? [block.text] : []).join("\n") : "";
65215
+ if (text2.length > 0) {
65216
+ await this.client.sessionUpdate({
65217
+ sessionId,
65218
+ update: {
65219
+ sessionUpdate: "compaction_summary_chunk",
65220
+ compactionId: compaction.id,
65221
+ content: { type: "text", text: text2 }
65222
+ }
65223
+ });
65224
+ }
65225
+ }
65226
+ continue;
65227
+ }
65056
65228
  if (isTaskNotificationOrigin(message.nativeOrigin)) {
65057
65229
  const body = message.message;
65058
65230
  const content2 = typeof body === "object" && body !== null && "content" in body ? body.content : void 0;
@@ -65074,7 +65246,7 @@ ${message.api_refusal_explanation}` : "";
65074
65246
  }
65075
65247
  let content = message.message.content;
65076
65248
  if (message.message.role === "user") {
65077
- content = stripLocalCommandMetadata(content);
65249
+ content = stripLocalCommandMetadata(content, { preserveCompactionCommand: true });
65078
65250
  if (content === null) {
65079
65251
  continue;
65080
65252
  }
@@ -90797,7 +90969,7 @@ var sessionPromptCommand = {
90797
90969
  // package.json
90798
90970
  var package_default = {
90799
90971
  name: "@moxt-ai/mobius",
90800
- version: "0.0.352",
90972
+ version: "0.0.354",
90801
90973
  description: "Mobius CLI for pairing and running local AI agent services.",
90802
90974
  type: "module",
90803
90975
  bin: {