@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/runtime.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all2) => {
5
5
  };
6
6
 
7
7
  // src/runtime.ts
8
- import { mkdir as mkdir5, realpath as realpath10, stat as stat9 } from "node:fs/promises";
8
+ import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
9
9
  import { dirname as dirname8, join as join17, resolve as resolve7 } from "node:path";
10
10
 
11
11
  // src/agent-catalog/local-agent.ts
@@ -1368,21 +1368,21 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
1368
1368
  };
1369
1369
 
1370
1370
  // src/agent-catalog/agents/deepseek-harness-agent.ts
1371
- import { realpath as realpath3, stat as stat3 } from "node:fs/promises";
1371
+ import { mkdir as mkdir2, realpath as realpath3, stat as stat3, writeFile } from "node:fs/promises";
1372
1372
  import { isAbsolute as isAbsolute3, join as join6, normalize } from "node:path";
1373
1373
 
1374
1374
  // src/agent-installation/deepseek-managed-package.ts
1375
1375
  var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
1376
- dependencyResolutionArguments = Object.freeze(["--before=2026-09-03T06:31:52.107Z"]);
1376
+ dependencyResolutionArguments = Object.freeze(["--before=2026-09-18T00:00:00.000Z"]);
1377
1377
  includeOptionalDependencies = true;
1378
1378
  verifyDependencyClosure = true;
1379
1379
  };
1380
1380
  var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
1381
1381
  "@deepseek-ai/dsh",
1382
- "0.1.2-rc.1",
1382
+ "0.1.5-rc.2",
1383
1383
  "dsh",
1384
- "sha512-RPq48TzxvwpdT9/7W1tbhZDBMmeK+bxDrX9cqQC27Wx/LqtgJF8PSa3b3xriU8oxtvhwYmk21w2cej3uMQrnVA==",
1385
- "https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.2-rc.1.tgz"
1384
+ "sha512-8Xc8hCQHcIWRmTCVU/xZdp6/qMsWMeAd2ObChKDEsfhUPJFXx6H0lgeb1DxUMD86HZrrVN+1bCvn1ppjZ/fOxw==",
1385
+ "https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.5-rc.2.tgz"
1386
1386
  );
1387
1387
 
1388
1388
  // src/storage/state-directory.ts
@@ -1397,16 +1397,30 @@ function readStateDirectory(environment = process.env) {
1397
1397
  }
1398
1398
 
1399
1399
  // src/agent-catalog/agents/deepseek-harness-agent.ts
1400
- async function validateAgentHome(path2) {
1400
+ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP bridge to an image-capable route.
1401
+ - id: acp
1402
+ config:
1403
+ provider: deepseek-official
1404
+ model: deepseek-v4-flash-vision-exp
1405
+ `;
1406
+ async function prepareAgentHome(path2, imagePrompts) {
1401
1407
  if (!isAbsolute3(path2) || normalize(path2) !== path2) {
1402
1408
  throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
1403
1409
  }
1404
1410
  try {
1411
+ if (imagePrompts) {
1412
+ await mkdir2(path2, { mode: 448, recursive: true });
1413
+ }
1405
1414
  const resolved = await realpath3(path2);
1406
1415
  const metadata = await stat3(resolved);
1407
1416
  if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
1408
1417
  throw new Error("Agent home is not a user-owned directory");
1409
1418
  }
1419
+ if (imagePrompts) {
1420
+ await writeFile(join6(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
1421
+ mode: 384
1422
+ });
1423
+ }
1410
1424
  return resolved;
1411
1425
  } catch (error62) {
1412
1426
  if (error62 instanceof AgentProbeError) {
@@ -1441,6 +1455,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
1441
1455
  }
1442
1456
  createLaunchEnvironment = async (agent, context) => {
1443
1457
  let selectedHome = context.environment["DSH_HOME"];
1458
+ let managedHome = false;
1444
1459
  try {
1445
1460
  const managed = await this.resolveManagedAgent(
1446
1461
  readStateDirectory(context.environment),
@@ -1449,6 +1464,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
1449
1464
  );
1450
1465
  if (managed.path === agent.path) {
1451
1466
  selectedHome = join6(readStateDirectory(context.environment), "agents", this.id, "home");
1467
+ managedHome = true;
1452
1468
  }
1453
1469
  } catch {
1454
1470
  context.signal.throwIfAborted();
@@ -1457,7 +1473,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
1457
1473
  return Object.freeze({});
1458
1474
  }
1459
1475
  return Object.freeze({
1460
- DSH_HOME: await validateAgentHome(selectedHome)
1476
+ DSH_HOME: await prepareAgentHome(selectedHome, managedHome)
1461
1477
  });
1462
1478
  };
1463
1479
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
@@ -1472,8 +1488,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
1472
1488
  verifyAcp = (_connection, initialized, _defaultWorkspace, _signal) => {
1473
1489
  const capabilities = initialized.agentCapabilities ?? {};
1474
1490
  const session = capabilities.sessionCapabilities;
1475
- const prompt = capabilities.promptCapabilities;
1476
- 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) {
1491
+ 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) {
1477
1492
  throw new AgentProbeError(
1478
1493
  "acp_incompatible",
1479
1494
  "DeepSeek Harness reported an unsupported ACP capability set"
@@ -1684,7 +1699,7 @@ import { join as join9 } from "node:path";
1684
1699
  // src/agent-installation/managed-agent-archive.ts
1685
1700
  import { createHash } from "node:crypto";
1686
1701
  import { createReadStream } from "node:fs";
1687
- 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";
1702
+ 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";
1688
1703
  import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute5, join as join8, relative as relative3, sep as sep3 } from "node:path";
1689
1704
 
1690
1705
  // src/agent-installation/verified-download.ts
@@ -2773,7 +2788,7 @@ var AuditStore = class {
2773
2788
  this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
2774
2789
  }
2775
2790
  }
2776
- record(record3) {
2791
+ record(record2) {
2777
2792
  this.database.prepare(
2778
2793
  `
2779
2794
  INSERT INTO audit_events (
@@ -2786,10 +2801,10 @@ var AuditStore = class {
2786
2801
  `
2787
2802
  ).run(
2788
2803
  (/* @__PURE__ */ new Date()).toISOString(),
2789
- record3.event,
2790
- record3.commandId,
2791
- record3.sessionId,
2792
- JSON.stringify(record3.details ?? {})
2804
+ record2.event,
2805
+ record2.commandId,
2806
+ record2.sessionId,
2807
+ JSON.stringify(record2.details ?? {})
2793
2808
  );
2794
2809
  }
2795
2810
  close() {
@@ -19393,8 +19408,8 @@ function rewriteKeyNames(ctx) {
19393
19408
  bySchema.set(entry.schema, entry);
19394
19409
  }
19395
19410
  const rewrites = /* @__PURE__ */ new Map();
19396
- for (const record3 of pendingRecords.get(ctx) ?? []) {
19397
- const seen = ctx.seen.get(record3);
19411
+ for (const record2 of pendingRecords.get(ctx) ?? []) {
19412
+ const seen = ctx.seen.get(record2);
19398
19413
  const names = (seen?.def ?? seen?.schema)?.propertyNames;
19399
19414
  if (!names || names === true || rewrites.has(names))
19400
19415
  continue;
@@ -22630,7 +22645,11 @@ var configValueSchema = external_exports.strictObject({
22630
22645
  groupId: external_exports.string().max(128),
22631
22646
  groupName: external_exports.string().max(255),
22632
22647
  name: external_exports.string().min(1).max(255),
22633
- value: external_exports.string().min(1).max(500)
22648
+ // ACP types a select value id as any string, and Agents use the empty
22649
+ // id to mean "the provider's own default" — no explicit setting is
22650
+ // sent. Refusing it would drop the whole option, so the id is bounded
22651
+ // by length alone.
22652
+ value: external_exports.string().max(500)
22634
22653
  }).readonly();
22635
22654
  var sessionConfigOptionSchema = external_exports.strictObject({
22636
22655
  booleanValue: external_exports.boolean(),
@@ -24232,10 +24251,10 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
24232
24251
  }
24233
24252
 
24234
24253
  // src/run-daemon.ts
24235
- import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
24254
+ import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
24236
24255
  import { basename as basename6 } from "node:path";
24237
24256
  import { styleText } from "node:util";
24238
- import { fetch as fetch5, WebSocket as WebSocket2 } from "undici";
24257
+ import { fetch as fetch4, WebSocket as WebSocket2 } from "undici";
24239
24258
 
24240
24259
  // src/acp/session-manager.ts
24241
24260
  import { spawn as spawn3 } from "node:child_process";
@@ -32307,12 +32326,16 @@ function readBoolean(value, fallback = false) {
32307
32326
  return typeof value === "boolean" ? value : fallback;
32308
32327
  }
32309
32328
  function normalizeConfigValue(option, groupId = "", groupName = "") {
32329
+ const value = option["value"];
32330
+ if (typeof value !== "string") {
32331
+ return void 0;
32332
+ }
32310
32333
  return {
32311
32334
  description: truncate2(readString2(option["description"]), 500),
32312
32335
  groupId: truncate2(groupId, 128),
32313
32336
  groupName: truncate2(groupName, 255),
32314
- name: truncate2(readString2(option["name"], readString2(option["value"])), 255),
32315
- value: truncate2(readString2(option["value"]), 500)
32337
+ name: truncate2(readString2(option["name"], value), 255),
32338
+ value: truncate2(value, 500)
32316
32339
  };
32317
32340
  }
32318
32341
  function normalizeConfigValues(value) {
@@ -32330,14 +32353,20 @@ function normalizeConfigValues(value) {
32330
32353
  const groupName = readString2(entry["name"]);
32331
32354
  for (const groupedOption of groupedOptions) {
32332
32355
  if (isRecord6(groupedOption)) {
32333
- normalized.push(normalizeConfigValue(groupedOption, groupId, groupName));
32356
+ const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
32357
+ if (normalizedValue !== void 0) {
32358
+ normalized.push(normalizedValue);
32359
+ }
32334
32360
  }
32335
32361
  }
32336
32362
  continue;
32337
32363
  }
32338
- normalized.push(normalizeConfigValue(entry));
32364
+ const normalizedEntry = normalizeConfigValue(entry);
32365
+ if (normalizedEntry !== void 0) {
32366
+ normalized.push(normalizedEntry);
32367
+ }
32339
32368
  }
32340
- return normalized.filter((entry) => entry.value.length > 0).slice(0, 500);
32369
+ return normalized.slice(0, 500);
32341
32370
  }
32342
32371
  function normalizeConfigOptions(value, modes) {
32343
32372
  const normalized = [];
@@ -32368,7 +32397,7 @@ function normalizeConfigOptions(value, modes) {
32368
32397
  if (option["type"] === "select") {
32369
32398
  const values = normalizeConfigValues(option["options"]);
32370
32399
  const currentValue = truncate2(readString2(option["currentValue"]), 500);
32371
- if (currentValue.length > 0 && values.some((entry) => entry.value === currentValue)) {
32400
+ if (values.some((entry) => entry.value === currentValue)) {
32372
32401
  normalized.push({
32373
32402
  booleanValue: false,
32374
32403
  category,
@@ -32939,10 +32968,6 @@ var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
32939
32968
  var SESSION_CONTROL_COMMAND_ID = "session-control";
32940
32969
  var SESSION_CONTROL_TIMEOUT_MILLISECONDS = 3e4;
32941
32970
  var NullAcpSessionObserver = class {
32942
- importLocalArtifact = (_sessionId, _artifact, signal) => {
32943
- signal.throwIfAborted();
32944
- return Promise.resolve("");
32945
- };
32946
32971
  onCommands = () => Promise.resolve();
32947
32972
  onConfig = () => Promise.resolve();
32948
32973
  onContent = () => Promise.resolve();
@@ -33502,20 +33527,7 @@ var AcpProcessSession = class _AcpProcessSession {
33502
33527
  #agentName = "";
33503
33528
  #agentVersion = "";
33504
33529
  #bufferedAgentText = [];
33505
- #capabilities = {
33506
- additionalDirectories: false,
33507
- audioPrompt: false,
33508
- closeSession: false,
33509
- deleteSession: false,
33510
- embeddedContextPrompt: false,
33511
- imagePrompt: false,
33512
- listSessions: false,
33513
- loadSession: false,
33514
- promptQueueing: false,
33515
- resumeSession: false,
33516
- steering: false,
33517
- unstableForkSession: false
33518
- };
33530
+ #capabilities = unsupportedSessionCapabilities();
33519
33531
  #commands = [];
33520
33532
  #configRevision = 0;
33521
33533
  #configOptions = [];
@@ -33735,7 +33747,7 @@ var AcpProcessSession = class _AcpProcessSession {
33735
33747
  if (video === null) {
33736
33748
  return { ...content3, data: "" };
33737
33749
  }
33738
- return await this.importVideo(video, AbortSignal.timeout(2e4));
33750
+ return this.importVideo(video);
33739
33751
  }
33740
33752
  return content3;
33741
33753
  };
@@ -33786,22 +33798,19 @@ var AcpProcessSession = class _AcpProcessSession {
33786
33798
  }
33787
33799
  return imageDisplayContent(raster.mimeType, raster.name, await raster.base64(), "");
33788
33800
  };
33789
- importVideo = async (video, signal) => {
33790
- const artifactId = await this.#getObserver().importLocalArtifact(this.#mobiusSessionId, video, signal);
33791
- return {
33792
- artifactId,
33793
- data: artifactId.length > 0 ? "" : video.base64(),
33794
- mimeType: video.mimeType,
33795
- name: video.name,
33796
- newText: "",
33797
- oldText: "",
33798
- path: "",
33799
- terminalId: "",
33800
- text: "",
33801
- type: "video",
33802
- uri: ""
33803
- };
33804
- };
33801
+ importVideo = (video) => ({
33802
+ artifactId: "",
33803
+ data: video.base64(),
33804
+ mimeType: video.mimeType,
33805
+ name: video.name,
33806
+ newText: "",
33807
+ oldText: "",
33808
+ path: "",
33809
+ terminalId: "",
33810
+ text: "",
33811
+ type: "video",
33812
+ uri: ""
33813
+ });
33805
33814
  async #initializeAgent(signal) {
33806
33815
  await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
33807
33816
  }
@@ -36623,391 +36632,6 @@ async function streamLocalFile(command, send2, signal) {
36623
36632
  });
36624
36633
  }
36625
36634
 
36626
- // src/artifacts/runtime-artifact-uploader.ts
36627
- import { createHash as createHash2 } from "node:crypto";
36628
-
36629
- // ../mobius-sdk/src/errors.ts
36630
- var MobiusError = class extends Error {
36631
- code;
36632
- constructor(code, message, options = {}) {
36633
- super(message, options);
36634
- this.code = code;
36635
- this.name = "MobiusError";
36636
- }
36637
- };
36638
- var MobiusProtocolError = class extends MobiusError {
36639
- constructor(message, options = {}) {
36640
- super("invalid_service_response", message, options);
36641
- this.name = "MobiusProtocolError";
36642
- }
36643
- };
36644
- var MobiusValidationError = class extends MobiusError {
36645
- constructor(message, options = {}) {
36646
- super("invalid_request", message, options);
36647
- this.name = "MobiusValidationError";
36648
- }
36649
- };
36650
-
36651
- // ../mobius-sdk/src/resources.ts
36652
- var IDENTIFIER_PATTERN4 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
36653
- function invalidResponse(message) {
36654
- return new MobiusProtocolError(message);
36655
- }
36656
- function isRecord9(value) {
36657
- return typeof value === "object" && value !== null && !Array.isArray(value);
36658
- }
36659
- function record2(value, name) {
36660
- if (!isRecord9(value)) {
36661
- throw invalidResponse(`The service returned an invalid ${name}`);
36662
- }
36663
- return value;
36664
- }
36665
- function stringField(value, field, maximumLength = 85e5) {
36666
- const candidate = value[field];
36667
- if (typeof candidate !== "string" || candidate.length > maximumLength) {
36668
- throw invalidResponse(`The service returned an invalid ${field}`);
36669
- }
36670
- return candidate;
36671
- }
36672
- function identifierField(value, field) {
36673
- const candidate = stringField(value, field, 128);
36674
- if (!IDENTIFIER_PATTERN4.test(candidate)) {
36675
- throw invalidResponse(`The service returned an invalid ${field}`);
36676
- }
36677
- return candidate;
36678
- }
36679
- function integerField(value, field) {
36680
- const candidate = value[field];
36681
- if (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0) {
36682
- throw invalidResponse(`The service returned an invalid ${field}`);
36683
- }
36684
- return candidate;
36685
- }
36686
- function validateTimestamp(value, field) {
36687
- if (Number.isNaN(Date.parse(value))) {
36688
- throw invalidResponse(`The service returned an invalid ${field}`);
36689
- }
36690
- return value;
36691
- }
36692
- var MobiusArtifactUploadRequest = class {
36693
- byteLength;
36694
- mediaType;
36695
- name;
36696
- sha256;
36697
- constructor(name, mediaType, byteLength, sha256) {
36698
- 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)) {
36699
- throw new MobiusValidationError("The artifact upload request is invalid");
36700
- }
36701
- this.byteLength = byteLength;
36702
- this.mediaType = mediaType;
36703
- this.name = name;
36704
- this.sha256 = sha256;
36705
- }
36706
- };
36707
- var MobiusArtifact = class {
36708
- artifactId;
36709
- byteLength;
36710
- createdAt;
36711
- mediaType;
36712
- name;
36713
- sessionId;
36714
- sha256;
36715
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt) {
36716
- this.artifactId = artifactId;
36717
- this.byteLength = byteLength;
36718
- this.createdAt = createdAt;
36719
- this.mediaType = mediaType;
36720
- this.name = name;
36721
- this.sessionId = sessionId;
36722
- this.sha256 = sha256;
36723
- }
36724
- };
36725
- var MobiusUploadingArtifact = class extends MobiusArtifact {
36726
- expiresAt;
36727
- state = "uploading";
36728
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiresAt) {
36729
- super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
36730
- this.expiresAt = expiresAt;
36731
- }
36732
- };
36733
- var MobiusArtifactUpload = class extends MobiusUploadingArtifact {
36734
- uploadToken;
36735
- constructor(artifact, uploadToken) {
36736
- super(
36737
- artifact.sessionId,
36738
- artifact.artifactId,
36739
- artifact.name,
36740
- artifact.mediaType,
36741
- artifact.byteLength,
36742
- artifact.sha256,
36743
- artifact.createdAt,
36744
- artifact.expiresAt
36745
- );
36746
- this.uploadToken = uploadToken;
36747
- }
36748
- };
36749
- var MobiusAvailableArtifact = class extends MobiusArtifact {
36750
- availableAt;
36751
- state = "available";
36752
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, availableAt) {
36753
- super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
36754
- this.availableAt = availableAt;
36755
- }
36756
- };
36757
- var MobiusExpiredArtifact = class extends MobiusArtifact {
36758
- expiredAt;
36759
- state = "expired";
36760
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiredAt) {
36761
- super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
36762
- this.expiredAt = expiredAt;
36763
- }
36764
- };
36765
- function artifactFields(value) {
36766
- const sha256 = stringField(value, "sha256", 64);
36767
- if (!/^[a-f0-9]{64}$/.test(sha256)) {
36768
- throw invalidResponse("The service returned an invalid artifact digest");
36769
- }
36770
- return {
36771
- artifactId: identifierField(value, "artifactId"),
36772
- byteLength: integerField(value, "byteLength"),
36773
- createdAt: validateTimestamp(stringField(value, "createdAt", 128), "createdAt"),
36774
- mediaType: stringField(value, "mediaType", 255),
36775
- name: stringField(value, "name", 500),
36776
- sessionId: identifierField(value, "sessionId"),
36777
- sha256
36778
- };
36779
- }
36780
- function uploadingArtifact(value) {
36781
- const fields = artifactFields(value);
36782
- return new MobiusUploadingArtifact(
36783
- fields.sessionId,
36784
- fields.artifactId,
36785
- fields.name,
36786
- fields.mediaType,
36787
- fields.byteLength,
36788
- fields.sha256,
36789
- fields.createdAt,
36790
- validateTimestamp(stringField(value, "expiresAt", 128), "expiresAt")
36791
- );
36792
- }
36793
- function decodeMobiusArtifactUpload(value) {
36794
- const artifact = record2(value, "artifact upload authorization");
36795
- return new MobiusArtifactUpload(uploadingArtifact(artifact), stringField(artifact, "uploadToken", 256));
36796
- }
36797
- function decodeMobiusArtifact(value) {
36798
- const artifact = record2(value, "artifact");
36799
- const state = stringField(artifact, "state", 32);
36800
- if (state === "uploading") {
36801
- return uploadingArtifact(artifact);
36802
- }
36803
- const fields = artifactFields(artifact);
36804
- if (state === "available") {
36805
- return new MobiusAvailableArtifact(
36806
- fields.sessionId,
36807
- fields.artifactId,
36808
- fields.name,
36809
- fields.mediaType,
36810
- fields.byteLength,
36811
- fields.sha256,
36812
- fields.createdAt,
36813
- validateTimestamp(stringField(artifact, "availableAt", 128), "availableAt")
36814
- );
36815
- }
36816
- if (state === "expired") {
36817
- return new MobiusExpiredArtifact(
36818
- fields.sessionId,
36819
- fields.artifactId,
36820
- fields.name,
36821
- fields.mediaType,
36822
- fields.byteLength,
36823
- fields.sha256,
36824
- fields.createdAt,
36825
- validateTimestamp(stringField(artifact, "expiredAt", 128), "expiredAt")
36826
- );
36827
- }
36828
- throw invalidResponse("The service returned an invalid artifact state");
36829
- }
36830
- function decodeMobiusAvailableArtifact(value) {
36831
- const artifact = decodeMobiusArtifact(value);
36832
- if (!(artifact instanceof MobiusAvailableArtifact)) {
36833
- throw invalidResponse("The service did not make the artifact available");
36834
- }
36835
- return artifact;
36836
- }
36837
- var MobiusRuntimePairingLifecycle = Object.freeze({
36838
- Expired: "expired",
36839
- Paired: "paired",
36840
- Pending: "pending",
36841
- Revoked: "revoked"
36842
- });
36843
-
36844
- // src/artifacts/runtime-artifact-uploader.ts
36845
- import { fetch as fetch3 } from "undici";
36846
- var UPLOAD_TIMEOUT_MILLISECONDS = 2e4;
36847
- var RuntimeArtifactUploadError = class extends Error {
36848
- code;
36849
- constructor(code, message, options = {}) {
36850
- super(message, options);
36851
- this.code = code;
36852
- this.name = "RuntimeArtifactUploadError";
36853
- }
36854
- };
36855
- var UploadedRuntimeArtifact = class {
36856
- artifactId;
36857
- byteLength;
36858
- mimeType;
36859
- name;
36860
- sha256;
36861
- constructor(artifactId, name, mimeType, byteLength, sha256) {
36862
- this.artifactId = artifactId;
36863
- this.byteLength = byteLength;
36864
- this.mimeType = mimeType;
36865
- this.name = name;
36866
- this.sha256 = sha256;
36867
- }
36868
- };
36869
- function channelOrigin(config2) {
36870
- const url2 = new URL(config2.relayUrl);
36871
- url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
36872
- let channelPath = "";
36873
- if (url2.pathname.endsWith("/daemon")) {
36874
- channelPath = url2.pathname.slice(0, -"/daemon".length);
36875
- } else {
36876
- const runtimePath = `${MOBIUS_API_PREFIX}/v1/runtimes/connect`;
36877
- if (!url2.pathname.endsWith("/v1/runtimes/connect") && !url2.pathname.endsWith(runtimePath)) {
36878
- throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay artifact endpoint is invalid");
36879
- }
36880
- channelPath = `${url2.pathname.replace(/\/v1\/runtimes\/connect$/, "")}/channels/${encodeURIComponent(config2.channelId)}`;
36881
- }
36882
- url2.pathname = channelPath;
36883
- url2.search = "";
36884
- url2.hash = "";
36885
- return url2;
36886
- }
36887
- function uploadError(code, message, cause) {
36888
- return new RuntimeArtifactUploadError(code, message, cause === void 0 ? {} : { cause });
36889
- }
36890
- function translateSdkError(cause) {
36891
- if (cause instanceof MobiusValidationError) {
36892
- throw uploadError("artifact_upload_failed", cause.message, cause);
36893
- }
36894
- if (cause instanceof MobiusProtocolError) {
36895
- throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
36896
- }
36897
- throw cause;
36898
- }
36899
- async function readJson(response) {
36900
- try {
36901
- return await response.json();
36902
- } catch (cause) {
36903
- throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
36904
- }
36905
- }
36906
- async function readAuthorization(response) {
36907
- try {
36908
- return decodeMobiusArtifactUpload(await readJson(response));
36909
- } catch (cause) {
36910
- translateSdkError(cause);
36911
- }
36912
- }
36913
- function sessionArtifactUrl(origin, sessionId, resourcePath) {
36914
- return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
36915
- }
36916
- async function postLease(url2, headers, request, signal) {
36917
- return await fetch3(url2, {
36918
- dispatcher: environmentProxyDispatcher,
36919
- headers: { ...headers, "content-type": "application/json" },
36920
- method: "POST",
36921
- body: JSON.stringify(request),
36922
- signal
36923
- });
36924
- }
36925
- async function putContent(url2, headers, authorization, bytes, signal) {
36926
- return await fetch3(url2, {
36927
- dispatcher: environmentProxyDispatcher,
36928
- headers: {
36929
- ...headers,
36930
- "content-type": authorization.mediaType,
36931
- "x-mobius-upload-token": authorization.uploadToken
36932
- },
36933
- method: "PUT",
36934
- body: bytes,
36935
- signal
36936
- });
36937
- }
36938
- async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
36939
- signal.throwIfAborted();
36940
- let request;
36941
- try {
36942
- request = new MobiusArtifactUploadRequest(
36943
- artifact.name,
36944
- artifact.mimeType,
36945
- artifact.bytes.byteLength,
36946
- createHash2("sha256").update(artifact.bytes).digest("hex")
36947
- );
36948
- } catch (cause) {
36949
- translateSdkError(cause);
36950
- }
36951
- const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
36952
- const requestSignal = AbortSignal.any([signal, timeoutSignal]);
36953
- const origin = channelOrigin(config2);
36954
- const headers = runtimeAuthorization(config2.relayUrl);
36955
- let created;
36956
- try {
36957
- created = await postLease(
36958
- sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
36959
- headers,
36960
- request,
36961
- requestSignal
36962
- );
36963
- } catch (cause) {
36964
- signal.throwIfAborted();
36965
- throw uploadError(
36966
- timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
36967
- timeoutSignal.aborted ? "The artifact upload authorization timed out" : "The artifact upload could not start",
36968
- cause
36969
- );
36970
- }
36971
- if (!created.ok) {
36972
- await created.body?.cancel();
36973
- throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact upload");
36974
- }
36975
- const authorization = await readAuthorization(created);
36976
- let uploaded;
36977
- try {
36978
- uploaded = await putContent(
36979
- sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
36980
- headers,
36981
- authorization,
36982
- artifact.bytes,
36983
- requestSignal
36984
- );
36985
- } catch (cause) {
36986
- signal.throwIfAborted();
36987
- throw uploadError(
36988
- timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
36989
- timeoutSignal.aborted ? "The artifact upload timed out" : "The artifact content could not be uploaded",
36990
- cause
36991
- );
36992
- }
36993
- if (!uploaded.ok) {
36994
- await uploaded.body?.cancel();
36995
- throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact content");
36996
- }
36997
- try {
36998
- const available = decodeMobiusAvailableArtifact(await readJson(uploaded));
36999
- return new UploadedRuntimeArtifact(
37000
- available.artifactId,
37001
- available.name,
37002
- available.mediaType,
37003
- available.byteLength,
37004
- available.sha256
37005
- );
37006
- } catch (cause) {
37007
- translateSdkError(cause);
37008
- }
37009
- }
37010
-
37011
36635
  // src/authorization/local-authorization-error.ts
37012
36636
  var LocalAuthorizationError = class extends Error {
37013
36637
  code = "local_authorization_failed";
@@ -37836,13 +37460,13 @@ var NativeSessionService = class {
37836
37460
  };
37837
37461
 
37838
37462
  // src/prompt-artifact-resolver.ts
37839
- import { createHash as createHash3 } from "node:crypto";
37840
- import { fetch as fetch4 } from "undici";
37463
+ import { createHash as createHash2 } from "node:crypto";
37464
+ import { fetch as fetch3 } from "undici";
37841
37465
  var ARTIFACT_SCHEME = "mobius-artifact:";
37842
37466
  var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
37843
37467
  var MAX_AGENT_IMAGE_BASE64_LENGTH = 4e6;
37844
37468
  var MAX_AGENT_RESOURCE_BYTE_LENGTH = 1e6;
37845
- var IDENTIFIER_PATTERN5 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
37469
+ var IDENTIFIER_PATTERN4 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
37846
37470
  var PromptArtifactError = class extends Error {
37847
37471
  code;
37848
37472
  constructor(code, message, options = {}) {
@@ -37885,7 +37509,7 @@ function parseReference(resource) {
37885
37509
  const encodedByteLength2 = url2.searchParams.get("byteLength") ?? "";
37886
37510
  const sha256 = url2.searchParams.get("sha256") ?? "";
37887
37511
  const byteLength = Number(encodedByteLength2);
37888
- if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !IDENTIFIER_PATTERN5.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)) {
37512
+ if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !IDENTIFIER_PATTERN4.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)) {
37889
37513
  throw new PromptArtifactError("artifact_reference_invalid", "The prompt artifact reference is invalid");
37890
37514
  }
37891
37515
  return new PromptArtifactReference(artifactId, byteLength, sha256, resource);
@@ -37951,7 +37575,7 @@ async function download(config2, command, reference, signal) {
37951
37575
  const requestSignal = AbortSignal.any([signal, timeoutSignal]);
37952
37576
  let response;
37953
37577
  try {
37954
- response = await fetch4(downloadUrl(config2, command, reference), {
37578
+ response = await fetch3(downloadUrl(config2, command, reference), {
37955
37579
  dispatcher: environmentProxyDispatcher,
37956
37580
  headers: {
37957
37581
  accept: reference.resource.mimeType,
@@ -37975,7 +37599,7 @@ async function download(config2, command, reference, signal) {
37975
37599
  );
37976
37600
  }
37977
37601
  const bytes = await responseBytes(response, reference.byteLength, requestSignal);
37978
- if (createHash3("sha256").update(bytes).digest("hex") !== reference.sha256) {
37602
+ if (createHash2("sha256").update(bytes).digest("hex") !== reference.sha256) {
37979
37603
  throw new PromptArtifactError(
37980
37604
  "artifact_integrity_failed",
37981
37605
  "The prompt artifact failed integrity validation"
@@ -39080,13 +38704,10 @@ var AGENT_TEXT_MAXIMUM_LENGTH = 1e5;
39080
38704
  var ACTIVE_TURN_RECONCILIATION_TIMEOUT_MILLISECONDS = 2e4;
39081
38705
  var ACTIVE_TURN_RECONCILIATION_CLOSE_CODE = 4009;
39082
38706
  var DaemonAcpObserver = class {
39083
- #config;
39084
38707
  #record;
39085
- constructor(config2, record3) {
39086
- this.#config = config2;
39087
- this.#record = record3;
38708
+ constructor(record2) {
38709
+ this.#record = record2;
39088
38710
  }
39089
- importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
39090
38711
  onCommands = (event) => {
39091
38712
  this.#record(event.sessionId, event);
39092
38713
  return Promise.resolve();
@@ -39304,7 +38925,7 @@ async function reconcileActiveTurn(config2, turn, signal) {
39304
38925
  const requestSignal = AbortSignal.any([signal, timeoutSignal]);
39305
38926
  let response;
39306
38927
  try {
39307
- response = await fetch5(activeTurnReconciliationEndpoint(config2, turn), {
38928
+ response = await fetch4(activeTurnReconciliationEndpoint(config2, turn), {
39308
38929
  body: JSON.stringify({ outcome: { kind: "running" } }),
39309
38930
  dispatcher: environmentProxyDispatcher,
39310
38931
  headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
@@ -39814,7 +39435,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
39814
39435
  resolution: modelEffort.resolution,
39815
39436
  valuesByModel: {}
39816
39437
  };
39817
- return createHash4("sha256").update(
39438
+ return createHash3("sha256").update(
39818
39439
  JSON.stringify({
39819
39440
  adapterVersion: agent.adapterVersion,
39820
39441
  agentId: agent.id,
@@ -41367,7 +40988,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
41367
40988
  }
41368
40989
  publisher.recordAttempt(sessionId, event, attemptId);
41369
40990
  };
41370
- const sessions = new AcpSessionManager(new DaemonAcpObserver(config2, recordSessionEvent), sessionStore);
40991
+ const sessions = new AcpSessionManager(new DaemonAcpObserver(recordSessionEvent), sessionStore);
41371
40992
  const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
41372
40993
  const installationObserver = new DaemonInstallationObserver();
41373
40994
  const diagnostics = new RelayConnectionDiagnostics(audit, config2.channelId, config2.relayUrl);
@@ -41502,19 +41123,19 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
41502
41123
  }
41503
41124
 
41504
41125
  // src/pairing/pair-local-machine.ts
41505
- import { mkdir as mkdir4, realpath as realpath9, stat as stat8 } from "node:fs/promises";
41126
+ import { mkdir as mkdir5, realpath as realpath9, stat as stat8 } from "node:fs/promises";
41506
41127
  import { hostname as hostname3 } from "node:os";
41507
41128
  import { basename as basename7, resolve as resolve6 } from "node:path";
41508
- import { fetch as fetch6 } from "undici";
41129
+ import { fetch as fetch5 } from "undici";
41509
41130
 
41510
41131
  // src/storage/runtime-installation-store.ts
41511
- import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
41512
- import { mkdir as mkdir3, open as open5, rename as rename3, unlink, writeFile as writeFile2 } from "node:fs/promises";
41132
+ import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
41133
+ import { mkdir as mkdir4, open as open5, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
41513
41134
  import { dirname as dirname7, join as join16, resolve as resolve5 } from "node:path";
41514
41135
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
41515
41136
  var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
41516
41137
  var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
41517
- var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
41138
+ var IDENTIFIER_PATTERN5 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
41518
41139
  var RUNTIME_CREDENTIAL_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
41519
41140
  var MAX_FILE_LENGTH = 16 * 1024;
41520
41141
  var INSTALLATION_POINTER_KEYS = ["installationId", "version"];
@@ -41595,7 +41216,7 @@ var ImportedLegacyRuntimeConnection = class extends StoredRuntimeConnection {
41595
41216
  super(applicationId, installationId2, connectionId2, channelId, defaultWorkspace, relayOrigin, runtimeCredential2);
41596
41217
  }
41597
41218
  };
41598
- function isRecord10(value) {
41219
+ function isRecord9(value) {
41599
41220
  return typeof value === "object" && value !== null && !Array.isArray(value);
41600
41221
  }
41601
41222
  function hasExactKeys(value, expectedKeys) {
@@ -41624,7 +41245,7 @@ function validateInstallationId(value) {
41624
41245
  return value;
41625
41246
  }
41626
41247
  function validateIdentifier(value, code) {
41627
- if (!IDENTIFIER_PATTERN6.test(value)) {
41248
+ if (!IDENTIFIER_PATTERN5.test(value)) {
41628
41249
  throw new RuntimeInstallationStoreError(code, "The saved Runtime connection is invalid");
41629
41250
  }
41630
41251
  return value;
@@ -41659,10 +41280,10 @@ function installationId() {
41659
41280
  return `min_${randomUUID4().replaceAll("-", "")}`;
41660
41281
  }
41661
41282
  function channelIndexFileName(channelId) {
41662
- return `mci_${createHash5("sha256").update(channelId).digest("hex")}.json`;
41283
+ return `mci_${createHash4("sha256").update(channelId).digest("hex")}.json`;
41663
41284
  }
41664
41285
  function decodeInstallationPointer(value) {
41665
- if (!isRecord10(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
41286
+ if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
41666
41287
  throw new RuntimeInstallationStoreError("invalid_installation", "The local installation record is invalid");
41667
41288
  }
41668
41289
  const storedInstallationId = value["installationId"];
@@ -41672,7 +41293,7 @@ function decodeInstallationPointer(value) {
41672
41293
  return { installationId: validateInstallationId(storedInstallationId) };
41673
41294
  }
41674
41295
  function decodeChannelIndex(value) {
41675
- if (!isRecord10(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
41296
+ if (!isRecord9(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
41676
41297
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
41677
41298
  }
41678
41299
  const applicationId = value["applicationId"];
@@ -41740,7 +41361,7 @@ function decodeImportedLegacyConnection(value) {
41740
41361
  );
41741
41362
  }
41742
41363
  function decodeConnection(value) {
41743
- if (!isRecord10(value)) {
41364
+ if (!isRecord9(value)) {
41744
41365
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
41745
41366
  }
41746
41367
  if (value["kind"] === "verified") {
@@ -41752,7 +41373,7 @@ function decodeConnection(value) {
41752
41373
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
41753
41374
  }
41754
41375
  function decodeLegacyConnection(value, expectedChannelId) {
41755
- if (!isRecord10(value) || !hasExactKeys(value, CURRENT_CONNECTION_KEYS) && !hasExactKeys(value, LEGACY_CONNECTION_KEYS)) {
41376
+ if (!isRecord9(value) || !hasExactKeys(value, CURRENT_CONNECTION_KEYS) && !hasExactKeys(value, LEGACY_CONNECTION_KEYS)) {
41756
41377
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
41757
41378
  }
41758
41379
  const channelId = value["channelId"];
@@ -41812,9 +41433,9 @@ async function writeJsonAtomically(path2, value, signal) {
41812
41433
  const directory = dirname7(path2);
41813
41434
  const temporaryPath = join16(directory, `.${randomUUID4()}.tmp`);
41814
41435
  try {
41815
- await mkdir3(directory, { mode: 448, recursive: true });
41436
+ await mkdir4(directory, { mode: 448, recursive: true });
41816
41437
  signal.throwIfAborted();
41817
- await writeFile2(temporaryPath, `${JSON.stringify(value, null, 2)}
41438
+ await writeFile3(temporaryPath, `${JSON.stringify(value, null, 2)}
41818
41439
  `, { flag: "wx", mode: 384 });
41819
41440
  signal.throwIfAborted();
41820
41441
  await rename3(temporaryPath, path2);
@@ -41845,7 +41466,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
41845
41466
  const rootDirectory = resolve5(options.stateDirectory);
41846
41467
  const applicationDirectory = join16(rootDirectory, "installations", applicationId);
41847
41468
  try {
41848
- await mkdir3(applicationDirectory, { mode: 448, recursive: true });
41469
+ await mkdir4(applicationDirectory, { mode: 448, recursive: true });
41849
41470
  } catch (cause) {
41850
41471
  throw new RuntimeInstallationStoreError(
41851
41472
  "installation_unavailable",
@@ -41858,7 +41479,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
41858
41479
  const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
41859
41480
  const stateDirectory = join16(applicationDirectory, storedInstallationId);
41860
41481
  try {
41861
- await mkdir3(stateDirectory, { mode: 448, recursive: true });
41482
+ await mkdir4(stateDirectory, { mode: 448, recursive: true });
41862
41483
  } catch (cause) {
41863
41484
  throw new RuntimeInstallationStoreError(
41864
41485
  "installation_unavailable",
@@ -42014,7 +41635,7 @@ async function readOrCreateInstallationId(applicationDirectory, signal) {
42014
41635
  }
42015
41636
  const candidate = installationId();
42016
41637
  try {
42017
- await writeFile2(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
41638
+ await writeFile3(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
42018
41639
  `, {
42019
41640
  flag: "wx",
42020
41641
  mode: 384
@@ -42040,7 +41661,7 @@ async function openRuntimeInstallationStore(options, signal) {
42040
41661
  // src/pairing/pair-local-machine.ts
42041
41662
  var PAIRING_TIMEOUT_MILLISECONDS = 2e4;
42042
41663
  var PAIRING_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{4}(?:-[A-HJ-NP-Z2-9]{4}){4}$/;
42043
- var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
41664
+ var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
42044
41665
  var TOKEN_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
42045
41666
  var CLAIM_RESPONSE_KEYS = ["channelId", "daemonToken", "runtimeId"];
42046
41667
  var REDEEM_RESPONSE_KEYS = ["channelId", "runtimeCredential", "runtimeId"];
@@ -42052,7 +41673,7 @@ var PairingClientError = class extends Error {
42052
41673
  this.name = "PairingClientError";
42053
41674
  }
42054
41675
  };
42055
- function isRecord11(value) {
41676
+ function isRecord10(value) {
42056
41677
  return typeof value === "object" && value !== null && !Array.isArray(value);
42057
41678
  }
42058
41679
  function hasExactKeys2(value, expectedKeys) {
@@ -42091,7 +41712,7 @@ function parsePairingCode(value) {
42091
41712
  return code;
42092
41713
  }
42093
41714
  function validatePairingId(value) {
42094
- if (!IDENTIFIER_PATTERN7.test(value)) {
41715
+ if (!IDENTIFIER_PATTERN6.test(value)) {
42095
41716
  throw new PairingClientError("invalid_pairing_id", "The Runtime pairing ID is invalid");
42096
41717
  }
42097
41718
  return value;
@@ -42099,7 +41720,7 @@ function validatePairingId(value) {
42099
41720
  async function resolveDefaultWorkspace2(path2) {
42100
41721
  const requestedWorkspace = resolve6(path2);
42101
41722
  try {
42102
- await mkdir4(requestedWorkspace, { recursive: true, mode: 448 });
41723
+ await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
42103
41724
  const defaultWorkspace = await realpath9(requestedWorkspace);
42104
41725
  const metadata = await stat8(defaultWorkspace);
42105
41726
  if (!metadata.isDirectory()) {
@@ -42130,9 +41751,9 @@ async function readJsonResponse(response) {
42130
41751
  }
42131
41752
  }
42132
41753
  function readRelayError(value) {
42133
- if (isRecord11(value)) {
41754
+ if (isRecord10(value)) {
42134
41755
  const error62 = value["error"];
42135
- if (isRecord11(error62)) {
41756
+ if (isRecord10(error62)) {
42136
41757
  const code = error62["code"];
42137
41758
  const message = error62["message"];
42138
41759
  if (typeof code === "string" && typeof message === "string") {
@@ -42143,13 +41764,13 @@ function readRelayError(value) {
42143
41764
  return new PairingClientError("pairing_failed", "The relay could not pair this machine");
42144
41765
  }
42145
41766
  function decodePairingResponse(value, credentialField, expectedKeys) {
42146
- if (!isRecord11(value) || !hasExactKeys2(value, expectedKeys)) {
41767
+ if (!isRecord10(value) || !hasExactKeys2(value, expectedKeys)) {
42147
41768
  throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
42148
41769
  }
42149
41770
  const channelId = value["channelId"];
42150
41771
  const runtimeCredential2 = value[credentialField];
42151
41772
  const runtimeId = value["runtimeId"];
42152
- if (typeof channelId !== "string" || !IDENTIFIER_PATTERN7.test(channelId) || typeof runtimeCredential2 !== "string" || !TOKEN_PATTERN.test(runtimeCredential2) || typeof runtimeId !== "string" || !IDENTIFIER_PATTERN7.test(runtimeId)) {
41773
+ if (typeof channelId !== "string" || !IDENTIFIER_PATTERN6.test(channelId) || typeof runtimeCredential2 !== "string" || !TOKEN_PATTERN.test(runtimeCredential2) || typeof runtimeId !== "string" || !IDENTIFIER_PATTERN6.test(runtimeId)) {
42153
41774
  throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
42154
41775
  }
42155
41776
  return { channelId, runtimeCredential: runtimeCredential2, runtimeId };
@@ -42167,7 +41788,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
42167
41788
  const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
42168
41789
  let response;
42169
41790
  try {
42170
- response = await fetch6(endpoint, {
41791
+ response = await fetch5(endpoint, {
42171
41792
  body: JSON.stringify({
42172
41793
  agents,
42173
41794
  installableAgents,
@@ -42269,7 +41890,7 @@ async function resumeMobiusRuntime(installation, connectionId2, signal, environm
42269
41890
  }
42270
41891
 
42271
41892
  // src/runtime.ts
42272
- var IDENTIFIER_PATTERN8 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
41893
+ var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
42273
41894
  var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
42274
41895
  var MobiusRuntimeConfigurationError = class extends Error {
42275
41896
  code = "runtime_configuration_invalid";
@@ -42321,7 +41942,7 @@ function relayUrlFromConnection(connection) {
42321
41942
  }
42322
41943
  function loadMobiusRuntimeConnection(environment = process.env) {
42323
41944
  const channelId = requiredEnvironmentValue(environment, "MOBIUS_CHANNEL_ID");
42324
- if (!IDENTIFIER_PATTERN8.test(channelId)) {
41945
+ if (!IDENTIFIER_PATTERN7.test(channelId)) {
42325
41946
  throw new MobiusRuntimeConfigurationError("MOBIUS_CHANNEL_ID is invalid");
42326
41947
  }
42327
41948
  return Object.freeze({
@@ -42335,7 +41956,7 @@ function loadMobiusRuntimeConnection(environment = process.env) {
42335
41956
  async function resolveWorkspace(path2) {
42336
41957
  const requested = resolve7(path2);
42337
41958
  try {
42338
- await mkdir5(requested, { recursive: true, mode: 448 });
41959
+ await mkdir6(requested, { recursive: true, mode: 448 });
42339
41960
  const resolved = await realpath10(requested);
42340
41961
  const metadata = await stat9(resolved);
42341
41962
  if (!metadata.isDirectory()) {
@@ -42355,7 +41976,7 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
42355
41976
  const relayUrl = relayUrlFromConnection(connection);
42356
41977
  const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
42357
41978
  const auditDatabasePath = resolve7(connection.auditDatabasePath);
42358
- await mkdir5(dirname8(auditDatabasePath), { recursive: true, mode: 448 });
41979
+ await mkdir6(dirname8(auditDatabasePath), { recursive: true, mode: 448 });
42359
41980
  const inventory = await discoverLocalAgentInventory({
42360
41981
  defaultWorkspace,
42361
41982
  environment: localContext.environment,