@moxt-ai/mobius 0.0.279 → 0.0.280

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.
package/dist/runtime.js CHANGED
@@ -21750,8 +21750,17 @@ var decodeRuntimeDiagnosticsResult = (raw) => runtimeDiagnosticsResultSchema.par
21750
21750
  var encodeRuntimeDiagnosticsRequest = (value) => JSON.stringify(runtimeDiagnosticsRequestSchema.parse(value));
21751
21751
  var encodeRuntimeDiagnosticsResult = (value) => JSON.stringify(runtimeDiagnosticsResultSchema.parse(value));
21752
21752
 
21753
+ // ../mobius-sdk/src/protocol/shared/directory.ts
21754
+ var MAX_WORKSPACE_PATH_LENGTH = 4096;
21755
+ var MAX_DIRECTORY_IDENTIFIER_LENGTH = "path-".length + MAX_WORKSPACE_PATH_LENGTH * 4;
21756
+ var DIRECTORY_IDENTIFIER_PATTERN = new RegExp(
21757
+ `^[a-zA-Z0-9][a-zA-Z0-9_-]{0,${MAX_DIRECTORY_IDENTIFIER_LENGTH - 1}}$`,
21758
+ "u"
21759
+ );
21760
+ var DIRECTORY_IDENTIFIER = external_exports.string().min(1).max(MAX_DIRECTORY_IDENTIFIER_LENGTH).regex(DIRECTORY_IDENTIFIER_PATTERN);
21761
+ var isDirectoryIdentifier = (value) => typeof value === "string" && value.length <= MAX_DIRECTORY_IDENTIFIER_LENGTH && DIRECTORY_IDENTIFIER_PATTERN.test(value);
21762
+
21753
21763
  // ../mobius-sdk/src/protocol/shared/message-codec.ts
21754
- var DIRECTORY_IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
21755
21764
  var ProtocolMessageError = class extends Error {
21756
21765
  code = "invalid_protocol_message";
21757
21766
  constructor(message, options = {}) {
@@ -21809,7 +21818,7 @@ function readDirectoryIdentifiers(value, key, maximumCount) {
21809
21818
  const identifiers = [];
21810
21819
  const unique = /* @__PURE__ */ new Set();
21811
21820
  for (const candidate of field) {
21812
- if (typeof candidate !== "string" || !DIRECTORY_IDENTIFIER_PATTERN.test(candidate) || unique.has(candidate)) {
21821
+ if (!isDirectoryIdentifier(candidate) || unique.has(candidate)) {
21813
21822
  throw new ProtocolMessageError(`Invalid directory in field: ${key}`);
21814
21823
  }
21815
21824
  unique.add(candidate);
@@ -21825,8 +21834,8 @@ function readIdentifier(value, key) {
21825
21834
  }
21826
21835
  }
21827
21836
  function readDirectoryIdentifier(value, key) {
21828
- const field = readString(value, key, 2048);
21829
- if (!DIRECTORY_IDENTIFIER_PATTERN.test(field)) {
21837
+ const field = readString(value, key, MAX_DIRECTORY_IDENTIFIER_LENGTH);
21838
+ if (!isDirectoryIdentifier(field)) {
21830
21839
  throw new ProtocolMessageError(`Invalid directory identifier field: ${key}`);
21831
21840
  }
21832
21841
  return field;
@@ -21867,6 +21876,8 @@ var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
21867
21876
  var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
21868
21877
  var RUNTIME_PING_KIND = "runtime.ping";
21869
21878
  var RUNTIME_PONG_KIND = "runtime.pong";
21879
+ var RUNTIME_HEARTBEAT_MESSAGE = `{"kind":"${RUNTIME_HEARTBEAT_KIND}"}`;
21880
+ var RUNTIME_HEARTBEAT_ACK_MESSAGE = `{"kind":"${RUNTIME_HEARTBEAT_ACK_KIND}"}`;
21870
21881
  function decodeRuntimeLivenessReadyEvent(encoded) {
21871
21882
  const value = parseJson(encoded);
21872
21883
  assertKind(value, RUNTIME_LIVENESS_READY_KIND);
@@ -21875,18 +21886,12 @@ function decodeRuntimeLivenessReadyEvent(encoded) {
21875
21886
  function decodeRuntimeHeartbeatEvent(encoded) {
21876
21887
  const value = parseJson(encoded);
21877
21888
  assertKind(value, RUNTIME_HEARTBEAT_KIND);
21878
- return {
21879
- heartbeatId: readIdentifier(value, "heartbeatId"),
21880
- kind: RUNTIME_HEARTBEAT_KIND
21881
- };
21889
+ return "heartbeatId" in value ? { heartbeatId: readIdentifier(value, "heartbeatId"), kind: RUNTIME_HEARTBEAT_KIND } : { kind: RUNTIME_HEARTBEAT_KIND };
21882
21890
  }
21883
21891
  function decodeRuntimeHeartbeatAckEvent(encoded) {
21884
21892
  const value = parseJson(encoded);
21885
21893
  assertKind(value, RUNTIME_HEARTBEAT_ACK_KIND);
21886
- return {
21887
- heartbeatId: readIdentifier(value, "heartbeatId"),
21888
- kind: RUNTIME_HEARTBEAT_ACK_KIND
21889
- };
21894
+ return "heartbeatId" in value ? { heartbeatId: readIdentifier(value, "heartbeatId"), kind: RUNTIME_HEARTBEAT_ACK_KIND } : { kind: RUNTIME_HEARTBEAT_ACK_KIND };
21890
21895
  }
21891
21896
  function decodeRuntimePingCommand(encoded) {
21892
21897
  const value = parseJson(encoded);
@@ -21902,10 +21907,12 @@ function encodeRuntimeLivenessReadyEvent(message) {
21902
21907
  return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
21903
21908
  }
21904
21909
  function encodeRuntimeHeartbeatEvent(message) {
21905
- return JSON.stringify(decodeRuntimeHeartbeatEvent(JSON.stringify(message)));
21910
+ const decoded = decodeRuntimeHeartbeatEvent(JSON.stringify(message));
21911
+ return "heartbeatId" in decoded ? JSON.stringify(decoded) : RUNTIME_HEARTBEAT_MESSAGE;
21906
21912
  }
21907
21913
  function encodeRuntimeHeartbeatAckEvent(message) {
21908
- return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
21914
+ const decoded = decodeRuntimeHeartbeatAckEvent(JSON.stringify(message));
21915
+ return "heartbeatId" in decoded ? JSON.stringify(decoded) : RUNTIME_HEARTBEAT_ACK_MESSAGE;
21909
21916
  }
21910
21917
  function encodeRuntimePingCommand(message) {
21911
21918
  return JSON.stringify(decodeRuntimePingCommand(JSON.stringify(message)));
@@ -21944,8 +21951,6 @@ var decodeRuntimeUpgradeResult = (raw) => runtimeUpgradeResultSchema.parse(JSON.
21944
21951
  var encodeRuntimeUpgradeResult = (value) => JSON.stringify(runtimeUpgradeResultSchema.parse(value));
21945
21952
 
21946
21953
  // ../mobius-sdk/src/protocol/session/shared/index.ts
21947
- var DIRECTORY_IDENTIFIER_PATTERN2 = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
21948
- var DIRECTORY_IDENTIFIER = external_exports.string().min(1).max(2048).regex(DIRECTORY_IDENTIFIER_PATTERN2);
21949
21954
  var SHORT_TEXT = external_exports.string().max(500);
21950
21955
  var workspaceEntrySchema = external_exports.object({
21951
21956
  directoryId: DIRECTORY_IDENTIFIER,
@@ -22420,7 +22425,7 @@ var sessionMetadataSchema = external_exports.object({
22420
22425
  additionalDirectories: external_exports.array(workspaceEntrySchema).max(16).readonly(),
22421
22426
  agentId: identifierStringSchema,
22422
22427
  directoryId: DIRECTORY_IDENTIFIER,
22423
- directoryLabel: external_exports.string().min(1).max(2048),
22428
+ directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
22424
22429
  prompted: external_exports.boolean(),
22425
22430
  sessionId: identifierStringSchema,
22426
22431
  status: sessionStatusSchema.default({ kind: "idle" }),
@@ -22494,7 +22499,7 @@ var sessionReadyEventSchema = external_exports.object({
22494
22499
  commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
22495
22500
  configOptions: sessionConfigOptionsSchema,
22496
22501
  directoryId: DIRECTORY_IDENTIFIER,
22497
- directoryLabel: external_exports.string().min(1).max(2048),
22502
+ directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
22498
22503
  kind: external_exports.literal(SESSION_READY_KIND),
22499
22504
  requestId: identifierStringSchema,
22500
22505
  restored: external_exports.boolean(),
@@ -22682,7 +22687,6 @@ var NATIVE_SESSION_RESULT_KIND = "native.session.result";
22682
22687
  var NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
22683
22688
  var SESSION_HISTORY_CHARACTER_LIMIT = 256e3;
22684
22689
  var SESSION_HISTORY_MESSAGE_LIMIT = 1e3;
22685
- var directoryId = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
22686
22690
  var envelope = {
22687
22691
  requestId: identifierStringSchema,
22688
22692
  sessionId: identifierStringSchema
@@ -22697,10 +22701,10 @@ var activeTurnSnapshotSchema = external_exports.object({
22697
22701
  var identity = {
22698
22702
  ...envelope,
22699
22703
  kind: external_exports.literal(NATIVE_SESSION_REQUEST_KIND),
22700
- additionalDirectoryIds: external_exports.array(directoryId).max(16).readonly(),
22704
+ additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
22701
22705
  agentId: identifierStringSchema,
22702
22706
  bindingId: identifierStringSchema,
22703
- directoryId
22707
+ directoryId: DIRECTORY_IDENTIFIER
22704
22708
  };
22705
22709
  var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
22706
22710
  external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
@@ -22737,10 +22741,10 @@ var nativeSessionEntrySchema = external_exports.object({
22737
22741
  mobiusSessionIds: external_exports.array(identifierStringSchema).max(500).readonly(),
22738
22742
  nativeSessionId: identifierStringSchema,
22739
22743
  title: external_exports.string().max(500),
22740
- directoryId,
22741
- directoryLabel: external_exports.string().min(1).max(2048),
22744
+ directoryId: DIRECTORY_IDENTIFIER,
22745
+ directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
22742
22746
  updatedAt: external_exports.iso.datetime({ offset: true }).nullable(),
22743
- additionalDirectories: external_exports.array(external_exports.object({ directoryId, name: external_exports.string().min(1).max(255) }).readonly()).max(16).readonly()
22747
+ additionalDirectories: external_exports.array(external_exports.object({ directoryId: DIRECTORY_IDENTIFIER, name: external_exports.string().min(1).max(255) }).readonly()).max(16).readonly()
22744
22748
  }).readonly();
22745
22749
  var resultEnvelope = {
22746
22750
  ...envelope,
@@ -23029,8 +23033,8 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
23029
23033
  var lifecycleBase = { commandId: identifierStringSchema };
23030
23034
  var promptExecutionContextSchema = external_exports.object({
23031
23035
  agentId: identifierStringSchema,
23032
- directoryId: shortString,
23033
- additionalDirectoryIds: external_exports.array(identifierStringSchema).max(16).readonly()
23036
+ directoryId: DIRECTORY_IDENTIFIER,
23037
+ additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly()
23034
23038
  }).readonly();
23035
23039
  var lifecycleMetadataSchema = external_exports.discriminatedUnion("kind", [
23036
23040
  external_exports.object({ kind: external_exports.literal("session.queue.changed") }).readonly(),
@@ -23182,7 +23186,6 @@ var SESSION_HISTORY_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
23182
23186
  var SESSION_HISTORY_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
23183
23187
  var SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
23184
23188
  var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loaded";
23185
- var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
23186
23189
  var pageRequestFields = {
23187
23190
  cursor: external_exports.string().min(1).max(512).nullable(),
23188
23191
  eventLimit: external_exports.number().int().min(1).max(1e4),
@@ -23193,10 +23196,10 @@ var pageRequestFields = {
23193
23196
  var sessionHistoryPageLoadSchema = external_exports.object({ ...pageRequestFields, kind: external_exports.literal(SESSION_HISTORY_PAGE_LOAD_KIND) }).readonly();
23194
23197
  var sessionPreviewHistoryPageLoadSchema = external_exports.object({
23195
23198
  ...pageRequestFields,
23196
- additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
23199
+ additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
23197
23200
  agentId: identifierStringSchema,
23198
23201
  bindingId: identifierStringSchema,
23199
- directoryId: directoryIdentifier,
23202
+ directoryId: DIRECTORY_IDENTIFIER,
23200
23203
  kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND)
23201
23204
  }).readonly();
23202
23205
  var pageLoadedFields = {
@@ -23305,10 +23308,10 @@ var workspaceListCommandSchema = external_exports.object({
23305
23308
  var workspaceEntriesEventSchema = external_exports.object({
23306
23309
  bindingId: identifierStringSchema,
23307
23310
  directoryId: DIRECTORY_IDENTIFIER,
23308
- directoryLabel: external_exports.string().min(1).max(2048),
23311
+ directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
23309
23312
  entries: external_exports.array(workspaceEntrySchema).max(500).readonly(),
23310
23313
  kind: external_exports.literal(WORKSPACE_ENTRIES_KIND),
23311
- parentDirectoryId: external_exports.string().max(2048),
23314
+ parentDirectoryId: external_exports.string().max(MAX_DIRECTORY_IDENTIFIER_LENGTH),
23312
23315
  requestId: identifierStringSchema
23313
23316
  }).readonly();
23314
23317
  var decodeWorkspaceListCommand = (encoded) => decodeZodMessage(encoded, workspaceListCommandSchema);
@@ -87215,12 +87218,11 @@ var RelayConnectionDiagnostics = class {
87215
87218
  false
87216
87219
  );
87217
87220
  };
87218
- heartbeatTimedOut = (connectionEpoch, heartbeatId, timeoutMilliseconds) => {
87221
+ heartbeatTimedOut = (connectionEpoch, timeoutMilliseconds) => {
87219
87222
  this.#record(
87220
87223
  "relay_heartbeat_timed_out",
87221
87224
  {
87222
87225
  connectionEpoch: connectionEpoch.toString(),
87223
- heartbeatId,
87224
87226
  relayOrigin: this.#relayOrigin,
87225
87227
  timeoutMilliseconds: timeoutMilliseconds.toString(),
87226
87228
  ...this.#route
@@ -87267,7 +87269,7 @@ import { WebSocket as WebSocket7 } from "undici";
87267
87269
  // package.json
87268
87270
  var package_default = {
87269
87271
  name: "@moxt-ai/mobius",
87270
- version: "0.0.279",
87272
+ version: "0.0.280",
87271
87273
  description: "Mobius CLI for pairing and running local AI agent services.",
87272
87274
  type: "module",
87273
87275
  bin: {
@@ -89133,8 +89135,8 @@ var ResolvedSessionDirectories = class {
89133
89135
  this.cwd = cwd;
89134
89136
  }
89135
89137
  };
89136
- async function resolveSessionDirectories(directories, bindingId, directoryId2, additionalDirectoryIds, signal) {
89137
- const cwd = await directories.resolve(bindingId, directoryId2, signal);
89138
+ async function resolveSessionDirectories(directories, bindingId, directoryId, additionalDirectoryIds, signal) {
89139
+ const cwd = await directories.resolve(bindingId, directoryId, signal);
89138
89140
  const additionalDirectories = [];
89139
89141
  const additionalDirectoryEntries = [];
89140
89142
  const unique = /* @__PURE__ */ new Set([cwd]);
@@ -90571,7 +90573,6 @@ function connectRelay(url2, signal) {
90571
90573
  }
90572
90574
 
90573
90575
  // src/runtime/relay/liveness.ts
90574
- import { randomUUID as randomUUID14 } from "node:crypto";
90575
90576
  var HEARTBEAT_ACK_TIMEOUT_MILLISECONDS = 1e4;
90576
90577
  var HEARTBEAT_INTERVAL_MILLISECONDS = 2e4;
90577
90578
  var RelayLivenessState = class {
@@ -90579,11 +90580,9 @@ var RelayLivenessState = class {
90579
90580
  var UnsupportedRelayLivenessState = class extends RelayLivenessState {
90580
90581
  };
90581
90582
  var AwaitingHeartbeatAckState = class extends RelayLivenessState {
90582
- heartbeatId;
90583
90583
  timeout;
90584
- constructor(heartbeatId, timeout) {
90584
+ constructor(timeout) {
90585
90585
  super();
90586
- this.heartbeatId = heartbeatId;
90587
90586
  this.timeout = timeout;
90588
90587
  }
90589
90588
  };
@@ -90604,13 +90603,10 @@ var RelayConnectionLiveness = class {
90604
90603
  this.#timer = timer;
90605
90604
  this.#transport = transport;
90606
90605
  }
90607
- acknowledge = (event) => {
90606
+ acknowledge = () => {
90608
90607
  if (!(this.#state instanceof AwaitingHeartbeatAckState)) {
90609
90608
  throw new Error("Unexpected relay heartbeat acknowledgement");
90610
90609
  }
90611
- if (event.heartbeatId !== this.#state.heartbeatId) {
90612
- throw new Error("Relay acknowledged the wrong heartbeat");
90613
- }
90614
90610
  this.#state.timeout.cancel();
90615
90611
  this.#state = new WaitingForHeartbeatState(
90616
90612
  this.#timer.schedule(this.#sendHeartbeat, HEARTBEAT_INTERVAL_MILLISECONDS)
@@ -90646,10 +90642,9 @@ var RelayConnectionLiveness = class {
90646
90642
  if (!(this.#state instanceof AwaitingHeartbeatAckState)) {
90647
90643
  throw new Error("Heartbeat timeout occurred in an invalid state");
90648
90644
  }
90649
- const heartbeatId = this.#state.heartbeatId;
90650
90645
  this.#state.timeout.cancel();
90651
90646
  this.#state = new FinishedRelayLivenessState();
90652
- this.#transport.unresponsive(heartbeatId, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS);
90647
+ this.#transport.unresponsive(HEARTBEAT_ACK_TIMEOUT_MILLISECONDS);
90653
90648
  };
90654
90649
  #sendHeartbeat = () => {
90655
90650
  if (this.#state instanceof WaitingForHeartbeatState) {
@@ -90660,17 +90655,13 @@ var RelayConnectionLiveness = class {
90660
90655
  }
90661
90656
  throw new Error("Heartbeat was scheduled in an invalid state");
90662
90657
  }
90663
- const heartbeatId = randomUUID14();
90664
- this.#state = new AwaitingHeartbeatAckState(
90665
- heartbeatId,
90658
+ const awaiting = new AwaitingHeartbeatAckState(
90666
90659
  this.#timer.schedule(this.#handleTimeout, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS)
90667
90660
  );
90668
- const sent = this.#transport.send({
90669
- heartbeatId,
90670
- kind: RUNTIME_HEARTBEAT_KIND
90671
- });
90672
- if (!sent && this.#state instanceof AwaitingHeartbeatAckState && this.#state.heartbeatId === heartbeatId) {
90673
- this.#state.timeout.cancel();
90661
+ this.#state = awaiting;
90662
+ const sent = this.#transport.send({ kind: RUNTIME_HEARTBEAT_KIND });
90663
+ if (!sent && this.#state === awaiting) {
90664
+ awaiting.timeout.cancel();
90674
90665
  this.#state = new FinishedRelayLivenessState();
90675
90666
  }
90676
90667
  };
@@ -90817,8 +90808,8 @@ async function runRelayConnection({
90817
90808
  throw error62;
90818
90809
  }
90819
90810
  },
90820
- unresponsive: (heartbeatId, timeoutMilliseconds) => {
90821
- diagnostics.heartbeatTimedOut(connectionEpoch, heartbeatId, timeoutMilliseconds);
90811
+ unresponsive: (timeoutMilliseconds) => {
90812
+ diagnostics.heartbeatTimedOut(connectionEpoch, timeoutMilliseconds);
90822
90813
  diagnostics.connectionClosed(
90823
90814
  connectionEpoch,
90824
90815
  4001,
@@ -90869,7 +90860,7 @@ async function runRelayConnection({
90869
90860
  return;
90870
90861
  }
90871
90862
  if (kind === RUNTIME_HEARTBEAT_ACK_KIND) {
90872
- connectionLiveness.acknowledge(message);
90863
+ connectionLiveness.acknowledge();
90873
90864
  return;
90874
90865
  }
90875
90866
  commands.dispatch(message);
@@ -91192,7 +91183,7 @@ var RuntimeSessionEventProjection = class {
91192
91183
  };
91193
91184
 
91194
91185
  // src/runtime/session/turn/active-turn.ts
91195
- import { randomUUID as randomUUID15 } from "node:crypto";
91186
+ import { randomUUID as randomUUID14 } from "node:crypto";
91196
91187
  var ActiveRuntimeTurn = class {
91197
91188
  attemptId;
91198
91189
  command;
@@ -91202,7 +91193,7 @@ var ActiveRuntimeTurn = class {
91202
91193
  #dispatch;
91203
91194
  #sequence = 0;
91204
91195
  #interaction = null;
91205
- #epoch = decodeIdentifier(randomUUID15());
91196
+ #epoch = decodeIdentifier(randomUUID14());
91206
91197
  constructor(command, attemptId) {
91207
91198
  this.attemptId = attemptId;
91208
91199
  this.command = command;
@@ -91484,8 +91475,8 @@ var WorkspaceDirectoryListing = class {
91484
91475
  directoryLabel;
91485
91476
  entries;
91486
91477
  parentDirectoryId;
91487
- constructor(directoryId2, directoryLabel, entries, parentDirectoryId) {
91488
- this.directoryId = directoryId2;
91478
+ constructor(directoryId, directoryLabel, entries, parentDirectoryId) {
91479
+ this.directoryId = directoryId;
91489
91480
  this.directoryLabel = directoryLabel;
91490
91481
  this.entries = entries;
91491
91482
  this.parentDirectoryId = parentDirectoryId;
@@ -91493,7 +91484,7 @@ var WorkspaceDirectoryListing = class {
91493
91484
  };
91494
91485
  function encodePath(path7) {
91495
91486
  const encoded = Buffer.from(path7, "utf8").toString("base64url");
91496
- if (encoded.length === 0 || encoded.length > 2e3) {
91487
+ if (path7.length === 0 || path7.length > MAX_WORKSPACE_PATH_LENGTH || encoded.length + "path-".length > MAX_DIRECTORY_IDENTIFIER_LENGTH) {
91497
91488
  throw new LocalAuthorizationError("The local directory path is too long to select");
91498
91489
  }
91499
91490
  return `path-${encoded}`;
@@ -91503,12 +91494,12 @@ function expandCurrentUserHome(path7) {
91503
91494
  }
91504
91495
  function decodePath(value, prefix) {
91505
91496
  const encoded = value.slice(prefix.length);
91506
- if (encoded.length === 0 || encoded.length > 2e3 || !/^[a-zA-Z0-9_-]+$/.test(encoded)) {
91497
+ if (encoded.length === 0 || value.length > MAX_DIRECTORY_IDENTIFIER_LENGTH || !/^[a-zA-Z0-9_-]+$/.test(encoded)) {
91507
91498
  throw new LocalAuthorizationError("The directory identifier is invalid");
91508
91499
  }
91509
91500
  const decoded = Buffer.from(encoded, "base64url").toString("utf8");
91510
91501
  const normalized = process.platform === "win32" && decoded.startsWith("~/") ? normalize3(decoded).replaceAll("\\", "/") : normalize3(decoded);
91511
- if (Buffer.from(decoded, "utf8").toString("base64url") !== encoded || decoded.includes("\0") || normalized !== decoded) {
91502
+ if (Buffer.from(decoded, "utf8").toString("base64url") !== encoded || decoded.length > MAX_WORKSPACE_PATH_LENGTH || decoded.includes("\0") || normalized !== decoded) {
91512
91503
  throw new LocalAuthorizationError("The directory identifier is invalid");
91513
91504
  }
91514
91505
  return decoded;