@moxt-ai/mobius 0.0.41 → 0.0.42

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.
Files changed (33) hide show
  1. package/dist/acp/activity.d.ts.map +1 -1
  2. package/dist/acp/activity.js +52 -8
  3. package/dist/acp/activity.js.map +1 -1
  4. package/dist/acp/session-manager.d.ts +4 -3
  5. package/dist/acp/session-manager.d.ts.map +1 -1
  6. package/dist/acp/session-manager.js +26 -2
  7. package/dist/acp/session-manager.js.map +1 -1
  8. package/dist/agent-catalog/discover-local-agents.d.ts +0 -1
  9. package/dist/agent-catalog/discover-local-agents.d.ts.map +1 -1
  10. package/dist/agent-catalog/discover-local-agents.js +0 -1
  11. package/dist/agent-catalog/discover-local-agents.js.map +1 -1
  12. package/dist/artifacts/runtime-artifact-uploader.d.ts +2 -2
  13. package/dist/artifacts/runtime-artifact-uploader.d.ts.map +1 -1
  14. package/dist/artifacts/runtime-artifact-uploader.js +3 -3
  15. package/dist/artifacts/runtime-artifact-uploader.js.map +1 -1
  16. package/dist/authorization/local-artifact.d.ts +6 -0
  17. package/dist/authorization/local-artifact.d.ts.map +1 -0
  18. package/dist/authorization/local-artifact.js +2 -0
  19. package/dist/authorization/local-artifact.js.map +1 -0
  20. package/dist/authorization/local-video.d.ts +11 -0
  21. package/dist/authorization/local-video.d.ts.map +1 -0
  22. package/dist/authorization/local-video.js +48 -0
  23. package/dist/authorization/local-video.js.map +1 -0
  24. package/dist/cli.js +151 -25
  25. package/dist/cli.js.map +4 -4
  26. package/dist/index.js +152 -26
  27. package/dist/index.js.map +4 -4
  28. package/dist/run-daemon.js +2 -2
  29. package/dist/run-daemon.js.map +1 -1
  30. package/dist/runtime.d.ts.map +1 -1
  31. package/dist/runtime.js +152 -26
  32. package/dist/runtime.js.map +4 -4
  33. package/package.json +1 -1
package/dist/runtime.js CHANGED
@@ -22691,7 +22691,7 @@ var displayContentSchema = external_exports.strictObject({
22691
22691
  path: external_exports.string().max(2048),
22692
22692
  terminalId: external_exports.string().max(255),
22693
22693
  text: LONG_TEXT,
22694
- type: external_exports.enum(["diff", "image", "resource", "resource_link", "terminal", "text"]),
22694
+ type: external_exports.enum(["diff", "image", "resource", "resource_link", "terminal", "text", "video"]),
22695
22695
  uri: external_exports.string().max(4096)
22696
22696
  }).readonly();
22697
22697
  var recordedDisplayContentSchema = external_exports.strictObject({
@@ -22704,7 +22704,7 @@ var recordedDisplayContentSchema = external_exports.strictObject({
22704
22704
  path: external_exports.string().max(2048),
22705
22705
  terminalId: external_exports.string().max(255),
22706
22706
  text: external_exports.string().max(4e6),
22707
- type: external_exports.enum(["diff", "image", "resource", "resource_link", "terminal", "text"]),
22707
+ type: external_exports.enum(["diff", "image", "resource", "resource_link", "terminal", "text", "video"]),
22708
22708
  uri: external_exports.string().max(4096)
22709
22709
  }).readonly();
22710
22710
  var promptImageSchema = external_exports.strictObject({
@@ -22751,8 +22751,17 @@ var sessionPrepareCommandSchema = external_exports.strictObject({
22751
22751
  }).readonly().optional(),
22752
22752
  kind: external_exports.literal(SESSION_PREPARE_KIND),
22753
22753
  requestId: IDENTIFIER,
22754
+ sessionState: external_exports.literal("provisioned").optional(),
22754
22755
  /** @deprecated Reserved for the legacy Bot Agent-configuration endpoint. */
22755
22756
  transient: external_exports.boolean().optional()
22757
+ }).superRefine((command, context) => {
22758
+ if (command.transient === true && command.sessionState === "provisioned") {
22759
+ context.addIssue({
22760
+ code: "custom",
22761
+ message: "A transient Session cannot already be provisioned",
22762
+ path: ["sessionState"]
22763
+ });
22764
+ }
22756
22765
  }).readonly();
22757
22766
  var runtimeTimingsSchema = external_exports.array(
22758
22767
  external_exports.strictObject({
@@ -24297,7 +24306,7 @@ function createDaemonConfig(connection, agents = [], installableAgents = []) {
24297
24306
 
24298
24307
  // src/run-daemon.ts
24299
24308
  import { randomUUID as randomUUID4 } from "node:crypto";
24300
- import { basename as basename4, join as join16 } from "node:path";
24309
+ import { basename as basename5, join as join16 } from "node:path";
24301
24310
  import { styleText } from "node:util";
24302
24311
  import { fetch as fetch6, WebSocket as WebSocket2 } from "undici";
24303
24312
 
@@ -24460,6 +24469,55 @@ async function readAuthorizedRaster(uri, roots, signal) {
24460
24469
  return new LocalRasterImage(basename(target) || "Image", mimeType, bytes);
24461
24470
  }
24462
24471
 
24472
+ // src/authorization/local-video.ts
24473
+ import { basename as basename2 } from "node:path";
24474
+ var MAX_INLINE_VIDEO_BYTES = 3e6;
24475
+ var MP4_FILE_TYPE = new TextEncoder().encode("ftyp");
24476
+ var WEBM_SIGNATURE = Uint8Array.of(26, 69, 223, 163);
24477
+ var LocalVideo = class {
24478
+ bytes;
24479
+ mimeType;
24480
+ name;
24481
+ constructor(name, mimeType, bytes) {
24482
+ this.bytes = bytes;
24483
+ this.mimeType = mimeType;
24484
+ this.name = name;
24485
+ }
24486
+ base64 = () => Buffer.from(this.bytes).toString("base64");
24487
+ };
24488
+ function startsWith2(bytes, signature, offset = 0) {
24489
+ if (bytes.byteLength < offset + signature.byteLength) {
24490
+ return false;
24491
+ }
24492
+ return signature.every((value, index2) => bytes[offset + index2] === value);
24493
+ }
24494
+ function sniffVideoMime(bytes) {
24495
+ if (startsWith2(bytes, MP4_FILE_TYPE, 4)) {
24496
+ return "video/mp4";
24497
+ }
24498
+ if (startsWith2(bytes, WEBM_SIGNATURE)) {
24499
+ return "video/webm";
24500
+ }
24501
+ return null;
24502
+ }
24503
+ function readInlineVideo(data, declaredMimeType, name = "Video") {
24504
+ if (data.length === 0 || data.length > Math.ceil(MAX_INLINE_VIDEO_BYTES / 3) * 4 || data.length % 4 !== 0) {
24505
+ return null;
24506
+ }
24507
+ if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data)) {
24508
+ return null;
24509
+ }
24510
+ const bytes = new Uint8Array(Buffer.from(data, "base64"));
24511
+ if (bytes.byteLength < 1 || bytes.byteLength > MAX_INLINE_VIDEO_BYTES) {
24512
+ return null;
24513
+ }
24514
+ const mimeType = sniffVideoMime(bytes);
24515
+ if (mimeType === null || mimeType !== declaredMimeType) {
24516
+ return null;
24517
+ }
24518
+ return new LocalVideo(basename2(name) || "Video", mimeType, bytes);
24519
+ }
24520
+
24463
24521
  // src/infra/operation-metrics.ts
24464
24522
  var AccumulatingOperationMetrics = class {
24465
24523
  #durations = /* @__PURE__ */ new Map();
@@ -24717,6 +24775,14 @@ function emptyDisplayContent(type) {
24717
24775
  uri: ""
24718
24776
  };
24719
24777
  }
24778
+ function resourceName(uri) {
24779
+ try {
24780
+ const pathname = new URL(uri).pathname;
24781
+ return decodeURIComponent(pathname.slice(pathname.lastIndexOf("/") + 1));
24782
+ } catch {
24783
+ return "";
24784
+ }
24785
+ }
24720
24786
  function imageDisplayContent(mimeType, name, data, artifactId = "", uri = "") {
24721
24787
  return {
24722
24788
  ...emptyDisplayContent("image"),
@@ -24748,18 +24814,21 @@ function normalizeContentBlock(content3) {
24748
24814
  };
24749
24815
  }
24750
24816
  if (content3.type === "resource") {
24817
+ const type = content3.resource.mimeType?.startsWith("video/") === true ? "video" : "resource";
24751
24818
  if ("text" in content3.resource) {
24752
24819
  return {
24753
- ...emptyDisplayContent("resource"),
24820
+ ...emptyDisplayContent(type),
24754
24821
  mimeType: content3.resource.mimeType ?? "",
24822
+ name: resourceName(content3.resource.uri),
24755
24823
  text: content3.resource.text,
24756
24824
  uri: content3.resource.uri
24757
24825
  };
24758
24826
  }
24759
24827
  return {
24760
- ...emptyDisplayContent("resource"),
24828
+ ...emptyDisplayContent(type),
24761
24829
  data: content3.resource.blob,
24762
24830
  mimeType: content3.resource.mimeType ?? "",
24831
+ name: resourceName(content3.resource.uri),
24763
24832
  uri: content3.resource.uri
24764
24833
  };
24765
24834
  }
@@ -24792,6 +24861,36 @@ async function normalizeToolContent(content3, prepareContent) {
24792
24861
  }
24793
24862
  return normalized;
24794
24863
  }
24864
+ function rawMcpToolContent(rawOutput) {
24865
+ if (!isRecord6(rawOutput)) {
24866
+ return [];
24867
+ }
24868
+ const result = isRecord6(rawOutput["result"]) ? rawOutput["result"] : rawOutput;
24869
+ const content3 = result["content"];
24870
+ if (!Array.isArray(content3)) {
24871
+ return [];
24872
+ }
24873
+ return content3.flatMap((item) => {
24874
+ if (!isRecord6(item) || item["type"] !== "image" || typeof item["data"] !== "string" || typeof item["mimeType"] !== "string") {
24875
+ return [];
24876
+ }
24877
+ const uri = item["uri"];
24878
+ return [
24879
+ {
24880
+ type: "content",
24881
+ content: {
24882
+ type: "image",
24883
+ data: item["data"],
24884
+ mimeType: item["mimeType"],
24885
+ ...typeof uri === "string" ? { uri } : {}
24886
+ }
24887
+ }
24888
+ ];
24889
+ });
24890
+ }
24891
+ function toolContent(content3, rawOutput) {
24892
+ return content3 !== void 0 && content3 !== null && content3.length > 0 ? content3 : rawMcpToolContent(rawOutput);
24893
+ }
24795
24894
  function normalizeLocations(locations) {
24796
24895
  const normalized = [];
24797
24896
  const unique = /* @__PURE__ */ new Set();
@@ -24955,7 +25054,10 @@ var AcpActivityTracker = class {
24955
25054
  const output2 = update.rawOutput === void 0 ? readContentOutput(update.content) : formatUnknown(update.rawOutput);
24956
25055
  const detailInput = update.rawInput === void 0 ? "" : formatUnknownDetail(update.rawInput);
24957
25056
  const detailOutput = update.rawOutput === void 0 ? readContentOutputDetail(update.content) : formatUnknownDetail(update.rawOutput);
24958
- const detailContent = await normalizeToolContent(update.content ?? [], this.#prepareContent);
25057
+ const detailContent = await normalizeToolContent(
25058
+ toolContent(update.content, update.rawOutput),
25059
+ this.#prepareContent
25060
+ );
24959
25061
  await this.#record(
24960
25062
  key,
24961
25063
  new AcpActivity(
@@ -24981,10 +25083,11 @@ var AcpActivityTracker = class {
24981
25083
  const identity2 = this.#identity(key);
24982
25084
  const previousDetail = recordedDetail(previous2);
24983
25085
  const output2 = update.rawOutput !== void 0 ? formatUnknown(update.rawOutput) : update.content !== void 0 && update.content !== null ? readContentOutput(update.content) : previous2?.output ?? "";
24984
- const content3 = update.content === void 0 || update.content === null ? previous2?.content ?? [] : await normalizeToolContent(update.content, this.#prepareContent);
25086
+ const nextContent = toolContent(update.content, update.rawOutput);
25087
+ const content3 = nextContent.length === 0 ? previous2?.content ?? [] : await normalizeToolContent(nextContent, this.#prepareContent);
24985
25088
  const detailInput = update.rawInput === void 0 ? previousDetail?.input ?? previous2?.input ?? "" : formatUnknownDetail(update.rawInput);
24986
25089
  const detailOutput = update.rawOutput !== void 0 ? formatUnknownDetail(update.rawOutput) : update.content !== void 0 && update.content !== null ? readContentOutputDetail(update.content) : previousDetail?.output ?? previous2?.output ?? "";
24987
- const detailContent = update.content === void 0 || update.content === null ? previousDetail?.content ?? previous2?.content ?? [] : content3;
25090
+ const detailContent = nextContent.length === 0 ? previousDetail?.content ?? previous2?.content ?? [] : content3;
24988
25091
  await this.#record(
24989
25092
  key,
24990
25093
  new AcpActivity(
@@ -32954,7 +33057,7 @@ var MAX_PRE_SESSION_UPDATES = 100;
32954
33057
  var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
32955
33058
  var SESSION_CONTROL_COMMAND_ID = "session-control";
32956
33059
  var NullAcpSessionObserver = class {
32957
- importLocalImage = (_sessionId, _image, signal) => {
33060
+ importLocalArtifact = (_sessionId, _artifact, signal) => {
32958
33061
  signal.throwIfAborted();
32959
33062
  return Promise.resolve("");
32960
33063
  };
@@ -33721,6 +33824,13 @@ var AcpProcessSession = class _AcpProcessSession {
33721
33824
  return await this.importRaster(raster, signal);
33722
33825
  }
33723
33826
  }
33827
+ if (content3.type === "video" && content3.data.length > 0) {
33828
+ const video = readInlineVideo(content3.data, content3.mimeType, content3.name);
33829
+ if (video === null) {
33830
+ return { ...content3, data: "" };
33831
+ }
33832
+ return await this.importVideo(video, AbortSignal.timeout(2e4));
33833
+ }
33724
33834
  return content3;
33725
33835
  };
33726
33836
  emitAgentContent = async (content3, messageId) => {
@@ -33746,7 +33856,7 @@ var AcpProcessSession = class _AcpProcessSession {
33746
33856
  });
33747
33857
  };
33748
33858
  importRaster = async (raster, signal) => {
33749
- const artifactId = await this.#getObserver().importLocalImage(this.#mobiusSessionId, raster, signal);
33859
+ const artifactId = await this.#getObserver().importLocalArtifact(this.#mobiusSessionId, raster, signal);
33750
33860
  return imageDisplayContent(
33751
33861
  raster.mimeType,
33752
33862
  raster.name,
@@ -33754,6 +33864,22 @@ var AcpProcessSession = class _AcpProcessSession {
33754
33864
  artifactId
33755
33865
  );
33756
33866
  };
33867
+ importVideo = async (video, signal) => {
33868
+ const artifactId = await this.#getObserver().importLocalArtifact(this.#mobiusSessionId, video, signal);
33869
+ return {
33870
+ artifactId,
33871
+ data: artifactId.length > 0 ? "" : video.base64(),
33872
+ mimeType: video.mimeType,
33873
+ name: video.name,
33874
+ newText: "",
33875
+ oldText: "",
33876
+ path: "",
33877
+ terminalId: "",
33878
+ text: "",
33879
+ type: "video",
33880
+ uri: ""
33881
+ };
33882
+ };
33757
33883
  async #initializeAgent(signal) {
33758
33884
  await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
33759
33885
  }
@@ -36573,15 +36699,15 @@ async function putContent(url2, authorization, bytes, signal) {
36573
36699
  signal
36574
36700
  });
36575
36701
  }
36576
- async function uploadRuntimeArtifact(config2, sessionId, image, signal) {
36702
+ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
36577
36703
  signal.throwIfAborted();
36578
36704
  let request;
36579
36705
  try {
36580
36706
  request = new MobiusArtifactUploadRequest(
36581
- image.name,
36582
- image.mimeType,
36583
- image.bytes.byteLength,
36584
- createHash2("sha256").update(image.bytes).digest("hex")
36707
+ artifact.name,
36708
+ artifact.mimeType,
36709
+ artifact.bytes.byteLength,
36710
+ createHash2("sha256").update(artifact.bytes).digest("hex")
36585
36711
  );
36586
36712
  } catch (cause) {
36587
36713
  translateSdkError(cause);
@@ -36620,7 +36746,7 @@ async function uploadRuntimeArtifact(config2, sessionId, image, signal) {
36620
36746
  token
36621
36747
  ),
36622
36748
  authorization,
36623
- image.bytes,
36749
+ artifact.bytes,
36624
36750
  requestSignal
36625
36751
  );
36626
36752
  } catch (cause) {
@@ -36661,7 +36787,7 @@ var LocalAuthorizationError = class extends Error {
36661
36787
  // src/authorization/workspace-directory.ts
36662
36788
  import { readdir as readdir2, realpath as realpath7, stat as stat6 } from "node:fs/promises";
36663
36789
  import { homedir as homedir2 } from "node:os";
36664
- import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute9, join as join15, normalize as normalize3, relative as relative5 } from "node:path";
36790
+ import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute9, join as join15, normalize as normalize3, relative as relative5 } from "node:path";
36665
36791
  var WorkspaceDirectoryListing = class {
36666
36792
  directoryId;
36667
36793
  directoryLabel;
@@ -36753,7 +36879,7 @@ var WorkspaceDirectoryService = class {
36753
36879
  return {
36754
36880
  path: path2,
36755
36881
  directoryId: encodePath(path2),
36756
- name: basename2(path2) || path2,
36882
+ name: basename3(path2) || path2,
36757
36883
  label: this.label(path2)
36758
36884
  };
36759
36885
  };
@@ -37620,7 +37746,7 @@ var BotOutboundIpcServer = class {
37620
37746
 
37621
37747
  // src/native-sessions/service.ts
37622
37748
  import { randomUUID as randomUUID2 } from "node:crypto";
37623
- import { basename as basename3 } from "node:path";
37749
+ import { basename as basename4 } from "node:path";
37624
37750
 
37625
37751
  // src/native-sessions/codex-history.ts
37626
37752
  import { spawn as spawn4 } from "node:child_process";
@@ -38129,7 +38255,7 @@ var NativeSessionService = class {
38129
38255
  }
38130
38256
  resolvedPaths.add(path2);
38131
38257
  additionalDirectories.push(path2);
38132
- additionalEntries.push({ directoryId: directoryId2, name: basename3(path2) });
38258
+ additionalEntries.push({ directoryId: directoryId2, name: basename4(path2) });
38133
38259
  }
38134
38260
  const listing = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
38135
38261
  const opened = await this.#sessions.forkSessionAtTurn(
@@ -39451,9 +39577,9 @@ var DaemonAcpObserver = class {
39451
39577
  this.#config = config2;
39452
39578
  this.#record = record3;
39453
39579
  }
39454
- importLocalImage = async (sessionId, image, signal) => {
39580
+ importLocalArtifact = async (sessionId, artifact, signal) => {
39455
39581
  try {
39456
- return (await uploadRuntimeArtifact(this.#config, sessionId, image, signal)).artifactId;
39582
+ return (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
39457
39583
  } catch (cause) {
39458
39584
  signal.throwIfAborted();
39459
39585
  if (cause instanceof Error && cause.name === "AbortError") {
@@ -40024,7 +40150,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
40024
40150
  additionalDirectories.push(directory);
40025
40151
  additionalDirectoryEntries.push({
40026
40152
  directoryId: additionalDirectoryId,
40027
- name: basename4(directory)
40153
+ name: basename5(directory)
40028
40154
  });
40029
40155
  }
40030
40156
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
@@ -41716,7 +41842,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
41716
41842
  import { randomUUID as randomUUID5 } from "node:crypto";
41717
41843
  import { mkdir as mkdir4, open as open4, realpath as realpath8, rename as rename3, stat as stat7, writeFile as writeFile2 } from "node:fs/promises";
41718
41844
  import { hostname as hostname3 } from "node:os";
41719
- import { basename as basename5, join as join17, resolve as resolve4 } from "node:path";
41845
+ import { basename as basename6, join as join17, resolve as resolve4 } from "node:path";
41720
41846
  import { fetch as fetch7 } from "undici";
41721
41847
  var PAIRING_TIMEOUT_MILLISECONDS = 2e4;
41722
41848
  var PAIRING_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{4}(?:-[A-HJ-NP-Z2-9]{4}){4}$/;
@@ -41856,7 +41982,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
41856
41982
  installableAgents,
41857
41983
  machineName: hostname3(),
41858
41984
  pairingCode: options.code,
41859
- workspaceName: basename5(defaultWorkspace) || "Local workspace"
41985
+ workspaceName: basename6(defaultWorkspace) || "Local workspace"
41860
41986
  }),
41861
41987
  dispatcher: environmentProxyDispatcher,
41862
41988
  headers: { "content-type": "application/json" },
@@ -42021,7 +42147,7 @@ async function resumeMobiusRuntime(channelId, signal, environment = process.env)
42021
42147
 
42022
42148
  // src/runtime.ts
42023
42149
  var IDENTIFIER_PATTERN9 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
42024
- var RUNTIME_CREDENTIAL_PATTERN = /^[a-zA-Z0-9_-]{43}$/;
42150
+ var RUNTIME_CREDENTIAL_PATTERN = /^(?:[a-zA-Z0-9_-]{43}|prj_[a-zA-Z0-9_-]{24}_[a-zA-Z0-9_-]{43}|prj_(?:wn|en|sa|we|ee|ap|oc|af|me)_01_[a-zA-Z0-9_-]{24}_[a-zA-Z0-9_-]{43})$/;
42025
42151
  var MobiusRuntimeConfigurationError = class extends Error {
42026
42152
  code = "runtime_configuration_invalid";
42027
42153
  constructor(message, options = {}) {