@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/index.js CHANGED
@@ -19933,7 +19933,7 @@ var displayContentSchema = external_exports.strictObject({
19933
19933
  path: external_exports.string().max(2048),
19934
19934
  terminalId: external_exports.string().max(255),
19935
19935
  text: LONG_TEXT,
19936
- type: external_exports.enum(["diff", "image", "resource", "resource_link", "terminal", "text"]),
19936
+ type: external_exports.enum(["diff", "image", "resource", "resource_link", "terminal", "text", "video"]),
19937
19937
  uri: external_exports.string().max(4096)
19938
19938
  }).readonly();
19939
19939
  var recordedDisplayContentSchema = external_exports.strictObject({
@@ -19946,7 +19946,7 @@ var recordedDisplayContentSchema = external_exports.strictObject({
19946
19946
  path: external_exports.string().max(2048),
19947
19947
  terminalId: external_exports.string().max(255),
19948
19948
  text: external_exports.string().max(4e6),
19949
- type: external_exports.enum(["diff", "image", "resource", "resource_link", "terminal", "text"]),
19949
+ type: external_exports.enum(["diff", "image", "resource", "resource_link", "terminal", "text", "video"]),
19950
19950
  uri: external_exports.string().max(4096)
19951
19951
  }).readonly();
19952
19952
  var promptImageSchema = external_exports.strictObject({
@@ -19993,8 +19993,17 @@ var sessionPrepareCommandSchema = external_exports.strictObject({
19993
19993
  }).readonly().optional(),
19994
19994
  kind: external_exports.literal(SESSION_PREPARE_KIND),
19995
19995
  requestId: IDENTIFIER,
19996
+ sessionState: external_exports.literal("provisioned").optional(),
19996
19997
  /** @deprecated Reserved for the legacy Bot Agent-configuration endpoint. */
19997
19998
  transient: external_exports.boolean().optional()
19999
+ }).superRefine((command, context) => {
20000
+ if (command.transient === true && command.sessionState === "provisioned") {
20001
+ context.addIssue({
20002
+ code: "custom",
20003
+ message: "A transient Session cannot already be provisioned",
20004
+ path: ["sessionState"]
20005
+ });
20006
+ }
19998
20007
  }).readonly();
19999
20008
  var runtimeTimingsSchema = external_exports.array(
20000
20009
  external_exports.strictObject({
@@ -22430,6 +22439,55 @@ async function readAuthorizedRaster(uri, roots, signal) {
22430
22439
  return new LocalRasterImage(basename(target) || "Image", mimeType, bytes);
22431
22440
  }
22432
22441
 
22442
+ // src/authorization/local-video.ts
22443
+ import { basename as basename2 } from "node:path";
22444
+ var MAX_INLINE_VIDEO_BYTES = 3e6;
22445
+ var MP4_FILE_TYPE = new TextEncoder().encode("ftyp");
22446
+ var WEBM_SIGNATURE = Uint8Array.of(26, 69, 223, 163);
22447
+ var LocalVideo = class {
22448
+ bytes;
22449
+ mimeType;
22450
+ name;
22451
+ constructor(name, mimeType, bytes) {
22452
+ this.bytes = bytes;
22453
+ this.mimeType = mimeType;
22454
+ this.name = name;
22455
+ }
22456
+ base64 = () => Buffer.from(this.bytes).toString("base64");
22457
+ };
22458
+ function startsWith2(bytes, signature, offset = 0) {
22459
+ if (bytes.byteLength < offset + signature.byteLength) {
22460
+ return false;
22461
+ }
22462
+ return signature.every((value, index2) => bytes[offset + index2] === value);
22463
+ }
22464
+ function sniffVideoMime(bytes) {
22465
+ if (startsWith2(bytes, MP4_FILE_TYPE, 4)) {
22466
+ return "video/mp4";
22467
+ }
22468
+ if (startsWith2(bytes, WEBM_SIGNATURE)) {
22469
+ return "video/webm";
22470
+ }
22471
+ return null;
22472
+ }
22473
+ function readInlineVideo(data, declaredMimeType, name = "Video") {
22474
+ if (data.length === 0 || data.length > Math.ceil(MAX_INLINE_VIDEO_BYTES / 3) * 4 || data.length % 4 !== 0) {
22475
+ return null;
22476
+ }
22477
+ if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data)) {
22478
+ return null;
22479
+ }
22480
+ const bytes = new Uint8Array(Buffer.from(data, "base64"));
22481
+ if (bytes.byteLength < 1 || bytes.byteLength > MAX_INLINE_VIDEO_BYTES) {
22482
+ return null;
22483
+ }
22484
+ const mimeType = sniffVideoMime(bytes);
22485
+ if (mimeType === null || mimeType !== declaredMimeType) {
22486
+ return null;
22487
+ }
22488
+ return new LocalVideo(basename2(name) || "Video", mimeType, bytes);
22489
+ }
22490
+
22433
22491
  // src/infra/operation-metrics.ts
22434
22492
  var AccumulatingOperationMetrics = class {
22435
22493
  #durations = /* @__PURE__ */ new Map();
@@ -22687,6 +22745,14 @@ function emptyDisplayContent(type) {
22687
22745
  uri: ""
22688
22746
  };
22689
22747
  }
22748
+ function resourceName(uri) {
22749
+ try {
22750
+ const pathname = new URL(uri).pathname;
22751
+ return decodeURIComponent(pathname.slice(pathname.lastIndexOf("/") + 1));
22752
+ } catch {
22753
+ return "";
22754
+ }
22755
+ }
22690
22756
  function imageDisplayContent(mimeType, name, data, artifactId = "", uri = "") {
22691
22757
  return {
22692
22758
  ...emptyDisplayContent("image"),
@@ -22718,18 +22784,21 @@ function normalizeContentBlock(content3) {
22718
22784
  };
22719
22785
  }
22720
22786
  if (content3.type === "resource") {
22787
+ const type = content3.resource.mimeType?.startsWith("video/") === true ? "video" : "resource";
22721
22788
  if ("text" in content3.resource) {
22722
22789
  return {
22723
- ...emptyDisplayContent("resource"),
22790
+ ...emptyDisplayContent(type),
22724
22791
  mimeType: content3.resource.mimeType ?? "",
22792
+ name: resourceName(content3.resource.uri),
22725
22793
  text: content3.resource.text,
22726
22794
  uri: content3.resource.uri
22727
22795
  };
22728
22796
  }
22729
22797
  return {
22730
- ...emptyDisplayContent("resource"),
22798
+ ...emptyDisplayContent(type),
22731
22799
  data: content3.resource.blob,
22732
22800
  mimeType: content3.resource.mimeType ?? "",
22801
+ name: resourceName(content3.resource.uri),
22733
22802
  uri: content3.resource.uri
22734
22803
  };
22735
22804
  }
@@ -22762,6 +22831,36 @@ async function normalizeToolContent(content3, prepareContent) {
22762
22831
  }
22763
22832
  return normalized;
22764
22833
  }
22834
+ function rawMcpToolContent(rawOutput) {
22835
+ if (!isRecord4(rawOutput)) {
22836
+ return [];
22837
+ }
22838
+ const result = isRecord4(rawOutput["result"]) ? rawOutput["result"] : rawOutput;
22839
+ const content3 = result["content"];
22840
+ if (!Array.isArray(content3)) {
22841
+ return [];
22842
+ }
22843
+ return content3.flatMap((item) => {
22844
+ if (!isRecord4(item) || item["type"] !== "image" || typeof item["data"] !== "string" || typeof item["mimeType"] !== "string") {
22845
+ return [];
22846
+ }
22847
+ const uri = item["uri"];
22848
+ return [
22849
+ {
22850
+ type: "content",
22851
+ content: {
22852
+ type: "image",
22853
+ data: item["data"],
22854
+ mimeType: item["mimeType"],
22855
+ ...typeof uri === "string" ? { uri } : {}
22856
+ }
22857
+ }
22858
+ ];
22859
+ });
22860
+ }
22861
+ function toolContent(content3, rawOutput) {
22862
+ return content3 !== void 0 && content3 !== null && content3.length > 0 ? content3 : rawMcpToolContent(rawOutput);
22863
+ }
22765
22864
  function normalizeLocations(locations) {
22766
22865
  const normalized = [];
22767
22866
  const unique = /* @__PURE__ */ new Set();
@@ -22925,7 +23024,10 @@ var AcpActivityTracker = class {
22925
23024
  const output2 = update.rawOutput === void 0 ? readContentOutput(update.content) : formatUnknown(update.rawOutput);
22926
23025
  const detailInput = update.rawInput === void 0 ? "" : formatUnknownDetail(update.rawInput);
22927
23026
  const detailOutput = update.rawOutput === void 0 ? readContentOutputDetail(update.content) : formatUnknownDetail(update.rawOutput);
22928
- const detailContent = await normalizeToolContent(update.content ?? [], this.#prepareContent);
23027
+ const detailContent = await normalizeToolContent(
23028
+ toolContent(update.content, update.rawOutput),
23029
+ this.#prepareContent
23030
+ );
22929
23031
  await this.#record(
22930
23032
  key,
22931
23033
  new AcpActivity(
@@ -22951,10 +23053,11 @@ var AcpActivityTracker = class {
22951
23053
  const identity2 = this.#identity(key);
22952
23054
  const previousDetail = recordedDetail(previous2);
22953
23055
  const output2 = update.rawOutput !== void 0 ? formatUnknown(update.rawOutput) : update.content !== void 0 && update.content !== null ? readContentOutput(update.content) : previous2?.output ?? "";
22954
- const content3 = update.content === void 0 || update.content === null ? previous2?.content ?? [] : await normalizeToolContent(update.content, this.#prepareContent);
23056
+ const nextContent = toolContent(update.content, update.rawOutput);
23057
+ const content3 = nextContent.length === 0 ? previous2?.content ?? [] : await normalizeToolContent(nextContent, this.#prepareContent);
22955
23058
  const detailInput = update.rawInput === void 0 ? previousDetail?.input ?? previous2?.input ?? "" : formatUnknownDetail(update.rawInput);
22956
23059
  const detailOutput = update.rawOutput !== void 0 ? formatUnknownDetail(update.rawOutput) : update.content !== void 0 && update.content !== null ? readContentOutputDetail(update.content) : previousDetail?.output ?? previous2?.output ?? "";
22957
- const detailContent = update.content === void 0 || update.content === null ? previousDetail?.content ?? previous2?.content ?? [] : content3;
23060
+ const detailContent = nextContent.length === 0 ? previousDetail?.content ?? previous2?.content ?? [] : content3;
22958
23061
  await this.#record(
22959
23062
  key,
22960
23063
  new AcpActivity(
@@ -30924,7 +31027,7 @@ var MAX_PRE_SESSION_UPDATES = 100;
30924
31027
  var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
30925
31028
  var SESSION_CONTROL_COMMAND_ID = "session-control";
30926
31029
  var NullAcpSessionObserver = class {
30927
- importLocalImage = (_sessionId, _image, signal) => {
31030
+ importLocalArtifact = (_sessionId, _artifact, signal) => {
30928
31031
  signal.throwIfAborted();
30929
31032
  return Promise.resolve("");
30930
31033
  };
@@ -31691,6 +31794,13 @@ var AcpProcessSession = class _AcpProcessSession {
31691
31794
  return await this.importRaster(raster, signal);
31692
31795
  }
31693
31796
  }
31797
+ if (content3.type === "video" && content3.data.length > 0) {
31798
+ const video = readInlineVideo(content3.data, content3.mimeType, content3.name);
31799
+ if (video === null) {
31800
+ return { ...content3, data: "" };
31801
+ }
31802
+ return await this.importVideo(video, AbortSignal.timeout(2e4));
31803
+ }
31694
31804
  return content3;
31695
31805
  };
31696
31806
  emitAgentContent = async (content3, messageId) => {
@@ -31716,7 +31826,7 @@ var AcpProcessSession = class _AcpProcessSession {
31716
31826
  });
31717
31827
  };
31718
31828
  importRaster = async (raster, signal) => {
31719
- const artifactId = await this.#getObserver().importLocalImage(this.#mobiusSessionId, raster, signal);
31829
+ const artifactId = await this.#getObserver().importLocalArtifact(this.#mobiusSessionId, raster, signal);
31720
31830
  return imageDisplayContent(
31721
31831
  raster.mimeType,
31722
31832
  raster.name,
@@ -31724,6 +31834,22 @@ var AcpProcessSession = class _AcpProcessSession {
31724
31834
  artifactId
31725
31835
  );
31726
31836
  };
31837
+ importVideo = async (video, signal) => {
31838
+ const artifactId = await this.#getObserver().importLocalArtifact(this.#mobiusSessionId, video, signal);
31839
+ return {
31840
+ artifactId,
31841
+ data: artifactId.length > 0 ? "" : video.base64(),
31842
+ mimeType: video.mimeType,
31843
+ name: video.name,
31844
+ newText: "",
31845
+ oldText: "",
31846
+ path: "",
31847
+ terminalId: "",
31848
+ text: "",
31849
+ type: "video",
31850
+ uri: ""
31851
+ };
31852
+ };
31727
31853
  async #initializeAgent(signal) {
31728
31854
  await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
31729
31855
  }
@@ -34700,7 +34826,7 @@ var BotOutboundIpcServer = class {
34700
34826
  import { randomUUID as randomUUID3 } from "node:crypto";
34701
34827
  import { mkdir as mkdir4, open as open4, realpath as realpath7, rename as rename3, stat as stat6, writeFile as writeFile2 } from "node:fs/promises";
34702
34828
  import { hostname as hostname3 } from "node:os";
34703
- import { basename as basename2, join as join15, resolve as resolve3 } from "node:path";
34829
+ import { basename as basename3, join as join15, resolve as resolve3 } from "node:path";
34704
34830
  import { fetch as fetch3 } from "undici";
34705
34831
 
34706
34832
  // src/agent-catalog/agent-discovery.ts
@@ -36877,7 +37003,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
36877
37003
  installableAgents,
36878
37004
  machineName: hostname3(),
36879
37005
  pairingCode: options.code,
36880
- workspaceName: basename2(defaultWorkspace) || "Local workspace"
37006
+ workspaceName: basename3(defaultWorkspace) || "Local workspace"
36881
37007
  }),
36882
37008
  dispatcher: environmentProxyDispatcher,
36883
37009
  headers: { "content-type": "application/json" },
@@ -37048,7 +37174,7 @@ async function resumeLocalMachine(arguments_, signal = new AbortController().sig
37048
37174
 
37049
37175
  // src/run-daemon.ts
37050
37176
  import { randomUUID as randomUUID6 } from "node:crypto";
37051
- import { basename as basename5, join as join17 } from "node:path";
37177
+ import { basename as basename6, join as join17 } from "node:path";
37052
37178
  import { styleText } from "node:util";
37053
37179
  import { fetch as fetch7, WebSocket as WebSocket2 } from "undici";
37054
37180
 
@@ -37911,15 +38037,15 @@ async function putContent(url2, authorization, bytes, signal) {
37911
38037
  signal
37912
38038
  });
37913
38039
  }
37914
- async function uploadRuntimeArtifact(config2, sessionId, image, signal) {
38040
+ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
37915
38041
  signal.throwIfAborted();
37916
38042
  let request;
37917
38043
  try {
37918
38044
  request = new MobiusArtifactUploadRequest(
37919
- image.name,
37920
- image.mimeType,
37921
- image.bytes.byteLength,
37922
- createHash3("sha256").update(image.bytes).digest("hex")
38045
+ artifact.name,
38046
+ artifact.mimeType,
38047
+ artifact.bytes.byteLength,
38048
+ createHash3("sha256").update(artifact.bytes).digest("hex")
37923
38049
  );
37924
38050
  } catch (cause) {
37925
38051
  translateSdkError(cause);
@@ -37958,7 +38084,7 @@ async function uploadRuntimeArtifact(config2, sessionId, image, signal) {
37958
38084
  token
37959
38085
  ),
37960
38086
  authorization,
37961
- image.bytes,
38087
+ artifact.bytes,
37962
38088
  requestSignal
37963
38089
  );
37964
38090
  } catch (cause) {
@@ -37990,7 +38116,7 @@ async function uploadRuntimeArtifact(config2, sessionId, image, signal) {
37990
38116
  // src/authorization/workspace-directory.ts
37991
38117
  import { readdir as readdir2, realpath as realpath8, stat as stat7 } from "node:fs/promises";
37992
38118
  import { homedir as homedir2 } from "node:os";
37993
- import { basename as basename3, dirname as dirname6, isAbsolute as isAbsolute10, join as join16, normalize as normalize3, relative as relative5 } from "node:path";
38119
+ import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute10, join as join16, normalize as normalize3, relative as relative5 } from "node:path";
37994
38120
  var WorkspaceDirectoryListing = class {
37995
38121
  directoryId;
37996
38122
  directoryLabel;
@@ -38082,7 +38208,7 @@ var WorkspaceDirectoryService = class {
38082
38208
  return {
38083
38209
  path: path2,
38084
38210
  directoryId: encodePath(path2),
38085
- name: basename3(path2) || path2,
38211
+ name: basename4(path2) || path2,
38086
38212
  label: this.label(path2)
38087
38213
  };
38088
38214
  };
@@ -38176,7 +38302,7 @@ var EmbeddedBotContextApplicator = class {
38176
38302
 
38177
38303
  // src/native-sessions/service.ts
38178
38304
  import { randomUUID as randomUUID4 } from "node:crypto";
38179
- import { basename as basename4 } from "node:path";
38305
+ import { basename as basename5 } from "node:path";
38180
38306
 
38181
38307
  // src/native-sessions/codex-history.ts
38182
38308
  import { spawn as spawn4 } from "node:child_process";
@@ -38685,7 +38811,7 @@ var NativeSessionService = class {
38685
38811
  }
38686
38812
  resolvedPaths.add(path2);
38687
38813
  additionalDirectories.push(path2);
38688
- additionalEntries.push({ directoryId: directoryId2, name: basename4(path2) });
38814
+ additionalEntries.push({ directoryId: directoryId2, name: basename5(path2) });
38689
38815
  }
38690
38816
  const listing = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
38691
38817
  const opened = await this.#sessions.forkSessionAtTurn(
@@ -40007,9 +40133,9 @@ var DaemonAcpObserver = class {
40007
40133
  this.#config = config2;
40008
40134
  this.#record = record3;
40009
40135
  }
40010
- importLocalImage = async (sessionId, image, signal) => {
40136
+ importLocalArtifact = async (sessionId, artifact, signal) => {
40011
40137
  try {
40012
- return (await uploadRuntimeArtifact(this.#config, sessionId, image, signal)).artifactId;
40138
+ return (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
40013
40139
  } catch (cause) {
40014
40140
  signal.throwIfAborted();
40015
40141
  if (cause instanceof Error && cause.name === "AbortError") {
@@ -40580,7 +40706,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
40580
40706
  additionalDirectories.push(directory);
40581
40707
  additionalDirectoryEntries.push({
40582
40708
  directoryId: additionalDirectoryId,
40583
- name: basename5(directory)
40709
+ name: basename6(directory)
40584
40710
  });
40585
40711
  }
40586
40712
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
@@ -42272,7 +42398,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
42272
42398
  import { mkdir as mkdir5, realpath as realpath9, stat as stat8 } from "node:fs/promises";
42273
42399
  import { dirname as dirname8, join as join18, resolve as resolve5 } from "node:path";
42274
42400
  var IDENTIFIER_PATTERN9 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
42275
- var RUNTIME_CREDENTIAL_PATTERN = /^[a-zA-Z0-9_-]{43}$/;
42401
+ 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})$/;
42276
42402
  var MobiusRuntimeConfigurationError = class extends Error {
42277
42403
  code = "runtime_configuration_invalid";
42278
42404
  constructor(message, options = {}) {