@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/index.js CHANGED
@@ -16628,8 +16628,8 @@ function rewriteKeyNames(ctx) {
16628
16628
  bySchema.set(entry.schema, entry);
16629
16629
  }
16630
16630
  const rewrites = /* @__PURE__ */ new Map();
16631
- for (const record3 of pendingRecords.get(ctx) ?? []) {
16632
- const seen = ctx.seen.get(record3);
16631
+ for (const record2 of pendingRecords.get(ctx) ?? []) {
16632
+ const seen = ctx.seen.get(record2);
16633
16633
  const names = (seen?.def ?? seen?.schema)?.propertyNames;
16634
16634
  if (!names || names === true || rewrites.has(names))
16635
16635
  continue;
@@ -19865,7 +19865,11 @@ var configValueSchema = external_exports.strictObject({
19865
19865
  groupId: external_exports.string().max(128),
19866
19866
  groupName: external_exports.string().max(255),
19867
19867
  name: external_exports.string().min(1).max(255),
19868
- value: external_exports.string().min(1).max(500)
19868
+ // ACP types a select value id as any string, and Agents use the empty
19869
+ // id to mean "the provider's own default" — no explicit setting is
19870
+ // sent. Refusing it would drop the whole option, so the id is bounded
19871
+ // by length alone.
19872
+ value: external_exports.string().max(500)
19869
19873
  }).readonly();
19870
19874
  var sessionConfigOptionSchema = external_exports.strictObject({
19871
19875
  booleanValue: external_exports.boolean(),
@@ -30277,12 +30281,16 @@ function readBoolean(value, fallback = false) {
30277
30281
  return typeof value === "boolean" ? value : fallback;
30278
30282
  }
30279
30283
  function normalizeConfigValue(option, groupId = "", groupName = "") {
30284
+ const value = option["value"];
30285
+ if (typeof value !== "string") {
30286
+ return void 0;
30287
+ }
30280
30288
  return {
30281
30289
  description: truncate2(readString2(option["description"]), 500),
30282
30290
  groupId: truncate2(groupId, 128),
30283
30291
  groupName: truncate2(groupName, 255),
30284
- name: truncate2(readString2(option["name"], readString2(option["value"])), 255),
30285
- value: truncate2(readString2(option["value"]), 500)
30292
+ name: truncate2(readString2(option["name"], value), 255),
30293
+ value: truncate2(value, 500)
30286
30294
  };
30287
30295
  }
30288
30296
  function normalizeConfigValues(value) {
@@ -30300,14 +30308,20 @@ function normalizeConfigValues(value) {
30300
30308
  const groupName = readString2(entry["name"]);
30301
30309
  for (const groupedOption of groupedOptions) {
30302
30310
  if (isRecord4(groupedOption)) {
30303
- normalized.push(normalizeConfigValue(groupedOption, groupId, groupName));
30311
+ const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
30312
+ if (normalizedValue !== void 0) {
30313
+ normalized.push(normalizedValue);
30314
+ }
30304
30315
  }
30305
30316
  }
30306
30317
  continue;
30307
30318
  }
30308
- normalized.push(normalizeConfigValue(entry));
30319
+ const normalizedEntry = normalizeConfigValue(entry);
30320
+ if (normalizedEntry !== void 0) {
30321
+ normalized.push(normalizedEntry);
30322
+ }
30309
30323
  }
30310
- return normalized.filter((entry) => entry.value.length > 0).slice(0, 500);
30324
+ return normalized.slice(0, 500);
30311
30325
  }
30312
30326
  function normalizeConfigOptions(value, modes) {
30313
30327
  const normalized = [];
@@ -30338,7 +30352,7 @@ function normalizeConfigOptions(value, modes) {
30338
30352
  if (option["type"] === "select") {
30339
30353
  const values = normalizeConfigValues(option["options"]);
30340
30354
  const currentValue = truncate2(readString2(option["currentValue"]), 500);
30341
- if (currentValue.length > 0 && values.some((entry) => entry.value === currentValue)) {
30355
+ if (values.some((entry) => entry.value === currentValue)) {
30342
30356
  normalized.push({
30343
30357
  booleanValue: false,
30344
30358
  category,
@@ -30909,10 +30923,6 @@ var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
30909
30923
  var SESSION_CONTROL_COMMAND_ID = "session-control";
30910
30924
  var SESSION_CONTROL_TIMEOUT_MILLISECONDS = 3e4;
30911
30925
  var NullAcpSessionObserver = class {
30912
- importLocalArtifact = (_sessionId, _artifact, signal) => {
30913
- signal.throwIfAborted();
30914
- return Promise.resolve("");
30915
- };
30916
30926
  onCommands = () => Promise.resolve();
30917
30927
  onConfig = () => Promise.resolve();
30918
30928
  onContent = () => Promise.resolve();
@@ -31472,20 +31482,7 @@ var AcpProcessSession = class _AcpProcessSession {
31472
31482
  #agentName = "";
31473
31483
  #agentVersion = "";
31474
31484
  #bufferedAgentText = [];
31475
- #capabilities = {
31476
- additionalDirectories: false,
31477
- audioPrompt: false,
31478
- closeSession: false,
31479
- deleteSession: false,
31480
- embeddedContextPrompt: false,
31481
- imagePrompt: false,
31482
- listSessions: false,
31483
- loadSession: false,
31484
- promptQueueing: false,
31485
- resumeSession: false,
31486
- steering: false,
31487
- unstableForkSession: false
31488
- };
31485
+ #capabilities = unsupportedSessionCapabilities();
31489
31486
  #commands = [];
31490
31487
  #configRevision = 0;
31491
31488
  #configOptions = [];
@@ -31705,7 +31702,7 @@ var AcpProcessSession = class _AcpProcessSession {
31705
31702
  if (video === null) {
31706
31703
  return { ...content3, data: "" };
31707
31704
  }
31708
- return await this.importVideo(video, AbortSignal.timeout(2e4));
31705
+ return this.importVideo(video);
31709
31706
  }
31710
31707
  return content3;
31711
31708
  };
@@ -31756,22 +31753,19 @@ var AcpProcessSession = class _AcpProcessSession {
31756
31753
  }
31757
31754
  return imageDisplayContent(raster.mimeType, raster.name, await raster.base64(), "");
31758
31755
  };
31759
- importVideo = async (video, signal) => {
31760
- const artifactId = await this.#getObserver().importLocalArtifact(this.#mobiusSessionId, video, signal);
31761
- return {
31762
- artifactId,
31763
- data: artifactId.length > 0 ? "" : video.base64(),
31764
- mimeType: video.mimeType,
31765
- name: video.name,
31766
- newText: "",
31767
- oldText: "",
31768
- path: "",
31769
- terminalId: "",
31770
- text: "",
31771
- type: "video",
31772
- uri: ""
31773
- };
31774
- };
31756
+ importVideo = (video) => ({
31757
+ artifactId: "",
31758
+ data: video.base64(),
31759
+ mimeType: video.mimeType,
31760
+ name: video.name,
31761
+ newText: "",
31762
+ oldText: "",
31763
+ path: "",
31764
+ terminalId: "",
31765
+ text: "",
31766
+ type: "video",
31767
+ uri: ""
31768
+ });
31775
31769
  async #initializeAgent(signal) {
31776
31770
  await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
31777
31771
  }
@@ -33783,7 +33777,7 @@ var AuditStore = class {
33783
33777
  this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
33784
33778
  }
33785
33779
  }
33786
- record(record3) {
33780
+ record(record2) {
33787
33781
  this.database.prepare(
33788
33782
  `
33789
33783
  INSERT INTO audit_events (
@@ -33796,10 +33790,10 @@ var AuditStore = class {
33796
33790
  `
33797
33791
  ).run(
33798
33792
  (/* @__PURE__ */ new Date()).toISOString(),
33799
- record3.event,
33800
- record3.commandId,
33801
- record3.sessionId,
33802
- JSON.stringify(record3.details ?? {})
33793
+ record2.event,
33794
+ record2.commandId,
33795
+ record2.sessionId,
33796
+ JSON.stringify(record2.details ?? {})
33803
33797
  );
33804
33798
  }
33805
33799
  close() {
@@ -33817,7 +33811,7 @@ var LocalAuthorizationError = class extends Error {
33817
33811
  };
33818
33812
 
33819
33813
  // src/pairing/pair-local-machine.ts
33820
- import { mkdir as mkdir4, realpath as realpath7, stat as stat6 } from "node:fs/promises";
33814
+ import { mkdir as mkdir5, realpath as realpath7, stat as stat6 } from "node:fs/promises";
33821
33815
  import { hostname as hostname3 } from "node:os";
33822
33816
  import { basename as basename3, resolve as resolve5 } from "node:path";
33823
33817
  import { fetch as fetch2 } from "undici";
@@ -34471,34 +34465,48 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
34471
34465
  };
34472
34466
 
34473
34467
  // src/agent-catalog/agents/deepseek-harness-agent.ts
34474
- import { realpath as realpath4, stat as stat4 } from "node:fs/promises";
34468
+ import { mkdir as mkdir2, realpath as realpath4, stat as stat4, writeFile } from "node:fs/promises";
34475
34469
  import { isAbsolute as isAbsolute4, join as join7, normalize as normalize2 } from "node:path";
34476
34470
 
34477
34471
  // src/agent-installation/deepseek-managed-package.ts
34478
34472
  var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
34479
- dependencyResolutionArguments = Object.freeze(["--before=2026-09-03T06:31:52.107Z"]);
34473
+ dependencyResolutionArguments = Object.freeze(["--before=2026-09-18T00:00:00.000Z"]);
34480
34474
  includeOptionalDependencies = true;
34481
34475
  verifyDependencyClosure = true;
34482
34476
  };
34483
34477
  var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
34484
34478
  "@deepseek-ai/dsh",
34485
- "0.1.2-rc.1",
34479
+ "0.1.5-rc.2",
34486
34480
  "dsh",
34487
- "sha512-RPq48TzxvwpdT9/7W1tbhZDBMmeK+bxDrX9cqQC27Wx/LqtgJF8PSa3b3xriU8oxtvhwYmk21w2cej3uMQrnVA==",
34488
- "https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.2-rc.1.tgz"
34481
+ "sha512-8Xc8hCQHcIWRmTCVU/xZdp6/qMsWMeAd2ObChKDEsfhUPJFXx6H0lgeb1DxUMD86HZrrVN+1bCvn1ppjZ/fOxw==",
34482
+ "https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.5-rc.2.tgz"
34489
34483
  );
34490
34484
 
34491
34485
  // src/agent-catalog/agents/deepseek-harness-agent.ts
34492
- async function validateAgentHome(path2) {
34486
+ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP bridge to an image-capable route.
34487
+ - id: acp
34488
+ config:
34489
+ provider: deepseek-official
34490
+ model: deepseek-v4-flash-vision-exp
34491
+ `;
34492
+ async function prepareAgentHome(path2, imagePrompts) {
34493
34493
  if (!isAbsolute4(path2) || normalize2(path2) !== path2) {
34494
34494
  throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
34495
34495
  }
34496
34496
  try {
34497
+ if (imagePrompts) {
34498
+ await mkdir2(path2, { mode: 448, recursive: true });
34499
+ }
34497
34500
  const resolved = await realpath4(path2);
34498
34501
  const metadata = await stat4(resolved);
34499
34502
  if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
34500
34503
  throw new Error("Agent home is not a user-owned directory");
34501
34504
  }
34505
+ if (imagePrompts) {
34506
+ await writeFile(join7(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
34507
+ mode: 384
34508
+ });
34509
+ }
34502
34510
  return resolved;
34503
34511
  } catch (error62) {
34504
34512
  if (error62 instanceof AgentProbeError) {
@@ -34533,6 +34541,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
34533
34541
  }
34534
34542
  createLaunchEnvironment = async (agent, context) => {
34535
34543
  let selectedHome = context.environment["DSH_HOME"];
34544
+ let managedHome = false;
34536
34545
  try {
34537
34546
  const managed = await this.resolveManagedAgent(
34538
34547
  readStateDirectory(context.environment),
@@ -34541,6 +34550,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
34541
34550
  );
34542
34551
  if (managed.path === agent.path) {
34543
34552
  selectedHome = join7(readStateDirectory(context.environment), "agents", this.id, "home");
34553
+ managedHome = true;
34544
34554
  }
34545
34555
  } catch {
34546
34556
  context.signal.throwIfAborted();
@@ -34549,7 +34559,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
34549
34559
  return Object.freeze({});
34550
34560
  }
34551
34561
  return Object.freeze({
34552
- DSH_HOME: await validateAgentHome(selectedHome)
34562
+ DSH_HOME: await prepareAgentHome(selectedHome, managedHome)
34553
34563
  });
34554
34564
  };
34555
34565
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
@@ -34564,8 +34574,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
34564
34574
  verifyAcp = (_connection, initialized, _defaultWorkspace, _signal) => {
34565
34575
  const capabilities = initialized.agentCapabilities ?? {};
34566
34576
  const session = capabilities.sessionCapabilities;
34567
- const prompt = capabilities.promptCapabilities;
34568
- 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) {
34577
+ 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) {
34569
34578
  throw new AgentProbeError(
34570
34579
  "acp_incompatible",
34571
34580
  "DeepSeek Harness reported an unsupported ACP capability set"
@@ -34776,7 +34785,7 @@ import { join as join10 } from "node:path";
34776
34785
  // src/agent-installation/managed-agent-archive.ts
34777
34786
  import { createHash } from "node:crypto";
34778
34787
  import { createReadStream } from "node:fs";
34779
- import { chmod, copyFile, mkdir as mkdir2, mkdtemp as mkdtemp2, open as open4, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5, writeFile } from "node:fs/promises";
34788
+ import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open4, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
34780
34789
  import { delimiter as delimiter2, dirname as dirname4, isAbsolute as isAbsolute6, join as join9, relative as relative3, sep as sep3 } from "node:path";
34781
34790
 
34782
34791
  // src/agent-installation/verified-download.ts
@@ -35814,7 +35823,7 @@ async function discoverLocalAgentInventory(options) {
35814
35823
 
35815
35824
  // src/storage/runtime-installation-store.ts
35816
35825
  import { createHash as createHash2, randomUUID } from "node:crypto";
35817
- import { mkdir as mkdir3, open as open5, rename as rename3, unlink, writeFile as writeFile2 } from "node:fs/promises";
35826
+ import { mkdir as mkdir4, open as open5, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
35818
35827
  import { dirname as dirname5, join as join15, resolve as resolve4 } from "node:path";
35819
35828
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
35820
35829
  var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
@@ -36117,9 +36126,9 @@ async function writeJsonAtomically(path2, value, signal) {
36117
36126
  const directory = dirname5(path2);
36118
36127
  const temporaryPath = join15(directory, `.${randomUUID()}.tmp`);
36119
36128
  try {
36120
- await mkdir3(directory, { mode: 448, recursive: true });
36129
+ await mkdir4(directory, { mode: 448, recursive: true });
36121
36130
  signal.throwIfAborted();
36122
- await writeFile2(temporaryPath, `${JSON.stringify(value, null, 2)}
36131
+ await writeFile3(temporaryPath, `${JSON.stringify(value, null, 2)}
36123
36132
  `, { flag: "wx", mode: 384 });
36124
36133
  signal.throwIfAborted();
36125
36134
  await rename3(temporaryPath, path2);
@@ -36150,7 +36159,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
36150
36159
  const rootDirectory = resolve4(options.stateDirectory);
36151
36160
  const applicationDirectory = join15(rootDirectory, "installations", applicationId);
36152
36161
  try {
36153
- await mkdir3(applicationDirectory, { mode: 448, recursive: true });
36162
+ await mkdir4(applicationDirectory, { mode: 448, recursive: true });
36154
36163
  } catch (cause) {
36155
36164
  throw new RuntimeInstallationStoreError(
36156
36165
  "installation_unavailable",
@@ -36163,7 +36172,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
36163
36172
  const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
36164
36173
  const stateDirectory = join15(applicationDirectory, storedInstallationId);
36165
36174
  try {
36166
- await mkdir3(stateDirectory, { mode: 448, recursive: true });
36175
+ await mkdir4(stateDirectory, { mode: 448, recursive: true });
36167
36176
  } catch (cause) {
36168
36177
  throw new RuntimeInstallationStoreError(
36169
36178
  "installation_unavailable",
@@ -36319,7 +36328,7 @@ async function readOrCreateInstallationId(applicationDirectory, signal) {
36319
36328
  }
36320
36329
  const candidate = installationId();
36321
36330
  try {
36322
- await writeFile2(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
36331
+ await writeFile3(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
36323
36332
  `, {
36324
36333
  flag: "wx",
36325
36334
  mode: 384
@@ -36483,7 +36492,7 @@ function parseResumeArgument(arguments_) {
36483
36492
  async function resolveDefaultWorkspace(path2) {
36484
36493
  const requestedWorkspace = resolve5(path2);
36485
36494
  try {
36486
- await mkdir4(requestedWorkspace, { recursive: true, mode: 448 });
36495
+ await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
36487
36496
  const defaultWorkspace = await realpath7(requestedWorkspace);
36488
36497
  const metadata = await stat6(defaultWorkspace);
36489
36498
  if (!metadata.isDirectory()) {
@@ -36705,10 +36714,10 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
36705
36714
  }
36706
36715
 
36707
36716
  // src/run-daemon.ts
36708
- import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
36717
+ import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
36709
36718
  import { basename as basename7 } from "node:path";
36710
36719
  import { styleText } from "node:util";
36711
- import { fetch as fetch6, WebSocket as WebSocket2 } from "undici";
36720
+ import { fetch as fetch5, WebSocket as WebSocket2 } from "undici";
36712
36721
 
36713
36722
  // src/agent-catalog/agent-settings-adapter.ts
36714
36723
  var AGENT_DEFAULT_VALUE = "agent_default";
@@ -37566,391 +37575,6 @@ async function streamLocalFile(command, send2, signal) {
37566
37575
  });
37567
37576
  }
37568
37577
 
37569
- // src/artifacts/runtime-artifact-uploader.ts
37570
- import { createHash as createHash3 } from "node:crypto";
37571
-
37572
- // ../mobius-sdk/src/errors.ts
37573
- var MobiusError = class extends Error {
37574
- code;
37575
- constructor(code, message, options = {}) {
37576
- super(message, options);
37577
- this.code = code;
37578
- this.name = "MobiusError";
37579
- }
37580
- };
37581
- var MobiusProtocolError = class extends MobiusError {
37582
- constructor(message, options = {}) {
37583
- super("invalid_service_response", message, options);
37584
- this.name = "MobiusProtocolError";
37585
- }
37586
- };
37587
- var MobiusValidationError = class extends MobiusError {
37588
- constructor(message, options = {}) {
37589
- super("invalid_request", message, options);
37590
- this.name = "MobiusValidationError";
37591
- }
37592
- };
37593
-
37594
- // ../mobius-sdk/src/resources.ts
37595
- var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
37596
- function invalidResponse(message) {
37597
- return new MobiusProtocolError(message);
37598
- }
37599
- function isRecord11(value) {
37600
- return typeof value === "object" && value !== null && !Array.isArray(value);
37601
- }
37602
- function record2(value, name) {
37603
- if (!isRecord11(value)) {
37604
- throw invalidResponse(`The service returned an invalid ${name}`);
37605
- }
37606
- return value;
37607
- }
37608
- function stringField(value, field, maximumLength = 85e5) {
37609
- const candidate = value[field];
37610
- if (typeof candidate !== "string" || candidate.length > maximumLength) {
37611
- throw invalidResponse(`The service returned an invalid ${field}`);
37612
- }
37613
- return candidate;
37614
- }
37615
- function identifierField(value, field) {
37616
- const candidate = stringField(value, field, 128);
37617
- if (!IDENTIFIER_PATTERN6.test(candidate)) {
37618
- throw invalidResponse(`The service returned an invalid ${field}`);
37619
- }
37620
- return candidate;
37621
- }
37622
- function integerField(value, field) {
37623
- const candidate = value[field];
37624
- if (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0) {
37625
- throw invalidResponse(`The service returned an invalid ${field}`);
37626
- }
37627
- return candidate;
37628
- }
37629
- function validateTimestamp(value, field) {
37630
- if (Number.isNaN(Date.parse(value))) {
37631
- throw invalidResponse(`The service returned an invalid ${field}`);
37632
- }
37633
- return value;
37634
- }
37635
- var MobiusArtifactUploadRequest = class {
37636
- byteLength;
37637
- mediaType;
37638
- name;
37639
- sha256;
37640
- constructor(name, mediaType, byteLength, sha256) {
37641
- 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)) {
37642
- throw new MobiusValidationError("The artifact upload request is invalid");
37643
- }
37644
- this.byteLength = byteLength;
37645
- this.mediaType = mediaType;
37646
- this.name = name;
37647
- this.sha256 = sha256;
37648
- }
37649
- };
37650
- var MobiusArtifact = class {
37651
- artifactId;
37652
- byteLength;
37653
- createdAt;
37654
- mediaType;
37655
- name;
37656
- sessionId;
37657
- sha256;
37658
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt) {
37659
- this.artifactId = artifactId;
37660
- this.byteLength = byteLength;
37661
- this.createdAt = createdAt;
37662
- this.mediaType = mediaType;
37663
- this.name = name;
37664
- this.sessionId = sessionId;
37665
- this.sha256 = sha256;
37666
- }
37667
- };
37668
- var MobiusUploadingArtifact = class extends MobiusArtifact {
37669
- expiresAt;
37670
- state = "uploading";
37671
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiresAt) {
37672
- super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
37673
- this.expiresAt = expiresAt;
37674
- }
37675
- };
37676
- var MobiusArtifactUpload = class extends MobiusUploadingArtifact {
37677
- uploadToken;
37678
- constructor(artifact, uploadToken) {
37679
- super(
37680
- artifact.sessionId,
37681
- artifact.artifactId,
37682
- artifact.name,
37683
- artifact.mediaType,
37684
- artifact.byteLength,
37685
- artifact.sha256,
37686
- artifact.createdAt,
37687
- artifact.expiresAt
37688
- );
37689
- this.uploadToken = uploadToken;
37690
- }
37691
- };
37692
- var MobiusAvailableArtifact = class extends MobiusArtifact {
37693
- availableAt;
37694
- state = "available";
37695
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, availableAt) {
37696
- super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
37697
- this.availableAt = availableAt;
37698
- }
37699
- };
37700
- var MobiusExpiredArtifact = class extends MobiusArtifact {
37701
- expiredAt;
37702
- state = "expired";
37703
- constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiredAt) {
37704
- super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
37705
- this.expiredAt = expiredAt;
37706
- }
37707
- };
37708
- function artifactFields(value) {
37709
- const sha256 = stringField(value, "sha256", 64);
37710
- if (!/^[a-f0-9]{64}$/.test(sha256)) {
37711
- throw invalidResponse("The service returned an invalid artifact digest");
37712
- }
37713
- return {
37714
- artifactId: identifierField(value, "artifactId"),
37715
- byteLength: integerField(value, "byteLength"),
37716
- createdAt: validateTimestamp(stringField(value, "createdAt", 128), "createdAt"),
37717
- mediaType: stringField(value, "mediaType", 255),
37718
- name: stringField(value, "name", 500),
37719
- sessionId: identifierField(value, "sessionId"),
37720
- sha256
37721
- };
37722
- }
37723
- function uploadingArtifact(value) {
37724
- const fields = artifactFields(value);
37725
- return new MobiusUploadingArtifact(
37726
- fields.sessionId,
37727
- fields.artifactId,
37728
- fields.name,
37729
- fields.mediaType,
37730
- fields.byteLength,
37731
- fields.sha256,
37732
- fields.createdAt,
37733
- validateTimestamp(stringField(value, "expiresAt", 128), "expiresAt")
37734
- );
37735
- }
37736
- function decodeMobiusArtifactUpload(value) {
37737
- const artifact = record2(value, "artifact upload authorization");
37738
- return new MobiusArtifactUpload(uploadingArtifact(artifact), stringField(artifact, "uploadToken", 256));
37739
- }
37740
- function decodeMobiusArtifact(value) {
37741
- const artifact = record2(value, "artifact");
37742
- const state = stringField(artifact, "state", 32);
37743
- if (state === "uploading") {
37744
- return uploadingArtifact(artifact);
37745
- }
37746
- const fields = artifactFields(artifact);
37747
- if (state === "available") {
37748
- return new MobiusAvailableArtifact(
37749
- fields.sessionId,
37750
- fields.artifactId,
37751
- fields.name,
37752
- fields.mediaType,
37753
- fields.byteLength,
37754
- fields.sha256,
37755
- fields.createdAt,
37756
- validateTimestamp(stringField(artifact, "availableAt", 128), "availableAt")
37757
- );
37758
- }
37759
- if (state === "expired") {
37760
- return new MobiusExpiredArtifact(
37761
- fields.sessionId,
37762
- fields.artifactId,
37763
- fields.name,
37764
- fields.mediaType,
37765
- fields.byteLength,
37766
- fields.sha256,
37767
- fields.createdAt,
37768
- validateTimestamp(stringField(artifact, "expiredAt", 128), "expiredAt")
37769
- );
37770
- }
37771
- throw invalidResponse("The service returned an invalid artifact state");
37772
- }
37773
- function decodeMobiusAvailableArtifact(value) {
37774
- const artifact = decodeMobiusArtifact(value);
37775
- if (!(artifact instanceof MobiusAvailableArtifact)) {
37776
- throw invalidResponse("The service did not make the artifact available");
37777
- }
37778
- return artifact;
37779
- }
37780
- var MobiusRuntimePairingLifecycle = Object.freeze({
37781
- Expired: "expired",
37782
- Paired: "paired",
37783
- Pending: "pending",
37784
- Revoked: "revoked"
37785
- });
37786
-
37787
- // src/artifacts/runtime-artifact-uploader.ts
37788
- import { fetch as fetch4 } from "undici";
37789
- var UPLOAD_TIMEOUT_MILLISECONDS = 2e4;
37790
- var RuntimeArtifactUploadError = class extends Error {
37791
- code;
37792
- constructor(code, message, options = {}) {
37793
- super(message, options);
37794
- this.code = code;
37795
- this.name = "RuntimeArtifactUploadError";
37796
- }
37797
- };
37798
- var UploadedRuntimeArtifact = class {
37799
- artifactId;
37800
- byteLength;
37801
- mimeType;
37802
- name;
37803
- sha256;
37804
- constructor(artifactId, name, mimeType, byteLength, sha256) {
37805
- this.artifactId = artifactId;
37806
- this.byteLength = byteLength;
37807
- this.mimeType = mimeType;
37808
- this.name = name;
37809
- this.sha256 = sha256;
37810
- }
37811
- };
37812
- function channelOrigin(config2) {
37813
- const url2 = new URL(config2.relayUrl);
37814
- url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
37815
- let channelPath = "";
37816
- if (url2.pathname.endsWith("/daemon")) {
37817
- channelPath = url2.pathname.slice(0, -"/daemon".length);
37818
- } else {
37819
- const runtimePath = `${MOBIUS_API_PREFIX}/v1/runtimes/connect`;
37820
- if (!url2.pathname.endsWith("/v1/runtimes/connect") && !url2.pathname.endsWith(runtimePath)) {
37821
- throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay artifact endpoint is invalid");
37822
- }
37823
- channelPath = `${url2.pathname.replace(/\/v1\/runtimes\/connect$/, "")}/channels/${encodeURIComponent(config2.channelId)}`;
37824
- }
37825
- url2.pathname = channelPath;
37826
- url2.search = "";
37827
- url2.hash = "";
37828
- return url2;
37829
- }
37830
- function uploadError(code, message, cause) {
37831
- return new RuntimeArtifactUploadError(code, message, cause === void 0 ? {} : { cause });
37832
- }
37833
- function translateSdkError(cause) {
37834
- if (cause instanceof MobiusValidationError) {
37835
- throw uploadError("artifact_upload_failed", cause.message, cause);
37836
- }
37837
- if (cause instanceof MobiusProtocolError) {
37838
- throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
37839
- }
37840
- throw cause;
37841
- }
37842
- async function readJson(response) {
37843
- try {
37844
- return await response.json();
37845
- } catch (cause) {
37846
- throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
37847
- }
37848
- }
37849
- async function readAuthorization(response) {
37850
- try {
37851
- return decodeMobiusArtifactUpload(await readJson(response));
37852
- } catch (cause) {
37853
- translateSdkError(cause);
37854
- }
37855
- }
37856
- function sessionArtifactUrl(origin, sessionId, resourcePath) {
37857
- return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
37858
- }
37859
- async function postLease(url2, headers, request, signal) {
37860
- return await fetch4(url2, {
37861
- dispatcher: environmentProxyDispatcher,
37862
- headers: { ...headers, "content-type": "application/json" },
37863
- method: "POST",
37864
- body: JSON.stringify(request),
37865
- signal
37866
- });
37867
- }
37868
- async function putContent(url2, headers, authorization, bytes, signal) {
37869
- return await fetch4(url2, {
37870
- dispatcher: environmentProxyDispatcher,
37871
- headers: {
37872
- ...headers,
37873
- "content-type": authorization.mediaType,
37874
- "x-mobius-upload-token": authorization.uploadToken
37875
- },
37876
- method: "PUT",
37877
- body: bytes,
37878
- signal
37879
- });
37880
- }
37881
- async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
37882
- signal.throwIfAborted();
37883
- let request;
37884
- try {
37885
- request = new MobiusArtifactUploadRequest(
37886
- artifact.name,
37887
- artifact.mimeType,
37888
- artifact.bytes.byteLength,
37889
- createHash3("sha256").update(artifact.bytes).digest("hex")
37890
- );
37891
- } catch (cause) {
37892
- translateSdkError(cause);
37893
- }
37894
- const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
37895
- const requestSignal = AbortSignal.any([signal, timeoutSignal]);
37896
- const origin = channelOrigin(config2);
37897
- const headers = runtimeAuthorization(config2.relayUrl);
37898
- let created;
37899
- try {
37900
- created = await postLease(
37901
- sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
37902
- headers,
37903
- request,
37904
- requestSignal
37905
- );
37906
- } catch (cause) {
37907
- signal.throwIfAborted();
37908
- throw uploadError(
37909
- timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
37910
- timeoutSignal.aborted ? "The artifact upload authorization timed out" : "The artifact upload could not start",
37911
- cause
37912
- );
37913
- }
37914
- if (!created.ok) {
37915
- await created.body?.cancel();
37916
- throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact upload");
37917
- }
37918
- const authorization = await readAuthorization(created);
37919
- let uploaded;
37920
- try {
37921
- uploaded = await putContent(
37922
- sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
37923
- headers,
37924
- authorization,
37925
- artifact.bytes,
37926
- requestSignal
37927
- );
37928
- } catch (cause) {
37929
- signal.throwIfAborted();
37930
- throw uploadError(
37931
- timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
37932
- timeoutSignal.aborted ? "The artifact upload timed out" : "The artifact content could not be uploaded",
37933
- cause
37934
- );
37935
- }
37936
- if (!uploaded.ok) {
37937
- await uploaded.body?.cancel();
37938
- throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact content");
37939
- }
37940
- try {
37941
- const available = decodeMobiusAvailableArtifact(await readJson(uploaded));
37942
- return new UploadedRuntimeArtifact(
37943
- available.artifactId,
37944
- available.name,
37945
- available.mediaType,
37946
- available.byteLength,
37947
- available.sha256
37948
- );
37949
- } catch (cause) {
37950
- translateSdkError(cause);
37951
- }
37952
- }
37953
-
37954
37578
  // src/authorization/workspace-directory.ts
37955
37579
  import { readdir as readdir2, realpath as realpath9, stat as stat8 } from "node:fs/promises";
37956
37580
  import { homedir as homedir2 } from "node:os";
@@ -38770,13 +38394,13 @@ var NativeSessionService = class {
38770
38394
  };
38771
38395
 
38772
38396
  // src/prompt-artifact-resolver.ts
38773
- import { createHash as createHash4 } from "node:crypto";
38774
- import { fetch as fetch5 } from "undici";
38397
+ import { createHash as createHash3 } from "node:crypto";
38398
+ import { fetch as fetch4 } from "undici";
38775
38399
  var ARTIFACT_SCHEME = "mobius-artifact:";
38776
38400
  var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
38777
38401
  var MAX_AGENT_IMAGE_BASE64_LENGTH = 4e6;
38778
38402
  var MAX_AGENT_RESOURCE_BYTE_LENGTH = 1e6;
38779
- var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
38403
+ var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
38780
38404
  var PromptArtifactError = class extends Error {
38781
38405
  code;
38782
38406
  constructor(code, message, options = {}) {
@@ -38819,7 +38443,7 @@ function parseReference(resource) {
38819
38443
  const encodedByteLength2 = url2.searchParams.get("byteLength") ?? "";
38820
38444
  const sha256 = url2.searchParams.get("sha256") ?? "";
38821
38445
  const byteLength = Number(encodedByteLength2);
38822
- 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)) {
38446
+ 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)) {
38823
38447
  throw new PromptArtifactError("artifact_reference_invalid", "The prompt artifact reference is invalid");
38824
38448
  }
38825
38449
  return new PromptArtifactReference(artifactId, byteLength, sha256, resource);
@@ -38885,7 +38509,7 @@ async function download(config2, command, reference, signal) {
38885
38509
  const requestSignal = AbortSignal.any([signal, timeoutSignal]);
38886
38510
  let response;
38887
38511
  try {
38888
- response = await fetch5(downloadUrl(config2, command, reference), {
38512
+ response = await fetch4(downloadUrl(config2, command, reference), {
38889
38513
  dispatcher: environmentProxyDispatcher,
38890
38514
  headers: {
38891
38515
  accept: reference.resource.mimeType,
@@ -38909,7 +38533,7 @@ async function download(config2, command, reference, signal) {
38909
38533
  );
38910
38534
  }
38911
38535
  const bytes = await responseBytes(response, reference.byteLength, requestSignal);
38912
- if (createHash4("sha256").update(bytes).digest("hex") !== reference.sha256) {
38536
+ if (createHash3("sha256").update(bytes).digest("hex") !== reference.sha256) {
38913
38537
  throw new PromptArtifactError(
38914
38538
  "artifact_integrity_failed",
38915
38539
  "The prompt artifact failed integrity validation"
@@ -39994,13 +39618,10 @@ var AGENT_TEXT_MAXIMUM_LENGTH = 1e5;
39994
39618
  var ACTIVE_TURN_RECONCILIATION_TIMEOUT_MILLISECONDS = 2e4;
39995
39619
  var ACTIVE_TURN_RECONCILIATION_CLOSE_CODE = 4009;
39996
39620
  var DaemonAcpObserver = class {
39997
- #config;
39998
39621
  #record;
39999
- constructor(config2, record3) {
40000
- this.#config = config2;
40001
- this.#record = record3;
39622
+ constructor(record2) {
39623
+ this.#record = record2;
40002
39624
  }
40003
- importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
40004
39625
  onCommands = (event) => {
40005
39626
  this.#record(event.sessionId, event);
40006
39627
  return Promise.resolve();
@@ -40218,7 +39839,7 @@ async function reconcileActiveTurn(config2, turn, signal) {
40218
39839
  const requestSignal = AbortSignal.any([signal, timeoutSignal]);
40219
39840
  let response;
40220
39841
  try {
40221
- response = await fetch6(activeTurnReconciliationEndpoint(config2, turn), {
39842
+ response = await fetch5(activeTurnReconciliationEndpoint(config2, turn), {
40222
39843
  body: JSON.stringify({ outcome: { kind: "running" } }),
40223
39844
  dispatcher: environmentProxyDispatcher,
40224
39845
  headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
@@ -40728,7 +40349,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
40728
40349
  resolution: modelEffort.resolution,
40729
40350
  valuesByModel: {}
40730
40351
  };
40731
- return createHash5("sha256").update(
40352
+ return createHash4("sha256").update(
40732
40353
  JSON.stringify({
40733
40354
  adapterVersion: agent.adapterVersion,
40734
40355
  agentId: agent.id,
@@ -42281,7 +41902,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
42281
41902
  }
42282
41903
  publisher.recordAttempt(sessionId, event, attemptId);
42283
41904
  };
42284
- const sessions = new AcpSessionManager(new DaemonAcpObserver(config2, recordSessionEvent), sessionStore);
41905
+ const sessions = new AcpSessionManager(new DaemonAcpObserver(recordSessionEvent), sessionStore);
42285
41906
  const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
42286
41907
  const installationObserver = new DaemonInstallationObserver();
42287
41908
  const diagnostics = new RelayConnectionDiagnostics(audit, config2.channelId, config2.relayUrl);
@@ -42416,9 +42037,9 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
42416
42037
  }
42417
42038
 
42418
42039
  // src/runtime.ts
42419
- import { mkdir as mkdir5, realpath as realpath10, stat as stat9 } from "node:fs/promises";
42040
+ import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
42420
42041
  import { dirname as dirname8, join as join17, resolve as resolve7 } from "node:path";
42421
- var IDENTIFIER_PATTERN8 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
42042
+ var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
42422
42043
  var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
42423
42044
  var MobiusRuntimeConfigurationError = class extends Error {
42424
42045
  code = "runtime_configuration_invalid";
@@ -42470,7 +42091,7 @@ function relayUrlFromConnection(connection) {
42470
42091
  }
42471
42092
  function loadMobiusRuntimeConnection(environment = process.env) {
42472
42093
  const channelId = requiredEnvironmentValue(environment, "MOBIUS_CHANNEL_ID");
42473
- if (!IDENTIFIER_PATTERN8.test(channelId)) {
42094
+ if (!IDENTIFIER_PATTERN7.test(channelId)) {
42474
42095
  throw new MobiusRuntimeConfigurationError("MOBIUS_CHANNEL_ID is invalid");
42475
42096
  }
42476
42097
  return Object.freeze({
@@ -42484,7 +42105,7 @@ function loadMobiusRuntimeConnection(environment = process.env) {
42484
42105
  async function resolveWorkspace(path2) {
42485
42106
  const requested = resolve7(path2);
42486
42107
  try {
42487
- await mkdir5(requested, { recursive: true, mode: 448 });
42108
+ await mkdir6(requested, { recursive: true, mode: 448 });
42488
42109
  const resolved = await realpath10(requested);
42489
42110
  const metadata = await stat9(resolved);
42490
42111
  if (!metadata.isDirectory()) {
@@ -42504,7 +42125,7 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
42504
42125
  const relayUrl = relayUrlFromConnection(connection);
42505
42126
  const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
42506
42127
  const auditDatabasePath = resolve7(connection.auditDatabasePath);
42507
- await mkdir5(dirname8(auditDatabasePath), { recursive: true, mode: 448 });
42128
+ await mkdir6(dirname8(auditDatabasePath), { recursive: true, mode: 448 });
42508
42129
  const inventory = await discoverLocalAgentInventory({
42509
42130
  defaultWorkspace,
42510
42131
  environment: localContext.environment,