@moxt-ai/mobius 0.0.338 → 0.0.340

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/runtime.js CHANGED
@@ -21741,128 +21741,9 @@ var sessionWireEnvelopeSchema = external_exports.object({
21741
21741
  kind: external_exports.literal(SESSION_EVENT_KIND),
21742
21742
  events: external_exports.array(sessionWireEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly()
21743
21743
  }).passthrough().readonly();
21744
- var knownContentBlockTypes = /* @__PURE__ */ new Set([
21745
- "text",
21746
- "image",
21747
- "audio",
21748
- "resource_link",
21749
- "resource",
21750
- "external_image",
21751
- "external_audio",
21752
- "external_resource"
21753
- ]);
21754
- var knownToolCallContentTypes = /* @__PURE__ */ new Set(["content", "diff", "terminal"]);
21755
- var knownPlanTypes = /* @__PURE__ */ new Set(["items", "file", "markdown"]);
21756
- var knownConfigOptionTypes = /* @__PURE__ */ new Set(["select", "boolean"]);
21757
- var knownSessionUpdates = /* @__PURE__ */ new Set([
21758
- "user_message_chunk",
21759
- "agent_message_chunk",
21760
- "agent_thought_chunk",
21761
- "tool_call",
21762
- "tool_call_update",
21763
- "plan",
21764
- "plan_update",
21765
- "plan_removed",
21766
- "available_commands_update",
21767
- "current_mode_update",
21768
- "config_option_update",
21769
- "session_info_update",
21770
- "usage_update",
21771
- "compaction_update",
21772
- "compaction_summary_chunk"
21773
- ]);
21774
- var knownLifecycleKinds = /* @__PURE__ */ new Set([
21775
- "session.queue.changed",
21776
- "session.permission.requested",
21777
- "session.permission.resolved",
21778
- "session.elicitation.requested",
21779
- "session.elicitation.resolved",
21780
- "prompt.requested",
21781
- "prompt.started",
21782
- "prompt.completed",
21783
- "prompt.failed-before-start",
21784
- "prompt.failed"
21785
- ]);
21786
21744
  function isRecord3(value) {
21787
21745
  return typeof value === "object" && value !== null && !Array.isArray(value);
21788
21746
  }
21789
- function hasUnknownDiscriminator(value, key, known) {
21790
- if (!isRecord3(value)) {
21791
- return false;
21792
- }
21793
- const variant = value[key];
21794
- return typeof variant === "string" && !known.has(variant);
21795
- }
21796
- function containsUnknownContentBlock(value) {
21797
- return hasUnknownDiscriminator(value, "type", knownContentBlockTypes);
21798
- }
21799
- function containsUnknownToolCallContent(value) {
21800
- if (hasUnknownDiscriminator(value, "type", knownToolCallContentTypes)) {
21801
- return true;
21802
- }
21803
- return isRecord3(value) && value["type"] === "content" && containsUnknownContentBlock(value["content"]);
21804
- }
21805
- function arrayContainsUnknown(value, predicate) {
21806
- return Array.isArray(value) && value.some(predicate);
21807
- }
21808
- function containsUnknownAcpVariant(payload) {
21809
- const update = payload["sessionUpdate"];
21810
- if (typeof update !== "string") {
21811
- return false;
21812
- }
21813
- if (!knownSessionUpdates.has(update)) {
21814
- return true;
21815
- }
21816
- if (["user_message_chunk", "agent_message_chunk", "agent_thought_chunk", "compaction_summary_chunk"].includes(
21817
- update
21818
- )) {
21819
- return containsUnknownContentBlock(payload["content"]);
21820
- }
21821
- if (update === "tool_call" || update === "tool_call_update") {
21822
- return arrayContainsUnknown(payload["content"], containsUnknownToolCallContent);
21823
- }
21824
- if (update === "plan_update") {
21825
- return hasUnknownDiscriminator(payload["plan"], "type", knownPlanTypes);
21826
- }
21827
- if (update === "config_option_update") {
21828
- return arrayContainsUnknown(
21829
- payload["configOptions"],
21830
- (option) => hasUnknownDiscriminator(option, "type", knownConfigOptionTypes)
21831
- );
21832
- }
21833
- if (update === "compaction_update") {
21834
- return arrayContainsUnknown(payload["summary"], containsUnknownContentBlock);
21835
- }
21836
- return false;
21837
- }
21838
- function isKnownSessionEventVariant(value) {
21839
- if (!isRecord3(value)) {
21840
- return true;
21841
- }
21842
- const type = value["type"];
21843
- if (typeof type !== "string") {
21844
- return true;
21845
- }
21846
- if (type === "acp") {
21847
- const payload = value["payload"];
21848
- return !isRecord3(payload) || !containsUnknownAcpVariant(payload);
21849
- }
21850
- if (type === "lifecycle-metadata") {
21851
- const payload = value["payload"];
21852
- if (!isRecord3(payload)) {
21853
- return true;
21854
- }
21855
- const kind = payload["kind"];
21856
- if (typeof kind === "string" && !knownLifecycleKinds.has(kind)) {
21857
- return false;
21858
- }
21859
- return kind !== "prompt.requested" || !arrayContainsUnknown(payload["content"], containsUnknownContentBlock);
21860
- }
21861
- return false;
21862
- }
21863
- function filterKnownSessionEventVariants(events) {
21864
- return Array.isArray(events) ? events.filter(isKnownSessionEventVariant) : events;
21865
- }
21866
21747
  var sessionEventBatchSchema = external_exports.array(sessionEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
21867
21748
  var sessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
21868
21749
  var sessionExportSchema = external_exports.object({
@@ -21948,7 +21829,13 @@ function decode3(value, schema) {
21948
21829
  function encode3(value, schema) {
21949
21830
  return JSON.stringify(decode3(value, schema));
21950
21831
  }
21951
- function sanitizeKnownNativeSessionEvents(value) {
21832
+ function decodedEntries(value, schema, maximum) {
21833
+ return Array.isArray(value) && value.length <= maximum ? value.flatMap((entry) => {
21834
+ const decoded = schema.safeParse(entry);
21835
+ return decoded.success ? [decoded.data] : [];
21836
+ }) : value;
21837
+ }
21838
+ function sanitizeConsumableNativeSessionEvents(value) {
21952
21839
  const input2 = inputValue(value);
21953
21840
  if (!isRecord3(input2)) {
21954
21841
  return input2;
@@ -21957,19 +21844,24 @@ function sanitizeKnownNativeSessionEvents(value) {
21957
21844
  const queuedPromptRequests = input2["queuedPromptRequests"];
21958
21845
  return {
21959
21846
  ...input2,
21960
- events: isRecord3(page) ? { ...page, events: filterKnownSessionEventVariants(page["events"]) } : page,
21961
- queuedPromptRequests: Array.isArray(queuedPromptRequests) ? queuedPromptRequests.filter(
21962
- (prompt) => !isRecord3(prompt) || !arrayContainsUnknown(prompt["content"], containsUnknownContentBlock)
21963
- ) : queuedPromptRequests
21847
+ events: isRecord3(page) ? { ...page, events: decodedEntries(page["events"], sessionEventSchema, MAX_EVENT_COUNT) } : page,
21848
+ queuedPromptRequests: decodedEntries(
21849
+ queuedPromptRequests,
21850
+ queuedPromptRequestEventLogSchema,
21851
+ MAX_COLLECTION_SIZE2
21852
+ )
21964
21853
  };
21965
21854
  }
21966
21855
  var knownSessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
21967
21856
  var decodeSessionEvent = (value) => decode3(value, sessionEventSchema);
21968
- var decodeKnownSessionEventPayload = (value) => isKnownSessionEventVariant(value) ? decode3(value, sessionEventPayloadSchema) : null;
21857
+ var decodeKnownSessionEventPayload = (value) => {
21858
+ const decoded = sessionEventPayloadSchema.safeParse(inputValue(value));
21859
+ return decoded.success ? decoded.data : null;
21860
+ };
21969
21861
  var decodeSessionEventEnvelope = (value) => decode3(value, sessionEventEnvelopeSchema);
21970
21862
  var encodeSessionEventEnvelope = (value) => encode3(value, sessionEventEnvelopeSchema);
21971
21863
  var decodeAcpSessionUpdate = (value) => decode3(value, acpSessionUpdateSchema);
21972
- var decodeKnownNativeSessionEvents = (value) => decode3(sanitizeKnownNativeSessionEvents(value), nativeSessionEventsSchema);
21864
+ var decodeKnownNativeSessionEvents = (value) => decode3(sanitizeConsumableNativeSessionEvents(value), nativeSessionEventsSchema);
21973
21865
 
21974
21866
  // ../mobius-sdk/src/protocol/session/files/index.ts
21975
21867
  var FILE_READ_KIND = "file.read";
@@ -22852,28 +22744,17 @@ var serviceToDaemonSignatures = {
22852
22744
  )
22853
22745
  };
22854
22746
  var serviceToDaemonRegistry = serviceToDaemonSignatures;
22855
- var knownNativeActions = /* @__PURE__ */ new Set(["active-turn", "find", "list", "import", "fork"]);
22856
- function isRecord4(value) {
22857
- return typeof value === "object" && value !== null && !Array.isArray(value);
22858
- }
22859
- function hasUnknownDiscriminator2(value, key, known) {
22860
- if (!isRecord4(value)) {
22861
- return false;
22862
- }
22863
- const variant = value[key];
22864
- return typeof variant === "string" && !known.has(variant);
22865
- }
22866
- function hasUnknownServiceVariant(kind, value) {
22867
- return kind === NATIVE_SESSION_REQUEST_KIND && hasUnknownDiscriminator2(value, "action", knownNativeActions);
22868
- }
22869
22747
  function decodeKnownServiceToDaemonMessage(encoded) {
22870
22748
  const kind = decodeMessageKind(encoded);
22871
22749
  const signature = serviceToDaemonRegistry[kind];
22872
22750
  if (signature === void 0) {
22873
22751
  return null;
22874
22752
  }
22875
- const value = parseJson(encoded);
22876
- return hasUnknownServiceVariant(kind, value) ? null : signature.decoder(encoded);
22753
+ try {
22754
+ return signature.decoder(encoded);
22755
+ } catch {
22756
+ return null;
22757
+ }
22877
22758
  }
22878
22759
  var daemonToServiceSignatures = {
22879
22760
  [SESSION_CLOSED_KIND]: defineMessageSignature(
@@ -23089,7 +22970,7 @@ var SessionConfigProtocolError = class extends Error {
23089
22970
  this.name = "SessionConfigProtocolError";
23090
22971
  }
23091
22972
  };
23092
- function isRecord5(value) {
22973
+ function isRecord4(value) {
23093
22974
  return typeof value === "object" && value !== null && !Array.isArray(value);
23094
22975
  }
23095
22976
  function readString3(value, fallback = "") {
@@ -23120,7 +23001,7 @@ function normalizeConfigValues(value) {
23120
23001
  }
23121
23002
  const normalized = [];
23122
23003
  for (const entry of value) {
23123
- if (!isRecord5(entry)) {
23004
+ if (!isRecord4(entry)) {
23124
23005
  continue;
23125
23006
  }
23126
23007
  const groupedOptions = entry["options"];
@@ -23128,7 +23009,7 @@ function normalizeConfigValues(value) {
23128
23009
  const groupId = readString3(entry["group"]);
23129
23010
  const groupName = readString3(entry["name"]);
23130
23011
  for (const groupedOption of groupedOptions) {
23131
- if (isRecord5(groupedOption)) {
23012
+ if (isRecord4(groupedOption)) {
23132
23013
  const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
23133
23014
  if (normalizedValue !== void 0) {
23134
23015
  normalized.push(normalizedValue);
@@ -23153,7 +23034,7 @@ function normalizeConfigOptions(value, modes) {
23153
23034
  const normalized = [];
23154
23035
  if (Array.isArray(value)) {
23155
23036
  for (const option of value) {
23156
- if (!isRecord5(option)) {
23037
+ if (!isRecord4(option)) {
23157
23038
  continue;
23158
23039
  }
23159
23040
  const id = truncate2(readString3(option["id"]), 128);
@@ -23193,12 +23074,12 @@ function normalizeConfigOptions(value, modes) {
23193
23074
  }
23194
23075
  }
23195
23076
  }
23196
- if (isRecord5(modes)) {
23077
+ if (isRecord4(modes)) {
23197
23078
  const values = [];
23198
23079
  const availableModes = modes["availableModes"];
23199
23080
  if (Array.isArray(availableModes)) {
23200
23081
  for (const mode of availableModes) {
23201
- if (!isRecord5(mode)) {
23082
+ if (!isRecord4(mode)) {
23202
23083
  continue;
23203
23084
  }
23204
23085
  const id = truncate2(readString3(mode["id"]), 500);
@@ -23231,7 +23112,7 @@ function normalizeConfigOptions(value, modes) {
23231
23112
  return normalized.slice(0, MAXIMUM_CONFIG_OPTIONS);
23232
23113
  }
23233
23114
  function normalizeStandardLifecycle(response) {
23234
- const lifecycle = isRecord5(response) ? response : {};
23115
+ const lifecycle = isRecord4(response) ? response : {};
23235
23116
  return normalizeConfigOptions(lifecycle["configOptions"], lifecycle["modes"]);
23236
23117
  }
23237
23118
  function replaceStandardConfigOptions(current, value) {
@@ -23273,7 +23154,7 @@ var StandardSessionConfigProtocol = class {
23273
23154
  "ACP agent exited while changing session configuration",
23274
23155
  change.signal
23275
23156
  );
23276
- if (!isRecord5(response) || !Array.isArray(response["configOptions"])) {
23157
+ if (!isRecord4(response) || !Array.isArray(response["configOptions"])) {
23277
23158
  throw new SessionConfigProtocolError("The Agent returned an invalid session configuration response");
23278
23159
  }
23279
23160
  return replaceStandardConfigOptions(current, response["configOptions"]);
@@ -32333,7 +32214,7 @@ var toolImageSchema = external_exports.union([
32333
32214
  file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
32334
32215
  }).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
32335
32216
  ]);
32336
- function isRecord6(value) {
32217
+ function isRecord5(value) {
32337
32218
  return typeof value === "object" && value !== null && !Array.isArray(value);
32338
32219
  }
32339
32220
  var AcpContentExternalizer = class {
@@ -32440,13 +32321,13 @@ var AcpContentExternalizer = class {
32440
32321
  }
32441
32322
  return result2;
32442
32323
  }
32443
- if (!isRecord6(value)) {
32324
+ if (!isRecord5(value)) {
32444
32325
  return value;
32445
32326
  }
32446
32327
  const image = toolImageSchema.safeParse(value);
32447
32328
  if (image.success && image.data.data.length > 0) {
32448
32329
  const prepared = await this.#content(sessionId, image.data, signal);
32449
- if (isRecord6(prepared.event) && typeof prepared.event["imageKey"] === "string") {
32330
+ if (isRecord5(prepared.event) && typeof prepared.event["imageKey"] === "string") {
32450
32331
  images.set(prepared.event["imageKey"], prepared);
32451
32332
  } else {
32452
32333
  images.set(`unavailable:${images.size}`, prepared);
@@ -32477,7 +32358,7 @@ var AcpContentExternalizer = class {
32477
32358
  const prepared = await this.#content(sessionId, content, signal);
32478
32359
  agentContent.push({ ...item, content: prepared.agent });
32479
32360
  eventContent.push({ ...item, content: prepared.event });
32480
- if (isRecord6(prepared.event) && typeof prepared.event["imageKey"] === "string") {
32361
+ if (isRecord5(prepared.event) && typeof prepared.event["imageKey"] === "string") {
32481
32362
  images.delete(prepared.event["imageKey"]);
32482
32363
  }
32483
32364
  }
@@ -32557,7 +32438,7 @@ import { fetch as fetch3 } from "undici";
32557
32438
  // package.json
32558
32439
  var package_default = {
32559
32440
  name: "@moxt-ai/mobius",
32560
- version: "0.0.338",
32441
+ version: "0.0.340",
32561
32442
  description: "Mobius CLI for pairing and running local AI agent services.",
32562
32443
  type: "module",
32563
32444
  bin: {
@@ -69835,7 +69716,7 @@ var DESTINATIONS = /* @__PURE__ */ new Set([
69835
69716
  ]);
69836
69717
  var BEHAVIORS = /* @__PURE__ */ new Set(["allow", "deny", "ask"]);
69837
69718
  var MODES = /* @__PURE__ */ new Set(["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto"]);
69838
- function isRecord7(value) {
69719
+ function isRecord6(value) {
69839
69720
  return !!value && typeof value === "object" && !Array.isArray(value);
69840
69721
  }
69841
69722
  function isDestination(value) {
@@ -69852,13 +69733,13 @@ function safePlainString(value, maxLength) {
69852
69733
  });
69853
69734
  }
69854
69735
  function isRule(value) {
69855
- if (!isRecord7(value) || !safePlainString(value.toolName, MAX_TOOL_NAME_LENGTH)) {
69736
+ if (!isRecord6(value) || !safePlainString(value.toolName, MAX_TOOL_NAME_LENGTH)) {
69856
69737
  return false;
69857
69738
  }
69858
69739
  return value.ruleContent === void 0 || safePlainString(value.ruleContent, MAX_RULE_CONTENT_LENGTH);
69859
69740
  }
69860
69741
  function isKnownUpdate(value) {
69861
- if (!isRecord7(value) || !isDestination(value.destination) || typeof value.type !== "string") {
69742
+ if (!isRecord6(value) || !isDestination(value.destination) || typeof value.type !== "string") {
69862
69743
  return false;
69863
69744
  }
69864
69745
  switch (value.type) {
@@ -82817,7 +82698,7 @@ var AgentCatalogPublishError = class extends Error {
82817
82698
  this.name = "AgentCatalogPublishError";
82818
82699
  }
82819
82700
  };
82820
- function isRecord8(value) {
82701
+ function isRecord7(value) {
82821
82702
  return typeof value === "object" && value !== null && !Array.isArray(value);
82822
82703
  }
82823
82704
  function isSafeRelayErrorMessage(value) {
@@ -82830,7 +82711,7 @@ async function rejectedCatalogError(response) {
82830
82711
  } catch {
82831
82712
  return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
82832
82713
  }
82833
- if (!isRecord8(value) || !isRecord8(value["error"])) {
82714
+ if (!isRecord7(value) || !isRecord7(value["error"])) {
82834
82715
  return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
82835
82716
  }
82836
82717
  const code = value["error"]["code"];
@@ -83252,7 +83133,7 @@ var RuntimeInstallationStoreError = class extends Error {
83252
83133
  this.name = "RuntimeInstallationStoreError";
83253
83134
  }
83254
83135
  };
83255
- function isRecord9(value) {
83136
+ function isRecord8(value) {
83256
83137
  return typeof value === "object" && value !== null && !Array.isArray(value);
83257
83138
  }
83258
83139
  function hasExactKeys(value, expectedKeys) {
@@ -83319,7 +83200,7 @@ function installationId() {
83319
83200
  return `min_${randomUUID13().replaceAll("-", "")}`;
83320
83201
  }
83321
83202
  function decodeInstallationPointer(value) {
83322
- if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
83203
+ if (!isRecord8(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
83323
83204
  throw new RuntimeInstallationStoreError("invalid_installation", "The local installation record is invalid");
83324
83205
  }
83325
83206
  const storedInstallationId = value["installationId"];
@@ -83329,7 +83210,7 @@ function decodeInstallationPointer(value) {
83329
83210
  return { installationId: validateInstallationId(storedInstallationId) };
83330
83211
  }
83331
83212
  function decodeChannelIndex(value) {
83332
- if (!isRecord9(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
83213
+ if (!isRecord8(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
83333
83214
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
83334
83215
  }
83335
83216
  const applicationId = value["applicationId"];
@@ -83379,7 +83260,7 @@ function decodeVerifiedConnection(value) {
83379
83260
  );
83380
83261
  }
83381
83262
  function decodeConnection(value) {
83382
- if (!isRecord9(value)) {
83263
+ if (!isRecord8(value)) {
83383
83264
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
83384
83265
  }
83385
83266
  return decodeVerifiedConnection(value);
@@ -84798,17 +84679,14 @@ var SessionInteractions = class {
84798
84679
  };
84799
84680
 
84800
84681
  // src/session/live/session-configurations.ts
84801
- var storedSessionConfigurationsSchema = external_exports.array(
84802
- external_exports.discriminatedUnion("type", [
84803
- external_exports.object({ booleanValue: external_exports.boolean(), configId: external_exports.string().max(128), type: external_exports.literal("boolean") }),
84804
- external_exports.object({ configId: external_exports.string().max(128), type: external_exports.literal("select"), value: external_exports.string().max(500) })
84805
- ])
84806
- ).max(100);
84807
- var decodeStoredSessionConfigurations = (value) => storedSessionConfigurationsSchema.parse(
84808
- Array.isArray(value) ? value.filter(
84809
- (configuration) => typeof configuration !== "object" || configuration === null || !("type" in configuration) || typeof configuration.type !== "string" || configuration.type === "boolean" || configuration.type === "select"
84810
- ) : value
84811
- );
84682
+ var storedSessionConfigurationSchema = external_exports.discriminatedUnion("type", [
84683
+ external_exports.object({ booleanValue: external_exports.boolean(), configId: external_exports.string().max(128), type: external_exports.literal("boolean") }),
84684
+ external_exports.object({ configId: external_exports.string().max(128), type: external_exports.literal("select"), value: external_exports.string().max(500) })
84685
+ ]);
84686
+ var decodeStoredSessionConfigurations = (value) => external_exports.array(external_exports.unknown()).max(100).parse(value).flatMap((configuration) => {
84687
+ const decoded = storedSessionConfigurationSchema.safeParse(configuration);
84688
+ return decoded.success ? [decoded.data] : [];
84689
+ });
84812
84690
  var SessionConfigurations = class {
84813
84691
  #selected = [];
84814
84692
  stored = () => this.#selected;