@moxt-ai/mobius 0.0.60 → 0.0.62

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 (32) hide show
  1. package/dist/acp/session-config/session-config-protocol.d.ts.map +1 -1
  2. package/dist/acp/session-config/session-config-protocol.js +21 -6
  3. package/dist/acp/session-config/session-config-protocol.js.map +1 -1
  4. package/dist/acp/session-manager.d.ts +0 -3
  5. package/dist/acp/session-manager.d.ts.map +1 -1
  6. package/dist/acp/session-manager.js +16 -36
  7. package/dist/acp/session-manager.js.map +1 -1
  8. package/dist/agent-catalog/agents/deepseek-harness-agent.d.ts.map +1 -1
  9. package/dist/agent-catalog/agents/deepseek-harness-agent.js +39 -8
  10. package/dist/agent-catalog/agents/deepseek-harness-agent.js.map +1 -1
  11. package/dist/agent-installation/deepseek-managed-package.js +2 -2
  12. package/dist/authorization/local-video.d.ts +1 -2
  13. package/dist/authorization/local-video.d.ts.map +1 -1
  14. package/dist/authorization/local-video.js.map +1 -1
  15. package/dist/cli.js +92 -472
  16. package/dist/cli.js.map +4 -4
  17. package/dist/index.js +94 -473
  18. package/dist/index.js.map +4 -4
  19. package/dist/run-daemon.d.ts.map +1 -1
  20. package/dist/run-daemon.js +2 -6
  21. package/dist/run-daemon.js.map +1 -1
  22. package/dist/runtime.js +112 -491
  23. package/dist/runtime.js.map +4 -4
  24. package/package.json +1 -2
  25. package/dist/artifacts/runtime-artifact-uploader.d.ts +0 -12
  26. package/dist/artifacts/runtime-artifact-uploader.d.ts.map +0 -1
  27. package/dist/artifacts/runtime-artifact-uploader.js +0 -150
  28. package/dist/artifacts/runtime-artifact-uploader.js.map +0 -1
  29. package/dist/authorization/local-artifact.d.ts +0 -6
  30. package/dist/authorization/local-artifact.d.ts.map +0 -1
  31. package/dist/authorization/local-artifact.js +0 -2
  32. package/dist/authorization/local-artifact.js.map +0 -1
package/dist/cli.js CHANGED
@@ -6,12 +6,12 @@ var __export = (target, all2) => {
6
6
  };
7
7
 
8
8
  // src/cli.ts
9
- import { mkdir as mkdir5 } from "node:fs/promises";
9
+ import { mkdir as mkdir6 } from "node:fs/promises";
10
10
 
11
11
  // package.json
12
12
  var package_default = {
13
13
  name: "@moxt-ai/mobius",
14
- version: "0.0.60",
14
+ version: "0.0.62",
15
15
  description: "Mobius CLI for pairing and running local AI agent services.",
16
16
  type: "module",
17
17
  bin: {
@@ -57,7 +57,6 @@ var package_default = {
57
57
  },
58
58
  devDependencies: {
59
59
  "@moxt-ai/mobius-protocol": "workspace:*",
60
- "@moxt-ai/mobius-sdk": "workspace:*",
61
60
  "@types/mdast": "4.0.4",
62
61
  "@types/node": "^24.13.4",
63
62
  esbuild: "0.28.2"
@@ -1500,21 +1499,21 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
1500
1499
  };
1501
1500
 
1502
1501
  // src/agent-catalog/agents/deepseek-harness-agent.ts
1503
- import { realpath as realpath3, stat as stat3 } from "node:fs/promises";
1502
+ import { mkdir as mkdir2, realpath as realpath3, stat as stat3, writeFile } from "node:fs/promises";
1504
1503
  import { isAbsolute as isAbsolute3, join as join6, normalize } from "node:path";
1505
1504
 
1506
1505
  // src/agent-installation/deepseek-managed-package.ts
1507
1506
  var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
1508
- dependencyResolutionArguments = Object.freeze(["--before=2026-09-03T06:31:52.107Z"]);
1507
+ dependencyResolutionArguments = Object.freeze(["--before=2026-09-18T00:00:00.000Z"]);
1509
1508
  includeOptionalDependencies = true;
1510
1509
  verifyDependencyClosure = true;
1511
1510
  };
1512
1511
  var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
1513
1512
  "@deepseek-ai/dsh",
1514
- "0.1.2-rc.1",
1513
+ "0.1.5-rc.2",
1515
1514
  "dsh",
1516
- "sha512-RPq48TzxvwpdT9/7W1tbhZDBMmeK+bxDrX9cqQC27Wx/LqtgJF8PSa3b3xriU8oxtvhwYmk21w2cej3uMQrnVA==",
1517
- "https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.2-rc.1.tgz"
1515
+ "sha512-8Xc8hCQHcIWRmTCVU/xZdp6/qMsWMeAd2ObChKDEsfhUPJFXx6H0lgeb1DxUMD86HZrrVN+1bCvn1ppjZ/fOxw==",
1516
+ "https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.5-rc.2.tgz"
1518
1517
  );
1519
1518
 
1520
1519
  // src/storage/state-directory.ts
@@ -1529,16 +1528,30 @@ function readStateDirectory(environment = process.env) {
1529
1528
  }
1530
1529
 
1531
1530
  // src/agent-catalog/agents/deepseek-harness-agent.ts
1532
- async function validateAgentHome(path2) {
1531
+ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP bridge to an image-capable route.
1532
+ - id: acp
1533
+ config:
1534
+ provider: deepseek-official
1535
+ model: deepseek-v4-flash-vision-exp
1536
+ `;
1537
+ async function prepareAgentHome(path2, imagePrompts) {
1533
1538
  if (!isAbsolute3(path2) || normalize(path2) !== path2) {
1534
1539
  throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
1535
1540
  }
1536
1541
  try {
1542
+ if (imagePrompts) {
1543
+ await mkdir2(path2, { mode: 448, recursive: true });
1544
+ }
1537
1545
  const resolved = await realpath3(path2);
1538
1546
  const metadata = await stat3(resolved);
1539
1547
  if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
1540
1548
  throw new Error("Agent home is not a user-owned directory");
1541
1549
  }
1550
+ if (imagePrompts) {
1551
+ await writeFile(join6(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
1552
+ mode: 384
1553
+ });
1554
+ }
1542
1555
  return resolved;
1543
1556
  } catch (error62) {
1544
1557
  if (error62 instanceof AgentProbeError) {
@@ -1573,6 +1586,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
1573
1586
  }
1574
1587
  createLaunchEnvironment = async (agent, context) => {
1575
1588
  let selectedHome = context.environment["DSH_HOME"];
1589
+ let managedHome = false;
1576
1590
  try {
1577
1591
  const managed = await this.resolveManagedAgent(
1578
1592
  readStateDirectory(context.environment),
@@ -1581,6 +1595,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
1581
1595
  );
1582
1596
  if (managed.path === agent.path) {
1583
1597
  selectedHome = join6(readStateDirectory(context.environment), "agents", this.id, "home");
1598
+ managedHome = true;
1584
1599
  }
1585
1600
  } catch {
1586
1601
  context.signal.throwIfAborted();
@@ -1589,7 +1604,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
1589
1604
  return Object.freeze({});
1590
1605
  }
1591
1606
  return Object.freeze({
1592
- DSH_HOME: await validateAgentHome(selectedHome)
1607
+ DSH_HOME: await prepareAgentHome(selectedHome, managedHome)
1593
1608
  });
1594
1609
  };
1595
1610
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
@@ -1604,8 +1619,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
1604
1619
  verifyAcp = (_connection, initialized, _defaultWorkspace, _signal) => {
1605
1620
  const capabilities = initialized.agentCapabilities ?? {};
1606
1621
  const session = capabilities.sessionCapabilities;
1607
- const prompt = capabilities.promptCapabilities;
1608
- if ((initialized.authMethods ?? []).length !== 0 || capabilities.loadSession === true || capabilities.mcpCapabilities?.http !== true || session?.close == null || session.list == null || session.resume == null || session.additionalDirectories != null || session.delete != null || session.fork != null || prompt?.audio === true || prompt?.embeddedContext === true || prompt?.image === true) {
1622
+ if ((initialized.authMethods ?? []).length !== 0 || capabilities.loadSession === true || capabilities.mcpCapabilities?.http !== true || session?.close == null || session.list == null || session.resume == null || session.additionalDirectories != null || session.delete != null || session.fork != null) {
1609
1623
  throw new AgentProbeError(
1610
1624
  "acp_incompatible",
1611
1625
  "DeepSeek Harness reported an unsupported ACP capability set"
@@ -1816,7 +1830,7 @@ import { join as join9 } from "node:path";
1816
1830
  // src/agent-installation/managed-agent-archive.ts
1817
1831
  import { createHash } from "node:crypto";
1818
1832
  import { createReadStream } from "node:fs";
1819
- import { chmod, copyFile, mkdir as mkdir2, mkdtemp as mkdtemp2, open as open2, realpath as realpath5, rename as rename2, rm as rm2, stat as stat4, writeFile } from "node:fs/promises";
1833
+ import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open2, realpath as realpath5, rename as rename2, rm as rm2, stat as stat4, writeFile as writeFile2 } from "node:fs/promises";
1820
1834
  import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute5, join as join8, relative as relative3, sep as sep3 } from "node:path";
1821
1835
 
1822
1836
  // src/agent-installation/verified-download.ts
@@ -19477,8 +19491,8 @@ function rewriteKeyNames(ctx) {
19477
19491
  bySchema.set(entry.schema, entry);
19478
19492
  }
19479
19493
  const rewrites = /* @__PURE__ */ new Map();
19480
- for (const record3 of pendingRecords.get(ctx) ?? []) {
19481
- const seen = ctx.seen.get(record3);
19494
+ for (const record2 of pendingRecords.get(ctx) ?? []) {
19495
+ const seen = ctx.seen.get(record2);
19482
19496
  const names = (seen?.def ?? seen?.schema)?.propertyNames;
19483
19497
  if (!names || names === true || rewrites.has(names))
19484
19498
  continue;
@@ -22714,7 +22728,11 @@ var configValueSchema = external_exports.strictObject({
22714
22728
  groupId: external_exports.string().max(128),
22715
22729
  groupName: external_exports.string().max(255),
22716
22730
  name: external_exports.string().min(1).max(255),
22717
- value: external_exports.string().min(1).max(500)
22731
+ // ACP types a select value id as any string, and Agents use the empty
22732
+ // id to mean "the provider's own default" — no explicit setting is
22733
+ // sent. Refusing it would drop the whole option, so the id is bounded
22734
+ // by length alone.
22735
+ value: external_exports.string().max(500)
22718
22736
  }).readonly();
22719
22737
  var sessionConfigOptionSchema = external_exports.strictObject({
22720
22738
  booleanValue: external_exports.boolean(),
@@ -24316,14 +24334,14 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
24316
24334
  }
24317
24335
 
24318
24336
  // src/pairing/pair-local-machine.ts
24319
- import { mkdir as mkdir4, realpath as realpath6, stat as stat5 } from "node:fs/promises";
24337
+ import { mkdir as mkdir5, realpath as realpath6, stat as stat5 } from "node:fs/promises";
24320
24338
  import { hostname as hostname3 } from "node:os";
24321
24339
  import { basename, resolve as resolve5 } from "node:path";
24322
24340
  import { fetch as fetch2 } from "undici";
24323
24341
 
24324
24342
  // src/storage/runtime-installation-store.ts
24325
24343
  import { createHash as createHash2, randomUUID } from "node:crypto";
24326
- import { mkdir as mkdir3, open as open4, rename as rename3, unlink, writeFile as writeFile2 } from "node:fs/promises";
24344
+ import { mkdir as mkdir4, open as open4, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
24327
24345
  import { dirname as dirname3, join as join15, resolve as resolve4 } from "node:path";
24328
24346
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
24329
24347
  var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
@@ -24626,9 +24644,9 @@ async function writeJsonAtomically(path2, value, signal) {
24626
24644
  const directory = dirname3(path2);
24627
24645
  const temporaryPath = join15(directory, `.${randomUUID()}.tmp`);
24628
24646
  try {
24629
- await mkdir3(directory, { mode: 448, recursive: true });
24647
+ await mkdir4(directory, { mode: 448, recursive: true });
24630
24648
  signal.throwIfAborted();
24631
- await writeFile2(temporaryPath, `${JSON.stringify(value, null, 2)}
24649
+ await writeFile3(temporaryPath, `${JSON.stringify(value, null, 2)}
24632
24650
  `, { flag: "wx", mode: 384 });
24633
24651
  signal.throwIfAborted();
24634
24652
  await rename3(temporaryPath, path2);
@@ -24659,7 +24677,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
24659
24677
  const rootDirectory = resolve4(options.stateDirectory);
24660
24678
  const applicationDirectory = join15(rootDirectory, "installations", applicationId);
24661
24679
  try {
24662
- await mkdir3(applicationDirectory, { mode: 448, recursive: true });
24680
+ await mkdir4(applicationDirectory, { mode: 448, recursive: true });
24663
24681
  } catch (cause) {
24664
24682
  throw new RuntimeInstallationStoreError(
24665
24683
  "installation_unavailable",
@@ -24672,7 +24690,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
24672
24690
  const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
24673
24691
  const stateDirectory = join15(applicationDirectory, storedInstallationId);
24674
24692
  try {
24675
- await mkdir3(stateDirectory, { mode: 448, recursive: true });
24693
+ await mkdir4(stateDirectory, { mode: 448, recursive: true });
24676
24694
  } catch (cause) {
24677
24695
  throw new RuntimeInstallationStoreError(
24678
24696
  "installation_unavailable",
@@ -24828,7 +24846,7 @@ async function readOrCreateInstallationId(applicationDirectory, signal) {
24828
24846
  }
24829
24847
  const candidate = installationId();
24830
24848
  try {
24831
- await writeFile2(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
24849
+ await writeFile3(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
24832
24850
  `, {
24833
24851
  flag: "wx",
24834
24852
  mode: 384
@@ -24992,7 +25010,7 @@ function parseResumeArgument(arguments_) {
24992
25010
  async function resolveDefaultWorkspace(path2) {
24993
25011
  const requestedWorkspace = resolve5(path2);
24994
25012
  try {
24995
- await mkdir4(requestedWorkspace, { recursive: true, mode: 448 });
25013
+ await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
24996
25014
  const defaultWorkspace = await realpath6(requestedWorkspace);
24997
25015
  const metadata = await stat5(defaultWorkspace);
24998
25016
  if (!metadata.isDirectory()) {
@@ -25206,7 +25224,7 @@ var AuditStore = class {
25206
25224
  this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
25207
25225
  }
25208
25226
  }
25209
- record(record3) {
25227
+ record(record2) {
25210
25228
  this.database.prepare(
25211
25229
  `
25212
25230
  INSERT INTO audit_events (
@@ -25219,10 +25237,10 @@ var AuditStore = class {
25219
25237
  `
25220
25238
  ).run(
25221
25239
  (/* @__PURE__ */ new Date()).toISOString(),
25222
- record3.event,
25223
- record3.commandId,
25224
- record3.sessionId,
25225
- JSON.stringify(record3.details ?? {})
25240
+ record2.event,
25241
+ record2.commandId,
25242
+ record2.sessionId,
25243
+ JSON.stringify(record2.details ?? {})
25226
25244
  );
25227
25245
  }
25228
25246
  close() {
@@ -25231,10 +25249,10 @@ var AuditStore = class {
25231
25249
  };
25232
25250
 
25233
25251
  // src/run-daemon.ts
25234
- import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
25252
+ import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
25235
25253
  import { basename as basename7 } from "node:path";
25236
25254
  import { styleText } from "node:util";
25237
- import { fetch as fetch6, WebSocket as WebSocket2 } from "undici";
25255
+ import { fetch as fetch5, WebSocket as WebSocket2 } from "undici";
25238
25256
 
25239
25257
  // src/acp/session-manager.ts
25240
25258
  import { spawn as spawn3 } from "node:child_process";
@@ -33306,12 +33324,16 @@ function readBoolean(value, fallback = false) {
33306
33324
  return typeof value === "boolean" ? value : fallback;
33307
33325
  }
33308
33326
  function normalizeConfigValue(option, groupId = "", groupName = "") {
33327
+ const value = option["value"];
33328
+ if (typeof value !== "string") {
33329
+ return void 0;
33330
+ }
33309
33331
  return {
33310
33332
  description: truncate2(readString2(option["description"]), 500),
33311
33333
  groupId: truncate2(groupId, 128),
33312
33334
  groupName: truncate2(groupName, 255),
33313
- name: truncate2(readString2(option["name"], readString2(option["value"])), 255),
33314
- value: truncate2(readString2(option["value"]), 500)
33335
+ name: truncate2(readString2(option["name"], value), 255),
33336
+ value: truncate2(value, 500)
33315
33337
  };
33316
33338
  }
33317
33339
  function normalizeConfigValues(value) {
@@ -33329,14 +33351,20 @@ function normalizeConfigValues(value) {
33329
33351
  const groupName = readString2(entry["name"]);
33330
33352
  for (const groupedOption of groupedOptions) {
33331
33353
  if (isRecord8(groupedOption)) {
33332
- normalized.push(normalizeConfigValue(groupedOption, groupId, groupName));
33354
+ const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
33355
+ if (normalizedValue !== void 0) {
33356
+ normalized.push(normalizedValue);
33357
+ }
33333
33358
  }
33334
33359
  }
33335
33360
  continue;
33336
33361
  }
33337
- normalized.push(normalizeConfigValue(entry));
33362
+ const normalizedEntry = normalizeConfigValue(entry);
33363
+ if (normalizedEntry !== void 0) {
33364
+ normalized.push(normalizedEntry);
33365
+ }
33338
33366
  }
33339
- return normalized.filter((entry) => entry.value.length > 0).slice(0, 500);
33367
+ return normalized.slice(0, 500);
33340
33368
  }
33341
33369
  function normalizeConfigOptions(value, modes) {
33342
33370
  const normalized = [];
@@ -33367,7 +33395,7 @@ function normalizeConfigOptions(value, modes) {
33367
33395
  if (option["type"] === "select") {
33368
33396
  const values = normalizeConfigValues(option["options"]);
33369
33397
  const currentValue = truncate2(readString2(option["currentValue"]), 500);
33370
- if (currentValue.length > 0 && values.some((entry) => entry.value === currentValue)) {
33398
+ if (values.some((entry) => entry.value === currentValue)) {
33371
33399
  normalized.push({
33372
33400
  booleanValue: false,
33373
33401
  category,
@@ -33938,10 +33966,6 @@ var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
33938
33966
  var SESSION_CONTROL_COMMAND_ID = "session-control";
33939
33967
  var SESSION_CONTROL_TIMEOUT_MILLISECONDS = 3e4;
33940
33968
  var NullAcpSessionObserver = class {
33941
- importLocalArtifact = (_sessionId, _artifact, signal) => {
33942
- signal.throwIfAborted();
33943
- return Promise.resolve("");
33944
- };
33945
33969
  onCommands = () => Promise.resolve();
33946
33970
  onConfig = () => Promise.resolve();
33947
33971
  onContent = () => Promise.resolve();
@@ -34501,20 +34525,7 @@ var AcpProcessSession = class _AcpProcessSession {
34501
34525
  #agentName = "";
34502
34526
  #agentVersion = "";
34503
34527
  #bufferedAgentText = [];
34504
- #capabilities = {
34505
- additionalDirectories: false,
34506
- audioPrompt: false,
34507
- closeSession: false,
34508
- deleteSession: false,
34509
- embeddedContextPrompt: false,
34510
- imagePrompt: false,
34511
- listSessions: false,
34512
- loadSession: false,
34513
- promptQueueing: false,
34514
- resumeSession: false,
34515
- steering: false,
34516
- unstableForkSession: false
34517
- };
34528
+ #capabilities = unsupportedSessionCapabilities();
34518
34529
  #commands = [];
34519
34530
  #configRevision = 0;
34520
34531
  #configOptions = [];
@@ -34734,7 +34745,7 @@ var AcpProcessSession = class _AcpProcessSession {
34734
34745
  if (video === null) {
34735
34746
  return { ...content3, data: "" };
34736
34747
  }
34737
- return await this.importVideo(video, AbortSignal.timeout(2e4));
34748
+ return this.importVideo(video);
34738
34749
  }
34739
34750
  return content3;
34740
34751
  };
@@ -34785,22 +34796,19 @@ var AcpProcessSession = class _AcpProcessSession {
34785
34796
  }
34786
34797
  return imageDisplayContent(raster.mimeType, raster.name, await raster.base64(), "");
34787
34798
  };
34788
- importVideo = async (video, signal) => {
34789
- const artifactId = await this.#getObserver().importLocalArtifact(this.#mobiusSessionId, video, signal);
34790
- return {
34791
- artifactId,
34792
- data: artifactId.length > 0 ? "" : video.base64(),
34793
- mimeType: video.mimeType,
34794
- name: video.name,
34795
- newText: "",
34796
- oldText: "",
34797
- path: "",
34798
- terminalId: "",
34799
- text: "",
34800
- type: "video",
34801
- uri: ""
34802
- };
34803
- };
34799
+ importVideo = (video) => ({
34800
+ artifactId: "",
34801
+ data: video.base64(),
34802
+ mimeType: video.mimeType,
34803
+ name: video.name,
34804
+ newText: "",
34805
+ oldText: "",
34806
+ path: "",
34807
+ terminalId: "",
34808
+ text: "",
34809
+ type: "video",
34810
+ uri: ""
34811
+ });
34804
34812
  async #initializeAgent(signal) {
34805
34813
  await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
34806
34814
  }
@@ -37622,391 +37630,6 @@ async function streamLocalFile(command, send2, signal) {
37622
37630
  });
37623
37631
  }
37624
37632
 
37625
- // src/artifacts/runtime-artifact-uploader.ts
37626
- import { createHash as createHash3 } from "node:crypto";
37627
-
37628
- // ../mobius-sdk/src/errors.ts
37629
- var MobiusError = class extends Error {
37630
- code;
37631
- constructor(code, message, options = {}) {
37632
- super(message, options);
37633
- this.code = code;
37634
- this.name = "MobiusError";
37635
- }
37636
- };
37637
- var MobiusProtocolError = class extends MobiusError {
37638
- constructor(message, options = {}) {
37639
- super("invalid_service_response", message, options);
37640
- this.name = "MobiusProtocolError";
37641
- }
37642
- };
37643
- var MobiusValidationError = class extends MobiusError {
37644
- constructor(message, options = {}) {
37645
- super("invalid_request", message, options);
37646
- this.name = "MobiusValidationError";
37647
- }
37648
- };
37649
-
37650
- // ../mobius-sdk/src/resources.ts
37651
- var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
37652
- function invalidResponse(message) {
37653
- return new MobiusProtocolError(message);
37654
- }
37655
- function isRecord11(value) {
37656
- return typeof value === "object" && value !== null && !Array.isArray(value);
37657
- }
37658
- function record2(value, name) {
37659
- if (!isRecord11(value)) {
37660
- throw invalidResponse(`The service returned an invalid ${name}`);
37661
- }
37662
- return value;
37663
- }
37664
- function stringField(value, field, maximumLength = 85e5) {
37665
- const candidate = value[field];
37666
- if (typeof candidate !== "string" || candidate.length > maximumLength) {
37667
- throw invalidResponse(`The service returned an invalid ${field}`);
37668
- }
37669
- return candidate;
37670
- }
37671
- function identifierField(value, field) {
37672
- const candidate = stringField(value, field, 128);
37673
- if (!IDENTIFIER_PATTERN6.test(candidate)) {
37674
- throw invalidResponse(`The service returned an invalid ${field}`);
37675
- }
37676
- return candidate;
37677
- }
37678
- function integerField(value, field) {
37679
- const candidate = value[field];
37680
- if (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0) {
37681
- throw invalidResponse(`The service returned an invalid ${field}`);
37682
- }
37683
- return candidate;
37684
- }
37685
- function validateTimestamp(value, field) {
37686
- if (Number.isNaN(Date.parse(value))) {
37687
- throw invalidResponse(`The service returned an invalid ${field}`);
37688
- }
37689
- return value;
37690
- }
37691
- var MobiusArtifactUploadRequest = class {
37692
- byteLength;
37693
- mediaType;
37694
- name;
37695
- sha256;
37696
- constructor(name, mediaType, byteLength, sha256) {
37697
- if (name.length < 1 || name.length > 500 || name.includes("\0") || mediaType.length < 1 || mediaType.length > 255 || mediaType.includes("\r") || mediaType.includes("\n") || !Number.isSafeInteger(byteLength) || byteLength < 1 || !/^[a-f0-9]{64}$/.test(sha256)) {
37698
- throw new MobiusValidationError("The artifact upload request is invalid");
37699
- }
37700
- this.byteLength = byteLength;
37701
- this.mediaType = mediaType;
37702
- this.name = name;
37703
- this.sha256 = sha256;
37704
- }
37705
- };
37706
- var MobiusArtifact = class {
37707
- artifactId;
37708
- byteLength;
37709
- createdAt;
37710
- mediaType;
37711
- name;
37712
- sessionId;
37713
- sha256;
37714
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt) {
37715
- this.artifactId = artifactId;
37716
- this.byteLength = byteLength;
37717
- this.createdAt = createdAt;
37718
- this.mediaType = mediaType;
37719
- this.name = name;
37720
- this.sessionId = sessionId;
37721
- this.sha256 = sha256;
37722
- }
37723
- };
37724
- var MobiusUploadingArtifact = class extends MobiusArtifact {
37725
- expiresAt;
37726
- state = "uploading";
37727
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiresAt) {
37728
- super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
37729
- this.expiresAt = expiresAt;
37730
- }
37731
- };
37732
- var MobiusArtifactUpload = class extends MobiusUploadingArtifact {
37733
- uploadToken;
37734
- constructor(artifact, uploadToken) {
37735
- super(
37736
- artifact.sessionId,
37737
- artifact.artifactId,
37738
- artifact.name,
37739
- artifact.mediaType,
37740
- artifact.byteLength,
37741
- artifact.sha256,
37742
- artifact.createdAt,
37743
- artifact.expiresAt
37744
- );
37745
- this.uploadToken = uploadToken;
37746
- }
37747
- };
37748
- var MobiusAvailableArtifact = class extends MobiusArtifact {
37749
- availableAt;
37750
- state = "available";
37751
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, availableAt) {
37752
- super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
37753
- this.availableAt = availableAt;
37754
- }
37755
- };
37756
- var MobiusExpiredArtifact = class extends MobiusArtifact {
37757
- expiredAt;
37758
- state = "expired";
37759
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiredAt) {
37760
- super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
37761
- this.expiredAt = expiredAt;
37762
- }
37763
- };
37764
- function artifactFields(value) {
37765
- const sha256 = stringField(value, "sha256", 64);
37766
- if (!/^[a-f0-9]{64}$/.test(sha256)) {
37767
- throw invalidResponse("The service returned an invalid artifact digest");
37768
- }
37769
- return {
37770
- artifactId: identifierField(value, "artifactId"),
37771
- byteLength: integerField(value, "byteLength"),
37772
- createdAt: validateTimestamp(stringField(value, "createdAt", 128), "createdAt"),
37773
- mediaType: stringField(value, "mediaType", 255),
37774
- name: stringField(value, "name", 500),
37775
- sessionId: identifierField(value, "sessionId"),
37776
- sha256
37777
- };
37778
- }
37779
- function uploadingArtifact(value) {
37780
- const fields = artifactFields(value);
37781
- return new MobiusUploadingArtifact(
37782
- fields.sessionId,
37783
- fields.artifactId,
37784
- fields.name,
37785
- fields.mediaType,
37786
- fields.byteLength,
37787
- fields.sha256,
37788
- fields.createdAt,
37789
- validateTimestamp(stringField(value, "expiresAt", 128), "expiresAt")
37790
- );
37791
- }
37792
- function decodeMobiusArtifactUpload(value) {
37793
- const artifact = record2(value, "artifact upload authorization");
37794
- return new MobiusArtifactUpload(uploadingArtifact(artifact), stringField(artifact, "uploadToken", 256));
37795
- }
37796
- function decodeMobiusArtifact(value) {
37797
- const artifact = record2(value, "artifact");
37798
- const state = stringField(artifact, "state", 32);
37799
- if (state === "uploading") {
37800
- return uploadingArtifact(artifact);
37801
- }
37802
- const fields = artifactFields(artifact);
37803
- if (state === "available") {
37804
- return new MobiusAvailableArtifact(
37805
- fields.sessionId,
37806
- fields.artifactId,
37807
- fields.name,
37808
- fields.mediaType,
37809
- fields.byteLength,
37810
- fields.sha256,
37811
- fields.createdAt,
37812
- validateTimestamp(stringField(artifact, "availableAt", 128), "availableAt")
37813
- );
37814
- }
37815
- if (state === "expired") {
37816
- return new MobiusExpiredArtifact(
37817
- fields.sessionId,
37818
- fields.artifactId,
37819
- fields.name,
37820
- fields.mediaType,
37821
- fields.byteLength,
37822
- fields.sha256,
37823
- fields.createdAt,
37824
- validateTimestamp(stringField(artifact, "expiredAt", 128), "expiredAt")
37825
- );
37826
- }
37827
- throw invalidResponse("The service returned an invalid artifact state");
37828
- }
37829
- function decodeMobiusAvailableArtifact(value) {
37830
- const artifact = decodeMobiusArtifact(value);
37831
- if (!(artifact instanceof MobiusAvailableArtifact)) {
37832
- throw invalidResponse("The service did not make the artifact available");
37833
- }
37834
- return artifact;
37835
- }
37836
- var MobiusRuntimePairingLifecycle = Object.freeze({
37837
- Expired: "expired",
37838
- Paired: "paired",
37839
- Pending: "pending",
37840
- Revoked: "revoked"
37841
- });
37842
-
37843
- // src/artifacts/runtime-artifact-uploader.ts
37844
- import { fetch as fetch4 } from "undici";
37845
- var UPLOAD_TIMEOUT_MILLISECONDS = 2e4;
37846
- var RuntimeArtifactUploadError = class extends Error {
37847
- code;
37848
- constructor(code, message, options = {}) {
37849
- super(message, options);
37850
- this.code = code;
37851
- this.name = "RuntimeArtifactUploadError";
37852
- }
37853
- };
37854
- var UploadedRuntimeArtifact = class {
37855
- artifactId;
37856
- byteLength;
37857
- mimeType;
37858
- name;
37859
- sha256;
37860
- constructor(artifactId, name, mimeType, byteLength, sha256) {
37861
- this.artifactId = artifactId;
37862
- this.byteLength = byteLength;
37863
- this.mimeType = mimeType;
37864
- this.name = name;
37865
- this.sha256 = sha256;
37866
- }
37867
- };
37868
- function channelOrigin(config2) {
37869
- const url2 = new URL(config2.relayUrl);
37870
- url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
37871
- let channelPath = "";
37872
- if (url2.pathname.endsWith("/daemon")) {
37873
- channelPath = url2.pathname.slice(0, -"/daemon".length);
37874
- } else {
37875
- const runtimePath = `${MOBIUS_API_PREFIX}/v1/runtimes/connect`;
37876
- if (!url2.pathname.endsWith("/v1/runtimes/connect") && !url2.pathname.endsWith(runtimePath)) {
37877
- throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay artifact endpoint is invalid");
37878
- }
37879
- channelPath = `${url2.pathname.replace(/\/v1\/runtimes\/connect$/, "")}/channels/${encodeURIComponent(config2.channelId)}`;
37880
- }
37881
- url2.pathname = channelPath;
37882
- url2.search = "";
37883
- url2.hash = "";
37884
- return url2;
37885
- }
37886
- function uploadError(code, message, cause) {
37887
- return new RuntimeArtifactUploadError(code, message, cause === void 0 ? {} : { cause });
37888
- }
37889
- function translateSdkError(cause) {
37890
- if (cause instanceof MobiusValidationError) {
37891
- throw uploadError("artifact_upload_failed", cause.message, cause);
37892
- }
37893
- if (cause instanceof MobiusProtocolError) {
37894
- throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
37895
- }
37896
- throw cause;
37897
- }
37898
- async function readJson(response) {
37899
- try {
37900
- return await response.json();
37901
- } catch (cause) {
37902
- throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
37903
- }
37904
- }
37905
- async function readAuthorization(response) {
37906
- try {
37907
- return decodeMobiusArtifactUpload(await readJson(response));
37908
- } catch (cause) {
37909
- translateSdkError(cause);
37910
- }
37911
- }
37912
- function sessionArtifactUrl(origin, sessionId, resourcePath) {
37913
- return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
37914
- }
37915
- async function postLease(url2, headers, request, signal) {
37916
- return await fetch4(url2, {
37917
- dispatcher: environmentProxyDispatcher,
37918
- headers: { ...headers, "content-type": "application/json" },
37919
- method: "POST",
37920
- body: JSON.stringify(request),
37921
- signal
37922
- });
37923
- }
37924
- async function putContent(url2, headers, authorization, bytes, signal) {
37925
- return await fetch4(url2, {
37926
- dispatcher: environmentProxyDispatcher,
37927
- headers: {
37928
- ...headers,
37929
- "content-type": authorization.mediaType,
37930
- "x-mobius-upload-token": authorization.uploadToken
37931
- },
37932
- method: "PUT",
37933
- body: bytes,
37934
- signal
37935
- });
37936
- }
37937
- async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
37938
- signal.throwIfAborted();
37939
- let request;
37940
- try {
37941
- request = new MobiusArtifactUploadRequest(
37942
- artifact.name,
37943
- artifact.mimeType,
37944
- artifact.bytes.byteLength,
37945
- createHash3("sha256").update(artifact.bytes).digest("hex")
37946
- );
37947
- } catch (cause) {
37948
- translateSdkError(cause);
37949
- }
37950
- const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
37951
- const requestSignal = AbortSignal.any([signal, timeoutSignal]);
37952
- const origin = channelOrigin(config2);
37953
- const headers = runtimeAuthorization(config2.relayUrl);
37954
- let created;
37955
- try {
37956
- created = await postLease(
37957
- sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
37958
- headers,
37959
- request,
37960
- requestSignal
37961
- );
37962
- } catch (cause) {
37963
- signal.throwIfAborted();
37964
- throw uploadError(
37965
- timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
37966
- timeoutSignal.aborted ? "The artifact upload authorization timed out" : "The artifact upload could not start",
37967
- cause
37968
- );
37969
- }
37970
- if (!created.ok) {
37971
- await created.body?.cancel();
37972
- throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact upload");
37973
- }
37974
- const authorization = await readAuthorization(created);
37975
- let uploaded;
37976
- try {
37977
- uploaded = await putContent(
37978
- sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
37979
- headers,
37980
- authorization,
37981
- artifact.bytes,
37982
- requestSignal
37983
- );
37984
- } catch (cause) {
37985
- signal.throwIfAborted();
37986
- throw uploadError(
37987
- timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
37988
- timeoutSignal.aborted ? "The artifact upload timed out" : "The artifact content could not be uploaded",
37989
- cause
37990
- );
37991
- }
37992
- if (!uploaded.ok) {
37993
- await uploaded.body?.cancel();
37994
- throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact content");
37995
- }
37996
- try {
37997
- const available = decodeMobiusAvailableArtifact(await readJson(uploaded));
37998
- return new UploadedRuntimeArtifact(
37999
- available.artifactId,
38000
- available.name,
38001
- available.mediaType,
38002
- available.byteLength,
38003
- available.sha256
38004
- );
38005
- } catch (cause) {
38006
- translateSdkError(cause);
38007
- }
38008
- }
38009
-
38010
37633
  // src/authorization/local-authorization-error.ts
38011
37634
  var LocalAuthorizationError = class extends Error {
38012
37635
  code = "local_authorization_failed";
@@ -38835,13 +38458,13 @@ var NativeSessionService = class {
38835
38458
  };
38836
38459
 
38837
38460
  // src/prompt-artifact-resolver.ts
38838
- import { createHash as createHash4 } from "node:crypto";
38839
- import { fetch as fetch5 } from "undici";
38461
+ import { createHash as createHash3 } from "node:crypto";
38462
+ import { fetch as fetch4 } from "undici";
38840
38463
  var ARTIFACT_SCHEME = "mobius-artifact:";
38841
38464
  var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
38842
38465
  var MAX_AGENT_IMAGE_BASE64_LENGTH = 4e6;
38843
38466
  var MAX_AGENT_RESOURCE_BYTE_LENGTH = 1e6;
38844
- var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
38467
+ var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
38845
38468
  var PromptArtifactError = class extends Error {
38846
38469
  code;
38847
38470
  constructor(code, message, options = {}) {
@@ -38884,7 +38507,7 @@ function parseReference(resource) {
38884
38507
  const encodedByteLength2 = url2.searchParams.get("byteLength") ?? "";
38885
38508
  const sha256 = url2.searchParams.get("sha256") ?? "";
38886
38509
  const byteLength = Number(encodedByteLength2);
38887
- if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !IDENTIFIER_PATTERN7.test(artifactId) || keys.length !== 2 || keys[0] !== "byteLength" || keys[1] !== "sha256" || !/^[1-9][0-9]*$/.test(encodedByteLength2) || !Number.isSafeInteger(byteLength) || !/^[a-f0-9]{64}$/.test(sha256)) {
38510
+ if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !IDENTIFIER_PATTERN6.test(artifactId) || keys.length !== 2 || keys[0] !== "byteLength" || keys[1] !== "sha256" || !/^[1-9][0-9]*$/.test(encodedByteLength2) || !Number.isSafeInteger(byteLength) || !/^[a-f0-9]{64}$/.test(sha256)) {
38888
38511
  throw new PromptArtifactError("artifact_reference_invalid", "The prompt artifact reference is invalid");
38889
38512
  }
38890
38513
  return new PromptArtifactReference(artifactId, byteLength, sha256, resource);
@@ -38950,7 +38573,7 @@ async function download(config2, command, reference, signal) {
38950
38573
  const requestSignal = AbortSignal.any([signal, timeoutSignal]);
38951
38574
  let response;
38952
38575
  try {
38953
- response = await fetch5(downloadUrl(config2, command, reference), {
38576
+ response = await fetch4(downloadUrl(config2, command, reference), {
38954
38577
  dispatcher: environmentProxyDispatcher,
38955
38578
  headers: {
38956
38579
  accept: reference.resource.mimeType,
@@ -38974,7 +38597,7 @@ async function download(config2, command, reference, signal) {
38974
38597
  );
38975
38598
  }
38976
38599
  const bytes = await responseBytes(response, reference.byteLength, requestSignal);
38977
- if (createHash4("sha256").update(bytes).digest("hex") !== reference.sha256) {
38600
+ if (createHash3("sha256").update(bytes).digest("hex") !== reference.sha256) {
38978
38601
  throw new PromptArtifactError(
38979
38602
  "artifact_integrity_failed",
38980
38603
  "The prompt artifact failed integrity validation"
@@ -40079,13 +39702,10 @@ var AGENT_TEXT_MAXIMUM_LENGTH = 1e5;
40079
39702
  var ACTIVE_TURN_RECONCILIATION_TIMEOUT_MILLISECONDS = 2e4;
40080
39703
  var ACTIVE_TURN_RECONCILIATION_CLOSE_CODE = 4009;
40081
39704
  var DaemonAcpObserver = class {
40082
- #config;
40083
39705
  #record;
40084
- constructor(config2, record3) {
40085
- this.#config = config2;
40086
- this.#record = record3;
39706
+ constructor(record2) {
39707
+ this.#record = record2;
40087
39708
  }
40088
- importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
40089
39709
  onCommands = (event) => {
40090
39710
  this.#record(event.sessionId, event);
40091
39711
  return Promise.resolve();
@@ -40303,7 +39923,7 @@ async function reconcileActiveTurn(config2, turn, signal) {
40303
39923
  const requestSignal = AbortSignal.any([signal, timeoutSignal]);
40304
39924
  let response;
40305
39925
  try {
40306
- response = await fetch6(activeTurnReconciliationEndpoint(config2, turn), {
39926
+ response = await fetch5(activeTurnReconciliationEndpoint(config2, turn), {
40307
39927
  body: JSON.stringify({ outcome: { kind: "running" } }),
40308
39928
  dispatcher: environmentProxyDispatcher,
40309
39929
  headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
@@ -40813,7 +40433,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
40813
40433
  resolution: modelEffort.resolution,
40814
40434
  valuesByModel: {}
40815
40435
  };
40816
- return createHash5("sha256").update(
40436
+ return createHash4("sha256").update(
40817
40437
  JSON.stringify({
40818
40438
  adapterVersion: agent.adapterVersion,
40819
40439
  agentId: agent.id,
@@ -42366,7 +41986,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
42366
41986
  }
42367
41987
  publisher.recordAttempt(sessionId, event, attemptId);
42368
41988
  };
42369
- const sessions = new AcpSessionManager(new DaemonAcpObserver(config2, recordSessionEvent), sessionStore);
41989
+ const sessions = new AcpSessionManager(new DaemonAcpObserver(recordSessionEvent), sessionStore);
42370
41990
  const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
42371
41991
  const installationObserver = new DaemonInstallationObserver();
42372
41992
  const diagnostics = new RelayConnectionDiagnostics(audit, config2.channelId, config2.relayUrl);
@@ -42600,7 +42220,7 @@ async function main() {
42600
42220
  const installation = await openMobiusCliInstallation(shutdown.signal, process.env);
42601
42221
  const localContext = new DaemonLocalContext(installation.stateDirectory, process.env);
42602
42222
  const defaultWorkspace = loadDefaultWorkspace(localContext.environment);
42603
- await mkdir5(defaultWorkspace, { recursive: true, mode: 448 });
42223
+ await mkdir6(defaultWorkspace, { recursive: true, mode: 448 });
42604
42224
  const inventory = await discoverLocalAgentInventory({
42605
42225
  defaultWorkspace,
42606
42226
  environment: localContext.environment,